Files
m241Neelima/components/ip_net2-6.9/ipsctp/include/ipsctp_pkt.h
T
2026-07-30 11:19:44 +05:30

966 lines
39 KiB
C

/* ipsctp_pkt.h - IPNet SCTP packet header file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01a,27oct07,tkf Created.
*/
#ifndef IPSCTP_PKT_H
#define IPSCTP_PKT_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*
* This file defines types and structures related to IPSCTP frame format. It
* also defines macros used to access the strurctures.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include "ipsctp_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define IPSCTP_MAX_MTU_SIZE 1500
#define IPSCTP_GET_CHUNK_TYPE(chkhdr) ((IP_GET_16HI8((chkhdr)->type_flags) & 0xF0) >> 4)
#define IPSCTP_SET_CHUNK_TYPE(chkhdr,type) IP_SET_16HI8((chkhdr)->type_flags, ((type & 0x3C) << 4))
/*
* ===========================================================================
* IPSCTP Chunk Type defines
*===========================================================================
*/
#define IPSCTP_CHUNK_TYPE_DATA 0x00
#define IPSCTP_CHUNK_TYPE_INIT 0x01
#define IPSCTP_CHUNK_TYPE_ACK 0x02
#define IPSCTP_CHUNK_TYPE_SACK 0x03
#define IPSCTP_CHUNK_TYPE_HBEAT 0x04
#define IPSCTP_CHUNK_TYPE_HBEATACK 0x05
#define IPSCTP_CHUNK_TYPE_ABORT 0x06
#define IPSCTP_CHUNK_TYPE_SHUT 0x07
#define IPSCTP_CHUNK_TYPE_SHUTACK 0x08
#define IPSCTP_CHUNK_TYPE_ERROR 0x09
#define IPSCTP_CHUNK_TYPE_COOKIE_ECHO 0x0A
#define IPSCTP_CHUNK_TYPE_COOKIE_ACK 0x0B
#define IPSCTP_CHUNK_TYPE_ECN 0x0C
#define IPSCTP_CHUNK_TYPE_CWR 0x0D
#define IPSCTP_CHUNK_TYPE_SHUTCOMPL 0x0E
/*
* ===========================================================================
* IPSCTP Chunk header access defines
*===========================================================================
*/
#define IPSCTP_CHUNK_LEN(chunk) (ip_ntohs((chunk)->length))
#define IPSCTP_CHUNK_TYPE(chunk) (ip_ntohs((chunk)->type))
#define IPSCTP_CHUNK_FLAGS(chunk) (ip_ntohs((chunk)->flags))
/*
*===========================================================================
* IPSCTP defines of types of optional, variable length parameters
*===========================================================================
*/
#define IPSCTP_PARAM_HB_INFO 0x0001
/* How about the holes: 2, 3, 4 ??? */
#define IPSCTP_PARAM_IPV4_ADDR 0x0005
#define IPSCTP_PARAM_IPV6_ADDR 0x0006
#define IPSCTP_PARAM_COOKIE 0x0007
#define IPSCTP_PARAM_UNRECOGNIZED 0x0008
#define IPSCTP_PARAM_COOKIE_PRESERV 0x0009
/* How about the hole: 10 ??? */
#define IPSCTP_PARAM_HOSTNAME 0x000B
#define IPSCTP_PARAM_SUPPORTED_ADDR_TYPES 0x000C
#define IPSCTP_PARAM_ECN_CAPABLE 0x8000
#define IPSCTP_PARAM_PRSCTP 0xC000
#define IPSCTP_PARAM_ADDIP 0xC001
#define IPSCTP_PARAM_DELIP 0xC002
#define IPSCTP_PARAM_ERROR_CAUSE_INDICATION 0xC003
#define IPSCTP_PARAM_SET_PRIMARY 0xC004
#define IPSCTP_PARAM_SUCCESS_REPORT 0xC005
#define IPSCTP_PARAM_ADAPTATION_LAYER_IND 0xC006
#define IPSCTP_PARAM_SUPPORTED_CHUNK_EXT 0x8008
#define IPSCTP_PARAM_SUPPORTED_ECN_NONCE 0x8001
#define IPSCTP_PARAM_RANDOM 0x8002
#define IPSCTP_PARAM_CHUNK_LIST 0x8003
#define IPSCTP_PARAM_HMAC_LIST 0x8004
/*
*===========================================================================
* IPSCTP Error Cause defines
*===========================================================================
*/
#define IPSCTP_ECAUSE_INVALID_STREAM_ID 1
#define IPSCTP_ECAUSE_MISSING_MANDATORY_PARAM 2
#define IPSCTP_ECAUSE_STALE_COOKIE_ERROR 3
#define IPSCTP_ECAUSE_OUT_OF_RESOURCE_ERROR 4
#define IPSCTP_ECAUSE_UNRESOLVABLE_ADDRESS 5
#define IPSCTP_ECAUSE_UNRECOGNIZED_CHUNKTYPE 6
#define IPSCTP_ECAUSE_INVALID_MANDATORY_PARAM 7
#define IPSCTP_ECAUSE_UNRECOGNIZED_PARAMS 8
#define IPSCTP_ECAUSE_NO_USER_DATA 9
#define IPSCTP_ECAUSE_COOKIE_RECEIVED_DURING_SHUTDWN 10
#define IPSCTP_ECAUSE_RESTART_WITH_NEW_ADDRESSES 11
#define IPSCTP_ECAUSE_USER_INITIATED_ABORT 12
#define IPSCTP_ECAUSE_PROTOCOL_VIOLATION 13
/* SCTP error codes */
#define IPSCTP_ECAUSE_CODE_FAILED_THRESHOLD 14
#define IPSCTP_ECAUSE_ICMP_ERROR 15
#define IPSCTP_FROM_SOCK 0x10000000
#define IPSCTP_FROM_IPSCTP 0x20000000
#define SCTP_LOC_01 0x00000001
#define SCTP_LOC_02 0x00000002
#define SCTP_LOC_03 0x00000003
#define SCTP_LOC_04 0x00000004
#define SCTP_LOC_05 0x00000005
#define SCTP_LOC_06 0x00000006
#define SCTP_LOC_07 0x00000007
/*
*===========================================================================
* IPSCTP Chunk type processing rule macros.
*
* Chunk Types are encoded such that the highest-order 2 bits specify the
* action that must be taken if the processing endpoint does not recognize
* the Chunk Type.
*===========================================================================
*/
#define IPSCTP_DROP_PKT_SILENT(type) (((Ip_u8)type & 0xC0)==0x00)
#define IPSCTP_DROP_PKT_REPORT(type) (((Ip_u8)type & 0xC0)==0x40)
#define IPSCTP_SKIP_CHNK_SILENT(type) (((Ip_u8)type & 0xC0)==0x80)
#define IPSCTP_SKIP_CHNK_REPORT(type) (((Ip_u8)type & 0xC0)==0xC0)
#define IPSCTP_UNKNOWN_CHUNK_DROP_FLAG(type) (((Ip_u8)(type) & 0x80) == 0)
#define IPSCTP_UNKNOWN_CHUNK_REPORT_FLAG(type) ((Ip_u8)(type) & 0x40)
/*
*===========================================================================
* IPSCTP Parameter type processing rule macros.
*
* Parameter Types are encoded such that the highest-order 2 bits specify the
* action that must be taken if the processing endpoint does not recognize
* the Chunk Type.
*===========================================================================
*/
#define IPSCTP_DROP_CHNK_SILENT(type) (((Ip_u16)type & 0xC000)==0x0000)
#define IPSCTP_DROP_CHNK_REPORT(type) (((Ip_u16)type & 0xC000)==0x4000)
#define IPSCTP_SKIP_PARAM_SILENT(type) (((Ip_u16)type & 0xC000)==0x8000)
#define IPSCTP_SKIP_PARAM_REPORT(type) (((Ip_u16)type & 0xC000)==0xC000)
/* chunk flags */
#define IPSCTP_HAD_NO_TCB 0x01
/* data chunk flag */
#define IPSCTP_FLAG_DATA_MIDDLE_FRAG 0x00
#define IPSCTP_FLAG_DATA_LAST_FRAG 0x01
#define IPSCTP_FLAG_DATA_FIRST_FRAG 0x02
#define IPSCTP_FLAG_DATA_NOT_FRAG 0x03
#define IPSCTP_FLAG_DATA_FRAG_MASK 0x03
#define IPSCTP_FLAG_DATA_UNORDERED 0x04
#define IPSCTP_MIN_PARA_NUM 1
#define IPSCTP_MAX_IP_ADDR_LEN 24 /* how it for IPV6? */
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
*===========================================================================
* Ipsctp_sctp_hdr
*
* SCTP Common Header Format
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Source Port | Destination Port |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Veirifcation Tag |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | CRC-32c Checksum |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Chunk 1 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ... |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Chunk 2 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*===========================================================================
*/
typedef struct Ipsctp_sctp_hdr_struct
{
Ip_u16 sport; /* source port */
Ip_u16 dport; /* destination port */
Ip_u32 vtag; /* packet verification tag */
Ip_u32 crc; /* CRC-32c Checksum */
/* one or more chunks */
}
Ipsctp_sctp_hdr;
/*
*===========================================================================
* Ipsctp_chunk_hdr
*
* SCTP Chunk Header Format
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Chunk type | Chunk flags | Chunk length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Chunk data |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_chunk_hdr_struct {
Ip_u8 type; /* chunk type */
Ip_u8 flags; /* chunk flags */
Ip_u16 length; /* chunk length */
/* optional params follow */
}
Ipsctp_chunk_hdr;
/*
*===========================================================================
* Ipsctp_state_cookie_struct
*
* State Cookie.
*
* This structure is used for genreating the State Cookie parameter that is
* included in an INIT-ACK chunk to be sent in response to a received INIT
* chunk. The members of the structure are selected such that they can be
* regenerated without a saved TCB.
*
* Each field, except the MAC field (mac) is used in the computation of the
* MAC value. When receving a Cookie Echo chunk, the computed MAC is compared
* against the one saved in the received Cookie. Moreover the following check
* is done during validation:
*
* - The port fields (my_port and peer_port) and the verification tag
* (vtag) are compared to those contained in the SCTP common header
* containing the Cookie Echo chunk when validating the Cookie Echo chunk.
*
* - The creation time (creation_time) is compared to current local time.
* The elapsed time should be shorter than or equal to the lifespan
* (lifetime).
*
* This structure is not used to generate the State Cookie when sending Cookie
* Echo chunk. We simply set the type of the received cookie parameter to
* Cookie Echo (10) and clear any flags and resend the chunk.
*
*===========================================================================
*/
typedef struct Ipsctp_state_cookie_struct {
Ip_u32 ltie_tag;
/* My previous verification tag;
non-zero if re-starting */
Ip_u32 ptie_tag;
/* Peer's previous verification tag;
non-zero if re-starting */
Ip_u16 lport; /* My local port (used in INIT) */
Ip_u16 pport; /* Peer port (used in INIT) */
struct Ip_timeval creation_time;
/* the cookie creation time */
Ip_u32 lifetime;
/* time the cookie can live (milliseconds)*/
union
{
#ifdef IPCOM_USE_INET
struct Ip_in_addr addr4;
#endif
#ifdef IPCOM_USE_INET6
struct Ip_in6_addr addr6;
#endif
}addr; /* destination addr of the cookie */
/*init chunk*/
/*init ack chunk*/
/*Ip_u8 hmac[IPSCTP_SIGNATURE_SIZE];*/
}
Ipsctp_state_cookie;
/*
*===========================================================================
* Ipsctp_data_chunk_hdr
*
* SCTP DATA Chunk Format.
* Chunk type is 0.
*
*===========================================================================
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Type = 0 | Reserved|U|B|E| Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | TSN |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Stream Identifier S | Stream Sequence Number n |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Payload Protocol Identifier |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_data_chunk_hdr_struct {
Ipsctp_chunk_hdr hdr;
Ip_u32 tsn; /* transport sequence number */
Ip_u16 sid; /* Stream Identifier */
Ip_u16 ssn; /* Stream Sequence Number */
Ip_u32 ppid; /* Payload Protocol Identifier */
}
Ipsctp_data_chunk_hdr;
/*
*===========================================================================
* Ipsctp_init_fixed_params
*
* Fixed portion of the parameters of the INIT/INIT-ACK chunks.
*===========================================================================
*/
typedef struct Ipsctp_init_fixed_params_struct {
Ip_u32 init_tag; /* Initiate Tag */
Ip_u32 a_rwnd; /* Advertised Receiver Window Credit */
Ip_u16 nos; /* Number of Outbound Streams */
Ip_u16 nis; /* Number of Inbound Streams */
Ip_u32 init_tsn; /* Initial TSN */
}
Ipsctp_init_fixed_params;
/*
*===========================================================================
* Ipsctp_init_chunk_hdr
*
* SCTP INIT or INIT-ACK Chunk Format.
* Chunk type is 1 (for INIT) or 2 (for INIT-ACK)
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 1/2 |Chunk Flags | Chunk Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Initiate Tag |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Advertised Receiver Window Credit (a_rwnd) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Number of Outbound Streams | Number of Inbound Streams |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Initial TSN |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_init_chunk_hdr_struct {
Ipsctp_chunk_hdr hdr;
Ipsctp_init_fixed_params fixed_params;
}
Ipsctp_init_chunk_hdr;
/*
*===========================================================================
* Ipsctp_sack_chunk_hdr
*
* SCTP Selective Acknowledgement (SACK) Chunk Format.
* Chunk type is 3.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 3 |Chunk Flags | Chunk Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cumulative TSN Ack |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Advertised Receiver Window Credit (a_rwnd) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Number of Gap Ack Blocks = N | Number of Duplicate TSNs = X |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_sack_chunk_hdr_struct {
Ipsctp_chunk_hdr hdr;
Ip_u32 cum_tsn_ack; /* Cumulative TSN Ack */
Ip_u32 a_rwnd; /* Advertised Receiver Window
Credit */
Ip_u16 ngaps; /* Number of Gap Ack Blocks */
Ip_u16 ndups; /* Number of Duplicate TSNs */
}
Ipsctp_sack_chunk_hdr;
/* gap entry in SACK */
typedef struct Ipsctp_sack_gap_struct{
Ip_u16 start;
Ip_u16 end;
}
Ipsctp_sack_gap;
/*
*===========================================================================
* Ipsctp_param_hdr
*
* This structure is used commonly by all types of parameter.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Parameter Type | Parameter Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_param_hdr_struct {
Ip_u16 type;
Ip_u16 len;
}
Ipsctp_param_hdr;
/*
*===========================================================================
* Heartbeat Info Parameter.
* Parameter type is 1.
*
* No fixed fields for the Heartbeat Info Parameter.
*===========================================================================
*/
/*
*===========================================================================
* Ipsctp_heartbeat_chunk_hdr
*
* Heartbeat Request (HEARTBEAT) or Heartbeat Acknowledgement (HEARTBEAT ACK)
* Chunk Formats.
* Chunk type is 4 (for HEARTBEAT) or 5 (for HEARTBEAT ACK).
*
* When using this structure with HEARTBEAT ACK, the user simply changes the
* chunk type field to that of HEARTBEAT ACK (5).
*
* This structure describes the HEARTBEAT chunk header plus the Heartbeat
* Info parameter that is specific to IPSCTP.
*
* When the HEARTBEAT chunk is used for Path Verification, the MAC value
* also to be appended to this structure. The structure definition does
* not include the MAC field.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 4/5 |Chunk Flags | Chunk Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Heartbeat Info Type | Heartbeat Info Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Heartbeat Send Time |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Destination Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_hb_infor_hdr_struct
{
Ipsctp_param_hdr param_hdr; /* parameter header */
struct Ip_timeval sendtime; /* chunk send time */
Ip_u32 random_v1; /* random value */
Ip_u32 random_v2; /* random value */
Ip_u8 addr_family; /* destination address family */
Ip_u8 addr_len; /* destination address length */
Ip_u16 reserved; /* 4-byte alignment */
Ip_u8 dstaddr [IPSCTP_MAX_IP_ADDR_LEN]; /* destination address */
}
Ipsctp_hb_infor_hdr;
typedef struct Ipsctp_hb_chunk_hdr_struct
{
Ipsctp_chunk_hdr chdr; /* Chunk header */
Ipsctp_hb_infor_hdr hb_infor; /* parameter header */
}
Ipsctp_hb_chunk_hdr;
/*
*===========================================================================
* 3.3.7. Abort Association (ABORT) (6)
*
* The ABORT chunk is sent to the peer of an association to close the
* association. The ABORT chunk may contain Cause Parameters to inform
* the receiver about the reason of the abort. DATA chunks MUST NOT be
* bundled with ABORT. Control chunks (except for INIT, INIT ACK, and
* SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be
* placed before the ABORT in the SCTP packet or they will be ignored by
* the receiver.
*
* If an endpoint receives an ABORT with a format error or no TCB is
* found, it MUST silently discard it. Moreover, under any
* circumstances, an endpoint that receives an ABORT MUST NOT respond to
* that ABORT by sending an ABORT of its own.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Type = 6 |Reserved |T| Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* \ \
* / zero or more Error Causes /
* \ \
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
/*
*===========================================================================
* Ipsctp_shtdown_chunk
*
* Shutdown Association (SHUTDOWN) Chunk format.
* Chunk Type is 7.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 7 | Chunk Flags | Length = 8 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cumulative TSN Ack |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*===========================================================================
*/
typedef struct Ipsctp_shtdown_chunk_struct {
Ipsctp_chunk_hdr hdr;
Ip_u32 ctsn; /* Cumulative TSN Ack */
}
Ipsctp_shtdown_chunk;
/*
*===========================================================================
*
* Shutdown Acknowledgment (SHUTDOWN ACK) Chunk format.
* Chunk Type is 8.
*
* No fixed parameters for SHUTDOWN ACK. Nor does this chunk have any variable
* length parameters. The chunk length field is always set to 4.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 8 |Chunk Flags | Chunk Length = 4 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
/*
*===========================================================================
* Operation Error (ERROR) Chunk error cause header.
*
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cause Code | Cause Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* / Cause-Specific Information /
* \ \
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*===========================================================================
*/
typedef struct Ipsctp_error_cause_hdr_struct {
Ip_u16 cause_code;
Ip_u16 cause_len;
/*Cause-Specific Information*/
}
Ipsctp_error_cause_hdr;
/*
*===========================================================================
* Operation Error (ERROR) Chunk format.
* Chunk Type is 9.
*
* There are no fixed ERROR chunk specific fields. The variable length
* value of this chunk is made up of 0 or more ERROR cause parameters.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 9 |Chunk Flags | Chunk Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_error_chunk_struct {
Ipsctp_chunk_hdr hdr;
Ipsctp_error_cause_hdr err_cause_hdr;
/*Cause-Specific Information*/
}
Ipsctp_error_chunk;
/*
*===========================================================================
* error cause 1:Invalid Stream Identifier
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cause Code=1 | Cause Length=8 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Stream Identifier | (Reserved) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_error_invalid_stream_id_struct{
Ip_u16 stream_id;
Ip_u16 reserved;
}
Ipsctp_error_invalid_stream_id;
/*
*===========================================================================
* error cause 2:Missing Mandatory Parameter
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cause Code=2 | Cause Length=8+N*2 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Number of missing params=N |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Missing Param Type #1 | Missing Param Type #2 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Missing Param Type #N-1 | Missing Param Type #N |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_error_miss_param_struct{
Ip_u32 miss_num;
Ip_u16 miss_type;
/*miss type followed if more than 1*/
}
Ipsctp_error_miss_param;
/*
*===========================================================================
* error cause 3:Stale Cookie Error
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cause Code=3 | Cause Length=8 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Measure of Staleness (usec.) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_error_stale_cookie_struct{
Ip_u32 stale_time; /*Measure of Staleness (usec.)*/
}
Ipsctp_error_stale_cookie;
/*error cause 5:Unresolvable Address*/
typedef Ipsctp_param_hdr Ipsctp_error_unres_addr;
/*error cause 6:Unrecognized Chunk Type*/
typedef Ipsctp_chunk_hdr Ipsctp_error_unreg_chunk;
/*error cause 8:Unrecognized Parameters*/
typedef Ipsctp_param_hdr Ipsctp_error_unrec_param;
/*
*===========================================================================
* error cause 9:No User Data
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cause Code=9 | Cause Length=8 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* / TSN value /
* \ \
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_error_no_user_data_struct{
Ip_u32 tsn;
}
Ipsctp_error_no_user_data;
/*
*===========================================================================
* error cause 11:Restart of an Association with New Addresses
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Cause Code=11 | Cause Length=Variable |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* / New Address TLVs /
* \ \
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef Ipsctp_param_hdr Ipsctp_error_restart_new_param;
/* User-Initiated Abort (12) undefined */
/* Protocol Violation (13) undefined */
/*
*===========================================================================
* Cookie Echo (COOKIE ECHO) Chunk format.
* Chunk Type is 10.
*
* There are no fixed COOKIE ECHO chunk specific fields. The variable length
* value of this chunk is made up of the State Cookie parameter.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 10 |Chunk Flags | Chunk Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_cookie_echo_chunk_struct{
Ipsctp_chunk_hdr hdr;
Ipsctp_state_cookie state_cookie;
} Ipsctp_cookie_echo_chunk;
/*
*===========================================================================
*
* Cookie Acknowledgement (COOKIE ACK) Chunk format.
* Chunk Type is 11.
*
* No fixed parameters for SHUTDOWN ACK. Nor does this chunk have any
* variable length parameters. The chunk length field is always set to 4.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 11 |Chunk Flags | Chunk Length = 4 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef Ipsctp_chunk_hdr Ipsctp_cookie_ack_chunk;
/*
*===========================================================================
*
* Shutdown Complete (SHUTDOWN COMPLETE) Chunk format.
* Chunk Type is 14.
*
* No fixed parameters for SHUTDOWN COMPLETE. Nor does this chunk have any
* variable length parameters. The chunk length field is always set to 4.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Ipsctp_chunk_hdr |
* | Type = 14 |Chunk Flags | Chunk Length = 4 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
#ifdef IPCOM_USE_INET
/*
*===========================================================================
* Ipsctp_param_ip4
*
* IPv4 Address Parameter.
* Parameter type is 5.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Parameter Type | Parameter Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_param_ip4_struct
{
Ipsctp_param_hdr hdr;
struct Ip_in_addr addr;
}
Ipsctp_param_ip4;
#endif
#ifdef IPCOM_USE_INET6
/*
*===========================================================================
* Ipsctp_param_ip6
*
* IPv6 Address Parameter.
* Parameter type is 6.
*
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Parameter Type | Parameter Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_param_ip6_struct
{
Ipsctp_param_hdr hdr;
struct Ip_in6_addr addr; /* IPV6 address */
}
Ipsctp_param_ip6;
#endif
/*
*===========================================================================
* Ipsctp_param_state_cookie_struct
*
* State Cookie Parameter.
* Parameter type is 7.
*
* This structure is used for genreating the State Cookie parameter that is
* included in an INIT-ACK chunk to be sent in response to a received INIT
* chunk. The members of the structure are selected such that they can be
* regenerated without a saved TCB.
*
* Each field, except the MAC field (mac) is used in the computation of the
* MAC value. When receving a Cookie Echo chunk, the computed MAC is compared
* against the one saved in the received Cookie. Moreover the following check
* is done during validation:
*
* - The port fields (my_port and peer_port) and the verification tag
* (vtag) are compared to those contained in the SCTP common header
* containing the Cookie Echo chunk when validating the Cookie Echo chunk.
*
* - The creation time (creation_time) is compared to current local time.
* The elapsed time should be shorter than or equal to the lifespan
* (lifetime).
*
* This structure is not used to generate the State Cookie when sending Cookie
* Echo chunk. We simply set the type of the received cookie parameter to
* Cookie Echo (10) and clear any flags and resend the chunk.
*
*===========================================================================
*/
typedef struct Ipsctp_param_state_cookie_struct {
Ipsctp_param_hdr hdr;
Ipsctp_state_cookie state_cookie;
} Ipsctp_param_state_cookie;
/*
*===========================================================================
* Unrecognized Parameter Parameter.
* Parameter type is 8.
*
* No fixed fields for the Unrecognized Parameter Parameter. It lists all
* unrecognized parameters in the received INIT chunk. The parameters are
* complete with type, length, and value.
*===========================================================================
*/
/*
*===========================================================================
* Ipsctp_param_cookie_preserve
*
* Cookie Preservative Parameter.
* Parameter Type is 9.
* 0 1 2 3
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Type = 9 | Length = 8 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Suggested Cookie Life-Span Increment (msec.) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*===========================================================================
*/
typedef struct Ipsctp_param_cookie_preserve_struct
{
Ipsctp_param_hdr hdr;
Ip_u32 cookie_lifetime_inc;
}
Ipsctp_param_cookie_preserve;
/*
*===========================================================================
* Host Name Address Parameter.
* Parameter type is 11.
*
* No fixed fields for the Host Name Address Parameter.
*===========================================================================
*/
/*
*===========================================================================
* Ipsctp_param_supp_addr_types
*
* Supported Address Types Parameter.
* Parameter type is 12.
*
* Address types can be IPv4 = 5,
* IPv6 = 6,
* Host name = 11
*===========================================================================
*/
typedef Ipsctp_param_hdr Ipsctp_param_supp_addr_types;
#if 0
#define SCTP_GET_NEXT_CHUNK(chunk,inputbuf,remain_len) do\
{\
chunk = (Ipsctp_chunk_hdr *)inputbuf;\
if(remain_len < sizeof(Ipsctp_chunk_hdr) || \
remain_len < chunk->length)\
{\
chunk = NULL;\
}\
else\
{\
inputbuf += IP_ROUNDUP(chunk->length);\
if (remain_len>=IP_ROUNDUP(chunk->length))\
{ remain_len -= IP_ROUNDUP(chunk->length);}\
else\
{remain_len = 0;}\
}\
}\
while(0)
#endif
/*
****************************************************************************
* 6 PUBLIC FUNCTIONS
****************************************************************************
*/
#ifdef __cplusplus
}
#endif
#endif /* IPSCTP_PKT_H */