sctp.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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. __le32 checksum;
  61. } __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. } __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. } __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. } __packed sctp_datahdr_t;
  201. typedef struct sctp_data_chunk {
  202. sctp_chunkhdr_t chunk_hdr;
  203. sctp_datahdr_t data_hdr;
  204. } __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. SCTP_DATA_SACK_IMM = 0x08,
  213. };
  214. enum { SCTP_DATA_FRAG_MASK = 0x03, };
  215. /* RFC 2960 Section 3.3.2 Initiation (INIT) (1)
  216. *
  217. * This chunk is used to initiate a SCTP association between two
  218. * endpoints.
  219. */
  220. typedef struct sctp_inithdr {
  221. __be32 init_tag;
  222. __be32 a_rwnd;
  223. __be16 num_outbound_streams;
  224. __be16 num_inbound_streams;
  225. __be32 initial_tsn;
  226. __u8 params[0];
  227. } __packed sctp_inithdr_t;
  228. typedef struct sctp_init_chunk {
  229. sctp_chunkhdr_t chunk_hdr;
  230. sctp_inithdr_t init_hdr;
  231. } __packed sctp_init_chunk_t;
  232. /* Section 3.3.2.1. IPv4 Address Parameter (5) */
  233. typedef struct sctp_ipv4addr_param {
  234. sctp_paramhdr_t param_hdr;
  235. struct in_addr addr;
  236. } __packed sctp_ipv4addr_param_t;
  237. /* Section 3.3.2.1. IPv6 Address Parameter (6) */
  238. typedef struct sctp_ipv6addr_param {
  239. sctp_paramhdr_t param_hdr;
  240. struct in6_addr addr;
  241. } __packed sctp_ipv6addr_param_t;
  242. /* Section 3.3.2.1 Cookie Preservative (9) */
  243. typedef struct sctp_cookie_preserve_param {
  244. sctp_paramhdr_t param_hdr;
  245. __be32 lifespan_increment;
  246. } __packed sctp_cookie_preserve_param_t;
  247. /* Section 3.3.2.1 Host Name Address (11) */
  248. typedef struct sctp_hostname_param {
  249. sctp_paramhdr_t param_hdr;
  250. uint8_t hostname[0];
  251. } __packed sctp_hostname_param_t;
  252. /* Section 3.3.2.1 Supported Address Types (12) */
  253. typedef struct sctp_supported_addrs_param {
  254. sctp_paramhdr_t param_hdr;
  255. __be16 types[0];
  256. } __packed sctp_supported_addrs_param_t;
  257. /* Appendix A. ECN Capable (32768) */
  258. typedef struct sctp_ecn_capable_param {
  259. sctp_paramhdr_t param_hdr;
  260. } __packed sctp_ecn_capable_param_t;
  261. /* ADDIP Section 3.2.6 Adaptation Layer Indication */
  262. typedef struct sctp_adaptation_ind_param {
  263. struct sctp_paramhdr param_hdr;
  264. __be32 adaptation_ind;
  265. } __packed sctp_adaptation_ind_param_t;
  266. /* ADDIP Section 4.2.7 Supported Extensions Parameter */
  267. typedef struct sctp_supported_ext_param {
  268. struct sctp_paramhdr param_hdr;
  269. __u8 chunks[0];
  270. } __packed sctp_supported_ext_param_t;
  271. /* AUTH Section 3.1 Random */
  272. typedef struct sctp_random_param {
  273. sctp_paramhdr_t param_hdr;
  274. __u8 random_val[0];
  275. } __packed sctp_random_param_t;
  276. /* AUTH Section 3.2 Chunk List */
  277. typedef struct sctp_chunks_param {
  278. sctp_paramhdr_t param_hdr;
  279. __u8 chunks[0];
  280. } __packed sctp_chunks_param_t;
  281. /* AUTH Section 3.3 HMAC Algorithm */
  282. typedef struct sctp_hmac_algo_param {
  283. sctp_paramhdr_t param_hdr;
  284. __be16 hmac_ids[0];
  285. } __packed sctp_hmac_algo_param_t;
  286. /* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
  287. * The INIT ACK chunk is used to acknowledge the initiation of an SCTP
  288. * association.
  289. */
  290. typedef sctp_init_chunk_t sctp_initack_chunk_t;
  291. /* Section 3.3.3.1 State Cookie (7) */
  292. typedef struct sctp_cookie_param {
  293. sctp_paramhdr_t p;
  294. __u8 body[0];
  295. } __packed sctp_cookie_param_t;
  296. /* Section 3.3.3.1 Unrecognized Parameters (8) */
  297. typedef struct sctp_unrecognized_param {
  298. sctp_paramhdr_t param_hdr;
  299. sctp_paramhdr_t unrecognized;
  300. } __packed sctp_unrecognized_param_t;
  301. /*
  302. * 3.3.4 Selective Acknowledgement (SACK) (3):
  303. *
  304. * This chunk is sent to the peer endpoint to acknowledge received DATA
  305. * chunks and to inform the peer endpoint of gaps in the received
  306. * subsequences of DATA chunks as represented by their TSNs.
  307. */
  308. typedef struct sctp_gap_ack_block {
  309. __be16 start;
  310. __be16 end;
  311. } __packed sctp_gap_ack_block_t;
  312. typedef __be32 sctp_dup_tsn_t;
  313. typedef union {
  314. sctp_gap_ack_block_t gab;
  315. sctp_dup_tsn_t dup;
  316. } sctp_sack_variable_t;
  317. typedef struct sctp_sackhdr {
  318. __be32 cum_tsn_ack;
  319. __be32 a_rwnd;
  320. __be16 num_gap_ack_blocks;
  321. __be16 num_dup_tsns;
  322. sctp_sack_variable_t variable[0];
  323. } __packed sctp_sackhdr_t;
  324. typedef struct sctp_sack_chunk {
  325. sctp_chunkhdr_t chunk_hdr;
  326. sctp_sackhdr_t sack_hdr;
  327. } __packed sctp_sack_chunk_t;
  328. /* RFC 2960. Section 3.3.5 Heartbeat Request (HEARTBEAT) (4):
  329. *
  330. * An endpoint should send this chunk to its peer endpoint to probe the
  331. * reachability of a particular destination transport address defined in
  332. * the present association.
  333. */
  334. typedef struct sctp_heartbeathdr {
  335. sctp_paramhdr_t info;
  336. } __packed sctp_heartbeathdr_t;
  337. typedef struct sctp_heartbeat_chunk {
  338. sctp_chunkhdr_t chunk_hdr;
  339. sctp_heartbeathdr_t hb_hdr;
  340. } __packed sctp_heartbeat_chunk_t;
  341. /* For the abort and shutdown ACK we must carry the init tag in the
  342. * common header. Just the common header is all that is needed with a
  343. * chunk descriptor.
  344. */
  345. typedef struct sctp_abort_chunk {
  346. sctp_chunkhdr_t uh;
  347. } __packed sctp_abort_chunk_t;
  348. /* For the graceful shutdown we must carry the tag (in common header)
  349. * and the highest consecutive acking value.
  350. */
  351. typedef struct sctp_shutdownhdr {
  352. __be32 cum_tsn_ack;
  353. } __packed sctp_shutdownhdr_t;
  354. struct sctp_shutdown_chunk_t {
  355. sctp_chunkhdr_t chunk_hdr;
  356. sctp_shutdownhdr_t shutdown_hdr;
  357. } __packed;
  358. /* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
  359. typedef struct sctp_errhdr {
  360. __be16 cause;
  361. __be16 length;
  362. __u8 variable[0];
  363. } __packed sctp_errhdr_t;
  364. typedef struct sctp_operr_chunk {
  365. sctp_chunkhdr_t chunk_hdr;
  366. sctp_errhdr_t err_hdr;
  367. } __packed sctp_operr_chunk_t;
  368. /* RFC 2960 3.3.10 - Operation Error
  369. *
  370. * Cause Code: 16 bits (unsigned integer)
  371. *
  372. * Defines the type of error conditions being reported.
  373. * Cause Code
  374. * Value Cause Code
  375. * --------- ----------------
  376. * 1 Invalid Stream Identifier
  377. * 2 Missing Mandatory Parameter
  378. * 3 Stale Cookie Error
  379. * 4 Out of Resource
  380. * 5 Unresolvable Address
  381. * 6 Unrecognized Chunk Type
  382. * 7 Invalid Mandatory Parameter
  383. * 8 Unrecognized Parameters
  384. * 9 No User Data
  385. * 10 Cookie Received While Shutting Down
  386. */
  387. typedef enum {
  388. SCTP_ERROR_NO_ERROR = cpu_to_be16(0x00),
  389. SCTP_ERROR_INV_STRM = cpu_to_be16(0x01),
  390. SCTP_ERROR_MISS_PARAM = cpu_to_be16(0x02),
  391. SCTP_ERROR_STALE_COOKIE = cpu_to_be16(0x03),
  392. SCTP_ERROR_NO_RESOURCE = cpu_to_be16(0x04),
  393. SCTP_ERROR_DNS_FAILED = cpu_to_be16(0x05),
  394. SCTP_ERROR_UNKNOWN_CHUNK = cpu_to_be16(0x06),
  395. SCTP_ERROR_INV_PARAM = cpu_to_be16(0x07),
  396. SCTP_ERROR_UNKNOWN_PARAM = cpu_to_be16(0x08),
  397. SCTP_ERROR_NO_DATA = cpu_to_be16(0x09),
  398. SCTP_ERROR_COOKIE_IN_SHUTDOWN = cpu_to_be16(0x0a),
  399. /* SCTP Implementation Guide:
  400. * 11 Restart of an association with new addresses
  401. * 12 User Initiated Abort
  402. * 13 Protocol Violation
  403. */
  404. SCTP_ERROR_RESTART = cpu_to_be16(0x0b),
  405. SCTP_ERROR_USER_ABORT = cpu_to_be16(0x0c),
  406. SCTP_ERROR_PROTO_VIOLATION = cpu_to_be16(0x0d),
  407. /* ADDIP Section 3.3 New Error Causes
  408. *
  409. * Four new Error Causes are added to the SCTP Operational Errors,
  410. * primarily for use in the ASCONF-ACK chunk.
  411. *
  412. * Value Cause Code
  413. * --------- ----------------
  414. * 0x00A0 Request to Delete Last Remaining IP Address.
  415. * 0x00A1 Operation Refused Due to Resource Shortage.
  416. * 0x00A2 Request to Delete Source IP Address.
  417. * 0x00A3 Association Aborted due to illegal ASCONF-ACK
  418. * 0x00A4 Request refused - no authorization.
  419. */
  420. SCTP_ERROR_DEL_LAST_IP = cpu_to_be16(0x00A0),
  421. SCTP_ERROR_RSRC_LOW = cpu_to_be16(0x00A1),
  422. SCTP_ERROR_DEL_SRC_IP = cpu_to_be16(0x00A2),
  423. SCTP_ERROR_ASCONF_ACK = cpu_to_be16(0x00A3),
  424. SCTP_ERROR_REQ_REFUSED = cpu_to_be16(0x00A4),
  425. /* AUTH Section 4. New Error Cause
  426. *
  427. * This section defines a new error cause that will be sent if an AUTH
  428. * chunk is received with an unsupported HMAC identifier.
  429. * illustrates the new error cause.
  430. *
  431. * Cause Code Error Cause Name
  432. * --------------------------------------------------------------
  433. * 0x0105 Unsupported HMAC Identifier
  434. */
  435. SCTP_ERROR_UNSUP_HMAC = cpu_to_be16(0x0105)
  436. } sctp_error_t;
  437. /* RFC 2960. Appendix A. Explicit Congestion Notification.
  438. * Explicit Congestion Notification Echo (ECNE) (12)
  439. */
  440. typedef struct sctp_ecnehdr {
  441. __be32 lowest_tsn;
  442. } sctp_ecnehdr_t;
  443. typedef struct sctp_ecne_chunk {
  444. sctp_chunkhdr_t chunk_hdr;
  445. sctp_ecnehdr_t ence_hdr;
  446. } __packed sctp_ecne_chunk_t;
  447. /* RFC 2960. Appendix A. Explicit Congestion Notification.
  448. * Congestion Window Reduced (CWR) (13)
  449. */
  450. typedef struct sctp_cwrhdr {
  451. __be32 lowest_tsn;
  452. } sctp_cwrhdr_t;
  453. typedef struct sctp_cwr_chunk {
  454. sctp_chunkhdr_t chunk_hdr;
  455. sctp_cwrhdr_t cwr_hdr;
  456. } __packed sctp_cwr_chunk_t;
  457. /* PR-SCTP
  458. * 3.2 Forward Cumulative TSN Chunk Definition (FORWARD TSN)
  459. *
  460. * Forward Cumulative TSN chunk has the following format:
  461. *
  462. * 0 1 2 3
  463. * 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
  464. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  465. * | Type = 192 | Flags = 0x00 | Length = Variable |
  466. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  467. * | New Cumulative TSN |
  468. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  469. * | Stream-1 | Stream Sequence-1 |
  470. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  471. * \ /
  472. * / \
  473. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  474. * | Stream-N | Stream Sequence-N |
  475. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  476. *
  477. * Chunk Flags:
  478. *
  479. * Set to all zeros on transmit and ignored on receipt.
  480. *
  481. * New Cumulative TSN: 32 bit u_int
  482. *
  483. * This indicates the new cumulative TSN to the data receiver. Upon
  484. * the reception of this value, the data receiver MUST consider
  485. * any missing TSNs earlier than or equal to this value as received
  486. * and stop reporting them as gaps in any subsequent SACKs.
  487. *
  488. * Stream-N: 16 bit u_int
  489. *
  490. * This field holds a stream number that was skipped by this
  491. * FWD-TSN.
  492. *
  493. * Stream Sequence-N: 16 bit u_int
  494. * This field holds the sequence number associated with the stream
  495. * that was skipped. The stream sequence field holds the largest stream
  496. * sequence number in this stream being skipped. The receiver of
  497. * the FWD-TSN's can use the Stream-N and Stream Sequence-N fields
  498. * to enable delivery of any stranded TSN's that remain on the stream
  499. * re-ordering queues. This field MUST NOT report TSN's corresponding
  500. * to DATA chunk that are marked as unordered. For ordered DATA
  501. * chunks this field MUST be filled in.
  502. */
  503. struct sctp_fwdtsn_skip {
  504. __be16 stream;
  505. __be16 ssn;
  506. } __packed;
  507. struct sctp_fwdtsn_hdr {
  508. __be32 new_cum_tsn;
  509. struct sctp_fwdtsn_skip skip[0];
  510. } __packed;
  511. struct sctp_fwdtsn_chunk {
  512. struct sctp_chunkhdr chunk_hdr;
  513. struct sctp_fwdtsn_hdr fwdtsn_hdr;
  514. } __packed;
  515. /* ADDIP
  516. * Section 3.1.1 Address Configuration Change Chunk (ASCONF)
  517. *
  518. * Serial Number: 32 bits (unsigned integer)
  519. * This value represents a Serial Number for the ASCONF Chunk. The
  520. * valid range of Serial Number is from 0 to 2^32-1.
  521. * Serial Numbers wrap back to 0 after reaching 2^32 -1.
  522. *
  523. * Address Parameter: 8 or 20 bytes (depending on type)
  524. * The address is an address of the sender of the ASCONF chunk,
  525. * the address MUST be considered part of the association by the
  526. * peer endpoint. This field may be used by the receiver of the
  527. * ASCONF to help in finding the association. This parameter MUST
  528. * be present in every ASCONF message i.e. it is a mandatory TLV
  529. * parameter.
  530. *
  531. * ASCONF Parameter: TLV format
  532. * Each Address configuration change is represented by a TLV
  533. * parameter as defined in Section 3.2. One or more requests may
  534. * be present in an ASCONF Chunk.
  535. *
  536. * Section 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
  537. *
  538. * Serial Number: 32 bits (unsigned integer)
  539. * This value represents the Serial Number for the received ASCONF
  540. * Chunk that is acknowledged by this chunk. This value is copied
  541. * from the received ASCONF Chunk.
  542. *
  543. * ASCONF Parameter Response: TLV format
  544. * The ASCONF Parameter Response is used in the ASCONF-ACK to
  545. * report status of ASCONF processing.
  546. */
  547. typedef struct sctp_addip_param {
  548. sctp_paramhdr_t param_hdr;
  549. __be32 crr_id;
  550. } __packed sctp_addip_param_t;
  551. typedef struct sctp_addiphdr {
  552. __be32 serial;
  553. __u8 params[0];
  554. } __packed sctp_addiphdr_t;
  555. typedef struct sctp_addip_chunk {
  556. sctp_chunkhdr_t chunk_hdr;
  557. sctp_addiphdr_t addip_hdr;
  558. } __packed sctp_addip_chunk_t;
  559. /* AUTH
  560. * Section 4.1 Authentication Chunk (AUTH)
  561. *
  562. * This chunk is used to hold the result of the HMAC calculation.
  563. *
  564. * 0 1 2 3
  565. * 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
  566. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  567. * | Type = 0x0F | Flags=0 | Length |
  568. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  569. * | Shared Key Identifier | HMAC Identifier |
  570. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  571. * | |
  572. * \ HMAC /
  573. * / \
  574. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  575. *
  576. * Type: 1 byte (unsigned integer)
  577. * This value MUST be set to 0x0F for all AUTH-chunks.
  578. *
  579. * Flags: 1 byte (unsigned integer)
  580. * Set to zero on transmit and ignored on receipt.
  581. *
  582. * Length: 2 bytes (unsigned integer)
  583. * This value holds the length of the HMAC in bytes plus 8.
  584. *
  585. * Shared Key Identifier: 2 bytes (unsigned integer)
  586. * This value describes which endpoint pair shared key is used.
  587. *
  588. * HMAC Identifier: 2 bytes (unsigned integer)
  589. * This value describes which message digest is being used. Table 2
  590. * shows the currently defined values.
  591. *
  592. * The following Table 2 shows the currently defined values for HMAC
  593. * identifiers.
  594. *
  595. * +-----------------+--------------------------+
  596. * | HMAC Identifier | Message Digest Algorithm |
  597. * +-----------------+--------------------------+
  598. * | 0 | Reserved |
  599. * | 1 | SHA-1 defined in [8] |
  600. * | 2 | Reserved |
  601. * | 3 | SHA-256 defined in [8] |
  602. * +-----------------+--------------------------+
  603. *
  604. *
  605. * HMAC: n bytes (unsigned integer) This hold the result of the HMAC
  606. * calculation.
  607. */
  608. typedef struct sctp_authhdr {
  609. __be16 shkey_id;
  610. __be16 hmac_id;
  611. __u8 hmac[0];
  612. } __packed sctp_authhdr_t;
  613. typedef struct sctp_auth_chunk {
  614. sctp_chunkhdr_t chunk_hdr;
  615. sctp_authhdr_t auth_hdr;
  616. } __packed sctp_auth_chunk_t;
  617. #endif /* __LINUX_SCTP_H__ */