sctp.h 23 KB

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