blob: 3bfe8d6ee248e8e38df18e9b0462678ee76d479f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -050013 * This SCTP implementation is free software;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 * 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 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -050019 * This SCTP implementation is distributed in the hope that it
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 * 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
54#include <linux/in.h> /* We need in_addr. */
55#include <linux/in6.h> /* We need in6_addr. */
Daniel Borkmann1b866432013-04-09 05:54:01 +000056#include <linux/skbuff.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Daniel Borkmann1b866432013-04-09 05:54:01 +000058#include <uapi/linux/sctp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60/* Section 3.1. SCTP Common Header Format */
61typedef struct sctphdr {
Al Virof3ffaf12006-11-20 16:59:12 -080062 __be16 source;
63 __be16 dest;
64 __be32 vtag;
Vlad Yasevich4458f042009-02-13 08:33:42 +000065 __le32 checksum;
Eric Dumazetbc105022010-06-03 03:21:52 -070066} __packed sctp_sctphdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Arnaldo Carvalho de Melo2c0fd382007-03-13 13:59:32 -030068static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
69{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -070070 return (struct sctphdr *)skb_transport_header(skb);
Arnaldo Carvalho de Melo2c0fd382007-03-13 13:59:32 -030071}
Arnaldo Carvalho de Melo2c0fd382007-03-13 13:59:32 -030072
Linus Torvalds1da177e2005-04-16 15:20:36 -070073/* Section 3.2. Chunk Field Descriptions. */
74typedef struct sctp_chunkhdr {
75 __u8 type;
76 __u8 flags;
Al Virof3ffaf12006-11-20 16:59:12 -080077 __be16 length;
Eric Dumazetbc105022010-06-03 03:21:52 -070078} __packed sctp_chunkhdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80
81/* Section 3.2. Chunk Type Values.
82 * [Chunk Type] identifies the type of information contained in the Chunk
83 * Value field. It takes a value from 0 to 254. The value of 255 is
84 * reserved for future use as an extension field.
85 */
86typedef enum {
87 SCTP_CID_DATA = 0,
88 SCTP_CID_INIT = 1,
89 SCTP_CID_INIT_ACK = 2,
90 SCTP_CID_SACK = 3,
91 SCTP_CID_HEARTBEAT = 4,
92 SCTP_CID_HEARTBEAT_ACK = 5,
93 SCTP_CID_ABORT = 6,
94 SCTP_CID_SHUTDOWN = 7,
95 SCTP_CID_SHUTDOWN_ACK = 8,
96 SCTP_CID_ERROR = 9,
97 SCTP_CID_COOKIE_ECHO = 10,
98 SCTP_CID_COOKIE_ACK = 11,
99 SCTP_CID_ECN_ECNE = 12,
100 SCTP_CID_ECN_CWR = 13,
101 SCTP_CID_SHUTDOWN_COMPLETE = 14,
102
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700103 /* AUTH Extension Section 4.1 */
104 SCTP_CID_AUTH = 0x0F,
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 /* PR-SCTP Sec 3.2 */
107 SCTP_CID_FWD_TSN = 0xC0,
108
109 /* Use hex, as defined in ADDIP sec. 3.1 */
110 SCTP_CID_ASCONF = 0xC1,
111 SCTP_CID_ASCONF_ACK = 0x80,
112} sctp_cid_t; /* enum */
113
114
115/* Section 3.2
116 * Chunk Types are encoded such that the highest-order two bits specify
117 * the action that must be taken if the processing endpoint does not
118 * recognize the Chunk Type.
119 */
120typedef enum {
121 SCTP_CID_ACTION_DISCARD = 0x00,
122 SCTP_CID_ACTION_DISCARD_ERR = 0x40,
123 SCTP_CID_ACTION_SKIP = 0x80,
124 SCTP_CID_ACTION_SKIP_ERR = 0xc0,
125} sctp_cid_action_t;
126
127enum { SCTP_CID_ACTION_MASK = 0xc0, };
128
129/* This flag is used in Chunk Flags for ABORT and SHUTDOWN COMPLETE.
130 *
131 * 3.3.7 Abort Association (ABORT) (6):
132 * The T bit is set to 0 if the sender had a TCB that it destroyed.
133 * If the sender did not have a TCB it should set this bit to 1.
134 */
135enum { SCTP_CHUNK_FLAG_T = 0x01 };
136
137/*
138 * Set the T bit
139 *
140 * 0 1 2 3
141 * 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
142 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143 * | Type = 14 |Reserved |T| Length = 4 |
144 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145 *
146 * Chunk Flags: 8 bits
147 *
148 * Reserved: 7 bits
149 * Set to 0 on transmit and ignored on receipt.
150 *
151 * T bit: 1 bit
152 * The T bit is set to 0 if the sender had a TCB that it destroyed. If
153 * the sender did NOT have a TCB it should set this bit to 1.
154 *
155 * Note: Special rules apply to this chunk for verification, please
156 * see Section 8.5.1 for details.
157 */
158
159#define sctp_test_T_bit(c) ((c)->chunk_hdr->flags & SCTP_CHUNK_FLAG_T)
160
161/* RFC 2960
162 * Section 3.2.1 Optional/Variable-length Parmaeter Format.
163 */
164
165typedef struct sctp_paramhdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800166 __be16 type;
167 __be16 length;
Eric Dumazetbc105022010-06-03 03:21:52 -0700168} __packed sctp_paramhdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170typedef enum {
171
172 /* RFC 2960 Section 3.3.5 */
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800173 SCTP_PARAM_HEARTBEAT_INFO = cpu_to_be16(1),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 /* RFC 2960 Section 3.3.2.1 */
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800175 SCTP_PARAM_IPV4_ADDRESS = cpu_to_be16(5),
176 SCTP_PARAM_IPV6_ADDRESS = cpu_to_be16(6),
177 SCTP_PARAM_STATE_COOKIE = cpu_to_be16(7),
178 SCTP_PARAM_UNRECOGNIZED_PARAMETERS = cpu_to_be16(8),
179 SCTP_PARAM_COOKIE_PRESERVATIVE = cpu_to_be16(9),
180 SCTP_PARAM_HOST_NAME_ADDRESS = cpu_to_be16(11),
181 SCTP_PARAM_SUPPORTED_ADDRESS_TYPES = cpu_to_be16(12),
182 SCTP_PARAM_ECN_CAPABLE = cpu_to_be16(0x8000),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700184 /* AUTH Extension Section 3 */
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800185 SCTP_PARAM_RANDOM = cpu_to_be16(0x8002),
186 SCTP_PARAM_CHUNKS = cpu_to_be16(0x8003),
187 SCTP_PARAM_HMAC_ALGO = cpu_to_be16(0x8004),
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700188
Vlad Yasevich131a47e2007-09-16 15:53:56 -0700189 /* Add-IP: Supported Extensions, Section 4.2 */
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800190 SCTP_PARAM_SUPPORTED_EXT = cpu_to_be16(0x8008),
Vlad Yasevich131a47e2007-09-16 15:53:56 -0700191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 /* PR-SCTP Sec 3.1 */
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800193 SCTP_PARAM_FWD_TSN_SUPPORT = cpu_to_be16(0xc000),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195 /* Add-IP Extension. Section 3.2 */
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800196 SCTP_PARAM_ADD_IP = cpu_to_be16(0xc001),
197 SCTP_PARAM_DEL_IP = cpu_to_be16(0xc002),
198 SCTP_PARAM_ERR_CAUSE = cpu_to_be16(0xc003),
199 SCTP_PARAM_SET_PRIMARY = cpu_to_be16(0xc004),
200 SCTP_PARAM_SUCCESS_REPORT = cpu_to_be16(0xc005),
201 SCTP_PARAM_ADAPTATION_LAYER_IND = cpu_to_be16(0xc006),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
203} sctp_param_t; /* enum */
204
205
206/* RFC 2960 Section 3.2.1
207 * The Parameter Types are encoded such that the highest-order two bits
208 * specify the action that must be taken if the processing endpoint does
209 * not recognize the Parameter Type.
210 *
211 */
212typedef enum {
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800213 SCTP_PARAM_ACTION_DISCARD = cpu_to_be16(0x0000),
214 SCTP_PARAM_ACTION_DISCARD_ERR = cpu_to_be16(0x4000),
215 SCTP_PARAM_ACTION_SKIP = cpu_to_be16(0x8000),
216 SCTP_PARAM_ACTION_SKIP_ERR = cpu_to_be16(0xc000),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217} sctp_param_action_t;
218
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800219enum { SCTP_PARAM_ACTION_MASK = cpu_to_be16(0xc000), };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221/* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */
222
223typedef struct sctp_datahdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800224 __be32 tsn;
225 __be16 stream;
226 __be16 ssn;
227 __be32 ppid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 __u8 payload[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700229} __packed sctp_datahdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
231typedef struct sctp_data_chunk {
232 sctp_chunkhdr_t chunk_hdr;
233 sctp_datahdr_t data_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700234} __packed sctp_data_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
236/* DATA Chuck Specific Flags */
237enum {
238 SCTP_DATA_MIDDLE_FRAG = 0x00,
239 SCTP_DATA_LAST_FRAG = 0x01,
240 SCTP_DATA_FIRST_FRAG = 0x02,
241 SCTP_DATA_NOT_FRAG = 0x03,
242 SCTP_DATA_UNORDERED = 0x04,
Wei Yongjun475cba42009-11-23 15:53:52 -0500243 SCTP_DATA_SACK_IMM = 0x08,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244};
245enum { SCTP_DATA_FRAG_MASK = 0x03, };
246
247
248/* RFC 2960 Section 3.3.2 Initiation (INIT) (1)
249 *
250 * This chunk is used to initiate a SCTP association between two
251 * endpoints.
252 */
253typedef struct sctp_inithdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800254 __be32 init_tag;
255 __be32 a_rwnd;
256 __be16 num_outbound_streams;
257 __be16 num_inbound_streams;
258 __be32 initial_tsn;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 __u8 params[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700260} __packed sctp_inithdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
262typedef struct sctp_init_chunk {
263 sctp_chunkhdr_t chunk_hdr;
264 sctp_inithdr_t init_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700265} __packed sctp_init_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
267
268/* Section 3.3.2.1. IPv4 Address Parameter (5) */
269typedef struct sctp_ipv4addr_param {
270 sctp_paramhdr_t param_hdr;
271 struct in_addr addr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700272} __packed sctp_ipv4addr_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274/* Section 3.3.2.1. IPv6 Address Parameter (6) */
275typedef struct sctp_ipv6addr_param {
276 sctp_paramhdr_t param_hdr;
277 struct in6_addr addr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700278} __packed sctp_ipv6addr_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
280/* Section 3.3.2.1 Cookie Preservative (9) */
281typedef struct sctp_cookie_preserve_param {
282 sctp_paramhdr_t param_hdr;
Al Virof3ffaf12006-11-20 16:59:12 -0800283 __be32 lifespan_increment;
Eric Dumazetbc105022010-06-03 03:21:52 -0700284} __packed sctp_cookie_preserve_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286/* Section 3.3.2.1 Host Name Address (11) */
287typedef struct sctp_hostname_param {
288 sctp_paramhdr_t param_hdr;
289 uint8_t hostname[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700290} __packed sctp_hostname_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
292/* Section 3.3.2.1 Supported Address Types (12) */
293typedef struct sctp_supported_addrs_param {
294 sctp_paramhdr_t param_hdr;
Al Virof3ffaf12006-11-20 16:59:12 -0800295 __be16 types[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700296} __packed sctp_supported_addrs_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
298/* Appendix A. ECN Capable (32768) */
299typedef struct sctp_ecn_capable_param {
300 sctp_paramhdr_t param_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700301} __packed sctp_ecn_capable_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Ivan Skytte Jorgensen0f3fffd2006-12-20 16:07:04 -0800303/* ADDIP Section 3.2.6 Adaptation Layer Indication */
304typedef struct sctp_adaptation_ind_param {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 struct sctp_paramhdr param_hdr;
Ivan Skytte Jorgensen0f3fffd2006-12-20 16:07:04 -0800306 __be32 adaptation_ind;
Eric Dumazetbc105022010-06-03 03:21:52 -0700307} __packed sctp_adaptation_ind_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Vlad Yasevich131a47e2007-09-16 15:53:56 -0700309/* ADDIP Section 4.2.7 Supported Extensions Parameter */
310typedef struct sctp_supported_ext_param {
311 struct sctp_paramhdr param_hdr;
312 __u8 chunks[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700313} __packed sctp_supported_ext_param_t;
Vlad Yasevich131a47e2007-09-16 15:53:56 -0700314
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700315/* AUTH Section 3.1 Random */
316typedef struct sctp_random_param {
317 sctp_paramhdr_t param_hdr;
318 __u8 random_val[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700319} __packed sctp_random_param_t;
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700320
321/* AUTH Section 3.2 Chunk List */
322typedef struct sctp_chunks_param {
323 sctp_paramhdr_t param_hdr;
324 __u8 chunks[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700325} __packed sctp_chunks_param_t;
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700326
327/* AUTH Section 3.3 HMAC Algorithm */
328typedef struct sctp_hmac_algo_param {
329 sctp_paramhdr_t param_hdr;
330 __be16 hmac_ids[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700331} __packed sctp_hmac_algo_param_t;
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700332
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
334 * The INIT ACK chunk is used to acknowledge the initiation of an SCTP
335 * association.
336 */
337typedef sctp_init_chunk_t sctp_initack_chunk_t;
338
339/* Section 3.3.3.1 State Cookie (7) */
340typedef struct sctp_cookie_param {
341 sctp_paramhdr_t p;
342 __u8 body[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700343} __packed sctp_cookie_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345/* Section 3.3.3.1 Unrecognized Parameters (8) */
346typedef struct sctp_unrecognized_param {
347 sctp_paramhdr_t param_hdr;
348 sctp_paramhdr_t unrecognized;
Eric Dumazetbc105022010-06-03 03:21:52 -0700349} __packed sctp_unrecognized_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
351
352
353/*
354 * 3.3.4 Selective Acknowledgement (SACK) (3):
355 *
356 * This chunk is sent to the peer endpoint to acknowledge received DATA
357 * chunks and to inform the peer endpoint of gaps in the received
358 * subsequences of DATA chunks as represented by their TSNs.
359 */
360
361typedef struct sctp_gap_ack_block {
Al Virof3ffaf12006-11-20 16:59:12 -0800362 __be16 start;
363 __be16 end;
Eric Dumazetbc105022010-06-03 03:21:52 -0700364} __packed sctp_gap_ack_block_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
Al Virof3ffaf12006-11-20 16:59:12 -0800366typedef __be32 sctp_dup_tsn_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
368typedef union {
369 sctp_gap_ack_block_t gab;
370 sctp_dup_tsn_t dup;
371} sctp_sack_variable_t;
372
373typedef struct sctp_sackhdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800374 __be32 cum_tsn_ack;
375 __be32 a_rwnd;
376 __be16 num_gap_ack_blocks;
377 __be16 num_dup_tsns;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 sctp_sack_variable_t variable[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700379} __packed sctp_sackhdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
381typedef struct sctp_sack_chunk {
382 sctp_chunkhdr_t chunk_hdr;
383 sctp_sackhdr_t sack_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700384} __packed sctp_sack_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385
386
387/* RFC 2960. Section 3.3.5 Heartbeat Request (HEARTBEAT) (4):
388 *
389 * An endpoint should send this chunk to its peer endpoint to probe the
390 * reachability of a particular destination transport address defined in
391 * the present association.
392 */
393
394typedef struct sctp_heartbeathdr {
395 sctp_paramhdr_t info;
Eric Dumazetbc105022010-06-03 03:21:52 -0700396} __packed sctp_heartbeathdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
398typedef struct sctp_heartbeat_chunk {
399 sctp_chunkhdr_t chunk_hdr;
400 sctp_heartbeathdr_t hb_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700401} __packed sctp_heartbeat_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
403
404/* For the abort and shutdown ACK we must carry the init tag in the
405 * common header. Just the common header is all that is needed with a
406 * chunk descriptor.
407 */
408typedef struct sctp_abort_chunk {
409 sctp_chunkhdr_t uh;
Eric Dumazetbc105022010-06-03 03:21:52 -0700410} __packed sctp_abort_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
412
413/* For the graceful shutdown we must carry the tag (in common header)
414 * and the highest consecutive acking value.
415 */
416typedef struct sctp_shutdownhdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800417 __be32 cum_tsn_ack;
Eric Dumazetbc105022010-06-03 03:21:52 -0700418} __packed sctp_shutdownhdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
420struct sctp_shutdown_chunk_t {
421 sctp_chunkhdr_t chunk_hdr;
422 sctp_shutdownhdr_t shutdown_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700423} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
425/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
426
427typedef struct sctp_errhdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800428 __be16 cause;
429 __be16 length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 __u8 variable[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700431} __packed sctp_errhdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
433typedef struct sctp_operr_chunk {
434 sctp_chunkhdr_t chunk_hdr;
435 sctp_errhdr_t err_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700436} __packed sctp_operr_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
438/* RFC 2960 3.3.10 - Operation Error
439 *
440 * Cause Code: 16 bits (unsigned integer)
441 *
442 * Defines the type of error conditions being reported.
443 * Cause Code
444 * Value Cause Code
445 * --------- ----------------
446 * 1 Invalid Stream Identifier
447 * 2 Missing Mandatory Parameter
448 * 3 Stale Cookie Error
449 * 4 Out of Resource
450 * 5 Unresolvable Address
451 * 6 Unrecognized Chunk Type
452 * 7 Invalid Mandatory Parameter
453 * 8 Unrecognized Parameters
454 * 9 No User Data
455 * 10 Cookie Received While Shutting Down
456 */
457typedef enum {
458
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800459 SCTP_ERROR_NO_ERROR = cpu_to_be16(0x00),
460 SCTP_ERROR_INV_STRM = cpu_to_be16(0x01),
461 SCTP_ERROR_MISS_PARAM = cpu_to_be16(0x02),
462 SCTP_ERROR_STALE_COOKIE = cpu_to_be16(0x03),
463 SCTP_ERROR_NO_RESOURCE = cpu_to_be16(0x04),
464 SCTP_ERROR_DNS_FAILED = cpu_to_be16(0x05),
465 SCTP_ERROR_UNKNOWN_CHUNK = cpu_to_be16(0x06),
466 SCTP_ERROR_INV_PARAM = cpu_to_be16(0x07),
467 SCTP_ERROR_UNKNOWN_PARAM = cpu_to_be16(0x08),
468 SCTP_ERROR_NO_DATA = cpu_to_be16(0x09),
469 SCTP_ERROR_COOKIE_IN_SHUTDOWN = cpu_to_be16(0x0a),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471
472 /* SCTP Implementation Guide:
473 * 11 Restart of an association with new addresses
474 * 12 User Initiated Abort
475 * 13 Protocol Violation
476 */
477
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800478 SCTP_ERROR_RESTART = cpu_to_be16(0x0b),
479 SCTP_ERROR_USER_ABORT = cpu_to_be16(0x0c),
480 SCTP_ERROR_PROTO_VIOLATION = cpu_to_be16(0x0d),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
482 /* ADDIP Section 3.3 New Error Causes
483 *
484 * Four new Error Causes are added to the SCTP Operational Errors,
485 * primarily for use in the ASCONF-ACK chunk.
486 *
487 * Value Cause Code
488 * --------- ----------------
Wei Yongjuna84db792009-04-07 15:41:39 +0800489 * 0x00A0 Request to Delete Last Remaining IP Address.
490 * 0x00A1 Operation Refused Due to Resource Shortage.
491 * 0x00A2 Request to Delete Source IP Address.
492 * 0x00A3 Association Aborted due to illegal ASCONF-ACK
493 * 0x00A4 Request refused - no authorization.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 */
Wei Yongjuna84db792009-04-07 15:41:39 +0800495 SCTP_ERROR_DEL_LAST_IP = cpu_to_be16(0x00A0),
496 SCTP_ERROR_RSRC_LOW = cpu_to_be16(0x00A1),
497 SCTP_ERROR_DEL_SRC_IP = cpu_to_be16(0x00A2),
498 SCTP_ERROR_ASCONF_ACK = cpu_to_be16(0x00A3),
499 SCTP_ERROR_REQ_REFUSED = cpu_to_be16(0x00A4),
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700500
501 /* AUTH Section 4. New Error Cause
502 *
503 * This section defines a new error cause that will be sent if an AUTH
504 * chunk is received with an unsupported HMAC identifier.
505 * illustrates the new error cause.
506 *
507 * Cause Code Error Cause Name
508 * --------------------------------------------------------------
509 * 0x0105 Unsupported HMAC Identifier
510 */
Harvey Harrisonf3a7c662009-02-14 22:58:35 -0800511 SCTP_ERROR_UNSUP_HMAC = cpu_to_be16(0x0105)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512} sctp_error_t;
513
514
515
516/* RFC 2960. Appendix A. Explicit Congestion Notification.
517 * Explicit Congestion Notification Echo (ECNE) (12)
518 */
519typedef struct sctp_ecnehdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800520 __be32 lowest_tsn;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521} sctp_ecnehdr_t;
522
523typedef struct sctp_ecne_chunk {
524 sctp_chunkhdr_t chunk_hdr;
525 sctp_ecnehdr_t ence_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700526} __packed sctp_ecne_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527
528/* RFC 2960. Appendix A. Explicit Congestion Notification.
529 * Congestion Window Reduced (CWR) (13)
530 */
531typedef struct sctp_cwrhdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800532 __be32 lowest_tsn;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533} sctp_cwrhdr_t;
534
535typedef struct sctp_cwr_chunk {
536 sctp_chunkhdr_t chunk_hdr;
537 sctp_cwrhdr_t cwr_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700538} __packed sctp_cwr_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539
540/* PR-SCTP
541 * 3.2 Forward Cumulative TSN Chunk Definition (FORWARD TSN)
542 *
543 * Forward Cumulative TSN chunk has the following format:
544 *
545 * 0 1 2 3
546 * 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
547 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
548 * | Type = 192 | Flags = 0x00 | Length = Variable |
549 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
550 * | New Cumulative TSN |
551 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
552 * | Stream-1 | Stream Sequence-1 |
553 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
554 * \ /
555 * / \
556 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
557 * | Stream-N | Stream Sequence-N |
558 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
559 *
560 * Chunk Flags:
561 *
562 * Set to all zeros on transmit and ignored on receipt.
563 *
564 * New Cumulative TSN: 32 bit u_int
565 *
566 * This indicates the new cumulative TSN to the data receiver. Upon
567 * the reception of this value, the data receiver MUST consider
568 * any missing TSNs earlier than or equal to this value as received
569 * and stop reporting them as gaps in any subsequent SACKs.
570 *
571 * Stream-N: 16 bit u_int
572 *
573 * This field holds a stream number that was skipped by this
574 * FWD-TSN.
575 *
576 * Stream Sequence-N: 16 bit u_int
577 * This field holds the sequence number associated with the stream
578 * that was skipped. The stream sequence field holds the largest stream
579 * sequence number in this stream being skipped. The receiver of
580 * the FWD-TSN's can use the Stream-N and Stream Sequence-N fields
581 * to enable delivery of any stranded TSN's that remain on the stream
582 * re-ordering queues. This field MUST NOT report TSN's corresponding
583 * to DATA chunk that are marked as unordered. For ordered DATA
584 * chunks this field MUST be filled in.
585 */
586struct sctp_fwdtsn_skip {
Al Virof3ffaf12006-11-20 16:59:12 -0800587 __be16 stream;
588 __be16 ssn;
Eric Dumazetbc105022010-06-03 03:21:52 -0700589} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590
591struct sctp_fwdtsn_hdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800592 __be32 new_cum_tsn;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 struct sctp_fwdtsn_skip skip[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700594} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595
596struct sctp_fwdtsn_chunk {
597 struct sctp_chunkhdr chunk_hdr;
598 struct sctp_fwdtsn_hdr fwdtsn_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700599} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600
601
602/* ADDIP
603 * Section 3.1.1 Address Configuration Change Chunk (ASCONF)
604 *
605 * Serial Number: 32 bits (unsigned integer)
606 * This value represents a Serial Number for the ASCONF Chunk. The
607 * valid range of Serial Number is from 0 to 2^32-1.
608 * Serial Numbers wrap back to 0 after reaching 2^32 -1.
609 *
610 * Address Parameter: 8 or 20 bytes (depending on type)
611 * The address is an address of the sender of the ASCONF chunk,
612 * the address MUST be considered part of the association by the
613 * peer endpoint. This field may be used by the receiver of the
614 * ASCONF to help in finding the association. This parameter MUST
615 * be present in every ASCONF message i.e. it is a mandatory TLV
616 * parameter.
617 *
618 * ASCONF Parameter: TLV format
619 * Each Address configuration change is represented by a TLV
620 * parameter as defined in Section 3.2. One or more requests may
621 * be present in an ASCONF Chunk.
622 *
623 * Section 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
624 *
625 * Serial Number: 32 bits (unsigned integer)
626 * This value represents the Serial Number for the received ASCONF
627 * Chunk that is acknowledged by this chunk. This value is copied
628 * from the received ASCONF Chunk.
629 *
630 * ASCONF Parameter Response: TLV format
631 * The ASCONF Parameter Response is used in the ASCONF-ACK to
632 * report status of ASCONF processing.
633 */
634typedef struct sctp_addip_param {
635 sctp_paramhdr_t param_hdr;
Al Virof3ffaf12006-11-20 16:59:12 -0800636 __be32 crr_id;
Eric Dumazetbc105022010-06-03 03:21:52 -0700637} __packed sctp_addip_param_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
639typedef struct sctp_addiphdr {
Al Virof3ffaf12006-11-20 16:59:12 -0800640 __be32 serial;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 __u8 params[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700642} __packed sctp_addiphdr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643
644typedef struct sctp_addip_chunk {
645 sctp_chunkhdr_t chunk_hdr;
646 sctp_addiphdr_t addip_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700647} __packed sctp_addip_chunk_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700649/* AUTH
650 * Section 4.1 Authentication Chunk (AUTH)
651 *
652 * This chunk is used to hold the result of the HMAC calculation.
653 *
654 * 0 1 2 3
655 * 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
656 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
657 * | Type = 0x0F | Flags=0 | Length |
658 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
659 * | Shared Key Identifier | HMAC Identifier |
660 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
661 * | |
662 * \ HMAC /
663 * / \
664 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
665 *
666 * Type: 1 byte (unsigned integer)
667 * This value MUST be set to 0x0F for all AUTH-chunks.
668 *
669 * Flags: 1 byte (unsigned integer)
670 * Set to zero on transmit and ignored on receipt.
671 *
672 * Length: 2 bytes (unsigned integer)
673 * This value holds the length of the HMAC in bytes plus 8.
674 *
675 * Shared Key Identifier: 2 bytes (unsigned integer)
676 * This value describes which endpoint pair shared key is used.
677 *
678 * HMAC Identifier: 2 bytes (unsigned integer)
679 * This value describes which message digest is being used. Table 2
680 * shows the currently defined values.
681 *
682 * The following Table 2 shows the currently defined values for HMAC
683 * identifiers.
684 *
685 * +-----------------+--------------------------+
686 * | HMAC Identifier | Message Digest Algorithm |
687 * +-----------------+--------------------------+
688 * | 0 | Reserved |
689 * | 1 | SHA-1 defined in [8] |
690 * | 2 | Reserved |
691 * | 3 | SHA-256 defined in [8] |
692 * +-----------------+--------------------------+
693 *
694 *
695 * HMAC: n bytes (unsigned integer) This hold the result of the HMAC
696 * calculation.
697 */
698typedef struct sctp_authhdr {
699 __be16 shkey_id;
700 __be16 hmac_id;
701 __u8 hmac[0];
Eric Dumazetbc105022010-06-03 03:21:52 -0700702} __packed sctp_authhdr_t;
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700703
704typedef struct sctp_auth_chunk {
705 sctp_chunkhdr_t chunk_hdr;
706 sctp_authhdr_t auth_hdr;
Eric Dumazetbc105022010-06-03 03:21:52 -0700707} __packed sctp_auth_chunk_t;
Vlad Yasevichf7b0e932007-09-16 19:26:06 -0700708
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709#endif /* __LINUX_SCTP_H__ */