original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
@@ -0,0 +1,584 @@
/* ipsctp.h - IPNET SCTP header file */
/*
* Copyright (c) 2007, 2018 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
--------------------
01b,21nov18,lan modify the msec_expires of Iptcp_timer structure to 64bit
(VXW6-86996)
01a,17nov07,kch Created.
*/
#ifndef IPSCTP_H
#define IPSCTP_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* This header file contains definitions and declarations used for IPSCTP.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include "ipsctp_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#ifdef IPNET
#include <ipnet.h>
#include <ipnet_h.h>
#endif /* IPNET */
#ifdef IPLITE
#include <iplite_h.h>
#endif
#include <ipsctp_sock.h>
#include <ipsctp_pkt.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#ifndef NULL
#define NULL IP_NULL
#endif
/*
* The following HAVE_XXX SCTP defines are not used by IPSCTP implementation.
* These defines are for compatibility with Section 9 of the socket draft-15
* only! Refer to the <ipsctp_config.h> configuration header file for more
* information about the supported IPSCTP_USE_XXX preprocessor constants.
*/
#ifdef IPSCTP_USE_SOCKET
#define HAVE_KERNEL_SCTP
#endif /* IPSCTP_USE_SOCKET */
#ifdef IPSCTP_USE_PRSCTP
#define HAVE_SCTP_PRSCTP
#endif /* IPSCTP_USE_PRSCTP */
#ifdef IPSCTP_USE_ADDIP
#define HAVE_SCTP_ADDIP
#endif /* IPSCTP_USE_ADDIP */
#ifdef IPSCTP_USE_CANSET_PRIMARY
#define HAVE_SCTP_CANSET_PRIMARY
#endif /* IPSCTP_USE_CANSET_PRIMARY */
#ifdef IPSCTP_USE_MULTIBUF
#define HAVE_SCTP_MULTIBUF 1
#else
#define HAVE_SCTP_MULTIBUF 0
#endif /* IPSCTP_USE_MULTIBUF */
#ifdef IPSCTP_USE_NOCONNECT
#define HAVE_SCTP_NOCONNECT
#endif /* IPSCTP_USE_NOCONNECT */
#ifdef IPSCTP_USE_EXT_RCVINFO
#define HAVE_SCTP_EXT_RCVINFO
#endif /* IPSCTP_USE_EXT_RCVINFO */
/* Stack specific types */
#ifdef IPNET
#define Ipsctp_socket Ipnet_socket
#define Ipsctp_netif Ipnet_netif
#define Ipsctp_timeout Ipnet_timeout
#define Ipsctp_timeout_handler Ipnet_timeout_handler
#define IPSCTP_STACK_CONST(x) IPNET_ ## x
#elif defined(IPLITE)
#define Ipsctp_socket Iplite_socket
#define Ipsctp_netif Iplite_netif
#define Ipsctp_timeout Iplite_timeout
#define Ipsctp_timeout_handler Iplite_timeout_handler
#define IPSCTP_STACK_CONST(x) IPLITE_ ## x
#else
#error "IPNET or IPLITE must be defined"
#endif
/* Default/minimum SCTP header is 12(SCTP Common Header) octets long */
#define IPSCTP_SIZE_SCTP_HDR (sizeof(Ipsctp_sctp_hdr))
/* Secret information for secret_key */
#define IPSCTP_SECRETS_NUM (2) /* How many secrets I keep */
#define IPSCTP_SECRET_SIZE (32) /* number of octets in a 256 bits */
#define IPSCTP_NUMBER_OF_SECRETS (8) /* or 8 * 4 = 32 octets */
#define IPSCTP_SIZE_INST (sizeof(Ipsctp_instance))
#define IPSCTP_SIZE_SOCK_DATA (IPSCTP_SIZE_INST)
/* Possible socket events */
#define IPSCTP_NOTIFY_EVENT_PATH_MTU 1 /* The path MTU has changed */
#define IPSCTP_NOTIFY_EVENT_KICKSTART 2 /* Try 'kickstart' this particular socket */
/* inst_flags in Ipsctp_instance */
#define IPSCTP_SOCKET_TCP (1u << 1)
#define IPSCTP_SOCKET_UDP (1u << 2)
#define IPSCTP_SOCKET_CLOSED (1u << 3)
#define IPSCTP_SOCKET_ACCEPTING (1u << 4)
#define IPSCTP_SOCKET_LISTENING (1u << 5)
#define IPSCTP_SOCKET_CONNECTED (1u << 6)
#define IPSCTP_SOCKET_BOUNDALL (1u << 7)
#define IPSCTP_SOCKET_BOUND_V6 (1u << 8)
#define IPSCTP_SOCKET_BOUND_V4 (1u << 9)
#define IPSCTP_SOCKET_CONNABORTED (1u << 10)
#define IPSCTP_SOCKET_KCLOSE_PENDING (1u << 11)
#define IPSCTP_SOCKET_FLAG_USER_REF (1u << 12)
#define IPSCTP_SOCKET_FLAG_LINGER (1u << 13) /* linger timer is running */
#define IPSCTP_SOCKET_KCLOSED (1u << 14)
#define IPSCTP_SOCKET_FLAG_AUTOCLOSE (1u << 15) /* auto-close timer is running */
#define IPSCTP_SOCKET_FLAG_SENDALL (1u << 16) /* send-all timer is running */
#define IPSCTP_SOCKET_FLAG_PEELOFF (1u << 17) /* peel-off socket
* NOTE : NOW not used, used if peeloff socket
* create with IP_SOCK_SEQPACKET */
#define ipsctp_style(sock, style) \
IP_BIT_ISSET(sock->sctp_inst->inst_flags, IPSCTP_SOCKET_##style)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/* Timeout type */
typedef enum Ipsctp_timo_enum {
IPSCTP_TIMO_NONE = 0, /* Placeholder that means: do not add a timer */
IPSCTP_TIMO_T1 = 1, /* init timer */
IPSCTP_TIMO_T2 = 2, /* shutdown timer */
IPSCTP_TIMO_T3 = 3, /* retransmission timer */
IPSCTP_TIMO_T5 = 4, /* shutdown guard timer */
IPSCTP_TIMO_DACK = 5, /* delay ack timer */
#ifdef IPSCTP_FAST_RETRANSMITE
IPSCTP_TIMO_FR = 6, /* fr timer */
#endif
IPSCTP_TIMO_COOKIE = 7, /* cookie timer */
IPSCTP_TIMO_HB = 8, /* heartbeat timer */
IPSCTP_TIMO_SECRET = 9, /* secret change timer */
IPSCTP_TIMO_LINGER = 10, /* linger timer */
IPSCTP_TIMO_AUTOCLOSE = 11, /* autoclose timer */
IPSCTP_TIMO_SENDALL = 12, /* send all timer */
IPSCTP_TIMO_MAX /* invalid value */
} Ipsctp_timo;
struct Ipsctp_instance;
struct Ipsctp_tcb_lookup_key_struct;
struct Ipsctp_tcb_struct;
struct Ipsctp_transport_struct;
typedef struct Ipsctp_timer_struct
{
/*
* Required so the timer can be part of the 'timers' list in the
* TCB structure.
*/
Ipcom_list list;
/*
* Absolute time when this timer expires.
*/
Ip_u64 msec_expires;
/*
* Handler to run if/when the timer expires.
*/
void (*action)(IP_CONST void *);
struct Ipsctp_instance_struct *inst;
struct Ipsctp_tcb_struct *tcb;
struct Ipsctp_transport_struct *tp;
struct Ipsctp_vtag_timewait_struct *timewait;
Ipsctp_timo type;
}
Ipsctp_timer;
typedef struct Ipsctp_netstat_tcbinfo
{
union Ip_sockaddr_union *raddr;
Ip_u32 raddr_count;
int state;
}
Ipsctp_netstat_tcbinfo;
typedef struct Ipsctp_netstatinfo_struct
{
Ipsctp_netstat_tcbinfo *tcb;
Ip_u32 tcb_count;
union Ip_sockaddr_union *laddr;
Ip_u32 laddr_count;
}
Ipsctp_netstatinfo;
typedef struct Ipsctp_sendall_pkt_struct
{
Ipcom_list next;
struct Ipsctp_sndrcvinfo sndrcvinfo;
Ipcom_pkt *pkt;
}
Ipsctp_sendall_pkt;
/*
*===========================================================================
* IPSCTP instance parameters
*===========================================================================
* The members of this structure are defined per recommendation in Section
* 13.1 of RFC4960. The members represent IPSCTP instance parameters, which
* are commonly used by all associations of the instance.
*/
typedef struct Ipsctp_instance_struct
{
/* Common information */
Ipsctp_socket *sock; /* Points to the socket this instance is
bound to */
Ipcom_list assoc_list; /* list of current associations; list
contains mappings to data consumers
per association. */
#ifndef IPCOM_FORWARDER_NAE
Ipcom_list active; /* List of active Instance:s */
#endif
Ipcom_spinlock tcb_lock; /* protect all TCBs' pmtu, mss */
Ip_u16 lport; /* locally bound IPSCTP port number, in network order */
Ipcom_list laddr_list; /* list of addresses bound by this
* instance. Passed to peer(s) in INIT
* and/or INIT ACK chunks.
* NOTE : address count be include in list */
Ip_u32 inst_flags;
Ipcom_atomic_t wait_readable;
Ip_u32 recv_lowat; /* The low water mark for receiving */
Ip_u32 send_lowat; /* The low water mark for sending */
Ip_u32 linger_time; /* Time this socket will linger after close */
Ipsctp_timer linger_timer; /* linger timer */
Ip_u32 shut_guard_time; /* time of shutdown guard timer */
Ip_u32 secret_time; /* time of secret timer */
/* Secret information */
Ip_u32 secret_key[IPSCTP_SECRETS_NUM][IPSCTP_NUMBER_OF_SECRETS];
/* secret key used by this endpoint to
compute the MAC. */
Ip_u8 current_secret_number; /* current using secret number */
Ip_u8 last_secret_number; /* last used secret number */
struct Ip_timeval secret_change_time; /* secret change time */
Ipsctp_timer secret_timer; /* secret timer */
Ipsctp_timer sendall_timer; /* sendall timer, here we use per instance,
not a global, because each has it own
send buffer, we do not want one block
other instance. */
Ipcom_list sendall_pkt; /* sendall timer packet list */
Ip_u32 congestion_control_module; /* Default congestion control module */
Ip_u32 autoclose_time; /* autoclose time, im MSEC */
Ip_u32 max_burst; /* maximum burst of packets
* that can be emitted by this association
*/
Ip_u32 frag_point; /* size to do fragments */
Ip_u32 pd_point; /* partial delivery point, Get or Set by
* option SCTP_PARTIAL_DELIVERY_POINT */
Ip_u32 context; /* Set or get by SCTP_CONTEXT */
Ipsctp_sctp_sack_info sack_info; /*to control the sack */
/* Socket Options when using ipcom_setsockopt(ipnet2\src\ipnet_sockopt.c) */
struct Ipsctp_initmsg initmsg; /* Initiation Message option
(sctp_initmsg) */
Ipsctp_sctp_rtoinfo rtoinfo; /* Retransmission Timeout Parameters
option(sctp_rtoinfo) */
Ipsctp_sctp_paddrparams paddrparam; /* Peer Address Parameters option
(sctp_paddrparams) */
Ip_u32 feature_flags; /* Notification Interest Options
(sctp_event_subscribe) */
Ipsctp_sctp_assocparams assocparams; /* Association Parameters option
(sctp_assocparams) */
Ipsctp_sctp_sndrcvinfo sndrcvinfo; /* Header Information option
(sctp_sndrcvinfo) */
Ipcom_list recv_list; /* All chunks to be read by socket */
/* Socket backlog information */
Ipsctp_socket *parent; /* The listen socket that was
used to create this socket */
Ip_u16 backlog_len; /* Maximum number of entries in
the backlog */
Ip_u16 backlog_used; /* Number of used entries
(pending + done) in the backlog */
int *backlog_pending; /* Connections that are doing the
four-way handshake */
int *backlog_done; /* Connections that have finished the
four-way handshake */
#ifndef IPSCTP_USE_MULTIBUF
Ip_u32 size_on_in_queue; /* chunk bytes in input stream's chunk queue,
haven't been delivered to socket receive buffer.*/
Ip_u32 cnt_on_in_queue; /* chunk count in input stream's chunk queue,
haven't been delivered to socket receive buffer.*/
Ip_u32 recv_chunks_cnt; /* chunks count in receive buffer */
Ip_u32 send_chunks_cnt; /* chunks count in send buffer */
#endif
Ip_u32 sws_sender;
Ip_u32 sws_receiver;
int (*get_tcb_info)(Ipsctp_socket *sock,
IP_CONST struct Ip_msghdr *msg,
struct Ipsctp_sndrcvinfo *sndrcv,
Ip_u32 *pmtu,
Ip_u32 *mss,
void **tcb_ret);
Ipcom_list timers;
}
Ipsctp_instance;
#ifdef IPSCTP_MIB
typedef struct Ipsctp_mib_stats_struct
{
/* Begin: mib in RFC3873 */
Ip_u32 sctp_Curr_Estab; /* Gauge32 */
Ip_u32 sctp_Active_Estabs;
Ip_u32 sctp_Passive_Estabs;
Ip_u32 sctp_Aborteds;
Ip_u32 sctp_Shutdowns;
Ip_u32 sctp_OutOfBlues;
Ip_u32 sctp_Checksum_Errors;
Ip_u64 sctp_Out_Ctrl_Chunks;
Ip_u64 sctp_Out_Order_Chunks;
Ip_u64 sctp_Out_Unorder_Chunks;
Ip_u64 sctp_In_Ctrl_Chunks;
Ip_u64 sctp_In_Order_Chunks;
Ip_u64 sctp_In_Unorder_Chunks;
Ip_u64 sctp_Frag_UsrMsgs;
Ip_u64 sctp_Reasm_UsrMsgs;
Ip_u64 sctp_Out_SCTP_Packs;
Ip_u64 sctp_In_SCTP_Packs;
Ip_u32 sctp_Discontinuity_Time;
/* End: mib in RFC3873 */
}
Ipsctp_mib_stats;
typedef struct Ipsctp_params_sturct {
Ip_s32 sctpRtoAlgorithm;
Ip_u32 sctpRtoMin;
Ip_u32 sctpRtoMax;
Ip_u32 sctpRtoInitial;
Ip_s32 sctpMaxAssocs;
Ip_u32 sctpValCookieLife;
Ip_u32 sctpMaxInitRetr;
}Ipsctp_params;
typedef struct Ipsctp_assoc_entry_struct {
Ip_u32 sctpAssocId;
Ip_u8 sctpAssocRemHostName[256];
Ip_u32 sctpAssocLocalPort;
Ip_u32 sctpAssocRemPort;
Ip_s32 sctpAssocRemPrimAddrType;
Ip_u8 sctpAssocRemPrimAddr[16];
Ip_u32 sctpAssocHeartBeatInterval;
Ip_s32 sctpAssocState;
Ip_u32 sctpAssocInStreams;
Ip_u32 sctpAssocOutStreams;
Ip_u32 sctpAssocMaxRetr;
Ip_u32 sctpAssocPrimProcess;
Ip_u32 sctpAssocT1expireds;
Ip_u32 sctpAssocT2expireds;
Ip_u32 sctpAssocRtxChunks;
Ip_u32 sctpAssocStartTime;
Ip_u32 sctpAssocDiscontinuityTime;
}Ipsctp_assoc_entry;
typedef struct Ipsctp_assoc_local_addr_entry_struct
{
Ip_s32 sctpAssocLocalAddrType;
Ip_u8 sctpAssocLocalAddr[16];
Ip_u32 sctpAssocLocalAddrStartTime;
Ip_u32 sctpAssocId;
}Ipsctp_assoc_local_addr_entry;
typedef struct Ipsctp_assoc_rem_addr_entry_struct {
Ip_s32 sctpAssocRemAddrType;
Ip_u8 sctpAssocRemAddr[16];
Ip_s32 sctpAssocRemAddrActive;
Ip_s32 sctpAssocRemAddrHBActive;
Ip_u32 sctpAssocRemAddrRTO;
Ip_u32 sctpAssocRemAddrMaxPathRtx;
Ip_u32 sctpAssocRemAddrRtx;
Ip_u32 sctpAssocRemAddrStartTime;
Ip_u32 sctpAssocId;
}Ipsctp_assoc_rem_addr_entry;
#endif
/*
* Forward declarations
*/
struct Ipnet_dst_cache_struct;
/*
****************************************************************************
* 6 PUBLIC FUNCTIONS
****************************************************************************
*/
IP_PUBLIC int ipnet_sock_sctp_register(void);
IP_GLOBAL void ipsctp_input(struct Ipnet_dst_cache_struct *dst,
Ipcom_pkt *pkt);
#ifdef IPCOM_USE_INET
IP_PUBLIC void ipsctp_icmp4_cb(IP_CONST Ipcom_pkt *pkt);
#endif
#ifdef IPCOM_USE_INET6
IP_PUBLIC void ipsctp_icmp6_cb(Ipcom_pkt *pkt, Ipnet_pkt_icmp6 *icmp6, Ipnet_pkt_ip6 *failed_ip6_hdr);
#endif
IP_PUBLIC void ipsctp_window_update(struct Ipnet_sig_sctp_wu *sig);
IP_PUBLIC int ipsctp_usr_recv(Ipsctp_socket *sock,
struct Ip_msghdr *msg,
int flags);
IP_PUBLIC void ipsctp_pkt_drain(void);
IP_PUBLIC int ipsctp_usr_sock_get_tcb_info_tcp(Ipnet_socket *sock,
IP_CONST struct Ip_msghdr *msg,
struct Ipsctp_sndrcvinfo *sndrcv,
Ip_u32 *pmtu,
Ip_u32 *mss,
void **tcb_ret);
IP_PUBLIC int ipsctp_usr_sock_get_tcb_info_udp(Ipnet_socket *sock,
IP_CONST struct Ip_msghdr *msg,
struct Ipsctp_sndrcvinfo *sndrcv,
Ip_u32 *pmtu,
Ip_u32 *mss,
void **tcb_ret);
IP_PUBLIC int ipsctp_usr_sock_sendbuf_add_and_return(Ipnet_socket *sock,
void *tcb_locked,
int bytes);
IP_PUBLIC void ipsctp_usr_sock_sendbuf_sub(Ipnet_socket *sock,
void *tcb_locked,
int bytes);
IP_PUBLIC int ipsctp_output(Ipsctp_socket *sock,
IP_CONST struct Ip_msghdr *msg,
Ipcom_pkt *pkt);
IP_PUBLIC void ipsctp_set_state(struct Ipnet_sig_sctp_set_state *sig);
IP_PUBLIC Ip_err ipsctp_create(void);
IP_PUBLIC const char *ipsctp_version(void);
IP_PUBLIC int ipsctp_fls(Ip_u32 mask);
IP_PUBLIC Ip_err ipsctp_start(void);
IP_PUBLIC int
ipsctp_accept(Ipsctp_socket *listen_sock,
struct Ip_sockaddr *addr,
Ip_socklen_t *addrlen);
IP_PUBLIC int
ipsctp_close(Ipsctp_socket *sock);
IP_PUBLIC int
ipsctp_listen(Ipsctp_socket *sock,
int backlog);
IP_PUBLIC void
ipsctp_shutdown(Ipsctp_socket *sock, int how);
IP_PUBLIC int
ipsctp_getsockopt(Ipsctp_socket *sock,
int level,
int optname,
void *optval,
Ip_socklen_t *optlen);
IP_PUBLIC int
ipsctp_setsockopt(Ipsctp_socket *sock,
int level,
int optname,
IP_CONST void *optval,
Ip_socklen_t optlen);
IP_PUBLIC int
ipsctp_ioctl(Ipsctp_socket *sock,
unsigned long request,
void *argp);
IP_PUBLIC int
ipsctp_getname(Ipsctp_socket *sock,
struct Ip_sockaddr *name,
Ip_socklen_t *namelen,
Ip_bool local);
IP_PUBLIC int
ipsctp_sock_init(Ipsctp_socket *sock);
IP_PUBLIC void
ipsctp_sock_free(Ipsctp_socket *sock);
IP_PUBLIC int
ipsctp_bind(Ipsctp_socket *sock,
IP_CONST struct Ip_sockaddr *name,
Ip_socklen_t namelen);
IP_PUBLIC int
ipsctp_connect(Ipsctp_socket *sock,
IP_CONST struct Ip_sockaddr *to);
IP_PUBLIC Ipsctp_socket *
ipsctp_sock_lookup_sa(Ip_u16 vr,
int sa_family,
IP_CONST void *local_addr,
Ip_u16 local_port);
IP_PUBLIC void *
ipsctp_get_netstat_info(Ipsctp_socket *sock);
IP_PUBLIC void
ipsctp_sys_send_init(Ip_fd fd, Ip_u32 vtag);
#ifdef IPSCTP_MIB
IP_PUBLIC int
ipsctp_mib_stats_lookup(Ipsctp_mib_stats **stats);
IP_PUBLIC void
ipsctp_mib_stats_get(Ipsctp_mib_stats **stats);
IP_PUBLIC int
ipsctp_mib_params_lookup(Ipsctp_params **params);
IP_PUBLIC Ipsctp_assoc_entry *
ipsctp_mib_assoc_entry_lookup(Ip_u32 vtag,
int getnext);
IP_PUBLIC void
ipsctp_mib_set_assoc_state(Ipsctp_assoc_entry *assoc_entry,
Ip_s32 state);
IP_PUBLIC Ipsctp_assoc_local_addr_entry *
ipsctp_mib_assoc_local_addr_entry_lookup(Ip_u32 vtag,
Ip_s32 addrType,
Ip_u8 *addr,
int get_next);
IP_PUBLIC Ipsctp_assoc_rem_addr_entry *
ipsctp_mib_assoc_rem_addr_entry_lookup(Ip_u32 vtag,
Ip_s32 addrType,
Ip_u8 *addr,
int get_next);
#endif
#ifdef __cplusplus
}
#endif
#endif /* IPSCTP_H */
@@ -0,0 +1,965 @@
/* 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 */
File diff suppressed because it is too large Load Diff