sctp.h 22 KB

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