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