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 */