sctp.h 23 KB

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