sctp.h 23 KB

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