sctp.h 22 KB

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