netwerk/sctp/src/usrsctp.h

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

michael@0 1 /*-
michael@0 2 * Copyright (c) 2009-2010 Brad Penoff
michael@0 3 * Copyright (c) 2009-2010 Humaira Kamal
michael@0 4 * Copyright (c) 2011-2012 Irene Ruengeler
michael@0 5 * Copyright (c) 2011-2012 Michael Tuexen
michael@0 6 *
michael@0 7 * All rights reserved.
michael@0 8 *
michael@0 9 * Redistribution and use in source and binary forms, with or without
michael@0 10 * modification, are permitted provided that the following conditions
michael@0 11 * are met:
michael@0 12 * 1. Redistributions of source code must retain the above copyright
michael@0 13 * notice, this list of conditions and the following disclaimer.
michael@0 14 * 2. Redistributions in binary form must reproduce the above copyright
michael@0 15 * notice, this list of conditions and the following disclaimer in the
michael@0 16 * documentation and/or other materials provided with the distribution.
michael@0 17 *
michael@0 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
michael@0 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
michael@0 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
michael@0 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
michael@0 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
michael@0 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
michael@0 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
michael@0 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
michael@0 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
michael@0 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@0 28 * SUCH DAMAGE.
michael@0 29 */
michael@0 30
michael@0 31 #ifndef __USRSCTP_H__
michael@0 32 #define __USRSCTP_H__
michael@0 33
michael@0 34 #ifdef __cplusplus
michael@0 35 extern "C" {
michael@0 36 #endif
michael@0 37
michael@0 38 #include <sys/types.h>
michael@0 39 #ifdef _WIN32
michael@0 40 #ifdef _MSC_VER
michael@0 41 #pragma warning(disable: 4200)
michael@0 42 #endif
michael@0 43 #include <winsock2.h>
michael@0 44 #include <ws2tcpip.h>
michael@0 45 #else
michael@0 46 #include <sys/socket.h>
michael@0 47 #include <netinet/in.h>
michael@0 48 #endif
michael@0 49
michael@0 50 #ifndef MSG_NOTIFICATION
michael@0 51 /* This definition MUST be in sync with usrsctplib/user_socketvar.h */
michael@0 52 #define MSG_NOTIFICATION 0x2000
michael@0 53 #endif
michael@0 54
michael@0 55 #ifndef IPPROTO_SCTP
michael@0 56 /* This is the IANA assigned protocol number of SCTP. */
michael@0 57 #define IPPROTO_SCTP 132
michael@0 58 #endif
michael@0 59
michael@0 60 #ifdef _WIN32
michael@0 61 #if defined(_MSC_VER) && _MSC_VER >= 1600
michael@0 62 #include <stdint.h>
michael@0 63 #elif defined(SCTP_STDINT_INCLUDE)
michael@0 64 #include SCTP_STDINT_INCLUDE
michael@0 65 #else
michael@0 66 #define uint8_t unsigned __int8
michael@0 67 #define uint16_t unsigned __int16
michael@0 68 #define uint32_t unsigned __int32
michael@0 69 #define int16_t __int16
michael@0 70 #define int32_t __int32
michael@0 71 #endif
michael@0 72
michael@0 73 #define ssize_t __int64
michael@0 74 #define MSG_EOR 0x8
michael@0 75 #ifndef EWOULDBLOCK
michael@0 76 #define EWOULDBLOCK WSAEWOULDBLOCK
michael@0 77 #endif
michael@0 78 #ifndef EINPROGRESS
michael@0 79 #define EINPROGRESS WSAEINPROGRESS
michael@0 80 #endif
michael@0 81 #define SHUT_RD 1
michael@0 82 #define SHUT_WR 2
michael@0 83 #define SHUT_RDWR 3
michael@0 84 #endif
michael@0 85
michael@0 86 typedef uint32_t sctp_assoc_t;
michael@0 87
michael@0 88 #define AF_CONN 123
michael@0 89 /* The definition of struct sockaddr_conn MUST be in
michael@0 90 * tune with other sockaddr_* structures.
michael@0 91 */
michael@0 92 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
michael@0 93 struct sockaddr_conn {
michael@0 94 uint8_t sconn_len;
michael@0 95 uint8_t sconn_family;
michael@0 96 uint16_t sconn_port;
michael@0 97 void *sconn_addr;
michael@0 98 };
michael@0 99 #else
michael@0 100 struct sockaddr_conn {
michael@0 101 uint16_t sconn_family;
michael@0 102 uint16_t sconn_port;
michael@0 103 void *sconn_addr;
michael@0 104 };
michael@0 105 #endif
michael@0 106
michael@0 107 union sctp_sockstore {
michael@0 108 #if defined(INET)
michael@0 109 struct sockaddr_in sin;
michael@0 110 #endif
michael@0 111 #if defined(INET6)
michael@0 112 struct sockaddr_in6 sin6;
michael@0 113 #endif
michael@0 114 struct sockaddr_conn sconn;
michael@0 115 struct sockaddr sa;
michael@0 116 };
michael@0 117
michael@0 118 #define SCTP_FUTURE_ASSOC 0
michael@0 119 #define SCTP_CURRENT_ASSOC 1
michael@0 120 #define SCTP_ALL_ASSOC 2
michael@0 121
michael@0 122 /*** Structures and definitions to use the socket API ***/
michael@0 123
michael@0 124 #define SCTP_ALIGN_RESV_PAD 92
michael@0 125 #define SCTP_ALIGN_RESV_PAD_SHORT 76
michael@0 126
michael@0 127 struct sctp_rcvinfo {
michael@0 128 uint16_t rcv_sid;
michael@0 129 uint16_t rcv_ssn;
michael@0 130 uint16_t rcv_flags;
michael@0 131 uint32_t rcv_ppid;
michael@0 132 uint32_t rcv_tsn;
michael@0 133 uint32_t rcv_cumtsn;
michael@0 134 uint32_t rcv_context;
michael@0 135 sctp_assoc_t rcv_assoc_id;
michael@0 136 };
michael@0 137
michael@0 138 struct sctp_nxtinfo {
michael@0 139 uint16_t nxt_sid;
michael@0 140 uint16_t nxt_flags;
michael@0 141 uint32_t nxt_ppid;
michael@0 142 uint32_t nxt_length;
michael@0 143 sctp_assoc_t nxt_assoc_id;
michael@0 144 };
michael@0 145
michael@0 146 #define SCTP_NO_NEXT_MSG 0x0000
michael@0 147 #define SCTP_NEXT_MSG_AVAIL 0x0001
michael@0 148 #define SCTP_NEXT_MSG_ISCOMPLETE 0x0002
michael@0 149 #define SCTP_NEXT_MSG_IS_UNORDERED 0x0004
michael@0 150 #define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008
michael@0 151
michael@0 152 struct sctp_recvv_rn {
michael@0 153 struct sctp_rcvinfo recvv_rcvinfo;
michael@0 154 struct sctp_nxtinfo recvv_nxtinfo;
michael@0 155 };
michael@0 156
michael@0 157 #define SCTP_RECVV_NOINFO 0
michael@0 158 #define SCTP_RECVV_RCVINFO 1
michael@0 159 #define SCTP_RECVV_NXTINFO 2
michael@0 160 #define SCTP_RECVV_RN 3
michael@0 161
michael@0 162 #define SCTP_SENDV_NOINFO 0
michael@0 163 #define SCTP_SENDV_SNDINFO 1
michael@0 164 #define SCTP_SENDV_PRINFO 2
michael@0 165 #define SCTP_SENDV_AUTHINFO 3
michael@0 166 #define SCTP_SENDV_SPA 4
michael@0 167
michael@0 168 #define SCTP_SEND_SNDINFO_VALID 0x00000001
michael@0 169 #define SCTP_SEND_PRINFO_VALID 0x00000002
michael@0 170 #define SCTP_SEND_AUTHINFO_VALID 0x00000004
michael@0 171
michael@0 172 struct sctp_snd_all_completes {
michael@0 173 uint16_t sall_stream;
michael@0 174 uint16_t sall_flags;
michael@0 175 uint32_t sall_ppid;
michael@0 176 uint32_t sall_context;
michael@0 177 uint32_t sall_num_sent;
michael@0 178 uint32_t sall_num_failed;
michael@0 179 };
michael@0 180
michael@0 181 struct sctp_sndinfo {
michael@0 182 uint16_t snd_sid;
michael@0 183 uint16_t snd_flags;
michael@0 184 uint32_t snd_ppid;
michael@0 185 uint32_t snd_context;
michael@0 186 sctp_assoc_t snd_assoc_id;
michael@0 187 };
michael@0 188
michael@0 189 struct sctp_prinfo {
michael@0 190 uint16_t pr_policy;
michael@0 191 uint32_t pr_value;
michael@0 192 };
michael@0 193
michael@0 194 struct sctp_authinfo {
michael@0 195 uint16_t auth_keynumber;
michael@0 196 };
michael@0 197
michael@0 198 struct sctp_sendv_spa {
michael@0 199 uint32_t sendv_flags;
michael@0 200 struct sctp_sndinfo sendv_sndinfo;
michael@0 201 struct sctp_prinfo sendv_prinfo;
michael@0 202 struct sctp_authinfo sendv_authinfo;
michael@0 203 };
michael@0 204
michael@0 205 struct sctp_udpencaps {
michael@0 206 struct sockaddr_storage sue_address;
michael@0 207 uint32_t sue_assoc_id;
michael@0 208 uint16_t sue_port;
michael@0 209 };
michael@0 210
michael@0 211 /******** Notifications **************/
michael@0 212
michael@0 213 /* notification types */
michael@0 214 #define SCTP_ASSOC_CHANGE 0x0001
michael@0 215 #define SCTP_PEER_ADDR_CHANGE 0x0002
michael@0 216 #define SCTP_REMOTE_ERROR 0x0003
michael@0 217 #define SCTP_SEND_FAILED 0x0004
michael@0 218 #define SCTP_SHUTDOWN_EVENT 0x0005
michael@0 219 #define SCTP_ADAPTATION_INDICATION 0x0006
michael@0 220 #define SCTP_PARTIAL_DELIVERY_EVENT 0x0007
michael@0 221 #define SCTP_AUTHENTICATION_EVENT 0x0008
michael@0 222 #define SCTP_STREAM_RESET_EVENT 0x0009
michael@0 223 #define SCTP_SENDER_DRY_EVENT 0x000a
michael@0 224 #define SCTP_NOTIFICATIONS_STOPPED_EVENT 0x000b
michael@0 225 #define SCTP_ASSOC_RESET_EVENT 0x000c
michael@0 226 #define SCTP_STREAM_CHANGE_EVENT 0x000d
michael@0 227 #define SCTP_SEND_FAILED_EVENT 0x000e
michael@0 228
michael@0 229 /* notification event structures */
michael@0 230
michael@0 231
michael@0 232 /* association change event */
michael@0 233 struct sctp_assoc_change {
michael@0 234 uint16_t sac_type;
michael@0 235 uint16_t sac_flags;
michael@0 236 uint32_t sac_length;
michael@0 237 uint16_t sac_state;
michael@0 238 uint16_t sac_error;
michael@0 239 uint16_t sac_outbound_streams;
michael@0 240 uint16_t sac_inbound_streams;
michael@0 241 sctp_assoc_t sac_assoc_id;
michael@0 242 uint8_t sac_info[]; /* not available yet */
michael@0 243 };
michael@0 244
michael@0 245 /* sac_state values */
michael@0 246 #define SCTP_COMM_UP 0x0001
michael@0 247 #define SCTP_COMM_LOST 0x0002
michael@0 248 #define SCTP_RESTART 0x0003
michael@0 249 #define SCTP_SHUTDOWN_COMP 0x0004
michael@0 250 #define SCTP_CANT_STR_ASSOC 0x0005
michael@0 251
michael@0 252 /* sac_info values */
michael@0 253 #define SCTP_ASSOC_SUPPORTS_PR 0x01
michael@0 254 #define SCTP_ASSOC_SUPPORTS_AUTH 0x02
michael@0 255 #define SCTP_ASSOC_SUPPORTS_ASCONF 0x03
michael@0 256 #define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04
michael@0 257 #define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05
michael@0 258 #define SCTP_ASSOC_SUPPORTS_MAX 0x05
michael@0 259
michael@0 260 /* Address event */
michael@0 261 struct sctp_paddr_change {
michael@0 262 uint16_t spc_type;
michael@0 263 uint16_t spc_flags;
michael@0 264 uint32_t spc_length;
michael@0 265 struct sockaddr_storage spc_aaddr;
michael@0 266 uint32_t spc_state;
michael@0 267 uint32_t spc_error;
michael@0 268 sctp_assoc_t spc_assoc_id;
michael@0 269 uint8_t spc_padding[4];
michael@0 270 };
michael@0 271
michael@0 272 /* paddr state values */
michael@0 273 #define SCTP_ADDR_AVAILABLE 0x0001
michael@0 274 #define SCTP_ADDR_UNREACHABLE 0x0002
michael@0 275 #define SCTP_ADDR_REMOVED 0x0003
michael@0 276 #define SCTP_ADDR_ADDED 0x0004
michael@0 277 #define SCTP_ADDR_MADE_PRIM 0x0005
michael@0 278 #define SCTP_ADDR_CONFIRMED 0x0006
michael@0 279
michael@0 280 /* remote error events */
michael@0 281 struct sctp_remote_error {
michael@0 282 uint16_t sre_type;
michael@0 283 uint16_t sre_flags;
michael@0 284 uint32_t sre_length;
michael@0 285 uint16_t sre_error;
michael@0 286 sctp_assoc_t sre_assoc_id;
michael@0 287 uint8_t sre_data[4];
michael@0 288 };
michael@0 289
michael@0 290 /* shutdown event */
michael@0 291 struct sctp_shutdown_event {
michael@0 292 uint16_t sse_type;
michael@0 293 uint16_t sse_flags;
michael@0 294 uint32_t sse_length;
michael@0 295 sctp_assoc_t sse_assoc_id;
michael@0 296 };
michael@0 297
michael@0 298 /* Adaptation layer indication */
michael@0 299 struct sctp_adaptation_event {
michael@0 300 uint16_t sai_type;
michael@0 301 uint16_t sai_flags;
michael@0 302 uint32_t sai_length;
michael@0 303 uint32_t sai_adaptation_ind;
michael@0 304 sctp_assoc_t sai_assoc_id;
michael@0 305 };
michael@0 306
michael@0 307 /* Partial delivery event */
michael@0 308 struct sctp_pdapi_event {
michael@0 309 uint16_t pdapi_type;
michael@0 310 uint16_t pdapi_flags;
michael@0 311 uint32_t pdapi_length;
michael@0 312 uint32_t pdapi_indication;
michael@0 313 uint32_t pdapi_stream;
michael@0 314 uint32_t pdapi_seq;
michael@0 315 sctp_assoc_t pdapi_assoc_id;
michael@0 316 };
michael@0 317
michael@0 318 /* indication values */
michael@0 319 #define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001
michael@0 320
michael@0 321 /* SCTP authentication event */
michael@0 322 struct sctp_authkey_event {
michael@0 323 uint16_t auth_type;
michael@0 324 uint16_t auth_flags;
michael@0 325 uint32_t auth_length;
michael@0 326 uint16_t auth_keynumber;
michael@0 327 uint32_t auth_indication;
michael@0 328 sctp_assoc_t auth_assoc_id;
michael@0 329 };
michael@0 330
michael@0 331 /* indication values */
michael@0 332 #define SCTP_AUTH_NEW_KEY 0x0001
michael@0 333 #define SCTP_AUTH_NO_AUTH 0x0002
michael@0 334 #define SCTP_AUTH_FREE_KEY 0x0003
michael@0 335
michael@0 336 /* SCTP sender dry event */
michael@0 337 struct sctp_sender_dry_event {
michael@0 338 uint16_t sender_dry_type;
michael@0 339 uint16_t sender_dry_flags;
michael@0 340 uint32_t sender_dry_length;
michael@0 341 sctp_assoc_t sender_dry_assoc_id;
michael@0 342 };
michael@0 343
michael@0 344
michael@0 345 /* Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT */
michael@0 346 struct sctp_stream_reset_event {
michael@0 347 uint16_t strreset_type;
michael@0 348 uint16_t strreset_flags;
michael@0 349 uint32_t strreset_length;
michael@0 350 sctp_assoc_t strreset_assoc_id;
michael@0 351 uint16_t strreset_stream_list[];
michael@0 352 };
michael@0 353
michael@0 354 /* flags in stream_reset_event (strreset_flags) */
michael@0 355 #define SCTP_STREAM_RESET_INCOMING_SSN 0x0001
michael@0 356 #define SCTP_STREAM_RESET_OUTGOING_SSN 0x0002
michael@0 357 #define SCTP_STREAM_RESET_DENIED 0x0004 /* SCTP_STRRESET_FAILED */
michael@0 358 #define SCTP_STREAM_RESET_FAILED 0x0008 /* SCTP_STRRESET_FAILED */
michael@0 359 #define SCTP_STREAM_CHANGED_DENIED 0x0010
michael@0 360
michael@0 361 #define SCTP_STREAM_RESET_INCOMING 0x00000001
michael@0 362 #define SCTP_STREAM_RESET_OUTGOING 0x00000002
michael@0 363
michael@0 364
michael@0 365 /* Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT */
michael@0 366 struct sctp_assoc_reset_event {
michael@0 367 uint16_t assocreset_type;
michael@0 368 uint16_t assocreset_flags;
michael@0 369 uint32_t assocreset_length;
michael@0 370 sctp_assoc_t assocreset_assoc_id;
michael@0 371 uint32_t assocreset_local_tsn;
michael@0 372 uint32_t assocreset_remote_tsn;
michael@0 373 };
michael@0 374
michael@0 375 #define SCTP_ASSOC_RESET_DENIED 0x0004
michael@0 376 #define SCTP_ASSOC_RESET_FAILED 0x0008
michael@0 377
michael@0 378
michael@0 379 /* Stream change event - subscribe to SCTP_STREAM_CHANGE_EVENT */
michael@0 380 struct sctp_stream_change_event {
michael@0 381 uint16_t strchange_type;
michael@0 382 uint16_t strchange_flags;
michael@0 383 uint32_t strchange_length;
michael@0 384 sctp_assoc_t strchange_assoc_id;
michael@0 385 uint16_t strchange_instrms;
michael@0 386 uint16_t strchange_outstrms;
michael@0 387 };
michael@0 388
michael@0 389 #define SCTP_STREAM_CHANGE_DENIED 0x0004
michael@0 390 #define SCTP_STREAM_CHANGE_FAILED 0x0008
michael@0 391
michael@0 392
michael@0 393 /* SCTP send failed event */
michael@0 394 struct sctp_send_failed_event {
michael@0 395 uint16_t ssfe_type;
michael@0 396 uint16_t ssfe_flags;
michael@0 397 uint32_t ssfe_length;
michael@0 398 uint32_t ssfe_error;
michael@0 399 struct sctp_sndinfo ssfe_info;
michael@0 400 sctp_assoc_t ssfe_assoc_id;
michael@0 401 uint8_t ssfe_data[];
michael@0 402 };
michael@0 403
michael@0 404 /* flag that indicates state of data */
michael@0 405 #define SCTP_DATA_UNSENT 0x0001 /* inqueue never on wire */
michael@0 406 #define SCTP_DATA_SENT 0x0002 /* on wire at failure */
michael@0 407
michael@0 408 /* SCTP event option */
michael@0 409 struct sctp_event {
michael@0 410 sctp_assoc_t se_assoc_id;
michael@0 411 uint16_t se_type;
michael@0 412 uint8_t se_on;
michael@0 413 };
michael@0 414
michael@0 415 union sctp_notification {
michael@0 416 struct sctp_tlv {
michael@0 417 uint16_t sn_type;
michael@0 418 uint16_t sn_flags;
michael@0 419 uint32_t sn_length;
michael@0 420 } sn_header;
michael@0 421 struct sctp_assoc_change sn_assoc_change;
michael@0 422 struct sctp_paddr_change sn_paddr_change;
michael@0 423 struct sctp_remote_error sn_remote_error;
michael@0 424 struct sctp_shutdown_event sn_shutdown_event;
michael@0 425 struct sctp_adaptation_event sn_adaptation_event;
michael@0 426 struct sctp_pdapi_event sn_pdapi_event;
michael@0 427 struct sctp_authkey_event sn_auth_event;
michael@0 428 struct sctp_sender_dry_event sn_sender_dry_event;
michael@0 429 struct sctp_send_failed_event sn_send_failed_event;
michael@0 430 struct sctp_stream_reset_event sn_strreset_event;
michael@0 431 struct sctp_assoc_reset_event sn_assocreset_event;
michael@0 432 struct sctp_stream_change_event sn_strchange_event;
michael@0 433 };
michael@0 434
michael@0 435 struct sctp_event_subscribe {
michael@0 436 uint8_t sctp_data_io_event;
michael@0 437 uint8_t sctp_association_event;
michael@0 438 uint8_t sctp_address_event;
michael@0 439 uint8_t sctp_send_failure_event;
michael@0 440 uint8_t sctp_peer_error_event;
michael@0 441 uint8_t sctp_shutdown_event;
michael@0 442 uint8_t sctp_partial_delivery_event;
michael@0 443 uint8_t sctp_adaptation_layer_event;
michael@0 444 uint8_t sctp_authentication_event;
michael@0 445 uint8_t sctp_sender_dry_event;
michael@0 446 uint8_t sctp_stream_reset_event;
michael@0 447 };
michael@0 448
michael@0 449
michael@0 450
michael@0 451 /* Flags that go into the sinfo->sinfo_flags field */
michael@0 452 #define SCTP_NOTIFICATION 0x0010 /* next message is a notification */
michael@0 453 #define SCTP_COMPLETE 0x0020 /* next message is complete */
michael@0 454 #define SCTP_EOF 0x0100 /* Start shutdown procedures */
michael@0 455 #define SCTP_ABORT 0x0200 /* Send an ABORT to peer */
michael@0 456 #define SCTP_UNORDERED 0x0400 /* Message is un-ordered */
michael@0 457 #define SCTP_ADDR_OVER 0x0800 /* Override the primary-address */
michael@0 458 #define SCTP_SENDALL 0x1000 /* Send this on all associations */
michael@0 459 #define SCTP_EOR 0x2000 /* end of message signal */
michael@0 460 #define SCTP_SACK_IMMEDIATELY 0x4000 /* Set I-Bit */
michael@0 461
michael@0 462 #define INVALID_SINFO_FLAG(x) (((x) & 0xfffffff0 \
michael@0 463 & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\
michael@0 464 SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR |\
michael@0 465 SCTP_SACK_IMMEDIATELY)) != 0)
michael@0 466 /* for the endpoint */
michael@0 467
michael@0 468 /* The lower byte is an enumeration of PR-SCTP policies */
michael@0 469 #define SCTP_PR_SCTP_NONE 0x0000 /* Reliable transfer */
michael@0 470 #define SCTP_PR_SCTP_TTL 0x0001 /* Time based PR-SCTP */
michael@0 471 #define SCTP_PR_SCTP_BUF 0x0002 /* Buffer based PR-SCTP */
michael@0 472 #define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
michael@0 473
michael@0 474 #define PR_SCTP_POLICY(x) ((x) & 0x0f)
michael@0 475 #define PR_SCTP_ENABLED(x) (PR_SCTP_POLICY(x) != SCTP_PR_SCTP_NONE)
michael@0 476 #define PR_SCTP_TTL_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL)
michael@0 477 #define PR_SCTP_BUF_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF)
michael@0 478 #define PR_SCTP_RTX_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX)
michael@0 479 #define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX)
michael@0 480
michael@0 481
michael@0 482 /*
michael@0 483 * user socket options: socket API defined
michael@0 484 */
michael@0 485 /*
michael@0 486 * read-write options
michael@0 487 */
michael@0 488 #define SCTP_RTOINFO 0x00000001
michael@0 489 #define SCTP_ASSOCINFO 0x00000002
michael@0 490 #define SCTP_INITMSG 0x00000003
michael@0 491 #define SCTP_NODELAY 0x00000004
michael@0 492 #define SCTP_AUTOCLOSE 0x00000005
michael@0 493 #define SCTP_PRIMARY_ADDR 0x00000007
michael@0 494 #define SCTP_ADAPTATION_LAYER 0x00000008
michael@0 495 #define SCTP_DISABLE_FRAGMENTS 0x00000009
michael@0 496 #define SCTP_PEER_ADDR_PARAMS 0x0000000a
michael@0 497 /* ancillary data/notification interest options */
michael@0 498 /* Without this applied we will give V4 and V6 addresses on a V6 socket */
michael@0 499 #define SCTP_I_WANT_MAPPED_V4_ADDR 0x0000000d
michael@0 500 #define SCTP_MAXSEG 0x0000000e
michael@0 501 #define SCTP_DELAYED_SACK 0x0000000f
michael@0 502 #define SCTP_FRAGMENT_INTERLEAVE 0x00000010
michael@0 503 #define SCTP_PARTIAL_DELIVERY_POINT 0x00000011
michael@0 504 /* authentication support */
michael@0 505 #define SCTP_HMAC_IDENT 0x00000014
michael@0 506 #define SCTP_AUTH_ACTIVE_KEY 0x00000015
michael@0 507 #define SCTP_AUTO_ASCONF 0x00000018
michael@0 508 #define SCTP_MAX_BURST 0x00000019
michael@0 509 /* assoc level context */
michael@0 510 #define SCTP_CONTEXT 0x0000001a
michael@0 511 /* explicit EOR signalling */
michael@0 512 #define SCTP_EXPLICIT_EOR 0x0000001b
michael@0 513 #define SCTP_REUSE_PORT 0x0000001c
michael@0 514
michael@0 515 #define SCTP_EVENT 0x0000001e
michael@0 516 #define SCTP_RECVRCVINFO 0x0000001f
michael@0 517 #define SCTP_RECVNXTINFO 0x00000020
michael@0 518 #define SCTP_DEFAULT_SNDINFO 0x00000021
michael@0 519 #define SCTP_DEFAULT_PRINFO 0x00000022
michael@0 520 #define SCTP_REMOTE_UDP_ENCAPS_PORT 0x00000024
michael@0 521
michael@0 522 #define SCTP_ENABLE_STREAM_RESET 0x00000900 /* struct sctp_assoc_value */
michael@0 523
michael@0 524 /*
michael@0 525 * read-only options
michael@0 526 */
michael@0 527 #define SCTP_STATUS 0x00000100
michael@0 528 #define SCTP_GET_PEER_ADDR_INFO 0x00000101
michael@0 529 /* authentication support */
michael@0 530 #define SCTP_PEER_AUTH_CHUNKS 0x00000102
michael@0 531 #define SCTP_LOCAL_AUTH_CHUNKS 0x00000103
michael@0 532 #define SCTP_GET_ASSOC_NUMBER 0x00000104
michael@0 533 #define SCTP_GET_ASSOC_ID_LIST 0x00000105
michael@0 534
michael@0 535 /*
michael@0 536 * write-only options
michael@0 537 */
michael@0 538 #define SCTP_SET_PEER_PRIMARY_ADDR 0x00000006
michael@0 539 #define SCTP_AUTH_CHUNK 0x00000012
michael@0 540 #define SCTP_AUTH_KEY 0x00000013
michael@0 541 #define SCTP_AUTH_DEACTIVATE_KEY 0x0000001d
michael@0 542 #define SCTP_AUTH_DELETE_KEY 0x00000016
michael@0 543 #define SCTP_RESET_STREAMS 0x00000901 /* struct sctp_reset_streams */
michael@0 544 #define SCTP_RESET_ASSOC 0x00000902 /* sctp_assoc_t */
michael@0 545 #define SCTP_ADD_STREAMS 0x00000903 /* struct sctp_add_streams */
michael@0 546
michael@0 547 struct sctp_initmsg {
michael@0 548 uint16_t sinit_num_ostreams;
michael@0 549 uint16_t sinit_max_instreams;
michael@0 550 uint16_t sinit_max_attempts;
michael@0 551 uint16_t sinit_max_init_timeo;
michael@0 552 };
michael@0 553
michael@0 554 struct sctp_rtoinfo {
michael@0 555 sctp_assoc_t srto_assoc_id;
michael@0 556 uint32_t srto_initial;
michael@0 557 uint32_t srto_max;
michael@0 558 uint32_t srto_min;
michael@0 559 };
michael@0 560
michael@0 561 struct sctp_assocparams {
michael@0 562 sctp_assoc_t sasoc_assoc_id;
michael@0 563 uint32_t sasoc_peer_rwnd;
michael@0 564 uint32_t sasoc_local_rwnd;
michael@0 565 uint32_t sasoc_cookie_life;
michael@0 566 uint16_t sasoc_asocmaxrxt;
michael@0 567 uint16_t sasoc_number_peer_destinations;
michael@0 568 };
michael@0 569
michael@0 570 struct sctp_setprim {
michael@0 571 struct sockaddr_storage ssp_addr;
michael@0 572 sctp_assoc_t ssp_assoc_id;
michael@0 573 uint8_t ssp_padding[4];
michael@0 574 };
michael@0 575
michael@0 576 struct sctp_setadaptation {
michael@0 577 uint32_t ssb_adaptation_ind;
michael@0 578 };
michael@0 579
michael@0 580 struct sctp_paddrparams {
michael@0 581 struct sockaddr_storage spp_address;
michael@0 582 sctp_assoc_t spp_assoc_id;
michael@0 583 uint32_t spp_hbinterval;
michael@0 584 uint32_t spp_pathmtu;
michael@0 585 uint32_t spp_flags;
michael@0 586 uint32_t spp_ipv6_flowlabel;
michael@0 587 uint16_t spp_pathmaxrxt;
michael@0 588 uint8_t spp_dscp;
michael@0 589 };
michael@0 590
michael@0 591 #define SPP_HB_ENABLE 0x00000001
michael@0 592 #define SPP_HB_DISABLE 0x00000002
michael@0 593 #define SPP_HB_DEMAND 0x00000004
michael@0 594 #define SPP_PMTUD_ENABLE 0x00000008
michael@0 595 #define SPP_PMTUD_DISABLE 0x00000010
michael@0 596 #define SPP_HB_TIME_IS_ZERO 0x00000080
michael@0 597 #define SPP_IPV6_FLOWLABEL 0x00000100
michael@0 598 #define SPP_DSCP 0x00000200
michael@0 599
michael@0 600 /* Used for SCTP_MAXSEG, SCTP_MAX_BURST, SCTP_ENABLE_STREAM_RESET, and SCTP_CONTEXT */
michael@0 601 struct sctp_assoc_value {
michael@0 602 sctp_assoc_t assoc_id;
michael@0 603 uint32_t assoc_value;
michael@0 604 };
michael@0 605
michael@0 606 /* To enable stream reset */
michael@0 607 #define SCTP_ENABLE_RESET_STREAM_REQ 0x00000001
michael@0 608 #define SCTP_ENABLE_RESET_ASSOC_REQ 0x00000002
michael@0 609 #define SCTP_ENABLE_CHANGE_ASSOC_REQ 0x00000004
michael@0 610 #define SCTP_ENABLE_VALUE_MASK 0x00000007
michael@0 611
michael@0 612 struct sctp_reset_streams {
michael@0 613 sctp_assoc_t srs_assoc_id;
michael@0 614 uint16_t srs_flags;
michael@0 615 uint16_t srs_number_streams; /* 0 == ALL */
michael@0 616 uint16_t srs_stream_list[]; /* list if strrst_num_streams is not 0 */
michael@0 617 };
michael@0 618
michael@0 619 struct sctp_add_streams {
michael@0 620 sctp_assoc_t sas_assoc_id;
michael@0 621 uint16_t sas_instrms;
michael@0 622 uint16_t sas_outstrms;
michael@0 623 };
michael@0 624
michael@0 625 struct sctp_hmacalgo {
michael@0 626 uint32_t shmac_number_of_idents;
michael@0 627 uint16_t shmac_idents[];
michael@0 628 };
michael@0 629
michael@0 630 /* AUTH hmac_id */
michael@0 631 #define SCTP_AUTH_HMAC_ID_RSVD 0x0000
michael@0 632 #define SCTP_AUTH_HMAC_ID_SHA1 0x0001 /* default, mandatory */
michael@0 633 #define SCTP_AUTH_HMAC_ID_SHA256 0x0003
michael@0 634 #define SCTP_AUTH_HMAC_ID_SHA224 0x0004
michael@0 635 #define SCTP_AUTH_HMAC_ID_SHA384 0x0005
michael@0 636 #define SCTP_AUTH_HMAC_ID_SHA512 0x0006
michael@0 637
michael@0 638
michael@0 639 struct sctp_sack_info {
michael@0 640 sctp_assoc_t sack_assoc_id;
michael@0 641 uint32_t sack_delay;
michael@0 642 uint32_t sack_freq;
michael@0 643 };
michael@0 644
michael@0 645 struct sctp_default_prinfo {
michael@0 646 uint16_t pr_policy;
michael@0 647 uint32_t pr_value;
michael@0 648 sctp_assoc_t pr_assoc_id;
michael@0 649 };
michael@0 650
michael@0 651 struct sctp_paddrinfo {
michael@0 652 struct sockaddr_storage spinfo_address;
michael@0 653 sctp_assoc_t spinfo_assoc_id;
michael@0 654 int32_t spinfo_state;
michael@0 655 uint32_t spinfo_cwnd;
michael@0 656 uint32_t spinfo_srtt;
michael@0 657 uint32_t spinfo_rto;
michael@0 658 uint32_t spinfo_mtu;
michael@0 659 };
michael@0 660
michael@0 661 struct sctp_status {
michael@0 662 sctp_assoc_t sstat_assoc_id;
michael@0 663 int32_t sstat_state;
michael@0 664 uint32_t sstat_rwnd;
michael@0 665 uint16_t sstat_unackdata;
michael@0 666 uint16_t sstat_penddata;
michael@0 667 uint16_t sstat_instrms;
michael@0 668 uint16_t sstat_outstrms;
michael@0 669 uint32_t sstat_fragmentation_point;
michael@0 670 struct sctp_paddrinfo sstat_primary;
michael@0 671 };
michael@0 672
michael@0 673 /*
michael@0 674 * user state values
michael@0 675 */
michael@0 676 #define SCTP_CLOSED 0x0000
michael@0 677 #define SCTP_BOUND 0x1000
michael@0 678 #define SCTP_LISTEN 0x2000
michael@0 679 #define SCTP_COOKIE_WAIT 0x0002
michael@0 680 #define SCTP_COOKIE_ECHOED 0x0004
michael@0 681 #define SCTP_ESTABLISHED 0x0008
michael@0 682 #define SCTP_SHUTDOWN_SENT 0x0010
michael@0 683 #define SCTP_SHUTDOWN_RECEIVED 0x0020
michael@0 684 #define SCTP_SHUTDOWN_ACK_SENT 0x0040
michael@0 685 #define SCTP_SHUTDOWN_PENDING 0x0080
michael@0 686
michael@0 687
michael@0 688 #define SCTP_ACTIVE 0x0001 /* SCTP_ADDR_REACHABLE */
michael@0 689 #define SCTP_INACTIVE 0x0002 /* neither SCTP_ADDR_REACHABLE
michael@0 690 nor SCTP_ADDR_UNCONFIRMED */
michael@0 691 #define SCTP_UNCONFIRMED 0x0200 /* SCTP_ADDR_UNCONFIRMED */
michael@0 692
michael@0 693 struct sctp_authchunks {
michael@0 694 sctp_assoc_t gauth_assoc_id;
michael@0 695 /* uint32_t gauth_number_of_chunks; not available */
michael@0 696 uint8_t gauth_chunks[];
michael@0 697 };
michael@0 698
michael@0 699 struct sctp_assoc_ids {
michael@0 700 uint32_t gaids_number_of_ids;
michael@0 701 sctp_assoc_t gaids_assoc_id[];
michael@0 702 };
michael@0 703
michael@0 704 struct sctp_setpeerprim {
michael@0 705 struct sockaddr_storage sspp_addr;
michael@0 706 sctp_assoc_t sspp_assoc_id;
michael@0 707 uint8_t sspp_padding[4];
michael@0 708 };
michael@0 709
michael@0 710 struct sctp_authchunk {
michael@0 711 uint8_t sauth_chunk;
michael@0 712 };
michael@0 713
michael@0 714
michael@0 715 struct sctp_get_nonce_values {
michael@0 716 sctp_assoc_t gn_assoc_id;
michael@0 717 uint32_t gn_peers_tag;
michael@0 718 uint32_t gn_local_tag;
michael@0 719 };
michael@0 720
michael@0 721
michael@0 722 /*
michael@0 723 * Main SCTP chunk types
michael@0 724 */
michael@0 725 /************0x00 series ***********/
michael@0 726 #define SCTP_DATA 0x00
michael@0 727 #define SCTP_INITIATION 0x01
michael@0 728 #define SCTP_INITIATION_ACK 0x02
michael@0 729 #define SCTP_SELECTIVE_ACK 0x03
michael@0 730 #define SCTP_HEARTBEAT_REQUEST 0x04
michael@0 731 #define SCTP_HEARTBEAT_ACK 0x05
michael@0 732 #define SCTP_ABORT_ASSOCIATION 0x06
michael@0 733 #define SCTP_SHUTDOWN 0x07
michael@0 734 #define SCTP_SHUTDOWN_ACK 0x08
michael@0 735 #define SCTP_OPERATION_ERROR 0x09
michael@0 736 #define SCTP_COOKIE_ECHO 0x0a
michael@0 737 #define SCTP_COOKIE_ACK 0x0b
michael@0 738 #define SCTP_ECN_ECHO 0x0c
michael@0 739 #define SCTP_ECN_CWR 0x0d
michael@0 740 #define SCTP_SHUTDOWN_COMPLETE 0x0e
michael@0 741 /* RFC4895 */
michael@0 742 #define SCTP_AUTHENTICATION 0x0f
michael@0 743 /* EY nr_sack chunk id*/
michael@0 744 #define SCTP_NR_SELECTIVE_ACK 0x10
michael@0 745 /************0x40 series ***********/
michael@0 746 /************0x80 series ***********/
michael@0 747 /* RFC5061 */
michael@0 748 #define SCTP_ASCONF_ACK 0x80
michael@0 749 /* draft-ietf-stewart-pktdrpsctp */
michael@0 750 #define SCTP_PACKET_DROPPED 0x81
michael@0 751 /* draft-ietf-stewart-strreset-xxx */
michael@0 752 #define SCTP_STREAM_RESET 0x82
michael@0 753
michael@0 754 /* RFC4820 */
michael@0 755 #define SCTP_PAD_CHUNK 0x84
michael@0 756 /************0xc0 series ***********/
michael@0 757 /* RFC3758 */
michael@0 758 #define SCTP_FORWARD_CUM_TSN 0xc0
michael@0 759 /* RFC5061 */
michael@0 760 #define SCTP_ASCONF 0xc1
michael@0 761
michael@0 762 struct sctp_authkey {
michael@0 763 sctp_assoc_t sca_assoc_id;
michael@0 764 uint16_t sca_keynumber;
michael@0 765 uint16_t sca_keylength;
michael@0 766 uint8_t sca_key[];
michael@0 767 };
michael@0 768
michael@0 769 struct sctp_authkeyid {
michael@0 770 sctp_assoc_t scact_assoc_id;
michael@0 771 uint16_t scact_keynumber;
michael@0 772 };
michael@0 773
michael@0 774 struct sctp_cc_option {
michael@0 775 int option;
michael@0 776 struct sctp_assoc_value aid_value;
michael@0 777 };
michael@0 778
michael@0 779 struct sctp_cwnd_args {
michael@0 780 struct sctp_nets *net; /* network to */ /* FIXME: LP64 issue */
michael@0 781 uint32_t cwnd_new_value; /* cwnd in k */
michael@0 782 uint32_t pseudo_cumack;
michael@0 783 uint16_t inflight; /* flightsize in k */
michael@0 784 uint16_t cwnd_augment; /* increment to it */
michael@0 785 uint8_t meets_pseudo_cumack;
michael@0 786 uint8_t need_new_pseudo_cumack;
michael@0 787 uint8_t cnt_in_send;
michael@0 788 uint8_t cnt_in_str;
michael@0 789 };
michael@0 790
michael@0 791 struct sctp_blk_args {
michael@0 792 uint32_t onsb; /* in 1k bytes */
michael@0 793 uint32_t sndlen; /* len of send being attempted */
michael@0 794 uint32_t peer_rwnd; /* rwnd of peer */
michael@0 795 uint16_t send_sent_qcnt; /* chnk cnt */
michael@0 796 uint16_t stream_qcnt; /* chnk cnt */
michael@0 797 uint16_t chunks_on_oque; /* chunks out */
michael@0 798 uint16_t flight_size; /* flight size in k */
michael@0 799 };
michael@0 800
michael@0 801 struct sctp_timeouts {
michael@0 802 sctp_assoc_t stimo_assoc_id;
michael@0 803 uint32_t stimo_init;
michael@0 804 uint32_t stimo_data;
michael@0 805 uint32_t stimo_sack;
michael@0 806 uint32_t stimo_shutdown;
michael@0 807 uint32_t stimo_heartbeat;
michael@0 808 uint32_t stimo_cookie;
michael@0 809 uint32_t stimo_shutdownack;
michael@0 810 };
michael@0 811
michael@0 812
michael@0 813 /* Standard TCP Congestion Control */
michael@0 814 #define SCTP_CC_RFC2581 0x00000000
michael@0 815 /* High Speed TCP Congestion Control (Floyd) */
michael@0 816 #define SCTP_CC_HSTCP 0x00000001
michael@0 817 /* HTCP Congestion Control */
michael@0 818 #define SCTP_CC_HTCP 0x00000002
michael@0 819 /* RTCC Congestion Control - RFC2581 plus */
michael@0 820 #define SCTP_CC_RTCC 0x00000003
michael@0 821
michael@0 822 #define SCTP_CC_OPT_RTCC_SETMODE 0x00002000
michael@0 823 #define SCTP_CC_OPT_USE_DCCC_EC 0x00002001
michael@0 824 #define SCTP_CC_OPT_STEADY_STEP 0x00002002
michael@0 825
michael@0 826 #define SCTP_CMT_OFF 0
michael@0 827 #define SCTP_CMT_BASE 1
michael@0 828 #define SCTP_CMT_RPV1 2
michael@0 829 #define SCTP_CMT_RPV2 3
michael@0 830 #define SCTP_CMT_MPTCP 4
michael@0 831 #define SCTP_CMT_MAX SCTP_CMT_MPTCP
michael@0 832
michael@0 833 /* RS - Supported stream scheduling modules for pluggable
michael@0 834 * stream scheduling
michael@0 835 */
michael@0 836 /* Default simple round-robin */
michael@0 837 #define SCTP_SS_DEFAULT 0x00000000
michael@0 838 /* Real round-robin */
michael@0 839 #define SCTP_SS_ROUND_ROBIN 0x00000001
michael@0 840 /* Real round-robin per packet */
michael@0 841 #define SCTP_SS_ROUND_ROBIN_PACKET 0x00000002
michael@0 842 /* Priority */
michael@0 843 #define SCTP_SS_PRIORITY 0x00000003
michael@0 844 /* Fair Bandwidth */
michael@0 845 #define SCTP_SS_FAIR_BANDWITH 0x00000004
michael@0 846 /* First-come, first-serve */
michael@0 847 #define SCTP_SS_FIRST_COME 0x00000005
michael@0 848
michael@0 849 /******************** System calls *************/
michael@0 850
michael@0 851 void
michael@0 852 usrsctp_init(uint16_t,
michael@0 853 int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
michael@0 854 void (*)(const char *format, ...));
michael@0 855
michael@0 856 struct socket *
michael@0 857 usrsctp_socket(int domain, int type, int protocol,
michael@0 858 int (*receive_cb)(struct socket *sock, union sctp_sockstore addr, void *data,
michael@0 859 size_t datalen, struct sctp_rcvinfo, int flags, void *ulp_info),
michael@0 860 int (*send_cb)(struct socket *sock, uint32_t sb_free),
michael@0 861 uint32_t sb_threshold,
michael@0 862 void *ulp_info);
michael@0 863
michael@0 864 int
michael@0 865 usrsctp_setsockopt(struct socket *so,
michael@0 866 int level,
michael@0 867 int option_name,
michael@0 868 const void *option_value,
michael@0 869 socklen_t option_len);
michael@0 870
michael@0 871 int
michael@0 872 usrsctp_getsockopt(struct socket *so,
michael@0 873 int level,
michael@0 874 int option_name,
michael@0 875 void *option_value,
michael@0 876 socklen_t *option_len);
michael@0 877
michael@0 878 int
michael@0 879 usrsctp_getpaddrs(struct socket *so,
michael@0 880 sctp_assoc_t id,
michael@0 881 struct sockaddr **raddrs);
michael@0 882
michael@0 883 void
michael@0 884 usrsctp_freepaddrs(struct sockaddr *addrs);
michael@0 885
michael@0 886 int
michael@0 887 usrsctp_getladdrs(struct socket *so,
michael@0 888 sctp_assoc_t id,
michael@0 889 struct sockaddr **raddrs);
michael@0 890
michael@0 891 void
michael@0 892 usrsctp_freeladdrs(struct sockaddr *addrs);
michael@0 893
michael@0 894 ssize_t
michael@0 895 usrsctp_sendv(struct socket *so,
michael@0 896 const void *data,
michael@0 897 size_t len,
michael@0 898 struct sockaddr *to,
michael@0 899 int addrcnt,
michael@0 900 void *info,
michael@0 901 socklen_t infolen,
michael@0 902 unsigned int infotype,
michael@0 903 int flags);
michael@0 904
michael@0 905 ssize_t
michael@0 906 usrsctp_recvv(struct socket *so,
michael@0 907 void *dbuf,
michael@0 908 size_t len,
michael@0 909 struct sockaddr *from,
michael@0 910 socklen_t * fromlen,
michael@0 911 void *info,
michael@0 912 socklen_t *infolen,
michael@0 913 unsigned int *infotype,
michael@0 914 int *msg_flags);
michael@0 915
michael@0 916 int
michael@0 917 usrsctp_bind(struct socket *so,
michael@0 918 struct sockaddr *name,
michael@0 919 socklen_t namelen);
michael@0 920
michael@0 921 #define SCTP_BINDX_ADD_ADDR 0x00008001
michael@0 922 #define SCTP_BINDX_REM_ADDR 0x00008002
michael@0 923
michael@0 924 int
michael@0 925 usrsctp_bindx(struct socket *so,
michael@0 926 struct sockaddr *addrs,
michael@0 927 int addrcnt,
michael@0 928 int flags);
michael@0 929
michael@0 930 int
michael@0 931 usrsctp_listen(struct socket *so,
michael@0 932 int backlog);
michael@0 933
michael@0 934 struct socket *
michael@0 935 usrsctp_accept(struct socket *so,
michael@0 936 struct sockaddr * aname,
michael@0 937 socklen_t * anamelen);
michael@0 938
michael@0 939 struct socket *
michael@0 940 usrsctp_peeloff(struct socket *, sctp_assoc_t);
michael@0 941
michael@0 942 int
michael@0 943 usrsctp_connect(struct socket *so,
michael@0 944 struct sockaddr *name,
michael@0 945 socklen_t namelen);
michael@0 946
michael@0 947 int
michael@0 948 usrsctp_connectx(struct socket *so,
michael@0 949 const struct sockaddr *addrs, int addrcnt,
michael@0 950 sctp_assoc_t *id);
michael@0 951
michael@0 952 void
michael@0 953 usrsctp_close(struct socket *so);
michael@0 954
michael@0 955 int
michael@0 956 usrsctp_finish(void);
michael@0 957
michael@0 958 int
michael@0 959 usrsctp_shutdown(struct socket *so, int how);
michael@0 960
michael@0 961 void
michael@0 962 usrsctp_conninput(void *, const void *, size_t, uint8_t);
michael@0 963
michael@0 964 int
michael@0 965 usrsctp_set_non_blocking(struct socket *, int);
michael@0 966
michael@0 967 int
michael@0 968 usrsctp_get_non_blocking(struct socket *);
michael@0 969
michael@0 970 void
michael@0 971 usrsctp_register_address(void *);
michael@0 972
michael@0 973 void
michael@0 974 usrsctp_deregister_address(void *);
michael@0 975
michael@0 976 #define SCTP_DUMP_OUTBOUND 1
michael@0 977 #define SCTP_DUMP_INBOUND 0
michael@0 978
michael@0 979 char *
michael@0 980 usrsctp_dumppacket(void *, size_t, int);
michael@0 981
michael@0 982 void
michael@0 983 usrsctp_freedumpbuffer(char *);
michael@0 984
michael@0 985 #define USRSCTP_SYSCTL_DECL(__field) \
michael@0 986 void usrsctp_sysctl_set_ ## __field(uint32_t value);\
michael@0 987 uint32_t usrsctp_sysctl_get_ ## __field(void);
michael@0 988
michael@0 989 USRSCTP_SYSCTL_DECL(sctp_sendspace)
michael@0 990 USRSCTP_SYSCTL_DECL(sctp_recvspace)
michael@0 991 USRSCTP_SYSCTL_DECL(sctp_auto_asconf)
michael@0 992 USRSCTP_SYSCTL_DECL(sctp_multiple_asconfs)
michael@0 993 USRSCTP_SYSCTL_DECL(sctp_ecn_enable)
michael@0 994 USRSCTP_SYSCTL_DECL(sctp_strict_sacks)
michael@0 995 #if !defined(SCTP_WITH_NO_CSUM)
michael@0 996 USRSCTP_SYSCTL_DECL(sctp_no_csum_on_loopback)
michael@0 997 #endif
michael@0 998 USRSCTP_SYSCTL_DECL(sctp_peer_chunk_oh)
michael@0 999 USRSCTP_SYSCTL_DECL(sctp_max_burst_default)
michael@0 1000 USRSCTP_SYSCTL_DECL(sctp_max_chunks_on_queue)
michael@0 1001 USRSCTP_SYSCTL_DECL(sctp_hashtblsize)
michael@0 1002 USRSCTP_SYSCTL_DECL(sctp_pcbtblsize)
michael@0 1003 USRSCTP_SYSCTL_DECL(sctp_min_split_point)
michael@0 1004 USRSCTP_SYSCTL_DECL(sctp_chunkscale)
michael@0 1005 USRSCTP_SYSCTL_DECL(sctp_delayed_sack_time_default)
michael@0 1006 USRSCTP_SYSCTL_DECL(sctp_sack_freq_default)
michael@0 1007 USRSCTP_SYSCTL_DECL(sctp_system_free_resc_limit)
michael@0 1008 USRSCTP_SYSCTL_DECL(sctp_asoc_free_resc_limit)
michael@0 1009 USRSCTP_SYSCTL_DECL(sctp_heartbeat_interval_default)
michael@0 1010 USRSCTP_SYSCTL_DECL(sctp_pmtu_raise_time_default)
michael@0 1011 USRSCTP_SYSCTL_DECL(sctp_shutdown_guard_time_default)
michael@0 1012 USRSCTP_SYSCTL_DECL(sctp_secret_lifetime_default)
michael@0 1013 USRSCTP_SYSCTL_DECL(sctp_rto_max_default)
michael@0 1014 USRSCTP_SYSCTL_DECL(sctp_rto_min_default)
michael@0 1015 USRSCTP_SYSCTL_DECL(sctp_rto_initial_default)
michael@0 1016 USRSCTP_SYSCTL_DECL(sctp_init_rto_max_default)
michael@0 1017 USRSCTP_SYSCTL_DECL(sctp_valid_cookie_life_default)
michael@0 1018 USRSCTP_SYSCTL_DECL(sctp_init_rtx_max_default)
michael@0 1019 USRSCTP_SYSCTL_DECL(sctp_assoc_rtx_max_default)
michael@0 1020 USRSCTP_SYSCTL_DECL(sctp_path_rtx_max_default)
michael@0 1021 USRSCTP_SYSCTL_DECL(sctp_add_more_threshold)
michael@0 1022 USRSCTP_SYSCTL_DECL(sctp_nr_incoming_streams_default)
michael@0 1023 USRSCTP_SYSCTL_DECL(sctp_nr_outgoing_streams_default)
michael@0 1024 USRSCTP_SYSCTL_DECL(sctp_cmt_on_off)
michael@0 1025 USRSCTP_SYSCTL_DECL(sctp_cmt_use_dac)
michael@0 1026 USRSCTP_SYSCTL_DECL(sctp_nr_sack_on_off)
michael@0 1027 USRSCTP_SYSCTL_DECL(sctp_use_cwnd_based_maxburst)
michael@0 1028 USRSCTP_SYSCTL_DECL(sctp_asconf_auth_nochk)
michael@0 1029 USRSCTP_SYSCTL_DECL(sctp_auth_disable)
michael@0 1030 USRSCTP_SYSCTL_DECL(sctp_nat_friendly)
michael@0 1031 USRSCTP_SYSCTL_DECL(sctp_L2_abc_variable)
michael@0 1032 USRSCTP_SYSCTL_DECL(sctp_mbuf_threshold_count)
michael@0 1033 USRSCTP_SYSCTL_DECL(sctp_do_drain)
michael@0 1034 USRSCTP_SYSCTL_DECL(sctp_hb_maxburst)
michael@0 1035 USRSCTP_SYSCTL_DECL(sctp_abort_if_one_2_one_hits_limit)
michael@0 1036 USRSCTP_SYSCTL_DECL(sctp_strict_data_order)
michael@0 1037 USRSCTP_SYSCTL_DECL(sctp_min_residual)
michael@0 1038 USRSCTP_SYSCTL_DECL(sctp_max_retran_chunk)
michael@0 1039 USRSCTP_SYSCTL_DECL(sctp_logging_level)
michael@0 1040 USRSCTP_SYSCTL_DECL(sctp_default_cc_module)
michael@0 1041 USRSCTP_SYSCTL_DECL(sctp_default_frag_interleave)
michael@0 1042 USRSCTP_SYSCTL_DECL(sctp_mobility_base)
michael@0 1043 USRSCTP_SYSCTL_DECL(sctp_mobility_fasthandoff)
michael@0 1044 USRSCTP_SYSCTL_DECL(sctp_inits_include_nat_friendly)
michael@0 1045 USRSCTP_SYSCTL_DECL(sctp_udp_tunneling_port)
michael@0 1046 USRSCTP_SYSCTL_DECL(sctp_enable_sack_immediately)
michael@0 1047 USRSCTP_SYSCTL_DECL(sctp_vtag_time_wait)
michael@0 1048 USRSCTP_SYSCTL_DECL(sctp_blackhole)
michael@0 1049 USRSCTP_SYSCTL_DECL(sctp_fr_max_burst_default)
michael@0 1050 USRSCTP_SYSCTL_DECL(sctp_path_pf_threshold)
michael@0 1051 USRSCTP_SYSCTL_DECL(sctp_default_ss_module)
michael@0 1052 USRSCTP_SYSCTL_DECL(sctp_rttvar_bw)
michael@0 1053 USRSCTP_SYSCTL_DECL(sctp_rttvar_rtt)
michael@0 1054 USRSCTP_SYSCTL_DECL(sctp_rttvar_eqret)
michael@0 1055 USRSCTP_SYSCTL_DECL(sctp_steady_step)
michael@0 1056 USRSCTP_SYSCTL_DECL(sctp_use_dccc_ecn)
michael@0 1057 USRSCTP_SYSCTL_DECL(sctp_buffer_splitting)
michael@0 1058 USRSCTP_SYSCTL_DECL(sctp_initial_cwnd)
michael@0 1059 #ifdef SCTP_DEBUG
michael@0 1060 USRSCTP_SYSCTL_DECL(sctp_debug_on)
michael@0 1061 /* More specific values can be found in sctp_constants, but
michael@0 1062 * are not considered to be part of the API.
michael@0 1063 */
michael@0 1064 #define SCTP_DEBUG_NONE 0x00000000
michael@0 1065 #define SCTP_DEBUG_ALL 0xffffffff
michael@0 1066 #endif
michael@0 1067 #undef USRSCTP_SYSCTL_DECL
michael@0 1068 struct sctp_timeval {
michael@0 1069 uint32_t tv_sec;
michael@0 1070 uint32_t tv_usec;
michael@0 1071 };
michael@0 1072
michael@0 1073 struct sctpstat {
michael@0 1074 struct sctp_timeval sctps_discontinuitytime; /* sctpStats 18 (TimeStamp) */
michael@0 1075 /* MIB according to RFC 3873 */
michael@0 1076 uint32_t sctps_currestab; /* sctpStats 1 (Gauge32) */
michael@0 1077 uint32_t sctps_activeestab; /* sctpStats 2 (Counter32) */
michael@0 1078 uint32_t sctps_restartestab;
michael@0 1079 uint32_t sctps_collisionestab;
michael@0 1080 uint32_t sctps_passiveestab; /* sctpStats 3 (Counter32) */
michael@0 1081 uint32_t sctps_aborted; /* sctpStats 4 (Counter32) */
michael@0 1082 uint32_t sctps_shutdown; /* sctpStats 5 (Counter32) */
michael@0 1083 uint32_t sctps_outoftheblue; /* sctpStats 6 (Counter32) */
michael@0 1084 uint32_t sctps_checksumerrors; /* sctpStats 7 (Counter32) */
michael@0 1085 uint32_t sctps_outcontrolchunks; /* sctpStats 8 (Counter64) */
michael@0 1086 uint32_t sctps_outorderchunks; /* sctpStats 9 (Counter64) */
michael@0 1087 uint32_t sctps_outunorderchunks; /* sctpStats 10 (Counter64) */
michael@0 1088 uint32_t sctps_incontrolchunks; /* sctpStats 11 (Counter64) */
michael@0 1089 uint32_t sctps_inorderchunks; /* sctpStats 12 (Counter64) */
michael@0 1090 uint32_t sctps_inunorderchunks; /* sctpStats 13 (Counter64) */
michael@0 1091 uint32_t sctps_fragusrmsgs; /* sctpStats 14 (Counter64) */
michael@0 1092 uint32_t sctps_reasmusrmsgs; /* sctpStats 15 (Counter64) */
michael@0 1093 uint32_t sctps_outpackets; /* sctpStats 16 (Counter64) */
michael@0 1094 uint32_t sctps_inpackets; /* sctpStats 17 (Counter64) */
michael@0 1095
michael@0 1096 /* input statistics: */
michael@0 1097 uint32_t sctps_recvpackets; /* total input packets */
michael@0 1098 uint32_t sctps_recvdatagrams; /* total input datagrams */
michael@0 1099 uint32_t sctps_recvpktwithdata; /* total packets that had data */
michael@0 1100 uint32_t sctps_recvsacks; /* total input SACK chunks */
michael@0 1101 uint32_t sctps_recvdata; /* total input DATA chunks */
michael@0 1102 uint32_t sctps_recvdupdata; /* total input duplicate DATA chunks */
michael@0 1103 uint32_t sctps_recvheartbeat; /* total input HB chunks */
michael@0 1104 uint32_t sctps_recvheartbeatack; /* total input HB-ACK chunks */
michael@0 1105 uint32_t sctps_recvecne; /* total input ECNE chunks */
michael@0 1106 uint32_t sctps_recvauth; /* total input AUTH chunks */
michael@0 1107 uint32_t sctps_recvauthmissing; /* total input chunks missing AUTH */
michael@0 1108 uint32_t sctps_recvivalhmacid; /* total number of invalid HMAC ids received */
michael@0 1109 uint32_t sctps_recvivalkeyid; /* total number of invalid secret ids received */
michael@0 1110 uint32_t sctps_recvauthfailed; /* total number of auth failed */
michael@0 1111 uint32_t sctps_recvexpress; /* total fast path receives all one chunk */
michael@0 1112 uint32_t sctps_recvexpressm; /* total fast path multi-part data */
michael@0 1113 uint32_t sctps_recvnocrc;
michael@0 1114 uint32_t sctps_recvswcrc;
michael@0 1115 uint32_t sctps_recvhwcrc;
michael@0 1116
michael@0 1117 /* output statistics: */
michael@0 1118 uint32_t sctps_sendpackets; /* total output packets */
michael@0 1119 uint32_t sctps_sendsacks; /* total output SACKs */
michael@0 1120 uint32_t sctps_senddata; /* total output DATA chunks */
michael@0 1121 uint32_t sctps_sendretransdata; /* total output retransmitted DATA chunks */
michael@0 1122 uint32_t sctps_sendfastretrans; /* total output fast retransmitted DATA chunks */
michael@0 1123 uint32_t sctps_sendmultfastretrans; /* total FR's that happened more than once
michael@0 1124 * to same chunk (u-del multi-fr algo).
michael@0 1125 */
michael@0 1126 uint32_t sctps_sendheartbeat; /* total output HB chunks */
michael@0 1127 uint32_t sctps_sendecne; /* total output ECNE chunks */
michael@0 1128 uint32_t sctps_sendauth; /* total output AUTH chunks FIXME */
michael@0 1129 uint32_t sctps_senderrors; /* ip_output error counter */
michael@0 1130 uint32_t sctps_sendnocrc;
michael@0 1131 uint32_t sctps_sendswcrc;
michael@0 1132 uint32_t sctps_sendhwcrc;
michael@0 1133 /* PCKDROPREP statistics: */
michael@0 1134 uint32_t sctps_pdrpfmbox; /* Packet drop from middle box */
michael@0 1135 uint32_t sctps_pdrpfehos; /* P-drop from end host */
michael@0 1136 uint32_t sctps_pdrpmbda; /* P-drops with data */
michael@0 1137 uint32_t sctps_pdrpmbct; /* P-drops, non-data, non-endhost */
michael@0 1138 uint32_t sctps_pdrpbwrpt; /* P-drop, non-endhost, bandwidth rep only */
michael@0 1139 uint32_t sctps_pdrpcrupt; /* P-drop, not enough for chunk header */
michael@0 1140 uint32_t sctps_pdrpnedat; /* P-drop, not enough data to confirm */
michael@0 1141 uint32_t sctps_pdrppdbrk; /* P-drop, where process_chunk_drop said break */
michael@0 1142 uint32_t sctps_pdrptsnnf; /* P-drop, could not find TSN */
michael@0 1143 uint32_t sctps_pdrpdnfnd; /* P-drop, attempt reverse TSN lookup */
michael@0 1144 uint32_t sctps_pdrpdiwnp; /* P-drop, e-host confirms zero-rwnd */
michael@0 1145 uint32_t sctps_pdrpdizrw; /* P-drop, midbox confirms no space */
michael@0 1146 uint32_t sctps_pdrpbadd; /* P-drop, data did not match TSN */
michael@0 1147 uint32_t sctps_pdrpmark; /* P-drop, TSN's marked for Fast Retran */
michael@0 1148 /* timeouts */
michael@0 1149 uint32_t sctps_timoiterator; /* Number of iterator timers that fired */
michael@0 1150 uint32_t sctps_timodata; /* Number of T3 data time outs */
michael@0 1151 uint32_t sctps_timowindowprobe; /* Number of window probe (T3) timers that fired */
michael@0 1152 uint32_t sctps_timoinit; /* Number of INIT timers that fired */
michael@0 1153 uint32_t sctps_timosack; /* Number of sack timers that fired */
michael@0 1154 uint32_t sctps_timoshutdown; /* Number of shutdown timers that fired */
michael@0 1155 uint32_t sctps_timoheartbeat; /* Number of heartbeat timers that fired */
michael@0 1156 uint32_t sctps_timocookie; /* Number of times a cookie timeout fired */
michael@0 1157 uint32_t sctps_timosecret; /* Number of times an endpoint changed its cookie secret*/
michael@0 1158 uint32_t sctps_timopathmtu; /* Number of PMTU timers that fired */
michael@0 1159 uint32_t sctps_timoshutdownack; /* Number of shutdown ack timers that fired */
michael@0 1160 uint32_t sctps_timoshutdownguard; /* Number of shutdown guard timers that fired */
michael@0 1161 uint32_t sctps_timostrmrst; /* Number of stream reset timers that fired */
michael@0 1162 uint32_t sctps_timoearlyfr; /* Number of early FR timers that fired */
michael@0 1163 uint32_t sctps_timoasconf; /* Number of times an asconf timer fired */
michael@0 1164 uint32_t sctps_timodelprim; /* Number of times a prim_deleted timer fired */
michael@0 1165 uint32_t sctps_timoautoclose; /* Number of times auto close timer fired */
michael@0 1166 uint32_t sctps_timoassockill; /* Number of asoc free timers expired */
michael@0 1167 uint32_t sctps_timoinpkill; /* Number of inp free timers expired */
michael@0 1168 /* former early FR counters */
michael@0 1169 uint32_t sctps_spare[11];
michael@0 1170 /* others */
michael@0 1171 uint32_t sctps_hdrops; /* packet shorter than header */
michael@0 1172 uint32_t sctps_badsum; /* checksum error */
michael@0 1173 uint32_t sctps_noport; /* no endpoint for port */
michael@0 1174 uint32_t sctps_badvtag; /* bad v-tag */
michael@0 1175 uint32_t sctps_badsid; /* bad SID */
michael@0 1176 uint32_t sctps_nomem; /* no memory */
michael@0 1177 uint32_t sctps_fastretransinrtt; /* number of multiple FR in a RTT window */
michael@0 1178 uint32_t sctps_markedretrans;
michael@0 1179 uint32_t sctps_naglesent; /* nagle allowed sending */
michael@0 1180 uint32_t sctps_naglequeued; /* nagle doesn't allow sending */
michael@0 1181 uint32_t sctps_maxburstqueued; /* max burst doesn't allow sending */
michael@0 1182 uint32_t sctps_ifnomemqueued; /* look ahead tells us no memory in
michael@0 1183 * interface ring buffer OR we had a
michael@0 1184 * send error and are queuing one send.
michael@0 1185 */
michael@0 1186 uint32_t sctps_windowprobed; /* total number of window probes sent */
michael@0 1187 uint32_t sctps_lowlevelerr; /* total times an output error causes us
michael@0 1188 * to clamp down on next user send.
michael@0 1189 */
michael@0 1190 uint32_t sctps_lowlevelerrusr; /* total times sctp_senderrors were caused from
michael@0 1191 * a user send from a user invoked send not
michael@0 1192 * a sack response
michael@0 1193 */
michael@0 1194 uint32_t sctps_datadropchklmt; /* Number of in data drops due to chunk limit reached */
michael@0 1195 uint32_t sctps_datadroprwnd; /* Number of in data drops due to rwnd limit reached */
michael@0 1196 uint32_t sctps_ecnereducedcwnd; /* Number of times a ECN reduced the cwnd */
michael@0 1197 uint32_t sctps_vtagexpress; /* Used express lookup via vtag */
michael@0 1198 uint32_t sctps_vtagbogus; /* Collision in express lookup. */
michael@0 1199 uint32_t sctps_primary_randry; /* Number of times the sender ran dry of user data on primary */
michael@0 1200 uint32_t sctps_cmt_randry; /* Same for above */
michael@0 1201 uint32_t sctps_slowpath_sack; /* Sacks the slow way */
michael@0 1202 uint32_t sctps_wu_sacks_sent; /* Window Update only sacks sent */
michael@0 1203 uint32_t sctps_sends_with_flags; /* number of sends with sinfo_flags !=0 */
michael@0 1204 uint32_t sctps_sends_with_unord; /* number of unordered sends */
michael@0 1205 uint32_t sctps_sends_with_eof; /* number of sends with EOF flag set */
michael@0 1206 uint32_t sctps_sends_with_abort; /* number of sends with ABORT flag set */
michael@0 1207 uint32_t sctps_protocol_drain_calls;/* number of times protocol drain called */
michael@0 1208 uint32_t sctps_protocol_drains_done;/* number of times we did a protocol drain */
michael@0 1209 uint32_t sctps_read_peeks; /* Number of times recv was called with peek */
michael@0 1210 uint32_t sctps_cached_chk; /* Number of cached chunks used */
michael@0 1211 uint32_t sctps_cached_strmoq; /* Number of cached stream oq's used */
michael@0 1212 uint32_t sctps_left_abandon; /* Number of unread messages abandoned by close */
michael@0 1213 uint32_t sctps_send_burst_avoid; /* Unused */
michael@0 1214 uint32_t sctps_send_cwnd_avoid; /* Send cwnd full avoidance, already max burst inflight to net */
michael@0 1215 uint32_t sctps_fwdtsn_map_over; /* number of map array over-runs via fwd-tsn's */
michael@0 1216 uint32_t sctps_queue_upd_ecne; /* Number of times we queued or updated an ECN chunk on send queue */
michael@0 1217 uint32_t sctps_reserved[31]; /* Future ABI compat - remove int's from here when adding new */
michael@0 1218 };
michael@0 1219
michael@0 1220 void
michael@0 1221 usrsctp_get_stat(struct sctpstat *);
michael@0 1222
michael@0 1223 #ifdef _WIN32
michael@0 1224 #ifdef _MSC_VER
michael@0 1225 #pragma warning(default: 4200)
michael@0 1226 #endif
michael@0 1227 #endif
michael@0 1228 #ifdef __cplusplus
michael@0 1229 }
michael@0 1230 #endif
michael@0 1231 #endif

mercurial