sctp.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* SCTP kernel reference Implementation
  3. * (C) Copyright IBM Corp. 2001, 2004
  4. * Copyright (c) 1999-2000 Cisco, Inc.
  5. * Copyright (c) 1999-2001 Motorola, Inc.
  6. * Copyright (c) 2001 Intel Corp.
  7. * Copyright (c) 2001 Nokia, Inc.
  8. * Copyright (c) 2001 La Monte H.P. Yarroll
  9. *
  10. * This file is part of the SCTP kernel reference Implementation
  11. *
  12. * Various protocol defined structures.
  13. *
  14. * Please send any bug reports or fixes you make to the
  15. * email address(es):
  16. * lksctp developers <[email protected]>
  17. *
  18. * Or submit a bug report through the following website:
  19. * http://www.sf.net/projects/lksctp
  20. *
  21. * Written or modified by:
  22. * La Monte H.P. Yarroll <[email protected]>
  23. * Karl Knutson <[email protected]>
  24. * Jon Grimm <[email protected]>
  25. * Xingang Guo <[email protected]>
  26. * [email protected]
  27. * [email protected]
  28. * [email protected]
  29. * Sridhar Samudrala <[email protected]>
  30. * Kevin Gao <[email protected]>
  31. *
  32. * Any bugs reported given to us we will try to fix... any fixes shared will
  33. * be incorporated into the next SCTP release.
  34. */
  35. #ifndef __LINUX_SCTP_H__
  36. #define __LINUX_SCTP_H__
  37. #include <linux/in.h> /* We need in_addr. */
  38. #include <linux/in6.h> /* We need in6_addr. */
  39. #include <linux/skbuff.h>
  40. #include <uapi/linux/sctp.h>
  41. /* Section 3.1. SCTP Common Header Format */
  42. struct sctphdr {
  43. __be16 source;
  44. __be16 dest;
  45. __be32 vtag;
  46. __le32 checksum;
  47. };
  48. static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
  49. {
  50. return (struct sctphdr *)skb_transport_header(skb);
  51. }
  52. /* Section 3.2. Chunk Field Descriptions. */
  53. struct sctp_chunkhdr {
  54. __u8 type;
  55. __u8 flags;
  56. __be16 length;
  57. };
  58. /* Section 3.2. Chunk Type Values.
  59. * [Chunk Type] identifies the type of information contained in the Chunk
  60. * Value field. It takes a value from 0 to 254. The value of 255 is
  61. * reserved for future use as an extension field.
  62. */
  63. enum sctp_cid {
  64. SCTP_CID_DATA = 0,
  65. SCTP_CID_INIT = 1,
  66. SCTP_CID_INIT_ACK = 2,
  67. SCTP_CID_SACK = 3,
  68. SCTP_CID_HEARTBEAT = 4,
  69. SCTP_CID_HEARTBEAT_ACK = 5,
  70. SCTP_CID_ABORT = 6,
  71. SCTP_CID_SHUTDOWN = 7,
  72. SCTP_CID_SHUTDOWN_ACK = 8,
  73. SCTP_CID_ERROR = 9,
  74. SCTP_CID_COOKIE_ECHO = 10,
  75. SCTP_CID_COOKIE_ACK = 11,
  76. SCTP_CID_ECN_ECNE = 12,
  77. SCTP_CID_ECN_CWR = 13,
  78. SCTP_CID_SHUTDOWN_COMPLETE = 14,
  79. /* AUTH Extension Section 4.1 */
  80. SCTP_CID_AUTH = 0x0F,
  81. /* sctp ndata 5.1. I-DATA */
  82. SCTP_CID_I_DATA = 0x40,
  83. /* PR-SCTP Sec 3.2 */
  84. SCTP_CID_FWD_TSN = 0xC0,
  85. /* Use hex, as defined in ADDIP sec. 3.1 */
  86. SCTP_CID_ASCONF = 0xC1,
  87. SCTP_CID_I_FWD_TSN = 0xC2,
  88. SCTP_CID_ASCONF_ACK = 0x80,
  89. SCTP_CID_RECONF = 0x82,
  90. SCTP_CID_PAD = 0x84,
  91. }; /* enum */
  92. /* Section 3.2
  93. * Chunk Types are encoded such that the highest-order two bits specify
  94. * the action that must be taken if the processing endpoint does not
  95. * recognize the Chunk Type.
  96. */
  97. enum {
  98. SCTP_CID_ACTION_DISCARD = 0x00,
  99. SCTP_CID_ACTION_DISCARD_ERR = 0x40,
  100. SCTP_CID_ACTION_SKIP = 0x80,
  101. SCTP_CID_ACTION_SKIP_ERR = 0xc0,
  102. };
  103. enum { SCTP_CID_ACTION_MASK = 0xc0, };
  104. /* This flag is used in Chunk Flags for ABORT and SHUTDOWN COMPLETE.
  105. *
  106. * 3.3.7 Abort Association (ABORT) (6):
  107. * The T bit is set to 0 if the sender had a TCB that it destroyed.
  108. * If the sender did not have a TCB it should set this bit to 1.
  109. */
  110. enum { SCTP_CHUNK_FLAG_T = 0x01 };
  111. /*
  112. * Set the T bit
  113. *
  114. * 0 1 2 3
  115. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  116. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  117. * | Type = 14 |Reserved |T| Length = 4 |
  118. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  119. *
  120. * Chunk Flags: 8 bits
  121. *
  122. * Reserved: 7 bits
  123. * Set to 0 on transmit and ignored on receipt.
  124. *
  125. * T bit: 1 bit
  126. * The T bit is set to 0 if the sender had a TCB that it destroyed. If
  127. * the sender did NOT have a TCB it should set this bit to 1.
  128. *
  129. * Note: Special rules apply to this chunk for verification, please
  130. * see Section 8.5.1 for details.
  131. */
  132. #define sctp_test_T_bit(c) ((c)->chunk_hdr->flags & SCTP_CHUNK_FLAG_T)
  133. /* RFC 2960
  134. * Section 3.2.1 Optional/Variable-length Parmaeter Format.
  135. */
  136. struct sctp_paramhdr {
  137. __be16 type;
  138. __be16 length;
  139. };
  140. enum sctp_param {
  141. /* RFC 2960 Section 3.3.5 */
  142. SCTP_PARAM_HEARTBEAT_INFO = cpu_to_be16(1),
  143. /* RFC 2960 Section 3.3.2.1 */
  144. SCTP_PARAM_IPV4_ADDRESS = cpu_to_be16(5),
  145. SCTP_PARAM_IPV6_ADDRESS = cpu_to_be16(6),
  146. SCTP_PARAM_STATE_COOKIE = cpu_to_be16(7),
  147. SCTP_PARAM_UNRECOGNIZED_PARAMETERS = cpu_to_be16(8),
  148. SCTP_PARAM_COOKIE_PRESERVATIVE = cpu_to_be16(9),
  149. SCTP_PARAM_HOST_NAME_ADDRESS = cpu_to_be16(11),
  150. SCTP_PARAM_SUPPORTED_ADDRESS_TYPES = cpu_to_be16(12),
  151. SCTP_PARAM_ECN_CAPABLE = cpu_to_be16(0x8000),
  152. /* AUTH Extension Section 3 */
  153. SCTP_PARAM_RANDOM = cpu_to_be16(0x8002),
  154. SCTP_PARAM_CHUNKS = cpu_to_be16(0x8003),
  155. SCTP_PARAM_HMAC_ALGO = cpu_to_be16(0x8004),
  156. /* Add-IP: Supported Extensions, Section 4.2 */
  157. SCTP_PARAM_SUPPORTED_EXT = cpu_to_be16(0x8008),
  158. /* PR-SCTP Sec 3.1 */
  159. SCTP_PARAM_FWD_TSN_SUPPORT = cpu_to_be16(0xc000),
  160. /* Add-IP Extension. Section 3.2 */
  161. SCTP_PARAM_ADD_IP = cpu_to_be16(0xc001),
  162. SCTP_PARAM_DEL_IP = cpu_to_be16(0xc002),
  163. SCTP_PARAM_ERR_CAUSE = cpu_to_be16(0xc003),
  164. SCTP_PARAM_SET_PRIMARY = cpu_to_be16(0xc004),
  165. SCTP_PARAM_SUCCESS_REPORT = cpu_to_be16(0xc005),
  166. SCTP_PARAM_ADAPTATION_LAYER_IND = cpu_to_be16(0xc006),
  167. /* RE-CONFIG. Section 4 */
  168. SCTP_PARAM_RESET_OUT_REQUEST = cpu_to_be16(0x000d),
  169. SCTP_PARAM_RESET_IN_REQUEST = cpu_to_be16(0x000e),
  170. SCTP_PARAM_RESET_TSN_REQUEST = cpu_to_be16(0x000f),
  171. SCTP_PARAM_RESET_RESPONSE = cpu_to_be16(0x0010),
  172. SCTP_PARAM_RESET_ADD_OUT_STREAMS = cpu_to_be16(0x0011),
  173. SCTP_PARAM_RESET_ADD_IN_STREAMS = cpu_to_be16(0x0012),
  174. }; /* enum */
  175. /* RFC 2960 Section 3.2.1
  176. * The Parameter Types are encoded such that the highest-order two bits
  177. * specify the action that must be taken if the processing endpoint does
  178. * not recognize the Parameter Type.
  179. *
  180. */
  181. enum {
  182. SCTP_PARAM_ACTION_DISCARD = cpu_to_be16(0x0000),
  183. SCTP_PARAM_ACTION_DISCARD_ERR = cpu_to_be16(0x4000),
  184. SCTP_PARAM_ACTION_SKIP = cpu_to_be16(0x8000),
  185. SCTP_PARAM_ACTION_SKIP_ERR = cpu_to_be16(0xc000),
  186. };
  187. enum { SCTP_PARAM_ACTION_MASK = cpu_to_be16(0xc000), };
  188. /* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */
  189. struct sctp_datahdr {
  190. __be32 tsn;
  191. __be16 stream;
  192. __be16 ssn;
  193. __u32 ppid;
  194. __u8 payload[];
  195. };
  196. struct sctp_data_chunk {
  197. struct sctp_chunkhdr chunk_hdr;
  198. struct sctp_datahdr data_hdr;
  199. };
  200. struct sctp_idatahdr {
  201. __be32 tsn;
  202. __be16 stream;
  203. __be16 reserved;
  204. __be32 mid;
  205. union {
  206. __u32 ppid;
  207. __be32 fsn;
  208. };
  209. __u8 payload[0];
  210. };
  211. struct sctp_idata_chunk {
  212. struct sctp_chunkhdr chunk_hdr;
  213. struct sctp_idatahdr data_hdr;
  214. };
  215. /* DATA Chuck Specific Flags */
  216. enum {
  217. SCTP_DATA_MIDDLE_FRAG = 0x00,
  218. SCTP_DATA_LAST_FRAG = 0x01,
  219. SCTP_DATA_FIRST_FRAG = 0x02,
  220. SCTP_DATA_NOT_FRAG = 0x03,
  221. SCTP_DATA_UNORDERED = 0x04,
  222. SCTP_DATA_SACK_IMM = 0x08,
  223. };
  224. enum { SCTP_DATA_FRAG_MASK = 0x03, };
  225. /* RFC 2960 Section 3.3.2 Initiation (INIT) (1)
  226. *
  227. * This chunk is used to initiate a SCTP association between two
  228. * endpoints.
  229. */
  230. struct sctp_inithdr {
  231. __be32 init_tag;
  232. __be32 a_rwnd;
  233. __be16 num_outbound_streams;
  234. __be16 num_inbound_streams;
  235. __be32 initial_tsn;
  236. __u8 params[];
  237. };
  238. struct sctp_init_chunk {
  239. struct sctp_chunkhdr chunk_hdr;
  240. struct sctp_inithdr init_hdr;
  241. };
  242. /* Section 3.3.2.1. IPv4 Address Parameter (5) */
  243. struct sctp_ipv4addr_param {
  244. struct sctp_paramhdr param_hdr;
  245. struct in_addr addr;
  246. };
  247. /* Section 3.3.2.1. IPv6 Address Parameter (6) */
  248. struct sctp_ipv6addr_param {
  249. struct sctp_paramhdr param_hdr;
  250. struct in6_addr addr;
  251. };
  252. /* Section 3.3.2.1 Cookie Preservative (9) */
  253. struct sctp_cookie_preserve_param {
  254. struct sctp_paramhdr param_hdr;
  255. __be32 lifespan_increment;
  256. };
  257. /* Section 3.3.2.1 Host Name Address (11) */
  258. struct sctp_hostname_param {
  259. struct sctp_paramhdr param_hdr;
  260. uint8_t hostname[];
  261. };
  262. /* Section 3.3.2.1 Supported Address Types (12) */
  263. struct sctp_supported_addrs_param {
  264. struct sctp_paramhdr param_hdr;
  265. __be16 types[];
  266. };
  267. /* ADDIP Section 3.2.6 Adaptation Layer Indication */
  268. struct sctp_adaptation_ind_param {
  269. struct sctp_paramhdr param_hdr;
  270. __be32 adaptation_ind;
  271. };
  272. /* ADDIP Section 4.2.7 Supported Extensions Parameter */
  273. struct sctp_supported_ext_param {
  274. struct sctp_paramhdr param_hdr;
  275. __u8 chunks[];
  276. };
  277. /* AUTH Section 3.1 Random */
  278. struct sctp_random_param {
  279. struct sctp_paramhdr param_hdr;
  280. __u8 random_val[];
  281. };
  282. /* AUTH Section 3.2 Chunk List */
  283. struct sctp_chunks_param {
  284. struct sctp_paramhdr param_hdr;
  285. __u8 chunks[];
  286. };
  287. /* AUTH Section 3.3 HMAC Algorithm */
  288. struct sctp_hmac_algo_param {
  289. struct sctp_paramhdr param_hdr;
  290. __be16 hmac_ids[];
  291. };
  292. /* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
  293. * The INIT ACK chunk is used to acknowledge the initiation of an SCTP
  294. * association.
  295. */
  296. struct sctp_initack_chunk {
  297. struct sctp_chunkhdr chunk_hdr;
  298. struct sctp_inithdr init_hdr;
  299. };
  300. /* Section 3.3.3.1 State Cookie (7) */
  301. struct sctp_cookie_param {
  302. struct sctp_paramhdr p;
  303. __u8 body[];
  304. };
  305. /* Section 3.3.3.1 Unrecognized Parameters (8) */
  306. struct sctp_unrecognized_param {
  307. struct sctp_paramhdr param_hdr;
  308. struct sctp_paramhdr unrecognized;
  309. };
  310. /*
  311. * 3.3.4 Selective Acknowledgement (SACK) (3):
  312. *
  313. * This chunk is sent to the peer endpoint to acknowledge received DATA
  314. * chunks and to inform the peer endpoint of gaps in the received
  315. * subsequences of DATA chunks as represented by their TSNs.
  316. */
  317. struct sctp_gap_ack_block {
  318. __be16 start;
  319. __be16 end;
  320. };
  321. union sctp_sack_variable {
  322. struct sctp_gap_ack_block gab;
  323. __be32 dup;
  324. };
  325. struct sctp_sackhdr {
  326. __be32 cum_tsn_ack;
  327. __be32 a_rwnd;
  328. __be16 num_gap_ack_blocks;
  329. __be16 num_dup_tsns;
  330. union sctp_sack_variable variable[];
  331. };
  332. struct sctp_sack_chunk {
  333. struct sctp_chunkhdr chunk_hdr;
  334. struct sctp_sackhdr sack_hdr;
  335. };
  336. /* RFC 2960. Section 3.3.5 Heartbeat Request (HEARTBEAT) (4):
  337. *
  338. * An endpoint should send this chunk to its peer endpoint to probe the
  339. * reachability of a particular destination transport address defined in
  340. * the present association.
  341. */
  342. struct sctp_heartbeathdr {
  343. struct sctp_paramhdr info;
  344. };
  345. struct sctp_heartbeat_chunk {
  346. struct sctp_chunkhdr chunk_hdr;
  347. struct sctp_heartbeathdr hb_hdr;
  348. };
  349. /* PAD chunk could be bundled with heartbeat chunk to probe pmtu */
  350. struct sctp_pad_chunk {
  351. struct sctp_chunkhdr uh;
  352. };
  353. /* For the abort and shutdown ACK we must carry the init tag in the
  354. * common header. Just the common header is all that is needed with a
  355. * chunk descriptor.
  356. */
  357. struct sctp_abort_chunk {
  358. struct sctp_chunkhdr uh;
  359. };
  360. /* For the graceful shutdown we must carry the tag (in common header)
  361. * and the highest consecutive acking value.
  362. */
  363. struct sctp_shutdownhdr {
  364. __be32 cum_tsn_ack;
  365. };
  366. struct sctp_shutdown_chunk {
  367. struct sctp_chunkhdr chunk_hdr;
  368. struct sctp_shutdownhdr shutdown_hdr;
  369. };
  370. /* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
  371. struct sctp_errhdr {
  372. __be16 cause;
  373. __be16 length;
  374. __u8 variable[];
  375. };
  376. struct sctp_operr_chunk {
  377. struct sctp_chunkhdr chunk_hdr;
  378. struct sctp_errhdr err_hdr;
  379. };
  380. /* RFC 2960 3.3.10 - Operation Error
  381. *
  382. * Cause Code: 16 bits (unsigned integer)
  383. *
  384. * Defines the type of error conditions being reported.
  385. * Cause Code
  386. * Value Cause Code
  387. * --------- ----------------
  388. * 1 Invalid Stream Identifier
  389. * 2 Missing Mandatory Parameter
  390. * 3 Stale Cookie Error
  391. * 4 Out of Resource
  392. * 5 Unresolvable Address
  393. * 6 Unrecognized Chunk Type
  394. * 7 Invalid Mandatory Parameter
  395. * 8 Unrecognized Parameters
  396. * 9 No User Data
  397. * 10 Cookie Received While Shutting Down
  398. */
  399. enum sctp_error {
  400. SCTP_ERROR_NO_ERROR = cpu_to_be16(0x00),
  401. SCTP_ERROR_INV_STRM = cpu_to_be16(0x01),
  402. SCTP_ERROR_MISS_PARAM = cpu_to_be16(0x02),
  403. SCTP_ERROR_STALE_COOKIE = cpu_to_be16(0x03),
  404. SCTP_ERROR_NO_RESOURCE = cpu_to_be16(0x04),
  405. SCTP_ERROR_DNS_FAILED = cpu_to_be16(0x05),
  406. SCTP_ERROR_UNKNOWN_CHUNK = cpu_to_be16(0x06),
  407. SCTP_ERROR_INV_PARAM = cpu_to_be16(0x07),
  408. SCTP_ERROR_UNKNOWN_PARAM = cpu_to_be16(0x08),
  409. SCTP_ERROR_NO_DATA = cpu_to_be16(0x09),
  410. SCTP_ERROR_COOKIE_IN_SHUTDOWN = cpu_to_be16(0x0a),
  411. /* SCTP Implementation Guide:
  412. * 11 Restart of an association with new addresses
  413. * 12 User Initiated Abort
  414. * 13 Protocol Violation
  415. * 14 Restart of an Association with New Encapsulation Port
  416. */
  417. SCTP_ERROR_RESTART = cpu_to_be16(0x0b),
  418. SCTP_ERROR_USER_ABORT = cpu_to_be16(0x0c),
  419. SCTP_ERROR_PROTO_VIOLATION = cpu_to_be16(0x0d),
  420. SCTP_ERROR_NEW_ENCAP_PORT = cpu_to_be16(0x0e),
  421. /* ADDIP Section 3.3 New Error Causes
  422. *
  423. * Four new Error Causes are added to the SCTP Operational Errors,
  424. * primarily for use in the ASCONF-ACK chunk.
  425. *
  426. * Value Cause Code
  427. * --------- ----------------
  428. * 0x00A0 Request to Delete Last Remaining IP Address.
  429. * 0x00A1 Operation Refused Due to Resource Shortage.
  430. * 0x00A2 Request to Delete Source IP Address.
  431. * 0x00A3 Association Aborted due to illegal ASCONF-ACK
  432. * 0x00A4 Request refused - no authorization.
  433. */
  434. SCTP_ERROR_DEL_LAST_IP = cpu_to_be16(0x00A0),
  435. SCTP_ERROR_RSRC_LOW = cpu_to_be16(0x00A1),
  436. SCTP_ERROR_DEL_SRC_IP = cpu_to_be16(0x00A2),
  437. SCTP_ERROR_ASCONF_ACK = cpu_to_be16(0x00A3),
  438. SCTP_ERROR_REQ_REFUSED = cpu_to_be16(0x00A4),
  439. /* AUTH Section 4. New Error Cause
  440. *
  441. * This section defines a new error cause that will be sent if an AUTH
  442. * chunk is received with an unsupported HMAC identifier.
  443. * illustrates the new error cause.
  444. *
  445. * Cause Code Error Cause Name
  446. * --------------------------------------------------------------
  447. * 0x0105 Unsupported HMAC Identifier
  448. */
  449. SCTP_ERROR_UNSUP_HMAC = cpu_to_be16(0x0105)
  450. };
  451. /* RFC 2960. Appendix A. Explicit Congestion Notification.
  452. * Explicit Congestion Notification Echo (ECNE) (12)
  453. */
  454. struct sctp_ecnehdr {
  455. __be32 lowest_tsn;
  456. };
  457. struct sctp_ecne_chunk {
  458. struct sctp_chunkhdr chunk_hdr;
  459. struct sctp_ecnehdr ence_hdr;
  460. };
  461. /* RFC 2960. Appendix A. Explicit Congestion Notification.
  462. * Congestion Window Reduced (CWR) (13)
  463. */
  464. struct sctp_cwrhdr {
  465. __be32 lowest_tsn;
  466. };
  467. /* PR-SCTP
  468. * 3.2 Forward Cumulative TSN Chunk Definition (FORWARD TSN)
  469. *
  470. * Forward Cumulative TSN chunk has the following format:
  471. *
  472. * 0 1 2 3
  473. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  474. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  475. * | Type = 192 | Flags = 0x00 | Length = Variable |
  476. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  477. * | New Cumulative TSN |
  478. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  479. * | Stream-1 | Stream Sequence-1 |
  480. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  481. * \ /
  482. * / \
  483. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  484. * | Stream-N | Stream Sequence-N |
  485. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  486. *
  487. * Chunk Flags:
  488. *
  489. * Set to all zeros on transmit and ignored on receipt.
  490. *
  491. * New Cumulative TSN: 32 bit u_int
  492. *
  493. * This indicates the new cumulative TSN to the data receiver. Upon
  494. * the reception of this value, the data receiver MUST consider
  495. * any missing TSNs earlier than or equal to this value as received
  496. * and stop reporting them as gaps in any subsequent SACKs.
  497. *
  498. * Stream-N: 16 bit u_int
  499. *
  500. * This field holds a stream number that was skipped by this
  501. * FWD-TSN.
  502. *
  503. * Stream Sequence-N: 16 bit u_int
  504. * This field holds the sequence number associated with the stream
  505. * that was skipped. The stream sequence field holds the largest stream
  506. * sequence number in this stream being skipped. The receiver of
  507. * the FWD-TSN's can use the Stream-N and Stream Sequence-N fields
  508. * to enable delivery of any stranded TSN's that remain on the stream
  509. * re-ordering queues. This field MUST NOT report TSN's corresponding
  510. * to DATA chunk that are marked as unordered. For ordered DATA
  511. * chunks this field MUST be filled in.
  512. */
  513. struct sctp_fwdtsn_skip {
  514. __be16 stream;
  515. __be16 ssn;
  516. };
  517. struct sctp_fwdtsn_hdr {
  518. __be32 new_cum_tsn;
  519. struct sctp_fwdtsn_skip skip[];
  520. };
  521. struct sctp_fwdtsn_chunk {
  522. struct sctp_chunkhdr chunk_hdr;
  523. struct sctp_fwdtsn_hdr fwdtsn_hdr;
  524. };
  525. struct sctp_ifwdtsn_skip {
  526. __be16 stream;
  527. __u8 reserved;
  528. __u8 flags;
  529. __be32 mid;
  530. };
  531. struct sctp_ifwdtsn_hdr {
  532. __be32 new_cum_tsn;
  533. struct sctp_ifwdtsn_skip skip[];
  534. };
  535. struct sctp_ifwdtsn_chunk {
  536. struct sctp_chunkhdr chunk_hdr;
  537. struct sctp_ifwdtsn_hdr fwdtsn_hdr;
  538. };
  539. /* ADDIP
  540. * Section 3.1.1 Address Configuration Change Chunk (ASCONF)
  541. *
  542. * Serial Number: 32 bits (unsigned integer)
  543. * This value represents a Serial Number for the ASCONF Chunk. The
  544. * valid range of Serial Number is from 0 to 2^32-1.
  545. * Serial Numbers wrap back to 0 after reaching 2^32 -1.
  546. *
  547. * Address Parameter: 8 or 20 bytes (depending on type)
  548. * The address is an address of the sender of the ASCONF chunk,
  549. * the address MUST be considered part of the association by the
  550. * peer endpoint. This field may be used by the receiver of the
  551. * ASCONF to help in finding the association. This parameter MUST
  552. * be present in every ASCONF message i.e. it is a mandatory TLV
  553. * parameter.
  554. *
  555. * ASCONF Parameter: TLV format
  556. * Each Address configuration change is represented by a TLV
  557. * parameter as defined in Section 3.2. One or more requests may
  558. * be present in an ASCONF Chunk.
  559. *
  560. * Section 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
  561. *
  562. * Serial Number: 32 bits (unsigned integer)
  563. * This value represents the Serial Number for the received ASCONF
  564. * Chunk that is acknowledged by this chunk. This value is copied
  565. * from the received ASCONF Chunk.
  566. *
  567. * ASCONF Parameter Response: TLV format
  568. * The ASCONF Parameter Response is used in the ASCONF-ACK to
  569. * report status of ASCONF processing.
  570. */
  571. struct sctp_addip_param {
  572. struct sctp_paramhdr param_hdr;
  573. __be32 crr_id;
  574. };
  575. struct sctp_addiphdr {
  576. __be32 serial;
  577. __u8 params[];
  578. };
  579. struct sctp_addip_chunk {
  580. struct sctp_chunkhdr chunk_hdr;
  581. struct sctp_addiphdr addip_hdr;
  582. };
  583. /* AUTH
  584. * Section 4.1 Authentication Chunk (AUTH)
  585. *
  586. * This chunk is used to hold the result of the HMAC calculation.
  587. *
  588. * 0 1 2 3
  589. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  590. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  591. * | Type = 0x0F | Flags=0 | Length |
  592. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  593. * | Shared Key Identifier | HMAC Identifier |
  594. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  595. * | |
  596. * \ HMAC /
  597. * / \
  598. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  599. *
  600. * Type: 1 byte (unsigned integer)
  601. * This value MUST be set to 0x0F for all AUTH-chunks.
  602. *
  603. * Flags: 1 byte (unsigned integer)
  604. * Set to zero on transmit and ignored on receipt.
  605. *
  606. * Length: 2 bytes (unsigned integer)
  607. * This value holds the length of the HMAC in bytes plus 8.
  608. *
  609. * Shared Key Identifier: 2 bytes (unsigned integer)
  610. * This value describes which endpoint pair shared key is used.
  611. *
  612. * HMAC Identifier: 2 bytes (unsigned integer)
  613. * This value describes which message digest is being used. Table 2
  614. * shows the currently defined values.
  615. *
  616. * The following Table 2 shows the currently defined values for HMAC
  617. * identifiers.
  618. *
  619. * +-----------------+--------------------------+
  620. * | HMAC Identifier | Message Digest Algorithm |
  621. * +-----------------+--------------------------+
  622. * | 0 | Reserved |
  623. * | 1 | SHA-1 defined in [8] |
  624. * | 2 | Reserved |
  625. * | 3 | SHA-256 defined in [8] |
  626. * +-----------------+--------------------------+
  627. *
  628. *
  629. * HMAC: n bytes (unsigned integer) This hold the result of the HMAC
  630. * calculation.
  631. */
  632. struct sctp_authhdr {
  633. __be16 shkey_id;
  634. __be16 hmac_id;
  635. __u8 hmac[];
  636. };
  637. struct sctp_auth_chunk {
  638. struct sctp_chunkhdr chunk_hdr;
  639. struct sctp_authhdr auth_hdr;
  640. };
  641. struct sctp_infox {
  642. struct sctp_info *sctpinfo;
  643. struct sctp_association *asoc;
  644. };
  645. struct sctp_reconf_chunk {
  646. struct sctp_chunkhdr chunk_hdr;
  647. __u8 params[];
  648. };
  649. struct sctp_strreset_outreq {
  650. struct sctp_paramhdr param_hdr;
  651. __be32 request_seq;
  652. __be32 response_seq;
  653. __be32 send_reset_at_tsn;
  654. __be16 list_of_streams[];
  655. };
  656. struct sctp_strreset_inreq {
  657. struct sctp_paramhdr param_hdr;
  658. __be32 request_seq;
  659. __be16 list_of_streams[];
  660. };
  661. struct sctp_strreset_tsnreq {
  662. struct sctp_paramhdr param_hdr;
  663. __be32 request_seq;
  664. };
  665. struct sctp_strreset_addstrm {
  666. struct sctp_paramhdr param_hdr;
  667. __be32 request_seq;
  668. __be16 number_of_streams;
  669. __be16 reserved;
  670. };
  671. enum {
  672. SCTP_STRRESET_NOTHING_TO_DO = 0x00,
  673. SCTP_STRRESET_PERFORMED = 0x01,
  674. SCTP_STRRESET_DENIED = 0x02,
  675. SCTP_STRRESET_ERR_WRONG_SSN = 0x03,
  676. SCTP_STRRESET_ERR_IN_PROGRESS = 0x04,
  677. SCTP_STRRESET_ERR_BAD_SEQNO = 0x05,
  678. SCTP_STRRESET_IN_PROGRESS = 0x06,
  679. };
  680. struct sctp_strreset_resp {
  681. struct sctp_paramhdr param_hdr;
  682. __be32 response_seq;
  683. __be32 result;
  684. };
  685. struct sctp_strreset_resptsn {
  686. struct sctp_paramhdr param_hdr;
  687. __be32 response_seq;
  688. __be32 result;
  689. __be32 senders_next_tsn;
  690. __be32 receivers_next_tsn;
  691. };
  692. enum {
  693. SCTP_DSCP_SET_MASK = 0x1,
  694. SCTP_DSCP_VAL_MASK = 0xfc,
  695. SCTP_FLOWLABEL_SET_MASK = 0x100000,
  696. SCTP_FLOWLABEL_VAL_MASK = 0xfffff
  697. };
  698. /* UDP Encapsulation
  699. * draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.html#section-4-4
  700. *
  701. * The error cause indicating an "Restart of an Association with
  702. * New Encapsulation Port"
  703. *
  704. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  705. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  706. * | Cause Code = 14 | Cause Length = 8 |
  707. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  708. * | Current Encapsulation Port | New Encapsulation Port |
  709. * +-------------------------------+-------------------------------+
  710. */
  711. struct sctp_new_encap_port_hdr {
  712. __be16 cur_port;
  713. __be16 new_port;
  714. };
  715. #endif /* __LINUX_SCTP_H__ */