Home | History | Annotate | Line # | Download | only in netinet
sctp_uio.h revision 1.1
      1 /*	$KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $	*/
      2 /*	$NetBSD: sctp_uio.h,v 1.1 2015/10/13 21:28:35 rjs Exp $ */
      3 
      4 #ifndef __SCTP_UIO_H__
      5 #define __SCTP_UIO_H__
      6 
      7 /*
      8  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *      This product includes software developed by Cisco Systems, Inc.
     22  * 4. Neither the name of the project nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  */
     38 
     39 #include <sys/types.h>
     40 #include <sys/socket.h>
     41 
     42 typedef u_int32_t sctp_assoc_t;
     43 
     44 /* On/Off setup for subscription to events */
     45 struct sctp_event_subscribe {
     46 	u_int8_t sctp_data_io_event;
     47 	u_int8_t sctp_association_event;
     48 	u_int8_t sctp_address_event;
     49 	u_int8_t sctp_send_failure_event;
     50 	u_int8_t sctp_peer_error_event;
     51 	u_int8_t sctp_shutdown_event;
     52 	u_int8_t sctp_partial_delivery_event;
     53 	u_int8_t sctp_adaption_layer_event;
     54 	u_int8_t sctp_stream_reset_events;
     55 };
     56 
     57 /* ancillary data types */
     58 #define SCTP_INIT	0x0001
     59 #define SCTP_SNDRCV	0x0002
     60 
     61 /*
     62  * ancillary data structures
     63  */
     64 struct sctp_initmsg {
     65 	u_int32_t sinit_num_ostreams;
     66 	u_int32_t sinit_max_instreams;
     67 	u_int16_t sinit_max_attempts;
     68 	u_int16_t sinit_max_init_timeo;
     69 };
     70 
     71 struct sctp_sndrcvinfo {
     72 	u_int16_t sinfo_stream;
     73 	u_int16_t sinfo_ssn;
     74 	u_int16_t sinfo_flags;
     75 	u_int32_t sinfo_ppid;
     76 	u_int32_t sinfo_context;
     77 	u_int32_t sinfo_timetolive;
     78 	u_int32_t sinfo_tsn;
     79 	u_int32_t sinfo_cumtsn;
     80 	sctp_assoc_t sinfo_assoc_id;
     81 };
     82 
     83 struct sctp_snd_all_completes {
     84 	u_int16_t sall_stream;
     85 	u_int16_t sall_flags;
     86 	u_int32_t sall_ppid;
     87 	u_int32_t sall_context;
     88 	u_int32_t sall_num_sent;
     89 	u_int32_t sall_num_failed;
     90 };
     91 
     92 /* send/recv flags */
     93 /* MSG_EOF (0x0100) is reused from sys/socket.h */
     94 #define MSG_SENDALL     0x0200
     95 #define MSG_PR_SCTP_TTL	0x0400	/* Partial Reliable on this msg */
     96 #define MSG_PR_SCTP_BUF	0x0800	/* Buffer based PR-SCTP */
     97 #ifndef MSG_EOF
     98 #define MSG_EOF 	0x1000	/* Start shutdown procedures */
     99 #endif
    100 #define MSG_UNORDERED 	0x2000	/* Message is un-ordered */
    101 #define MSG_ADDR_OVER	0x4000	/* Override the primary-address */
    102 #define MSG_ABORT	0x8000	/* Send an ABORT to peer */
    103 
    104 /* Stat's */
    105 struct sctp_pcbinfo {
    106 	u_int32_t ep_count;
    107 	u_int32_t asoc_count;
    108 	u_int32_t laddr_count;
    109 	u_int32_t raddr_count;
    110 	u_int32_t chk_count;
    111 	u_int32_t sockq_count;
    112 	u_int32_t mbuf_track;
    113 };
    114 
    115 struct sctp_sockstat {
    116 	sctp_assoc_t ss_assoc_id;
    117 	u_int32_t ss_total_sndbuf;
    118 	u_int32_t ss_total_mbuf_sndbuf;
    119 	u_int32_t ss_total_recv_buf;
    120 };
    121 
    122 /*
    123  * notification event structures
    124  */
    125 
    126 
    127 /* association change events */
    128 
    129 struct sctp_assoc_change {
    130 	u_int16_t sac_type;
    131 	u_int16_t sac_flags;
    132 	u_int32_t sac_length;
    133 	u_int16_t sac_state;
    134 	u_int16_t sac_error;
    135 	u_int16_t sac_outbound_streams;
    136 	u_int16_t sac_inbound_streams;
    137 	sctp_assoc_t sac_assoc_id;
    138 };
    139 /* sac_state values */
    140 
    141 #define SCTP_COMM_UP		0x0001
    142 #define SCTP_COMM_LOST		0x0002
    143 #define SCTP_RESTART		0x0003
    144 #define SCTP_SHUTDOWN_COMP	0x0004
    145 #define SCTP_CANT_STR_ASSOC	0x0005
    146 
    147 
    148 /* Address events */
    149 struct sctp_paddr_change {
    150 	u_int16_t spc_type;
    151 	u_int16_t spc_flags;
    152 	u_int32_t spc_length;
    153 	struct sockaddr_storage spc_aaddr;
    154 	u_int32_t spc_state;
    155 	u_int32_t spc_error;
    156 	sctp_assoc_t spc_assoc_id;
    157 };
    158 /* paddr state values */
    159 #define SCTP_ADDR_AVAILABLE	0x0001
    160 #define SCTP_ADDR_UNREACHABLE	0x0002
    161 #define SCTP_ADDR_REMOVED	0x0003
    162 #define SCTP_ADDR_ADDED		0x0004
    163 #define SCTP_ADDR_MADE_PRIM	0x0005
    164 #define SCTP_ADDR_CONFIRMED	0x0006
    165 
    166 /*
    167  * CAUTION: these are user exposed SCTP addr reachability states
    168  *          must be compatible with SCTP_ADDR states in sctp_constants.h
    169  */
    170 #ifdef SCTP_ACTIVE
    171 #undef SCTP_ACTIVE
    172 #endif
    173 #define SCTP_ACTIVE		0x0001	/* SCTP_ADDR_REACHABLE */
    174 
    175 #ifdef SCTP_INACTIVE
    176 #undef SCTP_INACTIVE
    177 #endif
    178 #define SCTP_INACTIVE		0x0002	/* SCTP_ADDR_NOT_REACHABLE */
    179 
    180 
    181 #ifdef SCTP_UNCONFIRMED
    182 #undef SCTP_UNCONFIRMED
    183 #endif
    184 #define SCTP_UNCONFIRMED	0x0200  /* SCTP_ADDR_UNCONFIRMED */
    185 
    186 #ifdef SCTP_NOHEARTBEAT
    187 #undef SCTP_NOHEARTBEAT
    188 #endif
    189 #define SCTP_NOHEARTBEAT        0x0040 /* SCTP_ADDR_NOHB */
    190 
    191 
    192 
    193 
    194 /* remote error events */
    195 struct sctp_remote_error {
    196 	u_int16_t sre_type;
    197 	u_int16_t sre_flags;
    198 	u_int32_t sre_length;
    199 	u_int16_t sre_error;
    200 	sctp_assoc_t sre_assoc_id;
    201 	u_int8_t  sre_data[4];
    202 };
    203 
    204 /* data send failure event */
    205 struct sctp_send_failed {
    206 	u_int16_t ssf_type;
    207 	u_int16_t ssf_flags;
    208 	u_int32_t ssf_length;
    209 	u_int32_t ssf_error;
    210 	struct sctp_sndrcvinfo ssf_info;
    211 	sctp_assoc_t ssf_assoc_id;
    212 	u_int8_t ssf_data[4];
    213 };
    214 
    215 /* flag that indicates state of data */
    216 #define SCTP_DATA_UNSENT	0x0001	/* inqueue never on wire */
    217 #define SCTP_DATA_SENT		0x0002	/* on wire at failure */
    218 
    219 /* shutdown event */
    220 struct sctp_shutdown_event {
    221 	u_int16_t	sse_type;
    222 	u_int16_t	sse_flags;
    223 	u_int32_t	sse_length;
    224 	sctp_assoc_t	sse_assoc_id;
    225 };
    226 
    227 /* Adaption layer indication stuff */
    228 struct sctp_adaption_event {
    229 	u_int16_t	sai_type;
    230 	u_int16_t	sai_flags;
    231 	u_int32_t	sai_length;
    232 	u_int32_t	sai_adaption_ind;
    233 	sctp_assoc_t	sai_assoc_id;
    234 };
    235 
    236 struct sctp_setadaption {
    237 	u_int32_t	ssb_adaption_ind;
    238 };
    239 
    240 /* pdapi indications */
    241 struct sctp_pdapi_event {
    242 	u_int16_t	pdapi_type;
    243 	u_int16_t	pdapi_flags;
    244 	u_int32_t	pdapi_length;
    245 	u_int32_t	pdapi_indication;
    246 	sctp_assoc_t	pdapi_assoc_id;
    247 };
    248 
    249 
    250 #define SCTP_PARTIAL_DELIVERY_ABORTED	0x0001
    251 
    252 /* stream reset stuff */
    253 
    254 struct sctp_stream_reset_event {
    255 	u_int16_t	strreset_type;
    256 	u_int16_t	strreset_flags;
    257 	u_int32_t	strreset_length;
    258 	sctp_assoc_t    strreset_assoc_id;
    259 	u_int16_t       strreset_list[0];
    260 };
    261 
    262 /* flags in strreset_flags filed */
    263 #define SCTP_STRRESET_INBOUND_STR  0x0001
    264 #define SCTP_STRRESET_OUTBOUND_STR 0x0002
    265 #define SCTP_STRRESET_ALL_STREAMS  0x0004
    266 #define SCTP_STRRESET_STREAM_LIST  0x0008
    267 
    268 #define MAX_ASOC_IDS_RET 255
    269 
    270 struct sctp_assoc_ids {
    271 	u_int16_t asls_assoc_start;	/* array of index's start at 0 */
    272 	u_int8_t asls_numb_present;
    273 	u_int8_t asls_more_to_get;
    274 	sctp_assoc_t asls_assoc_id[MAX_ASOC_IDS_RET];
    275 };
    276 
    277 /* notification types */
    278 #define SCTP_ASSOC_CHANGE		0x0001
    279 #define SCTP_PEER_ADDR_CHANGE		0x0002
    280 #define SCTP_REMOTE_ERROR		0x0003
    281 #define SCTP_SEND_FAILED		0x0004
    282 #define SCTP_SHUTDOWN_EVENT		0x0005
    283 #define SCTP_ADAPTION_INDICATION	0x0006
    284 #define SCTP_PARTIAL_DELIVERY_EVENT	0x0007
    285 #define SCTP_STREAM_RESET_EVENT         0x0008
    286 
    287 
    288 
    289 struct sctp_tlv {
    290 	u_int16_t sn_type;
    291 	u_int16_t sn_flags;
    292 	u_int32_t sn_length;
    293 };
    294 
    295 
    296 /* notification event */
    297 union sctp_notification {
    298 	struct sctp_tlv sn_header;
    299 	struct sctp_assoc_change sn_assoc_change;
    300 	struct sctp_paddr_change sn_paddr_change;
    301 	struct sctp_remote_error sn_remote_error;
    302 	struct sctp_send_failed	sn_send_failed;
    303 	struct sctp_shutdown_event sn_shutdown_event;
    304 	struct sctp_adaption_event sn_adaption_event;
    305 	struct sctp_pdapi_event sn_pdapi_event;
    306 	struct sctp_stream_reset_event sn_strreset_event;
    307 };
    308 
    309 /*
    310  * socket option structs
    311  */
    312 #define SCTP_ISSUE_HB 0xffffffff	/* get a on-demand hb */
    313 #define SCTP_NO_HB    0x0		/* turn off hb's */
    314 
    315 struct sctp_paddrparams {
    316 	sctp_assoc_t spp_assoc_id;
    317 	struct sockaddr_storage spp_address;
    318 	u_int32_t spp_hbinterval;
    319 	u_int16_t spp_pathmaxrxt;
    320 };
    321 
    322 struct sctp_paddrinfo {
    323 	sctp_assoc_t spinfo_assoc_id;
    324 	struct sockaddr_storage spinfo_address;
    325 	int32_t spinfo_state;
    326 	u_int32_t spinfo_cwnd;
    327 	u_int32_t spinfo_srtt;
    328 	u_int32_t spinfo_rto;
    329 	u_int32_t spinfo_mtu;
    330 };
    331 
    332 struct sctp_rtoinfo {
    333 	sctp_assoc_t srto_assoc_id;
    334 	u_int32_t srto_initial;
    335 	u_int32_t srto_max;
    336 	u_int32_t srto_min;
    337 };
    338 
    339 struct sctp_assocparams {
    340 	sctp_assoc_t sasoc_assoc_id;
    341 	u_int16_t sasoc_asocmaxrxt;
    342         u_int16_t sasoc_number_peer_destinations;
    343         u_int32_t sasoc_peer_rwnd;
    344         u_int32_t sasoc_local_rwnd;
    345         u_int32_t sasoc_cookie_life;
    346 };
    347 
    348 struct sctp_setprim {
    349 	sctp_assoc_t ssp_assoc_id;
    350 	struct sockaddr_storage ssp_addr;
    351 };
    352 
    353 struct sctp_setpeerprim {
    354 	sctp_assoc_t sspp_assoc_id;
    355 	struct sockaddr_storage sspp_addr;
    356 };
    357 
    358 struct sctp_getaddresses {
    359 	sctp_assoc_t sget_assoc_id;
    360 	/* addr is filled in for N * sockaddr_storage */
    361 	struct sockaddr addr[1];
    362 };
    363 
    364 struct sctp_setstrm_timeout {
    365 	sctp_assoc_t ssto_assoc_id;
    366 	u_int32_t ssto_timeout;
    367 	u_int32_t ssto_streamid_start;
    368 	u_int32_t ssto_streamid_end;
    369 };
    370 
    371 struct sctp_status {
    372 	sctp_assoc_t sstat_assoc_id;
    373 	int32_t sstat_state;
    374 	u_int32_t sstat_rwnd;
    375 	u_int16_t sstat_unackdata;
    376 	u_int16_t sstat_penddata;
    377         u_int16_t sstat_instrms;
    378         u_int16_t sstat_outstrms;
    379         u_int32_t sstat_fragmentation_point;
    380 	struct sctp_paddrinfo sstat_primary;
    381 };
    382 
    383 struct sctp_cwnd_args {
    384 	struct sctp_nets *net;		/* network to */
    385 	u_int32_t cwnd_new_value;	/* cwnd in k */
    386 	u_int32_t inflight;		/* flightsize in k */
    387 	int cwnd_augment;		/* increment to it */
    388 };
    389 
    390 struct sctp_blk_args {
    391 	u_int32_t onmb;			/* in 1k bytes */
    392 	u_int32_t onsb;			/* in 1k bytes */
    393 	u_int16_t maxmb;		/* in 1k bytes */
    394 	u_int16_t maxsb;		/* in 1k bytes */
    395 	u_int16_t send_sent_qcnt;	/* chnk cnt */
    396 	u_int16_t stream_qcnt;		/* chnk cnt */
    397 };
    398 
    399 /*
    400  * Max we can reset in one setting, note this is dictated not by the
    401  * define but the size of a mbuf cluster so don't change this define
    402  * and think you can specify more. You must do multiple resets if you
    403  * want to reset more than SCTP_MAX_EXPLICIT_STR_RESET.
    404  */
    405 #define SCTP_MAX_EXPLICT_STR_RESET   1000
    406 
    407 #define SCTP_RESET_LOCAL_RECV  0x0001
    408 #define SCTP_RESET_LOCAL_SEND  0x0002
    409 #define SCTP_RESET_BOTH        0x0003
    410 
    411 struct sctp_stream_reset {
    412 	sctp_assoc_t strrst_assoc_id;
    413 	u_int16_t    strrst_flags;
    414 	u_int16_t    strrst_num_streams;	/* 0 == ALL */
    415 	u_int16_t    strrst_list[0];		/* list if strrst_num_streams is not 0*/
    416 };
    417 
    418 
    419 struct sctp_get_nonce_values {
    420 	sctp_assoc_t gn_assoc_id;
    421 	u_int32_t    gn_peers_tag;
    422 	u_int32_t    gn_local_tag;
    423 };
    424 
    425 /* Debugging logs */
    426 struct sctp_str_log{
    427 	u_int32_t n_tsn;
    428 	u_int32_t e_tsn;
    429 	u_int16_t n_sseq;
    430 	u_int16_t e_sseq;
    431 };
    432 
    433 struct sctp_fr_log {
    434 	u_int32_t largest_tsn;
    435 	u_int32_t largest_new_tsn;
    436 	u_int32_t tsn;
    437 };
    438 
    439 struct sctp_fr_map {
    440 	u_int32_t base;
    441 	u_int32_t cum;
    442 	u_int32_t high;
    443 };
    444 
    445 struct sctp_rwnd_log {
    446 	u_int32_t rwnd;
    447 	u_int32_t send_size;
    448 	u_int32_t overhead;
    449 	u_int32_t new_rwnd;
    450 };
    451 
    452 struct sctp_mbcnt_log {
    453 	u_int32_t total_queue_size;
    454 	u_int32_t size_change;
    455 	u_int32_t total_queue_mb_size;
    456 	u_int32_t mbcnt_change;
    457 };
    458 
    459 struct sctp_cwnd_log{
    460 	union {
    461 		struct sctp_blk_args blk;
    462 		struct sctp_cwnd_args cwnd;
    463 		struct sctp_str_log strlog;
    464 		struct sctp_fr_log fr;
    465 		struct sctp_fr_map map;
    466 		struct sctp_rwnd_log rwnd;
    467 		struct sctp_mbcnt_log mbcnt;
    468 	}x;
    469 	u_int8_t from;
    470 	u_int8_t event_type;
    471 
    472 };
    473 
    474 struct sctp_cwnd_log_req{
    475 	int num_in_log;     /* Number in log */
    476 	int num_ret;        /* Number returned */
    477 	int start_at;       /* start at this one */
    478 	int end_at;         /* end at this one */
    479 	struct sctp_cwnd_log log[0];
    480 };
    481 
    482 
    483 
    484 /*
    485  * API system calls
    486  */
    487 #if !defined(_KERNEL)
    488 
    489 __BEGIN_DECLS
    490 int sctp_peeloff(int, sctp_assoc_t);
    491 int	sctp_bindx(int, struct sockaddr *, int, int);
    492 int     sctp_connectx(int, struct sockaddr *, int);
    493 int	sctp_getpaddrs(int, sctp_assoc_t, struct sockaddr **);
    494 void	sctp_freepaddrs(struct sockaddr *);
    495 int	sctp_getladdrs(int, sctp_assoc_t, struct sockaddr **);
    496 void	sctp_freeladdrs(struct sockaddr *);
    497 int     sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *);
    498 
    499 ssize_t sctp_sendmsg(int, const void *, size_t,
    500 	const struct sockaddr *,
    501 	socklen_t, u_int32_t, u_int32_t, u_int16_t, u_int32_t, u_int32_t);
    502 
    503 ssize_t sctp_send(int sd, const void *msg, size_t len,
    504 	const struct sctp_sndrcvinfo *sinfo,int flags);
    505 
    506 ssize_t
    507 sctp_sendx(int sd, const void *msg, size_t len,
    508 		struct sockaddr *addrs, int addrcnt,
    509 		struct sctp_sndrcvinfo *sinfo, int flags);
    510 ssize_t
    511 sctp_sendmsgx(int sd, const void *, size_t,
    512 	           struct sockaddr *, int,
    513 	           u_int32_t, u_int32_t, u_int16_t, u_int32_t, u_int32_t);
    514 
    515 sctp_assoc_t
    516 sctp_getassocid(int sd, struct sockaddr *sa);
    517 
    518 ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *,
    519         socklen_t *, struct sctp_sndrcvinfo *, int *);
    520 
    521 __END_DECLS
    522 
    523 #endif /* !_KERNEL */
    524 #endif /* !__SCTP_UIO_H__ */
    525