tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

sctp_uio.h (41778B)


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