FreeBSD kernel IPv4 code
sctp_header.h
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * a) Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * b) Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the distribution.
17 *
18 * c) Neither the name of Cisco Systems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD$");
37
38#ifndef _NETINET_SCTP_HEADER_H_
39#define _NETINET_SCTP_HEADER_H_
40
41#include <sys/time.h>
42#include <netinet/sctp.h>
44
45#define SCTP_PACKED __attribute__((packed))
46
47/*
48 * Parameter structures
49 */
51 struct sctp_paramhdr ph; /* type=SCTP_IPV4_PARAM_TYPE, len=8 */
52 uint32_t addr; /* IPV4 address */
54
55#define SCTP_V6_ADDR_BYTES 16
56
58 struct sctp_paramhdr ph; /* type=SCTP_IPV6_PARAM_TYPE, len=20 */
59 uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */
61
62/* Cookie Preservative */
64 struct sctp_paramhdr ph; /* type=SCTP_COOKIE_PRESERVE, len=8 */
65 uint32_t time; /* time in ms to extend cookie */
67
68#define SCTP_ARRAY_MIN_LEN 1
69/* Host Name Address */
71 struct sctp_paramhdr ph; /* type=SCTP_HOSTNAME_ADDRESS */
72 char name[SCTP_ARRAY_MIN_LEN]; /* host name */
74
75/*
76 * This is the maximum padded size of a s-a-p
77 * so paramheadr + 3 address types (6 bytes) + 2 byte pad = 12
78 */
79#define SCTP_MAX_ADDR_PARAMS_SIZE 12
80/* supported address type */
82 struct sctp_paramhdr ph; /* type=SCTP_SUPPORTED_ADDRTYPE */
83 uint16_t addr_type[2]; /* array of supported address types */
85
86/* heartbeat info parameter */
95 /* make sure that this structure is 4 byte aligned */
99
100/* draft-ietf-tsvwg-prsctp */
101/* PR-SCTP supported parameter */
105
106/* draft-ietf-tsvwg-addip-sctp */
107struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */
108 struct sctp_paramhdr ph; /* a SCTP parameter header */
109 uint32_t correlation_id; /* correlation id for this param */
111
112struct sctp_asconf_addr_param { /* an ASCONF address parameter */
113 struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
114 struct sctp_ipv6addr_param addrp; /* max storage size */
116
117struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */
118 struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
122
123struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */
124 struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
125 struct sctp_ipv4addr_param addrp; /* max storage size */
127
128#define SCTP_MAX_SUPPORTED_EXT 256
129
131 struct sctp_paramhdr ph; /* type = 0x8008 len = x */
134
135/*
136 * Structures for DATA chunks
137 */
138struct sctp_data {
143 /* user data follows */
145
148 struct sctp_data dp;
150
154 uint16_t reserved; /* Where does the SSN go? */
156 union {
158 uint32_t fsn; /* Fragment Sequence Number */
160 /* user data follows */
162
167
168/*
169 * Structures for the control chunks
170 */
171
172/* Initiate (INIT)/Initiate Ack (INIT ACK) */
173struct sctp_init {
174 uint32_t initiate_tag; /* initiate tag */
175 uint32_t a_rwnd; /* a_rwnd */
179 /* optional param's follow */
181#define SCTP_IDENTIFICATION_SIZE 16
182#define SCTP_ADDRESS_SIZE 4
183#define SCTP_RESERVE_SPACE 6
184/* state cookie header */
185struct sctp_state_cookie { /* this is our definition... */
187 struct timeval time_entered; /* the time I built cookie */
188 uint32_t cookie_life; /* life I will award this cookie */
189 uint32_t tie_tag_my_vtag; /* my tag in old association */
190
191 uint32_t tie_tag_peer_vtag; /* peers tag in old association */
192 uint32_t peers_vtag; /* peers tag in INIT (for quick ref) */
193
194 uint32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */
195 uint32_t address[SCTP_ADDRESS_SIZE]; /* 4 ints/128 bits */
196 uint32_t addr_type; /* address type */
197 uint32_t laddress[SCTP_ADDRESS_SIZE]; /* my local from address */
198 uint32_t laddr_type; /* my local from address type */
199 uint32_t scope_id; /* v6 scope id for link-locals */
200
201 uint16_t peerport; /* port address of the peer in the INIT */
202 uint16_t myport; /* my port address used in the INIT */
203 uint8_t ipv4_addr_legal; /* Are V4 addr legal? */
204 uint8_t ipv6_addr_legal; /* Are V6 addr legal? */
205 uint8_t local_scope; /* IPv6 local scope flag */
206 uint8_t site_scope; /* IPv6 site scope flag */
207
208 uint8_t ipv4_scope; /* IPv4 private addr scope */
209 uint8_t loopback_scope; /* loopback scope information */
210 uint8_t reserved[SCTP_RESERVE_SPACE]; /* Align to 64 bits */
211 /*
212 * at the end is tacked on the INIT chunk and the INIT-ACK chunk
213 * (minus the cookie).
214 */
216
217/* state cookie parameter */
222
227
229 struct sctphdr sh;
232
233/* ... used for both INIT and INIT ACK */
234#define sctp_init_ack sctp_init
235#define sctp_init_ack_chunk sctp_init_chunk
236#define sctp_init_ack_msg sctp_init_msg
237
238/* Selective Ack (SACK) */
240 uint16_t start; /* Gap Ack block start */
241 uint16_t end; /* Gap Ack block end */
243
244struct sctp_sack {
245 uint32_t cum_tsn_ack; /* cumulative TSN Ack */
246 uint32_t a_rwnd; /* updated a_rwnd of sender */
247 uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */
248 uint16_t num_dup_tsns; /* number of duplicate TSNs */
249 /* struct sctp_gap_ack_block's follow */
250 /* uint32_t duplicate_tsn's follow */
252
257
259 uint32_t cum_tsn_ack; /* cumulative TSN Ack */
260 uint32_t a_rwnd; /* updated a_rwnd of sender */
261 uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */
262 uint16_t num_nr_gap_ack_blks; /* number of NR Gap Ack blocks */
263 uint16_t num_dup_tsns; /* number of duplicate TSNs */
264 uint16_t reserved; /* not currently used */
265 /* struct sctp_gap_ack_block's follow */
266 /* uint32_t duplicate_tsn's follow */
268
273
274/* Heartbeat Request (HEARTBEAT) */
278
283
284/* ... used for Heartbeat Ack (HEARTBEAT ACK) */
285#define sctp_heartbeat_ack sctp_heartbeat
286#define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk
287
288/* Abort Asssociation (ABORT) */
291 /* optional error cause may follow */
293
295 struct sctphdr sh;
298
299/* Shutdown Association (SHUTDOWN) */
304
305/* Shutdown Acknowledgment (SHUTDOWN ACK) */
309
310/* Operation Error (ERROR) */
313 /* optional error causes follow */
315
316/* Cookie Echo (COOKIE ECHO) */
321
322/* Cookie Acknowledgment (COOKIE ACK) */
326
327/* Explicit Congestion Notification Echo (ECNE) */
332
338
339/* Congestion Window Reduced (CWR) */
344
345/* Shutdown Complete (SHUTDOWN COMPLETE) */
349
354
355/*
356 * draft-ietf-tsvwg-addip-sctp
357 */
358/* Address/Stream Configuration Change (ASCONF) */
362 /* lookup address parameter (mandatory) */
363 /* asconf parameters follow */
365
366/* Address/Stream Configuration Acknowledge (ASCONF ACK) */
370 /* asconf parameters follow */
372
373/* draft-ietf-tsvwg-prsctp */
374/* Forward Cumulative TSN (FORWARD TSN) */
378 /* stream/sequence pairs (sctp_strseq) follow */
380
385
390};
391
393 struct sctphdr sh;
396
397/* should be a multiple of 4 - 1 aka 3/7/11 etc. */
398
399#define SCTP_NUM_DB_TO_VERIFY 31
400
406
415
416/**********STREAM RESET STUFF ******************/
417
422
425 uint32_t request_seq; /* monotonically increasing seq no */
426 uint32_t response_seq; /* if a response, the resp seq no */
427 uint32_t send_reset_at_tsn; /* last TSN I assigned outbound */
428 uint16_t list_of_streams[]; /* if not all list of streams */
430
434 uint16_t list_of_streams[]; /* if not all list of streams */
436
441
444 uint32_t response_seq; /* if a response, the resp seq no */
447
450 uint32_t response_seq; /* if a response, the resp seq no */
455
462
463#define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */
464#define SCTP_STREAM_RESET_RESULT_PERFORMED 0x00000001
465#define SCTP_STREAM_RESET_RESULT_DENIED 0x00000002
466#define SCTP_STREAM_RESET_RESULT_ERR__WRONG_SSN 0x00000003 /* XXX: unused */
467#define SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS 0x00000004
468#define SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO 0x00000005
469#define SCTP_STREAM_RESET_RESULT_IN_PROGRESS 0x00000006 /* XXX: unused */
470
471/*
472 * convience structures, note that if you are making a request for specific
473 * streams then the request will need to be an overlay structure.
474 */
475
480
485
486/* respone only valid with a TSN request */
491
492/****************************************************/
493
494/*
495 * Authenticated chunks support draft-ietf-tsvwg-sctp-auth
496 */
497
498/* Should we make the max be 32? */
499#define SCTP_RANDOM_MAX_SIZE 256
501 struct sctp_paramhdr ph; /* type = 0x8002 */
504
506 struct sctp_paramhdr ph; /* type = 0x8003 */
509
511 struct sctp_paramhdr ph; /* type = 0x8004 */
514
521
522/*
523 * we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing
524 * pieces. If ENCE is missing we could have a couple of blocks. This way we
525 * optimize so we MOST likely can bundle a SACK/ECN with the smallest size
526 * data chunk I will split into. We could increase throughput slightly by
527 * taking out these two but the 24-sack/8-CWR i.e. 32 bytes I pre-reserve I
528 * feel is worth it for now.
529 */
530#ifndef SCTP_MAX_OVERHEAD
531#ifdef INET6
532#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
533 sizeof(struct sctphdr) + \
534 sizeof(struct sctp_ecne_chunk) + \
535 sizeof(struct sctp_sack_chunk) + \
536 sizeof(struct ip6_hdr))
537
538#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
539 sizeof(struct sctphdr) + \
540 sizeof(struct ip6_hdr))
541
542#define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
543 sizeof(struct sctphdr))
544
545#else
546#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
547 sizeof(struct sctphdr) + \
548 sizeof(struct sctp_ecne_chunk) + \
549 sizeof(struct sctp_sack_chunk) + \
550 sizeof(struct ip))
551
552#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
553 sizeof(struct sctphdr) + \
554 sizeof(struct ip))
555
556#define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
557 sizeof(struct sctphdr))
558
559#endif /* INET6 */
560#endif /* !SCTP_MAX_OVERHEAD */
561
562#define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
563 sizeof(struct sctphdr) + \
564 sizeof(struct ip))
565
566#define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
567 sizeof(struct sctphdr))
568
569#undef SCTP_PACKED
570#endif /* !__sctp_header_h__ */
__uint32_t uint32_t
Definition: in.h:62
__uint16_t uint16_t
Definition: in.h:57
__uint8_t uint8_t
Definition: in.h:52
#define SCTP_ADDRMAX
#define SCTP_V6_ADDR_BYTES
Definition: sctp_header.h:55
#define SCTP_RESERVE_SPACE
Definition: sctp_header.h:183
#define SCTP_NUM_DB_TO_VERIFY
Definition: sctp_header.h:399
#define SCTP_IDENTIFICATION_SIZE
Definition: sctp_header.h:181
#define SCTP_PACKED
Definition: sctp_header.h:45
#define SCTP_ARRAY_MIN_LEN
Definition: sctp_header.h:68
__FBSDID("$FreeBSD$")
#define SCTP_ADDRESS_SIZE
Definition: sctp_header.h:182
struct sctp_chunkhdr ch
Definition: sctp_header.h:329
struct sctp_chunkhdr ch
Definition: sctp_header.h:290
struct sctp_abort_chunk msg
Definition: sctp_header.h:296
struct sctphdr sh
Definition: sctp_header.h:295
struct sctp_chunkhdr ch
Definition: sctp_header.h:368
struct sctp_ipv6addr_param addrp
Definition: sctp_header.h:114
struct sctp_asconf_paramhdr aph
Definition: sctp_header.h:113
struct sctp_asconf_paramhdr aph
Definition: sctp_header.h:124
struct sctp_ipv4addr_param addrp
Definition: sctp_header.h:125
struct sctp_chunkhdr ch
Definition: sctp_header.h:360
uint32_t serial_number
Definition: sctp_header.h:361
struct sctp_paramhdr ph
Definition: sctp_header.h:108
struct sctp_asconf_paramhdr aph
Definition: sctp_header.h:118
struct sctp_paramhdr ph
Definition: sctp_header.h:506
uint16_t shared_key_id
Definition: sctp_header.h:517
uint16_t hmac_id
Definition: sctp_header.h:518
uint8_t hmac[]
Definition: sctp_header.h:519
struct sctp_chunkhdr ch
Definition: sctp_header.h:516
uint16_t hmac_ids[]
Definition: sctp_header.h:512
struct sctp_paramhdr ph
Definition: sctp_header.h:511
struct sctp_paramhdr ph
Definition: sctp_header.h:501
uint8_t random_data[]
Definition: sctp_header.h:502
uint32_t tsn_ifany
Definition: sctp_header.h:404
uint8_t data_bytes[SCTP_NUM_DB_TO_VERIFY]
Definition: sctp_header.h:403
uint8_t chunk_type
Definition: sctp_header.h:402
uint32_t tsn
Definition: sctp_header.h:342
struct sctp_chunkhdr ch
Definition: sctp_header.h:341
struct sctp_data dp
Definition: sctp_header.h:148
struct sctp_chunkhdr ch
Definition: sctp_header.h:147
uint16_t sid
Definition: sctp_header.h:140
uint16_t ssn
Definition: sctp_header.h:141
uint32_t tsn
Definition: sctp_header.h:139
uint32_t ppid
Definition: sctp_header.h:142
uint32_t num_pkts_since_cwr
Definition: sctp_header.h:336
struct sctp_chunkhdr ch
Definition: sctp_header.h:334
struct sctp_chunkhdr ch
Definition: sctp_header.h:312
struct sctp_chunkhdr ch
Definition: sctp_header.h:376
struct sctphdr sh
Definition: sctp_header.h:393
struct sctp_forward_tsn_chunk msg
Definition: sctp_header.h:394
struct sctp_heartbeat heartbeat
Definition: sctp_header.h:281
struct sctp_chunkhdr ch
Definition: sctp_header.h:280
char address[SCTP_ADDRMAX]
Definition: sctp_header.h:97
struct sctp_paramhdr ph
Definition: sctp_header.h:88
struct sctp_heartbeat_info_param hb_info
Definition: sctp_header.h:276
struct sctp_paramhdr ph
Definition: sctp_header.h:71
char name[SCTP_ARRAY_MIN_LEN]
Definition: sctp_header.h:72
struct sctp_idata dp
Definition: sctp_header.h:165
struct sctp_chunkhdr ch
Definition: sctp_header.h:164
uint32_t ppid
Definition: sctp_header.h:157
uint32_t mid
Definition: sctp_header.h:155
uint16_t sid
Definition: sctp_header.h:153
union sctp_idata::@32 ppid_fsn
uint16_t reserved
Definition: sctp_header.h:154
uint32_t fsn
Definition: sctp_header.h:158
uint32_t tsn
Definition: sctp_header.h:152
struct sctp_chunkhdr ch
Definition: sctp_header.h:224
struct sctp_init init
Definition: sctp_header.h:225
struct sctphdr sh
Definition: sctp_header.h:229
struct sctp_init_chunk msg
Definition: sctp_header.h:230
uint32_t initial_tsn
Definition: sctp_header.h:178
uint16_t num_inbound_streams
Definition: sctp_header.h:177
uint16_t num_outbound_streams
Definition: sctp_header.h:176
uint32_t a_rwnd
Definition: sctp_header.h:175
uint32_t initiate_tag
Definition: sctp_header.h:174
struct sctp_paramhdr ph
Definition: sctp_header.h:51
uint8_t addr[SCTP_V6_ADDR_BYTES]
Definition: sctp_header.h:59
struct sctp_paramhdr ph
Definition: sctp_header.h:58
struct sctp_chunkhdr ch
Definition: sctp_header.h:270
struct sctp_nr_sack nr_sack
Definition: sctp_header.h:271
uint32_t cum_tsn_ack
Definition: sctp_header.h:259
uint32_t a_rwnd
Definition: sctp_header.h:260
uint16_t num_nr_gap_ack_blks
Definition: sctp_header.h:262
uint16_t reserved
Definition: sctp_header.h:264
uint16_t num_dup_tsns
Definition: sctp_header.h:263
uint16_t num_gap_ack_blks
Definition: sctp_header.h:261
struct sctp_chunkhdr ch
Definition: sctp_header.h:408
uint32_t current_onq
Definition: sctp_header.h:410
struct sctp_paramhdr ph
Definition: sctp_header.h:103
struct sctp_sack sack
Definition: sctp_header.h:255
struct sctp_chunkhdr ch
Definition: sctp_header.h:254
uint16_t num_dup_tsns
Definition: sctp_header.h:248
uint32_t a_rwnd
Definition: sctp_header.h:246
uint16_t num_gap_ack_blks
Definition: sctp_header.h:247
uint32_t cum_tsn_ack
Definition: sctp_header.h:245
struct sctp_chunkhdr ch
Definition: sctp_header.h:307
struct sctp_chunkhdr ch
Definition: sctp_header.h:301
uint32_t cumulative_tsn_ack
Definition: sctp_header.h:302
struct sctp_chunkhdr ch
Definition: sctp_header.h:347
struct sctp_paramhdr ph
Definition: sctp_header.h:457
struct sctp_paramhdr ph
Definition: sctp_header.h:432
struct sctp_paramhdr ph
Definition: sctp_header.h:424
struct sctp_paramhdr ph
Definition: sctp_header.h:419
struct sctp_chunkhdr ch
Definition: sctp_header.h:488
struct sctp_stream_reset_response_tsn sr_resp
Definition: sctp_header.h:489
struct sctp_chunkhdr ch
Definition: sctp_header.h:482
struct sctp_stream_reset_response sr_resp
Definition: sctp_header.h:483
struct sctp_paramhdr ph
Definition: sctp_header.h:449
struct sctp_paramhdr ph
Definition: sctp_header.h:443
struct sctp_stream_reset_tsn_request sr_req
Definition: sctp_header.h:478
struct sctp_chunkhdr ch
Definition: sctp_header.h:477
struct sctp_paramhdr ph
Definition: sctp_header.h:438
uint16_t flags
Definition: sctp_header.h:388
uint16_t ssn
Definition: sctp_header.h:383
uint16_t sid
Definition: sctp_header.h:382
struct sctp_paramhdr ph
Definition: sctp_header.h:82
Definition: sctp.h:48