sctp_uio.h revision 234801
1163953Srrs/*- 2169382Srrs * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 3218319Srrs * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved. 4218319Srrs * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved. 5163953Srrs * 6163953Srrs * Redistribution and use in source and binary forms, with or without 7163953Srrs * modification, are permitted provided that the following conditions are met: 8163953Srrs * 9163953Srrs * a) Redistributions of source code must retain the above copyright notice, 10231038Stuexen * this list of conditions and the following disclaimer. 11163953Srrs * 12163953Srrs * b) Redistributions in binary form must reproduce the above copyright 13163953Srrs * notice, this list of conditions and the following disclaimer in 14231038Stuexen * the documentation and/or other materials provided with the distribution. 15163953Srrs * 16163953Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its 17163953Srrs * contributors may be used to endorse or promote products derived 18163953Srrs * from this software without specific prior written permission. 19163953Srrs * 20163953Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21163953Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22163953Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23163953Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24163953Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25163953Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26163953Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27163953Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28163953Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29163953Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30163953Srrs * THE POSSIBILITY OF SUCH DAMAGE. 31163953Srrs */ 32163953Srrs 33163953Srrs/* $KAME: sctp_uio.h,v 1.11 2005/03/06 16:04:18 itojun Exp $ */ 34163953Srrs#include <sys/cdefs.h> 35163953Srrs__FBSDID("$FreeBSD: stable/9/sys/netinet/sctp_uio.h 234801 2012-04-29 16:33:30Z tuexen $"); 36163953Srrs 37163953Srrs#ifndef __sctp_uio_h__ 38163953Srrs#define __sctp_uio_h__ 39163953Srrs 40163953Srrs 41163953Srrs#if ! defined(_KERNEL) 42163953Srrs#include <stdint.h> 43163953Srrs#endif 44163953Srrs#include <sys/types.h> 45163953Srrs#include <sys/socket.h> 46164085Srrs#include <netinet/in.h> 47163953Srrs 48163953Srrstypedef uint32_t sctp_assoc_t; 49163953Srrs 50223132Stuexen#define SCTP_FUTURE_ASSOC 0 51223132Stuexen#define SCTP_CURRENT_ASSOC 1 52223132Stuexen#define SCTP_ALL_ASSOC 2 53223132Stuexen 54223132Stuexenstruct sctp_event { 55223132Stuexen sctp_assoc_t se_assoc_id; 56223132Stuexen uint16_t se_type; 57223132Stuexen uint8_t se_on; 58223132Stuexen}; 59223132Stuexen 60202520Srrs/* Compatibility to previous define's */ 61202520Srrs#define sctp_stream_reset_events sctp_stream_reset_event 62202520Srrs 63163953Srrs/* On/Off setup for subscription to events */ 64163953Srrsstruct sctp_event_subscribe { 65163953Srrs uint8_t sctp_data_io_event; 66163953Srrs uint8_t sctp_association_event; 67163953Srrs uint8_t sctp_address_event; 68163953Srrs uint8_t sctp_send_failure_event; 69163953Srrs uint8_t sctp_peer_error_event; 70163953Srrs uint8_t sctp_shutdown_event; 71163953Srrs uint8_t sctp_partial_delivery_event; 72163953Srrs uint8_t sctp_adaptation_layer_event; 73163953Srrs uint8_t sctp_authentication_event; 74185694Srrs uint8_t sctp_sender_dry_event; 75202520Srrs uint8_t sctp_stream_reset_event; 76163953Srrs}; 77163953Srrs 78163953Srrs/* ancillary data types */ 79163953Srrs#define SCTP_INIT 0x0001 80163953Srrs#define SCTP_SNDRCV 0x0002 81163953Srrs#define SCTP_EXTRCV 0x0003 82223132Stuexen#define SCTP_SNDINFO 0x0004 83223132Stuexen#define SCTP_RCVINFO 0x0005 84223132Stuexen#define SCTP_NXTINFO 0x0006 85223132Stuexen#define SCTP_PRINFO 0x0007 86223132Stuexen#define SCTP_AUTHINFO 0x0008 87223132Stuexen#define SCTP_DSTADDRV4 0x0009 88223132Stuexen#define SCTP_DSTADDRV6 0x000a 89223132Stuexen 90163953Srrs/* 91163953Srrs * ancillary data structures 92163953Srrs */ 93163953Srrsstruct sctp_initmsg { 94193088Srrs uint16_t sinit_num_ostreams; 95193088Srrs uint16_t sinit_max_instreams; 96163953Srrs uint16_t sinit_max_attempts; 97163953Srrs uint16_t sinit_max_init_timeo; 98163953Srrs}; 99163953Srrs 100163953Srrs/* We add 96 bytes to the size of sctp_sndrcvinfo. 101163953Srrs * This makes the current structure 128 bytes long 102163953Srrs * which is nicely 64 bit aligned but also has room 103215034Sbrucec * for us to add more and keep ABI compatibility. 104163953Srrs * For example, already we have the sctp_extrcvinfo 105163953Srrs * when enabled which is 48 bytes. 106163953Srrs */ 107163953Srrs 108166675Srrs/* 109166675Srrs * The assoc up needs a verfid 110166675Srrs * all sendrcvinfo's need a verfid for SENDING only. 111166675Srrs */ 112166675Srrs 113166675Srrs 114223132Stuexen#define SCTP_ALIGN_RESV_PAD 92 115223132Stuexen#define SCTP_ALIGN_RESV_PAD_SHORT 76 116163953Srrs 117163953Srrsstruct sctp_sndrcvinfo { 118163953Srrs uint16_t sinfo_stream; 119163953Srrs uint16_t sinfo_ssn; 120163953Srrs uint16_t sinfo_flags; 121163953Srrs uint32_t sinfo_ppid; 122163953Srrs uint32_t sinfo_context; 123163953Srrs uint32_t sinfo_timetolive; 124163953Srrs uint32_t sinfo_tsn; 125163953Srrs uint32_t sinfo_cumtsn; 126163953Srrs sctp_assoc_t sinfo_assoc_id; 127223132Stuexen uint16_t sinfo_keynumber; 128223132Stuexen uint16_t sinfo_keynumber_valid; 129163953Srrs uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD]; 130163953Srrs}; 131163953Srrs 132163953Srrsstruct sctp_extrcvinfo { 133171745Srrs uint16_t sinfo_stream; 134171745Srrs uint16_t sinfo_ssn; 135171745Srrs uint16_t sinfo_flags; 136171745Srrs uint32_t sinfo_ppid; 137171745Srrs uint32_t sinfo_context; 138171745Srrs uint32_t sinfo_timetolive; 139171745Srrs uint32_t sinfo_tsn; 140171745Srrs uint32_t sinfo_cumtsn; 141171745Srrs sctp_assoc_t sinfo_assoc_id; 142168943Srrs uint16_t sreinfo_next_flags; 143168943Srrs uint16_t sreinfo_next_stream; 144168943Srrs uint32_t sreinfo_next_aid; 145168943Srrs uint32_t sreinfo_next_length; 146168943Srrs uint32_t sreinfo_next_ppid; 147223132Stuexen uint16_t sinfo_keynumber; 148223132Stuexen uint16_t sinfo_keynumber_valid; 149166675Srrs uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT]; 150163953Srrs}; 151163953Srrs 152223132Stuexenstruct sctp_sndinfo { 153223132Stuexen uint16_t snd_sid; 154223132Stuexen uint16_t snd_flags; 155223132Stuexen uint32_t snd_ppid; 156223132Stuexen uint32_t snd_context; 157223132Stuexen sctp_assoc_t snd_assoc_id; 158223132Stuexen}; 159223132Stuexen 160223132Stuexenstruct sctp_prinfo { 161223132Stuexen uint16_t pr_policy; 162223132Stuexen uint32_t pr_value; 163223132Stuexen}; 164223132Stuexen 165223162Stuexenstruct sctp_default_prinfo { 166223162Stuexen uint16_t pr_policy; 167223162Stuexen uint32_t pr_value; 168223162Stuexen sctp_assoc_t pr_assoc_id; 169223162Stuexen}; 170223162Stuexen 171223132Stuexenstruct sctp_authinfo { 172223132Stuexen uint16_t auth_keyid; 173223132Stuexen}; 174223132Stuexen 175223132Stuexenstruct sctp_rcvinfo { 176223132Stuexen uint16_t rcv_sid; 177223132Stuexen uint16_t rcv_ssn; 178223132Stuexen uint16_t rcv_flags; 179223132Stuexen uint32_t rcv_ppid; 180223132Stuexen uint32_t rcv_tsn; 181223132Stuexen uint32_t rcv_cumtsn; 182223132Stuexen uint32_t rcv_context; 183223132Stuexen sctp_assoc_t rcv_assoc_id; 184223132Stuexen}; 185223132Stuexen 186223132Stuexenstruct sctp_nxtinfo { 187223132Stuexen uint16_t nxt_sid; 188223132Stuexen uint16_t nxt_flags; 189223132Stuexen uint32_t nxt_ppid; 190223132Stuexen uint32_t nxt_length; 191223132Stuexen sctp_assoc_t nxt_assoc_id; 192223132Stuexen}; 193223132Stuexen 194163953Srrs#define SCTP_NO_NEXT_MSG 0x0000 195163953Srrs#define SCTP_NEXT_MSG_AVAIL 0x0001 196163953Srrs#define SCTP_NEXT_MSG_ISCOMPLETE 0x0002 197163953Srrs#define SCTP_NEXT_MSG_IS_UNORDERED 0x0004 198166675Srrs#define SCTP_NEXT_MSG_IS_NOTIFICATION 0x0008 199163953Srrs 200223132Stuexenstruct sctp_recvv_rn { 201223132Stuexen struct sctp_rcvinfo recvv_rcvinfo; 202223132Stuexen struct sctp_nxtinfo recvv_nxtinfo; 203223132Stuexen}; 204223132Stuexen 205223132Stuexen#define SCTP_RECVV_NOINFO 0 206223132Stuexen#define SCTP_RECVV_RCVINFO 1 207223132Stuexen#define SCTP_RECVV_NXTINFO 2 208223132Stuexen#define SCTP_RECVV_RN 3 209223132Stuexen 210223152Stuexen#define SCTP_SENDV_NOINFO 0 211223132Stuexen#define SCTP_SENDV_SNDINFO 1 212223132Stuexen#define SCTP_SENDV_PRINFO 2 213223132Stuexen#define SCTP_SENDV_AUTHINFO 3 214223132Stuexen#define SCTP_SENDV_SPA 4 215223132Stuexen 216223132Stuexenstruct sctp_sendv_spa { 217223132Stuexen uint32_t sendv_flags; 218223132Stuexen struct sctp_sndinfo sendv_sndinfo; 219223132Stuexen struct sctp_prinfo sendv_prinfo; 220223132Stuexen struct sctp_authinfo sendv_authinfo; 221223132Stuexen}; 222223132Stuexen 223223132Stuexen#define SCTP_SEND_SNDINFO_VALID 0x00000001 224223132Stuexen#define SCTP_SEND_PRINFO_VALID 0x00000002 225223132Stuexen#define SCTP_SEND_AUTHINFO_VALID 0x00000004 226223132Stuexen 227163953Srrsstruct sctp_snd_all_completes { 228163953Srrs uint16_t sall_stream; 229163953Srrs uint16_t sall_flags; 230163953Srrs uint32_t sall_ppid; 231163953Srrs uint32_t sall_context; 232163953Srrs uint32_t sall_num_sent; 233163953Srrs uint32_t sall_num_failed; 234163953Srrs}; 235163953Srrs 236163953Srrs/* Flags that go into the sinfo->sinfo_flags field */ 237223132Stuexen#define SCTP_NOTIFICATION 0x0010 /* next message is a notification */ 238223132Stuexen#define SCTP_COMPLETE 0x0020 /* next message is complete */ 239185694Srrs#define SCTP_EOF 0x0100 /* Start shutdown procedures */ 240185694Srrs#define SCTP_ABORT 0x0200 /* Send an ABORT to peer */ 241185694Srrs#define SCTP_UNORDERED 0x0400 /* Message is un-ordered */ 242185694Srrs#define SCTP_ADDR_OVER 0x0800 /* Override the primary-address */ 243185694Srrs#define SCTP_SENDALL 0x1000 /* Send this on all associations */ 244185694Srrs#define SCTP_EOR 0x2000 /* end of message signal */ 245185694Srrs#define SCTP_SACK_IMMEDIATELY 0x4000 /* Set I-Bit */ 246171990Srrs 247223132Stuexen#define INVALID_SINFO_FLAG(x) (((x) & 0xfffffff0 \ 248166023Srrs & ~(SCTP_EOF | SCTP_ABORT | SCTP_UNORDERED |\ 249185694Srrs SCTP_ADDR_OVER | SCTP_SENDALL | SCTP_EOR |\ 250185694Srrs SCTP_SACK_IMMEDIATELY)) != 0) 251163953Srrs/* for the endpoint */ 252163953Srrs 253163953Srrs/* The lower byte is an enumeration of PR-SCTP policies */ 254223613Stuexen#define SCTP_PR_SCTP_NONE 0x0000/* Reliable transfer */ 255163953Srrs#define SCTP_PR_SCTP_TTL 0x0001/* Time based PR-SCTP */ 256163953Srrs#define SCTP_PR_SCTP_BUF 0x0002/* Buffer based PR-SCTP */ 257163953Srrs#define SCTP_PR_SCTP_RTX 0x0003/* Number of retransmissions based PR-SCTP */ 258163953Srrs 259223132Stuexen#define PR_SCTP_POLICY(x) ((x) & 0x0f) 260223613Stuexen#define PR_SCTP_ENABLED(x) (PR_SCTP_POLICY(x) != SCTP_PR_SCTP_NONE) 261166023Srrs#define PR_SCTP_TTL_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL) 262166023Srrs#define PR_SCTP_BUF_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF) 263166023Srrs#define PR_SCTP_RTX_ENABLED(x) (PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX) 264166023Srrs#define PR_SCTP_INVALID_POLICY(x) (PR_SCTP_POLICY(x) > SCTP_PR_SCTP_RTX) 265163953Srrs/* Stat's */ 266163953Srrsstruct sctp_pcbinfo { 267163953Srrs uint32_t ep_count; 268163953Srrs uint32_t asoc_count; 269163953Srrs uint32_t laddr_count; 270163953Srrs uint32_t raddr_count; 271163953Srrs uint32_t chk_count; 272163953Srrs uint32_t readq_count; 273163953Srrs uint32_t free_chunks; 274163953Srrs uint32_t stream_oque; 275163953Srrs}; 276163953Srrs 277163953Srrsstruct sctp_sockstat { 278163953Srrs sctp_assoc_t ss_assoc_id; 279163953Srrs uint32_t ss_total_sndbuf; 280163953Srrs uint32_t ss_total_recv_buf; 281163953Srrs}; 282163953Srrs 283163953Srrs/* 284163953Srrs * notification event structures 285163953Srrs */ 286163953Srrs 287163953Srrs/* 288163953Srrs * association change event 289163953Srrs */ 290163953Srrsstruct sctp_assoc_change { 291163953Srrs uint16_t sac_type; 292163953Srrs uint16_t sac_flags; 293163953Srrs uint32_t sac_length; 294163953Srrs uint16_t sac_state; 295163953Srrs uint16_t sac_error; 296163953Srrs uint16_t sac_outbound_streams; 297163953Srrs uint16_t sac_inbound_streams; 298163953Srrs sctp_assoc_t sac_assoc_id; 299163953Srrs}; 300163953Srrs 301163953Srrs/* sac_state values */ 302163953Srrs#define SCTP_COMM_UP 0x0001 303163953Srrs#define SCTP_COMM_LOST 0x0002 304163953Srrs#define SCTP_RESTART 0x0003 305163953Srrs#define SCTP_SHUTDOWN_COMP 0x0004 306163953Srrs#define SCTP_CANT_STR_ASSOC 0x0005 307163953Srrs 308163953Srrs 309163953Srrs/* 310163953Srrs * Address event 311163953Srrs */ 312163953Srrsstruct sctp_paddr_change { 313163953Srrs uint16_t spc_type; 314163953Srrs uint16_t spc_flags; 315163953Srrs uint32_t spc_length; 316163953Srrs struct sockaddr_storage spc_aaddr; 317163953Srrs uint32_t spc_state; 318163953Srrs uint32_t spc_error; 319163953Srrs sctp_assoc_t spc_assoc_id; 320170992Srrs uint8_t spc_padding[4]; 321163953Srrs}; 322163953Srrs 323163953Srrs/* paddr state values */ 324163953Srrs#define SCTP_ADDR_AVAILABLE 0x0001 325163953Srrs#define SCTP_ADDR_UNREACHABLE 0x0002 326163953Srrs#define SCTP_ADDR_REMOVED 0x0003 327163953Srrs#define SCTP_ADDR_ADDED 0x0004 328163953Srrs#define SCTP_ADDR_MADE_PRIM 0x0005 329163953Srrs#define SCTP_ADDR_CONFIRMED 0x0006 330163953Srrs 331163953Srrs#define SCTP_ACTIVE 0x0001 /* SCTP_ADDR_REACHABLE */ 332224641Stuexen#define SCTP_INACTIVE 0x0002 /* neither SCTP_ADDR_REACHABLE nor 333224641Stuexen * SCTP_ADDR_UNCONFIRMED */ 334163953Srrs#define SCTP_UNCONFIRMED 0x0200 /* SCTP_ADDR_UNCONFIRMED */ 335163953Srrs 336163953Srrs/* remote error events */ 337163953Srrsstruct sctp_remote_error { 338163953Srrs uint16_t sre_type; 339163953Srrs uint16_t sre_flags; 340163953Srrs uint32_t sre_length; 341163953Srrs uint16_t sre_error; 342163953Srrs sctp_assoc_t sre_assoc_id; 343163953Srrs uint8_t sre_data[4]; 344163953Srrs}; 345163953Srrs 346163953Srrs/* data send failure event */ 347163953Srrsstruct sctp_send_failed { 348163953Srrs uint16_t ssf_type; 349163953Srrs uint16_t ssf_flags; 350163953Srrs uint32_t ssf_length; 351163953Srrs uint32_t ssf_error; 352163953Srrs struct sctp_sndrcvinfo ssf_info; 353163953Srrs sctp_assoc_t ssf_assoc_id; 354202782Stuexen uint8_t ssf_data[]; 355163953Srrs}; 356163953Srrs 357163953Srrs/* flag that indicates state of data */ 358163953Srrs#define SCTP_DATA_UNSENT 0x0001 /* inqueue never on wire */ 359163953Srrs#define SCTP_DATA_SENT 0x0002 /* on wire at failure */ 360163953Srrs 361163953Srrs/* shutdown event */ 362163953Srrsstruct sctp_shutdown_event { 363163953Srrs uint16_t sse_type; 364163953Srrs uint16_t sse_flags; 365163953Srrs uint32_t sse_length; 366163953Srrs sctp_assoc_t sse_assoc_id; 367163953Srrs}; 368163953Srrs 369163953Srrs/* Adaptation layer indication stuff */ 370163953Srrsstruct sctp_adaptation_event { 371163953Srrs uint16_t sai_type; 372163953Srrs uint16_t sai_flags; 373163953Srrs uint32_t sai_length; 374163953Srrs uint32_t sai_adaptation_ind; 375163953Srrs sctp_assoc_t sai_assoc_id; 376163953Srrs}; 377163953Srrs 378163953Srrsstruct sctp_setadaptation { 379163953Srrs uint32_t ssb_adaptation_ind; 380163953Srrs}; 381163953Srrs 382215034Sbrucec/* compatible old spelling */ 383163953Srrsstruct sctp_adaption_event { 384163953Srrs uint16_t sai_type; 385163953Srrs uint16_t sai_flags; 386163953Srrs uint32_t sai_length; 387163953Srrs uint32_t sai_adaption_ind; 388163953Srrs sctp_assoc_t sai_assoc_id; 389163953Srrs}; 390163953Srrs 391163953Srrsstruct sctp_setadaption { 392163953Srrs uint32_t ssb_adaption_ind; 393163953Srrs}; 394163953Srrs 395163953Srrs 396163953Srrs/* 397163953Srrs * Partial Delivery API event 398163953Srrs */ 399163953Srrsstruct sctp_pdapi_event { 400163953Srrs uint16_t pdapi_type; 401163953Srrs uint16_t pdapi_flags; 402163953Srrs uint32_t pdapi_length; 403163953Srrs uint32_t pdapi_indication; 404168943Srrs uint16_t pdapi_stream; 405168943Srrs uint16_t pdapi_seq; 406163953Srrs sctp_assoc_t pdapi_assoc_id; 407163953Srrs}; 408163953Srrs 409163953Srrs/* indication values */ 410163953Srrs#define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001 411163953Srrs 412163953Srrs 413163953Srrs/* 414163953Srrs * authentication key event 415163953Srrs */ 416163953Srrsstruct sctp_authkey_event { 417163953Srrs uint16_t auth_type; 418163953Srrs uint16_t auth_flags; 419163953Srrs uint32_t auth_length; 420163953Srrs uint16_t auth_keynumber; 421163953Srrs uint16_t auth_altkeynumber; 422163953Srrs uint32_t auth_indication; 423163953Srrs sctp_assoc_t auth_assoc_id; 424163953Srrs}; 425163953Srrs 426163953Srrs/* indication values */ 427163953Srrs#define SCTP_AUTH_NEWKEY 0x0001 428185694Srrs#define SCTP_AUTH_NO_AUTH 0x0002 429185694Srrs#define SCTP_AUTH_FREE_KEY 0x0003 430163953Srrs 431163953Srrs 432185694Srrsstruct sctp_sender_dry_event { 433185694Srrs uint16_t sender_dry_type; 434185694Srrs uint16_t sender_dry_flags; 435185694Srrs uint32_t sender_dry_length; 436185694Srrs sctp_assoc_t sender_dry_assoc_id; 437185694Srrs}; 438185694Srrs 439185694Srrs 440163953Srrs/* 441234790Stuexen * Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT 442163953Srrs */ 443163953Srrsstruct sctp_stream_reset_event { 444163953Srrs uint16_t strreset_type; 445163953Srrs uint16_t strreset_flags; 446163953Srrs uint32_t strreset_length; 447163953Srrs sctp_assoc_t strreset_assoc_id; 448234790Stuexen uint16_t strreset_stream_list[]; 449163953Srrs}; 450163953Srrs 451234790Stuexen/* flags in stream_reset_event (strreset_flags) */ 452234801Stuexen#define SCTP_STREAM_RESET_INCOMING_SSN 0x0001 453234801Stuexen#define SCTP_STREAM_RESET_OUTGOING_SSN 0x0002 454234801Stuexen#define SCTP_STREAM_RESET_DENIED 0x0004 455234801Stuexen#define SCTP_STREAM_RESET_FAILED 0x0008 456234801Stuexen#define SCTP_STREAM_CHANGED_DENIED 0x0010 457163953Srrs 458234790Stuexen/* 459234790Stuexen * Assoc reset event - subscribe to SCTP_ASSOC_RESET_EVENT 460234790Stuexen */ 461234790Stuexenstruct sctp_assoc_reset_event { 462234790Stuexen uint16_t assocreset_type; 463234790Stuexen uint16_t assocreset_flags; 464234790Stuexen uint32_t assocreset_length; 465234790Stuexen sctp_assoc_t assocreset_assoc_id; 466234790Stuexen uint32_t assocreset_local_tsn; 467234790Stuexen uint32_t assocreset_remote_tsn; 468234790Stuexen}; 469234790Stuexen 470234790Stuexen#define SCTP_ASSOC_RESET_DENIED 0x0004 471234790Stuexen#define SCTP_ASSOC_RESET_FAILED 0x0008 472234790Stuexen 473234790Stuexen/* 474234790Stuexen * Stream change event - subscribe to SCTP_STREAM_CHANGE_EVENT 475234790Stuexen */ 476234790Stuexenstruct sctp_stream_change_event { 477234790Stuexen uint16_t strchange_type; 478234790Stuexen uint16_t strchange_flags; 479234790Stuexen uint32_t strchange_length; 480234790Stuexen sctp_assoc_t strchange_assoc_id; 481234790Stuexen uint16_t strchange_instrms; 482234790Stuexen uint16_t strchange_outstrms; 483234790Stuexen}; 484234790Stuexen 485234790Stuexen#define SCTP_STREAM_CHANGE_DENIED 0x0004 486234790Stuexen#define SCTP_STREAM_CHANGE_FAILED 0x0008 487234790Stuexen 488234790Stuexen 489163953Srrs/* SCTP notification event */ 490163953Srrsstruct sctp_tlv { 491163953Srrs uint16_t sn_type; 492163953Srrs uint16_t sn_flags; 493163953Srrs uint32_t sn_length; 494163953Srrs}; 495163953Srrs 496163953Srrsunion sctp_notification { 497163953Srrs struct sctp_tlv sn_header; 498163953Srrs struct sctp_assoc_change sn_assoc_change; 499163953Srrs struct sctp_paddr_change sn_paddr_change; 500163953Srrs struct sctp_remote_error sn_remote_error; 501163953Srrs struct sctp_send_failed sn_send_failed; 502163953Srrs struct sctp_shutdown_event sn_shutdown_event; 503163953Srrs struct sctp_adaptation_event sn_adaptation_event; 504215034Sbrucec /* compatibility same as above */ 505163953Srrs struct sctp_adaption_event sn_adaption_event; 506163953Srrs struct sctp_pdapi_event sn_pdapi_event; 507163953Srrs struct sctp_authkey_event sn_auth_event; 508185694Srrs struct sctp_sender_dry_event sn_sender_dry_event; 509163953Srrs struct sctp_stream_reset_event sn_strreset_event; 510234790Stuexen struct sctp_assoc_reset_event sn_assocreset_event; 511234790Stuexen struct sctp_stream_change_event sn_strchange_event; 512234790Stuexen 513163953Srrs}; 514163953Srrs 515163953Srrs/* notification types */ 516202520Srrs#define SCTP_ASSOC_CHANGE 0x0001 517202520Srrs#define SCTP_PEER_ADDR_CHANGE 0x0002 518202520Srrs#define SCTP_REMOTE_ERROR 0x0003 519202520Srrs#define SCTP_SEND_FAILED 0x0004 520202520Srrs#define SCTP_SHUTDOWN_EVENT 0x0005 521202520Srrs#define SCTP_ADAPTATION_INDICATION 0x0006 522163953Srrs/* same as above */ 523202520Srrs#define SCTP_ADAPTION_INDICATION 0x0006 524202520Srrs#define SCTP_PARTIAL_DELIVERY_EVENT 0x0007 525202520Srrs#define SCTP_AUTHENTICATION_EVENT 0x0008 526202520Srrs#define SCTP_STREAM_RESET_EVENT 0x0009 527202520Srrs#define SCTP_SENDER_DRY_EVENT 0x000a 528216878Stuexen#define SCTP_NOTIFICATIONS_STOPPED_EVENT 0x000b /* we don't send this */ 529234790Stuexen#define SCTP_ASSOC_RESET_EVENT 0x000c 530234790Stuexen#define SCTP_STREAM_CHANGE_EVENT 0x000d 531234790Stuexen 532163953Srrs/* 533163953Srrs * socket option structs 534163953Srrs */ 535163953Srrs 536163953Srrsstruct sctp_paddrparams { 537170992Srrs struct sockaddr_storage spp_address; 538163953Srrs sctp_assoc_t spp_assoc_id; 539163953Srrs uint32_t spp_hbinterval; 540163953Srrs uint32_t spp_pathmtu; 541163953Srrs uint32_t spp_flags; 542163953Srrs uint32_t spp_ipv6_flowlabel; 543170992Srrs uint16_t spp_pathmaxrxt; 544224870Stuexen uint8_t spp_dscp; 545163953Srrs}; 546163953Srrs 547224870Stuexen#define spp_ipv4_tos spp_dscp 548224870Stuexen 549163953Srrs#define SPP_HB_ENABLE 0x00000001 550163953Srrs#define SPP_HB_DISABLE 0x00000002 551163953Srrs#define SPP_HB_DEMAND 0x00000004 552163953Srrs#define SPP_PMTUD_ENABLE 0x00000008 553163953Srrs#define SPP_PMTUD_DISABLE 0x00000010 554163953Srrs#define SPP_HB_TIME_IS_ZERO 0x00000080 555163953Srrs#define SPP_IPV6_FLOWLABEL 0x00000100 556224870Stuexen#define SPP_DSCP 0x00000200 557224870Stuexen#define SPP_IPV4_TOS SPP_DSCP 558163953Srrs 559224641Stuexenstruct sctp_paddrthlds { 560227948Stuexen struct sockaddr_storage spt_address; 561224641Stuexen sctp_assoc_t spt_assoc_id; 562224641Stuexen uint16_t spt_pathmaxrxt; 563224641Stuexen uint16_t spt_pathpfthld; 564224641Stuexen}; 565224641Stuexen 566163953Srrsstruct sctp_paddrinfo { 567170992Srrs struct sockaddr_storage spinfo_address; 568163953Srrs sctp_assoc_t spinfo_assoc_id; 569163953Srrs int32_t spinfo_state; 570163953Srrs uint32_t spinfo_cwnd; 571163953Srrs uint32_t spinfo_srtt; 572163953Srrs uint32_t spinfo_rto; 573163953Srrs uint32_t spinfo_mtu; 574163953Srrs}; 575163953Srrs 576163953Srrsstruct sctp_rtoinfo { 577163953Srrs sctp_assoc_t srto_assoc_id; 578163953Srrs uint32_t srto_initial; 579163953Srrs uint32_t srto_max; 580163953Srrs uint32_t srto_min; 581163953Srrs}; 582163953Srrs 583163953Srrsstruct sctp_assocparams { 584163953Srrs sctp_assoc_t sasoc_assoc_id; 585163953Srrs uint32_t sasoc_peer_rwnd; 586163953Srrs uint32_t sasoc_local_rwnd; 587163953Srrs uint32_t sasoc_cookie_life; 588170992Srrs uint16_t sasoc_asocmaxrxt; 589170992Srrs uint16_t sasoc_number_peer_destinations; 590163953Srrs}; 591163953Srrs 592163953Srrsstruct sctp_setprim { 593170992Srrs struct sockaddr_storage ssp_addr; 594163953Srrs sctp_assoc_t ssp_assoc_id; 595170992Srrs uint8_t ssp_padding[4]; 596163953Srrs}; 597163953Srrs 598163953Srrsstruct sctp_setpeerprim { 599170992Srrs struct sockaddr_storage sspp_addr; 600163953Srrs sctp_assoc_t sspp_assoc_id; 601170992Srrs uint8_t sspp_padding[4]; 602163953Srrs}; 603163953Srrs 604163953Srrsstruct sctp_getaddresses { 605163953Srrs sctp_assoc_t sget_assoc_id; 606163953Srrs /* addr is filled in for N * sockaddr_storage */ 607163953Srrs struct sockaddr addr[1]; 608163953Srrs}; 609163953Srrs 610163953Srrsstruct sctp_setstrm_timeout { 611163953Srrs sctp_assoc_t ssto_assoc_id; 612163953Srrs uint32_t ssto_timeout; 613163953Srrs uint32_t ssto_streamid_start; 614163953Srrs uint32_t ssto_streamid_end; 615163953Srrs}; 616163953Srrs 617163953Srrsstruct sctp_status { 618163953Srrs sctp_assoc_t sstat_assoc_id; 619163953Srrs int32_t sstat_state; 620163953Srrs uint32_t sstat_rwnd; 621163953Srrs uint16_t sstat_unackdata; 622163953Srrs uint16_t sstat_penddata; 623163953Srrs uint16_t sstat_instrms; 624163953Srrs uint16_t sstat_outstrms; 625163953Srrs uint32_t sstat_fragmentation_point; 626163953Srrs struct sctp_paddrinfo sstat_primary; 627163953Srrs}; 628163953Srrs 629163953Srrs/* 630163953Srrs * AUTHENTICATION support 631163953Srrs */ 632163953Srrs/* SCTP_AUTH_CHUNK */ 633163953Srrsstruct sctp_authchunk { 634163953Srrs uint8_t sauth_chunk; 635163953Srrs}; 636163953Srrs 637163953Srrs/* SCTP_AUTH_KEY */ 638163953Srrsstruct sctp_authkey { 639163953Srrs sctp_assoc_t sca_assoc_id; 640163953Srrs uint16_t sca_keynumber; 641223697Stuexen uint16_t sca_keylength; 642202782Stuexen uint8_t sca_key[]; 643163953Srrs}; 644163953Srrs 645163953Srrs/* SCTP_HMAC_IDENT */ 646163953Srrsstruct sctp_hmacalgo { 647179141Srrs uint32_t shmac_number_of_idents; 648202782Stuexen uint16_t shmac_idents[]; 649163953Srrs}; 650163953Srrs 651163953Srrs/* AUTH hmac_id */ 652163953Srrs#define SCTP_AUTH_HMAC_ID_RSVD 0x0000 653163953Srrs#define SCTP_AUTH_HMAC_ID_SHA1 0x0001 /* default, mandatory */ 654163953Srrs#define SCTP_AUTH_HMAC_ID_SHA256 0x0003 655171745Srrs#define SCTP_AUTH_HMAC_ID_SHA224 0x0004 656171745Srrs#define SCTP_AUTH_HMAC_ID_SHA384 0x0005 657171745Srrs#define SCTP_AUTH_HMAC_ID_SHA512 0x0006 658163953Srrs 659163953Srrs 660163953Srrs/* SCTP_AUTH_ACTIVE_KEY / SCTP_AUTH_DELETE_KEY */ 661163953Srrsstruct sctp_authkeyid { 662163953Srrs sctp_assoc_t scact_assoc_id; 663163953Srrs uint16_t scact_keynumber; 664163953Srrs}; 665163953Srrs 666163953Srrs/* SCTP_PEER_AUTH_CHUNKS / SCTP_LOCAL_AUTH_CHUNKS */ 667163953Srrsstruct sctp_authchunks { 668163953Srrs sctp_assoc_t gauth_assoc_id; 669202782Stuexen uint8_t gauth_chunks[]; 670163953Srrs}; 671163953Srrs 672163953Srrsstruct sctp_assoc_value { 673163953Srrs sctp_assoc_t assoc_id; 674163953Srrs uint32_t assoc_value; 675163953Srrs}; 676163953Srrs 677219057Srrsstruct sctp_cc_option { 678219057Srrs int option; 679219057Srrs struct sctp_assoc_value aid_value; 680219057Srrs}; 681219057Srrs 682217760Stuexenstruct sctp_stream_value { 683217760Stuexen sctp_assoc_t assoc_id; 684217760Stuexen uint16_t stream_id; 685217760Stuexen uint16_t stream_value; 686217760Stuexen}; 687217760Stuexen 688163953Srrsstruct sctp_assoc_ids { 689185694Srrs uint32_t gaids_number_of_ids; 690202782Stuexen sctp_assoc_t gaids_assoc_id[]; 691163953Srrs}; 692163953Srrs 693170056Srrsstruct sctp_sack_info { 694170056Srrs sctp_assoc_t sack_assoc_id; 695170056Srrs uint32_t sack_delay; 696170056Srrs uint32_t sack_freq; 697170056Srrs}; 698170056Srrs 699215410Stuexenstruct sctp_timeouts { 700215410Stuexen sctp_assoc_t stimo_assoc_id; 701215410Stuexen uint32_t stimo_init; 702215410Stuexen uint32_t stimo_data; 703215410Stuexen uint32_t stimo_sack; 704215410Stuexen uint32_t stimo_shutdown; 705215410Stuexen uint32_t stimo_heartbeat; 706215410Stuexen uint32_t stimo_cookie; 707215410Stuexen uint32_t stimo_shutdownack; 708215410Stuexen}; 709215410Stuexen 710231070Stuexenstruct sctp_udpencaps { 711231073Stuexen struct sockaddr_storage sue_address; 712231070Stuexen sctp_assoc_t sue_assoc_id; 713231070Stuexen uint16_t sue_port; 714231070Stuexen}; 715231070Stuexen 716163953Srrsstruct sctp_cwnd_args { 717170992Srrs struct sctp_nets *net; /* network to *//* FIXME: LP64 issue */ 718163953Srrs uint32_t cwnd_new_value;/* cwnd in k */ 719163953Srrs uint32_t pseudo_cumack; 720190689Srrs uint16_t inflight; /* flightsize in k */ 721190689Srrs uint16_t cwnd_augment; /* increment to it */ 722163953Srrs uint8_t meets_pseudo_cumack; 723163953Srrs uint8_t need_new_pseudo_cumack; 724163953Srrs uint8_t cnt_in_send; 725163953Srrs uint8_t cnt_in_str; 726163953Srrs}; 727163953Srrs 728163953Srrsstruct sctp_blk_args { 729163953Srrs uint32_t onsb; /* in 1k bytes */ 730163953Srrs uint32_t sndlen; /* len of send being attempted */ 731163953Srrs uint32_t peer_rwnd; /* rwnd of peer */ 732163953Srrs uint16_t send_sent_qcnt;/* chnk cnt */ 733163953Srrs uint16_t stream_qcnt; /* chnk cnt */ 734163953Srrs uint16_t chunks_on_oque;/* chunks out */ 735163953Srrs uint16_t flight_size; /* flight size in k */ 736163953Srrs}; 737163953Srrs 738163953Srrs/* 739163953Srrs * Max we can reset in one setting, note this is dictated not by the define 740163953Srrs * but the size of a mbuf cluster so don't change this define and think you 741163953Srrs * can specify more. You must do multiple resets if you want to reset more 742163953Srrs * than SCTP_MAX_EXPLICIT_STR_RESET. 743163953Srrs */ 744163953Srrs#define SCTP_MAX_EXPLICT_STR_RESET 1000 745163953Srrs 746234790Stuexenstruct sctp_reset_streams { 747234790Stuexen sctp_assoc_t srs_assoc_id; 748234790Stuexen uint16_t srs_flags; 749234790Stuexen uint16_t srs_number_streams; /* 0 == ALL */ 750234790Stuexen uint16_t srs_stream_list[]; /* list if strrst_num_streams is not 0 */ 751234790Stuexen}; 752163953Srrs 753234790Stuexenstruct sctp_add_streams { 754234790Stuexen sctp_assoc_t sas_assoc_id; 755234790Stuexen uint16_t sas_instrms; 756234790Stuexen uint16_t sas_outstrms; 757163953Srrs}; 758163953Srrs 759163953Srrsstruct sctp_get_nonce_values { 760163953Srrs sctp_assoc_t gn_assoc_id; 761163953Srrs uint32_t gn_peers_tag; 762163953Srrs uint32_t gn_local_tag; 763163953Srrs}; 764163953Srrs 765163953Srrs/* Debugging logs */ 766163953Srrsstruct sctp_str_log { 767170992Srrs void *stcb; /* FIXME: LP64 issue */ 768163953Srrs uint32_t n_tsn; 769163953Srrs uint32_t e_tsn; 770163953Srrs uint16_t n_sseq; 771163953Srrs uint16_t e_sseq; 772164181Srrs uint16_t strm; 773163953Srrs}; 774163953Srrs 775163953Srrsstruct sctp_sb_log { 776170992Srrs void *stcb; /* FIXME: LP64 issue */ 777163953Srrs uint32_t so_sbcc; 778163953Srrs uint32_t stcb_sbcc; 779163953Srrs uint32_t incr; 780163953Srrs}; 781163953Srrs 782163953Srrsstruct sctp_fr_log { 783163953Srrs uint32_t largest_tsn; 784163953Srrs uint32_t largest_new_tsn; 785163953Srrs uint32_t tsn; 786163953Srrs}; 787163953Srrs 788163953Srrsstruct sctp_fr_map { 789163953Srrs uint32_t base; 790163953Srrs uint32_t cum; 791163953Srrs uint32_t high; 792163953Srrs}; 793163953Srrs 794163953Srrsstruct sctp_rwnd_log { 795163953Srrs uint32_t rwnd; 796163953Srrs uint32_t send_size; 797163953Srrs uint32_t overhead; 798163953Srrs uint32_t new_rwnd; 799163953Srrs}; 800163953Srrs 801163953Srrsstruct sctp_mbcnt_log { 802163953Srrs uint32_t total_queue_size; 803163953Srrs uint32_t size_change; 804163953Srrs uint32_t total_queue_mb_size; 805163953Srrs uint32_t mbcnt_change; 806163953Srrs}; 807163953Srrs 808163953Srrsstruct sctp_sack_log { 809163953Srrs uint32_t cumack; 810163953Srrs uint32_t oldcumack; 811163953Srrs uint32_t tsn; 812163953Srrs uint16_t numGaps; 813163953Srrs uint16_t numDups; 814163953Srrs}; 815163953Srrs 816163953Srrsstruct sctp_lock_log { 817170992Srrs void *sock; /* FIXME: LP64 issue */ 818170992Srrs void *inp; /* FIXME: LP64 issue */ 819163953Srrs uint8_t tcb_lock; 820163953Srrs uint8_t inp_lock; 821163953Srrs uint8_t info_lock; 822163953Srrs uint8_t sock_lock; 823163953Srrs uint8_t sockrcvbuf_lock; 824163953Srrs uint8_t socksndbuf_lock; 825163953Srrs uint8_t create_lock; 826163953Srrs uint8_t resv; 827163953Srrs}; 828163953Srrs 829163953Srrsstruct sctp_rto_log { 830170992Srrs void *net; /* FIXME: LP64 issue */ 831163953Srrs uint32_t rtt; 832163953Srrs}; 833163953Srrs 834163953Srrsstruct sctp_nagle_log { 835170992Srrs void *stcb; /* FIXME: LP64 issue */ 836163953Srrs uint32_t total_flight; 837163953Srrs uint32_t total_in_queue; 838163953Srrs uint16_t count_in_queue; 839163953Srrs uint16_t count_in_flight; 840163953Srrs}; 841163953Srrs 842163953Srrsstruct sctp_sbwake_log { 843170992Srrs void *stcb; /* FIXME: LP64 issue */ 844163953Srrs uint16_t send_q; 845163953Srrs uint16_t sent_q; 846163953Srrs uint16_t flight; 847163953Srrs uint16_t wake_cnt; 848163953Srrs uint8_t stream_qcnt; /* chnk cnt */ 849163953Srrs uint8_t chunks_on_oque; /* chunks out */ 850163953Srrs uint8_t sbflags; 851163953Srrs uint8_t sctpflags; 852163953Srrs}; 853163953Srrs 854163953Srrsstruct sctp_misc_info { 855163953Srrs uint32_t log1; 856163953Srrs uint32_t log2; 857163953Srrs uint32_t log3; 858163953Srrs uint32_t log4; 859163953Srrs}; 860163953Srrs 861163953Srrsstruct sctp_log_closing { 862170992Srrs void *inp; /* FIXME: LP64 issue */ 863170992Srrs void *stcb; /* FIXME: LP64 issue */ 864163953Srrs uint32_t sctp_flags; 865163953Srrs uint16_t state; 866163953Srrs int16_t loc; 867163953Srrs}; 868163953Srrs 869163953Srrsstruct sctp_mbuf_log { 870170992Srrs struct mbuf *mp; /* FIXME: LP64 issue */ 871163953Srrs caddr_t ext; 872163953Srrs caddr_t data; 873163953Srrs uint16_t size; 874163953Srrs uint8_t refcnt; 875163953Srrs uint8_t mbuf_flags; 876163953Srrs}; 877163953Srrs 878163953Srrsstruct sctp_cwnd_log { 879170744Srrs uint64_t time_event; 880163953Srrs uint8_t from; 881163953Srrs uint8_t event_type; 882163953Srrs uint8_t resv[2]; 883163953Srrs union { 884163953Srrs struct sctp_log_closing close; 885163953Srrs struct sctp_blk_args blk; 886163953Srrs struct sctp_cwnd_args cwnd; 887163953Srrs struct sctp_str_log strlog; 888163953Srrs struct sctp_fr_log fr; 889163953Srrs struct sctp_fr_map map; 890163953Srrs struct sctp_rwnd_log rwnd; 891163953Srrs struct sctp_mbcnt_log mbcnt; 892163953Srrs struct sctp_sack_log sack; 893163953Srrs struct sctp_lock_log lock; 894163953Srrs struct sctp_rto_log rto; 895163953Srrs struct sctp_sb_log sb; 896163953Srrs struct sctp_nagle_log nagle; 897163953Srrs struct sctp_sbwake_log wake; 898163953Srrs struct sctp_mbuf_log mb; 899163953Srrs struct sctp_misc_info misc; 900163953Srrs } x; 901163953Srrs}; 902163953Srrs 903163953Srrsstruct sctp_cwnd_log_req { 904170992Srrs int32_t num_in_log; /* Number in log */ 905170992Srrs int32_t num_ret; /* Number returned */ 906170992Srrs int32_t start_at; /* start at this one */ 907170992Srrs int32_t end_at; /* end at this one */ 908202782Stuexen struct sctp_cwnd_log log[]; 909163953Srrs}; 910163953Srrs 911172091Srrsstruct sctp_timeval { 912172091Srrs uint32_t tv_sec; 913172091Srrs uint32_t tv_usec; 914172091Srrs}; 915172091Srrs 916163953Srrsstruct sctpstat { 917191890Srrs struct sctp_timeval sctps_discontinuitytime; /* sctpStats 18 918191890Srrs * (TimeStamp) */ 919163953Srrs /* MIB according to RFC 3873 */ 920170992Srrs uint32_t sctps_currestab; /* sctpStats 1 (Gauge32) */ 921170992Srrs uint32_t sctps_activeestab; /* sctpStats 2 (Counter32) */ 922170992Srrs uint32_t sctps_restartestab; 923170992Srrs uint32_t sctps_collisionestab; 924170992Srrs uint32_t sctps_passiveestab; /* sctpStats 3 (Counter32) */ 925170992Srrs uint32_t sctps_aborted; /* sctpStats 4 (Counter32) */ 926170992Srrs uint32_t sctps_shutdown;/* sctpStats 5 (Counter32) */ 927170992Srrs uint32_t sctps_outoftheblue; /* sctpStats 6 (Counter32) */ 928170992Srrs uint32_t sctps_checksumerrors; /* sctpStats 7 (Counter32) */ 929170992Srrs uint32_t sctps_outcontrolchunks; /* sctpStats 8 (Counter64) */ 930170992Srrs uint32_t sctps_outorderchunks; /* sctpStats 9 (Counter64) */ 931170992Srrs uint32_t sctps_outunorderchunks; /* sctpStats 10 (Counter64) */ 932170992Srrs uint32_t sctps_incontrolchunks; /* sctpStats 11 (Counter64) */ 933170992Srrs uint32_t sctps_inorderchunks; /* sctpStats 12 (Counter64) */ 934170992Srrs uint32_t sctps_inunorderchunks; /* sctpStats 13 (Counter64) */ 935170992Srrs uint32_t sctps_fragusrmsgs; /* sctpStats 14 (Counter64) */ 936170992Srrs uint32_t sctps_reasmusrmsgs; /* sctpStats 15 (Counter64) */ 937170992Srrs uint32_t sctps_outpackets; /* sctpStats 16 (Counter64) */ 938170992Srrs uint32_t sctps_inpackets; /* sctpStats 17 (Counter64) */ 939170992Srrs 940163953Srrs /* input statistics: */ 941170992Srrs uint32_t sctps_recvpackets; /* total input packets */ 942170992Srrs uint32_t sctps_recvdatagrams; /* total input datagrams */ 943170992Srrs uint32_t sctps_recvpktwithdata; /* total packets that had data */ 944170992Srrs uint32_t sctps_recvsacks; /* total input SACK chunks */ 945170992Srrs uint32_t sctps_recvdata;/* total input DATA chunks */ 946170992Srrs uint32_t sctps_recvdupdata; /* total input duplicate DATA chunks */ 947170992Srrs uint32_t sctps_recvheartbeat; /* total input HB chunks */ 948170992Srrs uint32_t sctps_recvheartbeatack; /* total input HB-ACK chunks */ 949170992Srrs uint32_t sctps_recvecne;/* total input ECNE chunks */ 950170992Srrs uint32_t sctps_recvauth;/* total input AUTH chunks */ 951170992Srrs uint32_t sctps_recvauthmissing; /* total input chunks missing AUTH */ 952170992Srrs uint32_t sctps_recvivalhmacid; /* total number of invalid HMAC ids 953163953Srrs * received */ 954170992Srrs uint32_t sctps_recvivalkeyid; /* total number of invalid secret ids 955163953Srrs * received */ 956170992Srrs uint32_t sctps_recvauthfailed; /* total number of auth failed */ 957170992Srrs uint32_t sctps_recvexpress; /* total fast path receives all one 958163953Srrs * chunk */ 959170992Srrs uint32_t sctps_recvexpressm; /* total fast path multi-part data */ 960188067Srrs uint32_t sctps_recvnocrc; 961188067Srrs uint32_t sctps_recvswcrc; 962188067Srrs uint32_t sctps_recvhwcrc; 963188067Srrs 964163953Srrs /* output statistics: */ 965170992Srrs uint32_t sctps_sendpackets; /* total output packets */ 966170992Srrs uint32_t sctps_sendsacks; /* total output SACKs */ 967170992Srrs uint32_t sctps_senddata;/* total output DATA chunks */ 968170992Srrs uint32_t sctps_sendretransdata; /* total output retransmitted DATA 969163953Srrs * chunks */ 970170992Srrs uint32_t sctps_sendfastretrans; /* total output fast retransmitted 971163953Srrs * DATA chunks */ 972170992Srrs uint32_t sctps_sendmultfastretrans; /* total FR's that happened 973168755Srrs * more than once to same 974168755Srrs * chunk (u-del multi-fr 975168755Srrs * algo). */ 976170992Srrs uint32_t sctps_sendheartbeat; /* total output HB chunks */ 977170992Srrs uint32_t sctps_sendecne;/* total output ECNE chunks */ 978170992Srrs uint32_t sctps_sendauth;/* total output AUTH chunks FIXME */ 979170992Srrs uint32_t sctps_senderrors; /* ip_output error counter */ 980188067Srrs uint32_t sctps_sendnocrc; 981188067Srrs uint32_t sctps_sendswcrc; 982188067Srrs uint32_t sctps_sendhwcrc; 983163953Srrs /* PCKDROPREP statistics: */ 984170992Srrs uint32_t sctps_pdrpfmbox; /* Packet drop from middle box */ 985170992Srrs uint32_t sctps_pdrpfehos; /* P-drop from end host */ 986170992Srrs uint32_t sctps_pdrpmbda;/* P-drops with data */ 987170992Srrs uint32_t sctps_pdrpmbct;/* P-drops, non-data, non-endhost */ 988170992Srrs uint32_t sctps_pdrpbwrpt; /* P-drop, non-endhost, bandwidth rep 989170992Srrs * only */ 990170992Srrs uint32_t sctps_pdrpcrupt; /* P-drop, not enough for chunk header */ 991170992Srrs uint32_t sctps_pdrpnedat; /* P-drop, not enough data to confirm */ 992170992Srrs uint32_t sctps_pdrppdbrk; /* P-drop, where process_chunk_drop 993170992Srrs * said break */ 994170992Srrs uint32_t sctps_pdrptsnnf; /* P-drop, could not find TSN */ 995170992Srrs uint32_t sctps_pdrpdnfnd; /* P-drop, attempt reverse TSN lookup */ 996170992Srrs uint32_t sctps_pdrpdiwnp; /* P-drop, e-host confirms zero-rwnd */ 997170992Srrs uint32_t sctps_pdrpdizrw; /* P-drop, midbox confirms no space */ 998170992Srrs uint32_t sctps_pdrpbadd;/* P-drop, data did not match TSN */ 999170992Srrs uint32_t sctps_pdrpmark;/* P-drop, TSN's marked for Fast Retran */ 1000163953Srrs /* timeouts */ 1001170992Srrs uint32_t sctps_timoiterator; /* Number of iterator timers that 1002168755Srrs * fired */ 1003170992Srrs uint32_t sctps_timodata;/* Number of T3 data time outs */ 1004170992Srrs uint32_t sctps_timowindowprobe; /* Number of window probe (T3) timers 1005168755Srrs * that fired */ 1006170992Srrs uint32_t sctps_timoinit;/* Number of INIT timers that fired */ 1007170992Srrs uint32_t sctps_timosack;/* Number of sack timers that fired */ 1008170992Srrs uint32_t sctps_timoshutdown; /* Number of shutdown timers that 1009168755Srrs * fired */ 1010170992Srrs uint32_t sctps_timoheartbeat; /* Number of heartbeat timers that 1011168755Srrs * fired */ 1012170992Srrs uint32_t sctps_timocookie; /* Number of times a cookie timeout 1013168755Srrs * fired */ 1014170992Srrs uint32_t sctps_timosecret; /* Number of times an endpoint changed 1015170992Srrs * its cookie secret */ 1016170992Srrs uint32_t sctps_timopathmtu; /* Number of PMTU timers that fired */ 1017170992Srrs uint32_t sctps_timoshutdownack; /* Number of shutdown ack timers that 1018168755Srrs * fired */ 1019170992Srrs uint32_t sctps_timoshutdownguard; /* Number of shutdown guard 1020170992Srrs * timers that fired */ 1021170992Srrs uint32_t sctps_timostrmrst; /* Number of stream reset timers that 1022168755Srrs * fired */ 1023170992Srrs uint32_t sctps_timoearlyfr; /* Number of early FR timers that 1024168755Srrs * fired */ 1025170992Srrs uint32_t sctps_timoasconf; /* Number of times an asconf timer 1026170992Srrs * fired */ 1027172091Srrs uint32_t sctps_timodelprim; /* Number of times a prim_deleted 1028172091Srrs * timer fired */ 1029170992Srrs uint32_t sctps_timoautoclose; /* Number of times auto close timer 1030170992Srrs * fired */ 1031170992Srrs uint32_t sctps_timoassockill; /* Number of asoc free timers expired */ 1032170992Srrs uint32_t sctps_timoinpkill; /* Number of inp free timers expired */ 1033224641Stuexen /* former early FR counters */ 1034224641Stuexen uint32_t sctps_spare[11]; 1035215034Sbrucec /* others */ 1036170992Srrs uint32_t sctps_hdrops; /* packet shorter than header */ 1037170992Srrs uint32_t sctps_badsum; /* checksum error */ 1038170992Srrs uint32_t sctps_noport; /* no endpoint for port */ 1039170992Srrs uint32_t sctps_badvtag; /* bad v-tag */ 1040170992Srrs uint32_t sctps_badsid; /* bad SID */ 1041170992Srrs uint32_t sctps_nomem; /* no memory */ 1042170992Srrs uint32_t sctps_fastretransinrtt; /* number of multiple FR in a 1043170992Srrs * RTT window */ 1044170992Srrs uint32_t sctps_markedretrans; 1045170992Srrs uint32_t sctps_naglesent; /* nagle allowed sending */ 1046215034Sbrucec uint32_t sctps_naglequeued; /* nagle doesn't allow sending */ 1047215034Sbrucec uint32_t sctps_maxburstqueued; /* max burst doesn't allow sending */ 1048170992Srrs uint32_t sctps_ifnomemqueued; /* look ahead tells us no memory in 1049168755Srrs * interface ring buffer OR we had a 1050168755Srrs * send error and are queuing one 1051168755Srrs * send. */ 1052170992Srrs uint32_t sctps_windowprobed; /* total number of window probes sent */ 1053170992Srrs uint32_t sctps_lowlevelerr; /* total times an output error causes 1054168755Srrs * us to clamp down on next user send. */ 1055170992Srrs uint32_t sctps_lowlevelerrusr; /* total times sctp_senderrors were 1056168755Srrs * caused from a user send from a user 1057168755Srrs * invoked send not a sack response */ 1058170992Srrs uint32_t sctps_datadropchklmt; /* Number of in data drops due to 1059168755Srrs * chunk limit reached */ 1060170992Srrs uint32_t sctps_datadroprwnd; /* Number of in data drops due to rwnd 1061168755Srrs * limit reached */ 1062170992Srrs uint32_t sctps_ecnereducedcwnd; /* Number of times a ECN reduced the 1063168755Srrs * cwnd */ 1064170992Srrs uint32_t sctps_vtagexpress; /* Used express lookup via vtag */ 1065170992Srrs uint32_t sctps_vtagbogus; /* Collision in express lookup. */ 1066170992Srrs uint32_t sctps_primary_randry; /* Number of times the sender ran dry 1067163953Srrs * of user data on primary */ 1068170992Srrs uint32_t sctps_cmt_randry; /* Same for above */ 1069170992Srrs uint32_t sctps_slowpath_sack; /* Sacks the slow way */ 1070170992Srrs uint32_t sctps_wu_sacks_sent; /* Window Update only sacks sent */ 1071170992Srrs uint32_t sctps_sends_with_flags; /* number of sends with 1072170992Srrs * sinfo_flags !=0 */ 1073215817Srrs uint32_t sctps_sends_with_unord; /* number of unordered sends */ 1074170992Srrs uint32_t sctps_sends_with_eof; /* number of sends with EOF flag set */ 1075170992Srrs uint32_t sctps_sends_with_abort; /* number of sends with ABORT 1076170992Srrs * flag set */ 1077170992Srrs uint32_t sctps_protocol_drain_calls; /* number of times protocol 1078168755Srrs * drain called */ 1079170992Srrs uint32_t sctps_protocol_drains_done; /* number of times we did a 1080168755Srrs * protocol drain */ 1081170992Srrs uint32_t sctps_read_peeks; /* Number of times recv was called 1082170992Srrs * with peek */ 1083170992Srrs uint32_t sctps_cached_chk; /* Number of cached chunks used */ 1084170992Srrs uint32_t sctps_cached_strmoq; /* Number of cached stream oq's used */ 1085215034Sbrucec uint32_t sctps_left_abandon; /* Number of unread messages abandoned 1086168859Srrs * by close */ 1087188854Srrs uint32_t sctps_send_burst_avoid; /* Unused */ 1088170992Srrs uint32_t sctps_send_cwnd_avoid; /* Send cwnd full avoidance, already 1089169352Srrs * max burst inflight to net */ 1090170992Srrs uint32_t sctps_fwdtsn_map_over; /* number of map array over-runs via 1091170091Srrs * fwd-tsn's */ 1092218037Srrs uint32_t sctps_queue_upd_ecne; /* Number of times we queued or 1093218037Srrs * updated an ECN chunk on send queue */ 1094218037Srrs uint32_t sctps_reserved[31]; /* Future ABI compat - remove int's 1095191890Srrs * from here when adding new */ 1096163953Srrs}; 1097163953Srrs 1098163953Srrs#define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1) 1099163953Srrs#define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1) 1100205629Srrs#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT) 1101205629Srrs#define SCTP_STAT_INCR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x += _d) 1102205629Srrs#define SCTP_STAT_DECR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x -= _d) 1103205629Srrs#else 1104179783Srrs#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d) 1105179783Srrs#define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d) 1106205629Srrs#endif 1107163953Srrs/* The following macros are for handling MIB values, */ 1108163953Srrs#define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x) 1109163953Srrs#define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x) 1110163953Srrs#define SCTP_STAT_INCR_GAUGE32(_x) SCTP_STAT_INCR(_x) 1111163953Srrs#define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x) 1112163953Srrs#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x) 1113163953Srrs#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x) 1114163953Srrs 1115164085Srrsunion sctp_sockstore { 1116167598Srrs#if defined(INET) || !defined(_KERNEL) 1117164085Srrs struct sockaddr_in sin; 1118164085Srrs#endif 1119167598Srrs#if defined(INET6) || !defined(_KERNEL) 1120164085Srrs struct sockaddr_in6 sin6; 1121164085Srrs#endif 1122164085Srrs struct sockaddr sa; 1123164085Srrs}; 1124164085Srrs 1125212242Stuexen 1126212242Stuexen/***********************************/ 1127212242Stuexen/* And something for us old timers */ 1128212242Stuexen/***********************************/ 1129212242Stuexen 1130212242Stuexen#ifndef ntohll 1131212242Stuexen#include <sys/endian.h> 1132212242Stuexen#define ntohll(x) be64toh(x) 1133212242Stuexen#endif 1134212242Stuexen 1135212242Stuexen#ifndef htonll 1136212242Stuexen#include <sys/endian.h> 1137212242Stuexen#define htonll(x) htobe64(x) 1138212242Stuexen#endif 1139212242Stuexen/***********************************/ 1140212242Stuexen 1141212242Stuexen 1142165220Srrsstruct xsctp_inpcb { 1143165220Srrs uint32_t last; 1144165220Srrs uint32_t flags; 1145165220Srrs uint32_t features; 1146165220Srrs uint32_t total_sends; 1147165220Srrs uint32_t total_recvs; 1148165220Srrs uint32_t total_nospaces; 1149169352Srrs uint32_t fragmentation_point; 1150170992Srrs uint16_t local_port; 1151170056Srrs uint16_t qlen; 1152170056Srrs uint16_t maxqlen; 1153190842Srrs uint32_t extra_padding[32]; /* future */ 1154165220Srrs}; 1155164085Srrs 1156165220Srrsstruct xsctp_tcb { 1157170992Srrs union sctp_sockstore primary_addr; /* sctpAssocEntry 5/6 */ 1158170056Srrs uint32_t last; 1159170056Srrs uint32_t heartbeat_interval; /* sctpAssocEntry 7 */ 1160170056Srrs uint32_t state; /* sctpAssocEntry 8 */ 1161170056Srrs uint32_t in_streams; /* sctpAssocEntry 9 */ 1162170056Srrs uint32_t out_streams; /* sctpAssocEntry 10 */ 1163170056Srrs uint32_t max_nr_retrans;/* sctpAssocEntry 11 */ 1164170056Srrs uint32_t primary_process; /* sctpAssocEntry 12 */ 1165170056Srrs uint32_t T1_expireries; /* sctpAssocEntry 13 */ 1166170056Srrs uint32_t T2_expireries; /* sctpAssocEntry 14 */ 1167170056Srrs uint32_t retransmitted_tsns; /* sctpAssocEntry 15 */ 1168165220Srrs uint32_t total_sends; 1169165220Srrs uint32_t total_recvs; 1170165220Srrs uint32_t local_tag; 1171165220Srrs uint32_t remote_tag; 1172165220Srrs uint32_t initial_tsn; 1173165220Srrs uint32_t highest_tsn; 1174165220Srrs uint32_t cumulative_tsn; 1175165220Srrs uint32_t cumulative_tsn_ack; 1176169352Srrs uint32_t mtu; 1177170091Srrs uint32_t refcnt; 1178170992Srrs uint16_t local_port; /* sctpAssocEntry 3 */ 1179170992Srrs uint16_t remote_port; /* sctpAssocEntry 4 */ 1180172091Srrs struct sctp_timeval start_time; /* sctpAssocEntry 16 */ 1181172091Srrs struct sctp_timeval discontinuity_time; /* sctpAssocEntry 17 */ 1182188577Srrs uint32_t peers_rwnd; 1183188067Srrs sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */ 1184190842Srrs uint32_t extra_padding[32]; /* future */ 1185165220Srrs}; 1186165220Srrs 1187165220Srrsstruct xsctp_laddr { 1188170992Srrs union sctp_sockstore address; /* sctpAssocLocalAddrEntry 1/2 */ 1189170056Srrs uint32_t last; 1190172091Srrs struct sctp_timeval start_time; /* sctpAssocLocalAddrEntry 3 */ 1191190842Srrs uint32_t extra_padding[32]; /* future */ 1192165220Srrs}; 1193165220Srrs 1194165220Srrsstruct xsctp_raddr { 1195170992Srrs union sctp_sockstore address; /* sctpAssocLocalRemEntry 1/2 */ 1196170056Srrs uint32_t last; 1197170056Srrs uint32_t rto; /* sctpAssocLocalRemEntry 5 */ 1198170056Srrs uint32_t max_path_rtx; /* sctpAssocLocalRemEntry 6 */ 1199170056Srrs uint32_t rtx; /* sctpAssocLocalRemEntry 7 */ 1200170056Srrs uint32_t error_counter; /* */ 1201170056Srrs uint32_t cwnd; /* */ 1202170056Srrs uint32_t flight_size; /* */ 1203170056Srrs uint32_t mtu; /* */ 1204170992Srrs uint8_t active; /* sctpAssocLocalRemEntry 3 */ 1205170992Srrs uint8_t confirmed; /* */ 1206170992Srrs uint8_t heartbeat_enabled; /* sctpAssocLocalRemEntry 4 */ 1207224641Stuexen uint8_t potentially_failed; 1208172091Srrs struct sctp_timeval start_time; /* sctpAssocLocalRemEntry 8 */ 1209190842Srrs uint32_t rtt; 1210224641Stuexen uint32_t heartbeat_interval; 1211224641Stuexen uint32_t extra_padding[31]; /* future */ 1212165220Srrs}; 1213165220Srrs 1214172157Srrs#define SCTP_MAX_LOGGING_SIZE 30000 1215172157Srrs#define SCTP_TRACE_PARAMS 6 /* This number MUST be even */ 1216172157Srrs 1217172157Srrsstruct sctp_log_entry { 1218172218Srrs uint64_t timestamp; 1219172157Srrs uint32_t subsys; 1220172157Srrs uint32_t padding; 1221172157Srrs uint32_t params[SCTP_TRACE_PARAMS]; 1222172157Srrs}; 1223172157Srrs 1224172157Srrsstruct sctp_log { 1225172157Srrs struct sctp_log_entry entry[SCTP_MAX_LOGGING_SIZE]; 1226172157Srrs uint32_t index; 1227172157Srrs uint32_t padding; 1228172157Srrs}; 1229172157Srrs 1230163953Srrs/* 1231163953Srrs * Kernel defined for sctp_send 1232163953Srrs */ 1233180387Srrs#if defined(_KERNEL) || defined(__Userspace__) 1234163953Srrsint 1235163953Srrssctp_lower_sosend(struct socket *so, 1236163953Srrs struct sockaddr *addr, 1237163953Srrs struct uio *uio, 1238169352Srrs struct mbuf *i_pak, 1239163953Srrs struct mbuf *control, 1240163953Srrs int flags, 1241168709Srrs struct sctp_sndrcvinfo *srcv 1242168709Srrs ,struct thread *p 1243163953Srrs); 1244163953Srrs 1245163953Srrsint 1246163953Srrssctp_sorecvmsg(struct socket *so, 1247163953Srrs struct uio *uio, 1248163953Srrs struct mbuf **mp, 1249163953Srrs struct sockaddr *from, 1250163953Srrs int fromlen, 1251163953Srrs int *msg_flags, 1252163953Srrs struct sctp_sndrcvinfo *sinfo, 1253163953Srrs int filling_sinfo); 1254163953Srrs 1255163953Srrs#endif 1256163953Srrs 1257163953Srrs/* 1258163953Srrs * API system calls 1259163953Srrs */ 1260180387Srrs#if !(defined(_KERNEL)) && !(defined(__Userspace__)) 1261163953Srrs 1262163953Srrs__BEGIN_DECLS 1263163953Srrsint sctp_peeloff __P((int, sctp_assoc_t)); 1264163953Srrsint sctp_bindx __P((int, struct sockaddr *, int, int)); 1265167598Srrsint sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *)); 1266163953Srrsint sctp_getaddrlen __P((sa_family_t)); 1267163953Srrsint sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **)); 1268163953Srrsvoid sctp_freepaddrs __P((struct sockaddr *)); 1269163953Srrsint sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **)); 1270163953Srrsvoid sctp_freeladdrs __P((struct sockaddr *)); 1271163953Srrsint sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *)); 1272163953Srrs 1273223132Stuexen/* deprecated */ 1274169352Srrsssize_t sctp_sendmsg 1275223132Stuexen__P((int, const void *, size_t, const struct sockaddr *, 1276163953Srrs socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t)); 1277163953Srrs 1278223132Stuexen/* deprecated */ 1279223132Stuexen ssize_t sctp_send __P((int, const void *, size_t, 1280223132Stuexen const struct sctp_sndrcvinfo *, int)); 1281163953Srrs 1282223132Stuexen/* deprecated */ 1283223132Stuexen ssize_t sctp_sendx __P((int, const void *, size_t, struct sockaddr *, 1284223132Stuexen int, struct sctp_sndrcvinfo *, int)); 1285169352Srrs 1286223132Stuexen/* deprecated */ 1287223132Stuexen ssize_t sctp_sendmsgx __P((int sd, const void *, size_t, struct sockaddr *, 1288223132Stuexen int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t)); 1289163953Srrs 1290223132Stuexen sctp_assoc_t sctp_getassocid __P((int, struct sockaddr *)); 1291163953Srrs 1292223132Stuexen/* deprecated */ 1293223132Stuexen ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *, socklen_t *, 1294223132Stuexen struct sctp_sndrcvinfo *, int *)); 1295163953Srrs 1296223132Stuexen ssize_t sctp_sendv __P((int, const struct iovec *, int, struct sockaddr *, 1297223132Stuexen int, void *, socklen_t, unsigned int, int)); 1298223132Stuexen 1299223132Stuexen ssize_t sctp_recvv __P((int, const struct iovec *, int, struct sockaddr *, 1300223132Stuexen socklen_t *, void *, socklen_t *, unsigned int *, int *)); 1301223132Stuexen 1302163953Srrs__END_DECLS 1303163953Srrs 1304163953Srrs#endif /* !_KERNEL */ 1305163953Srrs#endif /* !__sctp_uio_h__ */ 1306