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

📄 tcp.h

📁 用于嵌入式系统的TCP/IP协议栈及若干服务
💻 H
📖 第 1 页 / 共 3 页
字号:
/*********************//* codes in sv_flags2 */#ifdef TCP_WND_SCALE#define SV_WSCALE_PERMITTED       ((u16)0x1)/* Window scaling permitted on this socket. This                                             is set via the TCP_WINDOW_SCALE option. It 											 means that we will attempt to negotiate											 window scaling during connection setup. The											 outcome of that negotiation is contained											 in another flag. */#define SV_WSCALE_ENABLED         ((u16)0x2)/* Window scaling has been negotiated on this											  connection, and should be applied to the											  window fields of any outgoing or incoming 											  segments. */#define TCP_MAX_WINDOW_FIELD_VALUE ( (1 << 30) - 1) /* per RFC 1323 */#else#define TCP_MAX_WINDOW_FIELD_VALUE 65535#endif /* TCP_WIND_SCALE */#ifdef TCP_RTTM#define SV_RTTM_RFC_1323          ((u16)0x4)/* We will use the round-trip measurement											   algorithm defined in RFC 1323, as 											   opposed to the standard RTT algorithm											   (Provided that the timestamps option											   is succesfully negotiated during connection											   setup. This is selectable via a socket 											   option prior to connection setup */#endif /* TCP_RTTM */#ifdef TCP_PAWS#define SV_PAWS_ENABLED           ((u16)0x8) /* We will use the "protect against wrapped											   sequence numbers" algorithm defined in											   RFC1323, provided that timestamps option											   is succesfully negotiated during connection											   setup. This is selectable via a socket 											   option prior to connection setup */#endif /* TCP_PAWS */#ifdef TCP_TIMESTAMPS#define SV_PROVIDE_TIMESTAMPS     ((u16)0x10) /*The socket option for providing timestamps											   has been set, so we will attempt to 											   negotiate timestamps on this connection											   (even if SV_RTTM_RFC_1323 is not set) */											   #define SV_TIMESTAMPS_ENABLED     ((u16)0x20) /*The timestamps option has been negotiated											   on this connection. We will send and echo											   timestamps on each outgoing segment, and											   will process echoed timestamps in incoming											   segments. If PAWS is enabled, we will use											   timestamps in incoming segments for 											   detection of duplicate segments. If RFC 1323											   RTTM is operating (per socket option) we											   will use echoed timestamps in incoming											   segments for round-trip-time measurement */#endif /* TCP_TIMESTAMPS */#define SV_USE_PEER_MSS_OPTION    ((u16)0x40) /* Socket option TCP_USE_PEER_MSS_OPTION has											    been specified. Means that, if an MSS												option is received in a SYN, its value will												be used regardless of whether it is larger												or smaller than than IP's MTU */#define SV_GOT_PEER_MSS_OPTION    ((u16)0x80) /* We have received the peer's MSS option */#ifdef TCP_SELACK_ENHANCEMENTS#define SV_PERMIT_IN_SACKS        ((u16)0x100) /* We will send the SACK_PERMITTED option												  with our SYN, and if SACKs are received,												  we will process them. This flag is set                                                  via the TCP_PERMIT_SACKS socket option */#define SV_OUT_SACKS_ALLOWED      ((u16)0x200) /* If we receive a SACK_PERMITTED option												  with the incoming SYN, then we will send												  SACKS during the connection. This flag is												  set via the TCP_SEND_SACKS socket                                                   option. If not set, we will ignore the												  SACK_PERMITTED option */#define SV_OUT_SACKS_ENABLED      ((u16)0x400) /* Indicates that we should send SACKS.												  This flag is set only if the 												  TCP_SEND_SACKS socket option is set AND												  a SACK_PERMITTED option is received from												  the peer */#endif /* TCP_SELACK_ENHANCEMENTS */#ifdef TCP_SS_CA_FRETR_FREC#define SV_FAST_RETR_RECOV       ((u16)0x800) /* Indicates that fast retransmit/recovery												  algorithms are enabled */#define SV_SLOW_START_CA         ((u16)0x1000) /* Indicates that slow start/congestion												  avoidance algorithms are enabled */#endif /* TCP_SS_CA_FRETR_FREC */#define SV_NAGLE_DISABLED        ((u16)0x2000) /* If set, disables the send-side												  silly-window-syndrome avoidance												  (Nagle Algorithm) *//* 0x4000 is available *//* 0x8000 is available */#ifdef TCP_TIMESTAMPS#if ( defined(TCP_RTTM) && defined(TCP_PAWS) )#define TIMESTAMPS_DESIRED(svp) (svp->sv_flags2 & \                                    (SV_PROVIDE_TIMESTAMPS | SV_RTTM_RFC_1323 \                                     | SV_PAWS_ENABLED) )#elif ( defined(TCP_RTTM) )#define TIMESTAMPS_DESIRED(svp) (svp->sv_flags2 & \                                    (SV_PROVIDE_TIMESTAMPS | SV_RTTM_RFC_1323) )#elif ( defined(TCP_PAWS) )#define TIMESTAMPS_DESIRED(svp) (svp->sv_flags2 & \                                    (SV_PROVIDE_TIMESTAMPS | SV_PAWS_ENABLED) )#else#define TIMESTAMPS_DESIRED(svp) (svp->sv_flags2 & SV_PROVIDE_TIMESTAMPS)#endif#endif /* TCP_TIMESTAMPS */#ifdef TCP_RTTM#define RTTM_USING_RFC1323(svp) ( (svp->sv_flags2 & SV_RTTM_RFC_1323) && \                                  (svp->sv_flags2 & SV_TIMESTAMPS_ENABLED) ) #endif /* TCP_RTTM */#ifdef TCP_PAWS#define DOING_PAWS(svp) ( (svp->sv_flags2 & SV_PAWS_ENABLED) && \                          (svp->sv_flags2 & SV_TIMESTAMPS_ENABLED) )                               #endif /* TCP_PAWS */#ifdef OS_CURRENT_HRES_TIME#define TCP_CURRENT_HRES_TIME OS_CURRENT_HRES_TIME#define TCP_HRES_TIMER_GRANULARITY OS_HRES_TIMER_GRANULARITY#else#define TCP_CURRENT_HRES_TIME t_time#define TCP_HRES_TIMER_GRANULARITY MS_PER_TICK#endif#ifdef TCP_PAWS/* The following constant represents the number of fusion timer ticks in a 24-day    period, which RFC1323 specifies is the maximum amount of time a ts.recent	value can go without being updated before it is considered invalid. */#define TCP_PAWS_MAX_IDLE_TICKS ( (24 * 24 * 60 * 60 * 1000)/MS_PER_TICK )#endif/* flags used in m_pflags */#define RCURRENT        0x0001/* 9.4.6.2 Decision functions. pg. [120] *//* return values for functions */#define NO      0#define YES     1#define NONE    0#define VALID   1#define INVALID 2#define PASSIVE 0#define ACTIVE  1#define LESS    -1#define EQUAL   0#define GREATER 1/* Connection states in 'sv_state' - 9.2.2.4 [72..73] *//* These values are specifically ordered.  Do not change the values   unless you know exactly what effects will occur.  The ordering is   approximately the order in which state transitions are made. */#define CLOSED          0       /* must be zero! */#define LISTEN          1#define SYN_SENT        2#define SYN_RECVD       3#define ESTAB           4#define CLOSE_WAIT      5#define FIN1_WAIT       6#define FIN2_WAIT       7#define CLOSING         8#define LAST_ACK        9#define TIME_WAIT       10/* timing constants */#ifndef TCP_MSL#define TCP_MSL         (2 * 60)                 /* maximum segment lifetime (2 minutes) */#endif#define ONEMSL          ((u32) (TCP_MSL * 1000) ) /* Maximum Segment Lifetime (2 minutes) */#define TWOMSL          (ONEMSL << 1)           /* 2 Maximum Segment Lifetimes */#define CLOSE_TIME      ONEMSL                  /* Amount of time to hang around in the CLOSED state (milliseconds) */#define TCP_IRTT        1250                    /* Initial round-trip-time guestimate */#define DEFAULT_LINGER_TIME 60      /* 60 seconds */#define TCP_MIN_FREE            771     /* was 256 */                /* Changed to 771 for Berkeley compatibility*//* Minimum time to stay in the TIMED_WAIT state after receiving/acking the final FIN    of an active close. This can be shortened for testing purposes */#define TCP_MIN_TIME_WAIT TWOMSL/* reset_self codes (see 'tcp_rslf') */#define NO_REPORT       0#define AB_RA   FNS_ECONNRESET#define AB_NF   FNS_ENETDOWN#define AB_SP   FNS_ESECURITY#define AB_UT   FNS_ETIMEDOUT#define AB_UA   FNS_ECONNABORTED#define AB_UC   FNS_ECONNABORTED#define AB_SF   FNS_ENETUNREACH#ifdef TCP_KEEP_ALIVE#define TRY_GD          1#define TRY_NOGD        2#define GARBAGE_DATA    3#define NO_GARBAGE_DATA 4#define so_keepalive(x) GET_SOCKET_OPTION_STATUS(x,SO_KEEPALIVE)#endif/* TCP Timer constants *//* For Ack delay */#ifndef MAX_ACK_DELAY#define MAX_ACK_DELAY   (u32)200#endif/* Value to initialize the smoothed round trip time for purpose of round trip   measurement and adjustment */#ifndef SRTT_INITIAL_VALUE#define SRTT_INITIAL_VALUE 2500#endif#ifndef HALLOC_REX_DELAY#define HALLOC_REX_DELAY (u32)100  /* retry delay when no buffers available to send data */#endif/* Initial retransmission delay when sending a packet. Gets adjusted via round-trip-time   measurements to be proportional to the measured smooth round-trip time */#ifndef INITIAL_REX_DELAY#define INITIAL_REX_DELAY       (u32) (SRTT_INITIAL_VALUE << 1) #endif/* Minimum retransmission delay when sending a packet. If the computed value is smaller   than this value, this value is used */#ifndef MIN_REX_DELAY#define MIN_REX_DELAY           (u32) 1000#endif/* Maximum retransmission delay when sending a packet. If the computed value is larger   than this value, this value is used */#ifndef MAX_REX_DELAY#define MAX_REX_DELAY           (u32) 10000#endif#ifndef PROBE_REX_DELAY#define PROBE_REX_DELAY         (u32)120000 /* 2 minutes probe interval */#endif#ifndef IMMEDIATE_REX_DELAY#define IMMEDIATE_REX_DELAY     (u32)1 /* Retransmission at the next tick */#endif#ifndef HALLOC_FIN_DELAY#define HALLOC_FIN_DELAY        (u32)1000 /* Retry delay when no empty buffer                  					available to queue in receive queue */ #endifimport int tcp_initial_rex_delay;import int tcp_min_rex_delay;import int tcp_max_rex_delay;/* MBM NOTE: The following switch is just to preserve (temporarily) some code that was    removed from Fusion 6.0 -- that pertaining to adjusting the ACK delay time dynamically   under certain conditions. The only conceivable reason for doing so (as far as I can see)   is to compensate for a peer that retransmits too eagerly -- i.e., we would lower our   ACK delay to a value that would be soon enough not to cause the peer to retransmit.   But the peer's retransmit backoff timer should take care of that -- anyway, we now   have a socket option to configure the ACK delay period.      But, leaving the code here, but not compiled, just in case we find we need    to restore it.    *//* #define NEED_ADJUST_ACK_DELAY *//* #define TCP_TRACE */#ifdef TCP_TRACE#define TCP_TRACE_SEGMENT(a,b) tcp_trace_segment(a,b)#else#define TCP_TRACE_SEGMENT(a,b) #endif#endif  /*_TCP_*/

⌨️ 快捷键说明

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