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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
171 * 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
172 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
173 * | Chunk Type | Chunk Flags | Chunk Length |
174 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
179 * This field identifies the type of information contained in the
180 * Chunk Value field. It takes a value from 0 to 254.
181 * The value of 255 is reserved for future use as an extension field.
183 * The values of Chunk Types are defined as follows:
184 * ID Value Chunk Type
186 * 0 - Payload Data (DATA)
187 * 1 - Initiation (INIT)
188 * 2 - Initiation Acknowledgement (INIT ACK)
189 * 3 - Selective Acknowledgement (SACK)
190 * 4 - Heartbeat Request (HEARTBEAT)
191 * 5 - Heartbeat Acknowledgement (HEARTBEAT ACK)
193 * 7 - Shutdown (SHUTDOWN)
194 * 8 - Shutdown Acknowledgement (SHUTDOWN ACK)
195 * 9 - Operation Error (ERROR)
196 * 10 - State Cookie (COOKIE ECHO)
197 * 11 - Cookie Acknowledgement (COOKIE ACK)
198 * 12 - Reserved for Explicit Congestion Notification Echo (ECNE)
199 * 13 - Reserved for Congestion Window Reduced (CWR)
200 * 14 - Shutdown Complete (SHUTDOWN COMPLETE)
201 * 15 to 62 - available
202 * 63 - reserved for IETF-defined Chunk Extensions
203 * 64 to 126 - available
204 * 127 - reserved for IETF-defined Chunk Extensions
205 * 128 to 190 - available
206 * 191 - reserved for IETF-defined Chunk Extensions
207 * 192 to 254 - available
208 * 255 - reserved for IETF-defined Chunk Extensions
210 * Chunk Types are encoded such that the highest-order 2 bits specify
211 * the action that must be taken if the processing endpoint does not
212 * recognize the Chunk Type.
213 * 00 - Stop processing this SCTP packet and discard it, do not
214 * process any further chunks within it.
215 * 01 - Stop processing this SCTP packet and discard it, do not
216 * process any further chunks within it, and report the
217 * unrecognized chunk in an 'Unrecognized Chunk Type'.
218 * 10 - Skip this chunk and continue processing.
219 * 11 - Skip this chunk and continue processing, but report in an
220 * ERROR chunk using the 'Unrecognized Chunk Type' cause of error.
222 * Note: The ECNE and CWR chunk types are reserved for future use of
223 * Explicit Congestion Notification (ECN);
228 * The usage of these bits depends on the Chunk type as given by the
229 * Chunk Type field. Unless otherwise specified, they are set to 0 on
230 * transmit and are ignored on receipt.
235 * This value represents the size of the chunk in bytes, including
236 * the Chunk Type, Chunk Flags, Chunk Length, and Chunk Value fields.
237 * Therefore, if the Chunk Value field is zero-length, the Length
238 * field will be set to 4.
239 * The Chunk Length field does not count any chunk padding.
240 * Chunks (including Type, Length, and Value fields) are padded out
241 * by the sender with all zero bytes to be a multiple of 4 bytes
242 * long. This padding MUST NOT be more than 3 bytes in total. The
243 * Chunk Length value does not include terminating padding of the
244 * chunk. However, it does include padding of any variable-length
245 * parameter except the last parameter in the chunk. The receiver
246 * MUST ignore the padding.
248 * Note: A robust implementation should accept the chunk whether or
249 * not the final padding has been included in the Chunk Length.
255 } sctp_chunks_common_hdr_t;
260 sctp_chunks_common_hdr_t common_hdr;
264 #define CHUNK_TYPE_MASK 0xFF000000
265 #define CHUNK_TYPE_SHIFT 24
267 #define CHUNK_FLAGS_MASK 0x00FF0000
268 #define CHUNK_FLAGS_SHIFT 16
270 #define CHUNK_UBIT_MASK 0x000F0000
271 #define CHUNK_UBIT_SHIFT 18
273 #define CHUNK_BBIT_MASK 0x000F0000
274 #define CHUNK_BBIT_SHIFT 17
276 #define CHUNK_EBIT_MASK 0x000F0000
277 #define CHUNK_EBIT_SHIFT 16
279 #define CHUNK_LENGTH_MASK 0x0000FFFF
280 #define CHUNK_LENGTH_SHIFT 0
283 vnet_sctp_common_hdr_params_host_to_net (sctp_chunks_common_hdr_t * h)
285 h->params = clib_host_to_net_u32 (h->params);
289 vnet_sctp_common_hdr_params_net_to_host (sctp_chunks_common_hdr_t * h)
291 h->params = clib_net_to_host_u32 (h->params);
295 vnet_sctp_set_ubit (sctp_chunks_common_hdr_t * h)
297 h->params &= ~(CHUNK_UBIT_MASK);
298 h->params |= (1 << CHUNK_UBIT_SHIFT) & CHUNK_UBIT_MASK;
302 vnet_sctp_get_ubit (sctp_chunks_common_hdr_t * h)
304 return ((h->params & CHUNK_UBIT_MASK) >> CHUNK_UBIT_SHIFT);
308 vnet_sctp_set_bbit (sctp_chunks_common_hdr_t * h)
310 h->params &= ~(CHUNK_BBIT_MASK);
311 h->params |= (1 << CHUNK_BBIT_SHIFT) & CHUNK_BBIT_MASK;
315 vnet_sctp_get_bbit (sctp_chunks_common_hdr_t * h)
317 return ((h->params & CHUNK_BBIT_MASK) >> CHUNK_BBIT_SHIFT);
321 vnet_sctp_set_ebit (sctp_chunks_common_hdr_t * h)
323 h->params &= ~(CHUNK_EBIT_MASK);
324 h->params |= (1 << CHUNK_EBIT_SHIFT) & CHUNK_EBIT_MASK;
328 vnet_sctp_get_ebit (sctp_chunks_common_hdr_t * h)
330 return ((h->params & CHUNK_EBIT_MASK) >> CHUNK_EBIT_SHIFT);
334 vnet_sctp_set_chunk_type (sctp_chunks_common_hdr_t * h, sctp_chunk_type t)
336 h->params &= ~(CHUNK_TYPE_MASK);
337 h->params |= (t << CHUNK_TYPE_SHIFT) & CHUNK_TYPE_MASK;
341 vnet_sctp_get_chunk_type (sctp_chunks_common_hdr_t * h)
343 return ((h->params & CHUNK_TYPE_MASK) >> CHUNK_TYPE_SHIFT);
347 vnet_sctp_set_chunk_length (sctp_chunks_common_hdr_t * h, u16 length)
349 h->params &= ~(CHUNK_LENGTH_MASK);
350 h->params |= (length << CHUNK_LENGTH_SHIFT) & CHUNK_LENGTH_MASK;
354 vnet_sctp_get_chunk_length (sctp_chunks_common_hdr_t * h)
356 return ((h->params & CHUNK_LENGTH_MASK) >> CHUNK_LENGTH_SHIFT);
363 * 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
364 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
365 * | Type = 0 | Reserved|U|B|E| Length |
366 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
368 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369 * | Stream Identifier S | Stream Sequence Number n |
370 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371 * | Payload Protocol Identifier |
372 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
374 * / User Data (seq n of Stream S) /
376 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
380 sctp_header_t sctp_hdr;
384 * -- Reserved (5 bits): all 0s
388 * Length (16 bits): This field indicates the length of the DATA chunk in
389 * bytes from the beginning of the type field to the end of the User Data
390 * field excluding any padding.
391 * A DATA chunk with one byte of user data will have Length set to 17
392 * (indicating 17 bytes). A DATA chunk with a User Data field of length L
393 * will have the Length field set to (16 + L) (indicating 16+L bytes) where
394 * L MUST be greater than 0.
398 * Fragment Description Table:
401 * ============================================================
402 * | 1 0 | First piece of a fragmented user message |
403 * +----------------------------------------------------------+
404 * | 0 0 | Middle piece of a fragmented user message |
405 * +----------------------------------------------------------+
406 * | 0 1 | Last piece of a fragmented user message |
407 * +----------------------------------------------------------+
408 * | 1 1 | Unfragmented message |
409 * ============================================================
411 sctp_chunks_common_hdr_t chunk_hdr;
414 * This value represents the TSN for this DATA chunk.
415 * The valid range of TSN is from 0 to 4294967295 (2**32 - 1).
416 * TSN wraps back to 0 after reaching 4294967295.
421 * Identifies the stream to which the following user data belongs.
426 * This value represents the Stream Sequence Number of the following user data
427 * within the stream S. Valid range is 0 to 65535.
428 * When a user message is fragmented by SCTP for transport, the same Stream
429 * Sequence Number MUST be carried in each of the fragments of the message.
434 * This value represents an application (or upper layer) specified protocol
435 * identifier. This value is passed to SCTP by its upper layer and sent to its
436 * peer. This identifier is not used by SCTP but can be used by certain network
437 * entities, as well as by the peer application, to identify the type of
438 * information being carried in this DATA chunk. This field must be sent even
439 * in fragmented DATA chunks (to make sure it is available for agents in the
440 * middle of the network). Note that this field is NOT touched by an SCTP
441 * implementation; therefore, its byte order is NOT necessarily big endian.
442 * The upper layer is responsible for any byte order conversions to this field.
443 * The value 0 indicates that no application identifier is specified by the
444 * upper layer for this payload data.
449 * This is the payload user data. The implementation MUST pad the end of the
450 * data to a 4-byte boundary with all-zero bytes. Any padding MUST NOT be
451 * included in the Length field. A sender MUST never add more than 3 bytes of
456 } sctp_payload_data_chunk_t;
459 vnet_sctp_set_tsn (sctp_payload_data_chunk_t * p, u32 tsn)
461 p->tsn = clib_host_to_net_u32 (tsn);
465 vnet_sctp_get_tsn (sctp_payload_data_chunk_t * p)
467 return (clib_net_to_host_u32 (p->tsn));
471 vnet_sctp_set_stream_id (sctp_payload_data_chunk_t * p, u16 stream_id)
473 p->stream_id = clib_host_to_net_u16 (stream_id);
477 vnet_sctp_get_stream_id (sctp_payload_data_chunk_t * p)
479 return (clib_net_to_host_u16 (p->stream_id));
483 vnet_sctp_set_stream_seq (sctp_payload_data_chunk_t * p, u16 stream_seq)
485 p->stream_seq = clib_host_to_net_u16 (stream_seq);
489 vnet_sctp_get_stream_seq (sctp_payload_data_chunk_t * p)
491 return (clib_net_to_host_u16 (p->stream_seq));
495 vnet_sctp_set_payload_id (sctp_payload_data_chunk_t * p, u32 payload_id)
497 p->payload_id = clib_host_to_net_u32 (payload_id);
501 vnet_sctp_get_payload_id (sctp_payload_data_chunk_t * p)
503 return (clib_net_to_host_u32 (p->payload_id));
507 vnet_sctp_calculate_padding (u16 base_length)
509 if (base_length % 4 == 0)
512 return (4 - base_length % 4);
515 #define DEFAULT_A_RWND 1480
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;
1319 * Abort Association (ABORT)
1321 * The ABORT chunk is sent to the peer of an association to close the
1322 * association. The ABORT chunk may contain Cause Parameters to inform
1323 * the receiver about the reason of the abort. DATA chunks MUST NOT be
1324 * bundled with ABORT. Control chunks (except for INIT, INIT ACK, and
1325 * SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be
1326 * placed before the ABORT in the SCTP packet or they will be ignored by
1329 * If an endpoint receives an ABORT with a format error or no TCB is
1330 * found, it MUST silently discard it. Moreover, under any
1331 * circumstances, an endpoint that receives an ABORT MUST NOT respond to
1332 * that ABORT by sending an ABORT of its own.
1336 * 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
1337 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1338 * | Type = 6 |Reserved |T| Length |
1339 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1341 * / zero or more Error Causes /
1343 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1347 sctp_header_t sctp_hdr;
1348 sctp_chunks_common_hdr_t chunk_hdr;
1349 sctp_err_cause_param_t err_causes[];
1351 } sctp_abort_chunk_t;
1354 vnet_sctp_set_tbit (sctp_abort_chunk_t * a)
1356 vnet_sctp_set_chunk_type (&a->chunk_hdr, ABORT);
1357 // a->chunk_hdr.flags = clib_host_to_net_u16 (1);
1361 vnet_sctp_unset_tbit (sctp_abort_chunk_t * a)
1363 vnet_sctp_set_chunk_type (&a->chunk_hdr, ABORT);
1364 // a->chunk_hdr.flags = clib_host_to_net_u16 (0);
1368 * Shutdown Association (SHUTDOWN)
1370 * An endpoint in an association MUST use this chunk to initiate a
1371 * graceful close of the association with its peer.
1375 * 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
1376 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1377 * | Type = 7 | Chunk Flags | Length = 8 |
1378 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1379 * | Cumulative TSN Ack |
1380 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1384 sctp_header_t sctp_hdr;
1385 sctp_chunks_common_hdr_t chunk_hdr;
1387 * This parameter contains the TSN of the last chunk received in
1388 * sequence before any gaps.
1390 * Note: Since the SHUTDOWN message does not contain Gap Ack Blocks,
1391 * it cannot be used to acknowledge TSNs received out of order. In a
1392 * SACK, lack of Gap Ack Blocks that were previously included
1393 * indicates that the data receiver reneged on the associated DATA
1394 * chunks. Since SHUTDOWN does not contain Gap Ack Blocks, the
1395 * receiver of the SHUTDOWN shouldn't interpret the lack of a Gap Ack
1396 * Block as a renege.
1398 u32 cumulative_tsn_ack;
1400 } sctp_shutdown_association_chunk_t;
1403 vnet_sctp_set_tsn_last_received_chunk (sctp_shutdown_association_chunk_t * s,
1406 vnet_sctp_set_chunk_type (&s->chunk_hdr, SHUTDOWN);
1407 s->cumulative_tsn_ack = clib_host_to_net_u32 (tsn_last_chunk);
1411 * Shutdown Acknowledgement (SHUTDOWN ACK)
1413 * This chunk MUST be used to acknowledge the receipt of the SHUTDOWN
1414 * chunk at the completion of the shutdown process.
1418 * 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
1419 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1420 * | Type = 8 |Chunk Flags | Length = 4 |
1421 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1425 sctp_header_t sctp_hdr;
1426 sctp_chunks_common_hdr_t chunk_hdr;
1427 } sctp_shutdown_ack_chunk_t;
1430 vnet_sctp_fill_shutdown_ack (sctp_shutdown_ack_chunk_t * s)
1432 vnet_sctp_set_chunk_type (&s->chunk_hdr, SHUTDOWN_ACK);
1433 vnet_sctp_set_chunk_length (&s->chunk_hdr, 4);
1436 #endif /* included_vnet_sctp_packet_h */
1439 * fd.io coding-style-patch-verification: ON
1442 * eval: (c-set-style "gnu")