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 0x00040000
272 #define CHUNK_UBIT_SHIFT 18
274 #define CHUNK_BBIT_MASK 0x00020000
275 #define CHUNK_BBIT_SHIFT 17
277 #define CHUNK_EBIT_MASK 0x00010000
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 INBOUND_STREAMS_COUNT 1
517 #define OUTBOUND_STREAMS_COUNT 1
522 * This chunk is used to initiate an SCTP association between two
526 * 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
527 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
528 * | Type = 1 | Chunk Flags | Chunk Length |
529 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
531 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
532 * | Advertised Receiver Window Credit (a_rwnd) |
533 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
534 * | Number of Outbound Streams | Number of Inbound Streams |
535 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
537 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
539 * / Optional/Variable-Length Parameters /
541 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
543 * The INIT chunk contains the following parameters. Unless otherwise
544 * noted, each parameter MUST only be included once in the INIT chunk.
546 * Fixed Parameters Status
547 * ----------------------------------------------
548 * Initiate Tag Mandatory
549 * Advertised Receiver Window Credit Mandatory
550 * Number of Outbound Streams Mandatory
551 * Number of Inbound Streams Mandatory
552 * Initial TSN Mandatory
554 * Variable Parameters Status Type Value
555 * -------------------------------------------------------------
556 * IPv4 Address (Note 1) Optional 5
557 * IPv6 Address (Note 1) Optional 6
558 * Cookie Preservative Optional 9
559 * Reserved for ECN Capable (Note 2) Optional 32768 (0x8000)
560 * Host Name Address (Note 3) Optional 11
561 * Supported Address Types (Note 4) Optional 12
563 * Note 1: The INIT chunks can contain multiple addresses that can be
564 * IPv4 and/or IPv6 in any combination.
566 * Note 2: The ECN Capable field is reserved for future use of Explicit
567 * Congestion Notification.
569 * Note 3: An INIT chunk MUST NOT contain more than one Host Name Address
570 * parameter. Moreover, the sender of the INIT MUST NOT combine any other
571 * address types with the Host Name Address in the INIT. The receiver of
572 * INIT MUST ignore any other address types if the Host Name Address parameter
573 * is present in the received INIT chunk.
575 * Note 4: This parameter, when present, specifies all the address types the
576 * sending endpoint can support. The absence of this parameter indicates that
577 * the sending endpoint can support any address type.
579 * IMPLEMENTATION NOTE: If an INIT chunk is received with known parameters that
580 * are not optional parameters of the INIT chunk, then the receiver SHOULD
581 * process the INIT chunk and send back an INIT ACK. The receiver of the INIT
582 * chunk MAY bundle an ERROR chunk with the COOKIE ACK chunk later.
583 * However, restrictive implementations MAY send back an ABORT chunk in response
584 * to the INIT chunk. The Chunk Flags field in INIT is reserved, and all bits
585 * in it should be set to 0 by the sender and ignored by the receiver.
586 * The sequence of parameters within an INIT can be processed in any order.
590 sctp_header_t sctp_hdr;
591 sctp_chunks_common_hdr_t chunk_hdr;
594 * The receiver of the INIT (the responding end) records the value of
595 * the Initiate Tag parameter.
596 * This value MUST be placed into the Verification Tag field of every
597 * SCTP packet that the receiver of the INIT transmits within this association.
598 * The Initiate Tag is allowed to have any value except 0.
600 * If the value of the Initiate Tag in a received INIT chunk is found
601 * to be 0, the receiver MUST treat it as an error and close the
602 * association by transmitting an ABORT.
604 * The value of the INIT TAG is recommended to be random for security
605 * reasons. A good method is described in https://tools.ietf.org/html/rfc4086
610 * This value represents the dedicated buffer space, in number of bytes,
611 * the sender of the INIT has reserved in association with this window.
612 * During the life of the association, this buffer space SHOULD NOT be
613 * lessened (i.e., dedicated buffers taken away from this association);
614 * however, an endpoint MAY change the value of a_rwnd it sends in SACK
620 * Defines the number of outbound streams the sender of this INIT chunk
621 * wishes to create in this association.
622 * The value of 0 MUST NOT be used.
624 * Note: A receiver of an INIT with the OS value set to 0 SHOULD abort
627 u16 outbound_streams_count;
630 * Defines the maximum number of streams the sender of this INIT
631 * chunk allows the peer end to create in this association.
632 * The value 0 MUST NOT be used.
634 * Note: There is no negotiation of the actual number of streams but
635 * instead the two endpoints will use the min(requested, offered).
637 * Note: A receiver of an INIT with the MIS value of 0 SHOULD abort
640 u16 inboud_streams_count;
643 * Defines the initial TSN that the sender will use.
644 * The valid range is from 0 to 4294967295.
645 * This field MAY be set to the value of the Initiate Tag field.
649 /* The following field allows to have multiple optional fields which are:
650 * - sctp_ipv4_address
651 * - sctp_ipv6_address
652 * - sctp_cookie_preservative
653 * - sctp_hostname_address
654 * - sctp_supported_address_types
656 u32 optional_fields[];
663 * The INIT ACK chunk is used to acknowledge the initiation of an SCTP
664 * association. The parameter part of INIT ACK is formatted similarly to the
667 * It uses two extra variable parameters:
668 * - the State Cookie and
669 * - the Unrecognized Parameter:
673 * 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
674 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
675 * | Type = 2 | Chunk Flags | Chunk Length |
676 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
678 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
679 * | Advertised Receiver Window Credit |
680 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
681 * | Number of Outbound Streams | Number of Inbound Streams |
682 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
684 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
686 * / Optional/Variable-Length Parameters /
688 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
690 typedef sctp_init_chunk_t sctp_init_ack_chunk_t;
697 } sctp_opt_params_hdr_t;
699 #define SHA1_OUTPUT_LENGTH 20
702 * 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
703 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
704 * | Parameter Type | Parameter Length |
705 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
707 * / Parameter Value /
709 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
713 sctp_opt_params_hdr_t param_hdr;
715 unsigned char mac[SHA1_OUTPUT_LENGTH]; /* RFC 2104 */
719 } sctp_state_cookie_param_t;
722 * This chunk is used only during the initialization of an association.
723 * It is sent by the initiator of an association to its peer to complete
724 * the initialization process. This chunk MUST precede any DATA chunk
725 * sent within the association, but MAY be bundled with one or more DATA
726 * chunks in the same packet.
729 * 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
730 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
731 * | Type = 10 |Chunk Flags | Length |
732 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
735 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
739 sctp_header_t sctp_hdr;
740 sctp_chunks_common_hdr_t chunk_hdr;
742 sctp_state_cookie_param_t cookie;
744 } sctp_cookie_echo_chunk_t;
749 * 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
750 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
751 * | Type = 11 |Chunk Flags | Length = 4 |
752 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
756 sctp_header_t sctp_hdr;
757 sctp_chunks_common_hdr_t chunk_hdr;
759 } sctp_cookie_ack_chunk_t;
763 * 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
764 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
765 * | Type = 14 |Chunk Flags | Length = 4 |
766 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
770 sctp_header_t sctp_hdr;
771 sctp_chunks_common_hdr_t chunk_hdr;
773 } sctp_shutdown_complete_chunk_t;
775 /* OPTIONAL or VARIABLE-LENGTH parameters for INIT */
776 #define SCTP_IPV4_ADDRESS_TYPE 5
777 #define SCTP_IPV4_ADDRESS_TYPE_LENGTH 8
778 #define SCTP_IPV6_ADDRESS_TYPE 6
779 #define SCTP_IPV6_ADDRESS_TYPE_LENGTH 20
780 #define SCTP_STATE_COOKIE_TYPE 7
781 #define SCTP_UNRECOGNIZED_TYPE 8
782 #define SCTP_COOKIE_PRESERVATIVE_TYPE 9
783 #define SCTP_COOKIE_PRESERVATIVE_TYPE_LENGTH 8
784 #define SCTP_HOSTNAME_ADDRESS_TYPE 11
785 #define SCTP_SUPPORTED_ADDRESS_TYPES 12
789 * 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
790 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
791 * | Type = 5 | Length = 8 |
792 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
794 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
798 sctp_opt_params_hdr_t param_hdr;
801 * Contains an IPv4 address of the sending endpoint.
802 * It is binary encoded.
804 ip4_address_t address;
806 } sctp_ipv4_addr_param_t;
809 vnet_sctp_set_ipv4_address (sctp_ipv4_addr_param_t * a, ip4_address_t address)
811 a->param_hdr.type = clib_host_to_net_u16 (SCTP_IPV4_ADDRESS_TYPE);
812 a->param_hdr.length = clib_host_to_net_u16 (8);
813 a->address.as_u32 = clib_host_to_net_u32 (address.as_u32);
817 vnet_sctp_get_ipv4_address (sctp_ipv4_addr_param_t * a)
819 return (clib_net_to_host_u32 (a->address.as_u32));
824 * 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
825 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
826 * | Type = 6 | Length = 20 |
827 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
832 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
836 sctp_opt_params_hdr_t param_hdr;
839 * Contains an IPv6 address of the sending endpoint.
840 * It is binary encoded.
842 ip6_address_t address;
844 } sctp_ipv6_addr_param_t;
847 vnet_sctp_set_ipv6_address (sctp_ipv6_addr_param_t * a, ip6_address_t address)
849 a->param_hdr.type = clib_host_to_net_u16 (SCTP_IPV6_ADDRESS_TYPE);
850 a->param_hdr.length = clib_host_to_net_u16 (20);
851 a->address.as_u64[0] = clib_host_to_net_u64 (address.as_u64[0]);
852 a->address.as_u64[1] = clib_host_to_net_u64 (address.as_u64[1]);
855 always_inline ip6_address_t
856 vnet_sctp_get_ipv6_address (sctp_ipv6_addr_param_t * a)
858 ip6_address_t ip6_address;
860 ip6_address.as_u64[0] = clib_net_to_host_u64 (a->address.as_u64[0]);
861 ip6_address.as_u64[1] = clib_net_to_host_u64 (a->address.as_u64[1]);
867 * The sender of the INIT shall use this parameter to suggest to the
868 * receiver of the INIT for a longer life-span of the State Cookie.
872 * 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
873 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
874 * | Type = 9 | Length = 8 |
875 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
876 * | Suggested Cookie Life-Span Increment (msec.) |
877 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
881 sctp_opt_params_hdr_t param_hdr;
884 * This parameter indicates to the receiver how much increment in
885 * milliseconds the sender wishes the receiver to add to its default
888 * This optional parameter should be added to the INIT chunk by the
889 * sender when it reattempts establishing an association with a peer
890 * to which its previous attempt of establishing the association
891 * failed due to a stale cookie operation error. The receiver MAY
892 * choose to ignore the suggested cookie life-span increase for its
893 * own security reasons.
897 } sctp_cookie_preservative_param_t;
900 vnet_sctp_set_cookie_preservative (sctp_cookie_preservative_param_t * c,
903 c->param_hdr.type = clib_host_to_net_u16 (SCTP_COOKIE_PRESERVATIVE_TYPE);
904 c->param_hdr.length = clib_host_to_net_u16 (8);
905 c->life_span_inc = clib_host_to_net_u32 (life_span_inc);
909 vnet_sctp_get_cookie_preservative (sctp_cookie_preservative_param_t * c)
911 return (clib_net_to_host_u32 (c->life_span_inc));
914 #define FQDN_MAX_LENGTH 256
917 * The sender of INIT uses this parameter to pass its Host Name (in
918 * place of its IP addresses) to its peer.
919 * The peer is responsible for resolving the name.
920 * Using this parameter might make it more likely for the association to work
925 * 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
926 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
927 * | Type = 11 | Length |
928 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
931 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
935 sctp_opt_params_hdr_t param_hdr;
939 * This field contains a host name in "host name syntax" per RFC 1123
942 * Note: At least one null terminator is included in the Host Name
943 * string and must be included in the length.
945 char hostname[FQDN_MAX_LENGTH];
947 } sctp_hostname_param_t;
950 vnet_sctp_set_hostname_address (sctp_hostname_param_t * h, char *hostname)
952 h->param_hdr.length = FQDN_MAX_LENGTH;
953 h->param_hdr.type = clib_host_to_net_u16 (SCTP_HOSTNAME_ADDRESS_TYPE);
954 memset (h->hostname, '0', FQDN_MAX_LENGTH);
955 memcpy (h->hostname, hostname, FQDN_MAX_LENGTH);
958 #define MAX_SUPPORTED_ADDRESS_TYPES 3
961 * The sender of INIT uses this parameter to list all the address types
966 * 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
967 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
968 * | Type = 12 | Length |
969 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
970 * | Address Type #1 | Address Type #2 |
971 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
973 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-+-+-+-+-+-++-+-+-+
977 sctp_opt_params_hdr_t param_hdr;
979 u16 address_type[MAX_SUPPORTED_ADDRESS_TYPES];
981 } sctp_supported_addr_types_param_t;
984 vnet_sctp_set_supported_address_types (sctp_supported_addr_types_param_t * s)
986 s->param_hdr.type = clib_host_to_net_u16 (SCTP_SUPPORTED_ADDRESS_TYPES);
987 s->param_hdr.length = 4 /* base = type + length */ +
988 MAX_SUPPORTED_ADDRESS_TYPES * 4; /* each address type is 4 bytes */
990 s->address_type[0] = clib_host_to_net_u16 (SCTP_IPV4_ADDRESS_TYPE);
991 s->address_type[1] = clib_host_to_net_u16 (SCTP_IPV6_ADDRESS_TYPE);
992 s->address_type[2] = clib_host_to_net_u16 (SCTP_HOSTNAME_ADDRESS_TYPE);
996 * Error cause codes to be used for the sctp_error_cause.cause_code field
998 #define INVALID_STREAM_IDENTIFIER 1
999 #define MISSING_MANDATORY_PARAMETER 2
1000 #define STALE_COOKIE_ERROR 3
1001 #define OUT_OF_RESOURCE 4
1002 #define UNRESOLVABLE_ADDRESS 5
1003 #define UNRECOGNIZED_CHUNK_TYPE 6
1004 #define INVALID_MANDATORY_PARAMETER 7
1005 #define UNRECOGNIZED_PARAMETER 8
1006 #define NO_USER_DATA 9
1007 #define COOKIE_RECEIVED_WHILE_SHUTTING_DOWN 10
1008 #define RESTART_OF_ASSOCIATION_WITH_NEW_ADDR 11
1009 #define USER_INITIATED_ABORT 12
1010 #define PROTOCOL_VIOLATION 13
1013 vnet_sctp_set_state_cookie (sctp_state_cookie_param_t * s)
1015 s->param_hdr.type = clib_host_to_net_u16 (SCTP_STATE_COOKIE_TYPE);
1017 /* TODO: length & value to be populated */
1022 sctp_opt_params_hdr_t param_hdr;
1026 } sctp_unrecognized_param_t;
1029 vnet_sctp_set_unrecognized_param (sctp_unrecognized_param_t * u)
1031 u->param_hdr.type = clib_host_to_net_u16 (UNRECOGNIZED_PARAMETER);
1033 /* TODO: length & value to be populated */
1037 * Selective ACK (SACK) chunk
1039 * This chunk is sent to the peer endpoint to acknowledge received DATA
1040 * chunks and to inform the peer endpoint of gaps in the received
1041 * subsequences of DATA chunks as represented by their TSNs.
1045 * 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
1046 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1047 * | Type = 3 |Chunk Flags | Chunk Length |
1048 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1049 * | Cumulative TSN Ack |
1050 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1051 * | Advertised Receiver Window Credit (a_rwnd) |
1052 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1053 * | Number of Gap Ack Blocks = N | Number of Duplicate TSNs = X |
1054 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1055 * | Gap Ack Block #1 Start | Gap Ack Block #1 End |
1056 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1060 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1061 * | Gap Ack Block #N Start | Gap Ack Block #N End |
1062 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1063 * | Duplicate TSN 1 |
1064 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1068 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1069 * | Duplicate TSN X |
1070 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1074 sctp_header_t sctp_hdr;
1075 sctp_chunks_common_hdr_t chunk_hdr;
1077 * This parameter contains the TSN of the last DATA chunk received in
1078 * sequence before a gap. In the case where no DATA chunk has been
1079 * received, this value is set to the peer's Initial TSN minus one.
1081 u32 cumulative_tsn_ack;
1084 * This field indicates the updated receive buffer space in bytes of
1085 * the sender of this SACK.
1090 * Indicates the number of Gap Ack Blocks included in this SACK.
1092 u16 gap_ack_blocks_count;
1095 * This field contains the number of duplicate TSNs the endpoint has
1096 * received. Each duplicate TSN is listed following the Gap Ack Block
1099 u16 duplicate_tsn_count;
1102 * Indicates the Start offset TSN for this Gap Ack Block. To calculate
1103 * the actual TSN number the Cumulative TSN Ack is added to this offset
1104 * number. This calculated TSN identifies the first TSN in this Gap Ack
1105 * Block that has been received.
1107 u16 *gap_ack_block_start;
1110 * Indicates the End offset TSN for this Gap Ack Block. To calculate
1111 * the actual TSN number, the Cumulative TSN Ack is added to this offset
1112 * number. This calculated TSN identifies the TSN of the last DATA chunk
1113 * received in this Gap Ack Block.
1115 u16 *gap_ack_block_end;
1118 * Indicates the number of times a TSN was received in duplicate since
1119 * the last SACK was sent. Every time a receiver gets a duplicate TSN
1120 * (before sending the SACK), it adds it to the list of duplicates.
1121 * The duplicate count is reinitialized to zero after sending each SACK.
1125 } sctp_selective_ack_chunk_t;
1128 vnet_sctp_set_cumulative_tsn_ack (sctp_selective_ack_chunk_t * s,
1129 u32 cumulative_tsn_ack)
1131 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1132 s->cumulative_tsn_ack = clib_host_to_net_u32 (cumulative_tsn_ack);
1136 vnet_sctp_get_cumulative_tsn_ack (sctp_selective_ack_chunk_t * s)
1138 return clib_net_to_host_u32 (s->cumulative_tsn_ack);
1142 vnet_sctp_set_arwnd (sctp_selective_ack_chunk_t * s, u32 a_rwnd)
1144 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1145 s->a_rwnd = clib_host_to_net_u32 (a_rwnd);
1149 vnet_sctp_get_arwnd (sctp_selective_ack_chunk_t * s)
1151 return clib_net_to_host_u32 (s->a_rwnd);
1155 vnet_sctp_set_gap_ack_blocks_count (sctp_selective_ack_chunk_t * s,
1156 u16 gap_ack_blocks_count)
1158 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1159 s->gap_ack_blocks_count = clib_host_to_net_u16 (gap_ack_blocks_count);
1161 if (s->gap_ack_block_start == NULL)
1162 s->gap_ack_block_start =
1163 clib_mem_alloc (sizeof (u16) * gap_ack_blocks_count);
1164 if (s->gap_ack_block_end == NULL)
1165 s->gap_ack_block_end =
1166 clib_mem_alloc (sizeof (u16) * gap_ack_blocks_count);
1170 vnet_sctp_get_gap_ack_blocks_count (sctp_selective_ack_chunk_t * s)
1172 return clib_net_to_host_u32 (s->gap_ack_blocks_count);
1176 vnet_sctp_set_duplicate_tsn_count (sctp_selective_ack_chunk_t * s,
1177 u16 duplicate_tsn_count)
1179 vnet_sctp_set_chunk_type (&s->chunk_hdr, SACK);
1180 s->duplicate_tsn_count = clib_host_to_net_u16 (duplicate_tsn_count);
1184 vnet_sctp_get_duplicate_tsn_count (sctp_selective_ack_chunk_t * s)
1186 return clib_net_to_host_u16 (s->duplicate_tsn_count);
1193 * 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
1194 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1195 * | Heartbeat Info Type=1 | HB Info Length |
1196 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1197 * / Sender-Specific Heartbeat Info /
1199 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1203 sctp_opt_params_hdr_t param_hdr;
1206 * The Sender-Specific Heartbeat Info field should normally include
1207 * information about the sender's current time when this HEARTBEAT
1208 * chunk is sent and the destination transport address to which this
1209 * HEARTBEAT is sent.
1210 * This information is simply reflected back by the receiver in the
1211 * HEARTBEAT ACK message.
1213 * Note also that the HEARTBEAT message is both for reachability
1214 * checking and for path verification.
1215 * When a HEARTBEAT chunk is being used for path verification purposes,
1216 * it MUST hold a 64-bit random nonce.
1220 } sctp_hb_info_param_t;
1223 vnet_sctp_set_heartbeat_info (sctp_hb_info_param_t * h, u64 hb_info,
1226 h->hb_info = clib_host_to_net_u16 (1);
1227 h->param_hdr.length = clib_host_to_net_u16 (hb_info_length);
1228 h->hb_info = clib_host_to_net_u64 (hb_info);
1234 * An endpoint should send this chunk to its peer endpoint to probe the
1235 * reachability of a particular destination transport address defined in
1236 * the present association.
1237 * The parameter field contains the Heartbeat Information, which is a
1238 * variable-length opaque data structure understood only by the sender.
1242 * 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
1243 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1244 * | Type = 4 | Chunk Flags | Heartbeat Length |
1245 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1247 * / Heartbeat Information TLV (Variable-Length) /
1249 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1253 sctp_header_t sctp_hdr;
1254 sctp_chunks_common_hdr_t chunk_hdr;
1255 sctp_hb_info_param_t hb_info;
1257 } sctp_hb_req_chunk_t;
1260 vnet_sctp_set_hb_request_info (sctp_hb_req_chunk_t * h,
1261 sctp_hb_info_param_t * hb_info)
1263 vnet_sctp_set_chunk_type (&h->chunk_hdr, HEARTBEAT);
1264 memcpy (&h->hb_info, hb_info, sizeof (h->hb_info));
1268 * Heartbeat Acknowledgement
1270 * An endpoint should send this chunk to its peer endpoint as a response
1271 * to a HEARTBEAT chunk.
1272 * A HEARTBEAT ACK is always sent to the source IP address of the IP datagram
1273 * containing the HEARTBEAT chunk to which this ack is responding.
1278 * 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
1279 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1280 * | Type = 5 | Chunk Flags | Heartbeat Ack Length |
1281 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1283 * / Heartbeat Information TLV (Variable-Length) /
1285 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1287 typedef sctp_hb_req_chunk_t sctp_hb_ack_chunk_t;
1290 vnet_sctp_set_hb_ack_info (sctp_hb_ack_chunk_t * h,
1291 sctp_hb_info_param_t * hb_info)
1293 vnet_sctp_set_chunk_type (&h->chunk_hdr, HEARTBEAT_ACK);
1294 memcpy (&h->hb_info, hb_info, sizeof (h->hb_info));
1302 * 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
1303 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1304 * | Cause Code | Cause Length |
1305 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1306 * / Cause-Specific Information /
1308 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1313 sctp_opt_params_hdr_t param_hdr;
1316 } sctp_err_cause_param_t;
1320 * An end-point sends this chunk to its peer end-point to notify it of
1321 * certain error conditions. It contains one or more error causes.
1322 * An Operation Error is not considered fatal in and of itself, but may be
1323 * used with an ABORT chunk to report a fatal condition. It has the
1324 * following parameters:
1327 * 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
1328 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1329 * | Type = 9 | Chunk Flags | Length |
1330 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1332 * / one or more Error Causes /
1334 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1338 sctp_header_t sctp_hdr;
1339 sctp_chunks_common_hdr_t chunk_hdr;
1340 sctp_err_cause_param_t err_causes[];
1342 } sctp_operation_error_t;
1345 * Abort Association (ABORT)
1347 * The ABORT chunk is sent to the peer of an association to close the
1348 * association. The ABORT chunk may contain Cause Parameters to inform
1349 * the receiver about the reason of the abort. DATA chunks MUST NOT be
1350 * bundled with ABORT. Control chunks (except for INIT, INIT ACK, and
1351 * SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be
1352 * placed before the ABORT in the SCTP packet or they will be ignored by
1355 * If an endpoint receives an ABORT with a format error or no TCB is
1356 * found, it MUST silently discard it. Moreover, under any
1357 * circumstances, an endpoint that receives an ABORT MUST NOT respond to
1358 * that ABORT by sending an ABORT of its own.
1362 * 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
1363 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1364 * | Type = 6 |Reserved |T| Length |
1365 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1367 * / zero or more Error Causes /
1369 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1373 sctp_header_t sctp_hdr;
1374 sctp_chunks_common_hdr_t chunk_hdr;
1375 sctp_err_cause_param_t err_causes[];
1377 } sctp_abort_chunk_t;
1380 vnet_sctp_set_tbit (sctp_abort_chunk_t * a)
1382 vnet_sctp_set_chunk_type (&a->chunk_hdr, ABORT);
1383 // a->chunk_hdr.flags = clib_host_to_net_u16 (1);
1387 vnet_sctp_unset_tbit (sctp_abort_chunk_t * a)
1389 vnet_sctp_set_chunk_type (&a->chunk_hdr, ABORT);
1390 // a->chunk_hdr.flags = clib_host_to_net_u16 (0);
1394 * Shutdown Association (SHUTDOWN)
1396 * An endpoint in an association MUST use this chunk to initiate a
1397 * graceful close of the association with its peer.
1401 * 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
1402 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1403 * | Type = 7 | Chunk Flags | Length = 8 |
1404 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1405 * | Cumulative TSN Ack |
1406 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1410 sctp_header_t sctp_hdr;
1411 sctp_chunks_common_hdr_t chunk_hdr;
1413 * This parameter contains the TSN of the last chunk received in
1414 * sequence before any gaps.
1416 * Note: Since the SHUTDOWN message does not contain Gap Ack Blocks,
1417 * it cannot be used to acknowledge TSNs received out of order. In a
1418 * SACK, lack of Gap Ack Blocks that were previously included
1419 * indicates that the data receiver reneged on the associated DATA
1420 * chunks. Since SHUTDOWN does not contain Gap Ack Blocks, the
1421 * receiver of the SHUTDOWN shouldn't interpret the lack of a Gap Ack
1422 * Block as a renege.
1424 u32 cumulative_tsn_ack;
1426 } sctp_shutdown_association_chunk_t;
1429 vnet_sctp_set_tsn_last_received_chunk (sctp_shutdown_association_chunk_t * s,
1432 vnet_sctp_set_chunk_type (&s->chunk_hdr, SHUTDOWN);
1433 s->cumulative_tsn_ack = clib_host_to_net_u32 (tsn_last_chunk);
1437 * Shutdown Acknowledgement (SHUTDOWN ACK)
1439 * This chunk MUST be used to acknowledge the receipt of the SHUTDOWN
1440 * chunk at the completion of the shutdown process.
1444 * 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
1445 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1446 * | Type = 8 |Chunk Flags | Length = 4 |
1447 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1451 sctp_header_t sctp_hdr;
1452 sctp_chunks_common_hdr_t chunk_hdr;
1453 } sctp_shutdown_ack_chunk_t;
1456 vnet_sctp_fill_shutdown_ack (sctp_shutdown_ack_chunk_t * s)
1458 vnet_sctp_set_chunk_type (&s->chunk_hdr, SHUTDOWN_ACK);
1459 vnet_sctp_set_chunk_length (&s->chunk_hdr, 4);
1462 #endif /* included_vnet_sctp_packet_h */
1465 * fd.io coding-style-patch-verification: ON
1468 * eval: (c-set-style "gnu")