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
This commit is contained in:
@@ -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
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Retrieves a Unicode string that is the user readable name of the EFI Driver.
|
||||
|
||||
Arguments:
|
||||
|
||||
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.
|
||||
|
||||
Returns:
|
||||
|
||||
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.
|
||||
|
||||
--*/
|
||||
{
|
||||
return LookupUnicodeString (
|
||||
Language,
|
||||
gTcp4ComponentName.SupportedLanguages,
|
||||
mTcpDriverNameTable,
|
||||
DriverName
|
||||
);
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mTcpDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gTcp4ComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
)
|
||||
/*++
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
//
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user