[Change summary]:
1. Update NetLib to a combined NetLib support dual network stack: 1) Add Network Debug facility for IPv4 stack. 2) Extend the library APIs to support IPv6 stack: a. NetIp6IsUnspecifiedAddr b. NetIp6IsLinkLocalAddr c. NetIp6IsNetEqual d. NetLibCreateIPv6DPathNode. e. NetIp6PseudoHeadChecksum f. NetIp6IsValidUnicast 3) Update the structure definitions: a. Update NET_BUF to add EFI_IP6_HEADER and EFI_UDP_HEADER b. Add NET_IP6_PSEUDO_HDR 4) Update Ip4IsUnicast to NetIp4IsUnicast 2. Update the impacted modules to adopt the combined NetLib. 3. Clean up coding style errors in all network drivers and libraries. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9391 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Implementation of the Socket.
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -215,7 +215,7 @@ SockProcessRcvToken (
|
||||
|
||||
ASSERT (Sock != NULL);
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
ASSERT (SockStream == Sock->Type);
|
||||
|
||||
RxData = RcvToken->Packet.RxData;
|
||||
|
||||
@@ -481,7 +481,7 @@ SockProcessSndToken (
|
||||
EFI_TCP4_TRANSMIT_DATA *TxData;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT ((Sock != NULL) && (SOCK_STREAM == Sock->Type));
|
||||
ASSERT ((Sock != NULL) && (SockStream == Sock->Type));
|
||||
|
||||
FreeSpace = SockGetFreeSpace (Sock, SOCK_SND_BUF);
|
||||
|
||||
@@ -557,7 +557,7 @@ SockCreate (
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT ((SockInitData != NULL) && (SockInitData->ProtoHandler != NULL));
|
||||
ASSERT (SockInitData->Type == SOCK_STREAM);
|
||||
ASSERT (SockInitData->Type == SockStream);
|
||||
ASSERT ((SockInitData->ProtoData != NULL) && (SockInitData->DataSize <= PROTO_RESERVED_LEN));
|
||||
|
||||
Parent = SockInitData->Parent;
|
||||
@@ -720,7 +720,7 @@ SockDestroy (
|
||||
EFI_GUID *ProtocolGuid;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
ASSERT (SockStream == Sock->Type);
|
||||
|
||||
if (Sock->DestroyCallback != NULL) {
|
||||
Sock->DestroyCallback (Sock, Sock->Context);
|
||||
@@ -873,13 +873,13 @@ SockConnFlush (
|
||||
Set the state of the socket.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
@param State The new state to be set.
|
||||
@param State The new socket state to be set.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockSetState (
|
||||
IN OUT SOCKET *Sock,
|
||||
IN SOCK_STATE State
|
||||
IN UINT8 State
|
||||
)
|
||||
{
|
||||
Sock->State = State;
|
||||
@@ -1070,7 +1070,7 @@ SockGetDataToSend (
|
||||
IN UINT8 *Dest
|
||||
)
|
||||
{
|
||||
ASSERT ((Sock != NULL) && SOCK_STREAM == Sock->Type);
|
||||
ASSERT ((Sock != NULL) && SockStream == Sock->Type);
|
||||
|
||||
return NetbufQueCopy (
|
||||
Sock->SndBuffer.DataQueue,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Interface function of the Socket.
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -397,7 +397,7 @@ SockAccept (
|
||||
SOCKET *Socket;
|
||||
EFI_EVENT Event;
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
ASSERT (SockStream == Sock->Type);
|
||||
|
||||
Status = EfiAcquireLockOrFail (&(Sock->Lock));
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -510,7 +510,7 @@ SockSend (
|
||||
SOCK_TOKEN *SockToken;
|
||||
UINT32 DataLen;
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
ASSERT (SockStream == Sock->Type);
|
||||
|
||||
Status = EfiAcquireLockOrFail (&(Sock->Lock));
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -633,7 +633,7 @@ SockRcv (
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
ASSERT (SockStream == Sock->Type);
|
||||
|
||||
Status = EfiAcquireLockOrFail (&(Sock->Lock));
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -733,7 +733,7 @@ SockFlush (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
ASSERT (SockStream == Sock->Type);
|
||||
|
||||
Status = EfiAcquireLockOrFail (&(Sock->Lock));
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -798,7 +798,7 @@ SockClose (
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
|
||||
ASSERT (SOCK_STREAM == Sock->Type);
|
||||
ASSERT (SockStream == Sock->Type);
|
||||
|
||||
Status = EfiAcquireLockOrFail (&(Sock->Lock));
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Socket header file.
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -68,23 +68,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
///
|
||||
/// Socket state
|
||||
///
|
||||
typedef enum {
|
||||
SO_CLOSED = 0,
|
||||
SO_LISTENING,
|
||||
SO_CONNECTING,
|
||||
SO_CONNECTED,
|
||||
SO_DISCONNECTING
|
||||
} SOCK_STATE;
|
||||
#define SO_CLOSED 0
|
||||
#define SO_LISTENING 1
|
||||
#define SO_CONNECTING 2
|
||||
#define SO_CONNECTED 3
|
||||
#define SO_DISCONNECTING 4
|
||||
|
||||
///
|
||||
/// Socket configure state
|
||||
///
|
||||
typedef enum {
|
||||
SO_UNCONFIGURED = 0,
|
||||
SO_CONFIGURED_ACTIVE,
|
||||
SO_CONFIGURED_PASSIVE,
|
||||
SO_NO_MAPPING
|
||||
} SOCK_CONFIGURE_STATE;
|
||||
#define SO_UNCONFIGURED 0
|
||||
#define SO_CONFIGURED_ACTIVE 1
|
||||
#define SO_CONFIGURED_PASSIVE 2
|
||||
#define SO_NO_MAPPING 3
|
||||
|
||||
/**
|
||||
Set socket SO_NO_MORE_DATA flag.
|
||||
@@ -331,44 +327,44 @@ typedef struct _SOCK_COMPLETION_TOKEN {
|
||||
EFI_STATUS Status; ///< The status to be issued
|
||||
} SOCK_COMPLETION_TOKEN;
|
||||
|
||||
typedef union {
|
||||
VOID *RxData;
|
||||
VOID *TxData;
|
||||
} SOCK_IO_DATA;
|
||||
|
||||
///
|
||||
/// The application token with data packet
|
||||
///
|
||||
typedef struct _SOCK_IO_TOKEN {
|
||||
SOCK_COMPLETION_TOKEN Token;
|
||||
union {
|
||||
VOID *RxData;
|
||||
VOID *TxData;
|
||||
} Packet;
|
||||
SOCK_IO_DATA Packet;
|
||||
} SOCK_IO_TOKEN;
|
||||
|
||||
///
|
||||
/// The request issued from socket layer to protocol layer.
|
||||
///
|
||||
typedef enum {
|
||||
SOCK_ATTACH, ///< Attach current socket to a new PCB
|
||||
SOCK_DETACH, ///< Detach current socket from the PCB
|
||||
SOCK_CONFIGURE, ///< Configure attached PCB
|
||||
SOCK_FLUSH, ///< Flush attached PCB
|
||||
SOCK_SND, ///< Need protocol to send something
|
||||
SOCK_SNDPUSH, ///< Need protocol to send pushed data
|
||||
SOCK_SNDURG, ///< Need protocol to send urgent data
|
||||
SOCK_CONSUMED, ///< Application has retrieved data from socket
|
||||
SOCK_CONNECT, ///< Need to connect to a peer
|
||||
SOCK_CLOSE, ///< Need to close the protocol process
|
||||
SOCK_ABORT, ///< Need to reset the protocol process
|
||||
SOCK_POLL, ///< Need to poll to the protocol layer
|
||||
SOCK_ROUTE, ///< Need to add a route information
|
||||
SOCK_MODE, ///< Need to get the mode data of the protocol
|
||||
SOCK_GROUP ///< Need to join a mcast group
|
||||
} SOCK_REQUEST;
|
||||
#define SOCK_ATTACH 0 ///< Attach current socket to a new PCB
|
||||
#define SOCK_DETACH 1 ///< Detach current socket from the PCB
|
||||
#define SOCK_CONFIGURE 2 ///< Configure attached PCB
|
||||
#define SOCK_FLUSH 3 ///< Flush attached PCB
|
||||
#define SOCK_SND 4 ///< Need protocol to send something
|
||||
#define SOCK_SNDPUSH 5 ///< Need protocol to send pushed data
|
||||
#define SOCK_SNDURG 6 ///< Need protocol to send urgent data
|
||||
#define SOCK_CONSUMED 7 ///< Application has retrieved data from socket
|
||||
#define SOCK_CONNECT 8 ///< Need to connect to a peer
|
||||
#define SOCK_CLOSE 9 ///< Need to close the protocol process
|
||||
#define SOCK_ABORT 10 ///< Need to reset the protocol process
|
||||
#define SOCK_POLL 11 ///< Need to poll to the protocol layer
|
||||
#define SOCK_ROUTE 12 ///< Need to add a route information
|
||||
#define SOCK_MODE 13 ///< Need to get the mode data of the protocol
|
||||
#define SOCK_GROUP 14 ///< Need to join a mcast group
|
||||
|
||||
///
|
||||
/// The socket type.
|
||||
///
|
||||
typedef enum {
|
||||
SOCK_DGRAM, ///< This socket providing datagram service
|
||||
SOCK_STREAM ///< This socket providing stream service
|
||||
SockDgram, ///< This socket providing datagram service
|
||||
SockStream ///< This socket providing stream service
|
||||
} SOCK_TYPE;
|
||||
|
||||
///
|
||||
@@ -396,7 +392,7 @@ typedef
|
||||
EFI_STATUS
|
||||
(*SOCK_PROTO_HANDLER) (
|
||||
IN SOCKET *Socket,
|
||||
IN SOCK_REQUEST Request,
|
||||
IN UINT8 Request,
|
||||
IN VOID *RequestData
|
||||
);
|
||||
|
||||
@@ -413,13 +409,13 @@ EFI_STATUS
|
||||
Set the state of the socket.
|
||||
|
||||
@param Sock Pointer to the socket.
|
||||
@param State The new state to be set.
|
||||
@param State The new socket state to be set.
|
||||
|
||||
**/
|
||||
VOID
|
||||
SockSetState (
|
||||
IN OUT SOCKET *Sock,
|
||||
IN SOCK_STATE State
|
||||
IN UINT8 State
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -592,7 +588,7 @@ VOID
|
||||
///
|
||||
typedef struct _SOCK_INIT_DATA {
|
||||
SOCK_TYPE Type;
|
||||
SOCK_STATE State;
|
||||
UINT8 State;
|
||||
|
||||
SOCKET *Parent; ///< The parent of this socket
|
||||
UINT32 BackLog; ///< The connection limit for listening socket
|
||||
@@ -641,9 +637,9 @@ struct _SOCKET {
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
LIST_ENTRY Link;
|
||||
SOCK_CONFIGURE_STATE ConfigureState;
|
||||
UINT8 ConfigureState;
|
||||
SOCK_TYPE Type;
|
||||
SOCK_STATE State;
|
||||
UINT8 State;
|
||||
UINT16 Flag;
|
||||
EFI_LOCK Lock; ///< The lock of socket
|
||||
SOCK_BUFFER SndBuffer; ///< Send buffer of application's data
|
||||
|
@@ -592,7 +592,7 @@ OnExit:
|
||||
EFI_STATUS
|
||||
Tcp4Dispatcher (
|
||||
IN SOCKET *Sock,
|
||||
IN SOCK_REQUEST Request,
|
||||
IN UINT8 Request,
|
||||
IN VOID *Data OPTIONAL
|
||||
)
|
||||
{
|
||||
|
@@ -38,8 +38,8 @@ EFI_TCP4_PROTOCOL mTcp4ProtocolTemplate = {
|
||||
};
|
||||
|
||||
SOCK_INIT_DATA mTcp4DefaultSockData = {
|
||||
SOCK_STREAM,
|
||||
(SOCK_STATE) 0,
|
||||
SockStream,
|
||||
0,
|
||||
NULL,
|
||||
TCP_BACKLOG,
|
||||
TCP_SND_BUF_SIZE,
|
||||
|
@@ -122,7 +122,7 @@ TcpSendIpPacket (
|
||||
EFI_STATUS
|
||||
Tcp4Dispatcher (
|
||||
IN SOCKET *Sock,
|
||||
IN SOCK_REQUEST Request,
|
||||
IN UINT8 Request,
|
||||
IN VOID *Data OPTIONAL
|
||||
);
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Implementation of TCP4 protocol services.
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -170,7 +170,7 @@ Tcp4Configure (
|
||||
if (NULL != TcpConfigData) {
|
||||
|
||||
CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR));
|
||||
if ((Ip != 0) && !Ip4IsUnicast (NTOHL (Ip), 0)) {
|
||||
if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ Tcp4Configure (
|
||||
|
||||
CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));
|
||||
CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));
|
||||
if (!Ip4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) {
|
||||
if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
TCP4 protocol services header file.
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -50,7 +50,7 @@ extern CHAR16 *mTcpStateName[];
|
||||
EFI_STATUS
|
||||
Tcp4Dispatcher (
|
||||
IN SOCKET *Sock,
|
||||
IN SOCK_REQUEST Request,
|
||||
IN UINT8 Request,
|
||||
IN VOID *Data OPTIONAL
|
||||
);
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Tcp option's routine header file.
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -27,47 +27,44 @@ typedef struct _TCP_OPTION {
|
||||
UINT32 TSEcr; ///< The TSEcr field in a timestamp option
|
||||
} TCP_OPTION;
|
||||
|
||||
typedef enum {
|
||||
//
|
||||
// supported TCP option type and their length
|
||||
//
|
||||
#define TCP_OPTION_EOP 0 ///< End Of oPtion
|
||||
#define TCP_OPTION_NOP 1 ///< No-Option.
|
||||
#define TCP_OPTION_MSS 2 ///< Maximum Segment Size
|
||||
#define TCP_OPTION_WS 3 ///< Window scale
|
||||
#define TCP_OPTION_TS 8 ///< Timestamp
|
||||
#define TCP_OPTION_MSS_LEN 4 ///< Length of MSS option
|
||||
#define TCP_OPTION_WS_LEN 3 ///< Length of window scale option
|
||||
#define TCP_OPTION_TS_LEN 10 ///< Length of timestamp option
|
||||
#define TCP_OPTION_WS_ALIGNED_LEN 4 ///< Length of window scale option, aligned
|
||||
#define TCP_OPTION_TS_ALIGNED_LEN 12 ///< Length of timestamp option, aligned
|
||||
|
||||
//
|
||||
// supported TCP option type and their length
|
||||
//
|
||||
TCP_OPTION_EOP = 0, ///< End Of oPtion
|
||||
TCP_OPTION_NOP = 1, ///< No-Option.
|
||||
TCP_OPTION_MSS = 2, ///< Maximum Segment Size
|
||||
TCP_OPTION_WS = 3, ///< Window scale
|
||||
TCP_OPTION_TS = 8, ///< Timestamp
|
||||
TCP_OPTION_MSS_LEN = 4, ///< Length of MSS option
|
||||
TCP_OPTION_WS_LEN = 3, ///< Length of window scale option
|
||||
TCP_OPTION_TS_LEN = 10, ///< Length of timestamp option
|
||||
TCP_OPTION_WS_ALIGNED_LEN = 4, ///< Length of window scale option, aligned
|
||||
TCP_OPTION_TS_ALIGNED_LEN = 12, ///< Length of timestamp option, aligned
|
||||
//
|
||||
// recommend format of timestamp window scale
|
||||
// option for fast process.
|
||||
//
|
||||
#define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) | \
|
||||
(TCP_OPTION_NOP << 16) | \
|
||||
(TCP_OPTION_TS << 8) | \
|
||||
(TCP_OPTION_TS_LEN))
|
||||
|
||||
//
|
||||
// recommend format of timestamp window scale
|
||||
// option for fast process.
|
||||
//
|
||||
TCP_OPTION_TS_FAST = ((TCP_OPTION_NOP << 24) |
|
||||
(TCP_OPTION_NOP << 16) |
|
||||
(TCP_OPTION_TS << 8) |
|
||||
TCP_OPTION_TS_LEN),
|
||||
#define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \
|
||||
(TCP_OPTION_WS << 16) | \
|
||||
(TCP_OPTION_WS_LEN << 8))
|
||||
|
||||
TCP_OPTION_WS_FAST = ((TCP_OPTION_NOP << 24) |
|
||||
(TCP_OPTION_WS << 16) |
|
||||
(TCP_OPTION_WS_LEN << 8)),
|
||||
#define TCP_OPTION_MSS_FAST ((TCP_OPTION_MSS << 24) | (TCP_OPTION_MSS_LEN << 16))
|
||||
|
||||
TCP_OPTION_MSS_FAST = ((TCP_OPTION_MSS << 24) |
|
||||
(TCP_OPTION_MSS_LEN << 16)),
|
||||
//
|
||||
// Other misc definations
|
||||
//
|
||||
#define TCP_OPTION_RCVD_MSS 0x01
|
||||
#define TCP_OPTION_RCVD_WS 0x02
|
||||
#define TCP_OPTION_RCVD_TS 0x04
|
||||
#define TCP_OPTION_MAX_WS 14 ///< Maxium window scale value
|
||||
#define TCP_OPTION_MAX_WIN 0xffff ///< Max window size in TCP header
|
||||
|
||||
//
|
||||
// Other misc definations
|
||||
//
|
||||
TCP_OPTION_RCVD_MSS = 0x01,
|
||||
TCP_OPTION_RCVD_WS = 0x02,
|
||||
TCP_OPTION_RCVD_TS = 0x04,
|
||||
TCP_OPTION_MAX_WS = 14, ///< Maxium window scale value
|
||||
TCP_OPTION_MAX_WIN = 0xffff ///< Max window size in TCP header
|
||||
} TCP_OPTION_TYPE;
|
||||
|
||||
/**
|
||||
Compute the window scale value according to the given buffer size.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Tcp Protocol header file.
|
||||
|
||||
Copyright (c) 2005 - 2006, Intel Corporation<BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -27,122 +27,116 @@ typedef struct _TCP_CB TCP_CB;
|
||||
/// Tcp states, Don't change their order, it is used as
|
||||
/// index to mTcpOutFlag and other macros
|
||||
///
|
||||
typedef enum {
|
||||
TCP_CLOSED = 0,
|
||||
TCP_LISTEN,
|
||||
TCP_SYN_SENT,
|
||||
TCP_SYN_RCVD,
|
||||
TCP_ESTABLISHED,
|
||||
TCP_FIN_WAIT_1,
|
||||
TCP_FIN_WAIT_2,
|
||||
TCP_CLOSING,
|
||||
TCP_TIME_WAIT,
|
||||
TCP_CLOSE_WAIT,
|
||||
TCP_LAST_ACK
|
||||
} TCP_STATES;
|
||||
#define TCP_CLOSED 0
|
||||
#define TCP_LISTEN 1
|
||||
#define TCP_SYN_SENT 2
|
||||
#define TCP_SYN_RCVD 3
|
||||
#define TCP_ESTABLISHED 4
|
||||
#define TCP_FIN_WAIT_1 5
|
||||
#define TCP_FIN_WAIT_2 6
|
||||
#define TCP_CLOSING 7
|
||||
#define TCP_TIME_WAIT 8
|
||||
#define TCP_CLOSE_WAIT 9
|
||||
#define TCP_LAST_ACK 10
|
||||
|
||||
|
||||
///
|
||||
/// Flags in the TCP header
|
||||
///
|
||||
typedef enum {
|
||||
#define TCP_FLG_FIN 0x01
|
||||
#define TCP_FLG_SYN 0x02
|
||||
#define TCP_FLG_RST 0x04
|
||||
#define TCP_FLG_PSH 0x08
|
||||
#define TCP_FLG_ACK 0x10
|
||||
#define TCP_FLG_URG 0x20
|
||||
|
||||
//
|
||||
// mask for all the flags
|
||||
//
|
||||
#define TCP_FLG_FLAG 0x3F
|
||||
|
||||
TCP_FLG_FIN = 0x01,
|
||||
TCP_FLG_SYN = 0x02,
|
||||
TCP_FLG_RST = 0x04,
|
||||
TCP_FLG_PSH = 0x08,
|
||||
TCP_FLG_ACK = 0x10,
|
||||
TCP_FLG_URG = 0x20,
|
||||
|
||||
//
|
||||
// mask for all the flags
|
||||
//
|
||||
TCP_FLG_FLAG = 0x3F
|
||||
} TCP_HEADER_FLAG;
|
||||
|
||||
typedef enum {
|
||||
#define TCP_CONNECT_REFUSED (-1) ///< TCP error status
|
||||
#define TCP_CONNECT_RESET (-2) ///< TCP error status
|
||||
#define TCP_CONNECT_CLOSED (-3) ///< TCP error status
|
||||
|
||||
TCP_CONNECT_REFUSED = -1, ///< TCP error status
|
||||
TCP_CONNECT_RESET = -2, ///< TCP error status
|
||||
TCP_CONNECT_CLOSED = -3, ///< TCP error status
|
||||
//
|
||||
// Current congestion status as suggested by RFC3782.
|
||||
//
|
||||
#define TCP_CONGEST_RECOVER 1 ///< During the NewReno fast recovery
|
||||
#define TCP_CONGEST_LOSS 2 ///< Retxmit because of retxmit time out
|
||||
#define TCP_CONGEST_OPEN 3 ///< TCP is opening its congestion window
|
||||
|
||||
//
|
||||
// Current congestion status as suggested by RFC3782.
|
||||
//
|
||||
TCP_CONGEST_RECOVER = 1, ///< During the NewReno fast recovery
|
||||
TCP_CONGEST_LOSS = 2, ///< Retxmit because of retxmit time out
|
||||
TCP_CONGEST_OPEN = 3, ///< TCP is opening its congestion window
|
||||
//
|
||||
// TCP control flags
|
||||
//
|
||||
#define TCP_CTRL_NO_NAGLE 0x0001 ///< Disable Nagle algorithm
|
||||
#define TCP_CTRL_NO_KEEPALIVE 0x0002 ///< Disable keepalive timer
|
||||
#define TCP_CTRL_NO_WS 0x0004 ///< Disable window scale option
|
||||
#define TCP_CTRL_RCVD_WS 0x0008 ///< Received a wnd scale option in syn
|
||||
#define TCP_CTRL_NO_TS 0x0010 ///< Disable Timestamp option
|
||||
#define TCP_CTRL_RCVD_TS 0x0020 ///< Received a Timestamp option in syn
|
||||
#define TCP_CTRL_SND_TS 0x0040 ///< Send Timestamp option to remote
|
||||
#define TCP_CTRL_SND_URG 0x0080 ///< In urgent send mode
|
||||
#define TCP_CTRL_RCVD_URG 0x0100 ///< In urgent receive mode
|
||||
#define TCP_CTRL_SND_PSH 0x0200 ///< In PUSH send mode
|
||||
#define TCP_CTRL_FIN_SENT 0x0400 ///< FIN is sent
|
||||
#define TCP_CTRL_FIN_ACKED 0x0800 ///< FIN is ACKed.
|
||||
#define TCP_CTRL_TIMER_ON 0x1000 ///< At least one of the timer is on
|
||||
#define TCP_CTRL_RTT_ON 0x2000 ///< The RTT measurement is on
|
||||
#define TCP_CTRL_ACK_NOW 0x4000 ///< Send the ACK now, don't delay
|
||||
|
||||
//
|
||||
// TCP control flags
|
||||
//
|
||||
TCP_CTRL_NO_NAGLE = 0x0001, ///< Disable Nagle algorithm
|
||||
TCP_CTRL_NO_KEEPALIVE = 0x0002, ///< Disable keepalive timer
|
||||
TCP_CTRL_NO_WS = 0x0004, ///< Disable window scale option
|
||||
TCP_CTRL_RCVD_WS = 0x0008, ///< Received a wnd scale option in syn
|
||||
TCP_CTRL_NO_TS = 0x0010, ///< Disable Timestamp option
|
||||
TCP_CTRL_RCVD_TS = 0x0020, ///< Received a Timestamp option in syn
|
||||
TCP_CTRL_SND_TS = 0x0040, ///< Send Timestamp option to remote
|
||||
TCP_CTRL_SND_URG = 0x0080, ///< In urgent send mode
|
||||
TCP_CTRL_RCVD_URG = 0x0100, ///< In urgent receive mode
|
||||
TCP_CTRL_SND_PSH = 0x0200, ///< In PUSH send mode
|
||||
TCP_CTRL_FIN_SENT = 0x0400, ///< FIN is sent
|
||||
TCP_CTRL_FIN_ACKED = 0x0800, ///< FIN is ACKed.
|
||||
TCP_CTRL_TIMER_ON = 0x1000, ///< At least one of the timer is on
|
||||
TCP_CTRL_RTT_ON = 0x2000, ///< The RTT measurement is on
|
||||
TCP_CTRL_ACK_NOW = 0x4000, ///< Send the ACK now, don't delay
|
||||
//
|
||||
// Timer related values
|
||||
//
|
||||
#define TCP_TIMER_CONNECT 0 ///< Connection establishment timer
|
||||
#define TCP_TIMER_REXMIT 1 ///< Retransmit timer
|
||||
#define TCP_TIMER_PROBE 2 ///< Window probe timer
|
||||
#define TCP_TIMER_KEEPALIVE 3 ///< Keepalive timer
|
||||
#define TCP_TIMER_FINWAIT2 4 ///< FIN_WAIT_2 timer
|
||||
#define TCP_TIMER_2MSL 5 ///< TIME_WAIT tiemr
|
||||
#define TCP_TIMER_NUMBER 6 ///< The total number of TCP timer.
|
||||
#define TCP_TICK 200 ///< Every TCP tick is 200ms
|
||||
#define TCP_TICK_HZ 5 ///< The frequence of TCP tick
|
||||
#define TCP_RTT_SHIFT 3 ///< SRTT & RTTVAR scaled by 8
|
||||
#define TCP_RTO_MIN TCP_TICK_HZ ///< The minium value of RTO
|
||||
#define TCP_RTO_MAX (TCP_TICK_HZ * 60) ///< The maxium value of RTO
|
||||
#define TCP_FOLD_RTT 4 ///< Timeout threshod to fold RTT
|
||||
|
||||
//
|
||||
// Timer related values
|
||||
//
|
||||
TCP_TIMER_CONNECT = 0, ///< Connection establishment timer
|
||||
TCP_TIMER_REXMIT = 1, ///< Retransmit timer
|
||||
TCP_TIMER_PROBE = 2, ///< Window probe timer
|
||||
TCP_TIMER_KEEPALIVE = 3, ///< Keepalive timer
|
||||
TCP_TIMER_FINWAIT2 = 4, ///< FIN_WAIT_2 timer
|
||||
TCP_TIMER_2MSL = 5, ///< TIME_WAIT tiemr
|
||||
TCP_TIMER_NUMBER = 6, ///< The total number of TCP timer.
|
||||
TCP_TICK = 200, ///< Every TCP tick is 200ms
|
||||
TCP_TICK_HZ = 5, ///< The frequence of TCP tick
|
||||
TCP_RTT_SHIFT = 3, ///< SRTT & RTTVAR scaled by 8
|
||||
TCP_RTO_MIN = TCP_TICK_HZ, ///< The minium value of RTO
|
||||
TCP_RTO_MAX = (TCP_TICK_HZ * 60), ///< The maxium value of RTO
|
||||
TCP_FOLD_RTT = 4, ///< Timeout threshod to fold RTT
|
||||
//
|
||||
// Default values for some timers
|
||||
//
|
||||
#define TCP_MAX_LOSS 12 ///< Default max times to retxmit
|
||||
#define TCP_KEEPALIVE_IDLE_MIN (TCP_TICK_HZ * 60 * 60 * 2) ///< First keep alive
|
||||
#define TCP_KEEPALIVE_PERIOD (TCP_TICK_HZ * 60)
|
||||
#define TCP_MAX_KEEPALIVE 8
|
||||
#define TCP_FIN_WAIT2_TIME (2 * TCP_TICK_HZ)
|
||||
#define TCP_TIME_WAIT_TIME (2 * TCP_TICK_HZ)
|
||||
#define TCP_PAWS_24DAY (24 * 24 * 60 * 60 * TCP_TICK_HZ)
|
||||
#define TCP_CONNECT_TIME (75 * TCP_TICK_HZ)
|
||||
|
||||
//
|
||||
// Default values for some timers
|
||||
//
|
||||
TCP_MAX_LOSS = 12, ///< Default max times to retxmit
|
||||
TCP_KEEPALIVE_IDLE_MIN = (TCP_TICK_HZ * 60 * 60 * 2), ///< First keep alive
|
||||
TCP_KEEPALIVE_PERIOD = (TCP_TICK_HZ * 60),
|
||||
TCP_MAX_KEEPALIVE = 8,
|
||||
TCP_FIN_WAIT2_TIME = (2 * TCP_TICK_HZ),
|
||||
TCP_TIME_WAIT_TIME = (2 * TCP_TICK_HZ),
|
||||
TCP_PAWS_24DAY = (24 * 24 * 60 * 60 * TCP_TICK_HZ),
|
||||
TCP_CONNECT_TIME = (75 * TCP_TICK_HZ),
|
||||
//
|
||||
// The header space to be reserved before TCP data to accomodate :
|
||||
// 60byte IP head + 60byte TCP head + link layer head
|
||||
//
|
||||
#define TCP_MAX_HEAD 192
|
||||
|
||||
//
|
||||
// The header space to be reserved before TCP data to accomodate :
|
||||
// 60byte IP head + 60byte TCP head + link layer head
|
||||
//
|
||||
TCP_MAX_HEAD = 192,
|
||||
|
||||
//
|
||||
// Value ranges for some control option
|
||||
//
|
||||
TCP_RCV_BUF_SIZE = (2 * 1024 * 1024),
|
||||
TCP_RCV_BUF_SIZE_MIN = (8 * 1024),
|
||||
TCP_SND_BUF_SIZE = (2 * 1024 * 1024),
|
||||
TCP_SND_BUF_SIZE_MIN = (8 * 1024),
|
||||
TCP_BACKLOG = 10,
|
||||
TCP_BACKLOG_MIN = 5,
|
||||
TCP_MAX_LOSS_MIN = 6,
|
||||
TCP_CONNECT_TIME_MIN = (60 * TCP_TICK_HZ),
|
||||
TCP_MAX_KEEPALIVE_MIN = 4,
|
||||
TCP_KEEPALIVE_IDLE_MAX = (TCP_TICK_HZ * 60 * 60 * 4),
|
||||
TCP_KEEPALIVE_PERIOD_MIN= (TCP_TICK_HZ * 30),
|
||||
TCP_FIN_WAIT2_TIME_MAX = (4 * TCP_TICK_HZ),
|
||||
TCP_TIME_WAIT_TIME_MAX = (60 * TCP_TICK_HZ)
|
||||
} TCP_MISC_VALUES;
|
||||
//
|
||||
// Value ranges for some control option
|
||||
//
|
||||
#define TCP_RCV_BUF_SIZE (2 * 1024 * 1024)
|
||||
#define TCP_RCV_BUF_SIZE_MIN (8 * 1024)
|
||||
#define TCP_SND_BUF_SIZE (2 * 1024 * 1024)
|
||||
#define TCP_SND_BUF_SIZE_MIN (8 * 1024)
|
||||
#define TCP_BACKLOG 10
|
||||
#define TCP_BACKLOG_MIN 5
|
||||
#define TCP_MAX_LOSS_MIN 6
|
||||
#define TCP_CONNECT_TIME_MIN (60 * TCP_TICK_HZ)
|
||||
#define TCP_MAX_KEEPALIVE_MIN 4
|
||||
#define TCP_KEEPALIVE_IDLE_MAX (TCP_TICK_HZ * 60 * 60 * 4)
|
||||
#define TCP_KEEPALIVE_PERIOD_MIN (TCP_TICK_HZ * 30)
|
||||
#define TCP_FIN_WAIT2_TIME_MAX (4 * TCP_TICK_HZ)
|
||||
#define TCP_TIME_WAIT_TIME_MAX (60 * TCP_TICK_HZ)
|
||||
|
||||
///
|
||||
/// TCP segmentation data
|
||||
|
Reference in New Issue
Block a user