Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/sun/nio/ch/sctp/Sctp.h
32303 views
/*1* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef SUN_NIO_CH_SCTP_H26#define SUN_NIO_CH_SCTP_H2728#ifdef __solaris__2930#define _XPG4_231#define __EXTENSIONS__32#include <sys/socket.h>33#include <netinet/sctp.h>34#include "jni.h"3536/* Current Solaris headers don't comply with draft rfc */37#ifndef SCTP_EOF38#define SCTP_EOF MSG_EOF39#endif4041#ifndef SCTP_UNORDERED42#define SCTP_UNORDERED MSG_UNORDERED43#endif4445/* The current version of the socket API extension shipped with Solaris does46* not define the following options that the Java API (optionally) supports */47#ifndef SCTP_EXPLICIT_EOR48#define SCTP_EXPLICIT_EOR -149#endif50#ifndef SCTP_FRAGMENT_INTERLEAVE51#define SCTP_FRAGMENT_INTERLEAVE -152#endif53#ifndef SCTP_SET_PEER_PRIMARY_ADDR54#define SCTP_SET_PEER_PRIMARY_ADDR -155#endif5657/* Function types to support dynamic linking of socket API extension functions58* for SCTP. This is so that there is no linkage depandancy during build or59* runtime for libsctp.*/60typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);61typedef int sctp_freeladdrs_func(void* addrs);62typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);63typedef int sctp_freepaddrs_func(void *addrs);64typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);65typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);66676869#else /* __linux__ */70#include <stdint.h>71#include <linux/types.h>72#include <sys/socket.h>73#include <netinet/in.h>74#include "jni.h"7576//Causes compiler error if not found, should make warning and uncomment77/*#include <netinet/sctp.h>*/7879#ifndef IPPROTO_SCTP80#define IPPROTO_SCTP 13281#endif8283/* The current version of lksctp does84* not define the following option that the Java API (optionally) supports */85#ifndef SCTP_EXPLICIT_EOR86#define SCTP_EXPLICIT_EOR -187#endif8889/* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */90#ifndef SCTP_INITMSG9192enum sctp_optname {93SCTP_RTOINFO,94#define SCTP_RTOINFO SCTP_RTOINFO95SCTP_ASSOCINFO,96#define SCTP_ASSOCINFO SCTP_ASSOCINFO97SCTP_INITMSG,98#define SCTP_INITMSG SCTP_INITMSG99SCTP_NODELAY, /* Get/set nodelay option. */100#define SCTP_NODELAY SCTP_NODELAY101SCTP_AUTOCLOSE,102#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE103SCTP_SET_PEER_PRIMARY_ADDR,104#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR105SCTP_PRIMARY_ADDR,106#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR107SCTP_ADAPTATION_LAYER,108#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER109SCTP_DISABLE_FRAGMENTS,110#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS111SCTP_PEER_ADDR_PARAMS,112#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS113SCTP_DEFAULT_SEND_PARAM,114#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM115SCTP_EVENTS,116#define SCTP_EVENTS SCTP_EVENTS117SCTP_I_WANT_MAPPED_V4_ADDR, /* Turn on/off mapped v4 addresses */118#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR119SCTP_MAXSEG, /* Get/set maximum fragment. */120#define SCTP_MAXSEG SCTP_MAXSEG121SCTP_STATUS,122#define SCTP_STATUS SCTP_STATUS123SCTP_GET_PEER_ADDR_INFO,124#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO125SCTP_DELAYED_ACK_TIME,126#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME127SCTP_CONTEXT, /* Receive Context */128#define SCTP_CONTEXT SCTP_CONTEXT129SCTP_FRAGMENT_INTERLEAVE,130#define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE131SCTP_PARTIAL_DELIVERY_POINT, /* Set/Get partial delivery point */132#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT133SCTP_MAX_BURST, /* Set/Get max burst */134#define SCTP_MAX_BURST SCTP_MAX_BURST135};136137enum sctp_sac_state {138SCTP_COMM_UP,139SCTP_COMM_LOST,140SCTP_RESTART,141SCTP_SHUTDOWN_COMP,142SCTP_CANT_STR_ASSOC,143};144145enum sctp_spc_state {146SCTP_ADDR_AVAILABLE,147SCTP_ADDR_UNREACHABLE,148SCTP_ADDR_REMOVED,149SCTP_ADDR_ADDED,150SCTP_ADDR_MADE_PRIM,151SCTP_ADDR_CONFIRMED,152};153154enum sctp_sinfo_flags {155SCTP_UNORDERED = 1, /* Send/receive message unordered. */156SCTP_ADDR_OVER = 2, /* Override the primary destination. */157SCTP_ABORT=4, /* Send an ABORT message to the peer. */158SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */159};160161enum sctp_sn_type {162SCTP_SN_TYPE_BASE = (1<<15),163SCTP_ASSOC_CHANGE,164SCTP_PEER_ADDR_CHANGE,165SCTP_SEND_FAILED,166SCTP_REMOTE_ERROR,167SCTP_SHUTDOWN_EVENT,168SCTP_PARTIAL_DELIVERY_EVENT,169SCTP_ADAPTATION_INDICATION,170};171172typedef enum sctp_cmsg_type {173SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */174#define SCTP_INIT SCTP_INIT175SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */176#define SCTP_SNDRCV SCTP_SNDRCV177} sctp_cmsg_t;178179enum sctp_msg_flags {180MSG_NOTIFICATION = 0x8000,181#define MSG_NOTIFICATION MSG_NOTIFICATION182};183184#define SCTP_BINDX_ADD_ADDR 0x01185#define SCTP_BINDX_REM_ADDR 0x02186187typedef __s32 sctp_assoc_t;188189struct sctp_initmsg {190__u16 sinit_num_ostreams;191__u16 sinit_max_instreams;192__u16 sinit_max_attempts;193__u16 sinit_max_init_timeo;194};195196struct sctp_sndrcvinfo {197__u16 sinfo_stream;198__u16 sinfo_ssn;199__u16 sinfo_flags;200__u32 sinfo_ppid;201__u32 sinfo_context;202__u32 sinfo_timetolive;203__u32 sinfo_tsn;204__u32 sinfo_cumtsn;205sctp_assoc_t sinfo_assoc_id;206};207208struct sctp_event_subscribe {209__u8 sctp_data_io_event;210__u8 sctp_association_event;211__u8 sctp_address_event;212__u8 sctp_send_failure_event;213__u8 sctp_peer_error_event;214__u8 sctp_shutdown_event;215__u8 sctp_partial_delivery_event;216__u8 sctp_adaptation_layer_event;217};218219struct sctp_send_failed {220__u16 ssf_type;221__u16 ssf_flags;222__u32 ssf_length;223__u32 ssf_error;224struct sctp_sndrcvinfo ssf_info;225sctp_assoc_t ssf_assoc_id;226__u8 ssf_data[0];227};228229struct sctp_assoc_change {230__u16 sac_type;231__u16 sac_flags;232__u32 sac_length;233__u16 sac_state;234__u16 sac_error;235__u16 sac_outbound_streams;236__u16 sac_inbound_streams;237sctp_assoc_t sac_assoc_id;238__u8 sac_info[0];239};240241struct sctp_shutdown_event {242__u16 sse_type;243__u16 sse_flags;244__u32 sse_length;245sctp_assoc_t sse_assoc_id;246};247248struct sctp_paddr_change {249__u16 spc_type;250__u16 spc_flags;251__u32 spc_length;252struct sockaddr_storage spc_aaddr;253int spc_state;254int spc_error;255sctp_assoc_t spc_assoc_id;256} __attribute__((packed, aligned(4)));257258struct sctp_remote_error {259__u16 sre_type;260__u16 sre_flags;261__u32 sre_length;262__u16 sre_error;263sctp_assoc_t sre_assoc_id;264__u8 sre_data[0];265};266267struct sctp_adaptation_event {268__u16 sai_type;269__u16 sai_flags;270__u32 sai_length;271__u32 sai_adaptation_ind;272sctp_assoc_t sai_assoc_id;273};274275struct sctp_setprim {276sctp_assoc_t ssp_assoc_id;277struct sockaddr_storage ssp_addr;278} __attribute__((packed, aligned(4)));279280struct sctp_setpeerprim {281sctp_assoc_t sspp_assoc_id;282struct sockaddr_storage sspp_addr;283} __attribute__((packed, aligned(4)));284285286struct sctp_pdapi_event {287__u16 pdapi_type;288__u16 pdapi_flags;289__u32 pdapi_length;290__u32 pdapi_indication;291sctp_assoc_t pdapi_assoc_id;292};293294union sctp_notification {295struct {296__u16 sn_type; /* Notification type. */297__u16 sn_flags;298__u32 sn_length;299} sn_header;300struct sctp_assoc_change sn_assoc_change;301struct sctp_paddr_change sn_paddr_change;302struct sctp_remote_error sn_remote_error;303struct sctp_send_failed sn_send_failed;304struct sctp_shutdown_event sn_shutdown_event;305struct sctp_adaptation_event sn_adaptation_event;306struct sctp_pdapi_event sn_pdapi_event;307};308309#endif /* SCTP_INITMSG */310311/* Function types to support dynamic linking of socket API extension functions312* for SCTP. This is so that there is no linkage depandancy during build or313* runtime for libsctp.*/314typedef int sctp_getladdrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);315typedef int sctp_freeladdrs_func(struct sockaddr *addrs);316typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);317typedef int sctp_freepaddrs_func(struct sockaddr *addrs);318typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);319typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);320321322#endif /* __linux__ */323324extern sctp_getladdrs_func* nio_sctp_getladdrs;325extern sctp_freeladdrs_func* nio_sctp_freeladdrs;326extern sctp_getpaddrs_func* nio_sctp_getpaddrs;327extern sctp_freepaddrs_func* nio_sctp_freepaddrs;328extern sctp_bindx_func* nio_sctp_bindx;329extern sctp_peeloff_func* nio_sctp_peeloff;330331jboolean loadSocketExtensionFuncs(JNIEnv* env);332333#endif /* !SUN_NIO_CH_SCTP_H */334335336