sctp_uio.h 41 KB

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