2 * Copyright (c) 2017 SUSE LLC.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef included_vnet_sctp_packet_h
16 #define included_vnet_sctp_packet_h
20 #include <vnet/ip/ip4_packet.h>
21 #include <vnet/ip/ip6_packet.h>
25 * https://tools.ietf.org/html/rfc4960
30 * 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
31 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 * | Source Port Number | Destination Port Number |
33 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 * | Verification Tag |
35 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * This is the SCTP sender's port number. It can be used by the
43 * receiver in combination with the source IP address, the SCTP
44 * destination port, and possibly the destination IP address to
45 * identify the association to which this packet belongs.
46 * The port number 0 MUST NOT be used.
51 * This is the SCTP port number to which this packet is destined.
52 * The receiving host will use this port number to de-multiplex the
53 * SCTP packet to the correct receiving endpoint/application.
54 * The port number 0 MUST NOT be used.
59 * The receiver of this packet uses the Verification Tag to validate
60 * the sender of this SCTP packet. On transmit, the value of this
61 * Verification Tag MUST be set to the value of the Initiate Tag
62 * received from the peer endpoint during the association
63 * initialization, with the following exceptions:
64 * - A packet containing an INIT chunk MUST have a zero Verification
66 * - A packet containing a SHUTDOWN COMPLETE chunk with the T bit
67 * set MUST have the Verification Tag copied from the packet with
68 * the SHUTDOWN ACK chunk.
69 * - A packet containing an ABORT chunk may have the verification tag
70 * copied from the packet that caused the ABORT to be sent.
71 * An INIT chunk MUST be the only chunk in the SCTP packet carrying it.
76 * This field contains the checksum of this SCTP packet.
77 * SCTP uses the CRC32c algorithm.
84 vnet_set_sctp_src_port (sctp_header_t * h, u16 src_port)
86 h->src_port = clib_host_to_net_u16 (src_port);
90 vnet_get_sctp_src_port (sctp_header_t * h)
92 return (clib_net_to_host_u16 (h->src_port));
96 vnet_set_sctp_dst_port (sctp_header_t * h, u16 dst_port)
98 h->dst_port = clib_host_to_net_u16 (dst_port);
102 vnet_get_sctp_dst_port (sctp_header_t * h)
104 return (clib_net_to_host_u16 (h->dst_port));
108 vnet_set_sctp_verification_tag (sctp_header_t * h, u32 verification_tag)
110 h->verification_tag = clib_host_to_net_u32 (verification_tag);
114 vnet_get_sctp_verification_tag (sctp_header_t * h)
116 return (clib_net_to_host_u32 (h->verification_tag));
120 vnet_set_sctp_checksum (sctp_header_t * h, u32 checksum)
122 h->checksum = clib_host_to_net_u32 (checksum);
126 vnet_get_sctp_checksum (sctp_header_t * h)
128 return (clib_net_to_host_u32 (h->checksum));
132 * Multiple chunks can be bundled into one SCTP packet up to the MTU
133 * size, except for the INIT, INIT ACK, and SHUTDOWN COMPLETE chunks.
134 * These chunks MUST NOT be bundled with any other chunk in a packet.
138 * 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
139 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
147 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
172 * 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
173 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
174 * | Chunk Type | Chunk Flags | Chunk Length |
175 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
180 * This field identifies the type of information contained in the
181 * Chunk Value field. It takes a value from 0 to 254.
182 * The value of 255 is reserved for future use as an extension field.
184 * The values of Chunk Types are defined as follows:
185 * ID Value Chunk Type
187 * 0 - Payload Data (DATA)
188 * 1 - Initiation (INIT)
189 * 2 - Initiation Acknowledgement (INIT ACK)
190 * 3 - Selective Acknowledgement (SACK)
191 * 4 - Heartbeat Request (HEARTBEAT)
192 * 5 - Heartbeat Acknowledgement (HEARTBEAT ACK)
194 * 7 - Shutdown (SHUTDOWN)
195 * 8 - Shutdown Acknowledgement (SHUTDOWN ACK)
196 * 9 - Operation Error (ERROR)
197 * 10 - State Cookie (COOKIE ECHO)
198 * 11 - Cookie Acknowledgement (COOKIE ACK)
199 * 12 - Reserved for Explicit Congestion Notification Echo (ECNE)
200 * 13 - Reserved for Congestion Window Reduced (CWR)
201 * 14 - Shutdown Complete (SHUTDOWN COMPLETE)
202 * 15 to 62 - available
203 * 63 - reserved for IETF-defined Chunk Extensions
204 * 64 to 126 - available
205 * 127 - reserved for IETF-defined Chunk Extensions
206 * 128 to 190 - available
207 * 191 - reserved for IETF-defined Chunk Extensions
208 * 192 to 254 - available
209 * 255 - reserved for IETF-defined Chunk Extensions
211 * Chunk Types are encoded such that the highest-order 2 bits specify
212 * the action that must be taken if the processing endpoint does not
213 * recognize the Chunk Type.
214 * 00 - Stop processing this SCTP packet and discard it, do not
215 * process any further chunks within it.
216 * 01 - Stop processing this SCTP packet and discard it, do not
217 * process any further chunks within it, and report the
218 * unrecognized chunk in an 'Unrecognized Chunk Type'.
219 * 10 - Skip this chunk and continue processing.
220 * 11 - Skip this chunk and continue processing, but report in an
221 * ERROR chunk using the 'Unrecognized Chunk Type' cause of error.
223 * Note: The ECNE and CWR chunk types are reserved for future use of
224 * Explicit Congestion Notification (ECN);
229 * The usage of these bits depends on the Chunk type as given by the
230 * Chunk Type field. Unless otherwise specified, they are set to 0 on
231 * transmit and are ignored on receipt.
236 * This value represents the size of the chunk in bytes, including
237 * the Chunk Type, Chunk Flags, Chunk Length, and Chunk Value fields.
238 * Therefore, if the Chunk Value field is zero-length, the Length
239 * field will be set to 4.
240 * The Chunk Length field does not count any chunk padding.
241 * Chunks (including Type, Length, and Value fields) are padded out
242 * by the sender with all zero bytes to be a multiple of 4 bytes
243 * long. This padding MUST NOT be more than 3 bytes in total. The
244 * Chunk Length value does not include terminating padding of the
245 * chunk. However, it does include padding of any variable-length
246 * parameter except the last parameter in the chunk. The receiver
247 * MUST ignore the padding.
249 * Note: A robust implementation should accept the chunk whether or
250 * not the final padding has been included in the Chunk Length.
256 } sctp_chunks_common_hdr_t;
261 sctp_chunks_common_hdr_t common_hdr;
265 #define CHUNK_TYPE_MASK 0xFF000000
266 #define CHUNK_TYPE_SHIFT 24
268 #define CHUNK_FLAGS_MASK 0x00FF0000
269 #define CHUNK_FLAGS_SHIFT 16
271 #define CHUNK_UBIT_MASK 0x000F0000
272 #define CHUNK_UBIT_SHIFT 18
274 #define CHUNK_BBIT_MASK 0x000F0000
275 #define CHUNK_BBIT_SHIFT 17
277 #define CHUNK_EBIT_MASK 0x000F0000
278 #define CHUNK_EBIT_SHIFT 16
280 #define CHUNK_LENGTH_MASK 0x0000FFFF
281 #define CHUNK_LENGTH_SHIFT 0
284 vnet_sctp_common_hdr_params_host_to_net (sctp_chunks_common_hdr_t * h)
286 h->params = clib_host_to_net_u32 (h->params);
290 vnet_sctp_common_hdr_params_net_to_host (sctp_chunks_common_hdr_t * h)
292 h->params = clib_net_to_host_u32 (h->params);
296 vnet_sctp_set_ubit (sctp_chunks_common_hdr_t * h)
298 h->params &= ~(CHUNK_UBIT_MASK);
299 h->params |= (1 << CHUNK_UBIT_SHIFT) & CHUNK_UBIT_MASK;
303 vnet_sctp_get_ubit (sctp_chunks_common_hdr_t * h)
305 return ((h->params & CHUNK_UBIT_MASK) >> CHUNK_UBIT_SHIFT);
309 vnet_sctp_set_bbit (sctp_chunks_common_hdr_t * h)
311 h->params &= ~(CHUNK_BBIT_MASK);
312 h->params |= (1 << CHUNK_BBIT_SHIFT) & CHUNK_BBIT_MASK;
316 vnet_sctp_get_bbit (sctp_chunks_common_hdr_t * h)
318 return ((h->params & CHUNK_BBIT_MASK) >> CHUNK_BBIT_SHIFT);
322 vnet_sctp_set_ebit (sctp_chunks_common_hdr_t * h)
324 h->params &= ~(CHUNK_EBIT_MASK);
325 h->params |= (1 << CHUNK_EBIT_SHIFT) & CHUNK_EBIT_MASK;
329 vnet_sctp_get_ebit (sctp_chunks_common_hdr_t * h)
331 return ((h->params & CHUNK_EBIT_MASK) >> CHUNK_EBIT_SHIFT);
335 vnet_sctp_set_chunk_type (sctp_chunks_common_hdr_t * h, sctp_chunk_type t)
337 h->params &= ~(CHUNK_TYPE_MASK);
338 h->params |= (t << CHUNK_TYPE_SHIFT) & CHUNK_TYPE_MASK;
342 vnet_sctp_get_chunk_type (sctp_chunks_common_hdr_t * h)
344 return ((h->params & CHUNK_TYPE_MASK) >> CHUNK_TYPE_SHIFT);
348 vnet_sctp_set_chunk_length (sctp_chunks_common_hdr_t * h, u16 length)
350 h->params &= ~(CHUNK_LENGTH_MASK);
351 h->params |= (length << CHUNK_LENGTH_SHIFT) & CHUNK_LENGTH_MASK;
355 vnet_sctp_get_chunk_length (sctp_chunks_common_hdr_t * h)
357 return ((h->params & CHUNK_LENGTH_MASK) >> CHUNK_LENGTH_SHIFT);
364 * 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
365 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
366 * | Type = 0 | Reserved|U|B|E| Length |
367 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
370 * | Stream Identifier S | Stream Sequence Number n |
371 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
372 * | Payload Protocol Identifier |
373 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
375 * / User Data (seq n of Stream S) /
377 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
381 sctp_header_t sctp_hdr;
385 * -- Reserved (5 bits): all 0s
389 * Length (16 bits): This field indicates the length of the DATA chunk in
390 * bytes from the beginning of the type field to the end of the User Data
391 * field excluding any padding.
392 * A DATA chunk with one byte of user data will have Length set to 17
393 * (indicating 17 bytes). A DATA chunk with a User Data field of length L
394 * will have the Length field set to (16 + L) (indicating 16+L bytes) where
395 * L MUST be greater than 0.
399 * Fragment Description Table:
402 * ============================================================
403 * | 1 0 | First piece of a fragmented user message |
404 * +----------------------------------------------------------+
405 * | 0 0 | Middle piece of a fragmented user message |
406 * +----------------------------------------------------------+
407 * | 0 1 | Last piece of a fragmented user message |
408 * +----------------------------------------------------------+
409 * | 1 1 | Unfragmented message |
410 * ============================================================
412 sctp_chunks_common_hdr_t chunk_hdr;
415 * This value represents the TSN for this DATA chunk.
416 * The valid range of TSN is from 0 to 4294967295 (2**32 - 1).
417 * TSN wraps back to 0 after reaching 4294967295.
422 * Identifies the stream to which the following user data belongs.
427 * This value represents the Stream Sequence Number of the following user data
428 * within the stream S. Valid range is 0 to 65535.
429 * When a user message is fragmented by SCTP for transport, the same Stream
430 * Sequence Number MUST be carried in each of the fragments of the message.
435 * This value represents an application (or upper layer) specified protocol
436 * identifier. This value is passed to SCTP by its upper layer and sent to its
437 * peer. This identifier is not used by SCTP but can be used by certain network
438 * entities, as well as by the peer application, to identify the type of
439 * information being carried in this DATA chunk. This field must be sent even
440 * in fragmented DATA chunks (to make sure it is available for agents in the
441 * middle of the network). Note that this field is NOT touched by an SCTP
442 * implementation; therefore, its byte order is NOT necessarily big endian.
443 * The upper layer is responsible for any byte order conversions to this field.
444 * The value 0 indicates that no application identifier is specified by the
445 * upper layer for this payload data.
450 * This is the payload user data. The implementation MUST pad the end of the
451 * data to a 4-byte boundary with all-zero bytes. Any padding MUST NOT be
452 * included in the Length field. A sender MUST never add more than 3 bytes of
457 } sctp_payload_data_chunk_t;
460 vnet_sctp_set_tsn (sctp_payload_data_chunk_t * p, u32 tsn)
462 p->tsn = clib_host_to_net_u32 (tsn);
466 vnet_sctp_get_tsn (sctp_payload_data_chunk_t * p)
468 return (clib_net_to_host_u32 (p->tsn));
472 vnet_sctp_set_stream_id (sctp_payload_data_chunk_t * p, u16 stream_id)
474 p->stream_id = clib_host_to_net_u16 (stream_id);
478 vnet_sctp_get_stream_id (sctp_payload_data_chunk_t * p)
480 return (clib_net_to_host_u16 (p->stream_id));
484 vnet_sctp_set_stream_seq (sctp_payload_data_chunk_t * p, u16 stream_seq)
486 p->stream_seq = clib_host_to_net_u16 (stream_seq);
490 vnet_sctp_get_stream_seq (sctp_payload_data_chunk_t * p)
492 return (clib_net_to_host_u16 (p->stream_seq));
496 vnet_sctp_set_payload_id (sctp_payload_data_chunk_t * p, u32 payload_id)
498 p->payload_id = clib_host_to_net_u32 (payload_id);
502 vnet_sctp_get_payload_id (sctp_payload_data_chunk_t * p)
504 return (clib_net_to_host_u32 (p->payload_id));
508 vnet_sctp_calculate_padding (u16 base_length)
510 if (base_length % 4 == 0)
513 return (4 - base_length % 4);
516 #define DEFAULT_A_RWND 1480
517 #define INBOUND_STREAMS_COUNT 1
518 #define OUTBOUND_STREAMS_COUNT 1
523 * This chunk is used to initiate an SCTP association between two
527 * 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
528 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
529 * | Type = 1 | Chunk Flags | Chunk Length |
530 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
532 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
533 * | Advertised Receiver Window Credit (a_rwnd) |
534 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
535 * | Number of Outbound Streams | Number of Inbound Streams |
536 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
538 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
540 * / Optional/Variable-Length Parameters /
542 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
544 * The INIT chunk contains the following parameters. Unless otherwise
545 * noted, each parameter MUST only be included once in the INIT chunk.
547 * Fixed Parameters Status
548 * ----------------------------------------------
549 * Initiate Tag Mandatory
550 * Advertised Receiver Window Credit Mandatory
551 * Number of Outbound Streams Mandatory
552 * Number of Inbound Streams Mandatory
553 * Initial TSN Mandatory
555 * Variable Parameters Status Type Value
556 * -------------------------------------------------------------
557 * IPv4 Address (Note 1) Optional 5
558 * IPv6 Address (Note 1) Optional 6
559 * Cookie Preservative Optional 9
560 * Reserved for ECN Capable (Note 2) Optional 32768 (0x8000)
561 * Host Name Address (Note 3) Optional 11
562 * Supported Address Types (Note 4) Optional 12
564 * Note 1: The INIT chunks can contain multiple addresses that can be
565 * IPv4 and/or IPv6 in any combination.
567 * Note 2: The ECN Capable field is reserved for future use of Explicit
568 * Congestion Notification.
570 * Note 3: An INIT chunk MUST NOT contain more than one Host Name Address
571 * parameter. Moreover, the sender of the INIT MUST NOT combine any other
572 * address types with the Host Name Address in the INIT. The receiver of
573 * INIT MUST ignore any other address types if the Host Name Address parameter
574 * is present in the received INIT chunk.
576 * Note 4: This parameter, when present, specifies all the address types the
577 * sending endpoint can support. The absence of this parameter indicates that
578 * the sending endpoint can support any address type.
580 * IMPLEMENTATION NOTE: If an INIT chunk is received with known parameters that
581 * are not optional parameters of the INIT chunk, then the receiver SHOULD
582 * process the INIT chunk and send back an INIT ACK. The receiver of the INIT
583 * chunk MAY bundle an ERROR chunk with the COOKIE ACK chunk later.
584 * However, restrictive implementations MAY send back an ABORT chunk in response
585 * to the INIT chunk. The Chunk Flags field in INIT is reserved, and all bits
586 * in it should be set to 0 by the sender and ignored by the receiver.
587 * The sequence of parameters within an INIT can be processed in any order.
591 sctp_header_t sctp_hdr;
592 sctp_chunks_common_hdr_t chunk_hdr;
595 * The receiver of the INIT (the responding end) records the value of
596 * the Initiate Tag parameter.
597 * This value MUST be placed into the Verification Tag field of every
598 * SCTP packet that the receiver of the INIT transmits within this association.
599 * The Initiate Tag is allowed to have any value except 0.
601 * If the value of the Initiate Tag in a received INIT chunk is found
602 * to be 0, the receiver MUST treat it as an error and close the
603 * association by transmitting an ABORT.
605 * The value of the INIT TAG is recommended to be random for security
606 * reasons. A good method is described in https://tools.ietf.org/html/rfc4086
611 * This value represents the dedicated buffer space, in number of bytes,
612 * the sender of the INIT has reserved in association with this window.
613 * During the life of the association, this buffer space SHOULD NOT be
614 * lessened (i.e., dedicated buffers taken away from this association);
615 * however, an endpoint MAY change the value of a_rwnd it sends in SACK
621 * Defines the number of outbound streams the sender of this INIT chunk
622 * wishes to create in this association.
623 * The value of 0 MUST NOT be used.
625 * Note: A receiver of an INIT with the OS value set to 0 SHOULD abort
628 u16 outbound_streams_count;
631 * Defines the maximum number of streams the sender of this INIT
632 * chunk allows the peer end to create in this association.
633 * The value 0 MUST NOT be used.
635 * Note: There is no negotiation of the actual number of streams but
636 * instead the two endpoints will use the min(requested, offered).
638 * Note: A receiver of an INIT with the MIS value of 0 SHOULD abort
641 u16 inboud_streams_count;
644 * Defines the initial TSN that the sender will use.
645 * The valid range is from 0 to 4294967295.
646 * This field MAY be set to the value of the Initiate Tag field.
650 /* The following field allows to have multiple optional fields which are:
651 * - sctp_ipv4_address
652 * - sctp_ipv6_address
653 * - sctp_cookie_preservative
654 * - sctp_hostname_address
655 * - sctp_supported_address_types
657 u32 optional_fields[];
664 * The INIT ACK chunk is used to acknowledge the initiation of an SCTP
665 * association. The parameter part of INIT ACK is formatted similarly to the
668 * It uses two extra variable parameters:
669 * - the State Cookie and
670 * - the Unrecognized Parameter:
674 * 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
675 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
676 * | Type = 2 | Chunk Flags | Chunk Length |
677 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
679 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
680 * | Advertised Receiver Window Credit |
681 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
682 * | Number of Outbound Streams | Number of Inbound Streams |
683 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
685 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
687 * / Optional/Variable-Length Parameters /
689 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
691 typedef sctp_init_chunk_t sctp_init_ack_chunk_t;
698 } sctp_opt_params_hdr_t;
700 #define SHA1_OUTPUT_LENGTH 20
703 * 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
704 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
705 * | Parameter Type | Parameter Length |
706 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
708 * / Parameter Value /
710 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
714 sctp_opt_params_hdr_t param_hdr;
716 unsigned char mac[SHA1_OUTPUT_LENGTH]; /* RFC 2104 */
720 } sctp_state_cookie_param_t;
723 * This chunk is used only during the initialization of an association.
724 * It is sent by the initiator of an association to its peer to complete
725 * the initialization process. This chunk MUST precede any DATA chunk
726 * sent within the association, but MAY be bundled with one or more DATA
727 * chunks in the same packet.
730 * 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
731 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
732 * | Type = 10 |Chunk Flags | Length |
733 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
736 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
740 sctp_header_t sctp_hdr;
741 sctp_chunks_common_hdr_t chunk_hdr;
743 sctp_state_cookie_param_t cookie;
745 } sctp_cookie_echo_chunk_t;
750 * 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
751 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
752 * | Type = 11 |Chunk Flags | Length = 4 |
753 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
757 sctp_header_t sctp_hdr;
758 sctp_chunks_common_hdr_t chunk_hdr;
760 } sctp_cookie_ack_chunk_t;
764 * 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
765 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
766 * | Type = 14 |Chunk Flags | Length = 4 |
767 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
771 sctp_header_t sctp_hdr;
772 sctp_chunks_common_hdr_t chunk_hdr;
774 } sctp_shutdown_complete_chunk_t;
776 /* OPTIONAL or VARIABLE-LENGTH parameters for INIT */
777 #define SCTP_IPV4_ADDRESS_TYPE 5
778 #define SCTP_IPV4_ADDRESS_TYPE_LENGTH 8
779 #define SCTP_IPV6_ADDRESS_TYPE 6
780 #define SCTP_IPV6_ADDRESS_TYPE_LENGTH 20
781 #define SCTP_STATE_COOKIE_TYPE 7
782 #define SCTP_UNRECOGNIZED_TYPE 8
783 #define SCTP_COOKIE_PRESERVATIVE_TYPE 9
784 #define SCTP_COOKIE_PRESERVATIVE_TYPE_LENGTH 8
785 #define SCTP_HOSTNAME_ADDRESS_TYPE 11
786 #define SCTP_SUPPORTED_ADDRESS_TYPES 12
790 * 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
791 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
792 * | Type = 5 | Length = 8 |
793 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
795 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
799 sctp_opt_params_hdr_t param_hdr;
802 * Contains an IPv4 address of the sending endpoint.
803 * It is binary encoded.
805 ip4_address_t address;
807 } sctp_ipv4_addr_param_t;
810 vnet_sctp_set_ipv4_address (sctp_ipv4_addr_param_t * a, ip4_address_t address)
812 a->param_hdr.type = clib_host_to_net_u16 (SCTP_IPV4_ADDRESS_TYPE);
813 a->param_hdr.length = clib_host_to_net_u16 (8);
814 a->address.as_u32 = clib_host_to_net_u32 (address.as_u32);
818 vnet_sctp_get_ipv4_address (sctp_ipv4_addr_param_t * a)
820 return (clib_net_to_host_u32 (a->address.as_u32));
825 * 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
826 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
827 * | Type = 6 | Length = 20 |
828 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
833 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
837 sctp_opt_params_hdr_t param_hdr;
840 * Contains an IPv6 address of the sending endpoint.
841 * It is binary encoded.
843 ip6_address_t address;
845 } sctp_ipv6_addr_param_t;
848 vnet_sctp_set_ipv6_address (sctp_ipv6_addr_param_t * a, ip6_address_t address)
850 a->param_hdr.type = clib_host_to_net_u16 (SCTP_IPV6_ADDRESS_TYPE);
851 a->param_hdr.length = clib_host_to_net_u16 (20);
852 a->address.as_u64[0] = clib_host_to_net_u64 (address.as_u64[0]);
853 a->address.as_u64[1] = clib_host_to_net_u64 (address.as_u64[1]);
856 always_inline ip6_address_t
857 vnet_sctp_get_ipv6_address (sctp_ipv6_addr_param_t * a)
859 ip6_address_t ip6_address;
861 ip6_address.as_u64[0] = clib_net_to_host_u64 (a->address.as_u64[0]);
862 ip6_address.as_u64[1] = clib_net_to_host_u64 (a->address.as_u64[1]);
868 * The sender of the INIT shall use this parameter to suggest to the
869 * receiver of the INIT for a longer life-span of the State Cookie.
873 * 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
874 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
875 * | Type = 9 | Length = 8 |
876 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
877 * | Suggested Cookie Life-Span Increment (msec.) |
878 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
882 sctp_opt_params_hdr_t param_hdr;
885 * This parameter indicates to the receiver how much increment in
886 * milliseconds the sender wishes the receiver to add to its default
889 * This optional parameter should be added to the INIT chunk by the
890 * sender when it reattempts establishing an association with a peer
891 * to which its previous attempt of establishing the association
892 * failed due to a stale cookie operation error. The receiver MAY
893 * choose to ignore the suggested cookie life-span increase for its
894 * own security reasons.
898 } sctp_cookie_preservative_param_t;
901 vnet_sctp_set_cookie_preservative (sctp_cookie_preservative_param_t * c,
904 c->param_hdr.type = clib_host_to_net_u16 (SCTP_COOKIE_PRESERVATIVE_TYPE);
905 c->param_hdr.length = clib_host_to_net_u16 (8);
906 c->life_span_inc = clib_host_to_net_u32 (life_span_inc);
910 vnet_sctp_get_cookie_preservative (sctp_cookie_preservative_param_t * c)
912 return (clib_net_to_host_u32 (c->life_span_inc));
915 #define FQDN_MAX_LENGTH 256
918 * The sender of INIT uses this parameter to pass its Host Name (in
919 * place of its IP addresses) to its peer.
920 * The peer is responsible for resolving the name.
921 * Using this parameter might make it more likely for the association to work
926 * 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
927 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
928 * | Type = 11 | Length |
929 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
932 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
936 sctp_opt_params_hdr_t param_hdr;
940 * This field contains a host name in "host name syntax" per RFC 1123
943 * Note: At least one null terminator is included in the Host Name
944 * string and must be included in the length.
946 char hostname[FQDN_MAX_LENGTH];
948 } sctp_hostname_param_t;
951 vnet_sctp_set_hostname_address (sctp_hostname_param_t * h, char *hostname)
953 h->param_hdr.length = FQDN_MAX_LENGTH;
954 h->param_hdr.type = clib_host_to_net_u16 (SCTP_HOSTNAME_ADDRESS_TYPE);
955 memset (h->hostname, '0', FQDN_MAX_LENGTH);
956 memcpy (h->hostname, hostname, FQDN_MAX_LENGTH);
959 #define MAX_SUPPORTED_ADDRESS_TYPES 3
962 * The sender of INIT uses this parameter to list all the address types
967 * 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
968 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
969 * | Type = 12 | Length |
970 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
971 * | Address Type #1 | Address Type #2 |
972 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
974 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+
978 sctp_opt_params_hdr_t param_hdr;
980 u16 address_type[MAX_SUPPORTED_ADDRESS_TYPES];
982 } sctp_supported_addr_types_param_t;
985 vnet_sctp_set_supported_address_types (sctp_supported_addr_types_param_t * s)
987 s->param_hdr.type = clib_host_to_net_u16 (SCTP_SUPPORTED_ADDRESS_TYPES);
988 s->param_hdr.length = 4 /* base = type + length */ +
989 MAX_SUPPORTED_ADDRESS_TYPES * 4; /* each address type is 4 bytes */
991 s->address_type[0] = clib_host_to_net_u16 (SCTP_IPV4_ADDRESS_TYPE);
992 s->address_type[1] = clib_host_to_net_u16 (SCTP_IPV6_ADDRESS_TYPE);
993 s->address_type[2] = clib_host_to_net_u16 (SCTP_HOSTNAME_ADDRESS_TYPE);
997 * Error cause codes to be used for the sctp_error_cause.cause_code field
999 #define INVALID_STREAM_IDENTIFIER 1
1000 #define MISSING_MANDATORY_PARAMETER 2
1001 #define STALE_COOKIE_ERROR 3
1002 #define OUT_OF_RESOURCE 4
1003 #define UNRESOLVABLE_ADDRESS 5
1004 #define UNRECOGNIZED_CHUNK_TYPE 6
1005 #define INVALID_MANDATORY_PARAMETER 7
1006 #define UNRECOGNIZED_PARAMETER 8
1007 #define NO_USER_DATA 9
1008 #define COOKIE_RECEIVED_WHILE_SHUTTING_DOWN 10
1009 #define RESTART_OF_ASSOCIATION_WITH_NEW_ADDR 11
1010 #define USER_INITIATED_ABORT 12
1011 #define PROTOCOL_VIOLATION 13
1014 vnet_sctp_set_state_cookie (sctp_state_cookie_param_t * s)
1016 s->param_hdr.type = clib_host_to_net_u16 (SCTP_STATE_COOKIE_TYPE);
1018 /* TODO: length & value to be populated */
1023 sctp_opt_params_hdr_t param_hdr;
1027 } sctp_unrecognized_param_t;
1030 vnet_sctp_set_unrecognized_param (sctp_unrecognized_param_t * u)
1032 u->param_hdr.type = clib_host_to_net_u16 (UNRECOGNIZED_PARAMETER);
1034 /* TODO: length & value to be populated */
1038 * Selective ACK (SACK) chunk
1040 * This chunk is sent to the peer endpoint to acknowledge received DATA
1041 * chunks and to inform the peer endpoint of gaps in the received
1042 * subsequences of DATA chunks as represented by their TSNs.
1046 * 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
1047 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1048 * | Type = 3 |Chunk Flags | Chunk Length |
1049 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1050 * | Cumulative TSN Ack |
1051 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1052 * | Advertised Receiver Window Credit (a_rwnd) |
1053 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1054 * | Number of Gap Ack Blocks = N | Number of Duplicate TSNs = X |
1055 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1056 * | Gap Ack Block #1 Start | Gap Ack Block #1 End |
1057 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1061 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1062 * | Gap Ack Block #N Start | Gap Ack Block #N End |
1063 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1064 * | Duplicate TSN 1 |
1065 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1069 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1070 * | Duplicate TSN X |
1071 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1075 sctp_header_t sctp_hdr;
1076 sctp_chunks_common_hdr_t chunk_hdr;
1078 * This parameter contains the TSN of the last DATA chunk received in
1079 * sequence before a gap. In the case where no DATA chunk has been
1080 * received, this value is set to the peer's Initial TSN minus one.
1082 u32 cumulative_tsn_ack;
1085 * This field indicates the updated receive buffer space in bytes of
1086 * the sender of this SACK.
1091 * Indicates the number of Gap Ack Blocks included in this SACK.
1093 u16 gap_ack_blocks_count;
1096 * This field contains the number of duplicate TSNs the endpoint has
1097 * received. Each duplicate TSN is listed following the Gap Ack Block
1100 u16 duplicate_tsn_count;
1103 * Indicates the Start offset TSN for this Gap Ack Block. To calculate
1104 * the actual TSN number the Cumulative TSN Ack is added to this offset
1105 * number. This calculated TSN identifies the first TSN in this Gap Ack
1106 * Block that has been received.
1108 u16 *gap_ack_block_start;
1111 * Indicates the End offset TSN for this Gap Ack Block. To calculate
1112 * the actual TSN number, the Cumulative TSN Ack is added to this offset
1113 * number. This calculated TSN identifies the TSN of the last DATA chunk
1114 * received in this Gap Ack Block.
1116 u16 *gap_ack_block_end;
1119 * Indicates the number of times a TSN was received in duplicate since
1120 * the last SACK was sent. Every time a receiver gets a duplicate TSN
1121 * (before sending the SACK), it adds it to the list of duplicates.
1122 * The duplicate count is reinitialized to zero after sending each SACK.
1126 } sctp_selective_ack_chunk_t;
1129 vnet_sctp_set_cumulative_tsn_ack (sctp_selective_ack_chunk_t * s,
1130 u32 cumulative_tsn_ack)
1132 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1133 s->cumulative_tsn_ack = clib_host_to_net_u32 (cumulative_tsn_ack);
1137 vnet_sctp_get_cumulative_tsn_ack (sctp_selective_ack_chunk_t * s)
1139 return clib_net_to_host_u32 (s->cumulative_tsn_ack);
1143 vnet_sctp_set_arwnd (sctp_selective_ack_chunk_t * s, u32 a_rwnd)
1145 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1146 s->a_rwnd = clib_host_to_net_u32 (a_rwnd);
1150 vnet_sctp_get_arwnd (sctp_selective_ack_chunk_t * s)
1152 return clib_net_to_host_u32 (s->a_rwnd);
1156 vnet_sctp_set_gap_ack_blocks_count (sctp_selective_ack_chunk_t * s,
1157 u16 gap_ack_blocks_count)
1159 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1160 s->gap_ack_blocks_count = clib_host_to_net_u16 (gap_ack_blocks_count);
1162 if (s->gap_ack_block_start == NULL)
1163 s->gap_ack_block_start =
1164 clib_mem_alloc (sizeof (u16) * gap_ack_blocks_count);
1165 if (s->gap_ack_block_end == NULL)
1166 s->gap_ack_block_end =
1167 clib_mem_alloc (sizeof (u16) * gap_ack_blocks_count);
1171 vnet_sctp_get_gap_ack_blocks_count (sctp_selective_ack_chunk_t * s)
1173 return clib_net_to_host_u32 (s->gap_ack_blocks_count);
1177 vnet_sctp_set_duplicate_tsn_count (sctp_selective_ack_chunk_t * s,
1178 u16 duplicate_tsn_count)
1180 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1181 s->duplicate_tsn_count = clib_host_to_net_u16 (duplicate_tsn_count);
1185 vnet_sctp_get_duplicate_tsn_count (sctp_selective_ack_chunk_t * s)
1187 return clib_net_to_host_u16 (s->duplicate_tsn_count);
1194 * 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
1195 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1196 * | Heartbeat Info Type=1 | HB Info Length |
1197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1198 * / Sender-Specific Heartbeat Info /
1200 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1204 sctp_opt_params_hdr_t param_hdr;
1207 * The Sender-Specific Heartbeat Info field should normally include
1208 * information about the sender's current time when this HEARTBEAT
1209 * chunk is sent and the destination transport address to which this
1210 * HEARTBEAT is sent.
1211 * This information is simply reflected back by the receiver in the
1212 * HEARTBEAT ACK message.
1214 * Note also that the HEARTBEAT message is both for reachability
1215 * checking and for path verification.
1216 * When a HEARTBEAT chunk is being used for path verification purposes,
1217 * it MUST hold a 64-bit random nonce.
1221 } sctp_hb_info_param_t;
1224 vnet_sctp_set_heartbeat_info (sctp_hb_info_param_t * h, u64 hb_info,
1227 h->hb_info = clib_host_to_net_u16 (1);
1228 h->param_hdr.length = clib_host_to_net_u16 (hb_info_length);
1229 h->hb_info = clib_host_to_net_u64 (hb_info);
1235 * An endpoint should send this chunk to its peer endpoint to probe the
1236 * reachability of a particular destination transport address defined in
1237 * the present association.
1238 * The parameter field contains the Heartbeat Information, which is a
1239 * variable-length opaque data structure understood only by the sender.
1243 * 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
1244 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1245 * | Type = 4 | Chunk Flags | Heartbeat Length |
1246 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1248 * / Heartbeat Information TLV (Variable-Length) /
1250 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1254 sctp_header_t sctp_hdr;
1255 sctp_chunks_common_hdr_t chunk_hdr;
1256 sctp_hb_info_param_t hb_info;
1258 } sctp_hb_req_chunk_t;
1261 vnet_sctp_set_hb_request_info (sctp_hb_req_chunk_t * h,
1262 sctp_hb_info_param_t * hb_info)
1264 vnet_sctp_set_chunk_type (&h->chunk_hdr, HEARTBEAT);
1265 memcpy (&h->hb_info, hb_info, sizeof (h->hb_info));
1269 * Heartbeat Acknowledgement
1271 * An endpoint should send this chunk to its peer endpoint as a response
1272 * to a HEARTBEAT chunk.
1273 * A HEARTBEAT ACK is always sent to the source IP address of the IP datagram
1274 * containing the HEARTBEAT chunk to which this ack is responding.
1279 * 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
1280 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1281 * | Type = 5 | Chunk Flags | Heartbeat Ack Length |
1282 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1284 * / Heartbeat Information TLV (Variable-Length) /
1286 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1288 typedef sctp_hb_req_chunk_t sctp_hb_ack_chunk_t;
1291 vnet_sctp_set_hb_ack_info (sctp_hb_ack_chunk_t * h,
1292 sctp_hb_info_param_t * hb_info)
1294 vnet_sctp_set_chunk_type (&h->chunk_hdr, HEARTBEAT_ACK);
1295 memcpy (&h->hb_info, hb_info, sizeof (h->hb_info));
1303 * 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
1304 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1305 * | Cause Code | Cause Length |
1306 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1307 * / Cause-Specific Information /
1309 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1314 sctp_opt_params_hdr_t param_hdr;
1317 } sctp_err_cause_param_t;
1320 * Abort Association (ABORT)
1322 * The ABORT chunk is sent to the peer of an association to close the
1323 * association. The ABORT chunk may contain Cause Parameters to inform
1324 * the receiver about the reason of the abort. DATA chunks MUST NOT be
1325 * bundled with ABORT. Control chunks (except for INIT, INIT ACK, and
1326 * SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be
1327 * placed before the ABORT in the SCTP packet or they will be ignored by
1330 * If an endpoint receives an ABORT with a format error or no TCB is
1331 * found, it MUST silently discard it. Moreover, under any
1332 * circumstances, an endpoint that receives an ABORT MUST NOT respond to
1333 * that ABORT by sending an ABORT of its own.
1337 * 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
1338 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1339 * | Type = 6 |Reserved |T| Length |
1340 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1342 * / zero or more Error Causes /
1344 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1348 sctp_header_t sctp_hdr;
1349 sctp_chunks_common_hdr_t chunk_hdr;
1350 sctp_err_cause_param_t err_causes[];
1352 } sctp_abort_chunk_t;
1355 vnet_sctp_set_tbit (sctp_abort_chunk_t * a)
1357 vnet_sctp_set_chunk_type (&a->chunk_hdr, ABORT);
1358 // a->chunk_hdr.flags = clib_host_to_net_u16 (1);
1362 vnet_sctp_unset_tbit (sctp_abort_chunk_t * a)
1364 vnet_sctp_set_chunk_type (&a->chunk_hdr, ABORT);
1365 // a->chunk_hdr.flags = clib_host_to_net_u16 (0);
1369 * Shutdown Association (SHUTDOWN)
1371 * An endpoint in an association MUST use this chunk to initiate a
1372 * graceful close of the association with its peer.
1376 * 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
1377 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1378 * | Type = 7 | Chunk Flags | Length = 8 |
1379 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1380 * | Cumulative TSN Ack |
1381 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1385 sctp_header_t sctp_hdr;
1386 sctp_chunks_common_hdr_t chunk_hdr;
1388 * This parameter contains the TSN of the last chunk received in
1389 * sequence before any gaps.
1391 * Note: Since the SHUTDOWN message does not contain Gap Ack Blocks,
1392 * it cannot be used to acknowledge TSNs received out of order. In a
1393 * SACK, lack of Gap Ack Blocks that were previously included
1394 * indicates that the data receiver reneged on the associated DATA
1395 * chunks. Since SHUTDOWN does not contain Gap Ack Blocks, the
1396 * receiver of the SHUTDOWN shouldn't interpret the lack of a Gap Ack
1397 * Block as a renege.
1399 u32 cumulative_tsn_ack;
1401 } sctp_shutdown_association_chunk_t;
1404 vnet_sctp_set_tsn_last_received_chunk (sctp_shutdown_association_chunk_t * s,
1407 vnet_sctp_set_chunk_type (&s->chunk_hdr, SHUTDOWN);
1408 s->cumulative_tsn_ack = clib_host_to_net_u32 (tsn_last_chunk);
1412 * Shutdown Acknowledgement (SHUTDOWN ACK)
1414 * This chunk MUST be used to acknowledge the receipt of the SHUTDOWN
1415 * chunk at the completion of the shutdown process.
1419 * 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
1420 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1421 * | Type = 8 |Chunk Flags | Length = 4 |
1422 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1426 sctp_header_t sctp_hdr;
1427 sctp_chunks_common_hdr_t chunk_hdr;
1428 } sctp_shutdown_ack_chunk_t;
1431 vnet_sctp_fill_shutdown_ack (sctp_shutdown_ack_chunk_t * s)
1433 vnet_sctp_set_chunk_type (&s->chunk_hdr, SHUTDOWN_ACK);
1434 vnet_sctp_set_chunk_length (&s->chunk_hdr, 4);
1437 #endif /* included_vnet_sctp_packet_h */
1440 * fd.io coding-style-patch-verification: ON
1443 * eval: (c-set-style "gnu")