summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-16 02:57:53 +0000
committerniry <niry@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-16 02:57:53 +0000
commitdfc1f033eadc0110006698797925f7060a251f10 (patch)
tree07692e61690fa05ecc34426738b40396f753ff49
parent74935bd7321eab37fa6c72f6ac2dd60de5af9ac3 (diff)
downloadedk2-dfc1f033eadc0110006698797925f7060a251f10.tar.gz
edk2-dfc1f033eadc0110006698797925f7060a251f10.tar.bz2
edk2-dfc1f033eadc0110006698797925f7060a251f10.zip
Add comments for functions.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7039 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c90
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c30
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h93
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c13
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h623
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c17
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c176
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h236
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h505
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c31
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c15
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c33
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h420
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c33
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c16
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h108
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c28
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h310
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c16
19 files changed, 2015 insertions, 778 deletions
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
index 2e318b7d09..377fd3bb4b 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
@@ -1,28 +1,18 @@
/** @file
-Copyright (c) 2005 - 2007, Intel Corporation
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- ComponentName.c
-
-Abstract:
-
-
**/
#include "Tcp4Main.h"
-//
-// EFI Component Name Functions
-//
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -33,10 +23,10 @@ Abstract:
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language[in] A pointer to a Null-terminated ASCII string
+ @param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@@ -45,7 +35,7 @@ Abstract:
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
- @param DriverName[out] A pointer to the Unicode string to return.
+ @param[out] DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@@ -65,9 +55,9 @@ Abstract:
EFI_STATUS
EFIAPI
TcpComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
);
@@ -84,15 +74,15 @@ TcpComponentNameGetDriverName (
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle[in] The handle of a controller that the driver
+ @param[in] ControllerHandle The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
- @param ChildHandle[in] The handle of the child controller to retrieve
+ @param[in] ChildHandle The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
@@ -101,7 +91,7 @@ TcpComponentNameGetDriverName (
driver that wishes to retrieve the name of a
child controller.
- @param Language[in] A pointer to a Null-terminated ASCII string
+ @param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@@ -110,7 +100,7 @@ TcpComponentNameGetDriverName (
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
- @param ControllerName[out] A pointer to the Unicode string to return.
+ @param[out] ControllerName A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
@@ -142,26 +132,26 @@ TcpComponentNameGetDriverName (
EFI_STATUS
EFIAPI
TcpComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-//
-// EFI Component Name Protocol
-//
+///
+/// EFI Component Name Protocol
+///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gTcp4ComponentName = {
TcpComponentNameGetDriverName,
TcpComponentNameGetControllerName,
"eng"
};
-//
-// EFI Component Name 2 Protocol
-//
+///
+/// EFI Component Name 2 Protocol
+///
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTcp4ComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) TcpComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) TcpComponentNameGetControllerName,
@@ -190,10 +180,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language[in] A pointer to a Null-terminated ASCII string
+ @param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@@ -202,7 +192,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
- @param DriverName[out] A pointer to the Unicode string to return.
+ @param[out] DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@@ -222,9 +212,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
EFI_STATUS
EFIAPI
TcpComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@@ -249,15 +239,15 @@ TcpComponentNameGetDriverName (
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle[in] The handle of a controller that the driver
+ @param[in] ControllerHandle The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
- @param ChildHandle[in] The handle of the child controller to retrieve
+ @param[in] ChildHandle The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
@@ -266,7 +256,7 @@ TcpComponentNameGetDriverName (
driver that wishes to retrieve the name of a
child controller.
- @param Language[in] A pointer to a Null-terminated ASCII string
+ @param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
@@ -275,7 +265,7 @@ TcpComponentNameGetDriverName (
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
- @param ControllerName[out] A pointer to the Unicode string to return.
+ @param[out] ControllerName A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
@@ -307,11 +297,11 @@ TcpComponentNameGetDriverName (
EFI_STATUS
EFIAPI
TcpComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
index 14342dfff0..7cd3a84f27 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- SockImpl.c
-
-Abstract:
-
-
**/
#include "SockImpl.h"
@@ -35,9 +28,9 @@ Abstract:
**/
UINT32
SockTcpDataToRcv (
- IN SOCK_BUFFER *SockBuffer,
- OUT BOOLEAN *IsOOB,
- IN UINT32 BufLen
+ IN SOCK_BUFFER *SockBuffer,
+ OUT BOOLEAN *IsUrg,
+ IN UINT32 BufLen
);
/**
@@ -52,8 +45,10 @@ SockProcessSndToken (
);
/**
-
+ Supporting function for both SockImpl and SockInterface.
+ @param Event The Event this notify function registered to, ignored.
+
**/
VOID
SockFreeFoo (
@@ -236,7 +231,8 @@ SockProcessRcvToken (
//
SockSetTcpRxData (Sock, RxData, TokenRcvdBytes, IsUrg);
- SOCK_TRIM_RCV_BUFF (Sock, TokenRcvdBytes);
+ NetbufQueTrim (Sock->RcvBuffer.DataQueue, TokenRcvdBytes);
+// SOCK_TRIM_RCV_BUFF (Sock, TokenRcvdBytes);
SIGNAL_TOKEN (&(RcvToken->Token), EFI_SUCCESS);
return TokenRcvdBytes;
@@ -417,7 +413,7 @@ SockWakeListenToken (
RemoveEntryList (&Sock->ConnectionList);
Parent->ConnCnt--;
- DEBUG ((EFI_D_WARN, "SockWakeListenToken: accept a socket, now conncnt is %d", Parent->ConnCnt));
+ DEBUG ((EFI_D_INFO, "SockWakeListenToken: accept a socket, now conncnt is %d", Parent->ConnCnt));
Sock->Parent = NULL;
}
@@ -668,7 +664,7 @@ SockCreate (
Parent->ConnCnt++;
DEBUG (
- (EFI_D_WARN,
+ (EFI_D_INFO,
"SockCreate: Create a new socket and add to parent, now conncnt is %d\n",
Parent->ConnCnt)
);
@@ -757,7 +753,7 @@ SockDestroy (
(Sock->Parent->ConnCnt)--;
DEBUG (
- (EFI_D_WARN,
+ (EFI_D_INFO,
"SockDestory: Delete a unaccepted socket from parent"
"now conncnt is %d\n",
Sock->Parent->ConnCnt)
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
index f06179578c..7381f4460e 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- SockImpl.h
-
-Abstract:
-
-
**/
#ifndef _SOCK_IMPL_H_
@@ -23,56 +16,110 @@ Abstract:
#include "Socket.h"
-
-#define SOCK_TRIM_RCV_BUFF(Sock, Len) \
- (NetbufQueTrim ((Sock)->RcvBuffer.DataQueue, (Len)))
-
+/**
+ Signal a event with the given status.
+
+ @param Token The token's event is to be signaled.
+ @param TokenStatus The status to be sent with the event.
+
+**/
#define SIGNAL_TOKEN(Token, TokenStatus) \
do { \
(Token)->Status = (TokenStatus); \
gBS->SignalEvent ((Token)->Event); \
} while (0)
-#define SOCK_HEADER_SPACE (60 + 60 + 72)
-//
-// Supporting function for both SockImpl and SockInterface
-//
+/**
+ Supporting function for both SockImpl and SockInterface.
+
+ @param Event The Event this notify function registered to, ignored.
+
+**/
VOID
SockFreeFoo (
IN EFI_EVENT Event
);
+/**
+ Process the TCP send data, buffer the tcp txdata and append
+ the buffer to socket send buffer,then try to send it.
+
+ @param Sock Pointer to the socket.
+ @param TcpTxData Pointer to the tcp txdata.
+
+ @retval EFI_SUCCESS The operation is completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Failed due to resource limit.
+
+**/
EFI_STATUS
SockProcessTcpSndData (
- IN SOCKET *Sock,
- IN VOID *TcpTxData
+ IN SOCKET *Sock,
+ IN VOID *TcpTxData
);
+/**
+ Copy data from socket buffer to application provided receive buffer.
+
+ @param Sock Pointer to the socket.
+ @param TcpRxData Pointer to the application provided receive buffer.
+ @param RcvdBytes The maximum length of the data can be copied.
+ @param IsOOB If TURE the data is OOB, else the data is normal.
+
+**/
VOID
SockSetTcpRxData (
- IN SOCKET *Sock,
- IN VOID *TcpRxData,
- IN UINT32 RcvdBytes,
- IN BOOLEAN IsOOB
+ IN SOCKET *Sock,
+ IN VOID *TcpRxData,
+ IN UINT32 RcvdBytes,
+ IN BOOLEAN IsOOB
);
+/**
+ Get received data from the socket layer to the receive token.
+
+ @param Sock Pointer to the socket.
+ @param RcvToken Pointer to the application provided receive token.
+
+ @return The length of data received in this token.
+
+**/
UINT32
SockProcessRcvToken (
IN SOCKET *Sock,
IN SOCK_IO_TOKEN *RcvToken
);
+/**
+ Flush the socket.
+
+ @param Sock Pointer to the socket.
+
+**/
VOID
SockConnFlush (
IN SOCKET *Sock
);
+/**
+ Create a socket with initial data SockInitData.
+
+ @param SockInitData Pointer to the initial data of the socket.
+
+ @return Pointer to the newly created socket.
+
+**/
SOCKET *
SockCreate (
IN SOCK_INIT_DATA *SockInitData
);
+/**
+ Destroy a socket.
+
+ @param Sock Pointer to the socket.
+
+**/
VOID
SockDestroy (
IN SOCKET *Sock
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
index 67aa919c33..dd359823b4 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- SockInterface.c
-
-Abstract:
-
-
**/
@@ -458,7 +451,7 @@ SockAccept (
Socket->Parent->ConnCnt--;
DEBUG (
- (EFI_D_WARN,
+ (EFI_D_INFO,
"SockAccept: Accept a socket, now conncount is %d",
Socket->Parent->ConnCnt)
);
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
index 4ee8e6c39e..3c687063c2 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Socket.h
-
-Abstract:
-
-
**/
#ifndef _SOCKET_H_
@@ -40,9 +33,9 @@ Abstract:
#define SOCK_SND_BUF 0
#define SOCK_RCV_BUF 1
-#define SOCK_BUFF_LOW_WATER 2 * 1024
-#define SOCK_RCV_BUFF_SIZE 8 * 1024
-#define SOCK_SND_BUFF_SIZE 8 * 1024
+#define SOCK_BUFF_LOW_WATER (2 * 1024)
+#define SOCK_RCV_BUFF_SIZE (8 * 1024)
+#define SOCK_SND_BUFF_SIZE (8 * 1024)
#define SOCK_BACKLOG 5
#define PROTO_RESERVED_LEN 20
@@ -70,6 +63,10 @@ Abstract:
//
//
//
+
+///
+/// Socket state
+///
typedef enum {
SO_CLOSED = 0,
SO_LISTENING,
@@ -78,6 +75,9 @@ typedef enum {
SO_DISCONNECTING
} SOCK_STATE;
+///
+/// Socket configure state
+///
typedef enum {
SO_UNCONFIGURED = 0,
SO_CONFIGURED_ACTIVE,
@@ -102,21 +102,21 @@ typedef enum {
#define SOCK_IS_NO_MAPPING(Sock) \
((Sock)->ConfigureState == SO_NO_MAPPING)
-#define SOCK_IS_CLOSED(Sock) ((Sock)->State == SO_CLOSED)
+#define SOCK_IS_CLOSED(Sock) ((Sock)->State == SO_CLOSED)
-#define SOCK_IS_LISTENING(Sock) ((Sock)->State == SO_LISTENING)
+#define SOCK_IS_LISTENING(Sock) ((Sock)->State == SO_LISTENING)
-#define SOCK_IS_CONNECTING(Sock) ((Sock)->State == SO_CONNECTING)
+#define SOCK_IS_CONNECTING(Sock) ((Sock)->State == SO_CONNECTING)
-#define SOCK_IS_CONNECTED(Sock) ((Sock)->State == SO_CONNECTED)
+#define SOCK_IS_CONNECTED(Sock) ((Sock)->State == SO_CONNECTED)
-#define SOCK_IS_DISCONNECTING(Sock) ((Sock)->State == SO_DISCONNECTING)
+#define SOCK_IS_DISCONNECTING(Sock) ((Sock)->State == SO_DISCONNECTING)
-#define SOCK_IS_NO_MORE_DATA(Sock) (0 != ((Sock)->Flag & SO_NO_MORE_DATA))
+#define SOCK_IS_NO_MORE_DATA(Sock) (0 != ((Sock)->Flag & SO_NO_MORE_DATA))
-#define SOCK_SIGNATURE EFI_SIGNATURE_32 ('S', 'O', 'C', 'K')
+#define SOCK_SIGNATURE EFI_SIGNATURE_32 ('S', 'O', 'C', 'K')
-#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)
+#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)
#define SET_RCV_BUFFSIZE(Sock, Size) ((Sock)->RcvBuffer.HighWater = (Size))
@@ -149,11 +149,17 @@ typedef enum {
typedef struct _SOCKET SOCKET;
+///
+/// Socket completion token
+///
typedef struct _SOCK_COMPLETION_TOKEN {
- EFI_EVENT Event;
- EFI_STATUS Status;
+ EFI_EVENT Event; ///< The event to be issued
+ EFI_STATUS Status; ///< The status to be issued
} SOCK_COMPLETION_TOKEN;
+///
+/// The application token with data packet
+///
typedef struct _SOCK_IO_TOKEN {
SOCK_COMPLETION_TOKEN Token;
union {
@@ -162,150 +168,230 @@ typedef struct _SOCK_IO_TOKEN {
} Packet;
} SOCK_IO_TOKEN;
-//
-// the request issued from socket layer to protocol layer
-//
+///
+/// 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_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;
-//
-// the socket type
-//
+///
+/// The socket type.
+///
typedef enum {
- SOCK_DGRAM, // this socket providing datagram service
- SOCK_STREAM // this socket providing stream service
+ SOCK_DGRAM, ///< This socket providing datagram service
+ SOCK_STREAM ///< This socket providing stream service
} SOCK_TYPE;
-//
-// the handler of protocol for request from socket
-//
+///
+/// The handler of protocol for request from socket.
+///
typedef
EFI_STATUS
(*SOCK_PROTO_HANDLER) (
- IN SOCKET * Socket, // the socket issuing the request to protocol
- IN SOCK_REQUEST Request, // the request issued by socket
- IN VOID *RequestData // the request related data
+ IN SOCKET *Socket, ///< The socket issuing the request to protocol
+ IN SOCK_REQUEST Request, ///< The request issued by socket
+ IN VOID *RequestData ///< The request related data
);
-//
-// the buffer structure of rcvd data and send data used by socket
-//
+///
+/// The buffer structure of rcvd data and send data used by socket.
+///
typedef struct _SOCK_BUFFER {
- UINT32 HighWater; // the buffersize upper limit of sock_buffer
- UINT32 LowWater; // the low warter mark of sock_buffer
- NET_BUF_QUEUE *DataQueue; // the queue to buffer data
+ UINT32 HighWater; ///< The buffersize upper limit of sock_buffer
+ UINT32 LowWater; ///< The low warter mark of sock_buffer
+ NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data
} SOCK_BUFFER;
//
-// socket provided oprerations for low layer protocol
+// Socket provided oprerations for low layer protocol
//
//
-// socket provided operations for user interface
+// Socket provided operations for user interface
//
+
+/**
+ Set the state of the socket.
+
+ @param Sock Pointer to the socket.
+ @param State The new state to be set.
+
+**/
VOID
SockSetState (
IN SOCKET *Sock,
IN SOCK_STATE State
);
-//
-// when the connection establishment process for a Sock
-// is finished low layer protocol calling this function
-// to notify socket layer
-//
+/**
+ Called by the low layer protocol to indicate the socket a connection is
+ established. This function just changes the socket's state to SO_CONNECTED
+ and signals the token used for connection establishment.
+
+ @param Sock Pointer to the socket associated with the
+ established connection.
+
+**/
VOID
SockConnEstablished (
IN SOCKET *Sock
);
+/**
+ Called by the low layer protocol to indicate the connection is closed; This
+ function flushes the socket, sets the state to SO_CLOSED and signals the close
+ token.
+
+ @param Sock Pointer to the socket associated with the closed
+ connection.
+
+**/
VOID
SockConnClosed (
IN SOCKET *Sock
);
-//
-// called by low layer protocol to trim send buffer of
-// Sock, when Count data is sent out completely
-//
+/**
+ Called by low layer protocol to indicate that some data is sent or processed;
+ This function trims the sent data in the socket send buffer, signals the data
+ token if proper.
+
+ @param Sock Pointer to the socket.
+ @param Count The length of the data processed or sent, in bytes.
+
+**/
VOID
SockDataSent (
- IN SOCKET *Sock,
- IN UINT32 Count
+ IN SOCKET *Sock,
+ IN UINT32 Count
);
-//
-// called by low layer protocol to get Len of data from
-// socket to send and copy it in Dest
-//
+/**
+ Called by the low layer protocol to copy some data in socket send
+ buffer starting from the specific offset to a buffer provided by
+ the caller.
+
+ @param Sock Pointer to the socket.
+ @param Offset The start point of the data to be copied.
+ @param Len The length of the data to be copied.
+ @param Dest Pointer to the destination to copy the data.
+
+ @return The data size copied.
+
+**/
UINT32
SockGetDataToSend (
- IN SOCKET *Sock,
- IN UINT32 Offset,
- IN UINT32 Len,
- IN UINT8 *Dest
+ IN SOCKET *Sock,
+ IN UINT32 Offset,
+ IN UINT32 Len,
+ IN UINT8 *Dest
);
-//
-// called by low layer protocol to notify socket no more data can be
-// received
-//
+/**
+ Called by the low layer protocol to indicate that there
+ will be no more data from the communication peer; This
+ function set the socket's state to SO_NO_MORE_DATA and
+ signal all queued IO tokens with the error status
+ EFI_CONNECTION_FIN.
+
+ @param Sock Pointer to the socket.
+
+**/
VOID
SockNoMoreData (
IN SOCKET *Sock
);
-//
-// called by low layer protocol to append a NetBuffer
-// to rcv buffer of sock
-//
+/**
+ Called by the low layer protocol to deliver received data to socket layer;
+ This function will append the data to the socket receive buffer, set ther
+ urgent data length and then check if any receive token can be signaled.
+
+ @param Sock Pointer to the socket.
+ @param NetBuffer Pointer to the buffer that contains the received
+ data.
+ @param UrgLen The length of the urgent data in the received data.
+
+**/
VOID
SockDataRcvd (
IN SOCKET *Sock,
IN NET_BUF *NetBuffer,
- IN UINT32 UrgLen
+ IN UINT32 UrgLen
);
+/**
+ Get the length of the free space of the specific socket buffer.
+
+ @param Sock Pointer to the socket.
+ @param Which Flag to indicate which socket buffer to check,
+ either send buffer or receive buffer.
+
+ @return The length of the free space, in bytes.
+
+**/
UINT32
SockGetFreeSpace (
- IN SOCKET *Sock,
- IN UINT32 Which
+ IN SOCKET *Sock,
+ IN UINT32 Which
);
-SOCKET *
+/**
+ Clone a new socket including its associated protocol control block.
+
+ @param Sock Pointer to the socket to be cloned.
+
+ @return Pointer to the newly cloned socket. If NULL, error condition occurred.
+
+**/
+SOCKET *
SockClone (
IN SOCKET *Sock
);
+/**
+ Signal the receive token with the specific error or
+ set socket error code after error is received.
+
+ @param Sock Pointer to the socket.
+ @param Error The error code received.
+
+**/
VOID
SockRcvdErr (
IN SOCKET *Sock,
IN EFI_STATUS Error
);
+///
+/// Proto type of the create callback
+///
typedef
EFI_STATUS
(*SOCK_CREATE_CALLBACK) (
IN SOCKET *This,
IN VOID *Context
);
-
+
+///
+/// Proto type of the destroy callback
+///
typedef
VOID
(*SOCK_DESTROY_CALLBACK) (
@@ -313,26 +399,26 @@ VOID
IN VOID *Context
);
-//
-// the initialize data for create a new socket
-//
+///
+/// The initialize data for create a new socket.
+///
typedef struct _SOCK_INIT_DATA {
SOCK_TYPE Type;
SOCK_STATE State;
- SOCKET *Parent; // the parent of this socket
- UINT32 BackLog; // the connection limit for listening socket
- UINT32 SndBufferSize; // the high warter mark of send buffer
- UINT32 RcvBufferSize; // the high warter mark of receive buffer
- VOID *Protocol; // the pointer to protocol function template
- // wanted to install on socket
+ SOCKET *Parent; ///< The parent of this socket
+ UINT32 BackLog; ///< The connection limit for listening socket
+ UINT32 SndBufferSize; ///< The high warter mark of send buffer
+ UINT32 RcvBufferSize; ///< The high warter mark of receive buffer
+ VOID *Protocol; ///< The pointer to protocol function template
+ ///< wanted to install on socket
//
// Callbacks after socket is created and before socket is to be destroyed.
//
- SOCK_CREATE_CALLBACK CreateCallback;
- SOCK_DESTROY_CALLBACK DestroyCallback;
- VOID *Context;
+ SOCK_CREATE_CALLBACK CreateCallback; ///< Callback after created
+ SOCK_DESTROY_CALLBACK DestroyCallback; ///< Callback before destroied
+ VOID *Context; ///< The context of the callback
//
// Opaque protocol data.
@@ -340,29 +426,30 @@ typedef struct _SOCK_INIT_DATA {
VOID *ProtoData;
UINT32 DataSize;
- SOCK_PROTO_HANDLER ProtoHandler;
+ SOCK_PROTO_HANDLER ProtoHandler; ///< The handler of protocol for socket request
- EFI_HANDLE DriverBinding; // the driver binding handle
+ EFI_HANDLE DriverBinding; ///< The driver binding handle
} SOCK_INIT_DATA;
-//
-//the union type of TCP and UDP protocol
-//
-typedef union {
- EFI_TCP4_PROTOCOL TcpProtocol;
- EFI_UDP4_PROTOCOL UdpProtocol;
+///
+/// The union type of TCP and UDP protocol.
+///
+typedef union _NET_PROTOCOL {
+ EFI_TCP4_PROTOCOL TcpProtocol; ///< Tcp protocol
+ EFI_UDP4_PROTOCOL UdpProtocol; ///< Udp protocol
} NET_PROTOCOL;
-//
-// the socket structure representing a network service access point
-//
+
+///
+/// The socket structure representing a network service access point
+///
struct _SOCKET {
//
- // socket description information
+ // Socket description information
//
- UINT32 Signature;
- EFI_HANDLE SockHandle; // the virtual handle of the socket
- EFI_HANDLE DriverBinding; // socket't driver binding protocol
+ UINT32 Signature; ///< Signature of the socket
+ EFI_HANDLE SockHandle; ///< The virtual handle of the socket
+ EFI_HANDLE DriverBinding; ///< Socket's driver binding protocol
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
LIST_ENTRY Link;
@@ -370,143 +457,249 @@ struct _SOCKET {
SOCK_TYPE Type;
SOCK_STATE State;
UINT16 Flag;
- EFI_LOCK Lock; // the lock of socket
- SOCK_BUFFER SndBuffer; // send buffer of application's data
- SOCK_BUFFER RcvBuffer; // receive buffer of received data
- EFI_STATUS SockError; // the error returned by low layer protocol
+ EFI_LOCK Lock; ///< The lock of socket
+ SOCK_BUFFER SndBuffer; ///< Send buffer of application's data
+ SOCK_BUFFER RcvBuffer; ///< Receive buffer of received data
+ EFI_STATUS SockError; ///< The error returned by low layer protocol
BOOLEAN IsDestroyed;
//
- // fields used to manage the connection request
+ // Fields used to manage the connection request
//
- UINT32 BackLog; // the limit of connection to this socket
- UINT32 ConnCnt; // the current count of connections to it
- SOCKET *Parent; // listening parent that accept the connection
- LIST_ENTRY ConnectionList; // the connections maintained by this socket
+ UINT32 BackLog; ///< the limit of connection to this socket
+ UINT32 ConnCnt; ///< the current count of connections to it
+ SOCKET *Parent; ///< listening parent that accept the connection
+ LIST_ENTRY ConnectionList; ///< the connections maintained by this socket
+
//
- // the queue to buffer application's asynchronous token
+ // The queue to buffer application's asynchronous token
//
LIST_ENTRY ListenTokenList;
LIST_ENTRY RcvTokenList;
LIST_ENTRY SndTokenList;
LIST_ENTRY ProcessingSndTokenList;
- SOCK_COMPLETION_TOKEN *ConnectionToken; // app's token to signal if connected
- SOCK_COMPLETION_TOKEN *CloseToken; // app's token to signal if closed
+ SOCK_COMPLETION_TOKEN *ConnectionToken; ///< app's token to signal if connected
+ SOCK_COMPLETION_TOKEN *CloseToken; ///< app's token to signal if closed
//
- // interface for low level protocol
+ // Interface for low level protocol
//
- SOCK_PROTO_HANDLER ProtoHandler; // the request handler of protocol
- UINT8 ProtoReserved[PROTO_RESERVED_LEN]; // Data fields reserved for protocol
- NET_PROTOCOL NetProtocol;
+ SOCK_PROTO_HANDLER ProtoHandler; ///< The request handler of protocol
+ UINT8 ProtoReserved[PROTO_RESERVED_LEN]; ///< Data fields reserved for protocol
+ NET_PROTOCOL NetProtocol; ///< TCP or UDP protocol socket used
//
- // Callbacks.
+ // Callbacks after socket is created and before socket is to be destroyed.
//
- SOCK_CREATE_CALLBACK CreateCallback;
- SOCK_DESTROY_CALLBACK DestroyCallback;
- VOID *Context;
+ SOCK_CREATE_CALLBACK CreateCallback; ///< Callback after created
+ SOCK_DESTROY_CALLBACK DestroyCallback; ///< Callback before destroied
+ VOID *Context; ///< The context of the callback
};
-//
-// the token structure buffered in socket layer
-//
+///
+/// The token structure buffered in socket layer.
+///
typedef struct _SOCK_TOKEN {
- LIST_ENTRY TokenList; // the entry to add in the token list
- SOCK_COMPLETION_TOKEN *Token; // The application's token
- UINT32 RemainDataLen; // unprocessed data length
- SOCKET *Sock; // the poninter to the socket this token
- // belongs to
+ LIST_ENTRY TokenList; ///< The entry to add in the token list
+ SOCK_COMPLETION_TOKEN *Token; ///< The application's token
+ UINT32 RemainDataLen; ///< Unprocessed data length
+ SOCKET *Sock; ///< The poninter to the socket this token
+ ///< belongs to
} SOCK_TOKEN;
-//
-// reserved data to access the NET_BUF delivered by UDP driver
-//
+///
+/// Reserved data to access the NET_BUF delivered by UDP driver.
+///
typedef struct _UDP_RSV_DATA {
EFI_TIME TimeStamp;
EFI_UDP4_SESSION_DATA Session;
} UDP_RSV_DATA;
-//
-// reserved data to access the NET_BUF delivered by TCP driver
-//
+///
+/// Reserved data to access the NET_BUF delivered by TCP driver.
+///
typedef struct _TCP_RSV_DATA {
UINT32 UrgLen;
} TCP_RSV_DATA;
-//
-// call it to creat a socket and attach it to a PCB
-//
-SOCKET *
+/**
+ Create a socket and its associated protocol control block
+ with the intial data SockInitData and protocol specific
+ data ProtoData.
+
+ @param SockInitData Inital data to setting the socket.
+
+ @return Pointer to the newly created socket. If NULL, error condition occured.
+
+**/
+SOCKET *
SockCreateChild (
IN SOCK_INIT_DATA *SockInitData
);
-//
-// call it to destroy a socket and its related PCB
-//
+/**
+ Destory the socket Sock and its associated protocol control block.
+
+ @param Sock The socket to be destroyed.
+
+ @retval EFI_SUCCESS The socket Sock is destroyed successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
+
+**/
EFI_STATUS
SockDestroyChild (
- IN SOCKET *Sock
+ IN SOCKET *Sock
);
-//
-// call it to configure a socket and its related PCB
-//
+/**
+ Configure the specific socket Sock using configuration data ConfigData.
+
+ @param Sock Pointer to the socket to be configured.
+ @param ConfigData Pointer to the configuration data.
+
+ @retval EFI_SUCCESS The socket is configured successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket or the
+ socket is already configured.
+
+**/
EFI_STATUS
SockConfigure (
IN SOCKET *Sock,
IN VOID *ConfigData
);
-//
-// call it to connect a socket to the peer
-//
+/**
+ Initiate a connection establishment process.
+
+ @param Sock Pointer to the socket to initiate the initate the
+ connection.
+ @param Token Pointer to the token used for the connection
+ operation.
+
+ @retval EFI_SUCCESS The connection is initialized successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
+ socket is closed, or the socket is not configured to
+ be an active one, or the token is already in one of
+ this socket's lists.
+ @retval EFI_NO_MAPPING The IP address configuration operation is not
+ finished.
+ @retval EFI_NOT_STARTED The socket is not configured.
+
+**/
EFI_STATUS
SockConnect (
IN SOCKET *Sock,
IN VOID *Token
);
-//
-// call it to issue an asynchronous listen token to the socket
-//
+/**
+ Issue a listen token to get an existed connected network instance
+ or wait for a connection if there is none.
+
+ @param Sock Pointer to the socket to accept connections.
+ @param Token The token to accept a connection.
+
+ @retval EFI_SUCCESS Either a connection is accpeted or the Token is
+ buffered for further acception.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
+ socket is closed, or the socket is not configured to
+ be a passive one, or the token is already in one of
+ this socket's lists.
+ @retval EFI_NO_MAPPING The IP address configuration operation is not
+ finished.
+ @retval EFI_NOT_STARTED The socket is not configured.
+ @retval EFI_OUT_OF_RESOURCE Failed to buffer the Token due to memory limit.
+
+**/
EFI_STATUS
SockAccept (
IN SOCKET *Sock,
IN VOID *Token
);
-//
-// Call it to send data using this socket
-//
+/**
+ Issue a token with data to the socket to send out.
+
+ @param Sock Pointer to the socket to process the token with
+ data.
+ @param Token The token with data that needs to send out.
+
+ @retval EFI_SUCCESS The token is processed successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
+ socket is closed, or the socket is not in a
+ synchronized state , or the token is already in one
+ of this socket's lists.
+ @retval EFI_NO_MAPPING The IP address configuration operation is not
+ finished.
+ @retval EFI_NOT_STARTED The socket is not configured.
+ @retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.
+
+**/
EFI_STATUS
SockSend (
IN SOCKET *Sock,
IN VOID *Token
);
-//
-// Call it to receive data from this socket
-//
+/**
+ Issue a token to get data from the socket.
+
+ @param Sock Pointer to the socket to get data from.
+ @param Token The token to store the received data from the
+ socket.
+
+ @retval EFI_SUCCESS The token is processed successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
+ socket is closed, or the socket is not in a
+ synchronized state , or the token is already in one
+ of this socket's lists.
+ @retval EFI_NO_MAPPING The IP address configuration operation is not
+ finished.
+ @retval EFI_NOT_STARTED The socket is not configured.
+ @retval EFI_CONNECTION_FIN The connection is closed and there is no more data.
+ @retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.
+
+**/
EFI_STATUS
SockRcv (
IN SOCKET *Sock,
IN VOID *Token
);
-//
-// Call it to flush a socket
-//
+/**
+ Reset the socket and its associated protocol control block.
+
+ @param Sock Pointer to the socket to be flushed.
+
+ @retval EFI_SUCCESS The socket is flushed successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
+
+**/
EFI_STATUS
SockFlush (
IN SOCKET *Sock
);
-//
-// Call it to close a socket in the light of policy in Token
-//
+/**
+ Close or abort the socket associated connection.
+
+ @param Sock Pointer to the socket of the connection to close or
+ abort.
+ @param Token The token for close operation.
+ @param OnAbort TRUE for aborting the connection, FALSE to close it.
+
+ @retval EFI_SUCCESS The close or abort operation is initialized
+ successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
+ socket is closed, or the socket is not in a
+ synchronized state , or the token is already in one
+ of this socket's lists.
+ @retval EFI_NO_MAPPING The IP address configuration operation is not
+ finished.
+ @retval EFI_NOT_STARTED The socket is not configured.
+
+**/
EFI_STATUS
SockClose (
IN SOCKET *Sock,
@@ -514,27 +707,57 @@ SockClose (
IN BOOLEAN OnAbort
);
-//
-// Call it to get the mode data of low layer protocol
-//
+/**
+ Get the mode data of the low layer protocol.
+
+ @param Sock Pointer to the socket to get mode data from.
+ @param Mode Pointer to the data to store the low layer mode
+ information.
+
+ @retval EFI_SUCCESS The mode data is got successfully.
+ @retval EFI_NOT_STARTED The socket is not configured.
+
+**/
EFI_STATUS
SockGetMode (
IN SOCKET *Sock,
IN VOID *Mode
);
-//
-// call it to add this socket instance into a group
-//
+/**
+ Configure the low level protocol to join a multicast group for
+ this socket's connection.
+
+ @param Sock Pointer to the socket of the connection to join the
+ specific multicast group.
+ @param GroupInfo Pointer to the multicast group info.
+
+ @retval EFI_SUCCESS The configuration is done successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
+ @retval EFI_NOT_STARTED The socket is not configured.
+
+**/
EFI_STATUS
SockGroup (
IN SOCKET *Sock,
IN VOID *GroupInfo
);
-//
-// call it to add a route entry for this socket instance
-//
+/**
+ Add or remove route information in IP route table associated
+ with this socket.
+
+ @param Sock Pointer to the socket associated with the IP route
+ table to operate on.
+ @param RouteInfo Pointer to the route information to be processed.
+
+ @retval EFI_SUCCESS The route table is updated successfully.
+ @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
+ @retval EFI_NO_MAPPING The IP address configuration operation is not
+ finished.
+ @retval EFI_NOT_STARTED The socket is not configured.
+
+**/
EFI_STATUS
SockRoute (
IN SOCKET *Sock,
@@ -544,11 +767,31 @@ SockRoute (
//
// Supporting function to operate on socket buffer
//
+
+/**
+ Get the first buffer block in the specific socket buffer.
+
+ @param Sockbuf Pointer to the socket buffer.
+
+ @return Pointer to the first buffer in the queue. NULL if the queue is empty.
+
+**/
NET_BUF *
SockBufFirst (
IN SOCK_BUFFER *Sockbuf
);
+/**
+ Get the next buffer block in the specific socket buffer.
+
+ @param Sockbuf Pointer to the socket buffer.
+ @param SockEntry Pointer to the buffer block prior to the required
+ one.
+
+ @return Pointer to the buffer block next to SockEntry. NULL if SockEntry is
+ the tail or head entry.
+
+**/
NET_BUF *
SockBufNext (
IN SOCK_BUFFER *Sockbuf,
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c
index 009ae582a5..62574fecf1 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Dispatcher.c
-
-Abstract:
-
-
**/
#include "Tcp4Main.h"
@@ -250,7 +243,7 @@ Tcp4FlushPcb (
}
/**
- Attach a Tcb to the socket.
+ Attach a Pcb to the socket.
@param Sk Pointer to the socket of this TCP instance.
@@ -301,7 +294,7 @@ Tcp4AttachPcb (
}
/**
- Detach the Tcb of the socket.
+ Detach the Pcb of the socket.
@param Sk Pointer to the socket of this TCP instance.
@@ -330,7 +323,7 @@ Tcp4DetachPcb (
/**
- Configure the Tcb using CfgData.
+ Configure the Pcb using CfgData.
@param Sk Pointer to the socket of this TCP instance.
@param CfgData Pointer to the TCP configuration data.
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
index c51962ba9e..921332cbe0 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2007, Intel Corporation
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Driver.c
-
-Abstract:
-
-
**/
#include "Tcp4Main.h"
@@ -187,17 +180,33 @@ Tcp4DriverEntryPoint (
/**
- Test to see if this driver supports ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to test.
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver supports this device.
- @retval EFI_ALREADY_STARTED This driver is already running on this device.
- @retval other This driver does not support this device.
-
+ Tests to see if this driver supports a given controller.
+
+ If a child device is provided, it further tests to see if this driver supports
+ creating a handle for the specified child device.
+
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param ControllerHandle The handle of the controller to test. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param RemainingDevicePath A pointer to the remaining portion of a device path.
+ This parameter is ignored by device drivers, and is optional for bus drivers.
+
+
+ @retval EFI_SUCCESS The device specified by ControllerHandle and
+ RemainingDevicePath is supported by the driver
+ specified by This.
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
+ RemainingDevicePath is already being managed by
+ the driver specified by This.
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
+ RemainingDevicePath is already being managed by a
+ different driver or an application that requires
+ exclusive access.
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
+ RemainingDevicePath is not supported by the driver
+ specified by This.
+
**/
EFI_STATUS
EFIAPI
@@ -241,17 +250,32 @@ Tcp4DriverBindingSupported (
/**
- Start this driver on ControllerHandle.
-
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to bind driver to.
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS The driver is added to ControllerHandle.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the
- driver.
- @retval other The driver cannot be added to ControllerHandle.
+ Start this driver on ControllerHandle.
+
+ The Start() function is designed to be invoked from the EFI boot service
+ ConnectController(). As a result, much of the error checking on the parameters
+ to Start() has been moved into this common boot service. It is legal to call
+ Start() from other locations, but the following calling restrictions must be
+ followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE.
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally
+ aligned EFI_DEVICE_PATH_PROTOCOL.
+ 3. Prior to calling Start(), the Supported() function for the driver specified
+ by This must have been called with the same calling parameters, and Supported()
+ must have returned EFI_SUCCESS.
+
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param ControllerHandle The handle of the controller to start. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param RemainingDevicePath A pointer to the remaining portion of a device path.
+ This parameter is ignored by device drivers, and is
+ optional for bus drivers.
+
+ @retval EFI_SUCCESS The device was started.
+ @retval EFI_ALREADY_STARTED The device could not be started due to a device error.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
+ of resources.
**/
EFI_STATUS
@@ -270,7 +294,7 @@ Tcp4DriverBindingStart (
if (NULL == TcpServiceData) {
DEBUG ((EFI_D_ERROR, "Tcp4DriverBindingStart: Have no enough"
- " resource to create a Tcp Servcie Data!\n"));
+ " resource to create a Tcp Servcie Data\n"));
return EFI_OUT_OF_RESOURCES;
}
@@ -282,7 +306,7 @@ Tcp4DriverBindingStart (
if (NULL == TcpServiceData->IpIo) {
DEBUG ((EFI_D_ERROR, "Tcp4DriverBindingStart: Have no enough"
- " resource to create an Ip Io!\n"));
+ " resource to create an Ip Io\n"));
Status = EFI_OUT_OF_RESOURCES;
goto ON_ERROR;
@@ -363,15 +387,29 @@ ON_ERROR:
/**
Stop this driver on ControllerHandle.
+
+ The Stop() function is designed to be invoked from the EFI boot service
+ DisconnectController(). As a result, much of the error checking on the parameters
+ to Stop() has been moved into this common boot service. It is legal to call Stop()
+ from other locations, but the following calling restrictions must be followed
+ or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call
+ to this same driver's Start() function.
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
+ EFI_HANDLE. In addition, all of these handles must have been created in this
+ driver's Start() function, and the Start() function must have called OpenProtocol()
+ on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param ControllerHandle A handle to the device being stopped. The handle must
+ support a bus specific I/O protocol for the driver
+ to use to stop the device.
+ @param NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param ChildHandleBuffer An array of child handles to be freed. May be NULL if
+ NumberOfChildren is 0.
- @param This Protocol instance pointer.
- @param ControllerHandle Handle of device to stop driver on.
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number
- of children is zero stop the entire bus driver.
- @param ChildHandleBuffer List of Child Handles to Stop.
-
- @retval EFI_SUCCESS This driver is removed from ControllerHandle.
- @retval other This driver is not removed from ControllerHandle.
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
**/
EFI_STATUS
@@ -569,18 +607,23 @@ Tcp4DestroySocketCallback (
}
/**
- Creates a child handle with a set of TCP4 services.
-
- @param This Protocol instance pointer.
- @param ChildHandle Pointer to the handle of the child to create. If
- it is NULL, then a new handle is created. If it is
- not NULL, then the I/O services are added to the
- existing child handle.
-
- @retval EFI_SUCCESS The child handle is created.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to create the
- child.
+ Creates a child handle and installs a protocol.
+
+ The CreateChild() function installs a protocol on ChildHandle. If ChildHandle
+ is a pointer to NULL, then a new handle is created and returned in ChildHandle.
+ If ChildHandle is not a pointer to NULL, then the protocol installs on the existing
+ ChildHandle.
+
+ @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
+ @param ChildHandle Pointer to the handle of the child to create. If it is NULL, then
+ a new handle is created. If it is a pointer to an existing UEFI
+ handle, then the protocol is added to the existing UEFI handle.
+
+ @retval EFI_SUCCES The protocol was added to ChildHandle.
+ @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
+ the child.
+ @retval other The child handle was not created.
**/
EFI_STATUS
@@ -630,16 +673,23 @@ Tcp4ServiceBindingCreateChild (
/**
- Destroys a child handle with a set of UDP4 services.
-
- @param This Protocol instance pointer.
- @param ChildHandle Handle of the child to be destroyed.
-
- @retval EFI_SUCCESS The TCP4 services are removed from the child
- handle.
- @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
- @retval other The child handle is not destroyed.
-
+ Destroys a child handle with a protocol installed on it.
+
+ The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
+ that was installed by CreateChild() from ChildHandle. If the removed protocol is the
+ last protocol on ChildHandle, then ChildHandle is destroyed.
+
+ @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
+ @param ChildHandle Handle of the child to destroy
+
+ @retval EFI_SUCCES The protocol was removed from ChildHandle.
+ @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is
+ being removed.
+ @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
+ @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
+ because its services are being used.
+ @retval other The child handle was not destroyed.
+
**/
EFI_STATUS
EFIAPI
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
index 82fd57c34d..42303f3cf1 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Driver.h
-
-Abstract:
-
-
**/
#ifndef _TCP4_DRIVER_H_
@@ -29,6 +22,14 @@ Abstract:
#define TCP4_PORT_KNOWN 1024
#define TCP4_PORT_USER_RESERVED 65535
+#define TCP4_FROM_THIS(a) \
+ CR ( \
+ (a), \
+ TCP4_SERVICE_DATA, \
+ Tcp4ServiceBinding, \
+ TCP4_DRIVER_SIGNATURE \
+ )
+
typedef struct _TCP4_HEARTBEAT_TIMER {
EFI_EVENT TimerEvent;
INTN RefCnt;
@@ -44,9 +45,22 @@ typedef struct _TCP4_SERVICE_DATA {
LIST_ENTRY SocketList;
} TCP4_SERVICE_DATA;
-//
-// Prototype for TCP4 driver Rcv callback function registered to IP_IO
-//
+
+
+/**
+ Packet receive callback function provided to IP_IO, used to call
+ the proper function to handle the packet received by IP.
+
+ @param Status Status of the received packet.
+ @param IcmpErr ICMP error number.
+ @param NetSession Pointer to the net session of this packet.
+ @param Pkt Pointer to the recieved packet.
+ @param Context Pointer to the context configured in IpIoOpen(), not used
+ now.
+
+ @return None
+
+**/
VOID
Tcp4RxCallback (
IN EFI_STATUS Status,
@@ -56,6 +70,18 @@ Tcp4RxCallback (
IN VOID *Context OPTIONAL
);
+/**
+ Send the segment to IP via IpIo function.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Nbuf Pointer to the TCP segment to be sent.
+ @param Src Source address of the TCP segment.
+ @param Dest Destination address of the TCP segment.
+
+ @retval 0 The segment was sent out successfully.
+ @retval -1 The segment was failed to send.
+
+**/
INTN
TcpSendIpPacket (
IN TCP_CB *Tcb,
@@ -64,11 +90,26 @@ TcpSendIpPacket (
IN UINT32 Dest
);
+/**
+ The procotol handler provided to the socket layer, used to
+ dispatch the socket level requests by calling the corresponding
+ TCP layer functions.
+
+ @param Sock Pointer to the socket of this TCP instance.
+ @param Request The code of this operation request.
+ @param Data Pointer to the operation specific data passed in
+ together with the operation request.
+
+ @retval EFI_SUCCESS The socket request is completed successfully.
+ @retval other The error status returned by the corresponding TCP
+ layer function.
+
+**/
EFI_STATUS
Tcp4Dispatcher (
IN SOCKET *Sock,
IN SOCK_REQUEST Request,
- IN VOID *Data OPTIONAL
+ IN VOID *Data OPTIONAL
);
typedef struct _TCP4_PROTO_DATA {
@@ -76,17 +117,17 @@ typedef struct _TCP4_PROTO_DATA {
TCP_CB *TcpPcb;
} TCP4_PROTO_DATA;
-#define TCP4_FROM_THIS(a) \
- CR ( \
- (a), \
- TCP4_SERVICE_DATA, \
- Tcp4ServiceBinding, \
- TCP4_DRIVER_SIGNATURE \
- )
+/**
+ The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
-//
-// Function prototype for the driver's entry point
-//
+ @param ImageHandle The firmware allocated handle for this
+ driver image.
+ @param SystemTable Pointer to the EFI system table.
+
+ @retval EFI_SUCCESS Driver loaded.
+ @retval other Driver not loaded.
+
+**/
EFI_STATUS
EFIAPI
Tcp4DriverEntryPoint (
@@ -94,9 +135,36 @@ Tcp4DriverEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable
);
-//
-// Function prototypes for the Drivr Binding Protocol
-//
+
+/**
+ Tests to see if this driver supports a given controller.
+
+ If a child device is provided, it further tests to see if this driver supports
+ creating a handle for the specified child device.
+
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param ControllerHandle The handle of the controller to test. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param RemainingDevicePath A pointer to the remaining portion of a device path.
+ This parameter is ignored by device drivers, and is optional for bus drivers.
+
+
+ @retval EFI_SUCCESS The device specified by ControllerHandle and
+ RemainingDevicePath is supported by the driver
+ specified by This.
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
+ RemainingDevicePath is already being managed by
+ the driver specified by This.
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
+ RemainingDevicePath is already being managed by a
+ different driver or an application that requires
+ exclusive access.
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
+ RemainingDevicePath is not supported by the driver
+ specified by This.
+
+**/
EFI_STATUS
EFIAPI
Tcp4DriverBindingSupported (
@@ -105,6 +173,35 @@ Tcp4DriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
+/**
+ Start this driver on ControllerHandle.
+
+ The Start() function is designed to be invoked from the EFI boot service
+ ConnectController(). As a result, much of the error checking on the parameters
+ to Start() has been moved into this common boot service. It is legal to call
+ Start() from other locations, but the following calling restrictions must be
+ followed or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE.
+ 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally
+ aligned EFI_DEVICE_PATH_PROTOCOL.
+ 3. Prior to calling Start(), the Supported() function for the driver specified
+ by This must have been called with the same calling parameters, and Supported()
+ must have returned EFI_SUCCESS.
+
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param ControllerHandle The handle of the controller to start. This handle
+ must support a protocol interface that supplies
+ an I/O abstraction to the driver.
+ @param RemainingDevicePath A pointer to the remaining portion of a device path.
+ This parameter is ignored by device drivers, and is
+ optional for bus drivers.
+
+ @retval EFI_SUCCESS The device was started.
+ @retval EFI_ALREADY_STARTED The device could not be started due to a device error.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
+ of resources.
+
+**/
EFI_STATUS
EFIAPI
Tcp4DriverBindingStart (
@@ -113,6 +210,33 @@ Tcp4DriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
+/**
+ Stop this driver on ControllerHandle.
+
+ The Stop() function is designed to be invoked from the EFI boot service
+ DisconnectController(). As a result, much of the error checking on the parameters
+ to Stop() has been moved into this common boot service. It is legal to call Stop()
+ from other locations, but the following calling restrictions must be followed
+ or the system behavior will not be deterministic.
+ 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call
+ to this same driver's Start() function.
+ 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
+ EFI_HANDLE. In addition, all of these handles must have been created in this
+ driver's Start() function, and the Start() function must have called OpenProtocol()
+ on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+
+ @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
+ @param ControllerHandle A handle to the device being stopped. The handle must
+ support a bus specific I/O protocol for the driver
+ to use to stop the device.
+ @param NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param ChildHandleBuffer An array of child handles to be freed. May be NULL if
+ NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+
+**/
EFI_STATUS
EFIAPI
Tcp4DriverBindingStop (
@@ -122,21 +246,56 @@ Tcp4DriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
);
+/**
+ Open Ip4 and device path protocols for a created socket, and insert it in
+ socket list.
+
+ @param This Pointer to the socket just created
+ @param Context Context of the socket
+
+ @retval EFI_SUCCESS This protocol is installed successfully.
+ @retval other Some error occured.
+
+**/
EFI_STATUS
Tcp4CreateSocketCallback (
IN SOCKET *This,
IN VOID *Context
);
+/**
+ Close Ip4 and device path protocols for a socket, and remove it from socket list.
+
+ @param This Pointer to the socket to be removed
+ @param Context Context of the socket
+
+**/
VOID
Tcp4DestroySocketCallback (
IN SOCKET *This,
IN VOID *Context
);
-//
-// Function ptototypes for the ServiceBinding Prococol
-//
+/**
+ Creates a child handle and installs a protocol.
+
+ The CreateChild() function installs a protocol on ChildHandle. If ChildHandle
+ is a pointer to NULL, then a new handle is created and returned in ChildHandle.
+ If ChildHandle is not a pointer to NULL, then the protocol installs on the existing
+ ChildHandle.
+
+ @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
+ @param ChildHandle Pointer to the handle of the child to create. If it is NULL, then
+ a new handle is created. If it is a pointer to an existing UEFI
+ handle, then the protocol is added to the existing UEFI handle.
+
+ @retval EFI_SUCCES The protocol was added to ChildHandle.
+ @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
+ the child.
+ @retval other The child handle was not created.
+
+**/
EFI_STATUS
EFIAPI
Tcp4ServiceBindingCreateChild (
@@ -144,6 +303,25 @@ Tcp4ServiceBindingCreateChild (
IN EFI_HANDLE *ChildHandle
);
+/**
+ Destroys a child handle with a protocol installed on it.
+
+ The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
+ that was installed by CreateChild() from ChildHandle. If the removed protocol is the
+ last protocol on ChildHandle, then ChildHandle is destroyed.
+
+ @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
+ @param ChildHandle Handle of the child to destroy
+
+ @retval EFI_SUCCES The protocol was removed from ChildHandle.
+ @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is
+ being removed.
+ @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
+ @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
+ because its services are being used.
+ @retval other The child handle was not destroyed.
+
+**/
EFI_STATUS
EFIAPI
Tcp4ServiceBindingDestroyChild (
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
index dbb1008b40..21922c7a02 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Func.h
-
-Abstract:
-
-
**/
#ifndef _TCP4_FUNC_H_
@@ -30,13 +23,36 @@ Abstract:
//
// Functions in tcp.c
//
+
+/**
+ Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.
+
+ @param Addr Pointer to the IP address needs to match.
+ @param Port The port number needs to match.
+
+ @return The Tcb which matches the <Addr Port> paire exists or not.
+
+**/
BOOLEAN
TcpFindTcbByPeer (
IN EFI_IPv4_ADDRESS *Addr,
IN TCP_PORTNO Port
);
-TCP_CB *
+/**
+ Locate the TCP_CB related to the socket pair.
+
+ @param LocalPort The local port number.
+ @param LocalIp The local IP address.
+ @param RemotePort The remote port number.
+ @param RemoteIp The remote IP address.
+ @param Syn Whether to search the listen sockets, if TRUE, the
+ listen sockets are searched.
+
+ @return Pointer to the related TCP_CB, if NULL no match is found.
+
+**/
+TCP_CB *
TcpLocateTcb (
IN TCP_PORTNO LocalPort,
IN UINT32 LocalIp,
@@ -45,26 +61,64 @@ TcpLocateTcb (
IN BOOLEAN Syn
);
+/**
+ Insert a Tcb into the proper queue.
+
+ @param Tcb Pointer to the TCP_CB to be inserted.
+
+ @retval 0 The Tcb is inserted successfully.
+ @retval -1 Error condition occurred.
+
+**/
INTN
TcpInsertTcb (
IN TCP_CB *Tcb
);
-TCP_CB *
+/**
+ Clone a TCP_CB from Tcb.
+
+ @param Tcb Pointer to the TCP_CB to be cloned.
+
+ @return Pointer to the new cloned TCP_CB, if NULL error condition occurred.
+
+**/
+TCP_CB *
TcpCloneTcb (
IN TCP_CB *Tcb
);
+/**
+ Compute an ISS to be used by a new connection.
+
+ @return The result ISS.
+
+**/
TCP_SEQNO
TcpGetIss (
VOID
);
+/**
+ Initialize the Tcb local related members.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpInitTcbLocal (
IN TCP_CB *Tcb
);
+/**
+ Initialize the peer related members.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seg Pointer to the segment that contains the peer's
+ intial info.
+ @param Opt Pointer to the options announced by the peer.
+
+**/
VOID
TcpInitTcbPeer (
IN TCP_CB *Tcb,
@@ -72,95 +126,241 @@ TcpInitTcbPeer (
IN TCP_OPTION *Opt
);
+/**
+ Get the local mss.
+
+ @param Sock Pointer to the socket to get mss
+
+ @return The mss size.
+
+**/
UINT16
TcpGetRcvMss (
- IN SOCKET *Sock
+ IN SOCKET *Sock
);
+/**
+ Set the Tcb's state.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param State The state to be set.
+
+**/
VOID
TcpSetState (
- IN TCP_CB *Tcb,
- IN UINT8 State
+ IN TCP_CB *Tcb,
+ IN TCP_STATES State
);
//
// Functions in Tcp4Output.c
//
+/**
+ Send the segment to IP via IpIo function.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Nbuf Pointer to the TCP segment to be sent.
+ @param Src Source address of the TCP segment.
+ @param Dest Destination address of the TCP segment.
+
+ @retval 0 The segment was sent out successfully.
+ @retval -1 The segment was failed to send.
+
+**/
INTN
TcpSendIpPacket (
- IN TCP_CB *Tcb,
- IN NET_BUF *Nbuf,
- IN UINT32 Src,
- IN UINT32 Dst
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Nbuf,
+ IN UINT32 Src,
+ IN UINT32 Dest
);
+/**
+ Check whether to send data/SYN/FIN and piggy back an ACK.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Force Whether to ignore the sender's SWS avoidance algorithm and send
+ out data by force.
+
+ @return The number of bytes sent.
+
+**/
INTN
TcpToSendData (
IN TCP_CB *Tcb,
- IN INTN Force
+ IN INTN Force
);
+/**
+ Check whether to send an ACK or delayed ACK.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpToSendAck (
IN TCP_CB *Tcb
);
+/**
+ Send an ACK immediately.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpSendAck (
IN TCP_CB *Tcb
);
+/**
+ Send a zero probe segment. It can be used by keepalive and zero window probe.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+ @retval 0 The zero probe segment was sent out successfully.
+ @retval other Error condition occurred.
+
+**/
INTN
TcpSendZeroProbe (
IN TCP_CB *Tcb
);
+/**
+ Process the data and FIN flag, check whether to deliver
+ data to the socket layer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+ @retval 0 No error occurred to deliver data.
+ @retval -1 Error condition occurred. Proper response is to reset the
+ connection.
+
+**/
INTN
TcpDeliverData (
IN TCP_CB *Tcb
);
+/**
+ Send a RESET segment in response to the segment received.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance, may be NULL.
+ @param Head TCP header of the segment that triggers the reset.
+ @param Len Length of the segment that triggers the reset.
+ @param Local Local IP address.
+ @param Remote Remote peer's IP address.
+
+ @retval 0 A reset is sent or no need to send it.
+ @retval -1 No reset is sent.
+
+**/
INTN
TcpSendReset (
- IN TCP_CB *Tcb,
- IN TCP_HEAD *Head,
- IN INT32 Len,
- IN UINT32 Local,
- IN UINT32 Remote
+ IN TCP_CB *Tcb,
+ IN TCP_HEAD *Head,
+ IN INT32 Len,
+ IN UINT32 Local,
+ IN UINT32 Remote
);
+/**
+ Compute the sequence space left in the old receive window.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+ @return The sequence space left in the old receive window.
+
+**/
UINT32
TcpRcvWinOld (
IN TCP_CB *Tcb
);
+/**
+ Compute the current receive window.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+ @return The size of the current receive window, in bytes.
+
+**/
UINT32
TcpRcvWinNow (
IN TCP_CB *Tcb
);
+/**
+ Retransmit the segment from sequence Seq.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seq The sequence number of the segment to be retransmitted.
+
+ @retval 0 Retransmission succeeded.
+ @retval -1 Error condition occurred.
+
+**/
INTN
TcpRetransmit (
IN TCP_CB *Tcb,
IN TCP_SEQNO Seq
);
+/**
+ Compute how much data to send.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Force Whether to ignore the sender's SWS avoidance algorithm and send
+ out data by force.
+
+ @return The length of the data can be sent, if 0, no data can be sent.
+
+**/
UINT32
TcpDataToSend (
IN TCP_CB *Tcb,
IN INTN Force
);
+/**
+ Verify that the segment is in good shape.
+
+ @param Nbuf Buffer that contains the segment to be checked.
+
+ @retval 0 The segment is broken.
+ @retval 1 The segment is in good shape.
+
+**/
INTN
TcpVerifySegment (
IN NET_BUF *Nbuf
);
+/**
+ Verify that all the segments in SndQue are in good shape.
+
+ @param Head Pointer to the head node of the SndQue.
+
+ @retval 0 At least one segment is broken.
+ @retval 1 All segments in the specific queue are in good shape.
+
+**/
INTN
TcpCheckSndQue (
IN LIST_ENTRY *Head
);
+/**
+ Get a segment from the Tcb's SndQue.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seq The sequence number of the segment.
+ @param Len The maximum length of the segment.
+
+ @return Pointer to the segment, if NULL some error occurred.
+
+**/
NET_BUF *
TcpGetSegmentSndQue (
IN TCP_CB *Tcb,
@@ -168,6 +368,16 @@ TcpGetSegmentSndQue (
IN UINT32 Len
);
+/**
+ Get a segment from the Tcb's socket buffer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seq The sequence number of the segment.
+ @param Len The maximum length of the segment.
+
+ @return Pointer to the segment, if NULL some error occurred.
+
+**/
NET_BUF *
TcpGetSegmentSock (
IN TCP_CB *Tcb,
@@ -175,6 +385,17 @@ TcpGetSegmentSock (
IN UINT32 Len
);
+/**
+ Get a segment starting from sequence Seq of a maximum
+ length of Len.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seq The sequence number of the segment.
+ @param Len The maximum length of the segment.
+
+ @return Pointer to the segment, if NULL some error occurred.
+
+**/
NET_BUF *
TcpGetSegment (
IN TCP_CB *Tcb,
@@ -182,6 +403,14 @@ TcpGetSegment (
IN UINT32 Len
);
+/**
+ Get the maximum SndNxt.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+ @return The sequence number of the maximum SndNxt.
+
+**/
TCP_SEQNO
TcpGetMaxSndNxt (
IN TCP_CB *Tcb
@@ -190,6 +419,16 @@ TcpGetMaxSndNxt (
//
// Functions from Tcp4Input.c
//
+/**
+ Process the received ICMP error messages for TCP.
+
+ @param Nbuf Buffer that contains part of the TCP segment without IP header
+ truncated from the ICMP error packet.
+ @param IcmpErr The ICMP error code interpreted from ICMP error packet.
+ @param Src Source address of the ICMP error message.
+ @param Dst Destination address of the ICMP error message.
+
+**/
VOID
TcpIcmpInput (
IN NET_BUF *Nbuf,
@@ -198,6 +437,19 @@ TcpIcmpInput (
IN UINT32 Dst
);
+/**
+ Process the received TCP segments.
+
+ @param Nbuf Buffer that contains received TCP segment without IP header.
+ @param Src Source address of the segment, or the peer's IP address.
+ @param Dst Destination address of the segment, or the local end's IP
+ address.
+
+ @retval 0 Segment is processed successfully. It is either accepted or
+ discarded. But no connection is reset by the segment.
+ @retval -1 A connection is reset by the segment.
+
+**/
INTN
TcpInput (
IN NET_BUF *Nbuf,
@@ -205,42 +457,96 @@ TcpInput (
IN UINT32 Dst
);
+/**
+ Check whether the sequence number of the incoming segment is acceptable.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seg Pointer to the incoming segment.
+
+ @retval 1 The sequence number is acceptable.
+ @retval 0 The sequence number is not acceptable.
+
+**/
INTN
TcpSeqAcceptable (
IN TCP_CB *Tcb,
IN TCP_SEG *Seg
);
+/**
+ NewReno fast recovery, RFC3782.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seg Segment that triggers the fast recovery.
+
+**/
VOID
TcpFastRecover (
IN TCP_CB *Tcb,
IN TCP_SEG *Seg
);
+/**
+ NewReno fast loss recovery, RFC3792.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Seg Segment that triggers the fast loss recovery.
+
+**/
VOID
TcpFastLossRecover (
IN TCP_CB *Tcb,
IN TCP_SEG *Seg
);
+/**
+ Compute the RTT as specified in RFC2988.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Measure Currently measured RTT in heart beats.
+
+**/
VOID
TcpComputeRtt (
IN TCP_CB *Tcb,
IN UINT32 Measure
);
+/**
+ Trim off the data outside the tcb's receive window.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Nbuf Pointer to the NET_BUF containing the received tcp segment.
+
+ @return 0 The data is trimmed.
+
+**/
INTN
TcpTrimInWnd (
IN TCP_CB *Tcb,
- IN NET_BUF *Buf
+ IN NET_BUF *Nbuf
);
+/**
+ Store the data into the reassemble queue.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Nbuf Pointer to the buffer containing the data to be queued.
+
+**/
VOID
TcpQueueData (
IN TCP_CB *Tcb,
IN NET_BUF *Nbuf
);
+/**
+ Ajust the send queue or the retransmit queue.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Ack The acknowledge seuqence number of the received segment.
+
+**/
VOID
TcpAdjustSndQue (
IN TCP_CB *Tcb,
@@ -250,43 +556,110 @@ TcpAdjustSndQue (
//
// Functions from Tcp4Misc.c
//
+/**
+ Compute the TCP segment's checksum.
+
+ @param Nbuf Pointer to the buffer that contains the TCP
+ segment.
+ @param HeadSum The checksum value of the fixed part of pseudo
+ header.
+
+ @return The checksum value.
+
+**/
UINT16
TcpChecksum (
- IN NET_BUF *Buf,
- IN UINT16 HeadChecksum
+ IN NET_BUF *Nbuf,
+ IN UINT16 HeadSum
);
+/**
+ Translate the information from the head of the received TCP
+ segment Nbuf contains and fill it into a TCP_SEG structure.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Nbuf Pointer to the buffer contains the TCP segment.
+
+ @return Pointer to the TCP_SEG that contains the translated TCP head information.
+
+**/
TCP_SEG *
TcpFormatNetbuf (
IN TCP_CB *Tcb,
IN NET_BUF *Nbuf
);
+/**
+ Initialize an active connection.
+
+ @param Tcb Pointer to the TCP_CB that wants to initiate a
+ connection.
+
+**/
VOID
TcpOnAppConnect (
IN TCP_CB *Tcb
);
+/**
+ Application has consumed some data, check whether
+ to send a window updata ack or a delayed ack.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
INTN
TcpOnAppConsume (
IN TCP_CB *Tcb
);
+/**
+ Initiate the connection close procedure, called when
+ applications want to close the connection.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpOnAppClose (
IN TCP_CB *Tcb
);
+/**
+ Check whether the application's newly delivered data can be sent out.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+ @retval 0 Whether the data is sent out or is buffered for
+ further sending.
+ @retval -1 The Tcb is not in a state that data is permitted to
+ be sent out.
+
+**/
INTN
TcpOnAppSend (
IN TCP_CB *Tcb
);
+/**
+ Abort the connection by sending a reset segment, called
+ when the application wants to abort the connection.
+
+ @param Tcb Pointer to the TCP_CB of the TCP instance.
+
+**/
VOID
TcpOnAppAbort (
IN TCP_CB *Tcb
);
+/**
+ Reset the connection related with Tcb.
+
+ @param Tcb Pointer to the TCP_CB of the connection to be
+ reset.
+
+**/
VOID
TcpResetConnection (
IN TCP_CB *Tcb
@@ -295,11 +668,24 @@ TcpResetConnection (
//
// Functions in Tcp4Timer.c
//
+/**
+ Close the TCP connection.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpClose (
IN TCP_CB *Tcb
);
+/**
+ Heart beat timer handler, queues the DPC at TPL_CALLBACK.
+
+ @param Event Timer event signaled, ignored.
+ @param Context Context of the timer event, ignored.
+
+**/
VOID
EFIAPI
TcpTicking (
@@ -307,6 +693,14 @@ TcpTicking (
IN VOID *Context
);
+/**
+ Enable a TCP timer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Timer The index of the timer to be enabled.
+ @param TimeOut The timeout value of this timer.
+
+**/
VOID
TcpSetTimer (
IN TCP_CB *Tcb,
@@ -314,45 +708,100 @@ TcpSetTimer (
IN UINT32 TimeOut
);
+/**
+ Clear one TCP timer.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Timer The index of the timer to be cleared.
+
+**/
VOID
TcpClearTimer (
IN TCP_CB *Tcb,
IN UINT16 Timer
);
+/**
+ Clear all TCP timers.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpClearAllTimer (
IN TCP_CB *Tcb
);
+/**
+ Enable the window prober timer and set the timeout value.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpSetProbeTimer (
IN TCP_CB *Tcb
);
+/**
+ Enable the keepalive timer and set the timeout value.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpSetKeepaliveTimer (
IN TCP_CB *Tcb
);
+/**
+ Backoff the RTO.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+**/
VOID
TcpBackoffRto (
IN TCP_CB *Tcb
);
+/**
+ Set the Tdp4 variable data.
+
+ @param Tcp4Service Pointer to Tcp4 service data.
+
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.
+ @retval other Set variable failed.
+
+**/
EFI_STATUS
TcpSetVariableData (
IN TCP4_SERVICE_DATA *Tcp4Service
);
+/**
+ Clear the variable and free the resource.
+
+ @param Tcp4Service Pointer to Tcp4 service data.
+
+**/
VOID
TcpClearVariableData (
IN TCP4_SERVICE_DATA *Tcp4Service
);
+/**
+ Install the device path protocol on the TCP instance.
+
+ @param Sock Pointer to the socket representing the TCP instance.
+
+ @retval EFI_SUCCESS The device path protocol is installed.
+ @retval other Failed to install the device path protocol.
+
+**/
EFI_STATUS
TcpInstallDevicePath (
- IN SOCKET *Sock
+ IN SOCKET *Sock
);
#endif
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
index f525f240e4..f5ca9ac548 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
@@ -1,25 +1,18 @@
/** @file
+ TCP input process routines.
-Copyright (c) 2005 - 2007, Intel Corporation
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Input.c
-
-Abstract:
-
- TCP input process routines.
-
-
**/
+
#include "Tcp4Main.h"
@@ -491,6 +484,8 @@ TcpDeliverData (
NetbufFree (Nbuf);
return -1;
break;
+ case default:
+ break;
}
TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW);
@@ -773,10 +768,6 @@ TcpInput (
Nbuf->Tcp = NULL;
//
- // TODO: add fast path process here
- //
-
- //
// Process the segment in LISTEN state.
//
if (Tcb->State == TCP_LISTEN) {
@@ -861,14 +852,14 @@ TcpInput (
if (TCP_FLG_ON (Seg->Flag, TCP_FLG_ACK)) {
DEBUG ((EFI_D_WARN, "TcpInput: connection reset by"
- " peer for TCB%x in SYN_SENT\n", Tcb));
+ " peer for TCB %p in SYN_SENT\n", Tcb));
SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);
goto DROP_CONNECTION;
} else {
DEBUG ((EFI_D_WARN, "TcpInput: discard a reset segment "
- "because of no ACK for TCB%x in SYN_SENT\n", Tcb));
+ "because of no ACK for TCB %p in SYN_SENT\n", Tcb));
goto DISCARD;
}
@@ -985,9 +976,7 @@ TcpInput (
SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET);
} else {
- //
- // TODO: set socket error to CLOSED
- //
+
}
goto DROP_CONNECTION;
@@ -1174,7 +1163,7 @@ TcpInput (
}
DEBUG ((EFI_D_WARN, "TcpInput: peer shrinks the"
- " window for connected TCB %p\n", Tcb));
+ " window for connected TCB %p\n", Tcb));
if ((Tcb->CongestState == TCP_CONGEST_RECOVER) &&
(TCP_SEQ_LT (Right, Tcb->Recover))) {
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c
index c468bba380..e7f0df90e9 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c
@@ -1,26 +1,17 @@
/** @file
+ I/O interfaces between TCP and IpIo.
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Io.c
-
-Abstract:
-
- I/O interfaces between TCP and IpIo.
-
-
**/
-
#include "Tcp4Main.h"
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c
index d43a4a4faf..25ca2101a8 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c
@@ -1,25 +1,18 @@
/** @file
+ Implementation of TCP4 protocol services.
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Main.c
-
-Abstract:
-
- Implementation of TCP4 protocol services.
-
-
**/
+
#include "Tcp4Main.h"
@@ -221,9 +214,9 @@ Tcp4Configure (
/**
Add or delete routing entries.
- The Routes() function adds or deletes a route from the instance’s routing table.
+ The Routes() function adds or deletes a route from the instance's routing table.
The most specific route is selected by comparing the SubnetAddress with the
- destination IP address’s arithmetical AND to the SubnetMask.
+ destination IP address's arithmetical AND to the SubnetMask.
The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0.
The default route matches all destination IP addresses if there is no more specific route.
Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to
@@ -231,9 +224,9 @@ Tcp4Configure (
cache or it is on the local subnet. If the instance is configured to use default
address, a direct route to the local network will be added automatically.
Each TCP instance has its own independent routing table. Instance that uses the
- default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL’s routing table.
+ default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL's routing table.
The copy will be updated automatically whenever the IP driver reconfigures its
- instance. As a result, the previous modification to the instance’s local copy
+ instance. As a result, the previous modification to the instance's local copy
will be lost. The priority of checking the route table is specific with IP
implementation and every IP implementation must comply with RFC 1122.
@@ -348,7 +341,7 @@ Tcp4Connect (
incoming connection on the passive TCP instance. If a remote peer successfully
establishes a connection with this instance, a new TCP instance will be created
and its handle will be returned in ListenToken->NewChildHandle. The newly created
- instance is configured by inheriting the passive instance’s configuration and is
+ instance is configured by inheriting the passive instance's configuration and is
ready for use upon return. The instance is in the Tcp4StateEstablished state.
The ListenToken->CompletionToken.Event will be signaled when a new connection
is accepted, user aborts the listen or connection is reset. This function only
@@ -617,12 +610,12 @@ Tcp4Close (
@retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
is signaled.
@retval EFI_INVALID_PARAMETER This is NULL.
- @retval EFI_NOT_STARTED This instance hasn’t been configured.
+ @retval EFI_NOT_STARTED This instance hasn's been configured.
@retval EFI_NO_MAPPING When using the default address, configuration
- (DHCP, BOOTP,RARP, etc.) hasn’t finished yet.
- @retval EFI_NOT_FOUND The asynchronous I/O request isn’t found in the
+ (DHCP, BOOTP,RARP, etc.) hasn's finished yet.
+ @retval EFI_NOT_FOUND The asynchronous I/O request isn's found in the
transmission or receive queue. It has either
- completed or wasn’t issued by Transmit() and Receive().
+ completed or wasn's issued by Transmit() and Receive().
@retval EFI_UNSUPPORTED The operation is not supported in current
implementation.
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
index f1a69ab63d..3c2accf9eb 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
@@ -1,21 +1,14 @@
/** @file
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Main.h
-
-Abstract:
-
-
**/
#ifndef _TCP4_MAIN_H_
@@ -28,6 +21,7 @@ Abstract:
extern UINT16 mTcp4RandomPort;
+extern CHAR16 *mTcpStateName[];
//
// Driver Produced Protocol Prototypes
@@ -36,13 +30,31 @@ extern UINT16 mTcp4RandomPort;
//
// Function prototype for the Tcp4 socket request handler
//
+/**
+ The procotol handler provided to the socket layer, used to
+ dispatch the socket level requests by calling the corresponding
+ TCP layer functions.
+
+ @param Sock Pointer to the socket of this TCP instance.
+ @param Request The code of this operation request.
+ @param Data Pointer to the operation specific data passed in
+ together with the operation request.
+
+ @retval EFI_SUCCESS The socket request is completed successfully.
+ @retval other The error status returned by the corresponding TCP
+ layer function.
+
+**/
EFI_STATUS
Tcp4Dispatcher (
IN SOCKET *Sock,
IN SOCK_REQUEST Request,
IN VOID *Data OPTIONAL
);
-
+
+///
+/// TCP mode data
+///
typedef struct _TCP4_MODE_DATA {
EFI_TCP4_CONNECTION_STATE *Tcp4State;
EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;
@@ -51,6 +63,9 @@ typedef struct _TCP4_MODE_DATA {
EFI_SIMPLE_NETWORK_MODE *SnpModeData;
} TCP4_MODE_DATA;
+///
+/// TCP route infomation data
+///
typedef struct _TCP4_ROUTE_INFO {
BOOLEAN DeleteRoute;
EFI_IPv4_ADDRESS *SubnetAddress;
@@ -58,33 +73,136 @@ typedef struct _TCP4_ROUTE_INFO {
EFI_IPv4_ADDRESS *GatewayAddress;
} TCP4_ROUTE_INFO;
-//
-// Get the mode data of a TCP instance
-//
+/**
+ Get the current operational status of a TCP instance.
+
+ The GetModeData() function copies the current operational settings of this
+ EFI TCPv4 Protocol instance into user-supplied buffers. This function can
+ also be used to retrieve the operational setting of underlying drivers
+ such as IPv4, MNP, or SNP.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.
+ @param Tcp4State Pointer to the buffer to receive the current TCP
+ state.
+ @param Tcp4ConfigData Pointer to the buffer to receive the current TCP
+ configuration.
+ @param Ip4ModeData Pointer to the buffer to receive the current IPv4
+ configuration data used by the TCPv4 instance.
+ @param MnpConfigData Pointer to the buffer to receive the current MNP
+ configuration data indirectly used by the TCPv4
+ Instance.
+ @param SnpModeData Pointer to the buffer to receive the current SNP
+ configuration data indirectly used by the TCPv4
+ Instance.
+
+ @retval EFI_SUCCESS The mode data was read.
+ @retval EFI_NOT_STARTED No configuration data is available because this
+ instance hasn't been started.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+
+**/
EFI_STATUS
EFIAPI
Tcp4GetModeData (
- IN CONST EFI_TCP4_PROTOCOL *This,
- OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
- OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
- OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ IN CONST EFI_TCP4_PROTOCOL *This,
+ OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
+ OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
);
-//
-// Initialize or reset a TCP instance
-//
+
+/**
+ Initialize or brutally reset the operational parameters for
+ this EFI TCPv4 instance.
+
+ The Configure() function does the following:
+ * Initialize this EFI TCPv4 instance, i.e., initialize the communication end
+ setting, specify active open or passive open for an instance.
+ * Reset this TCPv4 instance brutally, i.e., cancel all pending asynchronous
+ tokens, flush transmission and receiving buffer directly without informing
+ the communication peer.
+ No other TCPv4 Protocol operation can be executed by this instance
+ until it is configured properly. For an active TCP4 instance, after a proper
+ configuration it may call Connect() to initiates the three-way handshake.
+ For a passive TCP4 instance, its state will transit to Tcp4StateListen after
+ configuration, and Accept() may be called to listen the incoming TCP connection
+ request. If TcpConfigData is set to NULL, the instance is reset. Resetting
+ process will be done brutally, the state machine will be set to Tcp4StateClosed
+ directly, the receive queue and transmit queue will be flushed, and no traffic is
+ allowed through this instance.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.
+ @param TcpConfigData Pointer to the configure data to configure the
+ instance.
+
+ @retval EFI_SUCCESS The operational settings are set, changed, or
+ reset successfully.
+ @retval EFI_NO_MAPPING When using a default address, configuration
+ (through DHCP, BOOTP, RARP, etc.) is not
+ finished.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+ @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already
+ configured.
+ @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
+ @retval EFI_UNSUPPORTED One or more of the control options are not
+ supported in the implementation.
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Configure (
IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
+ IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
);
-//
-// Add a route entry to the route table
-//
+/**
+ Add or delete routing entries.
+
+ The Routes() function adds or deletes a route from the instance's routing table.
+ The most specific route is selected by comparing the SubnetAddress with the
+ destination IP address's arithmetical AND to the SubnetMask.
+ The default route is added with both SubnetAddress and SubnetMask set to 0.0.0.0.
+ The default route matches all destination IP addresses if there is no more specific route.
+ Direct route is added with GatewayAddress set to 0.0.0.0. Packets are sent to
+ the destination host if its address can be found in the Address Resolution Protocol (ARP)
+ cache or it is on the local subnet. If the instance is configured to use default
+ address, a direct route to the local network will be added automatically.
+ Each TCP instance has its own independent routing table. Instance that uses the
+ default IP address will have a copy of the EFI_IP4_CONFIG_PROTOCOL's routing table.
+ The copy will be updated automatically whenever the IP driver reconfigures its
+ instance. As a result, the previous modification to the instance's local copy
+ will be lost. The priority of checking the route table is specific with IP
+ implementation and every IP implementation must comply with RFC 1122.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.
+ @param DeleteRoute If TRUE, delete the specified route from routing
+ table; if FALSE, add the specified route to
+ routing table.
+ DestinationAddress and SubnetMask are used as
+ the keywords to search route entry.
+ @param SubnetAddress The destination network.
+ @param SubnetMask The subnet mask for the destination network.
+ @param GatewayAddress The gateway address for this route.
+ It must be on the same subnet with the station
+ address unless a direct route is specified.
+
+ @retval EFI_SUCCESS The operation completed successfully.
+ @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been
+ configured.
+ @retval EFI_NO_MAPPING When using a default address, configuration
+ (through DHCP, BOOTP, RARP, etc.) is not
+ finished.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the
+ entry to the routing table.
+ @retval EFI_NOT_FOUND This route is not in the routing table.
+ @retval EFI_ACCESS_DENIED This route is already in the routing table.
+ @retval EFI_UNSUPPORTED The TCP driver does not support this operation.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Routes (
@@ -95,10 +213,35 @@ Tcp4Routes (
IN EFI_IPv4_ADDRESS *GatewayAddress
);
-//
-// Issue an asynchronous connection establishment
-// request to the peer
-//
+/**
+ Initiate a nonblocking TCP connection request for an active TCP instance.
+
+ The Connect() function will initiate an active open to the remote peer configured
+ in current TCP instance if it is configured active. If the connection succeeds
+ or fails due to any error, the ConnectionToken->CompletionToken.Event will be
+ signaled and ConnectionToken->CompletionToken.Status will be updated accordingly.
+ This function can only be called for the TCP instance in Tcp4StateClosed state.
+ The instance will transfer into Tcp4StateSynSent if the function returns EFI_SUCCESS.
+ If TCP three way handshake succeeds, its state will become Tcp4StateEstablished,
+ otherwise, the state will return to Tcp4StateClosed.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance
+ @param ConnectionToken Pointer to the connection token to return when
+ the TCP three way handshake finishes.
+
+ @retval EFI_SUCCESS The connection request is successfully initiated
+ and the state of this TCPv4 instance has
+ been changed to Tcp4StateSynSent.
+ @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been
+ configured.
+ @retval EFI_ACCESS_DENIED The instance is not configured as an active one
+ or it is not in Tcp4StateClosed state.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+ @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resource to
+ initiate the active open.
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Connect (
@@ -106,10 +249,36 @@ Tcp4Connect (
IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
);
-//
-// Issue an asynchronous listent token to accept an
-// incoming connection reques
-//
+/**
+ Listen on the passive instance to accept an incoming connection request.
+
+ The Accept() function initiates an asynchronous accept request to wait for an
+ incoming connection on the passive TCP instance. If a remote peer successfully
+ establishes a connection with this instance, a new TCP instance will be created
+ and its handle will be returned in ListenToken->NewChildHandle. The newly created
+ instance is configured by inheriting the passive instance's configuration and is
+ ready for use upon return. The instance is in the Tcp4StateEstablished state.
+ The ListenToken->CompletionToken.Event will be signaled when a new connection
+ is accepted, user aborts the listen or connection is reset. This function only
+ can be called when current TCP instance is in Tcp4StateListen state.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance
+ @param ListenToken Pointer to the listen token to return when
+ operation finishes.
+
+ @retval EFI_SUCCESS The listen token has been queued successfully.
+ @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
+ configured.
+ @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not
+ in Tcp4StateListen state or a same listen token
+ has already existed in the listen token queue of
+ this TCP instance.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish
+ the operation.
+ @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above category error.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Accept (
@@ -117,10 +286,40 @@ Tcp4Accept (
IN EFI_TCP4_LISTEN_TOKEN *ListenToken
);
-//
-// Issue an asynchronous IO token to transmit some data
-// through this TCP instance
-//
+/**
+ Queues outgoing data into the transmit queue.
+
+ The Transmit() function queues a sending request to this TCPv4 instance along
+ with the user data. The status of the token is updated and the event in the token
+ will be signaled once the data is sent out or some error occurs.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance
+ @param Token Pointer to the completion token to queue to the
+ transmit queue
+
+ @retval EFI_SUCCESS The data has been queued for transmission.
+ @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
+ configured.
+ @retval EFI_NO_MAPPING When using a default address, configuration
+ (DHCP, BOOTP, RARP, etc.) is not finished yet.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+ @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
+ * A transmit completion token with the same
+ Token-> CompletionToken.Event was already in the
+ transmission queue.
+ * The current instance is in Tcp4StateClosed state
+ * The current instance is a passive one and
+ it is in Tcp4StateListen state.
+ * User has called Close() to disconnect this
+ connection.
+ @retval EFI_NOT_READY The completion token could not be queued because
+ the transmit queue is full.
+ @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of
+ resource shortage.
+ @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or
+ address.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Transmit (
@@ -128,10 +327,52 @@ Tcp4Transmit (
IN EFI_TCP4_IO_TOKEN *Token
);
-//
-// Issue an asynchronous IO token to receive some data
-// through this TCP instance
-//
+/**
+ Place an asynchronous receive request into the receiving queue.
+
+ The Receive() function places a completion token into the receive packet queue.
+ This function is always asynchronous. The caller must allocate the
+ Token->CompletionToken.Event and the FragmentBuffer used to receive data. He also
+ must fill the DataLength which represents the whole length of all FragmentBuffer.
+ When the receive operation completes, the EFI TCPv4 Protocol driver updates the
+ Token->CompletionToken.Status and Token->Packet.RxData fields and the
+ Token->CompletionToken.Event is signaled. If got data the data and its length
+ will be copy into the FragmentTable, in the same time the full length of received
+ data will be recorded in the DataLength fields. Providing a proper notification
+ function and context for the event will enable the user to receive the notification
+ and receiving status. That notification function is guaranteed to not be re-entered.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.
+ @param Token Pointer to a token that is associated with the
+ receive data descriptor.
+
+ @retval EFI_SUCCESS The receive completion token was cached.
+ @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
+ configured.
+ @retval EFI_NO_MAPPING When using a default address, configuration
+ (DHCP, BOOTP, RARP, etc.) is not finished yet.
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+ @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
+ due to a lack of system resources.
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
+ The EFI TCPv4 Protocol instance has been reset
+ to startup defaults.
+ @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:
+ * A receive completion token with the same
+ Token->CompletionToken.Event was already in
+ the receive queue.
+ * The current instance is in Tcp4StateClosed state.
+ * The current instance is a passive one and it
+ is in Tcp4StateListen state.
+ * User has called Close() to disconnect this
+ connection.
+ @retval EFI_CONNECTION_FIN The communication peer has closed the connection
+ and there is no any buffered data in the receive
+ buffer of this instance.
+ @retval EFI_NOT_READY The receive request could not be queued because
+ the receive queue is full.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Receive (
@@ -139,10 +380,37 @@ Tcp4Receive (
IN EFI_TCP4_IO_TOKEN *Token
);
-//
-// Issue an asynchronous CloseToken to close a TCP
-// connection represented by instance
-//
+/**
+ Disconnecting a TCP connection gracefully or reset a TCP connection.
+
+ Initiate an asynchronous close token to TCP driver. After Close() is called,
+ any buffered transmission data will be sent by TCP driver and the current
+ instance will have a graceful close working flow described as RFC 793 if
+ AbortOnClose is set to FALSE, otherwise, a rest packet will be sent by TCP
+ driver to fast disconnect this connection. When the close operation completes
+ successfully the TCP instance is in Tcp4StateClosed state, all pending
+ asynchronous operation is signaled and any buffers used for TCP network traffic
+ is flushed.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.
+ @param CloseToken Pointer to the close token to return when
+ operation finishes.
+
+ @retval EFI_SUCCESS The operation completed successfully.
+ @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been
+ configured.
+ @retval EFI_ACCESS_DENIED One or more of the following are TRUE:
+ * Configure() has been called with TcpConfigData
+ set to NULL and this function has not returned.
+ * Previous Close() call on this instance has not
+ finished.
+ @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.
+ @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the
+ operation.
+ @retval EFI_DEVICE_ERROR Any unexpected and not belonged to above
+ category error.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Close (
@@ -150,19 +418,65 @@ Tcp4Close (
IN EFI_TCP4_CLOSE_TOKEN *CloseToken
);
-//
-// cancle an connect, listent or IO token
-//
+/**
+ Abort an asynchronous connection, listen, transmission or receive request.
+
+ The Cancel() function aborts a pending connection, listen, transmit or receive
+ request. If Token is not NULL and the token is in the connection, listen,
+ transmission or receive queue when it is being cancelled, its Token->Status
+ will be set to EFI_ABORTED and then Token->Event will be signaled. If the token
+ is not in one of the queues, which usually means that the asynchronous operation
+ has completed, EFI_NOT_FOUND is returned. If Token is NULL all asynchronous token
+ issued by Connect(), Accept(), Transmit() and Receive()will be aborted.
+ NOTE: It has not been implemented currently.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.
+ @param Token Pointer to a token that has been issued by
+ Connect(), Accept(), Transmit() or Receive(). If
+ NULL, all pending tokens issued by above four
+ functions will be aborted.
+
+ @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event
+ is signaled.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_NOT_STARTED This instance hasn's been configured.
+ @retval EFI_NO_MAPPING When using the default address, configuration
+ (DHCP, BOOTP,RARP, etc.) hasn's finished yet.
+ @retval EFI_NOT_FOUND The asynchronous I/O request isn's found in the
+ transmission or receive queue. It has either
+ completed or wasn's issued by Transmit() and Receive().
+ @retval EFI_UNSUPPORTED The operation is not supported in current
+ implementation.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Cancel (
IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
+ IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
);
-//
-// poll data from NIC for receive
-//
+/**
+ Poll to receive incoming data and transmit outgoing segments.
+
+ The Poll() function increases the rate that data is moved between the network
+ and application and can be called when the TCP instance is created successfully.
+ Its use is optional. In some implementations, the periodical timer in the MNP
+ driver may not poll the underlying communications device fast enough to avoid
+ drop packets. Drivers and applications that are experiencing packet loss should
+ try calling the Poll() function in a high frequency.
+
+ @param This Pointer to the EFI_TCP4_PROTOCOL instance.
+
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
+ @retval EFI_NOT_READY No incoming or outgoing data was processed.
+ @retval EFI_TIMEOUT Data was dropped out of the transmission or
+ receive queue. Consider increasing the polling
+ rate.
+
+**/
EFI_STATUS
EFIAPI
Tcp4Poll (
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
index 6d7117a164..1c269929e3 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
@@ -1,23 +1,15 @@
/** @file
+ Misc support routines for tcp.
-Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Misc.c
-
-Abstract:
-
- Misc support routines for tcp.
-
-
**/
@@ -405,7 +397,7 @@ TcpInsertTcb (
/**
- Clone a TCP_CB from Tcb.
+ Clone a TCB_CB from Tcb.
@param Tcb Pointer to the TCP_CB to be cloned.
@@ -504,8 +496,8 @@ TcpGetRcvMss (
**/
VOID
TcpSetState (
- IN TCP_CB *Tcb,
- IN UINT8 State
+ IN TCP_CB *Tcb,
+ IN TCP_STATES State
)
{
DEBUG (
@@ -516,7 +508,7 @@ TcpSetState (
mTcpStateName[State])
);
- Tcb->State = State;
+ Tcb->State = (TCP_STATES)State;
switch (State) {
case TCP_ESTABLISHED:
@@ -538,6 +530,8 @@ TcpSetState (
SockConnClosed (Tcb->Sk);
break;
+ case default:
+ break;
}
}
@@ -572,7 +566,6 @@ TcpChecksum (
return (UINT16) ~Checksum;
}
-
/**
Translate the information from the head of the received TCP
segment Nbuf contains and fill it into a TCP_SEG structure.
@@ -731,6 +724,8 @@ TcpOnAppClose (
case TCP_CLOSE_WAIT:
TcpSetState (Tcb, TCP_LAST_ACK);
break;
+ case default:
+ break;
}
TcpToSendData (Tcb, 1);
@@ -781,6 +776,8 @@ TcpOnAppSend (
case TCP_TIME_WAIT:
return -1;
break;
+ case default:
+ break;
}
return 0;
@@ -822,13 +819,13 @@ TcpOnAppConsume (
if (TcpOld < Tcb->RcvMss) {
DEBUG ((EFI_D_INFO, "TcpOnAppConsume: send a window"
- " update for a window closed Tcb(%p)\n", Tcb));
+ " update for a window closed Tcb %p\n", Tcb));
TcpSendAck (Tcb);
} else if (Tcb->DelayedAck == 0) {
DEBUG ((EFI_D_INFO, "TcpOnAppConsume: scheduled a delayed"
- " ACK to update window for Tcb(%p)\n", Tcb));
+ " ACK to update window for Tcb %p\n", Tcb));
Tcb->DelayedAck = 1;
}
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c
index 35e858fb9a..f321635323 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c
@@ -1,23 +1,15 @@
/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
+ Routines to process TCP option.
+
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Option.c
-
-Abstract:
-
- Routines to process TCP option.
-
-
**/
#include "Tcp4Main.h"
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
index faa4ffa587..727c6f2dd4 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
@@ -1,36 +1,29 @@
/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
+
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Option.h
-
-Abstract:
-
-
**/
#ifndef _TCP4_OPTION_H_
#define _TCP4_OPTION_H_
-//
-// The structure to store the parse option value.
-// ParseOption only parse the options, don't process them.
-//
-typedef struct s_TCP_OPTION {
- UINT8 Flag; // flag such as TCP_OPTION_RCVD_MSS
- UINT8 WndScale; // the WndScale received
- UINT16 Mss; // the Mss received
- UINT32 TSVal; // the TSVal field in a timestamp option
- UINT32 TSEcr; // the TSEcr field in a timestamp option
+///
+/// The structure to store the parse option value.
+/// ParseOption only parse the options, don't process them.
+///
+typedef struct _TCP_OPTION {
+ UINT8 Flag; ///< Flag such as TCP_OPTION_RCVD_MSS
+ UINT8 WndScale; ///< The WndScale received
+ UINT16 Mss; ///< The Mss received
+ UINT32 TSVal; ///< The TSVal field in a timestamp option
+ UINT32 TSEcr; ///< The TSEcr field in a timestamp option
} TCP_OPTION;
typedef enum {
@@ -38,16 +31,16 @@ typedef enum {
//
// 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
+ 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
@@ -71,33 +64,80 @@ typedef enum {
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_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.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+
+ @return The scale value.
+
+**/
UINT8
TcpComputeScale (
IN TCP_CB *Tcb
);
+/**
+ Build the TCP option in three-way handshake.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Nbuf Pointer to the buffer to store the options.
+
+ @return The total length of the TCP option field.
+
+**/
UINT16
TcpSynBuildOption (
IN TCP_CB *Tcb,
- IN NET_BUF *Buf
+ IN NET_BUF *Nbuf
);
+/**
+ Build the TCP option in synchronized states.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param Nbuf Pointer to the buffer to store the options.
+
+ @return The total length of the TCP option field.
+
+**/
UINT16
TcpBuildOption (
IN TCP_CB *Tcb,
- IN NET_BUF *Buf
+ IN NET_BUF *Nbuf
);
+/**
+ Parse the supported options.
+
+ @param Tcp Pointer to the TCP_CB of this TCP instance.
+ @param Option Pointer to the TCP_OPTION used to store the successfully pasrsed
+ options.
+
+ @retval 0 The options are successfully pasrsed.
+ @retval -1 Ilegal option was found.
+
+**/
INTN
TcpParseOption (
IN TCP_HEAD *Tcp,
IN TCP_OPTION *Option
);
+/**
+ Check the segment against PAWS.
+
+ @param Tcb Pointer to the TCP_CB of this TCP instance.
+ @param TSVal The timestamp value.
+
+ @retval 1 The segment passed the PAWS check.
+ @retval 0 The segment failed to pass the PAWS check.
+
+**/
UINT32
TcpPawsOK (
IN TCP_CB *Tcb,
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
index 187fd955a9..f12b2c5b4c 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
@@ -1,23 +1,15 @@
/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
+ TCP output process routines.
+
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Output.c
-
-Abstract:
-
- TCP output process routines.
-
-
**/
#include "Tcp4Main.h"
@@ -112,8 +104,7 @@ TcpRcvWinNow (
/**
- Compute the value to fill in the window size field
- of the outgoing segment.
+ Compute the value to fill in the window size field of the outgoing segment.
@param Tcb Pointer to the TCP_CB of this TCP instance.
@param Syn The flag to indicate whether the outgoing segment is a SYN
@@ -808,8 +799,13 @@ SEND_AGAIN:
(GET_SND_DATASIZE (Tcb->Sk) == 0) &&
TCP_SEQ_LT (End + 1, Tcb->SndWnd + Tcb->SndWl2)) {
- DEBUG ((EFI_D_INFO, "TcpToSendData: send FIN "
- "to peer for TCB %p in state %d\n", Tcb, Tcb->State));
+ DEBUG (
+ (EFI_D_INFO,
+ "TcpToSendData: send FIN "
+ "to peer for TCB %p in state %s\n",
+ Tcb,
+ mTcpStateName[Tcb->State])
+ );
End++;
} else {
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
index ee278e3516..8bb99caac0 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
@@ -1,21 +1,14 @@
/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
+
+Copyright (c) 2005 - 2006, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Proto.h
-
-Abstract:
-
-
**/
#ifndef _TCP4_PROTO_H_
@@ -27,10 +20,12 @@ typedef struct _TCP_CB TCP_CB;
#include "Socket.h"
#include "Tcp4Option.h"
-//
-// tcp states, Don't change their order, it is used as
-// index to mTcpOutFlag and other macros
-//
+
+
+///
+/// Tcp states, Don't change their order, it is used as
+/// index to mTcpOutFlag and other macros
+///
typedef enum {
TCP_CLOSED = 0,
TCP_LISTEN,
@@ -45,9 +40,9 @@ typedef enum {
TCP_LAST_ACK
} TCP_STATES;
-//
-// flags in the TCP header
-//
+///
+/// Flags in the TCP header
+///
typedef enum {
TCP_FLG_FIN = 0x01,
@@ -56,72 +51,73 @@ typedef enum {
TCP_FLG_PSH = 0x08,
TCP_FLG_ACK = 0x10,
TCP_FLG_URG = 0x20,
- TCP_FLG_FLAG = 0x3F // mask for all the flags
+
+ //
+ // mask for all the flags
+ //
+ TCP_FLG_FLAG = 0x3F
} TCP_HEADER_FLAG;
typedef enum {
- //
- // TCP error status
- //
- TCP_CONNECT_REFUSED = -1,
- TCP_CONNECT_RESET = -2,
- TCP_CONNECT_CLOSED = -3,
+ 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.
//
- 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_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
//
- 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, // rcvd a wnd scale option in syn
- TCP_CTRL_NO_TS = 0x0010, // disable Timestamp option
- TCP_CTRL_RCVD_TS = 0x0020, // rcvd 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
+ 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
//
- 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
+ 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
+ // 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_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, // * 60,
- 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,
+ 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 :
@@ -130,132 +126,133 @@ typedef enum {
TCP_MAX_HEAD = 192,
//
- // value ranges for some control option
+ // 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_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_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_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;
+///
+/// TCP segmentation data
+///
typedef struct _TCP_SEG {
- TCP_SEQNO Seq; // Starting sequence number
- TCP_SEQNO End; // The sequence of the last byte + 1,
- // include SYN/FIN. End-Seq = SEG.LEN
- TCP_SEQNO Ack; // ACK fild in the segment
- UINT8 Flag; // TCP header flags
- UINT16 Urg; // Valid if URG flag is set.
- UINT32 Wnd; // TCP window size field
+ TCP_SEQNO Seq; ///< Starting sequence number
+ TCP_SEQNO End; ///< The sequence of the last byte + 1, include SYN/FIN. End-Seq = SEG.LEN
+ TCP_SEQNO Ack; ///< ACK field in the segment
+ UINT8 Flag; ///< TCP header flags
+ UINT16 Urg; ///< Valid if URG flag is set.
+ UINT32 Wnd; ///< TCP window size field
} TCP_SEG;
+///
+/// Network endpoint, IP+Port structure
+///
typedef struct _TCP_PEER {
- UINT32 Ip; // Network byte order
- TCP_PORTNO Port; // Network byte order
+ UINT32 Ip; ///< IP address, network byte order
+ TCP_PORTNO Port; ///< Port number, network byte order
} TCP_PEER;
-//
-// tcp control block, it includes various states
-//
+///
+/// TCP control block, it includes various states
+///
struct _TCP_CB {
- LIST_ENTRY List;
- TCP_CB *Parent;
+ LIST_ENTRY List; ///< Back and forward link entry
+ TCP_CB *Parent; ///< The parent TCP_CB structure
- SOCKET *Sk;
- TCP_PEER LocalEnd;
- TCP_PEER RemoteEnd;
+ SOCKET *Sk; ///< The socket it controled.
+ TCP_PEER LocalEnd; ///< Local endpoint
+ TCP_PEER RemoteEnd;///< Remote endpoint
- LIST_ENTRY SndQue; // retxmission queue
- LIST_ENTRY RcvQue; // reassemble queue
- UINT32 CtrlFlag; // control flags, such as NO_NAGLE
- INT32 Error; // soft error status,TCP_CONNECT_RESET...
+ LIST_ENTRY SndQue; ///< Retxmission queue
+ LIST_ENTRY RcvQue; ///< Reassemble queue
+ UINT32 CtrlFlag; ///< Control flags, such as NO_NAGLE
+ INT32 Error; ///< Soft error status, such as TCP_CONNECT_RESET
//
// RFC793 and RFC1122 defined variables
//
- UINT8 State; // TCP state, such as SYN_SENT, LISTEN
- UINT8 DelayedAck; // number of delayed ACKs
- UINT16 HeadSum; // checksum of the fixed parts of pesudo
- // header: Src IP, Dst IP, 0, Protocol,
- // not include the TCP length.
-
- TCP_SEQNO Iss; // Initial Sending Sequence
- TCP_SEQNO SndUna; // first unacknowledged data
- TCP_SEQNO SndNxt; // next data sequence to send.
- TCP_SEQNO SndPsh; // Send PUSH point
- TCP_SEQNO SndUp; // Send urgent point
- UINT32 SndWnd; // Window advertised by the remote peer
- UINT32 SndWndMax; // max send window advertised by the peer
- TCP_SEQNO SndWl1; // Seq number used for last window update
- TCP_SEQNO SndWl2; // ack no of last window update
- UINT16 SndMss; // Max send segment size
- TCP_SEQNO RcvNxt; // Next sequence no to receive
- UINT32 RcvWnd; // Window advertised by the local peer
- TCP_SEQNO RcvWl2; // The RcvNxt (or ACK) of last window update.
- // It is necessary because of delayed ACK
-
- TCP_SEQNO RcvUp; // urgent point;
- TCP_SEQNO Irs; // Initial Receiving Sequence
- UINT16 RcvMss; // Max receive segment size
- UINT16 EnabledTimer; // which timer is currently enabled
- UINT32 Timer[TCP_TIMER_NUMBER]; // when the timer will expire
- INT32 NextExpire; // count down offset for the nearest timer
- UINT32 Idle; // How long the connection is in idle
- UINT32 ProbeTime; // the time out value for current window prober
+ TCP_STATES State; ///< TCP state, such as SYN_SENT, LISTEN
+ UINT8 DelayedAck; ///< Number of delayed ACKs
+ UINT16 HeadSum; ///< Checksum of the fixed parts of pesudo
+ ///< header: Src IP, Dst IP, 0, Protocol,
+ ///< not include the TCP length.
+
+ TCP_SEQNO Iss; ///< Initial Sending Sequence
+ TCP_SEQNO SndUna; ///< First unacknowledged data
+ TCP_SEQNO SndNxt; ///< Next data sequence to send.
+ TCP_SEQNO SndPsh; ///< Send PUSH point
+ TCP_SEQNO SndUp; ///< Send urgent point
+ UINT32 SndWnd; ///< Window advertised by the remote peer
+ UINT32 SndWndMax; ///< Max send window advertised by the peer
+ TCP_SEQNO SndWl1; ///< Seq number used for last window update
+ TCP_SEQNO SndWl2; ///< Ack no of last window update
+ UINT16 SndMss; ///< Max send segment size
+ TCP_SEQNO RcvNxt; ///< Next sequence no to receive
+ UINT32 RcvWnd; ///< Window advertised by the local peer
+ TCP_SEQNO RcvWl2; ///< The RcvNxt (or ACK) of last window update.
+ ///< It is necessary because of delayed ACK
+
+ TCP_SEQNO RcvUp; ///< Urgent point;
+ TCP_SEQNO Irs; ///< Initial Receiving Sequence
+ UINT16 RcvMss; ///< Max receive segment size
+ UINT16 EnabledTimer; ///< Which timer is currently enabled
+ UINT32 Timer[TCP_TIMER_NUMBER]; ///< When the timer will expire
+ INT32 NextExpire; ///< Count down offset for the nearest timer
+ UINT32 Idle; ///< How long the connection is in idle
+ UINT32 ProbeTime; ///< The time out value for current window prober
//
// RFC1323 defined variables, about window scale,
// timestamp and PAWS
//
- UINT8 SndWndScale; // Wndscale received from the peer
- UINT8 RcvWndScale; // Wndscale used to scale local buffer
- UINT32 TsRecent; // TsRecent to echo to the remote peer
- UINT32 TsRecentAge; // When this TsRecent is updated
-
- // TCP_SEQNO LastAckSent;
- // It isn't necessary to add LastAckSent here,
- // since it is the same as RcvWl2
+ UINT8 SndWndScale; ///< Wndscale received from the peer
+ UINT8 RcvWndScale; ///< Wndscale used to scale local buffer
+ UINT32 TsRecent; ///< TsRecent to echo to the remote peer
+ UINT32 TsRecentAge; ///< When this TsRecent is updated
//
// RFC2988 defined variables. about RTT measurement
//
- TCP_SEQNO RttSeq; // the seq of measured segment now
- UINT32 RttMeasure; // currently measured RTT in heart beats
- UINT32 SRtt; // Smoothed RTT, scaled by 8
- UINT32 RttVar; // RTT variance, scaled by 8
- UINT32 Rto; // Current RTO, not scaled
+ TCP_SEQNO RttSeq; ///< The seq of measured segment now
+ UINT32 RttMeasure; ///< Currently measured RTT in heart beats
+ UINT32 SRtt; ///< Smoothed RTT, scaled by 8
+ UINT32 RttVar; ///< RTT variance, scaled by 8
+ UINT32 Rto; ///< Current RTO, not scaled
//
// RFC2581, and 3782 variables.
// Congestion control + NewReno fast recovery.
//
- UINT32 CWnd; // Sender's congestion window
- UINT32 Ssthresh; // Slow start threshold.
- TCP_SEQNO Recover; // recover point for NewReno
- UINT16 DupAck; // number of duplicate ACKs
- UINT8 CongestState; // the current congestion state(RFC3782)
- UINT8 LossTimes; // number of retxmit timeouts in a row
- TCP_SEQNO LossRecover; // recover point for retxmit
+ UINT32 CWnd; ///< Sender's congestion window
+ UINT32 Ssthresh; ///< Slow start threshold.
+ TCP_SEQNO Recover; ///< Recover point for NewReno
+ UINT16 DupAck; ///< Number of duplicate ACKs
+ UINT8 CongestState; ///< The current congestion state(RFC3782)
+ UINT8 LossTimes; ///< Number of retxmit timeouts in a row
+ TCP_SEQNO LossRecover; ///< Recover point for retxmit
//
// configuration parameters, for EFI_TCP4_PROTOCOL specification
//
- UINT32 KeepAliveIdle; // idle time before sending first probe
- UINT32 KeepAlivePeriod; // interval for subsequent keep alive probe
- UINT8 MaxKeepAlive; // Maxium keep alive probe times.
- UINT8 KeepAliveProbes; // the number of keep alive probe.
- UINT16 MaxRexmit; // The maxium number of retxmit before abort
- UINT32 FinWait2Timeout; // The FIN_WAIT_2 time out
- UINT32 TimeWaitTimeout; // The TIME_WAIT time out
- UINT32 ConnectTimeout;
+ UINT32 KeepAliveIdle; ///< Idle time before sending first probe
+ UINT32 KeepAlivePeriod; ///< Interval for subsequent keep alive probe
+ UINT8 MaxKeepAlive; ///< Maxium keep alive probe times.
+ UINT8 KeepAliveProbes; ///< The number of keep alive probe.
+ UINT16 MaxRexmit; ///< The maxium number of retxmit before abort
+ UINT32 FinWait2Timeout; ///< The FIN_WAIT_2 time out
+ UINT32 TimeWaitTimeout; ///< The TIME_WAIT time out
+ UINT32 ConnectTimeout; ///< The connect establishment time out
//
// configuration for tcp provided by user
@@ -265,10 +262,7 @@ struct _TCP_CB {
UINT8 TTL;
EFI_IPv4_ADDRESS SubnetMask;
- //
- // pointer reference to Ip used to send pkt
- //
- IP_IO_IP_INFO *IpInfo;
+ IP_IO_IP_INFO *IpInfo; ///<pointer reference to Ip used to send pkt
};
extern LIST_ENTRY mTcpRunQue;
@@ -276,9 +270,9 @@ extern LIST_ENTRY mTcpListenQue;
extern TCP_SEQNO mTcpGlobalIss;
extern UINT32 mTcpTick;
-//
-// TCP_CONNECTED: both ends have synchronized their ISN.
-//
+///
+/// TCP_CONNECTED: both ends have synchronized their ISN.
+///
#define TCP_CONNECTED(state) ((state) > TCP_SYN_RCVD)
#define TCP_FIN_RCVD(State) \
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c
index 65c98de048..8ef9d2cedd 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c
@@ -1,23 +1,15 @@
/** @file
-
-Copyright (c) 2005 - 2007, Intel Corporation
+ TCP timer related functions.
+
+Copyright (c) 2005 - 2007, 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
-http://opensource.org/licenses/bsd-license.php
+http://opensource.org/licenses/bsd-license.php<BR>
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
-
- Tcp4Timer.c
-
-Abstract:
-
- TCP timer related functions.
-
-
**/
#include "Tcp4Main.h"