📄 sctp_defs.h
字号:
uint32_t addr;};struct sctp_ipv6_addr { struct sctpphdr ph;};struct sctp_state_cookie { struct sctpphdr ph; struct sctp_cookie cookie[0];};struct sctp_unrec_parms { struct sctpphdr ph;};struct sctp_cookie_psrv { struct sctpphdr ph; uint32_t ck_inc;};struct sctp_host_name { struct sctpphdr ph;};struct sctp_addr_type { struct sctpphdr ph; uint16_t type[0];};union sctp_parm { struct sctpphdr ph; struct sctp_heartbeat_info heartbeat_info; struct sctp_ipv4_addr ipv4_addr; struct sctp_ipv6_addr ipv6_addr; struct sctp_state_cookie state_cookie; struct sctp_unrec_parms unrec_parms; struct sctp_cookie_psrv cookie_prsv; struct sctp_host_name host_name; struct sctp_addr_type addr_type;};/* * SCTP Chunk Types */#define SCTP_CTYPE_DATA 0#define SCTP_CTYPE_INIT 1#define SCTP_CTYPE_INIT_ACK 2#define SCTP_CTYPE_SACK 3#define SCTP_CTYPE_HEARTBEAT 4#define SCTP_CTYPE_HEARTBEAT_ACK 5#define SCTP_CTYPE_ABORT 6#define SCTP_CTYPE_SHUTDOWN 7#define SCTP_CTYPE_SHUTDOWN_ACK 8#define SCTP_CTYPE_ERROR 9#define SCTP_CTYPE_COOKIE_ECHO 10#define SCTP_CTYPE_COOKIE_ACK 11#define SCTP_CTYPE_ECNE 12#define SCTP_CTYPE_CWR 13#define SCTP_CTYPE_SHUTDOWN_COMPLETE 14#define SCTP_CTYPE_MASK 0x3f#define SCTP_CTYPE_MASK_CONTINUE 0x80#define SCTP_CTYPE_MASK_REPORT 0x40/* * SCTP Chunk Structures */struct sctp_data { struct sctpchdr ch; uint32_t tsn; /* Transmit Sequence Number */ uint16_t sid; /* Stream Identifier */ uint16_t ssn; /* Stream Sequence Number */ uint32_t ppi; /* Payload Protocol Identifier */ uint8_t udat[0]; /* User data */};struct sctp_init { struct sctpchdr ch; uint32_t i_tag; /* Initiate Tag */ uint32_t a_rwnd; /* Advertised Received Window Credit */ uint16_t n_ostr; /* Number of Outbound Streams */ uint16_t n_istr; /* Number of Inbound Streams */ uint32_t i_tsn; /* Initial TSN */ };struct sctp_init_ack { struct sctpchdr ch; uint32_t i_tag; /* Initiate Tag */ uint32_t a_rwnd; /* Advertised Received Window Credit */ uint16_t n_ostr; /* Number of Outbound Streams */ uint16_t n_istr; /* Number of Inbound Streams */ uint32_t i_tsn; /* Initial TSN */};struct sctp_sack { struct sctpchdr ch; uint32_t c_tsn; /* Cumulative TSN Ack */ uint32_t a_rwnd; /* Advertized Receiver Window Credit */ uint16_t ngaps; /* Number of Gap Blocks */ uint16_t ndups; /* Number of Duplicate TSNs */ uint16_t gaps[0]; /* Gap blocks */ uint32_t dups[0]; /* Duplicate TSNs */};struct sctp_heartbeat { struct sctpchdr ch;};struct sctp_heartbeat_ack { struct sctpchdr ch;};struct sctp_abort { struct sctpchdr ch; union sctp_cause cause[0];};struct sctp_shutdown { struct sctpchdr ch; uint32_t c_tsn; /* Cummulative TSN Ack */};struct sctp_shutdown_ack { struct sctpchdr ch;};struct sctp_error { struct sctpchdr ch; union sctp_cause cause[0];};struct sctp_cookie_echo { struct sctpchdr ch; unsigned char cookie[0];};struct sctp_cookie_ack { struct sctpchdr ch;};struct sctp_ecne { struct sctpchdr ch; uint32_t l_tsn;};struct sctp_cwr { struct sctpchdr ch; uint32_t l_tsn;};struct sctp_shutdown_comp { struct sctpchdr ch;};union sctp_chunk { struct sctpchdr ch; struct sctp_data data; struct sctp_init init; struct sctp_init_ack init_ack; struct sctp_sack sack; struct sctp_heartbeat heartbeat; struct sctp_heartbeat_ack heartbeat_ack; struct sctp_abort abort; struct sctp_shutdown shutdown; struct sctp_shutdown_ack shutdown_ack; struct sctp_error error; struct sctp_cookie_echo cookie_echo; struct sctp_cookie_ack cookie_ack; struct sctp_ecne ecne; struct sctp_cwr cwr; struct sctp_shutdown_comp shutdown_comp;};/* * SCTP Message Structures */struct sctp_msg { struct sctphdr mh; union sctp_chunk chunk;};/* * ADLER 32 CHECKSUM * ------------------------------------------------------------------------- * Compute the adler32 checksum. This follows the description in RFC 2960 * Appendix B. Borrowed from zlib.c. */#define BASE 65521L /* largest prime smaller than 65536 */#define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);#define DO16(buf) DO8(buf,0); DO8(buf,8);static inline uint32_t adler32(uint32_t adler, void *buf, size_t len){ register uint32_t s1 = adler; register uint32_t s2 = (adler >> 16) & 0xffff; register uint8_t *ptr = buf; int k; if ( !ptr ) return 1L; while ( len > 0 ) { k = len < NMAX ? len : NMAX; len -= k; while ( k >= 16 ) { DO16(ptr); ptr += 16; k -= 16; } if ( k != 0 ) do { s1 += *ptr++; s2 += s1; } while ( --k ); s1 %= BASE; s2 %= BASE; } return (s2 << 16) | s1;}/* * Message control block datastructures: * ------------------------------------------------------------------------- *//* message control block */typedef struct sctp_tcb { /* for gaps, dups and acks on receive, frag on transmit */ struct sctp_tcb *next; /* message linkage */ struct sctp_tcb *prev; /* message linkage */ struct sctp_tcb *tail; /* message linkage */ struct sctp_tcb *head; /* message linkage */ mblk_t *mp; /* message linkage */ struct sctp_daddr *daddr; /* daddr tx to or rx from */ struct sctp_strm *st; /* strm tx to or rx from */ struct sctp_cookie *cookie; /* cookie if this is COOKIE ECHO msg */ unsigned long when; /* time of tx/rx/ack */ size_t trans; /* number of times retransmitted */ size_t sacks; /* number of times gap acked */ size_t dlen; /* data length */ ulong flags; /* general flags inc. data chunk flags */ uint32_t tsn; /* why do I need these?, they are in the chunk header */ uint16_t sid; uint16_t ssn; uint32_t ppi;} sctp_tcb_t;#define SCTP_TCB(__mp) ((sctp_tcb_t *)((__mp)->b_datap->db_base))#define SCTP_IPH(__mp) ((struct iphdr *)((__mp)->b_datap->db_base))/* * Some sctp_tcb flags. */#define SCTPCB_FLAG_LAST_FRAG 0x0001 /* aligned with SCTP DATA chunk flags */#define SCTPCB_FLAG_FIRST_FRAG 0x0002 /* aligned with SCTP DATA chunk flags */#define SCTPCB_FLAG_URG 0x0004 /* aligned with SCTP DATA chunk flags */#define SCTPCB_FLAG_UNUSED1 0x0100#define SCTPCB_FLAG_DELIV 0x0200 /* delivered to user on read */#define SCTPCB_FLAG_ACK 0x0400#define SCTPCB_FLAG_NACK 0x0800#define SCTPCB_FLAG_CONF 0x1000#define SCTPCB_FLAG_SENT 0x2000#define SCTPCB_FLAG_RETRANS 0x4000#define SCTPCB_FLAG_SACKED 0x8000#endif __SCTP_DEFS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -