⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcp.h

📁 用于嵌入式系统的TCP/IP协议栈及若干服务
💻 H
📖 第 1 页 / 共 3 页
字号:
/**            Copyright (c) 1998-2001 by NETsilicon Inc.**  This software is copyrighted by and is the sole property of*  NETsilicon.  All rights, title, ownership, or other interests*  in the software remain the property of NETsilicon.  This*  software may only be used in accordance with the corresponding*  license agreement.  Any unauthorized use, duplication, transmission,*  distribution, or disclosure of this software is expressly forbidden.**  This Copyright notice may not be removed or modified without prior*  written consent of NETsilicon.**  NETsilicon, reserves the right to modify this software*  without notice.**  NETsilicon*  411 Waverley Oaks Road                  USA 781.647.1234*  Suite 227                               http://www.netsilicon.com*  Waltham, MA 02452                       AmericaSales@netsilicon.com***************************************************************************  $Name: Fusion 6.52 $*  $Date: 2002/04/10 16:04:20 $*  $Source: M:/psisrc/stack/incl/rcs/tcp.h $*  $Revision: 1.31.2.2 $***************************************************************************  File Description:  TCP (Transmission Control Protocol) defines***************************************************************************/#ifndef _TCP_#define _TCP_#include "config.h"#include "ccdep.h"#include "q.h"#include "std.h"#include "socket.h"#include "timer.h"#include "dsu.h"#include "psu.h"#include "so.h"#include "ip.h"#include "m.h"/* TCP header */typedef u8 TCPH_T;#define TCPH_SPORT    0                 /* source port number, 2 bytes */#define TCPH_DPORT    (TCPH_SPORT+2)    /* destination port number, 2 bytes */#define TCPH_SEQNO    (TCPH_DPORT+2)    /* sequence number of first data byte, 4 bytes */#define TCPH_ACKNO    (TCPH_SEQNO+4)    /* sequence number we next expect, 4 bytes */#define TCPH_FLAGS    (TCPH_ACKNO+4)    /* 4 bits data offset : 12 bits flags, 2 bytes */#define TCPH_WINDOW   (TCPH_FLAGS+2)    /* how much data can be accepted now, 2 bytes */#define TCPH_CHECKSUM (TCPH_WINDOW+2)   /* ones complement checksum, 2 bytes */#define TCPH_URGENT   (TCPH_CHECKSUM+2) /* urgent pointer, 2 bytes */#define SIZEOF_TCPH_T (TCPH_URGENT+2)/* Maximum size possible for the options in a TCP header. Limited by the fact   that the data offset field is 4 bits (thus the highest value is 15, and its    unit is 32-bit words, thus the maximum data offset is 60), and the size of    the standard TCP header is 20 bytes */#define TCP_MAX_SEG_OPTSIZE 40          #if ( defined(TCP_SS_CA_FRETR_FREC) || defined(TCP_SELACK_ENHANCEMENTS) )#define TCP_RETRANSMIT_ENHANCEMENTS#endif/*****************************************************************//* definitions pertaining to TCP options                         *//*****************************************************************//* offsets from the beginning of any particular option into the   fields of that option */typedef u8 TCPO_T;#define TCPO_KIND     0                 /* 1 byte */#define TCPO_SIZE     (TCPO_KIND+1)     /* 1 byte */#define TCPO_VAL      (TCPO_SIZE+1)     /* "size" bytes */#define TCPO_EOL_KIND      0     /* End of option list *//* no other fields */#define TCPO_NOP_KIND      1     /* No operation, used for padding */#define TCPO_NOP_LEN       1/* no other fields */#define TCPO_MSS_KIND      2     /* Maximum segment size */#define TCPO_MSS_LEN       4     #define TCPO_WSF_KIND      3     /* Window scale factor */#define TCPO_WSF_LEN       3#define TCPO_SACK_PERMITTED_KIND 4     /* Selective-Acknowledgements permitted */#define TCPO_SACK_PERMITTED_LEN  2#define TCPO_SACK_KIND     5           /* Selective Acknowledgement option *//* Length of this option is variable, depending on how many SACKS are included */#define TCPO_SACK_BLOCK_SIZE 8         /* Size of each block in a SACK option */#define TCPO_TMSTMP_KIND   8     /* Time-Stamp */#define TCPO_TMSTMP_LEN    10  #define TCPO_TMSTMP_TSVAL  (TCPO_VAL)  /* 4 bytes in length */#define TCPO_TMSTMP_TSECR  (TCPO_TMSTMP_TSVAL + 4)/*******************************************************//* Options related to Transaction TCP                  */#define TCPO_CC_KIND       11     /* Connection Count */#define TCPO_CC_LEN        6#define TCPO_CC_VAL        (TCPO_VAL)  /* 4 bytes in length */#define TCPO_CCNEW_KIND    12     /* Connection Count (new) */#define TCPO_CCNEW_LEN     6     #define TCPO_CCNEW_VAL     (TCPO_VAL)  /* 4 bytes in length */#define TCPO_CCECHO_KIND   13     /* Connection Count (new) */#define TCPO_CCECHO_LEN    6     #define TCPO_CCECHO_VAL    (TCPO_VAL)  /* 4 bytes in length *//* Must update the following if any higher-numbered kinds are added */#define TCPO_HIGHEST_KIND TCPO_CCECHO_KIND#define TCP_DRMSS       536     /* Default Receive Maximum Segment Size, as per                                    RFC 1122, section 4.2.2.6 *//* flags in TCP header ('tcph_flags') */#define URG     ((u16)0x0020)   /* URGent pointer is significant */#define ACK     ((u16)0x0010)   /* ACKnowledgement field is significant */#define PSH     ((u16)0x0008)   /* PuSH function active in this segment */#define RST     ((u16)0x0004)   /* connection ReSeT directive */#define SYN     ((u16)0x0002)   /* SYNchronize seq numbers directive */#define FIN     ((u16)0x0001)   /* FINished, no more data from sender, start close */#define FLAG_MASK       ((u16)0x0FFF)   /* top 4 bits is data offset */#define RSVD_FLGS       ((u16)0x0FC0)   /* these bits are reserved *//* macros to test the states of flags */#define URG_ON(f)       bT1((f), URG)#define URG_OFF(f)      bF1((f), URG)#define ACK_ON(f)       bT1((f), ACK)#define ACK_OFF(f)      bF1((f), ACK)#define PSH_ON(f)       bT1((f), PSH)#define PSH_OFF(f)      bF1((f), PSH)#define RST_ON(f)       bT1((f), RST)#define RST_OFF(f)      bF1((f), RST)#define SYN_ON(f)       bT1((f), SYN)#define SYN_OFF(f)      bF1((f), SYN)#define FIN_ON(f)       bT1((f), FIN)#define FIN_OFF(f)      bF1((f), FIN)/* length of TCP header */#define tcphl(tcphp)    ((NetToHost16(&(tcphp)[TCPH_FLAGS]) >> 10) & 0x3C)#define TCPHL tcphl/* length of options part of TCP header */#define TCPHOPTL(tcphp)   ( TCPHL(tcphp) - SIZEOF_TCPH_T)/* pointer to the beginning of the options part of TCP header (should only be   used if actually is an options part, i.e.mTCPHOPTL is non-zero */#define TCPHOPTPTR(tcphp) (&( ( ((char *)tcphp)[SIZEOF_TCPH_T]) ) )#ifdef TCP_SELACK_ENHANCEMENTS/* Definitions pertaining to selective ack processing *//* most SACK blocks that can fit into the options field of a TCP header which   is devoid of any other options */#define MAX_NUM_OUT_SACK_BLOCKS 4/* The maximum number of incoming SACK blocks that Fusion will remember for a   connection. */#define MAX_NUM_IN_SACK_BLOCKS  8/* structure of information from which a single SACK block option can be constructed */typedef struct _tcp_sack_block_ {   u32 begin_seqno;   u32 end_seqno;} tcp_sack_block_;#endif /* TCP_SELACK_ENHANCEMENTS */#define MOD32   /* for tcpsv_t */#ifndef _MODULO_#include "modulo.h"#endif#ifdef  SV_SKEPTIC#define MAXREF  20#define sv_bind(svp, ref, m_ok) _sv_bind(svp, ref, m_ok)#define sv_detach(svp, ref, m_ok)       _sv_detach(svp, ref, m_ok)#else/* #define sv_bind(svp, ref, m_ok) _sv_bind(svp)    */#define sv_bind(svp,ref,m_ok) (svp)->sv_refcnt++;#define sv_detach(svp, ref, m_ok)       _sv_detach(svp)#endif/* Transmission Control Protocol Statistics Record */typedef struct tcpsr_s  {    u32     sr_avgbpc;      /* current (smoothed) average bytes / click */    u8      sr_nsamples;    /* # of samples in the above average */    u8      sr_1pad;    u16     sr_flags;       /* status and control (see below) */} tcpsr_t;/* values of 'sr_flags' *//* no special ones yet; some values of 'sv_rsflags' (below) also apply */#ifdef TCP_TRANSACTION_TCP#include "tcptrans.h"#endif/* Transmission Control Protocol State Vector */typedef struct tcpsv_t  {  /* TCP state vector */    q       sv_q;           /* queue of active state vectors */    ipa     sv_src;         /* source address */    ipa     sv_dest;        /* destination address */    u16     sv_state;       /* state of connection */    u16     sv_refcnt;      /* state vector reference count */    u16     sv_flags;       /* historical state & pending actions */	u16		sv_flags2;      /* More flags -- used separate u16 instead of changing 							   sv_flags into u32 so that the existing flag checks							   wouldn't cause 32-bit fetches -- maybe saves performance							   loss */	u16		sv_rcv_mss;     /* The receive MSS which has been set by a the							   TCP_SET_RCV_MSS socket option. If this option has							   been set, then this value will be advertised in the 							   outgoing SYN instead of using the send MSS value */#ifdef IP_RFC_1191    u16		sv_peer_mss;    /* The MSS option value that was received from the peer 							   (if any) in a SYN segment. Must be remembered because							   we not never adjust our operational send MSS larger							   than this (e.g., as a result of path MTU discovery							   notifications). */#endif /* IP_RFC_1191 */    u16     sv_mss;         /* max. segment size (not including standard TCP header) */	u16		sv_mssd;		/* maximum user data size in a maximum-sized segment 							   (mss - length of the options field) -- included for							   performance purposes, so that this value doesn't							   have to be determined on a per-segment basis, involving							   computations and function calls). This value is set							   at the same time as sv_mss, and it is assumed that							   all incoming and outgoing data segments will have the							   same-sized options field */	u16		sv_dseg_options; /* contains a bitmask of the options that will be present							    in data segments on this connection. Present for the same								reason as sv_mssd -- to minimize need for per-segment								CPU-cosnuming function calls */	u16		sv_mss_m_len;   /* message length that will be allocated for 							    outgoing segements with mss worth of data */    u32     sv_sq_max;      /* max size of the socket send queue for this TCP                               connection. If the sq_max is adjusted downward                               in response to a source quench, it will gradually                               be adjusted upward back to this value */    u32     sv_rq_max;      /* size of the socket receive queue for this TCP connection.*/#ifdef SOCKET_USE_OLD_SOCKOPT_FUNCTIONS    u16     sv_soptions;    /* copy of 'so_options' from socket */#else    u32     sv_soptions;    /* copy of 'so_options' from socket */#endif    u8      sv_tos;         /* copy of 'ipsu.ipsu_tos' from socket */    u8      sv_prec;        /* precedence */    u16     sv_err;         /* error which terminated this state vector */    u16     sv_soindx;      /* socket index (for validation of sv_sop) */    so_t    * sv_sop;       /* pointer to the socket this is attached to */    /* These variables defined on pgs. [70..71] MIL-STD-1778 */    m32     sv_snxt;        /* Send_NXT */    m32     sv_suna;        /* Send_UNA */    m32     sv_surg;        /* Send_URG */    m32     sv_spsh;        /* Send_PuSH */    m32     sv_rnxt;        /* Recv_NeXT */    m32     sv_rurg;        /* Recv_URG */    m32     sv_read;        /* Next byte for ULP to read (used for urgent data processing) */    m32     sv_sisn;        /* Send_Initial_Sequence_Number */    u32     sv_swnd;        /* Send_WNDw */#ifdef TCP_SS_CA_FRETR_FREC     u32     sv_cwnd;        /* Congestion window for slow start/congestion avoidance */	u32		sv_ssthresh;     /* Slow start threshold for slow start/congestion avoidance */#define TCP_OPERATIONAL_SEND_WINDOW(s) ( min(s->sv_swnd, s->sv_cwnd) )#endif#ifdef TCP_WND_SCALE	u16		sv_swndscale;   /* Send window scale */#endif    IPOS_T  sv_sec[SIZEOF_IPOS_T]; /* security structure */    /* (re)transmission smarts */    struct tcb * sv_rextcb; /* retransmission timer */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -