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