Home | History | Annotate | Download | only in netinet
      1 /*-
      2  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
      3  * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
      4  * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions are met:
      8  *
      9  * a) Redistributions of source code must retain the above copyright notice,
     10  *    this list of conditions and the following disclaimer.
     11  *
     12  * b) Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in
     14  *    the documentation and/or other materials provided with the distribution.
     15  *
     16  * c) Neither the name of Cisco Systems, Inc. nor the names of its
     17  *    contributors may be used to endorse or promote products derived
     18  *    from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     30  * THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #ifdef __FreeBSD__
     34 #include <sys/cdefs.h>
     35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 269945 2014-08-13 15:50:16Z tuexen $");
     36 #endif
     37 
     38 #ifndef _NETINET_SCTP_UIO_H_
     39 #define _NETINET_SCTP_UIO_H_
     40 
     41 #if (defined(__APPLE__) && defined(KERNEL))
     42 #ifndef _KERNEL
     43 #define _KERNEL
     44 #endif
     45 #endif
     46 
     47 #if !(defined(__Windows__)) && !defined(__Userspace_os_Windows)
     48 #if ! defined(_KERNEL)
     49 #include <stdint.h>
     50 #endif
     51 #include <sys/types.h>
     52 #include <sys/socket.h>
     53 #include <netinet/in.h>
     54 #endif
     55 #if defined(__Windows__)
     56 #pragma warning(push)
     57 #pragma warning(disable: 4200)
     58 #if defined(_KERNEL)
     59 #include <sys/types.h>
     60 #include <sys/socket.h>
     61 #include <netinet/in.h>
     62 #endif
     63 #endif
     64 
     65 typedef uint32_t sctp_assoc_t;
     66 
     67 #define SCTP_FUTURE_ASSOC  0
     68 #define SCTP_CURRENT_ASSOC 1
     69 #define SCTP_ALL_ASSOC     2
     70 
     71 struct sctp_event {
     72 	sctp_assoc_t se_assoc_id;
     73 	uint16_t     se_type;
     74 	uint8_t      se_on;
     75 };
     76 
     77 /* Compatibility to previous define's */
     78 #define sctp_stream_reset_events sctp_stream_reset_event
     79 
     80 /* On/Off setup for subscription to events */
     81 struct sctp_event_subscribe {
     82 	uint8_t sctp_data_io_event;
     83 	uint8_t sctp_association_event;
     84 	uint8_t sctp_address_event;
     85 	uint8_t sctp_send_failure_event;
     86 	uint8_t sctp_peer_error_event;
     87 	uint8_t sctp_shutdown_event;
     88 	uint8_t sctp_partial_delivery_event;
     89 	uint8_t sctp_adaptation_layer_event;
     90 	uint8_t sctp_authentication_event;
     91 	uint8_t sctp_sender_dry_event;
     92 	uint8_t sctp_stream_reset_event;
     93 };
     94 
     95 /* ancillary data types */
     96 #define SCTP_INIT	0x0001
     97 #define SCTP_SNDRCV	0x0002
     98 #define SCTP_EXTRCV	0x0003
     99 #define SCTP_SNDINFO    0x0004
    100 #define SCTP_RCVINFO    0x0005
    101 #define SCTP_NXTINFO    0x0006
    102 #define SCTP_PRINFO     0x0007
    103 #define SCTP_AUTHINFO   0x0008
    104 #define SCTP_DSTADDRV4  0x0009
    105 #define SCTP_DSTADDRV6  0x000a
    106 
    107 /*
    108  * ancillary data structures
    109  */
    110 struct sctp_initmsg {
    111 #if defined(__FreeBSD__) && __FreeBSD_version < 800000
    112 	/* This is a bug. Not fixed for ABI compatibility */
    113 	uint32_t sinit_num_ostreams;
    114 	uint32_t sinit_max_instreams;
    115 #else
    116 	uint16_t sinit_num_ostreams;
    117 	uint16_t sinit_max_instreams;
    118 #endif
    119 	uint16_t sinit_max_attempts;
    120 	uint16_t sinit_max_init_timeo;
    121 };
    122 
    123 /* We add 96 bytes to the size of sctp_sndrcvinfo.
    124  * This makes the current structure 128 bytes long
    125  * which is nicely 64 bit aligned but also has room
    126  * for us to add more and keep ABI compatibility.
    127  * For example, already we have the sctp_extrcvinfo
    128  * when enabled which is 48 bytes.
    129  */
    130 
    131 /*
    132  * The assoc up needs a verfid
    133  * all sendrcvinfo's need a verfid for SENDING only.
    134  */
    135 
    136 
    137 #define SCTP_ALIGN_RESV_PAD 92
    138 #define SCTP_ALIGN_RESV_PAD_SHORT 76
    139 
    140 struct sctp_sndrcvinfo {
    141 	uint16_t sinfo_stream;
    142 	uint16_t sinfo_ssn;
    143 	uint16_t sinfo_flags;
    144 #if defined(__FreeBSD__) && __FreeBSD_version < 800000
    145 	uint16_t sinfo_pr_policy;
    146 #endif
    147 	uint32_t sinfo_ppid;
    148 	uint32_t sinfo_context;
    149 	uint32_t sinfo_timetolive;
    150 	uint32_t sinfo_tsn;
    151 	uint32_t sinfo_cumtsn;
    152 	sctp_assoc_t sinfo_assoc_id;
    153 	uint16_t sinfo_keynumber;
    154 	uint16_t sinfo_keynumber_valid;
    155 	uint8_t  __reserve_pad[SCTP_ALIGN_RESV_PAD];
    156 };
    157 
    158 struct sctp_extrcvinfo {
    159 	uint16_t sinfo_stream;
    160 	uint16_t sinfo_ssn;
    161 	uint16_t sinfo_flags;
    162 #if defined(__FreeBSD__) && __FreeBSD_version < 800000
    163 	uint16_t sinfo_pr_policy;
    164 #endif
    165 	uint32_t sinfo_ppid;
    166 	uint32_t sinfo_context;
    167 	uint32_t sinfo_timetolive;
    168 	uint32_t sinfo_tsn;
    169 	uint32_t sinfo_cumtsn;
    170 	sctp_assoc_t sinfo_assoc_id;
    171 	uint16_t sreinfo_next_flags;
    172 	uint16_t sreinfo_next_stream;
    173 	uint32_t sreinfo_next_aid;
    174 	uint32_t sreinfo_next_length;
    175 	uint32_t sreinfo_next_ppid;
    176 	uint16_t sinfo_keynumber;
    177 	uint16_t sinfo_keynumber_valid;
    178 	uint8_t  __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT];
    179 };
    180 
    181 struct sctp_sndinfo {
    182 	uint16_t snd_sid;
    183 	uint16_t snd_flags;
    184 	uint32_t snd_ppid;
    185 	uint32_t snd_context;
    186 	sctp_assoc_t snd_assoc_id;
    187 };
    188 
    189 struct sctp_prinfo {
    190 	uint16_t pr_policy;
    191 	uint32_t pr_value;
    192 };
    193 
    194 struct sctp_default_prinfo {
    195 	uint16_t pr_policy;
    196 	uint32_t pr_value;
    197 	sctp_assoc_t pr_assoc_id;
    198 };
    199 
    200 struct sctp_authinfo {
    201 	uint16_t auth_keynumber;
    202 };
    203 
    204 struct sctp_rcvinfo {
    205 	uint16_t rcv_sid;
    206 	uint16_t rcv_ssn;
    207 	uint16_t rcv_flags;
    208 	uint32_t rcv_ppid;
    209 	uint32_t rcv_tsn;
    210 	uint32_t rcv_cumtsn;
    211 	uint32_t rcv_context;
    212 	sctp_assoc_t rcv_assoc_id;
    213 };
    214 
    215 struct sctp_nxtinfo {
    216 	uint16_t nxt_sid;
    217 	uint16_t nxt_flags;
    218 	uint32_t nxt_ppid;
    219 	uint32_t nxt_length;
    220 	sctp_assoc_t nxt_assoc_id;
    221 };
    222 
    223 #define SCTP_NO_NEXT_MSG           0x0000
    224 #define SCTP_NEXT_MSG_AVAIL        0x0001
    225 #define SCTP_NEXT_MSG_ISCOMPLETE   0x0002
    226 #define SCTP_NEXT_MSG_IS_UNORDERED 0x0004
    227 #define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008
    228 
    229 struct sctp_recvv_rn {
    230 	struct sctp_rcvinfo recvv_rcvinfo;
    231 	struct sctp_nxtinfo recvv_nxtinfo;
    232 };
    233 
    234 #define SCTP_RECVV_NOINFO  0
    235 #define SCTP_RECVV_RCVINFO 1
    236 #define SCTP_RECVV_NXTINFO 2
    237 #define SCTP_RECVV_RN      3
    238 
    239 #define SCTP_SENDV_NOINFO   0
    240 #define SCTP_SENDV_SNDINFO  1
    241 #define SCTP_SENDV_PRINFO   2
    242 #define SCTP_SENDV_AUTHINFO 3
    243 #define SCTP_SENDV_SPA      4
    244 
    245 struct sctp_sendv_spa {
    246 	uint32_t sendv_flags;
    247 	struct sctp_sndinfo sendv_sndinfo;
    248 	struct sctp_prinfo sendv_prinfo;
    249 	struct sctp_authinfo sendv_authinfo;
    250 };
    251 
    252 #define SCTP_SEND_SNDINFO_VALID  0x00000001
    253 #define SCTP_SEND_PRINFO_VALID   0x00000002
    254 #define SCTP_SEND_AUTHINFO_VALID 0x00000004
    255 
    256 struct sctp_snd_all_completes {
    257 	uint16_t sall_stream;
    258 	uint16_t sall_flags;
    259 	uint32_t sall_ppid;
    260 	uint32_t sall_context;
    261 	uint32_t sall_num_sent;
    262 	uint32_t sall_num_failed;
    263 };
    264 
    265 /* Flags that go into the sinfo->sinfo_flags field */
    266 #define SCTP_NOTIFICATION     0x0010 /* next message is a notification */
    267 #define SCTP_COMPLETE         0x0020 /* next message is complete */
    268 #define SCTP_EOF              0x0100 /* Start shutdown procedures */
    269 #define SCTP_ABORT            0x0200 /* Send an ABORT to peer */
    270 #define SCTP_UNORDERED        0x0400 /* Message is un-ordered */
    271 #define SCTP_ADDR_OVER        0x0800 /* Override the primary-address */
    272 #define SCTP_SENDALL          0x1000 /* Send this on all associations */
    273 #define SCTP_EOR              0x2000 /* end of message signal */
    274 #define SCTP_SACK_IMMEDIATELY 0x4000 /* Set I-Bit */
    275 
    276 #define INVALID_SINFO_FLAG(x) (((x) & 0xfffffff0 \
    277                                     & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\
    278 				        SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR |\
    279 					SCTP_SACK_IMMEDIATELY)) != 0)
    280 /* for the endpoint */
    281 
    282 /* The lower four bits is an enumeration of PR-SCTP policies */
    283 #define SCTP_PR_SCTP_NONE 0x0000 /* Reliable transfer */
    284 #define SCTP_PR_SCTP_TTL  0x0001 /* Time based PR-SCTP */
    285 #define SCTP_PR_SCTP_BUF  0x0002 /* Buffer based PR-SCTP */
    286 #define SCTP_PR_SCTP_RTX  0x0003 /* Number of retransmissions based PR-SCTP */
    287 #define SCTP_PR_SCTP_MAX  SCTP_PR_SCTP_RTX
    288 #define SCTP_PR_SCTP_ALL  0x000f /* Used for aggregated stats */
    289 
    290 #define PR_SCTP_POLICY(x)         ((x) & 0x0f)
    291 #define PR_SCTP_ENABLED(x)        ((PR_SCTP_POLICY(x) != SCTP_PR_SCTP_NONE) && \
    292                                    (PR_SCTP_POLICY(x) != SCTP_PR_SCTP_ALL))
    293 #define PR_SCTP_TTL_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL)
    294 #define PR_SCTP_BUF_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF)
    295 #define PR_SCTP_RTX_ENABLED(x)    (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX)
    296 #define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_MAX)
    297 #define PR_SCTP_VALID_POLICY(x)   (PR_SCTP_POLICY(x) <= SCTP_PR_SCTP_MAX)
    298 
    299 /* Stat's */
    300 struct sctp_pcbinfo {
    301 	uint32_t ep_count;
    302 	uint32_t asoc_count;
    303 	uint32_t laddr_count;
    304 	uint32_t raddr_count;
    305 	uint32_t chk_count;
    306 	uint32_t readq_count;
    307 	uint32_t free_chunks;
    308 	uint32_t stream_oque;
    309 };
    310 
    311 struct sctp_sockstat {
    312 	sctp_assoc_t ss_assoc_id;
    313 	uint32_t ss_total_sndbuf;
    314 	uint32_t ss_total_recv_buf;
    315 };
    316 
    317 /*
    318  * notification event structures
    319  */
    320 
    321 /*
    322  * association change event
    323  */
    324 struct sctp_assoc_change {
    325 	uint16_t sac_type;
    326 	uint16_t sac_flags;
    327 	uint32_t sac_length;
    328 	uint16_t sac_state;
    329 	uint16_t sac_error;
    330 	uint16_t sac_outbound_streams;
    331 	uint16_t sac_inbound_streams;
    332 	sctp_assoc_t sac_assoc_id;
    333 	uint8_t sac_info[];
    334 };
    335 
    336 /* sac_state values */
    337 #define SCTP_COMM_UP            0x0001
    338 #define SCTP_COMM_LOST          0x0002
    339 #define SCTP_RESTART            0x0003
    340 #define SCTP_SHUTDOWN_COMP      0x0004
    341 #define SCTP_CANT_STR_ASSOC     0x0005
    342 
    343 /* sac_info values */
    344 #define SCTP_ASSOC_SUPPORTS_PR        0x01
    345 #define SCTP_ASSOC_SUPPORTS_AUTH      0x02
    346 #define SCTP_ASSOC_SUPPORTS_ASCONF    0x03
    347 #define SCTP_ASSOC_SUPPORTS_MULTIBUF  0x04
    348 #define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05
    349 #define SCTP_ASSOC_SUPPORTS_MAX       0x05
    350 /*
    351  * Address event
    352  */
    353 struct sctp_paddr_change {
    354 	uint16_t spc_type;
    355 	uint16_t spc_flags;
    356 	uint32_t spc_length;
    357 	struct sockaddr_storage spc_aaddr;
    358 	uint32_t spc_state;
    359 	uint32_t spc_error;
    360 	sctp_assoc_t spc_assoc_id;
    361 };
    362 
    363 /* paddr state values */
    364 #define SCTP_ADDR_AVAILABLE	0x0001
    365 #define SCTP_ADDR_UNREACHABLE	0x0002
    366 #define SCTP_ADDR_REMOVED	0x0003
    367 #define SCTP_ADDR_ADDED		0x0004
    368 #define SCTP_ADDR_MADE_PRIM	0x0005
    369 #define SCTP_ADDR_CONFIRMED	0x0006
    370 
    371 #define SCTP_ACTIVE		0x0001	/* SCTP_ADDR_REACHABLE */
    372 #define SCTP_INACTIVE		0x0002	/* neither SCTP_ADDR_REACHABLE
    373 					   nor SCTP_ADDR_UNCONFIRMED */
    374 #define SCTP_UNCONFIRMED	0x0200	/* SCTP_ADDR_UNCONFIRMED */
    375 
    376 /* remote error events */
    377 struct sctp_remote_error {
    378 	uint16_t sre_type;
    379 	uint16_t sre_flags;
    380 	uint32_t sre_length;
    381 	uint16_t sre_error;
    382 	sctp_assoc_t sre_assoc_id;
    383 	uint8_t sre_data[];
    384 };
    385 
    386 /* data send failure event (deprecated) */
    387 struct sctp_send_failed {
    388 	uint16_t ssf_type;
    389 	uint16_t ssf_flags;
    390 	uint32_t ssf_length;
    391 	uint32_t ssf_error;
    392 	struct sctp_sndrcvinfo ssf_info;
    393 	sctp_assoc_t ssf_assoc_id;
    394 	uint8_t ssf_data[];
    395 };
    396 
    397 /* data send failure event (not deprecated) */
    398 struct sctp_send_failed_event {
    399 	uint16_t ssfe_type;
    400 	uint16_t ssfe_flags;
    401 	uint32_t ssfe_length;
    402 	uint32_t ssfe_error;
    403 	struct sctp_sndinfo ssfe_info;
    404 	sctp_assoc_t ssfe_assoc_id;
    405 	uint8_t  ssfe_data[];
    406 };
    407 
    408 /* flag that indicates state of data */
    409 #define SCTP_DATA_UNSENT	0x0001	/* inqueue never on wire */
    410 #define SCTP_DATA_SENT		0x0002	/* on wire at failure */
    411 
    412 /* shutdown event */
    413 struct sctp_shutdown_event {
    414 	uint16_t sse_type;
    415 	uint16_t sse_flags;
    416 	uint32_t sse_length;
    417 	sctp_assoc_t sse_assoc_id;
    418 };
    419 
    420 /* Adaptation layer indication stuff */
    421 struct sctp_adaptation_event {
    422 	uint16_t sai_type;
    423 	uint16_t sai_flags;
    424 	uint32_t sai_length;
    425 	uint32_t sai_adaptation_ind;
    426 	sctp_assoc_t sai_assoc_id;
    427 };
    428 
    429 struct sctp_setadaptation {
    430 	uint32_t ssb_adaptation_ind;
    431 };
    432 
    433 /* compatible old spelling */
    434 struct sctp_adaption_event {
    435 	uint16_t sai_type;
    436 	uint16_t sai_flags;
    437 	uint32_t sai_length;
    438 	uint32_t sai_adaption_ind;
    439 	sctp_assoc_t sai_assoc_id;
    440 };
    441 
    442 struct sctp_setadaption {
    443 	uint32_t ssb_adaption_ind;
    444 };
    445 
    446 
    447 /*
    448  * Partial Delivery API event
    449  */
    450 struct sctp_pdapi_event {
    451 	uint16_t pdapi_type;
    452 	uint16_t pdapi_flags;
    453 	uint32_t pdapi_length;
    454 	uint32_t pdapi_indication;
    455 	uint16_t pdapi_stream;
    456 	uint16_t pdapi_seq;
    457 	sctp_assoc_t pdapi_assoc_id;
    458 };
    459 
    460 /* indication values */
    461 #define SCTP_PARTIAL_DELIVERY_ABORTED	0x0001
    462 
    463 
    464 /*
    465  * authentication key event
    466  */
    467 struct sctp_authkey_event {
    468 	uint16_t auth_type;
    469 	uint16_t auth_flags;
    470 	uint32_t auth_length;
    471 	uint16_t auth_keynumber;
    472 	uint16_t auth_altkeynumber;
    473 	uint32_t auth_indication;
    474 	sctp_assoc_t auth_assoc_id;
    475 };
    476 
    477 /* indication values */
    478 #define SCTP_AUTH_NEW_KEY	0x0001
    479 #define SCTP_AUTH_NEWKEY	SCTP_AUTH_NEW_KEY
    480 #define SCTP_AUTH_NO_AUTH	0x0002
    481 #define SCTP_AUTH_FREE_KEY	0x0003
    482 
    483 
    484 struct sctp_sender_dry_event {
    485 	uint16_t sender_dry_type;
    486 	uint16_t sender_dry_flags;
    487 	uint32_t sender_dry_length;
    488 	sctp_assoc_t sender_dry_assoc_id;
    489 };
    490 
    491 
    492 /*
    493  * Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT
    494  */
    495 struct sctp_stream_reset_event {
    496 	uint16_t strreset_type;
    497 	uint16_t strreset_flags;
    498 	uint32_t strreset_length;
    499 	sctp_assoc_t strreset_assoc_id;
    500 	uint16_t strreset_stream_list[];
    501 };
    502 
    503 /* flags in stream_reset_event (strreset_flags) */
    504 #define SCTP_STREAM_RESET_INCOMING_SSN  0x0001
    505 #define SCTP_STREAM_RESET_OUTGOING_SSN  0x0002
    506 #define SCTP_STREAM_RESET_DENIED        0x0004
    507 #define SCTP_STREAM_RESET_FAILED        0x0008
    508 
    509 /*
    510  * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT
    511  */
    512 struct sctp_assoc_reset_event {
    513 	uint16_t 	assocreset_type;
    514 	uint16_t	assocreset_flags;
    515 	uint32_t	assocreset_length;
    516 	sctp_assoc_t	assocreset_assoc_id;
    517 	uint32_t	assocreset_local_tsn;
    518 	uint32_t	assocreset_remote_tsn;
    519 };
    520 
    521 #define SCTP_ASSOC_RESET_DENIED		0x0004
    522 #define SCTP_ASSOC_RESET_FAILED		0x0008
    523 
    524 /*
    525  * Stream change event - subscribe to SCTP_STREAM_CHANGE_EVENT
    526  */
    527 struct sctp_stream_change_event {
    528 	uint16_t	strchange_type;
    529 	uint16_t	strchange_flags;
    530 	uint32_t	strchange_length;
    531 	sctp_assoc_t	strchange_assoc_id;
    532 	uint16_t	strchange_instrms;
    533 	uint16_t	strchange_outstrms;
    534 };
    535 
    536 #define SCTP_STREAM_CHANGE_DENIED	0x0004
    537 #define SCTP_STREAM_CHANGE_FAILED	0x0008
    538 
    539 
    540 /* SCTP notification event */
    541 struct sctp_tlv {
    542 	uint16_t sn_type;
    543 	uint16_t sn_flags;
    544 	uint32_t sn_length;
    545 };
    546 
    547 union sctp_notification {
    548 	struct sctp_tlv sn_header;
    549 	struct sctp_assoc_change sn_assoc_change;
    550 	struct sctp_paddr_change sn_paddr_change;
    551 	struct sctp_remote_error sn_remote_error;
    552 	struct sctp_send_failed sn_send_failed;
    553 	struct sctp_shutdown_event sn_shutdown_event;
    554 	struct sctp_adaptation_event sn_adaptation_event;
    555 	/* compatibility same as above */
    556 	struct sctp_adaption_event sn_adaption_event;
    557 	struct sctp_pdapi_event sn_pdapi_event;
    558 	struct sctp_authkey_event sn_auth_event;
    559 	struct sctp_sender_dry_event sn_sender_dry_event;
    560 	struct sctp_send_failed_event sn_send_failed_event;
    561 	struct sctp_stream_reset_event sn_strreset_event;
    562 	struct sctp_assoc_reset_event  sn_assocreset_event;
    563 	struct sctp_stream_change_event sn_strchange_event;
    564 };
    565 
    566 /* notification types */
    567 #define SCTP_ASSOC_CHANGE                       0x0001
    568 #define SCTP_PEER_ADDR_CHANGE                   0x0002
    569 #define SCTP_REMOTE_ERROR                       0x0003
    570 #define SCTP_SEND_FAILED                        0x0004
    571 #define SCTP_SHUTDOWN_EVENT                     0x0005
    572 #define SCTP_ADAPTATION_INDICATION              0x0006
    573 /* same as above */
    574 #define SCTP_ADAPTION_INDICATION                0x0006
    575 #define SCTP_PARTIAL_DELIVERY_EVENT             0x0007
    576 #define SCTP_AUTHENTICATION_EVENT               0x0008
    577 #define SCTP_STREAM_RESET_EVENT                 0x0009
    578 #define SCTP_SENDER_DRY_EVENT                   0x000a
    579 #define SCTP_NOTIFICATIONS_STOPPED_EVENT        0x000b /* we don't send this*/
    580 #define SCTP_ASSOC_RESET_EVENT                  0x000c
    581 #define SCTP_STREAM_CHANGE_EVENT                0x000d
    582 #define SCTP_SEND_FAILED_EVENT                  0x000e
    583 /*
    584  * socket option structs
    585  */
    586 
    587 struct sctp_paddrparams {
    588 	struct sockaddr_storage spp_address;
    589 	sctp_assoc_t spp_assoc_id;
    590 	uint32_t spp_hbinterval;
    591 	uint32_t spp_pathmtu;
    592 	uint32_t spp_flags;
    593 	uint32_t spp_ipv6_flowlabel;
    594 	uint16_t spp_pathmaxrxt;
    595 	uint8_t spp_dscp;
    596 };
    597 #define spp_ipv4_tos spp_dscp
    598 
    599 #define SPP_HB_ENABLE		0x00000001
    600 #define SPP_HB_DISABLE		0x00000002
    601 #define SPP_HB_DEMAND		0x00000004
    602 #define SPP_PMTUD_ENABLE	0x00000008
    603 #define SPP_PMTUD_DISABLE	0x00000010
    604 #define SPP_HB_TIME_IS_ZERO     0x00000080
    605 #define SPP_IPV6_FLOWLABEL      0x00000100
    606 #define SPP_DSCP                0x00000200
    607 #define SPP_IPV4_TOS            SPP_DSCP
    608 
    609 struct sctp_paddrthlds {
    610 	struct sockaddr_storage spt_address;
    611 	sctp_assoc_t spt_assoc_id;
    612 	uint16_t spt_pathmaxrxt;
    613 	uint16_t spt_pathpfthld;
    614 };
    615 
    616 struct sctp_paddrinfo {
    617 	struct sockaddr_storage spinfo_address;
    618 	sctp_assoc_t spinfo_assoc_id;
    619 	int32_t spinfo_state;
    620 	uint32_t spinfo_cwnd;
    621 	uint32_t spinfo_srtt;
    622 	uint32_t spinfo_rto;
    623 	uint32_t spinfo_mtu;
    624 };
    625 
    626 struct sctp_rtoinfo {
    627 	sctp_assoc_t srto_assoc_id;
    628 	uint32_t srto_initial;
    629 	uint32_t srto_max;
    630 	uint32_t srto_min;
    631 };
    632 
    633 struct sctp_assocparams {
    634 	sctp_assoc_t sasoc_assoc_id;
    635 	uint32_t sasoc_peer_rwnd;
    636 	uint32_t sasoc_local_rwnd;
    637 	uint32_t sasoc_cookie_life;
    638 	uint16_t sasoc_asocmaxrxt;
    639 	uint16_t sasoc_number_peer_destinations;
    640 };
    641 
    642 struct sctp_setprim {
    643 	struct sockaddr_storage ssp_addr;
    644 	sctp_assoc_t ssp_assoc_id;
    645 	uint8_t ssp_padding[4];
    646 };
    647 
    648 struct sctp_setpeerprim {
    649 	struct sockaddr_storage sspp_addr;
    650 	sctp_assoc_t sspp_assoc_id;
    651 	uint8_t sspp_padding[4];
    652 };
    653 
    654 struct sctp_getaddresses {
    655 	sctp_assoc_t sget_assoc_id;
    656 	/* addr is filled in for N * sockaddr_storage */
    657 	struct sockaddr addr[1];
    658 };
    659 
    660 struct sctp_status {
    661 	sctp_assoc_t sstat_assoc_id;
    662 	int32_t sstat_state;
    663 	uint32_t sstat_rwnd;
    664 	uint16_t sstat_unackdata;
    665 	uint16_t sstat_penddata;
    666 	uint16_t sstat_instrms;
    667 	uint16_t sstat_outstrms;
    668 	uint32_t sstat_fragmentation_point;
    669 	struct sctp_paddrinfo sstat_primary;
    670 };
    671 
    672 /*
    673  * AUTHENTICATION support
    674  */
    675 /* SCTP_AUTH_CHUNK */
    676 struct sctp_authchunk {
    677 	uint8_t sauth_chunk;
    678 };
    679 
    680 /* SCTP_AUTH_KEY */
    681 struct sctp_authkey {
    682 	sctp_assoc_t sca_assoc_id;
    683 	uint16_t sca_keynumber;
    684 	uint16_t sca_keylength;
    685 	uint8_t sca_key[];
    686 };
    687 
    688 /* SCTP_HMAC_IDENT */
    689 struct sctp_hmacalgo {
    690 	uint32_t shmac_number_of_idents;
    691 	uint16_t shmac_idents[];
    692 };
    693 
    694 /* AUTH hmac_id */
    695 #define SCTP_AUTH_HMAC_ID_RSVD		0x0000
    696 #define SCTP_AUTH_HMAC_ID_SHA1		0x0001	/* default, mandatory */
    697 #define SCTP_AUTH_HMAC_ID_SHA256	0x0003
    698 
    699 /* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */
    700 struct sctp_authkeyid {
    701 	sctp_assoc_t scact_assoc_id;
    702 	uint16_t scact_keynumber;
    703 };
    704 
    705 /* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */
    706 struct sctp_authchunks {
    707 	sctp_assoc_t gauth_assoc_id;
    708 	uint32_t gauth_number_of_chunks;
    709 	uint8_t gauth_chunks[];
    710 };
    711 
    712 struct sctp_assoc_value {
    713 	sctp_assoc_t assoc_id;
    714 	uint32_t assoc_value;
    715 };
    716 
    717 struct sctp_cc_option {
    718 	int option;
    719 	struct sctp_assoc_value aid_value;
    720 };
    721 
    722 struct sctp_stream_value {
    723 	sctp_assoc_t assoc_id;
    724 	uint16_t stream_id;
    725 	uint16_t stream_value;
    726 };
    727 
    728 struct sctp_assoc_ids {
    729 	uint32_t gaids_number_of_ids;
    730 	sctp_assoc_t gaids_assoc_id[];
    731 };
    732 
    733 struct sctp_sack_info {
    734 	sctp_assoc_t sack_assoc_id;
    735 	uint32_t sack_delay;
    736 	uint32_t sack_freq;
    737 };
    738 
    739 struct sctp_timeouts {
    740 	sctp_assoc_t stimo_assoc_id;
    741 	uint32_t stimo_init;
    742 	uint32_t stimo_data;
    743 	uint32_t stimo_sack;
    744 	uint32_t stimo_shutdown;
    745 	uint32_t stimo_heartbeat;
    746 	uint32_t stimo_cookie;
    747 	uint32_t stimo_shutdownack;
    748 };
    749 
    750 struct sctp_udpencaps {
    751 	struct sockaddr_storage sue_address;
    752 	sctp_assoc_t sue_assoc_id;
    753 	uint16_t sue_port;
    754 };
    755 
    756 struct sctp_prstatus {
    757 	sctp_assoc_t sprstat_assoc_id;
    758 	uint16_t sprstat_sid;
    759 	uint16_t sprstat_policy;
    760 	uint64_t sprstat_abandoned_unsent;
    761 	uint64_t sprstat_abandoned_sent;
    762 };
    763 
    764 struct sctp_cwnd_args {
    765 	struct sctp_nets *net;	/* network to */ /* FIXME: LP64 issue */
    766 	uint32_t cwnd_new_value;/* cwnd in k */
    767 	uint32_t pseudo_cumack;
    768 	uint16_t inflight;	/* flightsize in k */
    769 	uint16_t cwnd_augment;	/* increment to it */
    770 	uint8_t meets_pseudo_cumack;
    771 	uint8_t need_new_pseudo_cumack;
    772 	uint8_t cnt_in_send;
    773 	uint8_t cnt_in_str;
    774 };
    775 
    776 struct sctp_blk_args {
    777 	uint32_t onsb;		/* in 1k bytes */
    778 	uint32_t sndlen;	/* len of send being attempted */
    779 	uint32_t peer_rwnd;	/* rwnd of peer */
    780 	uint16_t send_sent_qcnt;/* chnk cnt */
    781 	uint16_t stream_qcnt;	/* chnk cnt */
    782 	uint16_t chunks_on_oque;/* chunks out */
    783 	uint16_t flight_size;   /* flight size in k */
    784 };
    785 
    786 /*
    787  * Max we can reset in one setting, note this is dictated not by the define
    788  * but the size of a mbuf cluster so don't change this define and think you
    789  * can specify more. You must do multiple resets if you want to reset more
    790  * than SCTP_MAX_EXPLICIT_STR_RESET.
    791  */
    792 #define SCTP_MAX_EXPLICT_STR_RESET   1000
    793 
    794 struct sctp_reset_streams {
    795 	sctp_assoc_t srs_assoc_id;
    796 	uint16_t srs_flags;
    797 	uint16_t srs_number_streams;	/* 0 == ALL */
    798 	uint16_t srs_stream_list[];/* list if strrst_num_streams is not 0 */
    799 };
    800 
    801 struct sctp_add_streams {
    802 	sctp_assoc_t	sas_assoc_id;
    803 	uint16_t	sas_instrms;
    804 	uint16_t	sas_outstrms;
    805 };
    806 
    807 struct sctp_get_nonce_values {
    808 	sctp_assoc_t gn_assoc_id;
    809 	uint32_t gn_peers_tag;
    810 	uint32_t gn_local_tag;
    811 };
    812 
    813 /* Debugging logs */
    814 struct sctp_str_log {
    815 	void *stcb; /* FIXME: LP64 issue */
    816 	uint32_t n_tsn;
    817 	uint32_t e_tsn;
    818 	uint16_t n_sseq;
    819 	uint16_t e_sseq;
    820 	uint16_t strm;
    821 };
    822 
    823 struct sctp_sb_log {
    824 	void  *stcb; /* FIXME: LP64 issue */
    825 	uint32_t so_sbcc;
    826 	uint32_t stcb_sbcc;
    827 	uint32_t incr;
    828 };
    829 
    830 struct sctp_fr_log {
    831 	uint32_t largest_tsn;
    832 	uint32_t largest_new_tsn;
    833 	uint32_t tsn;
    834 };
    835 
    836 struct sctp_fr_map {
    837 	uint32_t base;
    838 	uint32_t cum;
    839 	uint32_t high;
    840 };
    841 
    842 struct sctp_rwnd_log {
    843 	uint32_t rwnd;
    844 	uint32_t send_size;
    845 	uint32_t overhead;
    846 	uint32_t new_rwnd;
    847 };
    848 
    849 struct sctp_mbcnt_log {
    850 	uint32_t total_queue_size;
    851 	uint32_t size_change;
    852 	uint32_t total_queue_mb_size;
    853 	uint32_t mbcnt_change;
    854 };
    855 
    856 struct sctp_sack_log {
    857 	uint32_t cumack;
    858 	uint32_t oldcumack;
    859 	uint32_t tsn;
    860 	uint16_t numGaps;
    861 	uint16_t numDups;
    862 };
    863 
    864 struct sctp_lock_log {
    865 	void *sock;  /* FIXME: LP64 issue */
    866 	void *inp; /* FIXME: LP64 issue */
    867 	uint8_t tcb_lock;
    868 	uint8_t inp_lock;
    869 	uint8_t info_lock;
    870 	uint8_t sock_lock;
    871 	uint8_t sockrcvbuf_lock;
    872 	uint8_t socksndbuf_lock;
    873 	uint8_t create_lock;
    874 	uint8_t resv;
    875 };
    876 
    877 struct sctp_rto_log {
    878 	void * net; /* FIXME: LP64 issue */
    879 	uint32_t rtt;
    880 };
    881 
    882 struct sctp_nagle_log {
    883 	void  *stcb; /* FIXME: LP64 issue */
    884 	uint32_t total_flight;
    885 	uint32_t total_in_queue;
    886 	uint16_t count_in_queue;
    887 	uint16_t count_in_flight;
    888 };
    889 
    890 struct sctp_sbwake_log {
    891 	void *stcb; /* FIXME: LP64 issue */
    892 	uint16_t send_q;
    893 	uint16_t sent_q;
    894 	uint16_t flight;
    895 	uint16_t wake_cnt;
    896 	uint8_t stream_qcnt;	/* chnk cnt */
    897 	uint8_t chunks_on_oque;/* chunks out */
    898 	uint8_t sbflags;
    899 	uint8_t sctpflags;
    900 };
    901 
    902 struct sctp_misc_info {
    903 	uint32_t log1;
    904 	uint32_t log2;
    905 	uint32_t log3;
    906 	uint32_t log4;
    907 };
    908 
    909 struct sctp_log_closing {
    910 	void *inp; /* FIXME: LP64 issue */
    911 	void *stcb;  /* FIXME: LP64 issue */
    912 	uint32_t sctp_flags;
    913 	uint16_t  state;
    914 	int16_t  loc;
    915 };
    916 
    917 struct sctp_mbuf_log {
    918 	struct mbuf *mp; /* FIXME: LP64 issue */
    919 	caddr_t  ext;
    920 	caddr_t  data;
    921 	uint16_t size;
    922 	uint8_t  refcnt;
    923 	uint8_t  mbuf_flags;
    924 };
    925 
    926 struct sctp_cwnd_log {
    927 	uint64_t time_event;
    928 	uint8_t  from;
    929 	uint8_t  event_type;
    930 	uint8_t  resv[2];
    931 	union {
    932 		struct sctp_log_closing close;
    933 		struct sctp_blk_args blk;
    934 		struct sctp_cwnd_args cwnd;
    935 		struct sctp_str_log strlog;
    936 		struct sctp_fr_log fr;
    937 		struct sctp_fr_map map;
    938 		struct sctp_rwnd_log rwnd;
    939 		struct sctp_mbcnt_log mbcnt;
    940 		struct sctp_sack_log sack;
    941 		struct sctp_lock_log lock;
    942 		struct sctp_rto_log rto;
    943 		struct sctp_sb_log sb;
    944 		struct sctp_nagle_log nagle;
    945 		struct sctp_sbwake_log wake;
    946 		struct sctp_mbuf_log mb;
    947 		struct sctp_misc_info misc;
    948 	}     x;
    949 };
    950 
    951 struct sctp_cwnd_log_req {
    952 	int32_t num_in_log;		/* Number in log */
    953 	int32_t num_ret;		/* Number returned */
    954 	int32_t start_at;		/* start at this one */
    955 	int32_t end_at;		        /* end at this one */
    956 	struct sctp_cwnd_log log[];
    957 };
    958 
    959 struct sctp_timeval {
    960 	uint32_t tv_sec;
    961 	uint32_t tv_usec;
    962 };
    963 
    964 struct sctpstat {
    965 	struct sctp_timeval sctps_discontinuitytime; /* sctpStats 18 (TimeStamp) */
    966 	/* MIB according to RFC 3873 */
    967 	uint32_t  sctps_currestab;           /* sctpStats  1   (Gauge32) */
    968 	uint32_t  sctps_activeestab;         /* sctpStats  2 (Counter32) */
    969 	uint32_t  sctps_restartestab;
    970 	uint32_t  sctps_collisionestab;
    971 	uint32_t  sctps_passiveestab;        /* sctpStats  3 (Counter32) */
    972 	uint32_t  sctps_aborted;             /* sctpStats  4 (Counter32) */
    973 	uint32_t  sctps_shutdown;            /* sctpStats  5 (Counter32) */
    974 	uint32_t  sctps_outoftheblue;        /* sctpStats  6 (Counter32) */
    975 	uint32_t  sctps_checksumerrors;      /* sctpStats  7 (Counter32) */
    976 	uint32_t  sctps_outcontrolchunks;    /* sctpStats  8 (Counter64) */
    977 	uint32_t  sctps_outorderchunks;      /* sctpStats  9 (Counter64) */
    978 	uint32_t  sctps_outunorderchunks;    /* sctpStats 10 (Counter64) */
    979 	uint32_t  sctps_incontrolchunks;     /* sctpStats 11 (Counter64) */
    980 	uint32_t  sctps_inorderchunks;       /* sctpStats 12 (Counter64) */
    981 	uint32_t  sctps_inunorderchunks;     /* sctpStats 13 (Counter64) */
    982 	uint32_t  sctps_fragusrmsgs;         /* sctpStats 14 (Counter64) */
    983 	uint32_t  sctps_reasmusrmsgs;        /* sctpStats 15 (Counter64) */
    984 	uint32_t  sctps_outpackets;          /* sctpStats 16 (Counter64) */
    985 	uint32_t  sctps_inpackets;           /* sctpStats 17 (Counter64) */
    986 
    987 	/* input statistics: */
    988 	uint32_t  sctps_recvpackets;         /* total input packets        */
    989 	uint32_t  sctps_recvdatagrams;       /* total input datagrams      */
    990 	uint32_t  sctps_recvpktwithdata;     /* total packets that had data */
    991 	uint32_t  sctps_recvsacks;           /* total input SACK chunks    */
    992 	uint32_t  sctps_recvdata;            /* total input DATA chunks    */
    993 	uint32_t  sctps_recvdupdata;         /* total input duplicate DATA chunks */
    994 	uint32_t  sctps_recvheartbeat;       /* total input HB chunks      */
    995 	uint32_t  sctps_recvheartbeatack;    /* total input HB-ACK chunks  */
    996 	uint32_t  sctps_recvecne;            /* total input ECNE chunks    */
    997 	uint32_t  sctps_recvauth;            /* total input AUTH chunks    */
    998 	uint32_t  sctps_recvauthmissing;     /* total input chunks missing AUTH */
    999 	uint32_t  sctps_recvivalhmacid;      /* total number of invalid HMAC ids received */
   1000 	uint32_t  sctps_recvivalkeyid;       /* total number of invalid secret ids received */
   1001 	uint32_t  sctps_recvauthfailed;      /* total number of auth failed */
   1002 	uint32_t  sctps_recvexpress;         /* total fast path receives all one chunk */
   1003 	uint32_t  sctps_recvexpressm;        /* total fast path multi-part data */
   1004 	uint32_t  sctps_recvnocrc;
   1005 	uint32_t  sctps_recvswcrc;
   1006 	uint32_t  sctps_recvhwcrc;
   1007 
   1008 	/* output statistics: */
   1009 	uint32_t  sctps_sendpackets;         /* total output packets       */
   1010 	uint32_t  sctps_sendsacks;           /* total output SACKs         */
   1011 	uint32_t  sctps_senddata;            /* total output DATA chunks   */
   1012 	uint32_t  sctps_sendretransdata;     /* total output retransmitted DATA chunks */
   1013 	uint32_t  sctps_sendfastretrans;     /* total output fast retransmitted DATA chunks */
   1014 	uint32_t  sctps_sendmultfastretrans; /* total FR's that happened more than once
   1015                                               * to same chunk (u-del multi-fr algo).
   1016 					      */
   1017 	uint32_t  sctps_sendheartbeat;       /* total output HB chunks     */
   1018 	uint32_t  sctps_sendecne;            /* total output ECNE chunks    */
   1019 	uint32_t  sctps_sendauth;            /* total output AUTH chunks FIXME   */
   1020 	uint32_t  sctps_senderrors;	     /* ip_output error counter */
   1021 	uint32_t  sctps_sendnocrc;
   1022 	uint32_t  sctps_sendswcrc;
   1023 	uint32_t  sctps_sendhwcrc;
   1024 	/* PCKDROPREP statistics: */
   1025 	uint32_t  sctps_pdrpfmbox;           /* Packet drop from middle box */
   1026 	uint32_t  sctps_pdrpfehos;           /* P-drop from end host */
   1027 	uint32_t  sctps_pdrpmbda;            /* P-drops with data */
   1028 	uint32_t  sctps_pdrpmbct;            /* P-drops, non-data, non-endhost */
   1029 	uint32_t  sctps_pdrpbwrpt;           /* P-drop, non-endhost, bandwidth rep only */
   1030 	uint32_t  sctps_pdrpcrupt;           /* P-drop, not enough for chunk header */
   1031 	uint32_t  sctps_pdrpnedat;           /* P-drop, not enough data to confirm */
   1032 	uint32_t  sctps_pdrppdbrk;           /* P-drop, where process_chunk_drop said break */
   1033 	uint32_t  sctps_pdrptsnnf;           /* P-drop, could not find TSN */
   1034 	uint32_t  sctps_pdrpdnfnd;           /* P-drop, attempt reverse TSN lookup */
   1035 	uint32_t  sctps_pdrpdiwnp;           /* P-drop, e-host confirms zero-rwnd */
   1036 	uint32_t  sctps_pdrpdizrw;           /* P-drop, midbox confirms no space */
   1037 	uint32_t  sctps_pdrpbadd;            /* P-drop, data did not match TSN */
   1038 	uint32_t  sctps_pdrpmark;            /* P-drop, TSN's marked for Fast Retran */
   1039 	/* timeouts */
   1040 	uint32_t  sctps_timoiterator;        /* Number of iterator timers that fired */
   1041 	uint32_t  sctps_timodata;            /* Number of T3 data time outs */
   1042 	uint32_t  sctps_timowindowprobe;     /* Number of window probe (T3) timers that fired */
   1043 	uint32_t  sctps_timoinit;            /* Number of INIT timers that fired */
   1044 	uint32_t  sctps_timosack;            /* Number of sack timers that fired */
   1045 	uint32_t  sctps_timoshutdown;        /* Number of shutdown timers that fired */
   1046 	uint32_t  sctps_timoheartbeat;       /* Number of heartbeat timers that fired */
   1047 	uint32_t  sctps_timocookie;          /* Number of times a cookie timeout fired */
   1048 	uint32_t  sctps_timosecret;          /* Number of times an endpoint changed its cookie secret*/
   1049 	uint32_t  sctps_timopathmtu;         /* Number of PMTU timers that fired */
   1050 	uint32_t  sctps_timoshutdownack;     /* Number of shutdown ack timers that fired */
   1051 	uint32_t  sctps_timoshutdownguard;   /* Number of shutdown guard timers that fired */
   1052 	uint32_t  sctps_timostrmrst;         /* Number of stream reset timers that fired */
   1053 	uint32_t  sctps_timoearlyfr;         /* Number of early FR timers that fired */
   1054 	uint32_t  sctps_timoasconf;          /* Number of times an asconf timer fired */
   1055 	uint32_t  sctps_timodelprim;	     /* Number of times a prim_deleted timer fired */
   1056 	uint32_t  sctps_timoautoclose;       /* Number of times auto close timer fired */
   1057 	uint32_t  sctps_timoassockill;       /* Number of asoc free timers expired */
   1058 	uint32_t  sctps_timoinpkill;         /* Number of inp free timers expired */
   1059 	/* former early FR counters */
   1060 	uint32_t  sctps_spare[11];
   1061 	/* others */
   1062 	uint32_t  sctps_hdrops;	          /* packet shorter than header */
   1063 	uint32_t  sctps_badsum;	          /* checksum error             */
   1064 	uint32_t  sctps_noport;           /* no endpoint for port       */
   1065 	uint32_t  sctps_badvtag;          /* bad v-tag                  */
   1066 	uint32_t  sctps_badsid;           /* bad SID                    */
   1067 	uint32_t  sctps_nomem;            /* no memory                  */
   1068 	uint32_t  sctps_fastretransinrtt; /* number of multiple FR in a RTT window */
   1069 	uint32_t  sctps_markedretrans;
   1070 	uint32_t  sctps_naglesent;        /* nagle allowed sending      */
   1071 	uint32_t  sctps_naglequeued;      /* nagle doesn't allow sending */
   1072 	uint32_t  sctps_maxburstqueued;   /* max burst doesn't allow sending */
   1073 	uint32_t  sctps_ifnomemqueued;    /* look ahead tells us no memory in
   1074                                          * interface ring buffer OR we had a
   1075 					 * send error and are queuing one send.
   1076                                          */
   1077 	uint32_t  sctps_windowprobed;     /* total number of window probes sent */
   1078 	uint32_t  sctps_lowlevelerr;	/* total times an output error causes us
   1079 					 * to clamp down on next user send.
   1080 					 */
   1081 	uint32_t  sctps_lowlevelerrusr;	/* total times sctp_senderrors were caused from
   1082 					 * a user send from a user invoked send not
   1083 					 * a sack response
   1084 					 */
   1085 	uint32_t  sctps_datadropchklmt;	/* Number of in data drops due to chunk limit reached */
   1086 	uint32_t  sctps_datadroprwnd;	/* Number of in data drops due to rwnd limit reached */
   1087 	uint32_t  sctps_ecnereducedcwnd;  /* Number of times a ECN reduced the cwnd */
   1088 	uint32_t  sctps_vtagexpress;	/* Used express lookup via vtag */
   1089 	uint32_t  sctps_vtagbogus;	/* Collision in express lookup. */
   1090 	uint32_t  sctps_primary_randry;	/* Number of times the sender ran dry of user data on primary */
   1091 	uint32_t  sctps_cmt_randry;       /* Same for above */
   1092 	uint32_t  sctps_slowpath_sack;    /* Sacks the slow way */
   1093 	uint32_t  sctps_wu_sacks_sent;	/* Window Update only sacks sent */
   1094 	uint32_t  sctps_sends_with_flags; /* number of sends with sinfo_flags !=0 */
   1095 	uint32_t  sctps_sends_with_unord; /* number of unordered sends */
   1096 	uint32_t  sctps_sends_with_eof; 	/* number of sends with EOF flag set */
   1097 	uint32_t  sctps_sends_with_abort; /* number of sends with ABORT flag set */
   1098 	uint32_t  sctps_protocol_drain_calls;	/* number of times protocol drain called */
   1099 	uint32_t  sctps_protocol_drains_done; 	/* number of times we did a protocol drain */
   1100 	uint32_t  sctps_read_peeks;	/* Number of times recv was called with peek */
   1101 	uint32_t  sctps_cached_chk;       /* Number of cached chunks used */
   1102 	uint32_t  sctps_cached_strmoq;    /* Number of cached stream oq's used */
   1103 	uint32_t  sctps_left_abandon;     /* Number of unread messages abandoned by close */
   1104 	uint32_t  sctps_send_burst_avoid; /* Unused */
   1105 	uint32_t  sctps_send_cwnd_avoid;  /* Send cwnd full  avoidance, already max burst inflight to net */
   1106 	uint32_t  sctps_fwdtsn_map_over;  /* number of map array over-runs via fwd-tsn's */
   1107 	uint32_t  sctps_queue_upd_ecne;  /* Number of times we queued or updated an ECN chunk on send queue */
   1108 	uint32_t  sctps_reserved[31];     /* Future ABI compat - remove int's from here when adding new */
   1109 };
   1110 
   1111 #define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1)
   1112 #define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1)
   1113 #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
   1114 #define SCTP_STAT_INCR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x += _d)
   1115 #define SCTP_STAT_DECR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x -= _d)
   1116 #else
   1117 #define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d)
   1118 #define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d)
   1119 #endif
   1120 /* The following macros are for handling MIB values, */
   1121 #define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x)
   1122 #define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x)
   1123 #define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x)
   1124 #define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x)
   1125 #define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
   1126 #define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
   1127 
   1128 #if defined(__Userspace__)
   1129 union sctp_sockstore {
   1130 #if defined(INET)
   1131 	struct sockaddr_in sin;
   1132 #endif
   1133 #if defined(INET6)
   1134 	struct sockaddr_in6 sin6;
   1135 #endif
   1136 	struct sockaddr_conn sconn;
   1137 	struct sockaddr sa;
   1138 };
   1139 #else
   1140 union sctp_sockstore {
   1141 	struct sockaddr_in sin;
   1142 	struct sockaddr_in6 sin6;
   1143 	struct sockaddr sa;
   1144 };
   1145 #endif
   1146 
   1147 
   1148 /***********************************/
   1149 /* And something for us old timers */
   1150 /***********************************/
   1151 
   1152 #ifndef __APPLE__
   1153 #ifndef __Userspace__
   1154 #ifndef ntohll
   1155 #if defined(__Userspace_os_Linux)
   1156 #ifndef _BSD_SOURCE
   1157 #define _BSD_SOURCE
   1158 #endif
   1159 #include <endian.h>
   1160 #else
   1161 #include <sys/endian.h>
   1162 #endif
   1163 #define ntohll(x) be64toh(x)
   1164 #endif
   1165 
   1166 #ifndef htonll
   1167 #if defined(__Userspace_os_Linux)
   1168 #ifndef _BSD_SOURCE
   1169 #define _BSD_SOURCE
   1170 #endif
   1171 #include <endian.h>
   1172 #else
   1173 #include <sys/endian.h>
   1174 #endif
   1175 #define htonll(x) htobe64(x)
   1176 #endif
   1177 #endif
   1178 #endif
   1179 /***********************************/
   1180 
   1181 
   1182 struct xsctp_inpcb {
   1183 	uint32_t last;
   1184 	uint32_t flags;
   1185 #if defined(__FreeBSD__) && __FreeBSD_version < 1000048
   1186 	uint32_t features;
   1187 #else
   1188 	uint64_t features;
   1189 #endif
   1190 	uint32_t total_sends;
   1191 	uint32_t total_recvs;
   1192 	uint32_t total_nospaces;
   1193 	uint32_t fragmentation_point;
   1194 	uint16_t local_port;
   1195 	uint16_t qlen;
   1196 	uint16_t maxqlen;
   1197 #if defined(__Windows__)
   1198 	uint16_t padding;
   1199 #endif
   1200 #if defined(__FreeBSD__) && __FreeBSD_version < 1000048
   1201 	uint32_t extra_padding[32]; /* future */
   1202 #else
   1203 	uint32_t extra_padding[31]; /* future */
   1204 #endif
   1205 };
   1206 
   1207 struct xsctp_tcb {
   1208 	union sctp_sockstore primary_addr;      /* sctpAssocEntry 5/6 */
   1209 	uint32_t last;
   1210 	uint32_t heartbeat_interval;            /* sctpAssocEntry 7   */
   1211 	uint32_t state;                         /* sctpAssocEntry 8   */
   1212 	uint32_t in_streams;                    /* sctpAssocEntry 9   */
   1213 	uint32_t out_streams;                   /* sctpAssocEntry 10  */
   1214 	uint32_t max_nr_retrans;                /* sctpAssocEntry 11  */
   1215 	uint32_t primary_process;               /* sctpAssocEntry 12  */
   1216 	uint32_t T1_expireries;                 /* sctpAssocEntry 13  */
   1217 	uint32_t T2_expireries;                 /* sctpAssocEntry 14  */
   1218 	uint32_t retransmitted_tsns;            /* sctpAssocEntry 15  */
   1219 	uint32_t total_sends;
   1220 	uint32_t total_recvs;
   1221 	uint32_t local_tag;
   1222 	uint32_t remote_tag;
   1223 	uint32_t initial_tsn;
   1224 	uint32_t highest_tsn;
   1225 	uint32_t cumulative_tsn;
   1226 	uint32_t cumulative_tsn_ack;
   1227 	uint32_t mtu;
   1228 	uint32_t refcnt;
   1229 	uint16_t local_port;                    /* sctpAssocEntry 3   */
   1230 	uint16_t remote_port;                   /* sctpAssocEntry 4   */
   1231 	struct sctp_timeval start_time;         /* sctpAssocEntry 16  */
   1232 	struct sctp_timeval discontinuity_time; /* sctpAssocEntry 17  */
   1233 #if defined(__FreeBSD__)
   1234 #if __FreeBSD_version >= 800000
   1235 	uint32_t peers_rwnd;
   1236 	sctp_assoc_t assoc_id;                  /* sctpAssocEntry 1   */
   1237 	uint32_t extra_padding[32];              /* future */
   1238 #else
   1239 #endif
   1240 #else
   1241 	uint32_t peers_rwnd;
   1242 	sctp_assoc_t assoc_id;                  /* sctpAssocEntry 1   */
   1243 	uint32_t extra_padding[32];              /* future */
   1244 #endif
   1245 };
   1246 
   1247 struct xsctp_laddr {
   1248 	union sctp_sockstore address;    /* sctpAssocLocalAddrEntry 1/2 */
   1249 	uint32_t last;
   1250 	struct sctp_timeval start_time;  /* sctpAssocLocalAddrEntry 3   */
   1251 	uint32_t extra_padding[32];       /* future */
   1252 };
   1253 
   1254 struct xsctp_raddr {
   1255 	union sctp_sockstore address;      /* sctpAssocLocalRemEntry 1/2 */
   1256 	uint32_t last;
   1257 	uint32_t rto;                      /* sctpAssocLocalRemEntry 5   */
   1258 	uint32_t max_path_rtx;             /* sctpAssocLocalRemEntry 6   */
   1259 	uint32_t rtx;                      /* sctpAssocLocalRemEntry 7   */
   1260 	uint32_t error_counter;            /*                            */
   1261 	uint32_t cwnd;                     /*                            */
   1262 	uint32_t flight_size;              /*                            */
   1263 	uint32_t mtu;                      /*                            */
   1264 	uint8_t active;                    /* sctpAssocLocalRemEntry 3   */
   1265 	uint8_t confirmed;                 /*                            */
   1266 	uint8_t heartbeat_enabled;         /* sctpAssocLocalRemEntry 4   */
   1267 	uint8_t potentially_failed;
   1268 	struct sctp_timeval start_time;    /* sctpAssocLocalRemEntry 8   */
   1269 #if defined(__FreeBSD__)
   1270 #if __FreeBSD_version >= 800000
   1271 	uint32_t rtt;
   1272 	uint32_t heartbeat_interval;
   1273 	uint32_t extra_padding[31];              /* future */
   1274 #endif
   1275 #else
   1276 	uint32_t rtt;
   1277 	uint32_t heartbeat_interval;
   1278 	uint32_t extra_padding[31];              /* future */
   1279 #endif
   1280 };
   1281 
   1282 #define SCTP_MAX_LOGGING_SIZE 30000
   1283 #define SCTP_TRACE_PARAMS 6                /* This number MUST be even   */
   1284 
   1285 struct sctp_log_entry {
   1286 	uint64_t timestamp;
   1287 	uint32_t subsys;
   1288 	uint32_t padding;
   1289 	uint32_t params[SCTP_TRACE_PARAMS];
   1290 };
   1291 
   1292 struct sctp_log {
   1293 	struct sctp_log_entry entry[SCTP_MAX_LOGGING_SIZE];
   1294 	uint32_t index;
   1295 	uint32_t padding;
   1296 };
   1297 
   1298 /*
   1299  * Kernel defined for sctp_send
   1300  */
   1301 #if defined(_KERNEL) || defined(__Userspace__)
   1302 int
   1303 sctp_lower_sosend(struct socket *so,
   1304     struct sockaddr *addr,
   1305     struct uio *uio,
   1306 #if defined(__Panda__)
   1307     pakhandle_type i_pak,
   1308     pakhandle_type i_control,
   1309 #else
   1310     struct mbuf *i_pak,
   1311     struct mbuf *control,
   1312 #endif
   1313     int flags,
   1314     struct sctp_sndrcvinfo *srcv
   1315 #if !(defined(__Panda__) || defined(__Userspace__))
   1316 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
   1317     ,struct thread *p
   1318 #elif defined(__Windows__)
   1319     , PKTHREAD p
   1320 #else
   1321     ,struct proc *p
   1322 #endif
   1323 #endif
   1324 );
   1325 
   1326 int
   1327 sctp_sorecvmsg(struct socket *so,
   1328     struct uio *uio,
   1329 #if defined(__Panda__)
   1330     particletype **mp,
   1331 #else
   1332     struct mbuf **mp,
   1333 #endif
   1334     struct sockaddr *from,
   1335     int fromlen,
   1336     int *msg_flags,
   1337     struct sctp_sndrcvinfo *sinfo,
   1338     int filling_sinfo);
   1339 #endif
   1340 
   1341 /*
   1342  * API system calls
   1343  */
   1344 #if !(defined(_KERNEL)) && !(defined(__Userspace__))
   1345 
   1346 __BEGIN_DECLS
   1347 #if defined(__FreeBSD__) && __FreeBSD_version < 902000
   1348 int	sctp_peeloff __P((int, sctp_assoc_t));
   1349 int	sctp_bindx __P((int, struct sockaddr *, int, int));
   1350 int	sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *));
   1351 int	sctp_getaddrlen __P((sa_family_t));
   1352 int	sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **));
   1353 void	sctp_freepaddrs __P((struct sockaddr *));
   1354 int	sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **));
   1355 void	sctp_freeladdrs __P((struct sockaddr *));
   1356 int	sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *));
   1357 
   1358 /* deprecated */
   1359 ssize_t	sctp_sendmsg __P((int, const void *, size_t, const struct sockaddr *,
   1360 	    socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
   1361 
   1362 /* deprecated */
   1363 ssize_t	sctp_send __P((int, const void *, size_t,
   1364 	    const struct sctp_sndrcvinfo *, int));
   1365 
   1366 /* deprecated */
   1367 ssize_t	sctp_sendx __P((int, const void *, size_t, struct sockaddr *,
   1368 	    int, struct sctp_sndrcvinfo *, int));
   1369 
   1370 /* deprecated */
   1371 ssize_t	sctp_sendmsgx __P((int sd, const void *, size_t, struct sockaddr *,
   1372 	    int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
   1373 
   1374 sctp_assoc_t	sctp_getassocid __P((int, struct sockaddr *));
   1375 
   1376 /* deprecated */
   1377 ssize_t	sctp_recvmsg __P((int, void *, size_t, struct sockaddr *, socklen_t *,
   1378 	    struct sctp_sndrcvinfo *, int *));
   1379 
   1380 ssize_t	sctp_sendv __P((int, const struct iovec *, int, struct sockaddr *,
   1381 	    int, void *, socklen_t, unsigned int, int));
   1382 
   1383 ssize_t	sctp_recvv __P((int, const struct iovec *, int, struct sockaddr *,
   1384 	    socklen_t *, void *, socklen_t *, unsigned int *, int *));
   1385 #else
   1386 int	sctp_peeloff(int, sctp_assoc_t);
   1387 int	sctp_bindx(int, struct sockaddr *, int, int);
   1388 int	sctp_connectx(int, const struct sockaddr *, int, sctp_assoc_t *);
   1389 int	sctp_getaddrlen(sa_family_t);
   1390 int	sctp_getpaddrs(int, sctp_assoc_t, struct sockaddr **);
   1391 void	sctp_freepaddrs(struct sockaddr *);
   1392 int	sctp_getladdrs(int, sctp_assoc_t, struct sockaddr **);
   1393 void	sctp_freeladdrs(struct sockaddr *);
   1394 int	sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *);
   1395 
   1396 /* deprecated */
   1397 ssize_t	sctp_sendmsg(int, const void *, size_t, const struct sockaddr *,
   1398 	    socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
   1399 
   1400 /* deprecated */
   1401 ssize_t	sctp_send(int, const void *, size_t,
   1402 	    const struct sctp_sndrcvinfo *, int);
   1403 
   1404 /* deprecated */
   1405 ssize_t	sctp_sendx(int, const void *, size_t, struct sockaddr *,
   1406 	    int, struct sctp_sndrcvinfo *, int);
   1407 
   1408 /* deprecated */
   1409 ssize_t	sctp_sendmsgx(int sd, const void *, size_t, struct sockaddr *,
   1410 	    int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
   1411 
   1412 sctp_assoc_t	sctp_getassocid(int, struct sockaddr *);
   1413 
   1414 /* deprecated */
   1415 ssize_t	sctp_recvmsg(int, void *, size_t, struct sockaddr *, socklen_t *,
   1416 	    struct sctp_sndrcvinfo *, int *);
   1417 
   1418 ssize_t	sctp_sendv(int, const struct iovec *, int, struct sockaddr *,
   1419 	    int, void *, socklen_t, unsigned int, int);
   1420 
   1421 ssize_t	sctp_recvv(int, const struct iovec *, int, struct sockaddr *,
   1422 	    socklen_t *, void *, socklen_t *, unsigned int *, int *);
   1423 #endif
   1424 __END_DECLS
   1425 
   1426 #endif				/* !_KERNEL */
   1427 #endif				/* !__sctp_uio_h__ */
   1428