1 /*- 2 * Copyright (c) 2001-2007, Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * 10 * b) Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the distribution. 13 * 14 * c) Neither the name of Cisco Systems, Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 /* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $ */ 32 #include <sys/cdefs.h> 33 __FBSDID("$FreeBSD$"); 34 35 #ifndef __sctp_uio_h__ 36 #define __sctp_uio_h__ 37 38 39 #if ! defined(_KERNEL) 40 #include <stdint.h> 41 #endif 42 #include <sys/types.h> 43 #include <sys/socket.h> 44 #include <sys/time.h> 45 #include <netinet/in.h> 46 47 typedef uint32_t sctp_assoc_t; 48 49 /* On/Off setup for subscription to events */ 50 struct sctp_event_subscribe { 51 uint8_t sctp_data_io_event; 52 uint8_t sctp_association_event; 53 uint8_t sctp_address_event; 54 uint8_t sctp_send_failure_event; 55 uint8_t sctp_peer_error_event; 56 uint8_t sctp_shutdown_event; 57 uint8_t sctp_partial_delivery_event; 58 uint8_t sctp_adaptation_layer_event; 59 uint8_t sctp_authentication_event; 60 uint8_t sctp_stream_reset_events; 61 }; 62 63 /* ancillary data types */ 64 #define SCTP_INIT 0x0001 65 #define SCTP_SNDRCV 0x0002 66 #define SCTP_EXTRCV 0x0003 67 /* 68 * ancillary data structures 69 */ 70 struct sctp_initmsg { 71 uint32_t sinit_num_ostreams; 72 uint32_t sinit_max_instreams; 73 uint16_t sinit_max_attempts; 74 uint16_t sinit_max_init_timeo; 75 }; 76 77 /* We add 96 bytes to the size of sctp_sndrcvinfo. 78 * This makes the current structure 128 bytes long 79 * which is nicely 64 bit aligned but also has room 80 * for us to add more and keep ABI compatability. 81 * For example, already we have the sctp_extrcvinfo 82 * when enabled which is 48 bytes. 83 */ 84 85 /* 86 * The assoc up needs a verfid 87 * all sendrcvinfo's need a verfid for SENDING only. 88 */ 89 90 91 #define SCTP_ALIGN_RESV_PAD 96 92 #define SCTP_ALIGN_RESV_PAD_SHORT 80 93 94 struct sctp_sndrcvinfo { 95 uint16_t sinfo_stream; 96 uint16_t sinfo_ssn; 97 uint16_t sinfo_flags; 98 uint32_t sinfo_ppid; 99 uint32_t sinfo_context; 100 uint32_t sinfo_timetolive; 101 uint32_t sinfo_tsn; 102 uint32_t sinfo_cumtsn; 103 sctp_assoc_t sinfo_assoc_id; 104 uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD]; 105 }; 106 107 struct sctp_extrcvinfo { 108 uint16_t sinfo_stream; 109 uint16_t sinfo_ssn; 110 uint16_t sinfo_flags; 111 uint32_t sinfo_ppid; 112 uint32_t sinfo_context; 113 uint32_t sinfo_timetolive; 114 uint32_t sinfo_tsn; 115 uint32_t sinfo_cumtsn; 116 sctp_assoc_t sinfo_assoc_id; 117 uint16_t next_flags; 118 uint16_t next_stream; 119 uint32_t next_asocid; 120 uint32_t next_length; 121 uint32_t next_ppid; 122 uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT]; 123 }; 124 125 #define SCTP_NO_NEXT_MSG 0x0000 126 #define SCTP_NEXT_MSG_AVAIL 0x0001 127 #define SCTP_NEXT_MSG_ISCOMPLETE 0x0002 128 #define SCTP_NEXT_MSG_IS_UNORDERED 0x0004 129 #define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008 130 131 struct sctp_snd_all_completes { 132 uint16_t sall_stream; 133 uint16_t sall_flags; 134 uint32_t sall_ppid; 135 uint32_t sall_context; 136 uint32_t sall_num_sent; 137 uint32_t sall_num_failed; 138 }; 139 140 /* Flags that go into the sinfo->sinfo_flags field */ 141 #define SCTP_EOF 0x0100/* Start shutdown procedures */ 142 #define SCTP_ABORT 0x0200/* Send an ABORT to peer */ 143 #define SCTP_UNORDERED 0x0400/* Message is un-ordered */ 144 #define SCTP_ADDR_OVER 0x0800/* Override the primary-address */ 145 #define SCTP_SENDALL 0x1000/* Send this on all associations */ 146 #define SCTP_EOR 0x2000/* end of message signal */ 147 #define INVALID_SINFO_FLAG(x) (((x) & 0xffffff00 \ 148 & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\ 149 SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR)) != 0) 150 /* for the endpoint */ 151 152 /* The lower byte is an enumeration of PR-SCTP policies */ 153 #define SCTP_PR_SCTP_TTL 0x0001/* Time based PR-SCTP */ 154 #define SCTP_PR_SCTP_BUF 0x0002/* Buffer based PR-SCTP */ 155 #define SCTP_PR_SCTP_RTX 0x0003/* Number of retransmissions based PR-SCTP */ 156 157 #define PR_SCTP_POLICY(x) ((x) & 0xff) 158 #define PR_SCTP_ENABLED(x) (PR_SCTP_POLICY(x) != 0) 159 #define PR_SCTP_TTL_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL) 160 #define PR_SCTP_BUF_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF) 161 #define PR_SCTP_RTX_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX) 162 #define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX) 163 /* Stat's */ 164 struct sctp_pcbinfo { 165 uint32_t ep_count; 166 uint32_t asoc_count; 167 uint32_t laddr_count; 168 uint32_t raddr_count; 169 uint32_t chk_count; 170 uint32_t readq_count; 171 uint32_t free_chunks; 172 uint32_t stream_oque; 173 }; 174 175 struct sctp_sockstat { 176 sctp_assoc_t ss_assoc_id; 177 uint32_t ss_total_sndbuf; 178 uint32_t ss_total_recv_buf; 179 }; 180 181 /* 182 * notification event structures 183 */ 184 185 /* 186 * association change event 187 */ 188 struct sctp_assoc_change { 189 uint16_t sac_type; 190 uint16_t sac_flags; 191 uint32_t sac_length; 192 uint16_t sac_state; 193 uint16_t sac_error; 194 uint16_t sac_outbound_streams; 195 uint16_t sac_inbound_streams; 196 sctp_assoc_t sac_assoc_id; 197 }; 198 199 /* sac_state values */ 200 #define SCTP_COMM_UP 0x0001 201 #define SCTP_COMM_LOST 0x0002 202 #define SCTP_RESTART 0x0003 203 #define SCTP_SHUTDOWN_COMP 0x0004 204 #define SCTP_CANT_STR_ASSOC 0x0005 205 206 207 /* 208 * Address event 209 */ 210 struct sctp_paddr_change { 211 uint16_t spc_type; 212 uint16_t spc_flags; 213 uint32_t spc_length; 214 struct sockaddr_storage spc_aaddr; 215 uint32_t spc_state; 216 uint32_t spc_error; 217 sctp_assoc_t spc_assoc_id; 218 }; 219 220 /* paddr state values */ 221 #define SCTP_ADDR_AVAILABLE 0x0001 222 #define SCTP_ADDR_UNREACHABLE 0x0002 223 #define SCTP_ADDR_REMOVED 0x0003 224 #define SCTP_ADDR_ADDED 0x0004 225 #define SCTP_ADDR_MADE_PRIM 0x0005 226 #define SCTP_ADDR_CONFIRMED 0x0006 227 228 /* 229 * CAUTION: these are user exposed SCTP addr reachability states must be 230 * compatible with SCTP_ADDR states in sctp_constants.h 231 */ 232 #ifdef SCTP_ACTIVE 233 #undef SCTP_ACTIVE 234 #endif 235 #define SCTP_ACTIVE 0x0001 /* SCTP_ADDR_REACHABLE */ 236 237 #ifdef SCTP_INACTIVE 238 #undef SCTP_INACTIVE 239 #endif 240 #define SCTP_INACTIVE 0x0002 /* SCTP_ADDR_NOT_REACHABLE */ 241 242 #ifdef SCTP_UNCONFIRMED 243 #undef SCTP_UNCONFIRMED 244 #endif 245 #define SCTP_UNCONFIRMED 0x0200 /* SCTP_ADDR_UNCONFIRMED */ 246 247 #ifdef SCTP_NOHEARTBEAT 248 #undef SCTP_NOHEARTBEAT 249 #endif 250 #define SCTP_NOHEARTBEAT 0x0040 /* SCTP_ADDR_NOHB */ 251 252 253 /* remote error events */ 254 struct sctp_remote_error { 255 uint16_t sre_type; 256 uint16_t sre_flags; 257 uint32_t sre_length; 258 uint16_t sre_error; 259 sctp_assoc_t sre_assoc_id; 260 uint8_t sre_data[4]; 261 }; 262 263 /* data send failure event */ 264 struct sctp_send_failed { 265 uint16_t ssf_type; 266 uint16_t ssf_flags; 267 uint32_t ssf_length; 268 uint32_t ssf_error; 269 struct sctp_sndrcvinfo ssf_info; 270 sctp_assoc_t ssf_assoc_id; 271 uint8_t ssf_data[4]; 272 }; 273 274 /* flag that indicates state of data */ 275 #define SCTP_DATA_UNSENT 0x0001 /* inqueue never on wire */ 276 #define SCTP_DATA_SENT 0x0002 /* on wire at failure */ 277 278 /* shutdown event */ 279 struct sctp_shutdown_event { 280 uint16_t sse_type; 281 uint16_t sse_flags; 282 uint32_t sse_length; 283 sctp_assoc_t sse_assoc_id; 284 }; 285 286 /* Adaptation layer indication stuff */ 287 struct sctp_adaptation_event { 288 uint16_t sai_type; 289 uint16_t sai_flags; 290 uint32_t sai_length; 291 uint32_t sai_adaptation_ind; 292 sctp_assoc_t sai_assoc_id; 293 }; 294 295 struct sctp_setadaptation { 296 uint32_t ssb_adaptation_ind; 297 }; 298 299 /* compatable old spelling */ 300 struct sctp_adaption_event { 301 uint16_t sai_type; 302 uint16_t sai_flags; 303 uint32_t sai_length; 304 uint32_t sai_adaption_ind; 305 sctp_assoc_t sai_assoc_id; 306 }; 307 308 struct sctp_setadaption { 309 uint32_t ssb_adaption_ind; 310 }; 311 312 313 /* 314 * Partial Delivery API event 315 */ 316 struct sctp_pdapi_event { 317 uint16_t pdapi_type; 318 uint16_t pdapi_flags; 319 uint32_t pdapi_length; 320 uint32_t pdapi_indication; 321 sctp_assoc_t pdapi_assoc_id; 322 }; 323 324 /* indication values */ 325 #define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001 326 327 328 /* 329 * authentication key event 330 */ 331 struct sctp_authkey_event { 332 uint16_t auth_type; 333 uint16_t auth_flags; 334 uint32_t auth_length; 335 uint16_t auth_keynumber; 336 uint16_t auth_altkeynumber; 337 uint32_t auth_indication; 338 sctp_assoc_t auth_assoc_id; 339 }; 340 341 /* indication values */ 342 #define SCTP_AUTH_NEWKEY 0x0001 343 344 345 /* 346 * stream reset event 347 */ 348 struct sctp_stream_reset_event { 349 uint16_t strreset_type; 350 uint16_t strreset_flags; 351 uint32_t strreset_length; 352 sctp_assoc_t strreset_assoc_id; 353 uint16_t strreset_list[0]; 354 }; 355 356 /* flags in strreset_flags field */ 357 #define SCTP_STRRESET_INBOUND_STR 0x0001 358 #define SCTP_STRRESET_OUTBOUND_STR 0x0002 359 #define SCTP_STRRESET_ALL_STREAMS 0x0004 360 #define SCTP_STRRESET_STREAM_LIST 0x0008 361 #define SCTP_STRRESET_FAILED 0x0010 362 363 364 /* SCTP notification event */ 365 struct sctp_tlv { 366 uint16_t sn_type; 367 uint16_t sn_flags; 368 uint32_t sn_length; 369 }; 370 371 union sctp_notification { 372 struct sctp_tlv sn_header; 373 struct sctp_assoc_change sn_assoc_change; 374 struct sctp_paddr_change sn_paddr_change; 375 struct sctp_remote_error sn_remote_error; 376 struct sctp_send_failed sn_send_failed; 377 struct sctp_shutdown_event sn_shutdown_event; 378 struct sctp_adaptation_event sn_adaptation_event; 379 /* compatability same as above */ 380 struct sctp_adaption_event sn_adaption_event; 381 struct sctp_pdapi_event sn_pdapi_event; 382 struct sctp_authkey_event sn_auth_event; 383 struct sctp_stream_reset_event sn_strreset_event; 384 }; 385 386 /* notification types */ 387 #define SCTP_ASSOC_CHANGE 0x0001 388 #define SCTP_PEER_ADDR_CHANGE 0x0002 389 #define SCTP_REMOTE_ERROR 0x0003 390 #define SCTP_SEND_FAILED 0x0004 391 #define SCTP_SHUTDOWN_EVENT 0x0005 392 #define SCTP_ADAPTATION_INDICATION 0x0006 393 /* same as above */ 394 #define SCTP_ADAPTION_INDICATION 0x0006 395 #define SCTP_PARTIAL_DELIVERY_EVENT 0x0007 396 #define SCTP_AUTHENTICATION_EVENT 0x0008 397 #define SCTP_STREAM_RESET_EVENT 0x0009 398 399 400 /* 401 * socket option structs 402 */ 403 404 struct sctp_paddrparams { 405 sctp_assoc_t spp_assoc_id; 406 struct sockaddr_storage spp_address; 407 uint32_t spp_hbinterval; 408 uint16_t spp_pathmaxrxt; 409 uint32_t spp_pathmtu; 410 uint32_t spp_flags; 411 uint32_t spp_ipv6_flowlabel; 412 uint8_t spp_ipv4_tos; 413 414 }; 415 416 #define SPP_HB_ENABLE 0x00000001 417 #define SPP_HB_DISABLE 0x00000002 418 #define SPP_HB_DEMAND 0x00000004 419 #define SPP_PMTUD_ENABLE 0x00000008 420 #define SPP_PMTUD_DISABLE 0x00000010 421 #define SPP_SACKDELAY_ENABLE 0x00000020 422 #define SPP_SACKDELAY_DISABLE 0x00000040 423 #define SPP_HB_TIME_IS_ZERO 0x00000080 424 #define SPP_IPV6_FLOWLABEL 0x00000100 425 #define SPP_IPV4_TOS 0x00000200 426 427 struct sctp_paddrinfo { 428 sctp_assoc_t spinfo_assoc_id; 429 struct sockaddr_storage spinfo_address; 430 int32_t spinfo_state; 431 uint32_t spinfo_cwnd; 432 uint32_t spinfo_srtt; 433 uint32_t spinfo_rto; 434 uint32_t spinfo_mtu; 435 }; 436 437 struct sctp_rtoinfo { 438 sctp_assoc_t srto_assoc_id; 439 uint32_t srto_initial; 440 uint32_t srto_max; 441 uint32_t srto_min; 442 }; 443 444 struct sctp_assocparams { 445 sctp_assoc_t sasoc_assoc_id; 446 uint16_t sasoc_asocmaxrxt; 447 uint16_t sasoc_number_peer_destinations; 448 uint32_t sasoc_peer_rwnd; 449 uint32_t sasoc_local_rwnd; 450 uint32_t sasoc_cookie_life; 451 uint32_t sasoc_sack_delay; 452 uint32_t sasoc_sack_freq; 453 }; 454 455 struct sctp_setprim { 456 sctp_assoc_t ssp_assoc_id; 457 struct sockaddr_storage ssp_addr; 458 }; 459 460 struct sctp_setpeerprim { 461 sctp_assoc_t sspp_assoc_id; 462 struct sockaddr_storage sspp_addr; 463 }; 464 465 struct sctp_getaddresses { 466 sctp_assoc_t sget_assoc_id; 467 /* addr is filled in for N * sockaddr_storage */ 468 struct sockaddr addr[1]; 469 }; 470 471 struct sctp_setstrm_timeout { 472 sctp_assoc_t ssto_assoc_id; 473 uint32_t ssto_timeout; 474 uint32_t ssto_streamid_start; 475 uint32_t ssto_streamid_end; 476 }; 477 478 struct sctp_status { 479 sctp_assoc_t sstat_assoc_id; 480 int32_t sstat_state; 481 uint32_t sstat_rwnd; 482 uint16_t sstat_unackdata; 483 uint16_t sstat_penddata; 484 uint16_t sstat_instrms; 485 uint16_t sstat_outstrms; 486 uint32_t sstat_fragmentation_point; 487 struct sctp_paddrinfo sstat_primary; 488 }; 489 490 /* 491 * AUTHENTICATION support 492 */ 493 /* SCTP_AUTH_CHUNK */ 494 struct sctp_authchunk { 495 uint8_t sauth_chunk; 496 }; 497 498 /* SCTP_AUTH_KEY */ 499 struct sctp_authkey { 500 sctp_assoc_t sca_assoc_id; 501 uint16_t sca_keynumber; 502 uint8_t sca_key[0]; 503 }; 504 505 /* SCTP_HMAC_IDENT */ 506 struct sctp_hmacalgo { 507 uint16_t shmac_idents[0]; 508 }; 509 510 /* AUTH hmac_id */ 511 #define SCTP_AUTH_HMAC_ID_RSVD 0x0000 512 #define SCTP_AUTH_HMAC_ID_SHA1 0x0001 /* default, mandatory */ 513 #define SCTP_AUTH_HMAC_ID_MD5 0x0002 /* deprecated */ 514 #define SCTP_AUTH_HMAC_ID_SHA256 0x0003 515 #define SCTP_AUTH_HMAC_ID_SHA224 0x8001 516 #define SCTP_AUTH_HMAC_ID_SHA384 0x8002 517 #define SCTP_AUTH_HMAC_ID_SHA512 0x8003 518 519 520 /* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */ 521 struct sctp_authkeyid { 522 sctp_assoc_t scact_assoc_id; 523 uint16_t scact_keynumber; 524 }; 525 526 /* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */ 527 struct sctp_authchunks { 528 sctp_assoc_t gauth_assoc_id; 529 uint8_t gauth_chunks[0]; 530 }; 531 532 struct sctp_assoc_value { 533 sctp_assoc_t assoc_id; 534 uint32_t assoc_value; 535 }; 536 537 #define MAX_ASOC_IDS_RET 255 538 struct sctp_assoc_ids { 539 uint16_t asls_assoc_start; /* array of index's start at 0 */ 540 uint8_t asls_numb_present; 541 uint8_t asls_more_to_get; 542 sctp_assoc_t asls_assoc_id[MAX_ASOC_IDS_RET]; 543 }; 544 545 struct sctp_cwnd_args { 546 struct sctp_nets *net; /* network to */ 547 uint32_t cwnd_new_value;/* cwnd in k */ 548 uint32_t inflight; /* flightsize in k */ 549 uint32_t pseudo_cumack; 550 int cwnd_augment; /* increment to it */ 551 uint8_t meets_pseudo_cumack; 552 uint8_t need_new_pseudo_cumack; 553 uint8_t cnt_in_send; 554 uint8_t cnt_in_str; 555 }; 556 557 struct sctp_blk_args { 558 uint32_t onsb; /* in 1k bytes */ 559 uint32_t sndlen; /* len of send being attempted */ 560 uint32_t peer_rwnd; /* rwnd of peer */ 561 uint16_t send_sent_qcnt;/* chnk cnt */ 562 uint16_t stream_qcnt; /* chnk cnt */ 563 uint16_t chunks_on_oque;/* chunks out */ 564 uint16_t flight_size; /* flight size in k */ 565 }; 566 567 /* 568 * Max we can reset in one setting, note this is dictated not by the define 569 * but the size of a mbuf cluster so don't change this define and think you 570 * can specify more. You must do multiple resets if you want to reset more 571 * than SCTP_MAX_EXPLICIT_STR_RESET. 572 */ 573 #define SCTP_MAX_EXPLICT_STR_RESET 1000 574 575 #define SCTP_RESET_LOCAL_RECV 0x0001 576 #define SCTP_RESET_LOCAL_SEND 0x0002 577 #define SCTP_RESET_BOTH 0x0003 578 #define SCTP_RESET_TSN 0x0004 579 580 struct sctp_stream_reset { 581 sctp_assoc_t strrst_assoc_id; 582 uint16_t strrst_flags; 583 uint16_t strrst_num_streams; /* 0 == ALL */ 584 uint16_t strrst_list[0];/* list if strrst_num_streams is not 0 */ 585 }; 586 587 588 struct sctp_get_nonce_values { 589 sctp_assoc_t gn_assoc_id; 590 uint32_t gn_peers_tag; 591 uint32_t gn_local_tag; 592 }; 593 594 /* Debugging logs */ 595 struct sctp_str_log { 596 void *stcb; 597 uint32_t n_tsn; 598 uint32_t e_tsn; 599 uint16_t n_sseq; 600 uint16_t e_sseq; 601 uint16_t strm; 602 }; 603 604 struct sctp_sb_log { 605 void *stcb; 606 uint32_t so_sbcc; 607 uint32_t stcb_sbcc; 608 uint32_t incr; 609 }; 610 611 struct sctp_fr_log { 612 uint32_t largest_tsn; 613 uint32_t largest_new_tsn; 614 uint32_t tsn; 615 }; 616 617 struct sctp_fr_map { 618 uint32_t base; 619 uint32_t cum; 620 uint32_t high; 621 }; 622 623 struct sctp_rwnd_log { 624 uint32_t rwnd; 625 uint32_t send_size; 626 uint32_t overhead; 627 uint32_t new_rwnd; 628 }; 629 630 struct sctp_mbcnt_log { 631 uint32_t total_queue_size; 632 uint32_t size_change; 633 uint32_t total_queue_mb_size; 634 uint32_t mbcnt_change; 635 }; 636 637 struct sctp_sack_log { 638 uint32_t cumack; 639 uint32_t oldcumack; 640 uint32_t tsn; 641 uint16_t numGaps; 642 uint16_t numDups; 643 }; 644 645 struct sctp_lock_log { 646 void *sock; 647 void *inp; 648 uint8_t tcb_lock; 649 uint8_t inp_lock; 650 uint8_t info_lock; 651 uint8_t sock_lock; 652 uint8_t sockrcvbuf_lock; 653 uint8_t socksndbuf_lock; 654 uint8_t create_lock; 655 uint8_t resv; 656 }; 657 658 struct sctp_rto_log { 659 void *net; 660 uint32_t rtt; 661 }; 662 663 struct sctp_nagle_log { 664 void *stcb; 665 uint32_t total_flight; 666 uint32_t total_in_queue; 667 uint16_t count_in_queue; 668 uint16_t count_in_flight; 669 }; 670 671 struct sctp_sbwake_log { 672 void *stcb; 673 uint16_t send_q; 674 uint16_t sent_q; 675 uint16_t flight; 676 uint16_t wake_cnt; 677 uint8_t stream_qcnt; /* chnk cnt */ 678 uint8_t chunks_on_oque; /* chunks out */ 679 uint8_t sbflags; 680 uint8_t sctpflags; 681 }; 682 683 struct sctp_misc_info { 684 uint32_t log1; 685 uint32_t log2; 686 uint32_t log3; 687 uint32_t log4; 688 }; 689 690 struct sctp_log_closing { 691 void *inp; 692 void *stcb; 693 uint32_t sctp_flags; 694 uint16_t state; 695 int16_t loc; 696 }; 697 698 struct sctp_mbuf_log { 699 struct mbuf *mp; 700 caddr_t ext; 701 caddr_t data; 702 uint16_t size; 703 uint8_t refcnt; 704 uint8_t mbuf_flags; 705 }; 706 707 struct sctp_cwnd_log { 708 uint32_t time_event; 709 uint8_t from; 710 uint8_t event_type; 711 uint8_t resv[2]; 712 union { 713 struct sctp_log_closing close; 714 struct sctp_blk_args blk; 715 struct sctp_cwnd_args cwnd; 716 struct sctp_str_log strlog; 717 struct sctp_fr_log fr; 718 struct sctp_fr_map map; 719 struct sctp_rwnd_log rwnd; 720 struct sctp_mbcnt_log mbcnt; 721 struct sctp_sack_log sack; 722 struct sctp_lock_log lock; 723 struct sctp_rto_log rto; 724 struct sctp_sb_log sb; 725 struct sctp_nagle_log nagle; 726 struct sctp_sbwake_log wake; 727 struct sctp_mbuf_log mb; 728 struct sctp_misc_info misc; 729 } x; 730 }; 731 732 struct sctp_cwnd_log_req { 733 int num_in_log; /* Number in log */ 734 int num_ret; /* Number returned */ 735 int start_at; /* start at this one */ 736 int end_at; /* end at this one */ 737 struct sctp_cwnd_log log[0]; 738 }; 739 740 struct sctpstat { 741 /* MIB according to RFC 3873 */ 742 u_long sctps_currestab; /* sctpStats 1 (Gauge32) */ 743 u_long sctps_activeestab; /* sctpStats 2 (Counter32) */ 744 u_long sctps_restartestab; 745 u_long sctps_collisionestab; 746 u_long sctps_passiveestab; /* sctpStats 3 (Counter32) */ 747 u_long sctps_aborted; /* sctpStats 4 (Counter32) */ 748 u_long sctps_shutdown; /* sctpStats 5 (Counter32) */ 749 u_long sctps_outoftheblue; /* sctpStats 6 (Counter32) */ 750 u_long sctps_checksumerrors; /* sctpStats 7 (Counter32) */ 751 u_long sctps_outcontrolchunks; /* sctpStats 8 (Counter64) */ 752 u_long sctps_outorderchunks; /* sctpStats 9 (Counter64) */ 753 u_long sctps_outunorderchunks; /* sctpStats 10 (Counter64) */ 754 u_long sctps_incontrolchunks; /* sctpStats 11 (Counter64) */ 755 u_long sctps_inorderchunks; /* sctpStats 12 (Counter64) */ 756 u_long sctps_inunorderchunks; /* sctpStats 13 (Counter64) */ 757 u_long sctps_fragusrmsgs; /* sctpStats 14 (Counter64) */ 758 u_long sctps_reasmusrmsgs; /* sctpStats 15 (Counter64) */ 759 u_long sctps_outpackets;/* sctpStats 16 (Counter64) */ 760 u_long sctps_inpackets; /* sctpStats 17 (Counter64) */ 761 struct timeval sctps_discontinuitytime; /* sctpStats 18 (TimeStamp) */ 762 /* input statistics: */ 763 u_long sctps_recvpackets; /* total input packets */ 764 u_long sctps_recvdatagrams; /* total input datagrams */ 765 u_long sctps_recvpktwithdata; 766 u_long sctps_recvsacks; /* total input SACK chunks */ 767 u_long sctps_recvdata; /* total input DATA chunks */ 768 u_long sctps_recvdupdata; /* total input duplicate DATA chunks */ 769 u_long sctps_recvheartbeat; /* total input HB chunks */ 770 u_long sctps_recvheartbeatack; /* total input HB-ACK chunks */ 771 u_long sctps_recvecne; /* total input ECNE chunks */ 772 u_long sctps_recvauth; /* total input AUTH chunks */ 773 u_long sctps_recvauthmissing; /* total input chunks missing AUTH */ 774 u_long sctps_recvivalhmacid; /* total number of invalid HMAC ids 775 * received */ 776 u_long sctps_recvivalkeyid; /* total number of invalid secret ids 777 * received */ 778 u_long sctps_recvauthfailed; /* total number of auth failed */ 779 u_long sctps_recvexpress; /* total fast path receives all one 780 * chunk */ 781 u_long sctps_recvexpressm; /* total fast path multi-part data */ 782 /* output statistics: */ 783 u_long sctps_sendpackets; /* total output packets */ 784 u_long sctps_sendsacks; /* total output SACKs */ 785 u_long sctps_senddata; /* total output DATA chunks */ 786 u_long sctps_sendretransdata; /* total output retransmitted DATA 787 * chunks */ 788 u_long sctps_sendfastretrans; /* total output fast retransmitted 789 * DATA chunks */ 790 u_long sctps_sendmultfastretrans; /* U-del */ 791 u_long sctps_sendheartbeat; /* total output HB chunks */ 792 u_long sctps_sendecne; /* total output ECNE chunks */ 793 u_long sctps_sendauth; /* total output AUTH chunks FIXME */ 794 u_long sctps_senderrors;/* ip_output error counter */ 795 /* PCKDROPREP statistics: */ 796 u_long sctps_pdrpfmbox; /* */ 797 u_long sctps_pdrpfehos; /* */ 798 u_long sctps_pdrpmbda; /* */ 799 u_long sctps_pdrpmbct; /* */ 800 u_long sctps_pdrpbwrpt; /* */ 801 u_long sctps_pdrpcrupt; /* */ 802 u_long sctps_pdrpnedat; /* */ 803 u_long sctps_pdrppdbrk; /* */ 804 u_long sctps_pdrptsnnf; /* */ 805 u_long sctps_pdrpdnfnd; /* */ 806 u_long sctps_pdrpdiwnp; /* */ 807 u_long sctps_pdrpdizrw; /* */ 808 u_long sctps_pdrpbadd; /* */ 809 u_long sctps_pdrpmark; /* */ 810 /* timeouts */ 811 u_long sctps_timoiterator; /* */ 812 u_long sctps_timodata; /* */ 813 u_long sctps_timowindowprobe; /* */ 814 u_long sctps_timoinit; /* */ 815 u_long sctps_timosack; /* */ 816 u_long sctps_timoshutdown; /* */ 817 u_long sctps_timoheartbeat; /* */ 818 u_long sctps_timocookie;/* */ 819 u_long sctps_timosecret;/* */ 820 u_long sctps_timopathmtu; /* */ 821 u_long sctps_timoshutdownack; /* */ 822 u_long sctps_timoshutdownguard; /* */ 823 u_long sctps_timostrmrst; /* */ 824 u_long sctps_timoearlyfr; /* */ 825 u_long sctps_timoasconf;/* */ 826 u_long sctps_timoautoclose; /* */ 827 u_long sctps_timoassockill; /* */ 828 u_long sctps_timoinpkill; /* */ 829 /* Early fast retransmission counters */ 830 u_long sctps_earlyfrstart; 831 u_long sctps_earlyfrstop; 832 u_long sctps_earlyfrmrkretrans; 833 u_long sctps_earlyfrstpout; 834 u_long sctps_earlyfrstpidsck1; 835 u_long sctps_earlyfrstpidsck2; 836 u_long sctps_earlyfrstpidsck3; 837 u_long sctps_earlyfrstpidsck4; 838 u_long sctps_earlyfrstrid; 839 u_long sctps_earlyfrstrout; 840 u_long sctps_earlyfrstrtmr; 841 /* otheres */ 842 u_long sctps_hdrops; /* packet shorter than header */ 843 u_long sctps_badsum; /* checksum error */ 844 u_long sctps_noport; /* no endpoint for port */ 845 u_long sctps_badvtag; /* bad v-tag */ 846 u_long sctps_badsid; /* bad SID */ 847 u_long sctps_nomem; /* no memory */ 848 u_long sctps_fastretransinrtt; /* number of multiple FR in a RTT 849 * window */ 850 u_long sctps_markedretrans; 851 u_long sctps_naglesent; /* nagle allowed sending */ 852 u_long sctps_naglequeued; /* nagle does't allow sending */ 853 u_long sctps_maxburstqueued; /* max burst dosn't allow sending */ 854 u_long sctps_ifnomemqueued; /* */ 855 u_long sctps_windowprobed; /* total number of window probes sent */ 856 u_long sctps_lowlevelerr; 857 u_long sctps_lowlevelerrusr; 858 u_long sctps_datadropchklmt; 859 u_long sctps_datadroprwnd; 860 u_long sctps_ecnereducedcwnd; 861 u_long sctps_vtagexpress; /* Used express lookup via vtag */ 862 u_long sctps_vtagbogus; /* Collision in express lookup. */ 863 u_long sctps_primary_randry; /* Number of times the sender ran dry 864 * of user data on primary */ 865 u_long sctps_cmt_randry;/* Same for above */ 866 u_long sctps_slowpath_sack; /* Sacks the slow way */ 867 u_long sctps_wu_sacks_sent; /* Window Update only sacks sent */ 868 u_long sctps_sends_with_flags; /* number of sends with sinfo_flags 869 * !=0 */ 870 u_long sctps_sends_with_unord; 871 u_long sctps_sends_with_eof; 872 u_long sctps_sends_with_abort; 873 u_long sctps_protocol_drain_calls; 874 u_long sctps_protocol_drains_done; 875 }; 876 877 #define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1) 878 #define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1) 879 #define SCTP_STAT_INCR_BY(_x,_d) atomic_add_long(&sctpstat._x, _d) 880 #define SCTP_STAT_DECR_BY(_x,_d) atomic_add_long(&sctpstat._x, -(_d)) 881 /* The following macros are for handling MIB values, */ 882 #define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x) 883 #define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x) 884 #define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x) 885 #define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x) 886 #define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x) 887 #define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x) 888 889 union sctp_sockstore { 890 #if defined(INET) || !defined(_KERNEL) 891 struct sockaddr_in sin; 892 #endif 893 #if defined(INET6) || !defined(_KERNEL) 894 struct sockaddr_in6 sin6; 895 #endif 896 struct sockaddr sa; 897 }; 898 899 struct xsctp_inpcb { 900 uint32_t last; 901 uint16_t local_port; 902 uint16_t number_local_addresses; 903 uint32_t number_associations; 904 uint32_t flags; 905 uint32_t features; 906 uint32_t total_sends; 907 uint32_t total_recvs; 908 uint32_t total_nospaces; 909 /* add more endpoint specific data here */ 910 }; 911 912 struct xsctp_tcb { 913 uint16_t LocalPort; /* sctpAssocEntry 3 */ 914 uint16_t RemPort; /* sctpAssocEntry 4 */ 915 union sctp_sockstore RemPrimAddr; /* sctpAssocEntry 5/6 */ 916 uint32_t HeartBeatInterval; /* sctpAssocEntry 7 */ 917 uint32_t State; /* sctpAssocEntry 8 */ 918 uint32_t InStreams; /* sctpAssocEntry 9 */ 919 uint32_t OutStreams; /* sctpAssocEntry 10 */ 920 uint32_t MaxRetr; /* sctpAssocEntry 11 */ 921 uint32_t PrimProcess; /* sctpAssocEntry 12 */ 922 uint32_t T1expireds; /* sctpAssocEntry 13 */ 923 uint32_t T2expireds; /* sctpAssocEntry 14 */ 924 uint32_t RtxChunks; /* sctpAssocEntry 15 */ 925 struct timeval StartTime; /* sctpAssocEntry 16 */ 926 struct timeval DiscontinuityTime; /* sctpAssocEntry 17 */ 927 uint32_t total_sends; 928 uint32_t total_recvs; 929 uint32_t local_tag; 930 uint32_t remote_tag; 931 uint32_t initial_tsn; 932 uint32_t highest_tsn; 933 uint32_t cumulative_tsn; 934 uint32_t cumulative_tsn_ack; 935 /* add more association specific data here */ 936 uint16_t number_local_addresses; 937 uint16_t number_remote_addresses; 938 }; 939 940 struct xsctp_laddr { 941 union sctp_sockstore LocalAddr; /* sctpAssocLocalAddrEntry 1/2 */ 942 struct timeval LocalStartTime; /* sctpAssocLocalAddrEntry 3 */ 943 /* add more local address specific data */ 944 }; 945 946 struct xsctp_raddr { 947 union sctp_sockstore RemAddr; /* sctpAssocLocalRemEntry 1/2 */ 948 uint8_t RemAddrActive; /* sctpAssocLocalRemEntry 3 */ 949 uint8_t RemAddrConfirmed; /* */ 950 uint8_t RemAddrHBActive;/* sctpAssocLocalRemEntry 4 */ 951 uint32_t RemAddrRTO; /* sctpAssocLocalRemEntry 5 */ 952 uint32_t RemAddrMaxPathRtx; /* sctpAssocLocalRemEntry 6 */ 953 uint32_t RemAddrRtx; /* sctpAssocLocalRemEntry 7 */ 954 uint32_t RemAddrErrorCounter; /* */ 955 uint32_t RemAddrCwnd; /* */ 956 uint32_t RemAddrFlightSize; /* */ 957 struct timeval RemAddrStartTime; /* sctpAssocLocalRemEntry 8 */ 958 /* add more remote address specific data */ 959 }; 960 961 /* 962 * Kernel defined for sctp_send 963 */ 964 #if defined(_KERNEL) 965 int 966 sctp_lower_sosend(struct socket *so, 967 struct sockaddr *addr, 968 struct uio *uio, 969 970 struct mbuf *top, 971 struct mbuf *control, 972 int flags, 973 int use_rcvinfo, 974 struct sctp_sndrcvinfo *srcv, 975 struct thread *p 976 ); 977 978 int 979 sctp_sorecvmsg(struct socket *so, 980 struct uio *uio, 981 struct mbuf **mp, 982 struct sockaddr *from, 983 int fromlen, 984 int *msg_flags, 985 struct sctp_sndrcvinfo *sinfo, 986 int filling_sinfo); 987 988 989 #endif 990 991 /* 992 * API system calls 993 */ 994 #if !(defined(_KERNEL)) 995 996 __BEGIN_DECLS 997 int sctp_peeloff __P((int, sctp_assoc_t)); 998 int sctp_bindx __P((int, struct sockaddr *, int, int)); 999 int sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *)); 1000 int sctp_getaddrlen __P((sa_family_t)); 1001 int sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **)); 1002 void sctp_freepaddrs __P((struct sockaddr *)); 1003 int sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **)); 1004 void sctp_freeladdrs __P((struct sockaddr *)); 1005 int sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *)); 1006 1007 ssize_t sctp_sendmsg 1008 __P((int, const void *, size_t, 1009 const struct sockaddr *, 1010 socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t)); 1011 1012 ssize_t sctp_send __P((int sd, const void *msg, size_t len, 1013 const struct sctp_sndrcvinfo *sinfo, int flags)); 1014 1015 ssize_t 1016 sctp_sendx __P((int sd, const void *msg, size_t len, 1017 struct sockaddr *addrs, int addrcnt, 1018 struct sctp_sndrcvinfo *sinfo, int flags)); 1019 ssize_t 1020 sctp_sendmsgx __P((int sd, const void *, size_t, 1021 struct sockaddr *, int, 1022 uint32_t, uint32_t, uint16_t, uint32_t, uint32_t)); 1023 1024 sctp_assoc_t 1025 sctp_getassocid __P((int sd, struct sockaddr *sa)); 1026 1027 ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *, 1028 socklen_t *, struct sctp_sndrcvinfo *, int *)); 1029 1030 __END_DECLS 1031 1032 #endif /* !_KERNEL */ 1033 #endif /* !__sctp_uio_h__ */ 1034