sctp.h 22 KB

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