xref: /freebsd/sys/netinet/sctp_header.h (revision ca85e9482aa4d92ab9da1852b69cc56ae1bec21c)
1f8829a4aSRandall Stewart /*-
2b1006367SRandall Stewart  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
35d40cf5dSRandall Stewart  * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
45d40cf5dSRandall Stewart  * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
5f8829a4aSRandall Stewart  *
6f8829a4aSRandall Stewart  * Redistribution and use in source and binary forms, with or without
7f8829a4aSRandall Stewart  * modification, are permitted provided that the following conditions are met:
8f8829a4aSRandall Stewart  *
9f8829a4aSRandall Stewart  * a) Redistributions of source code must retain the above copyright notice,
10f8829a4aSRandall Stewart  *   this list of conditions and the following disclaimer.
11f8829a4aSRandall Stewart  *
12f8829a4aSRandall Stewart  * b) Redistributions in binary form must reproduce the above copyright
13f8829a4aSRandall Stewart  *    notice, this list of conditions and the following disclaimer in
14f8829a4aSRandall Stewart  *   the documentation and/or other materials provided with the distribution.
15f8829a4aSRandall Stewart  *
16f8829a4aSRandall Stewart  * c) Neither the name of Cisco Systems, Inc. nor the names of its
17f8829a4aSRandall Stewart  *    contributors may be used to endorse or promote products derived
18f8829a4aSRandall Stewart  *    from this software without specific prior written permission.
19f8829a4aSRandall Stewart  *
20f8829a4aSRandall Stewart  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21f8829a4aSRandall Stewart  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22f8829a4aSRandall Stewart  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23f8829a4aSRandall Stewart  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24f8829a4aSRandall Stewart  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25f8829a4aSRandall Stewart  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26f8829a4aSRandall Stewart  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27f8829a4aSRandall Stewart  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28f8829a4aSRandall Stewart  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29f8829a4aSRandall Stewart  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30f8829a4aSRandall Stewart  * THE POSSIBILITY OF SUCH DAMAGE.
31f8829a4aSRandall Stewart  */
32f8829a4aSRandall Stewart 
33f8829a4aSRandall Stewart /* $KAME: sctp_header.h,v 1.14 2005/03/06 16:04:17 itojun Exp $	 */
34f8829a4aSRandall Stewart 
35f8829a4aSRandall Stewart #include <sys/cdefs.h>
36f8829a4aSRandall Stewart __FBSDID("$FreeBSD$");
37f8829a4aSRandall Stewart 
38f8829a4aSRandall Stewart #ifndef __sctp_header_h__
39f8829a4aSRandall Stewart #define __sctp_header_h__
40f8829a4aSRandall Stewart 
41f8829a4aSRandall Stewart #include <sys/time.h>
42f8829a4aSRandall Stewart #include <netinet/sctp.h>
43f8829a4aSRandall Stewart #include <netinet/sctp_constants.h>
44f8829a4aSRandall Stewart 
45b3f1ea41SRandall Stewart #define SCTP_PACKED __attribute__((packed))
4635918f85SRandall Stewart 
47f8829a4aSRandall Stewart /*
48f8829a4aSRandall Stewart  * Parameter structures
49f8829a4aSRandall Stewart  */
50f8829a4aSRandall Stewart struct sctp_ipv4addr_param {
51f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type=SCTP_IPV4_PARAM_TYPE, len=8 */
52f8829a4aSRandall Stewart 	uint32_t addr;		/* IPV4 address */
5335918f85SRandall Stewart }                   SCTP_PACKED;
54f8829a4aSRandall Stewart 
5542551e99SRandall Stewart #define SCTP_V6_ADDR_BYTES 16
5642551e99SRandall Stewart 
5742551e99SRandall Stewart 
58f8829a4aSRandall Stewart struct sctp_ipv6addr_param {
59f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */
6042551e99SRandall Stewart 	uint8_t addr[SCTP_V6_ADDR_BYTES];	/* IPV6 address */
6135918f85SRandall Stewart }                   SCTP_PACKED;
62f8829a4aSRandall Stewart 
63f8829a4aSRandall Stewart /* Cookie Preservative */
64f8829a4aSRandall Stewart struct sctp_cookie_perserve_param {
65f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type=SCTP_COOKIE_PRESERVE, len=8 */
66f8829a4aSRandall Stewart 	uint32_t time;		/* time in ms to extend cookie */
678d9d0613SMichael Tuexen }                          SCTP_PACKED;
68f8829a4aSRandall Stewart 
6942551e99SRandall Stewart #define SCTP_ARRAY_MIN_LEN 1
70f8829a4aSRandall Stewart /* Host Name Address */
71f8829a4aSRandall Stewart struct sctp_host_name_param {
72f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type=SCTP_HOSTNAME_ADDRESS */
7342551e99SRandall Stewart 	char name[SCTP_ARRAY_MIN_LEN];	/* host name */
7435918f85SRandall Stewart }                    SCTP_PACKED;
75f8829a4aSRandall Stewart 
76d06c82f1SRandall Stewart /*
77d06c82f1SRandall Stewart  * This is the maximum padded size of a s-a-p
78d06c82f1SRandall Stewart  * so paramheadr + 3 address types (6 bytes) + 2 byte pad = 12
79d06c82f1SRandall Stewart  */
80d06c82f1SRandall Stewart #define SCTP_MAX_ADDR_PARAMS_SIZE 12
81f8829a4aSRandall Stewart /* supported address type */
82f8829a4aSRandall Stewart struct sctp_supported_addr_param {
83f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type=SCTP_SUPPORTED_ADDRTYPE */
8442551e99SRandall Stewart 	uint16_t addr_type[SCTP_ARRAY_MIN_LEN];	/* array of supported address
8542551e99SRandall Stewart 						 * types */
8635918f85SRandall Stewart }                         SCTP_PACKED;
87f8829a4aSRandall Stewart 
88f8829a4aSRandall Stewart /* ECN parameter */
89f8829a4aSRandall Stewart struct sctp_ecn_supported_param {
90f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type=SCTP_ECN_CAPABLE */
9135918f85SRandall Stewart }                        SCTP_PACKED;
92f8829a4aSRandall Stewart 
93f8829a4aSRandall Stewart 
94f8829a4aSRandall Stewart /* heartbeat info parameter */
95f8829a4aSRandall Stewart struct sctp_heartbeat_info_param {
96f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
97f8829a4aSRandall Stewart 	uint32_t time_value_1;
98f8829a4aSRandall Stewart 	uint32_t time_value_2;
99f8829a4aSRandall Stewart 	uint32_t random_value1;
100f8829a4aSRandall Stewart 	uint32_t random_value2;
101f8829a4aSRandall Stewart 	uint8_t addr_family;
102f8829a4aSRandall Stewart 	uint8_t addr_len;
103*ca85e948SMichael Tuexen 	/* make sure that this structure is 4 byte aligned */
104*ca85e948SMichael Tuexen 	uint8_t padding[2];
105f8829a4aSRandall Stewart 	char address[SCTP_ADDRMAX];
10635918f85SRandall Stewart }                         SCTP_PACKED;
107f8829a4aSRandall Stewart 
108f8829a4aSRandall Stewart 
109f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */
110f8829a4aSRandall Stewart /* PR-SCTP supported parameter */
111f8829a4aSRandall Stewart struct sctp_prsctp_supported_param {
112f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
11335918f85SRandall Stewart }                           SCTP_PACKED;
114f8829a4aSRandall Stewart 
115f8829a4aSRandall Stewart 
116f8829a4aSRandall Stewart /* draft-ietf-tsvwg-addip-sctp */
117f8829a4aSRandall Stewart struct sctp_asconf_paramhdr {	/* an ASCONF "parameter" */
118f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* a SCTP parameter header */
119f8829a4aSRandall Stewart 	uint32_t correlation_id;/* correlation id for this param */
12035918f85SRandall Stewart }                    SCTP_PACKED;
121f8829a4aSRandall Stewart 
122f8829a4aSRandall Stewart struct sctp_asconf_addr_param {	/* an ASCONF address parameter */
123f8829a4aSRandall Stewart 	struct sctp_asconf_paramhdr aph;	/* asconf "parameter" */
124f8829a4aSRandall Stewart 	struct sctp_ipv6addr_param addrp;	/* max storage size */
12535918f85SRandall Stewart }                      SCTP_PACKED;
126f8829a4aSRandall Stewart 
127830d754dSRandall Stewart 
128830d754dSRandall Stewart struct sctp_asconf_tag_param {	/* an ASCONF NAT-Vtag parameter */
129830d754dSRandall Stewart 	struct sctp_asconf_paramhdr aph;	/* asconf "parameter" */
130830d754dSRandall Stewart 	uint32_t local_vtag;
131830d754dSRandall Stewart 	uint32_t remote_vtag;
132830d754dSRandall Stewart }                     SCTP_PACKED;
133830d754dSRandall Stewart 
134830d754dSRandall Stewart 
135f8829a4aSRandall Stewart struct sctp_asconf_addrv4_param {	/* an ASCONF address (v4) parameter */
136f8829a4aSRandall Stewart 	struct sctp_asconf_paramhdr aph;	/* asconf "parameter" */
137f8829a4aSRandall Stewart 	struct sctp_ipv4addr_param addrp;	/* max storage size */
13835918f85SRandall Stewart }                        SCTP_PACKED;
139f8829a4aSRandall Stewart 
140d06c82f1SRandall Stewart #define SCTP_MAX_SUPPORTED_EXT 256
141d06c82f1SRandall Stewart 
142f8829a4aSRandall Stewart struct sctp_supported_chunk_types_param {
143f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type = 0x8008  len = x */
144663fdad8SMichael Tuexen 	uint8_t chunk_types[];
14535918f85SRandall Stewart }                                SCTP_PACKED;
146f8829a4aSRandall Stewart 
147f8829a4aSRandall Stewart 
148f8829a4aSRandall Stewart /*
149f8829a4aSRandall Stewart  * Structures for DATA chunks
150f8829a4aSRandall Stewart  */
151f8829a4aSRandall Stewart struct sctp_data {
152f8829a4aSRandall Stewart 	uint32_t tsn;
153f8829a4aSRandall Stewart 	uint16_t stream_id;
154f8829a4aSRandall Stewart 	uint16_t stream_sequence;
155f8829a4aSRandall Stewart 	uint32_t protocol_id;
156f8829a4aSRandall Stewart 	/* user data follows */
15735918f85SRandall Stewart }         SCTP_PACKED;
158f8829a4aSRandall Stewart 
159f8829a4aSRandall Stewart struct sctp_data_chunk {
160f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
161f8829a4aSRandall Stewart 	struct sctp_data dp;
16235918f85SRandall Stewart }               SCTP_PACKED;
163f8829a4aSRandall Stewart 
164f8829a4aSRandall Stewart /*
165f8829a4aSRandall Stewart  * Structures for the control chunks
166f8829a4aSRandall Stewart  */
167f8829a4aSRandall Stewart 
168f8829a4aSRandall Stewart /* Initiate (INIT)/Initiate Ack (INIT ACK) */
169f8829a4aSRandall Stewart struct sctp_init {
170f8829a4aSRandall Stewart 	uint32_t initiate_tag;	/* initiate tag */
171f8829a4aSRandall Stewart 	uint32_t a_rwnd;	/* a_rwnd */
172f8829a4aSRandall Stewart 	uint16_t num_outbound_streams;	/* OS */
173f8829a4aSRandall Stewart 	uint16_t num_inbound_streams;	/* MIS */
174f8829a4aSRandall Stewart 	uint32_t initial_tsn;	/* I-TSN */
175f8829a4aSRandall Stewart 	/* optional param's follow */
17635918f85SRandall Stewart }         SCTP_PACKED;
177f8829a4aSRandall Stewart 
17842551e99SRandall Stewart #define SCTP_IDENTIFICATION_SIZE 16
17942551e99SRandall Stewart #define SCTP_ADDRESS_SIZE 4
18035918f85SRandall Stewart #define SCTP_RESERVE_SPACE 6
181f8829a4aSRandall Stewart /* state cookie header */
182f8829a4aSRandall Stewart struct sctp_state_cookie {	/* this is our definition... */
18342551e99SRandall Stewart 	uint8_t identification[SCTP_IDENTIFICATION_SIZE];	/* id of who we are */
18435918f85SRandall Stewart 	struct timeval time_entered;	/* the time I built cookie */
185f8829a4aSRandall Stewart 	uint32_t cookie_life;	/* life I will award this cookie */
186f8829a4aSRandall Stewart 	uint32_t tie_tag_my_vtag;	/* my tag in old association */
18735918f85SRandall Stewart 
188f8829a4aSRandall Stewart 	uint32_t tie_tag_peer_vtag;	/* peers tag in old association */
189f8829a4aSRandall Stewart 	uint32_t peers_vtag;	/* peers tag in INIT (for quick ref) */
19035918f85SRandall Stewart 
191f8829a4aSRandall Stewart 	uint32_t my_vtag;	/* my tag in INIT-ACK (for quick ref) */
19242551e99SRandall Stewart 	uint32_t address[SCTP_ADDRESS_SIZE];	/* 4 ints/128 bits */
193f8829a4aSRandall Stewart 	uint32_t addr_type;	/* address type */
19442551e99SRandall Stewart 	uint32_t laddress[SCTP_ADDRESS_SIZE];	/* my local from address */
195f8829a4aSRandall Stewart 	uint32_t laddr_type;	/* my local from address type */
196f8829a4aSRandall Stewart 	uint32_t scope_id;	/* v6 scope id for link-locals */
19735918f85SRandall Stewart 
198f8829a4aSRandall Stewart 	uint16_t peerport;	/* port address of the peer in the INIT */
199f8829a4aSRandall Stewart 	uint16_t myport;	/* my port address used in the INIT */
200f8829a4aSRandall Stewart 	uint8_t ipv4_addr_legal;/* Are V4 addr legal? */
201f8829a4aSRandall Stewart 	uint8_t ipv6_addr_legal;/* Are V6 addr legal? */
202f8829a4aSRandall Stewart 	uint8_t local_scope;	/* IPv6 local scope flag */
203f8829a4aSRandall Stewart 	uint8_t site_scope;	/* IPv6 site scope flag */
20435918f85SRandall Stewart 
205f8829a4aSRandall Stewart 	uint8_t ipv4_scope;	/* IPv4 private addr scope */
206f8829a4aSRandall Stewart 	uint8_t loopback_scope;	/* loopback scope information */
20735918f85SRandall Stewart 	uint8_t reserved[SCTP_RESERVE_SPACE];	/* Align to 64 bits */
208f8829a4aSRandall Stewart 	/*
209f8829a4aSRandall Stewart 	 * at the end is tacked on the INIT chunk and the INIT-ACK chunk
210f8829a4aSRandall Stewart 	 * (minus the cookie).
211f8829a4aSRandall Stewart 	 */
21235918f85SRandall Stewart }                 SCTP_PACKED;
213f8829a4aSRandall Stewart 
214830d754dSRandall Stewart 
215830d754dSRandall Stewart /* Used for NAT state error cause */
216830d754dSRandall Stewart struct sctp_missing_nat_state {
217830d754dSRandall Stewart 	uint16_t cause;
218830d754dSRandall Stewart 	uint16_t length;
219663fdad8SMichael Tuexen 	uint8_t data[];
220830d754dSRandall Stewart }                      SCTP_PACKED;
221830d754dSRandall Stewart 
222830d754dSRandall Stewart 
223f8829a4aSRandall Stewart struct sctp_inv_mandatory_param {
224f8829a4aSRandall Stewart 	uint16_t cause;
225f8829a4aSRandall Stewart 	uint16_t length;
226f8829a4aSRandall Stewart 	uint32_t num_param;
227f8829a4aSRandall Stewart 	uint16_t param;
228f8829a4aSRandall Stewart 	/*
229f8829a4aSRandall Stewart 	 * We include this to 0 it since only a missing cookie will cause
230f8829a4aSRandall Stewart 	 * this error.
231f8829a4aSRandall Stewart 	 */
232f8829a4aSRandall Stewart 	uint16_t resv;
23335918f85SRandall Stewart }                        SCTP_PACKED;
234f8829a4aSRandall Stewart 
235f8829a4aSRandall Stewart struct sctp_unresolv_addr {
236f8829a4aSRandall Stewart 	uint16_t cause;
237f8829a4aSRandall Stewart 	uint16_t length;
238f8829a4aSRandall Stewart 	uint16_t addr_type;
239f8829a4aSRandall Stewart 	uint16_t reserved;	/* Only one invalid addr type */
24035918f85SRandall Stewart }                  SCTP_PACKED;
241f8829a4aSRandall Stewart 
242f8829a4aSRandall Stewart /* state cookie parameter */
243f8829a4aSRandall Stewart struct sctp_state_cookie_param {
244f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
245f8829a4aSRandall Stewart 	struct sctp_state_cookie cookie;
24635918f85SRandall Stewart }                       SCTP_PACKED;
247f8829a4aSRandall Stewart 
248f8829a4aSRandall Stewart struct sctp_init_chunk {
249f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
250f8829a4aSRandall Stewart 	struct sctp_init init;
25135918f85SRandall Stewart }               SCTP_PACKED;
252f8829a4aSRandall Stewart 
253f8829a4aSRandall Stewart struct sctp_init_msg {
254f8829a4aSRandall Stewart 	struct sctphdr sh;
255f8829a4aSRandall Stewart 	struct sctp_init_chunk msg;
25635918f85SRandall Stewart }             SCTP_PACKED;
257f8829a4aSRandall Stewart 
258f8829a4aSRandall Stewart /* ... used for both INIT and INIT ACK */
259f8829a4aSRandall Stewart #define sctp_init_ack		sctp_init
260f8829a4aSRandall Stewart #define sctp_init_ack_chunk	sctp_init_chunk
261f8829a4aSRandall Stewart #define sctp_init_ack_msg	sctp_init_msg
262f8829a4aSRandall Stewart 
263f8829a4aSRandall Stewart 
264f8829a4aSRandall Stewart /* Selective Ack (SACK) */
265f8829a4aSRandall Stewart struct sctp_gap_ack_block {
266f8829a4aSRandall Stewart 	uint16_t start;		/* Gap Ack block start */
267f8829a4aSRandall Stewart 	uint16_t end;		/* Gap Ack block end */
26835918f85SRandall Stewart }                  SCTP_PACKED;
269f8829a4aSRandall Stewart 
270f8829a4aSRandall Stewart struct sctp_sack {
271f8829a4aSRandall Stewart 	uint32_t cum_tsn_ack;	/* cumulative TSN Ack */
272f8829a4aSRandall Stewart 	uint32_t a_rwnd;	/* updated a_rwnd of sender */
273f8829a4aSRandall Stewart 	uint16_t num_gap_ack_blks;	/* number of Gap Ack blocks */
274f8829a4aSRandall Stewart 	uint16_t num_dup_tsns;	/* number of duplicate TSNs */
275f8829a4aSRandall Stewart 	/* struct sctp_gap_ack_block's follow */
276f8829a4aSRandall Stewart 	/* uint32_t duplicate_tsn's follow */
27735918f85SRandall Stewart }         SCTP_PACKED;
278f8829a4aSRandall Stewart 
279f8829a4aSRandall Stewart struct sctp_sack_chunk {
280f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
281f8829a4aSRandall Stewart 	struct sctp_sack sack;
28235918f85SRandall Stewart }               SCTP_PACKED;
283f8829a4aSRandall Stewart 
284830d754dSRandall Stewart struct sctp_nr_sack {
285830d754dSRandall Stewart 	uint32_t cum_tsn_ack;	/* cumulative TSN Ack */
286830d754dSRandall Stewart 	uint32_t a_rwnd;	/* updated a_rwnd of sender */
287830d754dSRandall Stewart 	uint16_t num_gap_ack_blks;	/* number of Gap Ack blocks */
288830d754dSRandall Stewart 	uint16_t num_nr_gap_ack_blks;	/* number of NR Gap Ack blocks */
289830d754dSRandall Stewart 	uint16_t num_dup_tsns;	/* number of duplicate TSNs */
290830d754dSRandall Stewart 	uint16_t reserved;	/* not currently used */
291830d754dSRandall Stewart 	/* struct sctp_gap_ack_block's follow */
292830d754dSRandall Stewart 	/* uint32_t duplicate_tsn's follow */
293830d754dSRandall Stewart }            SCTP_PACKED;
294830d754dSRandall Stewart 
295830d754dSRandall Stewart struct sctp_nr_sack_chunk {
296830d754dSRandall Stewart 	struct sctp_chunkhdr ch;
297830d754dSRandall Stewart 	struct sctp_nr_sack nr_sack;
298830d754dSRandall Stewart }                  SCTP_PACKED;
299830d754dSRandall Stewart 
300830d754dSRandall Stewart 
301f8829a4aSRandall Stewart /* Heartbeat Request (HEARTBEAT) */
302f8829a4aSRandall Stewart struct sctp_heartbeat {
303f8829a4aSRandall Stewart 	struct sctp_heartbeat_info_param hb_info;
30435918f85SRandall Stewart }              SCTP_PACKED;
305f8829a4aSRandall Stewart 
306f8829a4aSRandall Stewart struct sctp_heartbeat_chunk {
307f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
308f8829a4aSRandall Stewart 	struct sctp_heartbeat heartbeat;
30935918f85SRandall Stewart }                    SCTP_PACKED;
310f8829a4aSRandall Stewart 
311f8829a4aSRandall Stewart /* ... used for Heartbeat Ack (HEARTBEAT ACK) */
312f8829a4aSRandall Stewart #define sctp_heartbeat_ack		sctp_heartbeat
313f8829a4aSRandall Stewart #define sctp_heartbeat_ack_chunk	sctp_heartbeat_chunk
314f8829a4aSRandall Stewart 
315f8829a4aSRandall Stewart 
316f8829a4aSRandall Stewart /* Abort Asssociation (ABORT) */
317f8829a4aSRandall Stewart struct sctp_abort_chunk {
318f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
319f8829a4aSRandall Stewart 	/* optional error cause may follow */
32035918f85SRandall Stewart }                SCTP_PACKED;
321f8829a4aSRandall Stewart 
322f8829a4aSRandall Stewart struct sctp_abort_msg {
323f8829a4aSRandall Stewart 	struct sctphdr sh;
324f8829a4aSRandall Stewart 	struct sctp_abort_chunk msg;
32535918f85SRandall Stewart }              SCTP_PACKED;
326f8829a4aSRandall Stewart 
327f8829a4aSRandall Stewart 
328f8829a4aSRandall Stewart /* Shutdown Association (SHUTDOWN) */
329f8829a4aSRandall Stewart struct sctp_shutdown_chunk {
330f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
331f8829a4aSRandall Stewart 	uint32_t cumulative_tsn_ack;
33235918f85SRandall Stewart }                   SCTP_PACKED;
333f8829a4aSRandall Stewart 
334f8829a4aSRandall Stewart 
335f8829a4aSRandall Stewart /* Shutdown Acknowledgment (SHUTDOWN ACK) */
336f8829a4aSRandall Stewart struct sctp_shutdown_ack_chunk {
337f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
33835918f85SRandall Stewart }                       SCTP_PACKED;
339f8829a4aSRandall Stewart 
340f8829a4aSRandall Stewart 
341f8829a4aSRandall Stewart /* Operation Error (ERROR) */
342f8829a4aSRandall Stewart struct sctp_error_chunk {
343f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
344f8829a4aSRandall Stewart 	/* optional error causes follow */
34535918f85SRandall Stewart }                SCTP_PACKED;
346f8829a4aSRandall Stewart 
347f8829a4aSRandall Stewart 
348f8829a4aSRandall Stewart /* Cookie Echo (COOKIE ECHO) */
349f8829a4aSRandall Stewart struct sctp_cookie_echo_chunk {
350f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
351f8829a4aSRandall Stewart 	struct sctp_state_cookie cookie;
35235918f85SRandall Stewart }                      SCTP_PACKED;
353f8829a4aSRandall Stewart 
354f8829a4aSRandall Stewart /* Cookie Acknowledgment (COOKIE ACK) */
355f8829a4aSRandall Stewart struct sctp_cookie_ack_chunk {
356f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
35735918f85SRandall Stewart }                     SCTP_PACKED;
358f8829a4aSRandall Stewart 
359f8829a4aSRandall Stewart /* Explicit Congestion Notification Echo (ECNE) */
360a21779f0SRandall Stewart struct old_sctp_ecne_chunk {
361a21779f0SRandall Stewart 	struct sctp_chunkhdr ch;
362a21779f0SRandall Stewart 	uint32_t tsn;
363a21779f0SRandall Stewart }                   SCTP_PACKED;
364a21779f0SRandall Stewart 
365f8829a4aSRandall Stewart struct sctp_ecne_chunk {
366f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
367f8829a4aSRandall Stewart 	uint32_t tsn;
368a21779f0SRandall Stewart 	uint32_t num_pkts_since_cwr;
36935918f85SRandall Stewart }               SCTP_PACKED;
370f8829a4aSRandall Stewart 
371f8829a4aSRandall Stewart /* Congestion Window Reduced (CWR) */
372f8829a4aSRandall Stewart struct sctp_cwr_chunk {
373f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
374f8829a4aSRandall Stewart 	uint32_t tsn;
37535918f85SRandall Stewart }              SCTP_PACKED;
376f8829a4aSRandall Stewart 
377f8829a4aSRandall Stewart /* Shutdown Complete (SHUTDOWN COMPLETE) */
378f8829a4aSRandall Stewart struct sctp_shutdown_complete_chunk {
379f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
38035918f85SRandall Stewart }                            SCTP_PACKED;
381f8829a4aSRandall Stewart 
382f8829a4aSRandall Stewart /* Oper error holding a stale cookie */
383f8829a4aSRandall Stewart struct sctp_stale_cookie_msg {
384f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* really an error cause */
385f8829a4aSRandall Stewart 	uint32_t time_usec;
38635918f85SRandall Stewart }                     SCTP_PACKED;
387f8829a4aSRandall Stewart 
388f8829a4aSRandall Stewart struct sctp_adaptation_layer_indication {
389f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
390f8829a4aSRandall Stewart 	uint32_t indication;
39135918f85SRandall Stewart }                                SCTP_PACKED;
392f8829a4aSRandall Stewart 
393f8829a4aSRandall Stewart struct sctp_cookie_while_shutting_down {
394f8829a4aSRandall Stewart 	struct sctphdr sh;
395f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
396f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* really an error cause */
39735918f85SRandall Stewart }                               SCTP_PACKED;
398f8829a4aSRandall Stewart 
399f8829a4aSRandall Stewart struct sctp_shutdown_complete_msg {
400f8829a4aSRandall Stewart 	struct sctphdr sh;
401f8829a4aSRandall Stewart 	struct sctp_shutdown_complete_chunk shut_cmp;
40235918f85SRandall Stewart }                          SCTP_PACKED;
403f8829a4aSRandall Stewart 
404f8829a4aSRandall Stewart /*
405f8829a4aSRandall Stewart  * draft-ietf-tsvwg-addip-sctp
406f8829a4aSRandall Stewart  */
407f8829a4aSRandall Stewart /* Address/Stream Configuration Change (ASCONF) */
408f8829a4aSRandall Stewart struct sctp_asconf_chunk {
409f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
410f8829a4aSRandall Stewart 	uint32_t serial_number;
411f8829a4aSRandall Stewart 	/* lookup address parameter (mandatory) */
412f8829a4aSRandall Stewart 	/* asconf parameters follow */
41335918f85SRandall Stewart }                 SCTP_PACKED;
414f8829a4aSRandall Stewart 
415f8829a4aSRandall Stewart /* Address/Stream Configuration Acknowledge (ASCONF ACK) */
416f8829a4aSRandall Stewart struct sctp_asconf_ack_chunk {
417f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
418f8829a4aSRandall Stewart 	uint32_t serial_number;
419f8829a4aSRandall Stewart 	/* asconf parameters follow */
42035918f85SRandall Stewart }                     SCTP_PACKED;
421f8829a4aSRandall Stewart 
422f8829a4aSRandall Stewart /* draft-ietf-tsvwg-prsctp */
423f8829a4aSRandall Stewart /* Forward Cumulative TSN (FORWARD TSN) */
424f8829a4aSRandall Stewart struct sctp_forward_tsn_chunk {
425f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
426f8829a4aSRandall Stewart 	uint32_t new_cumulative_tsn;
427f8829a4aSRandall Stewart 	/* stream/sequence pairs (sctp_strseq) follow */
42835918f85SRandall Stewart }                      SCTP_PACKED;
429f8829a4aSRandall Stewart 
430f8829a4aSRandall Stewart struct sctp_strseq {
431f8829a4aSRandall Stewart 	uint16_t stream;
432f8829a4aSRandall Stewart 	uint16_t sequence;
43335918f85SRandall Stewart }           SCTP_PACKED;
434f8829a4aSRandall Stewart 
435f8829a4aSRandall Stewart struct sctp_forward_tsn_msg {
436f8829a4aSRandall Stewart 	struct sctphdr sh;
437f8829a4aSRandall Stewart 	struct sctp_forward_tsn_chunk msg;
43835918f85SRandall Stewart }                    SCTP_PACKED;
439f8829a4aSRandall Stewart 
440f8829a4aSRandall Stewart /* should be a multiple of 4 - 1 aka 3/7/11 etc. */
441f8829a4aSRandall Stewart 
442f8829a4aSRandall Stewart #define SCTP_NUM_DB_TO_VERIFY 31
443f8829a4aSRandall Stewart 
444f8829a4aSRandall Stewart struct sctp_chunk_desc {
445f8829a4aSRandall Stewart 	uint8_t chunk_type;
446f8829a4aSRandall Stewart 	uint8_t data_bytes[SCTP_NUM_DB_TO_VERIFY];
447f8829a4aSRandall Stewart 	uint32_t tsn_ifany;
44835918f85SRandall Stewart }               SCTP_PACKED;
449f8829a4aSRandall Stewart 
450f8829a4aSRandall Stewart 
451f8829a4aSRandall Stewart struct sctp_pktdrop_chunk {
452f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
453f8829a4aSRandall Stewart 	uint32_t bottle_bw;
454f8829a4aSRandall Stewart 	uint32_t current_onq;
455f8829a4aSRandall Stewart 	uint16_t trunc_len;
456f8829a4aSRandall Stewart 	uint16_t reserved;
457663fdad8SMichael Tuexen 	uint8_t data[];
45835918f85SRandall Stewart }                  SCTP_PACKED;
459f8829a4aSRandall Stewart 
460f8829a4aSRandall Stewart /**********STREAM RESET STUFF ******************/
461f8829a4aSRandall Stewart 
462f8829a4aSRandall Stewart struct sctp_stream_reset_out_request {
463f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
464f8829a4aSRandall Stewart 	uint32_t request_seq;	/* monotonically increasing seq no */
465f8829a4aSRandall Stewart 	uint32_t response_seq;	/* if a response, the resp seq no */
466f8829a4aSRandall Stewart 	uint32_t send_reset_at_tsn;	/* last TSN I assigned outbound */
467663fdad8SMichael Tuexen 	uint16_t list_of_streams[];	/* if not all list of streams */
46835918f85SRandall Stewart }                             SCTP_PACKED;
469f8829a4aSRandall Stewart 
470f8829a4aSRandall Stewart struct sctp_stream_reset_in_request {
471f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
472f8829a4aSRandall Stewart 	uint32_t request_seq;
473663fdad8SMichael Tuexen 	uint16_t list_of_streams[];	/* if not all list of streams */
47435918f85SRandall Stewart }                            SCTP_PACKED;
475f8829a4aSRandall Stewart 
476f8829a4aSRandall Stewart 
477f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_request {
478f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
479f8829a4aSRandall Stewart 	uint32_t request_seq;
48035918f85SRandall Stewart }                             SCTP_PACKED;
481f8829a4aSRandall Stewart 
482f8829a4aSRandall Stewart struct sctp_stream_reset_response {
483f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
484f8829a4aSRandall Stewart 	uint32_t response_seq;	/* if a response, the resp seq no */
485f8829a4aSRandall Stewart 	uint32_t result;
48635918f85SRandall Stewart }                          SCTP_PACKED;
487f8829a4aSRandall Stewart 
488f8829a4aSRandall Stewart struct sctp_stream_reset_response_tsn {
489f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
490f8829a4aSRandall Stewart 	uint32_t response_seq;	/* if a response, the resp seq no */
491f8829a4aSRandall Stewart 	uint32_t result;
492f8829a4aSRandall Stewart 	uint32_t senders_next_tsn;
493f8829a4aSRandall Stewart 	uint32_t receivers_next_tsn;
49435918f85SRandall Stewart }                              SCTP_PACKED;
495f8829a4aSRandall Stewart 
496ea44232bSRandall Stewart struct sctp_stream_reset_add_strm {
497ea44232bSRandall Stewart 	struct sctp_paramhdr ph;
498ea44232bSRandall Stewart 	uint32_t request_seq;
499ea44232bSRandall Stewart 	uint16_t number_of_streams;
500ea44232bSRandall Stewart 	uint16_t reserved;
5018d9d0613SMichael Tuexen }                          SCTP_PACKED;
502f8829a4aSRandall Stewart 
503f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_NOTHING   0x00000000	/* Nothing for me to do */
504f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_PERFORMED 0x00000001	/* Did it */
505f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_DENIED    0x00000002	/* refused to do it */
506f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_ERROR_STR 0x00000003	/* bad Stream no */
507f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_TRY_LATER 0x00000004	/* collision, try again */
508f8829a4aSRandall Stewart #define SCTP_STREAM_RESET_BAD_SEQNO 0x00000005	/* bad str-reset seq no */
509f8829a4aSRandall Stewart 
510f8829a4aSRandall Stewart /*
511f8829a4aSRandall Stewart  * convience structures, note that if you are making a request for specific
512f8829a4aSRandall Stewart  * streams then the request will need to be an overlay structure.
513f8829a4aSRandall Stewart  */
514f8829a4aSRandall Stewart 
515f8829a4aSRandall Stewart struct sctp_stream_reset_out_req {
516f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
517f8829a4aSRandall Stewart 	struct sctp_stream_reset_out_request sr_req;
51835918f85SRandall Stewart }                         SCTP_PACKED;
519f8829a4aSRandall Stewart 
520f8829a4aSRandall Stewart struct sctp_stream_reset_in_req {
521f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
522f8829a4aSRandall Stewart 	struct sctp_stream_reset_in_request sr_req;
52335918f85SRandall Stewart }                        SCTP_PACKED;
524f8829a4aSRandall Stewart 
525f8829a4aSRandall Stewart struct sctp_stream_reset_tsn_req {
526f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
527f8829a4aSRandall Stewart 	struct sctp_stream_reset_tsn_request sr_req;
52835918f85SRandall Stewart }                         SCTP_PACKED;
529f8829a4aSRandall Stewart 
530f8829a4aSRandall Stewart struct sctp_stream_reset_resp {
531f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
532f8829a4aSRandall Stewart 	struct sctp_stream_reset_response sr_resp;
53335918f85SRandall Stewart }                      SCTP_PACKED;
534f8829a4aSRandall Stewart 
535f8829a4aSRandall Stewart /* respone only valid with a TSN request */
536f8829a4aSRandall Stewart struct sctp_stream_reset_resp_tsn {
537f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
538f8829a4aSRandall Stewart 	struct sctp_stream_reset_response_tsn sr_resp;
53935918f85SRandall Stewart }                          SCTP_PACKED;
540f8829a4aSRandall Stewart 
541f8829a4aSRandall Stewart /****************************************************/
542f8829a4aSRandall Stewart 
543f8829a4aSRandall Stewart /*
544f8829a4aSRandall Stewart  * Authenticated chunks support draft-ietf-tsvwg-sctp-auth
545f8829a4aSRandall Stewart  */
546d06c82f1SRandall Stewart 
547d06c82f1SRandall Stewart /* Should we make the max be 32? */
548d06c82f1SRandall Stewart #define SCTP_RANDOM_MAX_SIZE 256
549f8829a4aSRandall Stewart struct sctp_auth_random {
550f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type = 0x8002 */
551663fdad8SMichael Tuexen 	uint8_t random_data[];
55235918f85SRandall Stewart }                SCTP_PACKED;
553f8829a4aSRandall Stewart 
554f8829a4aSRandall Stewart struct sctp_auth_chunk_list {
555f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type = 0x8003 */
556663fdad8SMichael Tuexen 	uint8_t chunk_types[];
55735918f85SRandall Stewart }                    SCTP_PACKED;
558f8829a4aSRandall Stewart 
559f8829a4aSRandall Stewart struct sctp_auth_hmac_algo {
560f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;/* type = 0x8004 */
561663fdad8SMichael Tuexen 	uint16_t hmac_ids[];
56235918f85SRandall Stewart }                   SCTP_PACKED;
563f8829a4aSRandall Stewart 
564f8829a4aSRandall Stewart struct sctp_auth_chunk {
565f8829a4aSRandall Stewart 	struct sctp_chunkhdr ch;
566f8829a4aSRandall Stewart 	uint16_t shared_key_id;
567f8829a4aSRandall Stewart 	uint16_t hmac_id;
568663fdad8SMichael Tuexen 	uint8_t hmac[];
56935918f85SRandall Stewart }               SCTP_PACKED;
570f8829a4aSRandall Stewart 
571f8829a4aSRandall Stewart struct sctp_auth_invalid_hmac {
572f8829a4aSRandall Stewart 	struct sctp_paramhdr ph;
573f8829a4aSRandall Stewart 	uint16_t hmac_id;
574f8829a4aSRandall Stewart 	uint16_t padding;
57535918f85SRandall Stewart }                      SCTP_PACKED;
576f8829a4aSRandall Stewart 
577f8829a4aSRandall Stewart /*
578f8829a4aSRandall Stewart  * we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing
579f8829a4aSRandall Stewart  * pieces. If ENCE is missing we could have a couple of blocks. This way we
580f8829a4aSRandall Stewart  * optimize so we MOST likely can bundle a SACK/ECN with the smallest size
581f8829a4aSRandall Stewart  * data chunk I will split into. We could increase throughput slightly by
582f8829a4aSRandall Stewart  * taking out these two but the  24-sack/8-CWR i.e. 32 bytes I pre-reserve I
583f8829a4aSRandall Stewart  * feel is worth it for now.
584f8829a4aSRandall Stewart  */
585f8829a4aSRandall Stewart #ifndef SCTP_MAX_OVERHEAD
58642551e99SRandall Stewart #ifdef INET6
587f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
588f8829a4aSRandall Stewart 			   sizeof(struct sctphdr) + \
589f8829a4aSRandall Stewart 			   sizeof(struct sctp_ecne_chunk) + \
590f8829a4aSRandall Stewart 			   sizeof(struct sctp_sack_chunk) + \
591f8829a4aSRandall Stewart 			   sizeof(struct ip6_hdr))
592f8829a4aSRandall Stewart 
593f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
594f8829a4aSRandall Stewart 			   sizeof(struct sctphdr) + \
595f8829a4aSRandall Stewart 			   sizeof(struct ip6_hdr))
596f8829a4aSRandall Stewart 
597f8829a4aSRandall Stewart 
598f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
599f8829a4aSRandall Stewart 			   sizeof(struct sctphdr))
600f8829a4aSRandall Stewart 
601f8829a4aSRandall Stewart #else
602f8829a4aSRandall Stewart #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
603f8829a4aSRandall Stewart 			   sizeof(struct sctphdr) + \
604f8829a4aSRandall Stewart 			   sizeof(struct sctp_ecne_chunk) + \
605f8829a4aSRandall Stewart 			   sizeof(struct sctp_sack_chunk) + \
606f8829a4aSRandall Stewart 			   sizeof(struct ip))
607f8829a4aSRandall Stewart 
608f8829a4aSRandall Stewart #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
609f8829a4aSRandall Stewart 			   sizeof(struct sctphdr) + \
610f8829a4aSRandall Stewart 			   sizeof(struct ip))
611f8829a4aSRandall Stewart 
612f8829a4aSRandall Stewart 
613f8829a4aSRandall Stewart #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
614f8829a4aSRandall Stewart 			   sizeof(struct sctphdr))
615f8829a4aSRandall Stewart 
61642551e99SRandall Stewart #endif				/* INET6 */
617f8829a4aSRandall Stewart #endif				/* !SCTP_MAX_OVERHEAD */
618f8829a4aSRandall Stewart 
619f8829a4aSRandall Stewart #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
620f8829a4aSRandall Stewart 			      sizeof(struct sctphdr) + \
621f8829a4aSRandall Stewart 			      sizeof(struct ip))
622f8829a4aSRandall Stewart 
623f8829a4aSRandall Stewart #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
624f8829a4aSRandall Stewart 			      sizeof(struct sctphdr))
625f8829a4aSRandall Stewart 
626b3f1ea41SRandall Stewart #undef SCTP_PACKED
627f8829a4aSRandall Stewart #endif				/* !__sctp_header_h__ */
628