summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Network/Tcp4Dxe
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2007-09-30 03:08:02 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2007-09-30 03:08:02 +0000
commit83cbd279b64f3081af5c06d50fa26e15a99fc066 (patch)
tree98bd3d981f28536759a3e5f451d4752d38d7a665 /MdeModulePkg/Universal/Network/Tcp4Dxe
parent5bca971e545e01271c6ae5b1b66ee9f281123bf2 (diff)
downloadedk2-platforms-83cbd279b64f3081af5c06d50fa26e15a99fc066.tar.xz
Update to support to produce Component Name and & Component Name 2 protocol based on Feature flag PcdComponentNameDisable & PcdComponentName2Disable.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4006 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Network/Tcp4Dxe')
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c333
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h168
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h1020
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c8
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h282
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h716
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h350
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h214
-rw-r--r--MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h710
9 files changed, 1975 insertions, 1826 deletions
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
index 477af22e1e..fae269fa16 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/ComponentName.c
@@ -23,6 +23,45 @@ Abstract:
//
// EFI Component Name Functions
//
+/**
+ Retrieves a Unicode string that is the user readable name of the driver.
+
+ This function retrieves the user readable name of a driver in the form of a
+ Unicode string. If the driver specified by This has a user readable name in
+ the language specified by Language, then a pointer to the driver name is
+ returned in DriverName, and EFI_SUCCESS 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
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+
+ @param Language[in] 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
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ 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.
+ This Unicode string is the name of the
+ driver specified by This in the language
+ specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by
+ This and the language specified by Language was
+ returned in DriverName.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
EFI_STATUS
EFIAPI
TcpComponentNameGetDriverName (
@@ -31,28 +70,108 @@ TcpComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
+
+/**
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by a driver.
+
+ This function retrieves the user readable name of the controller specified by
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the
+ driver specified by This has a user readable name in the language specified by
+ Language, then a pointer to the controller name is returned in ControllerName,
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently
+ managing the controller specified by ControllerHandle and ChildHandle,
+ 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
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+
+ @param ControllerHandle[in] 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
+ 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
+ that wish to retrieve the name of the bus
+ controller. It will not be NULL for a bus
+ driver that wishes to retrieve the name of a
+ child controller.
+
+ @param Language[in] 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
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ 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.
+ This Unicode string is the name of the
+ controller specified by ControllerHandle and
+ ChildHandle in the language specified by
+ Language from the point of view of the driver
+ specified by This.
+
+ @retval EFI_SUCCESS The Unicode string for the user readable name in
+ the language specified by Language for the
+ driver specified by This was returned in
+ DriverName.
+
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
+
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
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 gTcp4ComponentName = {
+EFI_COMPONENT_NAME_PROTOCOL gTcp4ComponentName = {
TcpComponentNameGetDriverName,
TcpComponentNameGetControllerName,
"eng"
-};
+ };
+
+//
+// EFI Component Name 2 Protocol
+//
+EFI_COMPONENT_NAME2_PROTOCOL gTcp4ComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) TcpComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) TcpComponentNameGetControllerName,
+ "en"
+ };
+
static EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
{
- "eng",
+ "eng;en",
L"Tcp Network Service Driver"
},
{
@@ -61,6 +180,45 @@ static EFI_UNICODE_STRING_TABLE mTcpDriverNameTable[] = {
}
};
+/**
+ Retrieves a Unicode string that is the user readable name of the driver.
+
+ This function retrieves the user readable name of a driver in the form of a
+ Unicode string. If the driver specified by This has a user readable name in
+ the language specified by Language, then a pointer to the driver name is
+ returned in DriverName, and EFI_SUCCESS 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
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+
+ @param Language[in] 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
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ 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.
+ This Unicode string is the name of the
+ driver specified by This in the language
+ specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by
+ This and the language specified by Language was
+ returned in DriverName.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
EFI_STATUS
EFIAPI
TcpComponentNameGetDriverName (
@@ -68,102 +226,93 @@ TcpComponentNameGetDriverName (
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
-/*++
+{
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mTcpDriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gTcp4ComponentName)
+ );
+}
-Routine Description:
+/**
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by a driver.
- Retrieves a Unicode string that is the user readable name of the EFI Driver.
+ This function retrieves the user readable name of the controller specified by
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the
+ driver specified by This has a user readable name in the language specified by
+ Language, then a pointer to the controller name is returned in ControllerName,
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently
+ managing the controller specified by ControllerHandle and ChildHandle,
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.
-Arguments:
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- Language - A pointer to a three character ISO 639-2 language identifier.
- This is the language of the driver name that that the caller
- is requesting, and it must match one of the languages
- specified in SupportedLanguages. The number of languages
- supported by a driver is up to the driver writer.
- 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.
+ @param ControllerHandle[in] The handle of a controller that the driver
+ specified by This is managing. This handle
+ specifies the controller whose name is to be
+ returned.
-Returns:
+ @param ChildHandle[in] 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
+ that wish to retrieve the name of the bus
+ controller. It will not be NULL for a bus
+ driver that wishes to retrieve the name of a
+ child controller.
- EFI_SUCCES - The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
- EFI_INVALID_PARAMETER - Language is NULL.
- EFI_INVALID_PARAMETER - DriverName is NULL.
- EFI_UNSUPPORTED - The driver specified by This does not support the
- language specified by Language.
+ @param Language[in] 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
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified in
+ RFC 3066 or ISO 639-2 language code format.
---*/
-{
- return LookupUnicodeString (
- Language,
- gTcp4ComponentName.SupportedLanguages,
- mTcpDriverNameTable,
- DriverName
- );
-}
+ @param ControllerName[out] 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
+ Language from the point of view of the driver
+ specified by This.
+
+ @retval EFI_SUCCESS The Unicode string for the user readable name in
+ the language specified by Language for the
+ driver specified by This was returned in
+ DriverName.
+
+ @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
+
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
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
)
-/*++
-
-Routine Description:
-
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by an EFI Driver.
-
-Arguments:
-
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- 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.
- 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 that wish to retrieve the name of
- the bus controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a child
- controller.
- Language - A pointer to a three character ISO 639-2 language
- identifier. This is the language of the controller
- name that that the caller is requesting, and it must
- match one of the languages specified in supported
- languages. The number of languages supported by a driver
- is up to the driver writer.
- 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 Language from the point of view of the
- driver specified by This.
-
-Returns:
-
- EFI_SUCCESS - The Unicode string for the user readable name in
- the language specified by Language for the driver
- specified by This was returned in DriverName.
- EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
- EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- EFI_INVALID_PARAMETER - Language is NULL.
- EFI_INVALID_PARAMETER - ControllerName is NULL.
- EFI_UNSUPPORTED - The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- EFI_UNSUPPORTED - The driver specified by This does not support the
- language specified by Language.
-
---*/
{
return EFI_UNSUPPORTED;
}
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
index 69a1ac6222..13feea18fa 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.h
@@ -1,84 +1,84 @@
-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-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
-
-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_
-#define _SOCK_IMPL_H_
-
-#include "Socket.h"
-
-#define SOCK_DEBUG_ERROR(PrintArg) NET_DEBUG_ERROR("Sock", PrintArg)
-#define SOCK_DEBUG_WARN(PrintArg) NET_DEBUG_WARNING("Sock", PrintArg)
-#define SOCK_DEBUG_TRACE(PrintArg) NET_DEBUG_TRACE("Sock", PrintArg)
-
-#define SOCK_TRIM_RCV_BUFF(Sock, Len) \
- (NetbufQueTrim ((Sock)->RcvBuffer.DataQueue, (Len)))
-
-#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
-//
-VOID
-SockFreeFoo (
- IN EFI_EVENT Event
- );
-
-EFI_STATUS
-SockProcessTcpSndData (
- IN SOCKET *Sock,
- IN VOID *TcpTxData
- );
-
-VOID
-SockSetTcpRxData (
- IN SOCKET *Sock,
- IN VOID *TcpRxData,
- IN UINT32 RcvdBytes,
- IN BOOLEAN IsOOB
- );
-
-UINT32
-SockProcessRcvToken (
- IN SOCKET *Sock,
- IN SOCK_IO_TOKEN *RcvToken
- );
-
-VOID
-SockConnFlush (
- IN SOCKET *Sock
- );
-
-SOCKET *
-SockCreate (
- IN SOCK_INIT_DATA *SockInitData
- );
-
-VOID
-SockDestroy (
- IN SOCKET *Sock
- );
-
-#endif
+/** @file
+
+Copyright (c) 2005 - 2006, Intel Corporation
+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
+
+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_
+#define _SOCK_IMPL_H_
+
+#include "Socket.h"
+
+#define SOCK_DEBUG_ERROR(PrintArg) NET_DEBUG_ERROR("Sock", PrintArg)
+#define SOCK_DEBUG_WARN(PrintArg) NET_DEBUG_WARNING("Sock", PrintArg)
+#define SOCK_DEBUG_TRACE(PrintArg) NET_DEBUG_TRACE("Sock", PrintArg)
+
+#define SOCK_TRIM_RCV_BUFF(Sock, Len) \
+ (NetbufQueTrim ((Sock)->RcvBuffer.DataQueue, (Len)))
+
+#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
+//
+VOID
+SockFreeFoo (
+ IN EFI_EVENT Event
+ );
+
+EFI_STATUS
+SockProcessTcpSndData (
+ IN SOCKET *Sock,
+ IN VOID *TcpTxData
+ );
+
+VOID
+SockSetTcpRxData (
+ IN SOCKET *Sock,
+ IN VOID *TcpRxData,
+ IN UINT32 RcvdBytes,
+ IN BOOLEAN IsOOB
+ );
+
+UINT32
+SockProcessRcvToken (
+ IN SOCKET *Sock,
+ IN SOCK_IO_TOKEN *RcvToken
+ );
+
+VOID
+SockConnFlush (
+ IN SOCKET *Sock
+ );
+
+SOCKET *
+SockCreate (
+ IN SOCK_INIT_DATA *SockInitData
+ );
+
+VOID
+SockDestroy (
+ IN SOCKET *Sock
+ );
+
+#endif
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
index 75efa045b1..34b098bcde 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
@@ -1,520 +1,520 @@
-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-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
-
-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_
-#define _SOCKET_H_
-
+/** @file
+
+Copyright (c) 2005 - 2006, Intel Corporation
+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
+
+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_
+#define _SOCKET_H_
+
#include <PiDxe.h>
#include <Protocol/IP4.h>
-#include <Protocol/Tcp4.h>
+#include <Protocol/Tcp4.h>
#include <Protocol/Udp4.h>
-
+
#include <Library/NetLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
-#include <Library/UefiLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseMemoryLib.h>
-
-#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_BACKLOG 5
-
-#define PROTO_RESERVED_LEN 20
-
-#define SO_NO_MORE_DATA 0x0001
-
-//
-//
-//
-// When a socket is created it enters into SO_UNCONFIGURED,
-// no actions can be taken on this socket, only after calling
-// SockConfigure. The state transition diagram of socket is
-// as following:
-//
-// SO_UNCONFIGURED --- SO_CONFIGURED --- SO_CONNECTING
-// ^ | |
-// | ---> SO_LISTENING |
-// | |
-// |------------------SO_DISCONNECTING<-- SO_CONNECTED
-//
-// A passive socket can only go into SO_LISTENING and
-// SO_UNCONFIGURED state. SO_XXXING state is a middle state
-// when a socket is undergoing a protocol procedure such
-// as requesting a TCP connection.
-//
-//
-//
-typedef enum {
- SO_CLOSED = 0,
- SO_LISTENING,
- SO_CONNECTING,
- SO_CONNECTED,
- SO_DISCONNECTING
-} SOCK_STATE;
-
-typedef enum {
- SO_UNCONFIGURED = 0,
- SO_CONFIGURED_ACTIVE,
- SO_CONFIGURED_PASSIVE,
- SO_NO_MAPPING
-} SOCK_CONFIGURE_STATE;
-
-#define SOCK_NO_MORE_DATA(Sock) ((Sock)->Flag |= SO_NO_MORE_DATA)
-
-#define SOCK_IS_UNCONFIGURED(Sock) ((Sock)->ConfigureState == SO_UNCONFIGURED)
-
-#define SOCK_IS_CONFIGURED(Sock) \
- (((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE) || \
- ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE))
-
-#define SOCK_IS_CONFIGURED_ACTIVE(Sock) \
- ((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE)
-
-#define SOCK_IS_CONNECTED_PASSIVE(Sock) \
- ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE)
-
-#define SOCK_IS_NO_MAPPING(Sock) \
- ((Sock)->ConfigureState == SO_NO_MAPPING)
-
-#define SOCK_IS_CLOSED(Sock) ((Sock)->State == SO_CLOSED)
-
-#define SOCK_IS_LISTENING(Sock) ((Sock)->State == SO_LISTENING)
-
-#define SOCK_IS_CONNECTING(Sock) ((Sock)->State == SO_CONNECTING)
-
-#define SOCK_IS_CONNECTED(Sock) ((Sock)->State == SO_CONNECTED)
-
-#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_SIGNATURE EFI_SIGNATURE_32 ('S', 'O', 'C', 'K')
-
-#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)
-
-#define SET_RCV_BUFFSIZE(Sock, Size) ((Sock)->RcvBuffer.HighWater = (Size))
-
-#define GET_RCV_BUFFSIZE(Sock) ((Sock)->RcvBuffer.HighWater)
-
-#define GET_RCV_DATASIZE(Sock) (((Sock)->RcvBuffer.DataQueue)->BufSize)
-
-#define SET_SND_BUFFSIZE(Sock, Size) ((Sock)->SndBuffer.HighWater = (Size))
-
-#define GET_SND_BUFFSIZE(Sock) ((Sock)->SndBuffer.HighWater)
-
-#define GET_SND_DATASIZE(Sock) (((Sock)->SndBuffer.DataQueue)->BufSize)
-
-#define SET_BACKLOG(Sock, Value) ((Sock)->BackLog = (Value))
-
-#define GET_BACKLOG(Sock) ((Sock)->BackLog)
-
-#define SOCK_ERROR(Sock, Error) ((Sock)->SockError = (Error))
-
-#define SND_BUF_HDR_LEN(Sock) \
- ((SockBufFirst (&((Sock)->SndBuffer)))->TotalSize)
-
-#define RCV_BUF_HDR_LEN(Sock) \
- ((SockBufFirst (&((Sock)->RcvBuffer)))->TotalSize)
-
-#define SOCK_FROM_TOKEN(Token) (((SOCK_TOKEN *) (Token))->Sock)
-
-#define PROTO_TOKEN_FORM_SOCK(SockToken, Type) \
- ((Type *) (((SOCK_TOKEN *) (SockToken))->Token))
-
-typedef struct _SOCKET SOCKET;
-
-typedef struct _SOCK_COMPLETION_TOKEN {
- EFI_EVENT Event;
- EFI_STATUS Status;
-} SOCK_COMPLETION_TOKEN;
-
-typedef struct _SOCK_IO_TOKEN {
- SOCK_COMPLETION_TOKEN Token;
- union {
- VOID *RxData;
- VOID *TxData;
- } Packet;
-} SOCK_IO_TOKEN;
-
-//
-// the request issued from socket layer to protocol layer
-//
-typedef enum {
- SOCK_ATTACH, // attach current socket to a new PCB
- SOCK_DETACH, // detach current socket from the PCB
- SOCK_CONFIGURE, // configure attached PCB
- SOCK_FLUSH, // flush attached PCB
- SOCK_SND, // need protocol to send something
- SOCK_SNDPUSH, // need protocol to send pushed data
- SOCK_SNDURG, // need protocol to send urgent data
- SOCK_CONSUMED, // application has retrieved data from socket
- SOCK_CONNECT, // need to connect to a peer
- SOCK_CLOSE, // need to close the protocol process
- SOCK_ABORT, // need to reset the protocol process
- SOCK_POLL, // need to poll to the protocol layer
- SOCK_ROUTE, // need to add a route information
- SOCK_MODE, // need to get the mode data of the protocol
- SOCK_GROUP // need to join a mcast group
-} SOCK_REQUEST;
-
-//
-// the socket type
-//
-typedef enum {
- SOCK_DGRAM, // this socket providing datagram service
- SOCK_STREAM // this socket providing stream service
-} SOCK_TYPE;
-
-//
-// 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
- );
-
-//
-// 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
-} SOCK_BUFFER;
-
-//
-// 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
-
- SOCK_PROTO_HANDLER ProtoHandler;
-
- EFI_HANDLE DriverBinding; // the driver binding handle
-} SOCK_INIT_DATA;
-
-//
-// socket provided oprerations for low layer protocol
-//
-
-//
-// socket provided operations for user interface
-//
-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
-//
-VOID
-SockConnEstablished (
- IN SOCKET *Sock
- );
-
-VOID
-SockConnClosed (
- IN SOCKET *Sock
- );
-
-//
-// called by low layer protocol to trim send buffer of
-// Sock, when Count data is sent out completely
-//
-VOID
-SockDataSent (
- 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
-//
-UINT32
-SockGetDataToSend (
- 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
-//
-VOID
-SockNoMoreData (
- IN SOCKET *Sock
- );
-
-//
-// called by low layer protocol to append a NetBuffer
-// to rcv buffer of sock
-//
-VOID
-SockDataRcvd (
- IN SOCKET *Sock,
- IN NET_BUF *NetBuffer,
- IN UINT32 UrgLen
- );
-
-UINT32
-SockGetFreeSpace (
- IN SOCKET *Sock,
- IN UINT32 Which
- );
-
-SOCKET *
-SockClone (
- IN SOCKET *Sock
- );
-
-VOID
-SockRcvdErr (
- IN SOCKET *Sock,
- IN EFI_STATUS Error
- );
-
-//
-// the socket structure representing a network service access point
-//
-struct _SOCKET {
-
- //
- // socket description information
- //
- UINT32 Signature;
- EFI_HANDLE SockHandle; // the virtual handle of the socket
- EFI_HANDLE DriverBinding; // socket't driver binding protocol
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- SOCK_CONFIGURE_STATE ConfigureState;
- SOCK_TYPE Type;
- SOCK_STATE State;
- UINT16 Flag;
- NET_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
- //
- 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
- NET_LIST_ENTRY ConnectionList; // the connections maintained by this socket
- //
- // the queue to buffer application's asynchronous token
- //
- NET_LIST_ENTRY ListenTokenList;
- NET_LIST_ENTRY RcvTokenList;
- NET_LIST_ENTRY SndTokenList;
- NET_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
-
- //
- // interface for low level protocol
- //
- SOCK_PROTO_HANDLER ProtoHandler; // the request handler of protocol
- UINT8 ProtoReserved[PROTO_RESERVED_LEN]; // Data fields reserved for protocol
- union {
- EFI_TCP4_PROTOCOL TcpProtocol;
- EFI_UDP4_PROTOCOL UdpProtocol;
- } NetProtocol;
-};
-
-//
-// the token structure buffered in socket layer
-//
-typedef struct _SOCK_TOKEN {
- NET_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
-//
-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
-//
-typedef struct _TCP_RSV_DATA {
- UINT32 UrgLen;
-} TCP_RSV_DATA;
-
-//
-// call it to creat a socket and attach it to a PCB
-//
-SOCKET *
-SockCreateChild (
- IN SOCK_INIT_DATA *SockInitData,
- IN VOID *ProtoData,
- IN UINT32 Len
- );
-
-//
-// call it to destroy a socket and its related PCB
-//
-EFI_STATUS
-SockDestroyChild (
- IN SOCKET *Sock
- );
-
-//
-// call it to configure a socket and its related PCB
-//
-EFI_STATUS
-SockConfigure (
- IN SOCKET *Sock,
- IN VOID *ConfigData
- );
-
-//
-// call it to connect a socket to the peer
-//
-EFI_STATUS
-SockConnect (
- IN SOCKET *Sock,
- IN VOID *Token
- );
-
-//
-// call it to issue an asynchronous listen token to the socket
-//
-EFI_STATUS
-SockAccept (
- IN SOCKET *Sock,
- IN VOID *Token
- );
-
-//
-// Call it to send data using this socket
-//
-EFI_STATUS
-SockSend (
- IN SOCKET *Sock,
- IN VOID *Token
- );
-
-//
-// Call it to receive data from this socket
-//
-EFI_STATUS
-SockRcv (
- IN SOCKET *Sock,
- IN VOID *Token
- );
-
-//
-// Call it to flush a socket
-//
-EFI_STATUS
-SockFlush (
- IN SOCKET *Sock
- );
-
-//
-// Call it to close a socket in the light of policy in Token
-//
-EFI_STATUS
-SockClose (
- IN SOCKET *Sock,
- IN VOID *Token,
- IN BOOLEAN OnAbort
- );
-
-//
-// Call it to get the mode data of low layer protocol
-//
-EFI_STATUS
-SockGetMode (
- IN SOCKET *Sock,
- IN VOID *Mode
- );
-
-//
-// call it to add this socket instance into a group
-//
-EFI_STATUS
-SockGroup (
- IN SOCKET *Sock,
- IN VOID *GroupInfo
- );
-
-//
-// call it to add a route entry for this socket instance
-//
-EFI_STATUS
-SockRoute (
- IN SOCKET *Sock,
- IN VOID *RouteInfo
- );
-
-//
-// Supporting function to operate on socket buffer
-//
-NET_BUF *
-SockBufFirst (
- IN SOCK_BUFFER *Sockbuf
- );
-
-NET_BUF *
-SockBufNext (
- IN SOCK_BUFFER *Sockbuf,
- IN NET_BUF *SockEntry
- );
-
-#endif
+#include <Library/UefiLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/BaseMemoryLib.h>
+
+#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_BACKLOG 5
+
+#define PROTO_RESERVED_LEN 20
+
+#define SO_NO_MORE_DATA 0x0001
+
+//
+//
+//
+// When a socket is created it enters into SO_UNCONFIGURED,
+// no actions can be taken on this socket, only after calling
+// SockConfigure. The state transition diagram of socket is
+// as following:
+//
+// SO_UNCONFIGURED --- SO_CONFIGURED --- SO_CONNECTING
+// ^ | |
+// | ---> SO_LISTENING |
+// | |
+// |------------------SO_DISCONNECTING<-- SO_CONNECTED
+//
+// A passive socket can only go into SO_LISTENING and
+// SO_UNCONFIGURED state. SO_XXXING state is a middle state
+// when a socket is undergoing a protocol procedure such
+// as requesting a TCP connection.
+//
+//
+//
+typedef enum {
+ SO_CLOSED = 0,
+ SO_LISTENING,
+ SO_CONNECTING,
+ SO_CONNECTED,
+ SO_DISCONNECTING
+} SOCK_STATE;
+
+typedef enum {
+ SO_UNCONFIGURED = 0,
+ SO_CONFIGURED_ACTIVE,
+ SO_CONFIGURED_PASSIVE,
+ SO_NO_MAPPING
+} SOCK_CONFIGURE_STATE;
+
+#define SOCK_NO_MORE_DATA(Sock) ((Sock)->Flag |= SO_NO_MORE_DATA)
+
+#define SOCK_IS_UNCONFIGURED(Sock) ((Sock)->ConfigureState == SO_UNCONFIGURED)
+
+#define SOCK_IS_CONFIGURED(Sock) \
+ (((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE) || \
+ ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE))
+
+#define SOCK_IS_CONFIGURED_ACTIVE(Sock) \
+ ((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE)
+
+#define SOCK_IS_CONNECTED_PASSIVE(Sock) \
+ ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE)
+
+#define SOCK_IS_NO_MAPPING(Sock) \
+ ((Sock)->ConfigureState == SO_NO_MAPPING)
+
+#define SOCK_IS_CLOSED(Sock) ((Sock)->State == SO_CLOSED)
+
+#define SOCK_IS_LISTENING(Sock) ((Sock)->State == SO_LISTENING)
+
+#define SOCK_IS_CONNECTING(Sock) ((Sock)->State == SO_CONNECTING)
+
+#define SOCK_IS_CONNECTED(Sock) ((Sock)->State == SO_CONNECTED)
+
+#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_SIGNATURE EFI_SIGNATURE_32 ('S', 'O', 'C', 'K')
+
+#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)
+
+#define SET_RCV_BUFFSIZE(Sock, Size) ((Sock)->RcvBuffer.HighWater = (Size))
+
+#define GET_RCV_BUFFSIZE(Sock) ((Sock)->RcvBuffer.HighWater)
+
+#define GET_RCV_DATASIZE(Sock) (((Sock)->RcvBuffer.DataQueue)->BufSize)
+
+#define SET_SND_BUFFSIZE(Sock, Size) ((Sock)->SndBuffer.HighWater = (Size))
+
+#define GET_SND_BUFFSIZE(Sock) ((Sock)->SndBuffer.HighWater)
+
+#define GET_SND_DATASIZE(Sock) (((Sock)->SndBuffer.DataQueue)->BufSize)
+
+#define SET_BACKLOG(Sock, Value) ((Sock)->BackLog = (Value))
+
+#define GET_BACKLOG(Sock) ((Sock)->BackLog)
+
+#define SOCK_ERROR(Sock, Error) ((Sock)->SockError = (Error))
+
+#define SND_BUF_HDR_LEN(Sock) \
+ ((SockBufFirst (&((Sock)->SndBuffer)))->TotalSize)
+
+#define RCV_BUF_HDR_LEN(Sock) \
+ ((SockBufFirst (&((Sock)->RcvBuffer)))->TotalSize)
+
+#define SOCK_FROM_TOKEN(Token) (((SOCK_TOKEN *) (Token))->Sock)
+
+#define PROTO_TOKEN_FORM_SOCK(SockToken, Type) \
+ ((Type *) (((SOCK_TOKEN *) (SockToken))->Token))
+
+typedef struct _SOCKET SOCKET;
+
+typedef struct _SOCK_COMPLETION_TOKEN {
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+} SOCK_COMPLETION_TOKEN;
+
+typedef struct _SOCK_IO_TOKEN {
+ SOCK_COMPLETION_TOKEN Token;
+ union {
+ VOID *RxData;
+ VOID *TxData;
+ } Packet;
+} SOCK_IO_TOKEN;
+
+//
+// the request issued from socket layer to protocol layer
+//
+typedef enum {
+ SOCK_ATTACH, // attach current socket to a new PCB
+ SOCK_DETACH, // detach current socket from the PCB
+ SOCK_CONFIGURE, // configure attached PCB
+ SOCK_FLUSH, // flush attached PCB
+ SOCK_SND, // need protocol to send something
+ SOCK_SNDPUSH, // need protocol to send pushed data
+ SOCK_SNDURG, // need protocol to send urgent data
+ SOCK_CONSUMED, // application has retrieved data from socket
+ SOCK_CONNECT, // need to connect to a peer
+ SOCK_CLOSE, // need to close the protocol process
+ SOCK_ABORT, // need to reset the protocol process
+ SOCK_POLL, // need to poll to the protocol layer
+ SOCK_ROUTE, // need to add a route information
+ SOCK_MODE, // need to get the mode data of the protocol
+ SOCK_GROUP // need to join a mcast group
+} SOCK_REQUEST;
+
+//
+// the socket type
+//
+typedef enum {
+ SOCK_DGRAM, // this socket providing datagram service
+ SOCK_STREAM // this socket providing stream service
+} SOCK_TYPE;
+
+//
+// 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
+ );
+
+//
+// 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
+} SOCK_BUFFER;
+
+//
+// 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
+
+ SOCK_PROTO_HANDLER ProtoHandler;
+
+ EFI_HANDLE DriverBinding; // the driver binding handle
+} SOCK_INIT_DATA;
+
+//
+// socket provided oprerations for low layer protocol
+//
+
+//
+// socket provided operations for user interface
+//
+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
+//
+VOID
+SockConnEstablished (
+ IN SOCKET *Sock
+ );
+
+VOID
+SockConnClosed (
+ IN SOCKET *Sock
+ );
+
+//
+// called by low layer protocol to trim send buffer of
+// Sock, when Count data is sent out completely
+//
+VOID
+SockDataSent (
+ 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
+//
+UINT32
+SockGetDataToSend (
+ 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
+//
+VOID
+SockNoMoreData (
+ IN SOCKET *Sock
+ );
+
+//
+// called by low layer protocol to append a NetBuffer
+// to rcv buffer of sock
+//
+VOID
+SockDataRcvd (
+ IN SOCKET *Sock,
+ IN NET_BUF *NetBuffer,
+ IN UINT32 UrgLen
+ );
+
+UINT32
+SockGetFreeSpace (
+ IN SOCKET *Sock,
+ IN UINT32 Which
+ );
+
+SOCKET *
+SockClone (
+ IN SOCKET *Sock
+ );
+
+VOID
+SockRcvdErr (
+ IN SOCKET *Sock,
+ IN EFI_STATUS Error
+ );
+
+//
+// the socket structure representing a network service access point
+//
+struct _SOCKET {
+
+ //
+ // socket description information
+ //
+ UINT32 Signature;
+ EFI_HANDLE SockHandle; // the virtual handle of the socket
+ EFI_HANDLE DriverBinding; // socket't driver binding protocol
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ SOCK_CONFIGURE_STATE ConfigureState;
+ SOCK_TYPE Type;
+ SOCK_STATE State;
+ UINT16 Flag;
+ NET_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
+ //
+ 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
+ NET_LIST_ENTRY ConnectionList; // the connections maintained by this socket
+ //
+ // the queue to buffer application's asynchronous token
+ //
+ NET_LIST_ENTRY ListenTokenList;
+ NET_LIST_ENTRY RcvTokenList;
+ NET_LIST_ENTRY SndTokenList;
+ NET_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
+
+ //
+ // interface for low level protocol
+ //
+ SOCK_PROTO_HANDLER ProtoHandler; // the request handler of protocol
+ UINT8 ProtoReserved[PROTO_RESERVED_LEN]; // Data fields reserved for protocol
+ union {
+ EFI_TCP4_PROTOCOL TcpProtocol;
+ EFI_UDP4_PROTOCOL UdpProtocol;
+ } NetProtocol;
+};
+
+//
+// the token structure buffered in socket layer
+//
+typedef struct _SOCK_TOKEN {
+ NET_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
+//
+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
+//
+typedef struct _TCP_RSV_DATA {
+ UINT32 UrgLen;
+} TCP_RSV_DATA;
+
+//
+// call it to creat a socket and attach it to a PCB
+//
+SOCKET *
+SockCreateChild (
+ IN SOCK_INIT_DATA *SockInitData,
+ IN VOID *ProtoData,
+ IN UINT32 Len
+ );
+
+//
+// call it to destroy a socket and its related PCB
+//
+EFI_STATUS
+SockDestroyChild (
+ IN SOCKET *Sock
+ );
+
+//
+// call it to configure a socket and its related PCB
+//
+EFI_STATUS
+SockConfigure (
+ IN SOCKET *Sock,
+ IN VOID *ConfigData
+ );
+
+//
+// call it to connect a socket to the peer
+//
+EFI_STATUS
+SockConnect (
+ IN SOCKET *Sock,
+ IN VOID *Token
+ );
+
+//
+// call it to issue an asynchronous listen token to the socket
+//
+EFI_STATUS
+SockAccept (
+ IN SOCKET *Sock,
+ IN VOID *Token
+ );
+
+//
+// Call it to send data using this socket
+//
+EFI_STATUS
+SockSend (
+ IN SOCKET *Sock,
+ IN VOID *Token
+ );
+
+//
+// Call it to receive data from this socket
+//
+EFI_STATUS
+SockRcv (
+ IN SOCKET *Sock,
+ IN VOID *Token
+ );
+
+//
+// Call it to flush a socket
+//
+EFI_STATUS
+SockFlush (
+ IN SOCKET *Sock
+ );
+
+//
+// Call it to close a socket in the light of policy in Token
+//
+EFI_STATUS
+SockClose (
+ IN SOCKET *Sock,
+ IN VOID *Token,
+ IN BOOLEAN OnAbort
+ );
+
+//
+// Call it to get the mode data of low layer protocol
+//
+EFI_STATUS
+SockGetMode (
+ IN SOCKET *Sock,
+ IN VOID *Mode
+ );
+
+//
+// call it to add this socket instance into a group
+//
+EFI_STATUS
+SockGroup (
+ IN SOCKET *Sock,
+ IN VOID *GroupInfo
+ );
+
+//
+// call it to add a route entry for this socket instance
+//
+EFI_STATUS
+SockRoute (
+ IN SOCKET *Sock,
+ IN VOID *RouteInfo
+ );
+
+//
+// Supporting function to operate on socket buffer
+//
+NET_BUF *
+SockBufFirst (
+ IN SOCK_BUFFER *Sockbuf
+ );
+
+NET_BUF *
+SockBufNext (
+ IN SOCK_BUFFER *Sockbuf,
+ IN NET_BUF *SockEntry
+ );
+
+#endif
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
index bbd5a30a7b..a8185b0b92 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c
@@ -22,7 +22,8 @@ Abstract:
UINT16 mTcp4RandomPort;
-extern EFI_COMPONENT_NAME_PROTOCOL gTcp4ComponentName;
+extern EFI_COMPONENT_NAME_PROTOCOL gTcp4ComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gTcp4ComponentName2;
TCP4_HEARTBEAT_TIMER mTcp4Timer = {
NULL,
@@ -176,14 +177,13 @@ Returns:
//
// Install the TCP4 Driver Binding Protocol
//
- Status = EfiLibInstallAllDriverProtocols (
+ Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&mTcp4DriverBinding,
ImageHandle,
&gTcp4ComponentName,
- NULL,
- NULL
+ &gTcp4ComponentName2
);
ASSERT_EFI_ERROR (Status);
//
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
index af3444ef58..28fe53dc5a 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
@@ -1,141 +1,141 @@
-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-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
-
-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_
-#define _TCP4_DRIVER_H_
-
-#include <Protocol/ServiceBinding.h>
-#include <Library/IpIoLib.h>
-
-#define TCP4_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('T', 'C', 'P', '4')
-
-#define TCP4_PORT_KNOWN 1024
-#define TCP4_PORT_USER_RESERVED 65535
-
-typedef struct _TCP4_HEARTBEAT_TIMER {
- EFI_EVENT TimerEvent;
- INTN RefCnt;
-} TCP4_HEARTBEAT_TIMER;
-
-typedef struct _TCP4_SERVICE_DATA {
- UINT32 Signature;
- EFI_HANDLE ControllerHandle;
- IP_IO *IpIo; // IP Io consumed by TCP4
- EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding;
- EFI_HANDLE DriverBindingHandle;
- CHAR16 *MacString;
-} TCP4_SERVICE_DATA;
-
-//
-// Prototype for TCP4 driver Rcv callback function registered to IP_IO
-//
-VOID
-Tcp4RxCallback (
- IN EFI_STATUS Status,
- IN ICMP_ERROR IcmpErr,
- IN EFI_NET_SESSION_DATA *NetSession,
- IN NET_BUF *Pkt,
- IN VOID *Context OPTIONAL
- );
-
-INTN
-TcpSendIpPacket (
- IN TCP_CB *Tcb,
- IN NET_BUF *Nbuf,
- IN UINT32 Src,
- IN UINT32 Dest
- );
-
-EFI_STATUS
-Tcp4Dispatcher (
- IN SOCKET *Sock,
- IN SOCK_REQUEST Request,
- IN VOID *Data OPTIONAL
- );
-
-typedef struct _TCP4_PROTO_DATA {
- TCP4_SERVICE_DATA *TcpService;
- TCP_CB *TcpPcb;
-} TCP4_PROTO_DATA;
-
-#define TCP4_FROM_THIS(a) \
- CR ( \
- (a), \
- TCP4_SERVICE_DATA, \
- Tcp4ServiceBinding, \
- TCP4_DRIVER_SIGNATURE \
- )
-
-//
-// Function prototype for the driver's entry point
-//
-EFI_STATUS
-EFIAPI
-Tcp4DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-//
-// Function prototypes for the Drivr Binding Protocol
-//
-EFI_STATUS
-EFIAPI
-Tcp4DriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
- );
-
-EFI_STATUS
-EFIAPI
-Tcp4DriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
- );
-
-EFI_STATUS
-EFIAPI
-Tcp4DriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// Function ptototypes for the ServiceBinding Prococol
-//
-EFI_STATUS
-EFIAPI
-Tcp4ServiceBindingCreateChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE *ChildHandle
- );
-
-EFI_STATUS
-EFIAPI
-Tcp4ServiceBindingDestroyChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE ChildHandle
- );
-
-#endif
+/** @file
+
+Copyright (c) 2005 - 2006, Intel Corporation
+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
+
+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_
+#define _TCP4_DRIVER_H_
+
+#include <Protocol/ServiceBinding.h>
+#include <Library/IpIoLib.h>
+
+#define TCP4_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('T', 'C', 'P', '4')
+
+#define TCP4_PORT_KNOWN 1024
+#define TCP4_PORT_USER_RESERVED 65535
+
+typedef struct _TCP4_HEARTBEAT_TIMER {
+ EFI_EVENT TimerEvent;
+ INTN RefCnt;
+} TCP4_HEARTBEAT_TIMER;
+
+typedef struct _TCP4_SERVICE_DATA {
+ UINT32 Signature;
+ EFI_HANDLE ControllerHandle;
+ IP_IO *IpIo; // IP Io consumed by TCP4
+ EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding;
+ EFI_HANDLE DriverBindingHandle;
+ CHAR16 *MacString;
+} TCP4_SERVICE_DATA;
+
+//
+// Prototype for TCP4 driver Rcv callback function registered to IP_IO
+//
+VOID
+Tcp4RxCallback (
+ IN EFI_STATUS Status,
+ IN ICMP_ERROR IcmpErr,
+ IN EFI_NET_SESSION_DATA *NetSession,
+ IN NET_BUF *Pkt,
+ IN VOID *Context OPTIONAL
+ );
+
+INTN
+TcpSendIpPacket (
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Nbuf,
+ IN UINT32 Src,
+ IN UINT32 Dest
+ );
+
+EFI_STATUS
+Tcp4Dispatcher (
+ IN SOCKET *Sock,
+ IN SOCK_REQUEST Request,
+ IN VOID *Data OPTIONAL
+ );
+
+typedef struct _TCP4_PROTO_DATA {
+ TCP4_SERVICE_DATA *TcpService;
+ TCP_CB *TcpPcb;
+} TCP4_PROTO_DATA;
+
+#define TCP4_FROM_THIS(a) \
+ CR ( \
+ (a), \
+ TCP4_SERVICE_DATA, \
+ Tcp4ServiceBinding, \
+ TCP4_DRIVER_SIGNATURE \
+ )
+
+//
+// Function prototype for the driver's entry point
+//
+EFI_STATUS
+EFIAPI
+Tcp4DriverEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+//
+// Function prototypes for the Drivr Binding Protocol
+//
+EFI_STATUS
+EFIAPI
+Tcp4DriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
+ );
+
+EFI_STATUS
+EFIAPI
+Tcp4DriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
+ );
+
+EFI_STATUS
+EFIAPI
+Tcp4DriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ );
+
+//
+// Function ptototypes for the ServiceBinding Prococol
+//
+EFI_STATUS
+EFIAPI
+Tcp4ServiceBindingCreateChild (
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE *ChildHandle
+ );
+
+EFI_STATUS
+EFIAPI
+Tcp4ServiceBindingDestroyChild (
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ChildHandle
+ );
+
+#endif
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
index be99f3bf47..5bfdf2612d 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h
@@ -1,358 +1,358 @@
-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-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
-
-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_
-#define _TCP4_FUNC_H_
-
-//
-// Declaration of all the functions in TCP
-// protocol. It is intended to keep tcp.h
-// clear.
-//
-
-//
-// Functions in tcp.c
-//
-BOOLEAN
-TcpFindTcbByPeer (
- IN EFI_IPv4_ADDRESS *Addr,
- IN TCP_PORTNO Port
- );
-
-TCP_CB *
-TcpLocateTcb (
- IN TCP_PORTNO LocalPort,
- IN UINT32 LocalIp,
- IN TCP_PORTNO RemotePort,
- IN UINT32 RemoteIp,
- IN BOOLEAN Syn
- );
-
-INTN
-TcpInsertTcb (
- IN TCP_CB *Tcb
- );
-
-TCP_CB *
-TcpCloneTcb (
- IN TCP_CB *Tcb
- );
-
-TCP_SEQNO
-TcpGetIss (
- VOID
- );
-
-VOID
-TcpInitTcbLocal (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpInitTcbPeer (
- IN TCP_CB *Tcb,
- IN TCP_SEG *Seg,
- IN TCP_OPTION *Opt
- );
-
-UINT16
-TcpGetRcvMss (
- IN SOCKET *Sock
- );
-
-VOID
-TcpSetState (
- IN TCP_CB *Tcb,
- IN UINT8 State
- );
-
-//
-// Functions in Tcp4Output.c
-//
-INTN
-TcpSendIpPacket (
- IN TCP_CB *Tcb,
- IN NET_BUF *Nbuf,
- IN UINT32 Src,
- IN UINT32 Dst
- );
-
-INTN
-TcpToSendData (
- IN TCP_CB *Tcb,
- IN INTN Force
- );
-
-VOID
-TcpToSendAck (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpSendAck (
- IN TCP_CB *Tcb
- );
-
-INTN
-TcpSendZeroProbe (
- IN TCP_CB *Tcb
- );
-
-INTN
-TcpDeliverData (
- IN TCP_CB *Tcb
- );
-
-INTN
-TcpSendReset (
- IN TCP_CB *Tcb,
- IN TCP_HEAD *Head,
- IN INT32 Len,
- IN UINT32 Local,
- IN UINT32 Remote
- );
-
-UINT32
-TcpRcvWinOld (
- IN TCP_CB *Tcb
- );
-
-UINT32
-TcpRcvWinNow (
- IN TCP_CB *Tcb
- );
-
-INTN
-TcpRetransmit (
- IN TCP_CB *Tcb,
- IN TCP_SEQNO Seq
- );
-
-UINT32
-TcpDataToSend (
- IN TCP_CB *Tcb,
- IN INTN Force
- );
-
-INTN
-TcpVerifySegment (
- IN NET_BUF *Nbuf
- );
-
-INTN
-TcpCheckSndQue (
- IN NET_LIST_ENTRY *Head
- );
-
-NET_BUF *
-TcpGetSegmentSndQue (
- IN TCP_CB *Tcb,
- IN TCP_SEQNO Seq,
- IN UINT32 Len
- );
-
-NET_BUF *
-TcpGetSegmentSock (
- IN TCP_CB *Tcb,
- IN TCP_SEQNO Seq,
- IN UINT32 Len
- );
-
-NET_BUF *
-TcpGetSegment (
- IN TCP_CB *Tcb,
- IN TCP_SEQNO Seq,
- IN UINT32 Len
- );
-
-TCP_SEQNO
-TcpGetMaxSndNxt (
- IN TCP_CB *Tcb
- );
-
-//
-// Functions from Tcp4Input.c
-//
-VOID
-TcpIcmpInput (
- IN NET_BUF *Nbuf,
- IN ICMP_ERROR IcmpErr,
- IN UINT32 Src,
- IN UINT32 Dst
- );
-
-INTN
-TcpInput (
- IN NET_BUF *Nbuf,
- IN UINT32 Src,
- IN UINT32 Dst
- );
-
-INTN
-TcpSeqAcceptable (
- IN TCP_CB *Tcb,
- IN TCP_SEG *Seg
- );
-
-VOID
-TcpFastRecover (
- IN TCP_CB *Tcb,
- IN TCP_SEG *Seg
- );
-
-VOID
-TcpFastLossRecover (
- IN TCP_CB *Tcb,
- IN TCP_SEG *Seg
- );
-
-VOID
-TcpComputeRtt (
- IN TCP_CB *Tcb,
- IN UINT32 Measure
- );
-
-INTN
-TcpTrimInWnd (
- IN TCP_CB *Tcb,
- IN NET_BUF *Buf
- );
-
-VOID
-TcpQueueData (
- IN TCP_CB *Tcb,
- IN NET_BUF *Nbuf
- );
-
-VOID
-TcpAdjustSndQue (
- IN TCP_CB *Tcb,
- IN TCP_SEQNO Ack
- );
-
-//
-// Functions from Tcp4Misc.c
-//
-UINT16
-TcpChecksum (
- IN NET_BUF *Buf,
- IN UINT16 HeadChecksum
- );
-
-TCP_SEG *
-TcpFormatNetbuf (
- IN TCP_CB *Tcb,
- IN NET_BUF *Nbuf
- );
-
-VOID
-TcpOnAppConnect (
- IN TCP_CB *Tcb
- );
-
-INTN
-TcpOnAppConsume (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpOnAppClose (
- IN TCP_CB *Tcb
- );
-
-INTN
-TcpOnAppSend (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpOnAppAbort (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpResetConnection (
- IN TCP_CB *Tcb
- );
-
-//
-// Functions in Tcp4Timer.c
-//
-VOID
-TcpClose (
- IN TCP_CB *Tcb
- );
-
-VOID
-EFIAPI
-TcpTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-VOID
-TcpSetTimer (
- IN TCP_CB *Tcb,
- IN UINT16 Timer,
- IN UINT32 TimeOut
- );
-
-VOID
-TcpClearTimer (
- IN TCP_CB *Tcb,
- IN UINT16 Timer
- );
-
-VOID
-TcpClearAllTimer (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpSetProbeTimer (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpSetKeepaliveTimer (
- IN TCP_CB *Tcb
- );
-
-VOID
-TcpBackoffRto (
- IN TCP_CB *Tcb
- );
-
-EFI_STATUS
-TcpSetVariableData (
- IN TCP4_SERVICE_DATA *Tcp4Service
- );
-
-VOID
-TcpClearVariableData (
- IN TCP4_SERVICE_DATA *Tcp4Service
- );
-
-EFI_STATUS
-TcpInstallDevicePath (
- IN SOCKET *Sock
- );
-
-#endif
+/** @file
+
+Copyright (c) 2005 - 2006, Intel Corporation
+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
+
+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_
+#define _TCP4_FUNC_H_
+
+//
+// Declaration of all the functions in TCP
+// protocol. It is intended to keep tcp.h
+// clear.
+//
+
+//
+// Functions in tcp.c
+//
+BOOLEAN
+TcpFindTcbByPeer (
+ IN EFI_IPv4_ADDRESS *Addr,
+ IN TCP_PORTNO Port
+ );
+
+TCP_CB *
+TcpLocateTcb (
+ IN TCP_PORTNO LocalPort,
+ IN UINT32 LocalIp,
+ IN TCP_PORTNO RemotePort,
+ IN UINT32 RemoteIp,
+ IN BOOLEAN Syn
+ );
+
+INTN
+TcpInsertTcb (
+ IN TCP_CB *Tcb
+ );
+
+TCP_CB *
+TcpCloneTcb (
+ IN TCP_CB *Tcb
+ );
+
+TCP_SEQNO
+TcpGetIss (
+ VOID
+ );
+
+VOID
+TcpInitTcbLocal (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpInitTcbPeer (
+ IN TCP_CB *Tcb,
+ IN TCP_SEG *Seg,
+ IN TCP_OPTION *Opt
+ );
+
+UINT16
+TcpGetRcvMss (
+ IN SOCKET *Sock
+ );
+
+VOID
+TcpSetState (
+ IN TCP_CB *Tcb,
+ IN UINT8 State
+ );
+
+//
+// Functions in Tcp4Output.c
+//
+INTN
+TcpSendIpPacket (
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Nbuf,
+ IN UINT32 Src,
+ IN UINT32 Dst
+ );
+
+INTN
+TcpToSendData (
+ IN TCP_CB *Tcb,
+ IN INTN Force
+ );
+
+VOID
+TcpToSendAck (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpSendAck (
+ IN TCP_CB *Tcb
+ );
+
+INTN
+TcpSendZeroProbe (
+ IN TCP_CB *Tcb
+ );
+
+INTN
+TcpDeliverData (
+ IN TCP_CB *Tcb
+ );
+
+INTN
+TcpSendReset (
+ IN TCP_CB *Tcb,
+ IN TCP_HEAD *Head,
+ IN INT32 Len,
+ IN UINT32 Local,
+ IN UINT32 Remote
+ );
+
+UINT32
+TcpRcvWinOld (
+ IN TCP_CB *Tcb
+ );
+
+UINT32
+TcpRcvWinNow (
+ IN TCP_CB *Tcb
+ );
+
+INTN
+TcpRetransmit (
+ IN TCP_CB *Tcb,
+ IN TCP_SEQNO Seq
+ );
+
+UINT32
+TcpDataToSend (
+ IN TCP_CB *Tcb,
+ IN INTN Force
+ );
+
+INTN
+TcpVerifySegment (
+ IN NET_BUF *Nbuf
+ );
+
+INTN
+TcpCheckSndQue (
+ IN NET_LIST_ENTRY *Head
+ );
+
+NET_BUF *
+TcpGetSegmentSndQue (
+ IN TCP_CB *Tcb,
+ IN TCP_SEQNO Seq,
+ IN UINT32 Len
+ );
+
+NET_BUF *
+TcpGetSegmentSock (
+ IN TCP_CB *Tcb,
+ IN TCP_SEQNO Seq,
+ IN UINT32 Len
+ );
+
+NET_BUF *
+TcpGetSegment (
+ IN TCP_CB *Tcb,
+ IN TCP_SEQNO Seq,
+ IN UINT32 Len
+ );
+
+TCP_SEQNO
+TcpGetMaxSndNxt (
+ IN TCP_CB *Tcb
+ );
+
+//
+// Functions from Tcp4Input.c
+//
+VOID
+TcpIcmpInput (
+ IN NET_BUF *Nbuf,
+ IN ICMP_ERROR IcmpErr,
+ IN UINT32 Src,
+ IN UINT32 Dst
+ );
+
+INTN
+TcpInput (
+ IN NET_BUF *Nbuf,
+ IN UINT32 Src,
+ IN UINT32 Dst
+ );
+
+INTN
+TcpSeqAcceptable (
+ IN TCP_CB *Tcb,
+ IN TCP_SEG *Seg
+ );
+
+VOID
+TcpFastRecover (
+ IN TCP_CB *Tcb,
+ IN TCP_SEG *Seg
+ );
+
+VOID
+TcpFastLossRecover (
+ IN TCP_CB *Tcb,
+ IN TCP_SEG *Seg
+ );
+
+VOID
+TcpComputeRtt (
+ IN TCP_CB *Tcb,
+ IN UINT32 Measure
+ );
+
+INTN
+TcpTrimInWnd (
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Buf
+ );
+
+VOID
+TcpQueueData (
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Nbuf
+ );
+
+VOID
+TcpAdjustSndQue (
+ IN TCP_CB *Tcb,
+ IN TCP_SEQNO Ack
+ );
+
+//
+// Functions from Tcp4Misc.c
+//
+UINT16
+TcpChecksum (
+ IN NET_BUF *Buf,
+ IN UINT16 HeadChecksum
+ );
+
+TCP_SEG *
+TcpFormatNetbuf (
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Nbuf
+ );
+
+VOID
+TcpOnAppConnect (
+ IN TCP_CB *Tcb
+ );
+
+INTN
+TcpOnAppConsume (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpOnAppClose (
+ IN TCP_CB *Tcb
+ );
+
+INTN
+TcpOnAppSend (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpOnAppAbort (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpResetConnection (
+ IN TCP_CB *Tcb
+ );
+
+//
+// Functions in Tcp4Timer.c
+//
+VOID
+TcpClose (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+EFIAPI
+TcpTicking (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+VOID
+TcpSetTimer (
+ IN TCP_CB *Tcb,
+ IN UINT16 Timer,
+ IN UINT32 TimeOut
+ );
+
+VOID
+TcpClearTimer (
+ IN TCP_CB *Tcb,
+ IN UINT16 Timer
+ );
+
+VOID
+TcpClearAllTimer (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpSetProbeTimer (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpSetKeepaliveTimer (
+ IN TCP_CB *Tcb
+ );
+
+VOID
+TcpBackoffRto (
+ IN TCP_CB *Tcb
+ );
+
+EFI_STATUS
+TcpSetVariableData (
+ IN TCP4_SERVICE_DATA *Tcp4Service
+ );
+
+VOID
+TcpClearVariableData (
+ IN TCP4_SERVICE_DATA *Tcp4Service
+ );
+
+EFI_STATUS
+TcpInstallDevicePath (
+ IN SOCKET *Sock
+ );
+
+#endif
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
index 3e6575be92..3e0b9db498 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h
@@ -1,175 +1,175 @@
-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-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
-
-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_
-#define _TCP4_MAIN_H_
-
-#include "Socket.h"
-
-#include "Tcp4Proto.h"
-#include "Tcp4Driver.h"
-
-
-extern UINT16 mTcp4RandomPort;
-
-//
-// Driver Produced Protocol Prototypes
-//
-
-#define TCP4_DEBUG_ERROR(PrintArg) NET_DEBUG_ERROR ("Tcp", PrintArg)
-#define TCP4_DEBUG_WARN(PrintArg) NET_DEBUG_WARNING ("Tcp", PrintArg)
-#define TCP4_DEBUG_TRACE(PrintArg) NET_DEBUG_TRACE ("Tcp", PrintArg)
-
-//
-// Function prototype for the Tcp4 socket request handler
-//
-EFI_STATUS
-Tcp4Dispatcher (
- IN SOCKET *Sock,
- IN SOCK_REQUEST Request,
- IN VOID *Data OPTIONAL
- );
-
-typedef struct _TCP4_MODE_DATA {
- EFI_TCP4_CONNECTION_STATE *Tcp4State;
- EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;
- EFI_IP4_MODE_DATA *Ip4ModeData;
- EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
- EFI_SIMPLE_NETWORK_MODE *SnpModeData;
-} TCP4_MODE_DATA;
-
-typedef struct _TCP4_ROUTE_INFO {
- BOOLEAN DeleteRoute;
- EFI_IPv4_ADDRESS *SubnetAddress;
- EFI_IPv4_ADDRESS *SubnetMask;
- EFI_IPv4_ADDRESS *GatewayAddress;
-} TCP4_ROUTE_INFO;
-
-//
-// Get the mode data of a TCP instance
-//
-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
- );
-
-//
-// Initialize or reset a TCP instance
-//
-EFI_STATUS
-EFIAPI
-Tcp4Configure (
- IN EFI_TCP4_PROTOCOL * This,
- IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL
- );
-
-//
-// Add a route entry to the route table
-//
-EFI_STATUS
-EFIAPI
-Tcp4Routes (
- IN EFI_TCP4_PROTOCOL *This,
- IN BOOLEAN DeleteRoute,
- IN EFI_IPv4_ADDRESS *SubnetAddress,
- IN EFI_IPv4_ADDRESS *SubnetMask,
- IN EFI_IPv4_ADDRESS *GatewayAddress
- );
-
-//
-// Issue an asynchronous connection establishment
-// request to the peer
-//
-EFI_STATUS
-EFIAPI
-Tcp4Connect (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
- );
-
-//
-// Issue an asynchronous listent token to accept an
-// incoming connection reques
-//
-EFI_STATUS
-EFIAPI
-Tcp4Accept (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_LISTEN_TOKEN *ListenToken
- );
-
-//
-// Issue an asynchronous IO token to transmit some data
-// through this TCP instance
-//
-EFI_STATUS
-EFIAPI
-Tcp4Transmit (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_IO_TOKEN *Token
- );
-
-//
-// Issue an asynchronous IO token to receive some data
-// through this TCP instance
-//
-EFI_STATUS
-Tcp4Receive (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_IO_TOKEN *Token
- );
-
-//
-// Issue an asynchronous CloseToken to close a TCP
-// connection represented by instance
-//
-EFI_STATUS
-EFIAPI
-Tcp4Close (
- IN EFI_TCP4_PROTOCOL *This,
- IN EFI_TCP4_CLOSE_TOKEN *CloseToken
- );
-
-//
-// cancle an connect, listent or IO token
-//
-EFI_STATUS
-EFIAPI
-Tcp4Cancel (
- IN EFI_TCP4_PROTOCOL * This,
- IN EFI_TCP4_COMPLETION_TOKEN * Token OPTIONAL
- );
-
-//
-// poll data from NIC for receive
-//
-EFI_STATUS
-EFIAPI
-Tcp4Poll (
- IN EFI_TCP4_PROTOCOL *This
- );
-
-#endif
+/** @file
+
+Copyright (c) 2005 - 2006, Intel Corporation
+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
+
+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_
+#define _TCP4_MAIN_H_
+
+#include "Socket.h"
+
+#include "Tcp4Proto.h"
+#include "Tcp4Driver.h"
+
+
+extern UINT16 mTcp4RandomPort;
+
+//
+// Driver Produced Protocol Prototypes
+//
+
+#define TCP4_DEBUG_ERROR(PrintArg) NET_DEBUG_ERROR ("Tcp", PrintArg)
+#define TCP4_DEBUG_WARN(PrintArg) NET_DEBUG_WARNING ("Tcp", PrintArg)
+#define TCP4_DEBUG_TRACE(PrintArg) NET_DEBUG_TRACE ("Tcp", PrintArg)
+
+//
+// Function prototype for the Tcp4 socket request handler
+//
+EFI_STATUS
+Tcp4Dispatcher (
+ IN SOCKET *Sock,
+ IN SOCK_REQUEST Request,
+ IN VOID *Data OPTIONAL
+ );
+
+typedef struct _TCP4_MODE_DATA {
+ EFI_TCP4_CONNECTION_STATE *Tcp4State;
+ EFI_TCP4_CONFIG_DATA *Tcp4ConfigData;
+ EFI_IP4_MODE_DATA *Ip4ModeData;
+ EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData;
+ EFI_SIMPLE_NETWORK_MODE *SnpModeData;
+} TCP4_MODE_DATA;
+
+typedef struct _TCP4_ROUTE_INFO {
+ BOOLEAN DeleteRoute;
+ EFI_IPv4_ADDRESS *SubnetAddress;
+ EFI_IPv4_ADDRESS *SubnetMask;
+ EFI_IPv4_ADDRESS *GatewayAddress;
+} TCP4_ROUTE_INFO;
+
+//
+// Get the mode data of a TCP instance
+//
+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
+ );
+
+//
+// Initialize or reset a TCP instance
+//
+EFI_STATUS
+EFIAPI
+Tcp4Configure (
+ IN EFI_TCP4_PROTOCOL * This,
+ IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL
+ );
+
+//
+// Add a route entry to the route table
+//
+EFI_STATUS
+EFIAPI
+Tcp4Routes (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv4_ADDRESS *SubnetAddress,
+ IN EFI_IPv4_ADDRESS *SubnetMask,
+ IN EFI_IPv4_ADDRESS *GatewayAddress
+ );
+
+//
+// Issue an asynchronous connection establishment
+// request to the peer
+//
+EFI_STATUS
+EFIAPI
+Tcp4Connect (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
+ );
+
+//
+// Issue an asynchronous listent token to accept an
+// incoming connection reques
+//
+EFI_STATUS
+EFIAPI
+Tcp4Accept (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_LISTEN_TOKEN *ListenToken
+ );
+
+//
+// Issue an asynchronous IO token to transmit some data
+// through this TCP instance
+//
+EFI_STATUS
+EFIAPI
+Tcp4Transmit (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_IO_TOKEN *Token
+ );
+
+//
+// Issue an asynchronous IO token to receive some data
+// through this TCP instance
+//
+EFI_STATUS
+Tcp4Receive (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_IO_TOKEN *Token
+ );
+
+//
+// Issue an asynchronous CloseToken to close a TCP
+// connection represented by instance
+//
+EFI_STATUS
+EFIAPI
+Tcp4Close (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CLOSE_TOKEN *CloseToken
+ );
+
+//
+// cancle an connect, listent or IO token
+//
+EFI_STATUS
+EFIAPI
+Tcp4Cancel (
+ IN EFI_TCP4_PROTOCOL * This,
+ IN EFI_TCP4_COMPLETION_TOKEN * Token OPTIONAL
+ );
+
+//
+// poll data from NIC for receive
+//
+EFI_STATUS
+EFIAPI
+Tcp4Poll (
+ IN EFI_TCP4_PROTOCOL *This
+ );
+
+#endif
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
index cae0e885cf..ad856c777a 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
@@ -1,107 +1,107 @@
-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-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
-
-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
-} TCP_OPTION;
-
-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
-
- //
- // recommend format of timestamp window scale
- // option for fast process.
- //
- TCP_OPTION_TS_FAST = ((TCP_OPTION_NOP << 24) |
- (TCP_OPTION_NOP << 16) |
- (TCP_OPTION_TS << 8) |
- TCP_OPTION_TS_LEN),
-
- TCP_OPTION_WS_FAST = ((TCP_OPTION_NOP << 24) |
- (TCP_OPTION_WS << 16) |
- (TCP_OPTION_WS_LEN << 8)),
-
- TCP_OPTION_MSS_FAST = ((TCP_OPTION_MSS << 24) |
- (TCP_OPTION_MSS_LEN << 16)),
-
- //
- // Other misc definations
- //
- TCP_OPTION_MAX_WS = 14, // Maxium window scale value
- TCP_OPTION_MAX_WIN = 0xffff, // max window size in TCP header
- TCP_OPTION_RCVD_MSS = 0x01,
- TCP_OPTION_RCVD_WS = 0x02,
- TCP_OPTION_RCVD_TS = 0x04
-};
-
-UINT8
-TcpComputeScale (
- IN TCP_CB *Tcb
- );
-
-UINT16
-TcpSynBuildOption (
- IN TCP_CB *Tcb,
- IN NET_BUF *Buf
- );
-
-UINT16
-TcpBuildOption (
- IN TCP_CB *Tcb,
- IN NET_BUF *Buf
- );
-
-INTN
-TcpParseOption (
- IN TCP_HEAD *Tcp,
- IN TCP_OPTION *Option
- );
-
-UINT32
-TcpPawsOK (
- IN TCP_CB *Tcb,
- IN UINT32 TSVal
- );
-
-#endif
+/** @file
+
+Copyright (c) 2005 - 2006, Intel Corporation
+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
+
+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
+} TCP_OPTION;
+
+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
+
+ //
+ // recommend format of timestamp window scale
+ // option for fast process.
+ //
+ TCP_OPTION_TS_FAST = ((TCP_OPTION_NOP << 24) |
+ (TCP_OPTION_NOP << 16) |
+ (TCP_OPTION_TS << 8) |
+ TCP_OPTION_TS_LEN),
+
+ TCP_OPTION_WS_FAST = ((TCP_OPTION_NOP << 24) |
+ (TCP_OPTION_WS << 16) |
+ (TCP_OPTION_WS_LEN << 8)),
+
+ TCP_OPTION_MSS_FAST = ((TCP_OPTION_MSS << 24) |
+ (TCP_OPTION_MSS_LEN << 16)),
+
+ //
+ // Other misc definations
+ //
+ TCP_OPTION_MAX_WS = 14, // Maxium window scale value
+ TCP_OPTION_MAX_WIN = 0xffff, // max window size in TCP header
+ TCP_OPTION_RCVD_MSS = 0x01,
+ TCP_OPTION_RCVD_WS = 0x02,
+ TCP_OPTION_RCVD_TS = 0x04
+};
+
+UINT8
+TcpComputeScale (
+ IN TCP_CB *Tcb
+ );
+
+UINT16
+TcpSynBuildOption (
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Buf
+ );
+
+UINT16
+TcpBuildOption (
+ IN TCP_CB *Tcb,
+ IN NET_BUF *Buf
+ );
+
+INTN
+TcpParseOption (
+ IN TCP_HEAD *Tcp,
+ IN TCP_OPTION *Option
+ );
+
+UINT32
+TcpPawsOK (
+ IN TCP_CB *Tcb,
+ IN UINT32 TSVal
+ );
+
+#endif
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
index a35a51b3cc..cfefdf2ea3 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h
@@ -1,355 +1,355 @@
-/** @file
-
-Copyright (c) 2005 - 2006, Intel Corporation
-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
-
-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_
-#define _TCP4_PROTO_H_
-
-typedef struct _TCP_CB TCP_CB;
-
-#include "Tcp4Driver.h"
-#include "Socket.h"
-#include "Tcp4Option.h"
-
-//
-// tcp states, Don't change their order, it is used as
-// index to mTcpOutFlag and other macros
-//
-enum {
- TCP_CLOSED = 0,
- TCP_LISTEN,
- TCP_SYN_SENT,
- TCP_SYN_RCVD,
- TCP_ESTABLISHED,
- TCP_FIN_WAIT_1,
- TCP_FIN_WAIT_2,
- TCP_CLOSING,
- TCP_TIME_WAIT,
- TCP_CLOSE_WAIT,
- TCP_LAST_ACK
-};
-
-//
-// flags in the TCP header
-//
-enum {
-
- TCP_FLG_FIN = 0x01,
- TCP_FLG_SYN = 0x02,
- TCP_FLG_RST = 0x04,
- TCP_FLG_PSH = 0x08,
- TCP_FLG_ACK = 0x10,
- TCP_FLG_URG = 0x20,
- TCP_FLG_FLAG = 0x3F // mask for all the flags
-};
-
-enum {
-
- //
- // TCP error status
- //
- TCP_CONNECT_REFUSED = -1,
- TCP_CONNECT_RESET = -2,
- TCP_CONNECT_CLOSED = -3,
-
- //
- // Current congestion status as suggested by RFC3782.
- //
- TCP_CONGEST_RECOVER = 1, // during the NewReno fast recovery
- TCP_CONGEST_LOSS = 2, // retxmit because of retxmit time out
- TCP_CONGEST_OPEN = 3, // TCP is opening its congestion window
-
- //
- // TCP control flags
- //
- 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
-
- //
- // Timer related values
- //
- TCP_TIMER_CONNECT = 0, // Connection establishment timer
- TCP_TIMER_REXMIT = 1, // retransmit timer
- TCP_TIMER_PROBE = 2, // Window probe timer
- TCP_TIMER_KEEPALIVE = 3, // Keepalive timer
- TCP_TIMER_FINWAIT2 = 4, // FIN_WAIT_2 timer
- TCP_TIMER_2MSL = 5, // TIME_WAIT tiemr
- TCP_TIMER_NUMBER = 6, // the total number of TCP timer.
- TCP_TICK = 200, // every TCP tick is 200ms
- TCP_TICK_HZ = 5, // the frequence of TCP tick
- TCP_RTT_SHIFT = 3, // SRTT & RTTVAR scaled by 8
- TCP_RTO_MIN = TCP_TICK_HZ, // the minium value of RTO
- TCP_RTO_MAX = TCP_TICK_HZ *60, // the maxium value of RTO
- TCP_FOLD_RTT = 4, // timeout threshod to fold RTT
-
- //
- // default values for some timers
- //
- 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,
-
- //
- // The header space to be reserved before TCP data to accomodate :
- // 60byte IP head + 60byte TCP head + link layer head
- //
- TCP_MAX_HEAD = 192,
-
- //
- // value ranges for some control option
- //
- TCP_RCV_BUF_SIZE = 2 *1024 *1024,
- TCP_RCV_BUF_SIZE_MIN = 8 *1024,
- TCP_SND_BUF_SIZE = 2 *1024 *1024,
- TCP_SND_BUF_SIZE_MIN = 8 *1024,
- TCP_BACKLOG = 10,
- TCP_BACKLOG_MIN = 5,
- TCP_MAX_LOSS_MIN = 6,
- TCP_CONNECT_TIME_MIN = 60 *TCP_TICK_HZ,
- TCP_MAX_KEEPALIVE_MIN = 4,
- TCP_KEEPALIVE_IDLE_MAX = TCP_TICK_HZ *60 *60 *4,
- TCP_KEEPALIVE_PERIOD_MIN= TCP_TICK_HZ *30,
- TCP_FIN_WAIT2_TIME_MAX = 4 *TCP_TICK_HZ,
- TCP_TIME_WAIT_TIME_MAX = 60 *TCP_TICK_HZ
-};
-
-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_SEG;
-
-typedef struct _TCP_PEER {
- UINT32 Ip; // Network byte order
- TCP_PORTNO Port; // Network byte order
-} TCP_PEER;
-
-//
-// tcp control block, it includes various states
-//
-struct _TCP_CB {
- NET_LIST_ENTRY List;
- TCP_CB *Parent;
-
- SOCKET *Sk;
- TCP_PEER LocalEnd;
- TCP_PEER RemoteEnd;
-
- NET_LIST_ENTRY SndQue; // retxmission queue
- NET_LIST_ENTRY RcvQue; // reassemble queue
- UINT32 CtrlFlag; // control flags, such as NO_NAGLE
- INT32 Error; // soft error status,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
-
- //
- // 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
-
- //
- // 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
-
- //
- // 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
-
- //
- // 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;
-
- //
- // configuration for tcp provided by user
- //
- BOOLEAN UseDefaultAddr;
- UINT8 TOS;
- UINT8 TTL;
- EFI_IPv4_ADDRESS SubnetMask;
-
- //
- // pointer reference to Ip used to send pkt
- //
- IP_IO_IP_INFO *IpInfo;
-};
-
-extern NET_LIST_ENTRY mTcpRunQue;
-extern NET_LIST_ENTRY mTcpListenQue;
-extern TCP_SEQNO mTcpGlobalIss;
-extern UINT32 mTcpTick;
-
-//
-// TCP_CONNECTED: both ends have synchronized their ISN.
-//
-#define TCP_CONNECTED(state) ((state) > TCP_SYN_RCVD)
-
-#define TCP_FIN_RCVD(State) \
- (((State) == TCP_CLOSE_WAIT) || \
- ((State) == TCP_LAST_ACK) || \
- ((State) == TCP_CLOSING) || \
- ((State) == TCP_TIME_WAIT))
-
-#define TCP_LOCAL_CLOSED(State) \
- (((State) == TCP_FIN_WAIT_1) || \
- ((State) == TCP_FIN_WAIT_2) || \
- ((State) == TCP_CLOSING) || \
- ((State) == TCP_TIME_WAIT) || \
- ((State) == TCP_LAST_ACK))
-
-//
-// Get the TCP_SEG point from a net buffer's ProtoData
-//
-#define TCPSEG_NETBUF(NBuf) ((TCP_SEG *) ((NBuf)->ProtoData))
-
-//
-// macros to compare sequence no
-//
-#define TCP_SEQ_LT(SeqA, SeqB) ((INT32) ((SeqA) - (SeqB)) < 0)
-#define TCP_SEQ_LEQ(SeqA, SeqB) ((INT32) ((SeqA) - (SeqB)) <= 0)
-#define TCP_SEQ_GT(SeqA, SeqB) ((INT32) ((SeqB) - (SeqA)) < 0)
-#define TCP_SEQ_GEQ(SeqA, SeqB) ((INT32) ((SeqB) - (SeqA)) <= 0)
-
-//
-// TCP_SEQ_BETWEEN return whether b <= m <= e
-//
-#define TCP_SEQ_BETWEEN(b, m, e) ((e) - (b) >= (m) - (b))
-
-//
-// TCP_SUB_SEQ returns Seq1 - Seq2. Make sure Seq1 >= Seq2
-//
-#define TCP_SUB_SEQ(Seq1, Seq2) ((UINT32) ((Seq1) - (Seq2)))
-
-#define TCP_FLG_ON(Value, Flag) ((BOOLEAN) (((Value) & (Flag)) != 0))
-#define TCP_SET_FLG(Value, Flag) ((Value) |= (Flag))
-#define TCP_CLEAR_FLG(Value, Flag) ((Value) &= ~(Flag))
-
-//
-// test whether two peers are equal
-//
-#define TCP_PEER_EQUAL(Pa, Pb) \
- (((Pa)->Ip == (Pb)->Ip) && ((Pa)->Port == (Pb)->Port))
-
-//
-// test whether Pa matches Pb, or Pa is more specific
-// than pb. Zero means wildcard.
-//
-#define TCP_PEER_MATCH(Pa, Pb) \
- ((((Pb)->Ip == 0) || ((Pb)->Ip == (Pa)->Ip)) && \
- (((Pb)->Port == 0) || ((Pb)->Port == (Pa)->Port)))
-
-#define TCP_TIMER_ON(Flag, Timer) ((Flag) & (1 << (Timer)))
-#define TCP_SET_TIMER(Flag, Timer) ((Flag) = (UINT16) ((Flag) | (1 << (Timer))))
-#define TCP_CLEAR_TIMER(Flag, Timer) ((Flag) = (UINT16) ((Flag) & (~(1 << (Timer)))))
-
-#define TCP_TIME_LT(Ta, Tb) ((INT32) ((Ta) - (Tb)) < 0)
-#define TCP_TIME_LEQ(Ta, Tb) ((INT32) ((Ta) - (Tb)) <= 0)
-#define TCP_SUB_TIME(Ta, Tb) ((UINT32) ((Ta) - (Tb)))
-
-#define TCP_MAX_WIN 0xFFFFU
-
-typedef
-VOID
-(*TCP_TIMER_HANDLER) (
- IN TCP_CB * Tcb
- );
-
-#include "Tcp4Func.h"
-#endif
+/** @file
+
+Copyright (c) 2005 - 2006, Intel Corporation
+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
+
+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_
+#define _TCP4_PROTO_H_
+
+typedef struct _TCP_CB TCP_CB;
+
+#include "Tcp4Driver.h"
+#include "Socket.h"
+#include "Tcp4Option.h"
+
+//
+// tcp states, Don't change their order, it is used as
+// index to mTcpOutFlag and other macros
+//
+enum {
+ TCP_CLOSED = 0,
+ TCP_LISTEN,
+ TCP_SYN_SENT,
+ TCP_SYN_RCVD,
+ TCP_ESTABLISHED,
+ TCP_FIN_WAIT_1,
+ TCP_FIN_WAIT_2,
+ TCP_CLOSING,
+ TCP_TIME_WAIT,
+ TCP_CLOSE_WAIT,
+ TCP_LAST_ACK
+};
+
+//
+// flags in the TCP header
+//
+enum {
+
+ TCP_FLG_FIN = 0x01,
+ TCP_FLG_SYN = 0x02,
+ TCP_FLG_RST = 0x04,
+ TCP_FLG_PSH = 0x08,
+ TCP_FLG_ACK = 0x10,
+ TCP_FLG_URG = 0x20,
+ TCP_FLG_FLAG = 0x3F // mask for all the flags
+};
+
+enum {
+
+ //
+ // TCP error status
+ //
+ TCP_CONNECT_REFUSED = -1,
+ TCP_CONNECT_RESET = -2,
+ TCP_CONNECT_CLOSED = -3,
+
+ //
+ // Current congestion status as suggested by RFC3782.
+ //
+ TCP_CONGEST_RECOVER = 1, // during the NewReno fast recovery
+ TCP_CONGEST_LOSS = 2, // retxmit because of retxmit time out
+ TCP_CONGEST_OPEN = 3, // TCP is opening its congestion window
+
+ //
+ // TCP control flags
+ //
+ 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
+
+ //
+ // Timer related values
+ //
+ TCP_TIMER_CONNECT = 0, // Connection establishment timer
+ TCP_TIMER_REXMIT = 1, // retransmit timer
+ TCP_TIMER_PROBE = 2, // Window probe timer
+ TCP_TIMER_KEEPALIVE = 3, // Keepalive timer
+ TCP_TIMER_FINWAIT2 = 4, // FIN_WAIT_2 timer
+ TCP_TIMER_2MSL = 5, // TIME_WAIT tiemr
+ TCP_TIMER_NUMBER = 6, // the total number of TCP timer.
+ TCP_TICK = 200, // every TCP tick is 200ms
+ TCP_TICK_HZ = 5, // the frequence of TCP tick
+ TCP_RTT_SHIFT = 3, // SRTT & RTTVAR scaled by 8
+ TCP_RTO_MIN = TCP_TICK_HZ, // the minium value of RTO
+ TCP_RTO_MAX = TCP_TICK_HZ *60, // the maxium value of RTO
+ TCP_FOLD_RTT = 4, // timeout threshod to fold RTT
+
+ //
+ // default values for some timers
+ //
+ 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,
+
+ //
+ // The header space to be reserved before TCP data to accomodate :
+ // 60byte IP head + 60byte TCP head + link layer head
+ //
+ TCP_MAX_HEAD = 192,
+
+ //
+ // value ranges for some control option
+ //
+ TCP_RCV_BUF_SIZE = 2 *1024 *1024,
+ TCP_RCV_BUF_SIZE_MIN = 8 *1024,
+ TCP_SND_BUF_SIZE = 2 *1024 *1024,
+ TCP_SND_BUF_SIZE_MIN = 8 *1024,
+ TCP_BACKLOG = 10,
+ TCP_BACKLOG_MIN = 5,
+ TCP_MAX_LOSS_MIN = 6,
+ TCP_CONNECT_TIME_MIN = 60 *TCP_TICK_HZ,
+ TCP_MAX_KEEPALIVE_MIN = 4,
+ TCP_KEEPALIVE_IDLE_MAX = TCP_TICK_HZ *60 *60 *4,
+ TCP_KEEPALIVE_PERIOD_MIN= TCP_TICK_HZ *30,
+ TCP_FIN_WAIT2_TIME_MAX = 4 *TCP_TICK_HZ,
+ TCP_TIME_WAIT_TIME_MAX = 60 *TCP_TICK_HZ
+};
+
+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_SEG;
+
+typedef struct _TCP_PEER {
+ UINT32 Ip; // Network byte order
+ TCP_PORTNO Port; // Network byte order
+} TCP_PEER;
+
+//
+// tcp control block, it includes various states
+//
+struct _TCP_CB {
+ NET_LIST_ENTRY List;
+ TCP_CB *Parent;
+
+ SOCKET *Sk;
+ TCP_PEER LocalEnd;
+ TCP_PEER RemoteEnd;
+
+ NET_LIST_ENTRY SndQue; // retxmission queue
+ NET_LIST_ENTRY RcvQue; // reassemble queue
+ UINT32 CtrlFlag; // control flags, such as NO_NAGLE
+ INT32 Error; // soft error status,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
+
+ //
+ // 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
+
+ //
+ // 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
+
+ //
+ // 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
+
+ //
+ // 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;
+
+ //
+ // configuration for tcp provided by user
+ //
+ BOOLEAN UseDefaultAddr;
+ UINT8 TOS;
+ UINT8 TTL;
+ EFI_IPv4_ADDRESS SubnetMask;
+
+ //
+ // pointer reference to Ip used to send pkt
+ //
+ IP_IO_IP_INFO *IpInfo;
+};
+
+extern NET_LIST_ENTRY mTcpRunQue;
+extern NET_LIST_ENTRY mTcpListenQue;
+extern TCP_SEQNO mTcpGlobalIss;
+extern UINT32 mTcpTick;
+
+//
+// TCP_CONNECTED: both ends have synchronized their ISN.
+//
+#define TCP_CONNECTED(state) ((state) > TCP_SYN_RCVD)
+
+#define TCP_FIN_RCVD(State) \
+ (((State) == TCP_CLOSE_WAIT) || \
+ ((State) == TCP_LAST_ACK) || \
+ ((State) == TCP_CLOSING) || \
+ ((State) == TCP_TIME_WAIT))
+
+#define TCP_LOCAL_CLOSED(State) \
+ (((State) == TCP_FIN_WAIT_1) || \
+ ((State) == TCP_FIN_WAIT_2) || \
+ ((State) == TCP_CLOSING) || \
+ ((State) == TCP_TIME_WAIT) || \
+ ((State) == TCP_LAST_ACK))
+
+//
+// Get the TCP_SEG point from a net buffer's ProtoData
+//
+#define TCPSEG_NETBUF(NBuf) ((TCP_SEG *) ((NBuf)->ProtoData))
+
+//
+// macros to compare sequence no
+//
+#define TCP_SEQ_LT(SeqA, SeqB) ((INT32) ((SeqA) - (SeqB)) < 0)
+#define TCP_SEQ_LEQ(SeqA, SeqB) ((INT32) ((SeqA) - (SeqB)) <= 0)
+#define TCP_SEQ_GT(SeqA, SeqB) ((INT32) ((SeqB) - (SeqA)) < 0)
+#define TCP_SEQ_GEQ(SeqA, SeqB) ((INT32) ((SeqB) - (SeqA)) <= 0)
+
+//
+// TCP_SEQ_BETWEEN return whether b <= m <= e
+//
+#define TCP_SEQ_BETWEEN(b, m, e) ((e) - (b) >= (m) - (b))
+
+//
+// TCP_SUB_SEQ returns Seq1 - Seq2. Make sure Seq1 >= Seq2
+//
+#define TCP_SUB_SEQ(Seq1, Seq2) ((UINT32) ((Seq1) - (Seq2)))
+
+#define TCP_FLG_ON(Value, Flag) ((BOOLEAN) (((Value) & (Flag)) != 0))
+#define TCP_SET_FLG(Value, Flag) ((Value) |= (Flag))
+#define TCP_CLEAR_FLG(Value, Flag) ((Value) &= ~(Flag))
+
+//
+// test whether two peers are equal
+//
+#define TCP_PEER_EQUAL(Pa, Pb) \
+ (((Pa)->Ip == (Pb)->Ip) && ((Pa)->Port == (Pb)->Port))
+
+//
+// test whether Pa matches Pb, or Pa is more specific
+// than pb. Zero means wildcard.
+//
+#define TCP_PEER_MATCH(Pa, Pb) \
+ ((((Pb)->Ip == 0) || ((Pb)->Ip == (Pa)->Ip)) && \
+ (((Pb)->Port == 0) || ((Pb)->Port == (Pa)->Port)))
+
+#define TCP_TIMER_ON(Flag, Timer) ((Flag) & (1 << (Timer)))
+#define TCP_SET_TIMER(Flag, Timer) ((Flag) = (UINT16) ((Flag) | (1 << (Timer))))
+#define TCP_CLEAR_TIMER(Flag, Timer) ((Flag) = (UINT16) ((Flag) & (~(1 << (Timer)))))
+
+#define TCP_TIME_LT(Ta, Tb) ((INT32) ((Ta) - (Tb)) < 0)
+#define TCP_TIME_LEQ(Ta, Tb) ((INT32) ((Ta) - (Tb)) <= 0)
+#define TCP_SUB_TIME(Ta, Tb) ((UINT32) ((Ta) - (Tb)))
+
+#define TCP_MAX_WIN 0xFFFFU
+
+typedef
+VOID
+(*TCP_TIMER_HANDLER) (
+ IN TCP_CB * Tcb
+ );
+
+#include "Tcp4Func.h"
+#endif