📄 net_tcp.h
字号:
*
* The following TCP option types are multi-octet TCP options where the option's second
* octet specify the total TCP option length, in octets, including the option type & the
* option length octets :
*
* (1) TYPE = 2 Maximum Segment Size See RFC #793, Section 3.1 'Header Format :
* Options : Maximum Segment Size';
* RFC #1122, Section 4.2.2.6;
* RFC # 879, Section 3
*
* (2) TYPE = 3 Window Scale See 'net_tcp.h Note #1c1'
* (3) TYPE = 4 SACK Allowed See 'net_tcp.h Note #1c2'
* (4) TYPE = 5 SACK Option See 'net_tcp.h Note #1c2'
* (5) TYPE = 6 Echo Request See 'net_tcp.h Note #1c3'
* (6) TYPE = 7 Echo Reply See 'net_tcp.h Note #1c3'
* (7) TYPE = 8 Timestamp See 'net_tcp.h Note #1c4'
*
* (3) TCP header allows for a maximum option list length of 40 octets :
*
* NET_TCP_HDR_OPT_SIZE_MAX = NET_TCP_HDR_SIZE_MAX - NET_TCP_HDR_SIZE_MIN
*
* = 60 - 20
*
* = 40
*
* (4) Data type MUST be globally declared PRIOR to certain dependent #define's.
*********************************************************************************************************
*/
/*$PAGE*/
#define NET_TCP_HDR_OPT_END_LIST 0
#define NET_TCP_HDR_OPT_NOP 1
#define NET_TCP_HDR_OPT_MAX_SEG_SIZE 2
#define NET_TCP_HDR_OPT_WIN_SCALE 3
#define NET_TCP_HDR_OPT_SACK_PERMIT 4
#define NET_TCP_HDR_OPT_SACK 5
#define NET_TCP_HDR_OPT_ECHO_REQ 6
#define NET_TCP_HDR_OPT_ECHO_REPLY 7
#define NET_TCP_HDR_OPT_TS 8
#define NET_TCP_HDR_OPT_PAD NET_TCP_HDR_OPT_END_LIST
#define NET_TCP_HDR_OPT_LEN_END_LIST 1
#define NET_TCP_HDR_OPT_LEN_NOP 1
#define NET_TCP_HDR_OPT_LEN_MAX_SEG_SIZE 4
#define NET_TCP_HDR_OPT_LEN_WIN_SCALE 3
#define NET_TCP_HDR_OPT_LEN_SACK_PERMIT 2
#define NET_TCP_HDR_OPT_LEN_ECHO_REQ 6
#define NET_TCP_HDR_OPT_LEN_ECHO_REPLY 6
#define NET_TCP_HDR_OPT_LEN_TS 10
#define NET_TCP_HDR_OPT_LEN_SACK_MIN 6
#define NET_TCP_HDR_OPT_LEN_SACK_MAX 38
#define NET_TCP_HDR_OPT_LEN_MIN 1
#define NET_TCP_HDR_OPT_LEN_MIN_LEN 2
#define NET_TCP_HDR_OPT_LEN_MAX 38
typedef CPU_INT32U NET_TCP_OPT_SIZE; /* TCP opt size data type (see Note #4). */
#define NET_TCP_HDR_OPT_SIZE_WORD (sizeof(NET_TCP_OPT_SIZE))
#define NET_TCP_HDR_OPT_SIZE_MAX (NET_TCP_HDR_SIZE_MAX - NET_TCP_HDR_SIZE_MIN)
#define NET_TCP_HDR_OPT_NBR_MIN 0
#define NET_TCP_HDR_OPT_NBR_MAX (NET_TCP_HDR_OPT_SIZE_MAX / NET_TCP_HDR_OPT_SIZE_WORD)
#define NET_TCP_HDR_OPT_IX NET_TCP_HDR_SIZE_MIN
/*$PAGE*/
/*
*********************************************************************************************************
* TCP OPTION CONFIGURATION TYPE DEFINES
*
* Note(s) : (1) NET_TCP_OPT_CFG_TYPE_??? #define values specifically chosen as ASCII representations of
* the TCP option configuration types. Memory displays of TCP option configuration buffers
* will display the TCP option configuration TYPEs with their chosen ASCII names.
*********************************************************************************************************
*/
/* ---------------- TCP OPT CFG TYPES ----------------- */
#if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
#define NET_TCP_OPT_CFG_TYPE_NONE 0x4E4F4E45 /* "NONE" in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x4D535320 /* "MSS " in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x57494E20 /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */
#define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x53434B50 /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_SACK 0x5341434B /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x45524551 /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x4543484F /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_TS 0x54532020 /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */
#else
#if (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_32)
#define NET_TCP_OPT_CFG_TYPE_NONE 0x454E4F4E /* "NONE" in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x2053534D /* "MSS " in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x204E4957 /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */
#define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x504B4353 /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_SACK 0x4B434153 /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x51455245 /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x4F484345 /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_TS 0x20205354 /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */
#elif (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_16)
#define NET_TCP_OPT_CFG_TYPE_NONE 0x4F4E454E /* "NONE" in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x534D2053 /* "MSS " in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x4957204E /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */
#define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x4353504B /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_SACK 0x41534B43 /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x52455145 /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x43454F48 /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_TS 0x53542020 /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */
#else /* Dflt CPU_WORD_SIZE_08. */
#define NET_TCP_OPT_CFG_TYPE_NONE 0x4E4F4E45 /* "NONE" in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE 0x4D535320 /* "MSS " in ASCII. */
#define NET_TCP_OPT_CFG_TYPE_WIN_SCALE 0x57494E20 /* "WIN " in ASCII (see 'net_tcp.h Note #1c1'). */
#define NET_TCP_OPT_CFG_TYPE_SACK_PERMIT 0x53434B50 /* "SCKP" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_SACK 0x5341434B /* "SACK" in ASCII (see 'net_tcp.h Note #1c2'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REQ 0x45524551 /* "EREQ" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_ECHO_REPLY 0x4543484F /* "ECHO" in ASCII (see 'net_tcp.h Note #1c3'). */
#define NET_TCP_OPT_CFG_TYPE_TS 0x54532020 /* "TS " in ASCII (see 'net_tcp.h Note #1c4'). */
#endif
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* TCP CONNECTION DEFINES
*********************************************************************************************************
*/
#define NET_TCP_CONN_ID_MIN 0
#define NET_TCP_CONN_ID_MAX (NET_TCP_CFG_NBR_CONN - 1)
#define NET_TCP_CONN_ID_NONE (NET_TCP_CONN_ID_MIN - 1)
/*
*********************************************************************************************************
* TCP CONNECTION TIMEOUT DEFINES
*
* Note(s) : (1) (a) (1) RFC #1122, Section 4.2.2.13 'DISCUSSION' states that "the graceful close algorithm
* of TCP requires that the connection state remain defined on (at least) one end of
* the connection, for a timeout period of 2xMSL ... During this period, the (remote
* socket, local socket) pair that defines the connection is busy and cannot be reused".
*
* (2) The following sections reiterate that the TIME-WAIT state timeout scalar is two
* maximum segment lifetimes (2 MSL) :
*
* (A) RFC #793, Section 3.9 'Event Processing : SEGMENT ARRIVES :
* Check Sequence Number : TIME-WAIT STATE'
* (B) RFC #793, Section 3.9 'Event Processing : SEGMENT ARRIVES :
* Check FIN Bit : TIME-WAIT STATE'
*
* (b) (1) RFC #793, Section 3.3 'Sequence Numbers : Knowing When to Keep Quiet' states that
* "the Maximum Segment Lifetime (MSL) is ... to be 2 minutes. This is an engineering
* choice, and may be changed if experience indicates it is desirable to do so".
*
* (2) Microsoft Corporation's Windows XP defaults MSL to 15 seconds.
*********************************************************************************************************
*/
/* Max seg timeout (see Note #1b). */
#define NET_TCP_CONN_TIMEOUT_MAX_SEG_MIN_SEC ( 0L) /* Max seg timeout min = 0 seconds */
#define NET_TCP_CONN_TIMEOUT_MAX_SEG_MAX_SEC ( 2L * 60L) /* Max seg timeout max = 2 minutes */
#define NET_TCP_CONN_TIMEOUT_MAX_SEG_DFLT_SEC ( 15L) /* Max seg timeout dflt = 15 seconds */
#define NET_TCP_CONN_TIMEOUT_MAX_SEG_SCALAR 2 /* Max seg timeout scalar (see Note #1a). */
#define NET_TCP_CONN_TIMEOUT_CONN_DFLT_SEC (120L * 60L) /* Dflt conn timeout = 120 minutes */
#define NET_TCP_CONN_TIMEOUT_USER_DFLT_SEC ( 30L * 60L) /* Dflt user timeout = 30 minutes */
/*$PAGE*/
/*
*********************************************************************************************************
* TCP CONNECTION STATES
*
* Note(s) : (1) See the following RFC's for TCP state machine summary :
*
* (a) RFC # 793; Sections 3.2, 3.4, 3.5, 3.9
* (b) RFC #1122; Sections 4.2.2.8, 4.2.2.10, 4.2.2.11, 4.2.2.13, 4.2.2.18, 4.2.2.20
*
* (2) (a) #### Additional closing-data-available state used for closing connections to allow the
* application layer to receive any remaining data.
*
* See also 'net_tcp.c NetTCP_RxPktConnHandlerFinWait1() Note #2f5A2',
* 'net_tcp.c NetTCP_RxPktConnHandlerFinWait2() Note #2f5B',
* 'net_tcp.c NetTCP_RxPktConnHandlerClosing() Note #2d2B2a1B',
* & 'net_tcp.c NetTCP_RxPktConnHandlerLastAck() Note #2d2A1b'.
*********************************************************************************************************
*/
#define NET_TCP_CONN_STATE_NONE 0
#define NET_TCP_CONN_STATE_FREE 1
#define NET_TCP_CONN_STATE_CLOSED 10
#define NET_TCP_CONN_STATE_LISTEN 20
#define NET_TCP_CONN_STATE_SYNC_RXD 30
#define NET_TCP_CONN_STATE_SYNC_RXD_PASSIVE 31
#define NET_TCP_CONN_STATE_SYNC_RXD_ACTIVE 32
#define NET_TCP_CONN_STATE_SYNC_TXD 35
#define NET_TCP_CONN_STATE_CONN 40
#define NET_TCP_CONN_STATE_FIN_WAIT_1 50
#define NET_TCP_CONN_STATE_FIN_WAIT_2 51
#define NET_TCP_CONN_STATE_CLOSING 52
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -