sctp_uio.h 38 KB

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