usrsctp.h 42 KB

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