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:
@@ -24,6 +24,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
|
||||
Ip4ComponentNameGetDriverName (
|
||||
@@ -32,6 +71,75 @@ Ip4ComponentNameGetDriverName (
|
||||
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
|
||||
Ip4ComponentNameGetControllerName (
|
||||
@@ -42,18 +150,29 @@ Ip4ComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName = {
|
||||
EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName = {
|
||||
Ip4ComponentNameGetDriverName,
|
||||
Ip4ComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ip4ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ip4ComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
static EFI_UNICODE_STRING_TABLE mIp4DriverNameTable[] = {
|
||||
{
|
||||
"eng",
|
||||
"eng;en",
|
||||
L"IP4 Network Service Driver"
|
||||
},
|
||||
{
|
||||
@@ -62,6 +181,45 @@ static EFI_UNICODE_STRING_TABLE mIp4DriverNameTable[] = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
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
|
||||
Ip4ComponentNameGetDriverName (
|
||||
@@ -69,44 +227,85 @@ Ip4ComponentNameGetDriverName (
|
||||
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,
|
||||
gIp4ComponentName.SupportedLanguages,
|
||||
mIp4DriverNameTable,
|
||||
DriverName
|
||||
);
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mIp4DriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gIp4ComponentName)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
Ip4ComponentNameGetControllerName (
|
||||
@@ -116,51 +315,6 @@ Ip4ComponentNameGetControllerName (
|
||||
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 SupportedLanguages. 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,143 +1,143 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Common.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Common definition for IP4.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_COMMON_H__
|
||||
#define __EFI_IP4_COMMON_H__
|
||||
|
||||
typedef struct _IP4_INTERFACE IP4_INTERFACE;
|
||||
typedef struct _IP4_PROTOCOL IP4_PROTOCOL;
|
||||
typedef struct _IP4_SERVICE IP4_SERVICE;
|
||||
|
||||
|
||||
enum {
|
||||
IP4_ETHER_PROTO = 0x0800,
|
||||
|
||||
IP4_PROTO_ICMP = 0x01,
|
||||
IP4_PROTO_IGMP = 0x02,
|
||||
|
||||
//
|
||||
// The packet is received as link level broadcast/multicast/promiscuous.
|
||||
//
|
||||
IP4_LINK_BROADCAST = 0x00000001,
|
||||
IP4_LINK_MULTICAST = 0x00000002,
|
||||
IP4_LINK_PROMISC = 0x00000004,
|
||||
|
||||
//
|
||||
// IP4 address cast type classfication. Keep it true that any
|
||||
// type bigger than or equal to LOCAL_BROADCAST is broadcast.
|
||||
//
|
||||
IP4_PROMISCUOUS = 1,
|
||||
IP4_LOCAL_HOST,
|
||||
IP4_MULTICAST,
|
||||
IP4_LOCAL_BROADCAST, // Destination is 255.255.255.255
|
||||
IP4_SUBNET_BROADCAST,
|
||||
IP4_NET_BROADCAST,
|
||||
|
||||
//
|
||||
// IP4 header flags
|
||||
//
|
||||
IP4_HEAD_DF_MASK = 0x4000,
|
||||
IP4_HEAD_MF_MASK = 0x2000,
|
||||
IP4_HEAD_OFFSET_MASK = 0x1fff
|
||||
};
|
||||
|
||||
#define IP4_ALLZERO_ADDRESS 0x00000000u
|
||||
#define IP4_ALLONE_ADDRESS 0xFFFFFFFFu
|
||||
#define IP4_ALLSYSTEM_ADDRESS 0xE0000001u
|
||||
#define IP4_ALLROUTER_ADDRESS 0xE0000002u
|
||||
|
||||
//
|
||||
// Compose the fragment field to be used in the IP4 header.
|
||||
//
|
||||
#define IP4_HEAD_FRAGMENT_FIELD(Df, Mf, Offset) \
|
||||
((UINT16)(((Df) ? 0x4000 : 0) | ((Mf) ? 0x2000 : 0) | (((Offset) >> 3) & 0x1fff)))
|
||||
|
||||
#define IP4_LAST_FRAGMENT(FragmentField) \
|
||||
(((FragmentField) & IP4_HEAD_MF_MASK) == 0)
|
||||
|
||||
#define IP4_FIRST_FRAGMENT(FragmentField) \
|
||||
((BOOLEAN)(((FragmentField) & IP4_HEAD_OFFSET_MASK) == 0))
|
||||
|
||||
#define IP4_IS_BROADCAST(CastType) ((CastType) >= IP4_LOCAL_BROADCAST)
|
||||
|
||||
//
|
||||
// Conver the Microsecond to second. IP transmit/receive time is
|
||||
// in the unit of microsecond. IP ticks once per second.
|
||||
//
|
||||
#define IP4_US_TO_SEC(Us) (((Us) + 999999) / 1000000)
|
||||
|
||||
INTN
|
||||
Ip4GetNetCast (
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
);
|
||||
|
||||
INTN
|
||||
Ip4GetHostCast (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4FindInterface (
|
||||
IN IP4_SERVICE *IpService,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4FindNet (
|
||||
IN IP4_SERVICE *IpService,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4FindStationAddress (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4GetMulticastMac (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN IP4_ADDR Multicast,
|
||||
OUT EFI_MAC_ADDRESS *Mac
|
||||
);
|
||||
|
||||
IP4_HEAD *
|
||||
Ip4NtohHead (
|
||||
IN IP4_HEAD *Head
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SetVariableData (
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4ClearVariableData (
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
#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:
|
||||
|
||||
Ip4Common.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Common definition for IP4.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_COMMON_H__
|
||||
#define __EFI_IP4_COMMON_H__
|
||||
|
||||
typedef struct _IP4_INTERFACE IP4_INTERFACE;
|
||||
typedef struct _IP4_PROTOCOL IP4_PROTOCOL;
|
||||
typedef struct _IP4_SERVICE IP4_SERVICE;
|
||||
|
||||
|
||||
enum {
|
||||
IP4_ETHER_PROTO = 0x0800,
|
||||
|
||||
IP4_PROTO_ICMP = 0x01,
|
||||
IP4_PROTO_IGMP = 0x02,
|
||||
|
||||
//
|
||||
// The packet is received as link level broadcast/multicast/promiscuous.
|
||||
//
|
||||
IP4_LINK_BROADCAST = 0x00000001,
|
||||
IP4_LINK_MULTICAST = 0x00000002,
|
||||
IP4_LINK_PROMISC = 0x00000004,
|
||||
|
||||
//
|
||||
// IP4 address cast type classfication. Keep it true that any
|
||||
// type bigger than or equal to LOCAL_BROADCAST is broadcast.
|
||||
//
|
||||
IP4_PROMISCUOUS = 1,
|
||||
IP4_LOCAL_HOST,
|
||||
IP4_MULTICAST,
|
||||
IP4_LOCAL_BROADCAST, // Destination is 255.255.255.255
|
||||
IP4_SUBNET_BROADCAST,
|
||||
IP4_NET_BROADCAST,
|
||||
|
||||
//
|
||||
// IP4 header flags
|
||||
//
|
||||
IP4_HEAD_DF_MASK = 0x4000,
|
||||
IP4_HEAD_MF_MASK = 0x2000,
|
||||
IP4_HEAD_OFFSET_MASK = 0x1fff
|
||||
};
|
||||
|
||||
#define IP4_ALLZERO_ADDRESS 0x00000000u
|
||||
#define IP4_ALLONE_ADDRESS 0xFFFFFFFFu
|
||||
#define IP4_ALLSYSTEM_ADDRESS 0xE0000001u
|
||||
#define IP4_ALLROUTER_ADDRESS 0xE0000002u
|
||||
|
||||
//
|
||||
// Compose the fragment field to be used in the IP4 header.
|
||||
//
|
||||
#define IP4_HEAD_FRAGMENT_FIELD(Df, Mf, Offset) \
|
||||
((UINT16)(((Df) ? 0x4000 : 0) | ((Mf) ? 0x2000 : 0) | (((Offset) >> 3) & 0x1fff)))
|
||||
|
||||
#define IP4_LAST_FRAGMENT(FragmentField) \
|
||||
(((FragmentField) & IP4_HEAD_MF_MASK) == 0)
|
||||
|
||||
#define IP4_FIRST_FRAGMENT(FragmentField) \
|
||||
((BOOLEAN)(((FragmentField) & IP4_HEAD_OFFSET_MASK) == 0))
|
||||
|
||||
#define IP4_IS_BROADCAST(CastType) ((CastType) >= IP4_LOCAL_BROADCAST)
|
||||
|
||||
//
|
||||
// Conver the Microsecond to second. IP transmit/receive time is
|
||||
// in the unit of microsecond. IP ticks once per second.
|
||||
//
|
||||
#define IP4_US_TO_SEC(Us) (((Us) + 999999) / 1000000)
|
||||
|
||||
INTN
|
||||
Ip4GetNetCast (
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
);
|
||||
|
||||
INTN
|
||||
Ip4GetHostCast (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4FindInterface (
|
||||
IN IP4_SERVICE *IpService,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4FindNet (
|
||||
IN IP4_SERVICE *IpService,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4FindStationAddress (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4GetMulticastMac (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN IP4_ADDR Multicast,
|
||||
OUT EFI_MAC_ADDRESS *Mac
|
||||
);
|
||||
|
||||
IP4_HEAD *
|
||||
Ip4NtohHead (
|
||||
IN IP4_HEAD *Head
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SetVariableData (
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4ClearVariableData (
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -56,14 +56,13 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
return EfiLibInstallAllDriverProtocols (
|
||||
return EfiLibInstallDriverBindingComponentName2 (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gIp4DriverBinding,
|
||||
ImageHandle,
|
||||
&gIp4ComponentName,
|
||||
NULL,
|
||||
NULL
|
||||
&gIp4ComponentName2
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,84 +1,85 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2007, 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:
|
||||
|
||||
Ip4Driver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_DRIVER_H__
|
||||
#define __EFI_IP4_DRIVER_H__
|
||||
|
||||
#include <Protocol/ServiceBinding.h>
|
||||
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName;
|
||||
|
||||
//
|
||||
// Function prototype for the driver's entry point
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
//
|
||||
// Function prototypes for the Drivr Binding Protocol
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingStop (
|
||||
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
|
||||
Ip4ServiceBindingCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE *ChildHandle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4ServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
#endif
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2005 - 2007, 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:
|
||||
|
||||
Ip4Driver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_DRIVER_H__
|
||||
#define __EFI_IP4_DRIVER_H__
|
||||
|
||||
#include <Protocol/ServiceBinding.h>
|
||||
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2;
|
||||
|
||||
//
|
||||
// Function prototype for the driver's entry point
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
//
|
||||
// Function prototypes for the Drivr Binding Protocol
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingStop (
|
||||
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
|
||||
Ip4ServiceBindingCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE *ChildHandle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4ServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
#endif
|
||||
|
@@ -1,99 +1,99 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Icmp.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Header file for ICMP protocol.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_ICMP_H__
|
||||
#define __EFI_IP4_ICMP_H__
|
||||
|
||||
enum {
|
||||
//
|
||||
// ICMP type definations
|
||||
//
|
||||
ICMP_ECHO_REPLY = 0,
|
||||
ICMP_DEST_UNREACHABLE = 3,
|
||||
ICMP_SOURCE_QUENCH = 4,
|
||||
ICMP_REDIRECT = 5,
|
||||
ICMP_ECHO_REQUEST = 8,
|
||||
ICMP_TIME_EXCEEDED = 11,
|
||||
ICMP_PARAMETER_PROBLEM = 12,
|
||||
ICMP_TIMESTAMP = 13,
|
||||
ICMP_INFO_REQUEST = 15,
|
||||
ICMP_INFO_REPLY = 16,
|
||||
ICMP_TYPE_MAX = ICMP_INFO_REPLY,
|
||||
|
||||
ICMP_DEFAULT_CODE = 0,
|
||||
|
||||
//
|
||||
// ICMP code definations for ICMP_DEST_UNREACHABLE
|
||||
//
|
||||
ICMP_NET_UNREACHABLE = 0,
|
||||
ICMP_HOST_UNREACHABLE = 1,
|
||||
ICMP_PROTO_UNREACHABLE = 2, // Host may generate
|
||||
ICMP_PORT_UNREACHABLE = 3, // Host may generate
|
||||
ICMP_FRAGMENT_FAILED = 4,
|
||||
ICMP_SOURCEROUTE_FAILED = 5, // Host may generate
|
||||
ICMP_NET_UNKNOWN = 6,
|
||||
ICMP_HOST_UNKNOWN = 7,
|
||||
ICMP_SOURCE_ISOLATED = 8,
|
||||
ICMP_NET_PROHIBITED = 9,
|
||||
ICMP_HOST_PROHIBITED = 10,
|
||||
ICMP_NET_UNREACHABLE_TOS = 11,
|
||||
ICMP_HOST_UNREACHABLE_TOS = 12,
|
||||
|
||||
//
|
||||
// ICMP code definations for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
ICMP_TIMEOUT_IN_TRANSIT = 0,
|
||||
ICMp_TIMEOUT_REASSEMBLE = 1, // Host may generate
|
||||
|
||||
//
|
||||
// ICMP code definations for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
ICMP_NET_REDIRECT = 0,
|
||||
ICMP_HOST_REDIRECT = 1,
|
||||
ICMP_NET_TOS_REDIRECT = 2,
|
||||
ICMP_HOST_TOS_REDIRECT = 3,
|
||||
|
||||
//
|
||||
// ICMP message classes, each class of ICMP message shares
|
||||
// a common message format. INVALID_MESSAGE is only a flag.
|
||||
//
|
||||
ICMP_INVALID_MESSAGE = 0,
|
||||
ICMP_ERROR_MESSAGE = 1,
|
||||
ICMP_QUERY_MESSAGE = 2
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
UINT8 IcmpType;
|
||||
UINT8 IcmpClass;
|
||||
} IP4_ICMP_CLASS;
|
||||
|
||||
extern IP4_ICMP_CLASS mIcmpClass[];
|
||||
extern EFI_IP4_ICMP_TYPE mIp4SupportedIcmp[];
|
||||
|
||||
EFI_STATUS
|
||||
Ip4IcmpHandle (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Header,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
#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:
|
||||
|
||||
Ip4Icmp.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Header file for ICMP protocol.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_ICMP_H__
|
||||
#define __EFI_IP4_ICMP_H__
|
||||
|
||||
enum {
|
||||
//
|
||||
// ICMP type definations
|
||||
//
|
||||
ICMP_ECHO_REPLY = 0,
|
||||
ICMP_DEST_UNREACHABLE = 3,
|
||||
ICMP_SOURCE_QUENCH = 4,
|
||||
ICMP_REDIRECT = 5,
|
||||
ICMP_ECHO_REQUEST = 8,
|
||||
ICMP_TIME_EXCEEDED = 11,
|
||||
ICMP_PARAMETER_PROBLEM = 12,
|
||||
ICMP_TIMESTAMP = 13,
|
||||
ICMP_INFO_REQUEST = 15,
|
||||
ICMP_INFO_REPLY = 16,
|
||||
ICMP_TYPE_MAX = ICMP_INFO_REPLY,
|
||||
|
||||
ICMP_DEFAULT_CODE = 0,
|
||||
|
||||
//
|
||||
// ICMP code definations for ICMP_DEST_UNREACHABLE
|
||||
//
|
||||
ICMP_NET_UNREACHABLE = 0,
|
||||
ICMP_HOST_UNREACHABLE = 1,
|
||||
ICMP_PROTO_UNREACHABLE = 2, // Host may generate
|
||||
ICMP_PORT_UNREACHABLE = 3, // Host may generate
|
||||
ICMP_FRAGMENT_FAILED = 4,
|
||||
ICMP_SOURCEROUTE_FAILED = 5, // Host may generate
|
||||
ICMP_NET_UNKNOWN = 6,
|
||||
ICMP_HOST_UNKNOWN = 7,
|
||||
ICMP_SOURCE_ISOLATED = 8,
|
||||
ICMP_NET_PROHIBITED = 9,
|
||||
ICMP_HOST_PROHIBITED = 10,
|
||||
ICMP_NET_UNREACHABLE_TOS = 11,
|
||||
ICMP_HOST_UNREACHABLE_TOS = 12,
|
||||
|
||||
//
|
||||
// ICMP code definations for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
ICMP_TIMEOUT_IN_TRANSIT = 0,
|
||||
ICMp_TIMEOUT_REASSEMBLE = 1, // Host may generate
|
||||
|
||||
//
|
||||
// ICMP code definations for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
ICMP_NET_REDIRECT = 0,
|
||||
ICMP_HOST_REDIRECT = 1,
|
||||
ICMP_NET_TOS_REDIRECT = 2,
|
||||
ICMP_HOST_TOS_REDIRECT = 3,
|
||||
|
||||
//
|
||||
// ICMP message classes, each class of ICMP message shares
|
||||
// a common message format. INVALID_MESSAGE is only a flag.
|
||||
//
|
||||
ICMP_INVALID_MESSAGE = 0,
|
||||
ICMP_ERROR_MESSAGE = 1,
|
||||
ICMP_QUERY_MESSAGE = 2
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
UINT8 IcmpType;
|
||||
UINT8 IcmpClass;
|
||||
} IP4_ICMP_CLASS;
|
||||
|
||||
extern IP4_ICMP_CLASS mIcmpClass[];
|
||||
extern EFI_IP4_ICMP_TYPE mIp4SupportedIcmp[];
|
||||
|
||||
EFI_STATUS
|
||||
Ip4IcmpHandle (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Header,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
#endif
|
||||
|
@@ -1,238 +1,238 @@
|
||||
/** @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:
|
||||
|
||||
Ip4If.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Definition for IP4 pesudo interface structure.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_IF_H__
|
||||
#define __EFI_IP4_IF_H__
|
||||
|
||||
enum {
|
||||
IP4_FRAME_RX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'),
|
||||
IP4_FRAME_TX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'),
|
||||
IP4_FRAME_ARP_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'),
|
||||
IP4_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'I', 'F')
|
||||
};
|
||||
|
||||
//
|
||||
// This prototype is used by both receive and transmission.
|
||||
// When receiving Netbuf is allocated by IP4_INTERFACE, and
|
||||
// released by IP4. Flag shows whether the frame is received
|
||||
// as link broadcast/multicast...
|
||||
//
|
||||
// When transmitting, the Netbuf is from IP4, and provided
|
||||
// to the callback as a reference. Flag isn't used.
|
||||
//
|
||||
// IpInstance can be NULL which means that it is the IP4 driver
|
||||
// itself sending the packets. IP4 driver may send packets that
|
||||
// don't belong to any instance, such as ICMP errors, ICMP echo
|
||||
// responses, or IGMP packets. IpInstance is used as a tag in
|
||||
// this module.
|
||||
//
|
||||
typedef
|
||||
VOID
|
||||
(*IP4_FRAME_CALLBACK) (
|
||||
IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 LinkFlag,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
//
|
||||
// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.
|
||||
// Upon completion, the Callback will be called. Only one
|
||||
// receive request is send to MNP. IpInstance is always NULL.
|
||||
// Reference MNP's spec for information.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
VOID *Context;
|
||||
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
} IP4_LINK_RX_TOKEN;
|
||||
|
||||
//
|
||||
// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.
|
||||
// Upon completion, the Callback will be called.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
NET_LIST_ENTRY Link;
|
||||
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
NET_BUF *Packet;
|
||||
VOID *Context;
|
||||
|
||||
EFI_MAC_ADDRESS DstMac;
|
||||
EFI_MAC_ADDRESS SrcMac;
|
||||
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;
|
||||
} IP4_LINK_TX_TOKEN;
|
||||
|
||||
//
|
||||
// Only one ARP request is requested for all the frames in
|
||||
// a time. It is started for the first frames to the Ip. Any
|
||||
// subsequent transmission frame will be linked to Frames, and
|
||||
// be sent all at once the ARP requests succeed.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
NET_LIST_ENTRY Link;
|
||||
|
||||
NET_LIST_ENTRY Frames;
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
//
|
||||
// ARP requesting staffs
|
||||
//
|
||||
EFI_EVENT OnResolved;
|
||||
IP4_ADDR Ip;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
} IP4_ARP_QUE;
|
||||
|
||||
//
|
||||
// Callback to select which frame to cancel. Caller can cancel a
|
||||
// single frame, or all the frame from an IP instance.
|
||||
//
|
||||
typedef
|
||||
BOOLEAN
|
||||
(*IP4_FRAME_TO_CANCEL) (
|
||||
IP4_LINK_TX_TOKEN *Frame,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
//
|
||||
// Each IP4 instance has its own station address. All the instances
|
||||
// with the same station address share a single interface structure.
|
||||
// Each interface has its own ARP child, and shares one MNP child.
|
||||
// Notice the special cases that DHCP can configure the interface
|
||||
// with 0.0.0.0/0.0.0.0.
|
||||
//
|
||||
struct _IP4_INTERFACE {
|
||||
UINT32 Signature;
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
|
||||
//
|
||||
// IP address and subnet mask of the interface. It also contains
|
||||
// the subnet/net broadcast address for quick access. The fileds
|
||||
// are invalid if (Configured == FALSE)
|
||||
//
|
||||
IP4_ADDR Ip;
|
||||
IP4_ADDR SubnetMask;
|
||||
IP4_ADDR SubnetBrdcast;
|
||||
IP4_ADDR NetBrdcast;
|
||||
BOOLEAN Configured;
|
||||
|
||||
//
|
||||
// Handle used to create/destory ARP child. All the IP children
|
||||
// share one MNP which is owned by IP service binding.
|
||||
//
|
||||
EFI_HANDLE Controller;
|
||||
EFI_HANDLE Image;
|
||||
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
EFI_ARP_PROTOCOL *Arp;
|
||||
EFI_HANDLE ArpHandle;
|
||||
|
||||
//
|
||||
// Queues to keep the frames sent and waiting ARP request.
|
||||
//
|
||||
NET_LIST_ENTRY ArpQues;
|
||||
NET_LIST_ENTRY SentFrames;
|
||||
IP4_LINK_RX_TOKEN *RecvRequest;
|
||||
|
||||
//
|
||||
// The interface's MAC and broadcast MAC address.
|
||||
//
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
EFI_MAC_ADDRESS BroadcastMac;
|
||||
UINT32 HwaddrLen;
|
||||
|
||||
//
|
||||
// All the IP instances that have the same IP/SubnetMask are linked
|
||||
// together through IpInstances. If any of the instance enables
|
||||
// promiscuous receive, PromiscRecv is true.
|
||||
//
|
||||
NET_LIST_ENTRY IpInstances;
|
||||
BOOLEAN PromiscRecv;
|
||||
};
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4CreateInterface (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SetAddress (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_ADDR SubnetMask
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4FreeInterface (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SendFrame (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_ADDR NextHop,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CancelFrames (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CancelReceive (
|
||||
IN IP4_INTERFACE *Interface
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4ReceiveFrame (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
#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:
|
||||
|
||||
Ip4If.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Definition for IP4 pesudo interface structure.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_IF_H__
|
||||
#define __EFI_IP4_IF_H__
|
||||
|
||||
enum {
|
||||
IP4_FRAME_RX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'),
|
||||
IP4_FRAME_TX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'),
|
||||
IP4_FRAME_ARP_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'),
|
||||
IP4_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'I', 'F')
|
||||
};
|
||||
|
||||
//
|
||||
// This prototype is used by both receive and transmission.
|
||||
// When receiving Netbuf is allocated by IP4_INTERFACE, and
|
||||
// released by IP4. Flag shows whether the frame is received
|
||||
// as link broadcast/multicast...
|
||||
//
|
||||
// When transmitting, the Netbuf is from IP4, and provided
|
||||
// to the callback as a reference. Flag isn't used.
|
||||
//
|
||||
// IpInstance can be NULL which means that it is the IP4 driver
|
||||
// itself sending the packets. IP4 driver may send packets that
|
||||
// don't belong to any instance, such as ICMP errors, ICMP echo
|
||||
// responses, or IGMP packets. IpInstance is used as a tag in
|
||||
// this module.
|
||||
//
|
||||
typedef
|
||||
VOID
|
||||
(*IP4_FRAME_CALLBACK) (
|
||||
IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 LinkFlag,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
//
|
||||
// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.
|
||||
// Upon completion, the Callback will be called. Only one
|
||||
// receive request is send to MNP. IpInstance is always NULL.
|
||||
// Reference MNP's spec for information.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
VOID *Context;
|
||||
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
} IP4_LINK_RX_TOKEN;
|
||||
|
||||
//
|
||||
// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.
|
||||
// Upon completion, the Callback will be called.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
NET_LIST_ENTRY Link;
|
||||
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
NET_BUF *Packet;
|
||||
VOID *Context;
|
||||
|
||||
EFI_MAC_ADDRESS DstMac;
|
||||
EFI_MAC_ADDRESS SrcMac;
|
||||
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;
|
||||
} IP4_LINK_TX_TOKEN;
|
||||
|
||||
//
|
||||
// Only one ARP request is requested for all the frames in
|
||||
// a time. It is started for the first frames to the Ip. Any
|
||||
// subsequent transmission frame will be linked to Frames, and
|
||||
// be sent all at once the ARP requests succeed.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
NET_LIST_ENTRY Link;
|
||||
|
||||
NET_LIST_ENTRY Frames;
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
//
|
||||
// ARP requesting staffs
|
||||
//
|
||||
EFI_EVENT OnResolved;
|
||||
IP4_ADDR Ip;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
} IP4_ARP_QUE;
|
||||
|
||||
//
|
||||
// Callback to select which frame to cancel. Caller can cancel a
|
||||
// single frame, or all the frame from an IP instance.
|
||||
//
|
||||
typedef
|
||||
BOOLEAN
|
||||
(*IP4_FRAME_TO_CANCEL) (
|
||||
IP4_LINK_TX_TOKEN *Frame,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
//
|
||||
// Each IP4 instance has its own station address. All the instances
|
||||
// with the same station address share a single interface structure.
|
||||
// Each interface has its own ARP child, and shares one MNP child.
|
||||
// Notice the special cases that DHCP can configure the interface
|
||||
// with 0.0.0.0/0.0.0.0.
|
||||
//
|
||||
struct _IP4_INTERFACE {
|
||||
UINT32 Signature;
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
|
||||
//
|
||||
// IP address and subnet mask of the interface. It also contains
|
||||
// the subnet/net broadcast address for quick access. The fileds
|
||||
// are invalid if (Configured == FALSE)
|
||||
//
|
||||
IP4_ADDR Ip;
|
||||
IP4_ADDR SubnetMask;
|
||||
IP4_ADDR SubnetBrdcast;
|
||||
IP4_ADDR NetBrdcast;
|
||||
BOOLEAN Configured;
|
||||
|
||||
//
|
||||
// Handle used to create/destory ARP child. All the IP children
|
||||
// share one MNP which is owned by IP service binding.
|
||||
//
|
||||
EFI_HANDLE Controller;
|
||||
EFI_HANDLE Image;
|
||||
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
EFI_ARP_PROTOCOL *Arp;
|
||||
EFI_HANDLE ArpHandle;
|
||||
|
||||
//
|
||||
// Queues to keep the frames sent and waiting ARP request.
|
||||
//
|
||||
NET_LIST_ENTRY ArpQues;
|
||||
NET_LIST_ENTRY SentFrames;
|
||||
IP4_LINK_RX_TOKEN *RecvRequest;
|
||||
|
||||
//
|
||||
// The interface's MAC and broadcast MAC address.
|
||||
//
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
EFI_MAC_ADDRESS BroadcastMac;
|
||||
UINT32 HwaddrLen;
|
||||
|
||||
//
|
||||
// All the IP instances that have the same IP/SubnetMask are linked
|
||||
// together through IpInstances. If any of the instance enables
|
||||
// promiscuous receive, PromiscRecv is true.
|
||||
//
|
||||
NET_LIST_ENTRY IpInstances;
|
||||
BOOLEAN PromiscRecv;
|
||||
};
|
||||
|
||||
IP4_INTERFACE *
|
||||
Ip4CreateInterface (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SetAddress (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_ADDR SubnetMask
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4FreeInterface (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SendFrame (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_ADDR NextHop,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CancelFrames (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CancelReceive (
|
||||
IN IP4_INTERFACE *Interface
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4ReceiveFrame (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -1,120 +1,120 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Igmp.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_IGMP_H__
|
||||
#define __EFI_IP4_IGMP_H__
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 MaxRespTime;
|
||||
UINT16 Checksum;
|
||||
IP4_ADDR Group;
|
||||
} IGMP_HEAD;
|
||||
#pragma pack()
|
||||
|
||||
//
|
||||
// The status of multicast group. It isn't necessary to maintain
|
||||
// explicit state of host state diagram. A group with non-zero
|
||||
// DelayTime is in "delaying member" state. otherwise, it is in
|
||||
// "idle member" state.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Address;
|
||||
INTN DelayTime;
|
||||
BOOLEAN ReportByUs;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
} IGMP_GROUP;
|
||||
|
||||
//
|
||||
// The IGMP status. Each IP4 service instance has a IGMP_SERVICE_DATA
|
||||
// attached. The Igmpv1QuerySeen remember whether the server on this
|
||||
// connected network is v1 or v2.
|
||||
//
|
||||
typedef struct {
|
||||
INTN Igmpv1QuerySeen;
|
||||
NET_LIST_ENTRY Groups;
|
||||
} IGMP_SERVICE_DATA;
|
||||
|
||||
enum {
|
||||
//
|
||||
// IGMP message type
|
||||
//
|
||||
IGMP_MEMBERSHIP_QUERY = 0x11,
|
||||
IGMP_V1_MEMBERSHIP_REPORT = 0x12,
|
||||
IGMP_V2_MEMBERSHIP_REPORT = 0x16,
|
||||
IGMP_LEAVE_GROUP = 0x17,
|
||||
|
||||
IGMP_V1ROUTER_PRESENT = 400,
|
||||
IGMP_UNSOLICIATED_REPORT = 10
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
Ip4InitIgmp (
|
||||
IN IP4_SERVICE *IpService
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4JoinGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4LeaveGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4IgmpHandle (
|
||||
IN IP4_SERVICE *IpService,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4IgmpTicking (
|
||||
IN IP4_SERVICE *IpService
|
||||
);
|
||||
|
||||
IP4_ADDR *
|
||||
Ip4CombineGroups (
|
||||
IN IP4_ADDR *SourceGroups,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
INTN
|
||||
Ip4RemoveGroupAddr (
|
||||
IN IP4_ADDR *Group,
|
||||
IN UINT32 GroupCnt,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
IGMP_GROUP *
|
||||
Ip4FindGroup (
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
#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:
|
||||
|
||||
Ip4Igmp.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_IGMP_H__
|
||||
#define __EFI_IP4_IGMP_H__
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 MaxRespTime;
|
||||
UINT16 Checksum;
|
||||
IP4_ADDR Group;
|
||||
} IGMP_HEAD;
|
||||
#pragma pack()
|
||||
|
||||
//
|
||||
// The status of multicast group. It isn't necessary to maintain
|
||||
// explicit state of host state diagram. A group with non-zero
|
||||
// DelayTime is in "delaying member" state. otherwise, it is in
|
||||
// "idle member" state.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Address;
|
||||
INTN DelayTime;
|
||||
BOOLEAN ReportByUs;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
} IGMP_GROUP;
|
||||
|
||||
//
|
||||
// The IGMP status. Each IP4 service instance has a IGMP_SERVICE_DATA
|
||||
// attached. The Igmpv1QuerySeen remember whether the server on this
|
||||
// connected network is v1 or v2.
|
||||
//
|
||||
typedef struct {
|
||||
INTN Igmpv1QuerySeen;
|
||||
NET_LIST_ENTRY Groups;
|
||||
} IGMP_SERVICE_DATA;
|
||||
|
||||
enum {
|
||||
//
|
||||
// IGMP message type
|
||||
//
|
||||
IGMP_MEMBERSHIP_QUERY = 0x11,
|
||||
IGMP_V1_MEMBERSHIP_REPORT = 0x12,
|
||||
IGMP_V2_MEMBERSHIP_REPORT = 0x16,
|
||||
IGMP_LEAVE_GROUP = 0x17,
|
||||
|
||||
IGMP_V1ROUTER_PRESENT = 400,
|
||||
IGMP_UNSOLICIATED_REPORT = 10
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
Ip4InitIgmp (
|
||||
IN IP4_SERVICE *IpService
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4JoinGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4LeaveGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4IgmpHandle (
|
||||
IN IP4_SERVICE *IpService,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4IgmpTicking (
|
||||
IN IP4_SERVICE *IpService
|
||||
);
|
||||
|
||||
IP4_ADDR *
|
||||
Ip4CombineGroups (
|
||||
IN IP4_ADDR *SourceGroups,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
INTN
|
||||
Ip4RemoveGroupAddr (
|
||||
IN IP4_ADDR *Group,
|
||||
IN UINT32 GroupCnt,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
IGMP_GROUP *
|
||||
Ip4FindGroup (
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
#endif
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Impl.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Ip4 internal functions and type defintions.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_IMPL_H__
|
||||
#define __EFI_IP4_IMPL_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:
|
||||
|
||||
Ip4Impl.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Ip4 internal functions and type defintions.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_IMPL_H__
|
||||
#define __EFI_IP4_IMPL_H__
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Protocol/IP4.h>
|
||||
@@ -35,224 +35,224 @@ Abstract:
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/NetLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
#include "Ip4Common.h"
|
||||
#include "Ip4Driver.h"
|
||||
#include "Ip4If.h"
|
||||
#include "Ip4Icmp.h"
|
||||
#include "Ip4Option.h"
|
||||
#include "Ip4Igmp.h"
|
||||
#include "Ip4Route.h"
|
||||
#include "Ip4Input.h"
|
||||
#include "Ip4Output.h"
|
||||
|
||||
enum {
|
||||
IP4_PROTOCOL_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'P'),
|
||||
IP4_SERVICE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'S'),
|
||||
|
||||
//
|
||||
// The state of IP4 protocol. It starts from UNCONFIGED. if it is
|
||||
// successfully configured, it goes to CONFIGED. if configure NULL
|
||||
// is called, it becomes UNCONFIGED again. If (partly) destoried, it
|
||||
// becomes DESTORY.
|
||||
//
|
||||
IP4_STATE_UNCONFIGED = 0,
|
||||
IP4_STATE_CONFIGED,
|
||||
IP4_STATE_DESTORY,
|
||||
|
||||
//
|
||||
// The state of IP4 service. It starts from UNSTARTED. It transits
|
||||
// to STARTED if autoconfigure is started. If default address is
|
||||
// configured, it becomes CONFIGED. and if partly destoried, it goes
|
||||
// to DESTORY.
|
||||
//
|
||||
IP4_SERVICE_UNSTARTED = 0,
|
||||
IP4_SERVICE_STARTED,
|
||||
IP4_SERVICE_CONFIGED,
|
||||
IP4_SERVICE_DESTORY
|
||||
};
|
||||
|
||||
//
|
||||
// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.
|
||||
// The user's data is kept in the Packet. When fragment is
|
||||
// needed, each fragment of the Packet has a reference to the
|
||||
// Packet, no data is actually copied. The Packet will be
|
||||
// released when all the fragments of it have been recycled by
|
||||
// MNP. Upon then, the IP4_TXTOKEN_WRAP will be released, and
|
||||
// user's event signalled.
|
||||
//
|
||||
typedef struct {
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
NET_BUF *Packet;
|
||||
BOOLEAN Sent;
|
||||
INTN Life;
|
||||
} IP4_TXTOKEN_WRAP;
|
||||
|
||||
//
|
||||
// IP4_RXDATA_WRAP wraps the data IP4 child delivers to the
|
||||
// upper layers. The received packet is kept in the Packet.
|
||||
// The Packet itself may be constructured from some fragments.
|
||||
// All the fragments of the Packet is organized by a
|
||||
// IP4_ASSEMBLE_ENTRY structure. If the Packet is recycled by
|
||||
// the upper layer, the assemble entry and its associated
|
||||
// fragments will be freed at last.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
NET_BUF *Packet;
|
||||
EFI_IP4_RECEIVE_DATA RxData;
|
||||
} IP4_RXDATA_WRAP;
|
||||
|
||||
struct _IP4_PROTOCOL {
|
||||
UINT32 Signature;
|
||||
|
||||
EFI_IP4_PROTOCOL Ip4Proto;
|
||||
EFI_HANDLE Handle;
|
||||
INTN State;
|
||||
|
||||
IP4_SERVICE *Service;
|
||||
NET_LIST_ENTRY Link; // Link to all the IP protocol from the service
|
||||
|
||||
//
|
||||
// User's transmit/receive tokens, and received/deliverd packets
|
||||
//
|
||||
NET_MAP RxTokens;
|
||||
NET_MAP TxTokens; // map between (User's Token, IP4_TXTOKE_WRAP)
|
||||
NET_LIST_ENTRY Received; // Received but not delivered packet
|
||||
NET_LIST_ENTRY Delivered; // Delivered and to be recycled packets
|
||||
EFI_LOCK RecycleLock;
|
||||
|
||||
//
|
||||
// Instance's address and route tables. There are two route tables.
|
||||
// RouteTable is used by the IP4 driver to route packet. EfiRouteTable
|
||||
// is used to communicate the current route info to the upper layer.
|
||||
//
|
||||
IP4_INTERFACE *Interface;
|
||||
NET_LIST_ENTRY AddrLink; // Ip instances with the same IP address.
|
||||
IP4_ROUTE_TABLE *RouteTable;
|
||||
|
||||
EFI_IP4_ROUTE_TABLE *EfiRouteTable;
|
||||
UINT32 EfiRouteCount;
|
||||
|
||||
//
|
||||
// IGMP data for this instance
|
||||
//
|
||||
IP4_ADDR *Groups; // stored in network byte order
|
||||
UINT32 GroupCount;
|
||||
|
||||
EFI_IP4_CONFIG_DATA ConfigData;
|
||||
|
||||
};
|
||||
|
||||
struct _IP4_SERVICE {
|
||||
UINT32 Signature;
|
||||
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
||||
INTN State;
|
||||
BOOLEAN InDestory;
|
||||
|
||||
//
|
||||
// List of all the IP instances and interfaces, and default
|
||||
// interface and route table and caches.
|
||||
//
|
||||
UINTN NumChildren;
|
||||
NET_LIST_ENTRY Children;
|
||||
|
||||
NET_LIST_ENTRY Interfaces;
|
||||
|
||||
IP4_INTERFACE *DefaultInterface;
|
||||
IP4_ROUTE_TABLE *DefaultRouteTable;
|
||||
|
||||
//
|
||||
// Ip reassemble utilities, and IGMP data
|
||||
//
|
||||
IP4_ASSEMBLE_TABLE Assemble;
|
||||
IGMP_SERVICE_DATA IgmpCtrl;
|
||||
|
||||
//
|
||||
// Low level protocol used by this service instance
|
||||
//
|
||||
EFI_HANDLE Image;
|
||||
EFI_HANDLE Controller;
|
||||
|
||||
EFI_HANDLE MnpChildHandle;
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
|
||||
EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
|
||||
EFI_SIMPLE_NETWORK_MODE SnpMode;
|
||||
|
||||
EFI_EVENT Timer;
|
||||
|
||||
//
|
||||
// Auto configure staff
|
||||
//
|
||||
EFI_IP4_CONFIG_PROTOCOL *Ip4Config;
|
||||
EFI_EVENT DoneEvent;
|
||||
EFI_EVENT ReconfigEvent;
|
||||
|
||||
//
|
||||
// The string representation of the current mac address of the
|
||||
// NIC this IP4_SERVICE works on.
|
||||
//
|
||||
CHAR16 *MacString;
|
||||
};
|
||||
|
||||
#define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \
|
||||
CR ((Ip4), IP4_PROTOCOL, Ip4Proto, IP4_PROTOCOL_SIGNATURE)
|
||||
|
||||
#define IP4_SERVICE_FROM_PROTOCOL(Sb) \
|
||||
CR ((Sb), IP4_SERVICE, ServiceBinding, IP4_SERVICE_SIGNATURE)
|
||||
|
||||
#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
|
||||
|
||||
extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
|
||||
|
||||
EFI_STATUS
|
||||
Ip4ServiceConfigMnp (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN BOOLEAN Force
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4InitProtocol (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4CleanProtocol (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Cancel (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN EFI_IP4_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Groups (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv4_ADDRESS *GroupAddress
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4TimerTicking (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SentPacketTicking (
|
||||
IN NET_MAP *Map,
|
||||
IN NET_MAP_ITEM *Item,
|
||||
IN VOID *Context
|
||||
);
|
||||
#endif
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/NetLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
#include "Ip4Common.h"
|
||||
#include "Ip4Driver.h"
|
||||
#include "Ip4If.h"
|
||||
#include "Ip4Icmp.h"
|
||||
#include "Ip4Option.h"
|
||||
#include "Ip4Igmp.h"
|
||||
#include "Ip4Route.h"
|
||||
#include "Ip4Input.h"
|
||||
#include "Ip4Output.h"
|
||||
|
||||
enum {
|
||||
IP4_PROTOCOL_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'P'),
|
||||
IP4_SERVICE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'S'),
|
||||
|
||||
//
|
||||
// The state of IP4 protocol. It starts from UNCONFIGED. if it is
|
||||
// successfully configured, it goes to CONFIGED. if configure NULL
|
||||
// is called, it becomes UNCONFIGED again. If (partly) destoried, it
|
||||
// becomes DESTORY.
|
||||
//
|
||||
IP4_STATE_UNCONFIGED = 0,
|
||||
IP4_STATE_CONFIGED,
|
||||
IP4_STATE_DESTORY,
|
||||
|
||||
//
|
||||
// The state of IP4 service. It starts from UNSTARTED. It transits
|
||||
// to STARTED if autoconfigure is started. If default address is
|
||||
// configured, it becomes CONFIGED. and if partly destoried, it goes
|
||||
// to DESTORY.
|
||||
//
|
||||
IP4_SERVICE_UNSTARTED = 0,
|
||||
IP4_SERVICE_STARTED,
|
||||
IP4_SERVICE_CONFIGED,
|
||||
IP4_SERVICE_DESTORY
|
||||
};
|
||||
|
||||
//
|
||||
// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.
|
||||
// The user's data is kept in the Packet. When fragment is
|
||||
// needed, each fragment of the Packet has a reference to the
|
||||
// Packet, no data is actually copied. The Packet will be
|
||||
// released when all the fragments of it have been recycled by
|
||||
// MNP. Upon then, the IP4_TXTOKEN_WRAP will be released, and
|
||||
// user's event signalled.
|
||||
//
|
||||
typedef struct {
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
NET_BUF *Packet;
|
||||
BOOLEAN Sent;
|
||||
INTN Life;
|
||||
} IP4_TXTOKEN_WRAP;
|
||||
|
||||
//
|
||||
// IP4_RXDATA_WRAP wraps the data IP4 child delivers to the
|
||||
// upper layers. The received packet is kept in the Packet.
|
||||
// The Packet itself may be constructured from some fragments.
|
||||
// All the fragments of the Packet is organized by a
|
||||
// IP4_ASSEMBLE_ENTRY structure. If the Packet is recycled by
|
||||
// the upper layer, the assemble entry and its associated
|
||||
// fragments will be freed at last.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
NET_BUF *Packet;
|
||||
EFI_IP4_RECEIVE_DATA RxData;
|
||||
} IP4_RXDATA_WRAP;
|
||||
|
||||
struct _IP4_PROTOCOL {
|
||||
UINT32 Signature;
|
||||
|
||||
EFI_IP4_PROTOCOL Ip4Proto;
|
||||
EFI_HANDLE Handle;
|
||||
INTN State;
|
||||
|
||||
IP4_SERVICE *Service;
|
||||
NET_LIST_ENTRY Link; // Link to all the IP protocol from the service
|
||||
|
||||
//
|
||||
// User's transmit/receive tokens, and received/deliverd packets
|
||||
//
|
||||
NET_MAP RxTokens;
|
||||
NET_MAP TxTokens; // map between (User's Token, IP4_TXTOKE_WRAP)
|
||||
NET_LIST_ENTRY Received; // Received but not delivered packet
|
||||
NET_LIST_ENTRY Delivered; // Delivered and to be recycled packets
|
||||
EFI_LOCK RecycleLock;
|
||||
|
||||
//
|
||||
// Instance's address and route tables. There are two route tables.
|
||||
// RouteTable is used by the IP4 driver to route packet. EfiRouteTable
|
||||
// is used to communicate the current route info to the upper layer.
|
||||
//
|
||||
IP4_INTERFACE *Interface;
|
||||
NET_LIST_ENTRY AddrLink; // Ip instances with the same IP address.
|
||||
IP4_ROUTE_TABLE *RouteTable;
|
||||
|
||||
EFI_IP4_ROUTE_TABLE *EfiRouteTable;
|
||||
UINT32 EfiRouteCount;
|
||||
|
||||
//
|
||||
// IGMP data for this instance
|
||||
//
|
||||
IP4_ADDR *Groups; // stored in network byte order
|
||||
UINT32 GroupCount;
|
||||
|
||||
EFI_IP4_CONFIG_DATA ConfigData;
|
||||
|
||||
};
|
||||
|
||||
struct _IP4_SERVICE {
|
||||
UINT32 Signature;
|
||||
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
||||
INTN State;
|
||||
BOOLEAN InDestory;
|
||||
|
||||
//
|
||||
// List of all the IP instances and interfaces, and default
|
||||
// interface and route table and caches.
|
||||
//
|
||||
UINTN NumChildren;
|
||||
NET_LIST_ENTRY Children;
|
||||
|
||||
NET_LIST_ENTRY Interfaces;
|
||||
|
||||
IP4_INTERFACE *DefaultInterface;
|
||||
IP4_ROUTE_TABLE *DefaultRouteTable;
|
||||
|
||||
//
|
||||
// Ip reassemble utilities, and IGMP data
|
||||
//
|
||||
IP4_ASSEMBLE_TABLE Assemble;
|
||||
IGMP_SERVICE_DATA IgmpCtrl;
|
||||
|
||||
//
|
||||
// Low level protocol used by this service instance
|
||||
//
|
||||
EFI_HANDLE Image;
|
||||
EFI_HANDLE Controller;
|
||||
|
||||
EFI_HANDLE MnpChildHandle;
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
|
||||
EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
|
||||
EFI_SIMPLE_NETWORK_MODE SnpMode;
|
||||
|
||||
EFI_EVENT Timer;
|
||||
|
||||
//
|
||||
// Auto configure staff
|
||||
//
|
||||
EFI_IP4_CONFIG_PROTOCOL *Ip4Config;
|
||||
EFI_EVENT DoneEvent;
|
||||
EFI_EVENT ReconfigEvent;
|
||||
|
||||
//
|
||||
// The string representation of the current mac address of the
|
||||
// NIC this IP4_SERVICE works on.
|
||||
//
|
||||
CHAR16 *MacString;
|
||||
};
|
||||
|
||||
#define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \
|
||||
CR ((Ip4), IP4_PROTOCOL, Ip4Proto, IP4_PROTOCOL_SIGNATURE)
|
||||
|
||||
#define IP4_SERVICE_FROM_PROTOCOL(Sb) \
|
||||
CR ((Sb), IP4_SERVICE, ServiceBinding, IP4_SERVICE_SIGNATURE)
|
||||
|
||||
#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
|
||||
|
||||
extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
|
||||
|
||||
EFI_STATUS
|
||||
Ip4ServiceConfigMnp (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN BOOLEAN Force
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4InitProtocol (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4CleanProtocol (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Cancel (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN EFI_IP4_COMPLETION_TOKEN *Token
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Groups (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv4_ADDRESS *GroupAddress
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4TimerTicking (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4SentPacketTicking (
|
||||
IN NET_MAP *Map,
|
||||
IN NET_MAP_ITEM *Item,
|
||||
IN VOID *Context
|
||||
);
|
||||
#endif
|
||||
|
@@ -1,138 +1,138 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Input.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_INPUT_H__
|
||||
#define __EFI_IP4_INPUT_H__
|
||||
|
||||
enum {
|
||||
IP4_MIN_HEADLEN = 20,
|
||||
IP4_MAX_HEADLEN = 60,
|
||||
|
||||
IP4_ASSEMLE_HASH_SIZE = 31,
|
||||
IP4_FRAGMENT_LIFE = 120,
|
||||
IP4_MAX_PACKET_SIZE = 65535
|
||||
};
|
||||
|
||||
//
|
||||
// Per packet information for input process. LinkFlag specifies whether
|
||||
// the packet is received as Link layer unicast, multicast or broadcast.
|
||||
// The CastType is the IP layer cast type, such as IP multicast or unicast.
|
||||
// Start, End and Length are staffs used to assemble the packets. Start
|
||||
// is the sequence number of the first byte of data in the packet. Length
|
||||
// is the number of bytes of data. End = Start + Length, that is, the
|
||||
// sequence number of last byte + 1. Each assembled packet has a count down
|
||||
// life. If it isn't consumed before Life reaches zero, the packet is released.
|
||||
//
|
||||
typedef struct {
|
||||
UINTN LinkFlag;
|
||||
INTN CastType;
|
||||
INTN Start;
|
||||
INTN End;
|
||||
INTN Length;
|
||||
UINT32 Life;
|
||||
EFI_STATUS Status;
|
||||
} IP4_CLIP_INFO;
|
||||
|
||||
//
|
||||
// Structure used to assemble IP packets.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
|
||||
//
|
||||
// Identity of one IP4 packet. Each fragment of a packet has
|
||||
// the same (Dst, Src, Id, Protocol).
|
||||
//
|
||||
IP4_ADDR Dst;
|
||||
IP4_ADDR Src;
|
||||
UINT16 Id;
|
||||
UINT8 Protocol;
|
||||
|
||||
INTN TotalLen;
|
||||
INTN CurLen;
|
||||
NET_LIST_ENTRY Fragments; // List of all the fragments of this packet
|
||||
|
||||
IP4_HEAD *Head; // IP head of the first fragment
|
||||
IP4_CLIP_INFO *Info; // Per packet info of the first fragment
|
||||
INTN Life; // Count down life for the packet.
|
||||
} IP4_ASSEMBLE_ENTRY;
|
||||
|
||||
//
|
||||
// Each Ip service instance has an assemble table to reassemble
|
||||
// the packets before delivery to its children. It is organized
|
||||
// as hash table.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];
|
||||
} IP4_ASSEMBLE_TABLE;
|
||||
|
||||
#define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))
|
||||
|
||||
#define IP4_ASSEMBLE_HASH(Dst, Src, Id, Proto) \
|
||||
(((Dst) + (Src) + ((Id) << 16) + (Proto)) % IP4_ASSEMLE_HASH_SIZE)
|
||||
|
||||
#define IP4_RXDATA_WRAP_SIZE(NumFrag) \
|
||||
(sizeof (IP4_RXDATA_WRAP) + sizeof (EFI_IP4_FRAGMENT_DATA) * ((NumFrag) - 1))
|
||||
|
||||
VOID
|
||||
Ip4InitAssembleTable (
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CleanAssembleTable (
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4AccpetFrame (
|
||||
IN IP4_PROTOCOL *Ip4Instance,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 Flag,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Demultiplex (
|
||||
IN IP4_SERVICE *SbInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
|
||||
INTN
|
||||
Ip4InterfaceEnquePacket (
|
||||
IN IP4_SERVICE *SbInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_INTERFACE *Interface
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4InstanceDeliverPacket (
|
||||
IN IP4_PROTOCOL *Ip4Instance
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4PacketTimerTicking (
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
#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:
|
||||
|
||||
Ip4Input.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_INPUT_H__
|
||||
#define __EFI_IP4_INPUT_H__
|
||||
|
||||
enum {
|
||||
IP4_MIN_HEADLEN = 20,
|
||||
IP4_MAX_HEADLEN = 60,
|
||||
|
||||
IP4_ASSEMLE_HASH_SIZE = 31,
|
||||
IP4_FRAGMENT_LIFE = 120,
|
||||
IP4_MAX_PACKET_SIZE = 65535
|
||||
};
|
||||
|
||||
//
|
||||
// Per packet information for input process. LinkFlag specifies whether
|
||||
// the packet is received as Link layer unicast, multicast or broadcast.
|
||||
// The CastType is the IP layer cast type, such as IP multicast or unicast.
|
||||
// Start, End and Length are staffs used to assemble the packets. Start
|
||||
// is the sequence number of the first byte of data in the packet. Length
|
||||
// is the number of bytes of data. End = Start + Length, that is, the
|
||||
// sequence number of last byte + 1. Each assembled packet has a count down
|
||||
// life. If it isn't consumed before Life reaches zero, the packet is released.
|
||||
//
|
||||
typedef struct {
|
||||
UINTN LinkFlag;
|
||||
INTN CastType;
|
||||
INTN Start;
|
||||
INTN End;
|
||||
INTN Length;
|
||||
UINT32 Life;
|
||||
EFI_STATUS Status;
|
||||
} IP4_CLIP_INFO;
|
||||
|
||||
//
|
||||
// Structure used to assemble IP packets.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
|
||||
//
|
||||
// Identity of one IP4 packet. Each fragment of a packet has
|
||||
// the same (Dst, Src, Id, Protocol).
|
||||
//
|
||||
IP4_ADDR Dst;
|
||||
IP4_ADDR Src;
|
||||
UINT16 Id;
|
||||
UINT8 Protocol;
|
||||
|
||||
INTN TotalLen;
|
||||
INTN CurLen;
|
||||
NET_LIST_ENTRY Fragments; // List of all the fragments of this packet
|
||||
|
||||
IP4_HEAD *Head; // IP head of the first fragment
|
||||
IP4_CLIP_INFO *Info; // Per packet info of the first fragment
|
||||
INTN Life; // Count down life for the packet.
|
||||
} IP4_ASSEMBLE_ENTRY;
|
||||
|
||||
//
|
||||
// Each Ip service instance has an assemble table to reassemble
|
||||
// the packets before delivery to its children. It is organized
|
||||
// as hash table.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];
|
||||
} IP4_ASSEMBLE_TABLE;
|
||||
|
||||
#define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))
|
||||
|
||||
#define IP4_ASSEMBLE_HASH(Dst, Src, Id, Proto) \
|
||||
(((Dst) + (Src) + ((Id) << 16) + (Proto)) % IP4_ASSEMLE_HASH_SIZE)
|
||||
|
||||
#define IP4_RXDATA_WRAP_SIZE(NumFrag) \
|
||||
(sizeof (IP4_RXDATA_WRAP) + sizeof (EFI_IP4_FRAGMENT_DATA) * ((NumFrag) - 1))
|
||||
|
||||
VOID
|
||||
Ip4InitAssembleTable (
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CleanAssembleTable (
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4AccpetFrame (
|
||||
IN IP4_PROTOCOL *Ip4Instance,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 Flag,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Demultiplex (
|
||||
IN IP4_SERVICE *SbInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
|
||||
INTN
|
||||
Ip4InterfaceEnquePacket (
|
||||
IN IP4_SERVICE *SbInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_INTERFACE *Interface
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4InstanceDeliverPacket (
|
||||
IN IP4_PROTOCOL *Ip4Instance
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4PacketTimerTicking (
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -1,52 +1,52 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Option.h
|
||||
|
||||
Abstract:
|
||||
|
||||
IP4 option support routines.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_OPTION_H__
|
||||
#define __EFI_IP4_OPTION_H__
|
||||
|
||||
enum {
|
||||
IP4_OPTION_EOP = 0,
|
||||
IP4_OPTION_NOP = 1,
|
||||
IP4_OPTION_LSRR = 131, // Loss source and record routing, 10000011
|
||||
IP4_OPTION_SSRR = 137, // Strict source and record routing, 10001001
|
||||
IP4_OPTION_RR = 7, // Record routing, 00000111
|
||||
|
||||
IP4_OPTION_COPY_MASK = 0x80
|
||||
};
|
||||
|
||||
BOOLEAN
|
||||
Ip4OptionIsValid (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN BOOLEAN Rcvd
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4CopyOption (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN BOOLEAN Fragment,
|
||||
IN UINT8 *Buf, OPTIONAL
|
||||
IN OUT UINT32 *BufLen
|
||||
);
|
||||
#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:
|
||||
|
||||
Ip4Option.h
|
||||
|
||||
Abstract:
|
||||
|
||||
IP4 option support routines.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_OPTION_H__
|
||||
#define __EFI_IP4_OPTION_H__
|
||||
|
||||
enum {
|
||||
IP4_OPTION_EOP = 0,
|
||||
IP4_OPTION_NOP = 1,
|
||||
IP4_OPTION_LSRR = 131, // Loss source and record routing, 10000011
|
||||
IP4_OPTION_SSRR = 137, // Strict source and record routing, 10001001
|
||||
IP4_OPTION_RR = 7, // Record routing, 00000111
|
||||
|
||||
IP4_OPTION_COPY_MASK = 0x80
|
||||
};
|
||||
|
||||
BOOLEAN
|
||||
Ip4OptionIsValid (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN BOOLEAN Rcvd
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4CopyOption (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN BOOLEAN Fragment,
|
||||
IN UINT8 *Buf, OPTIONAL
|
||||
IN OUT UINT32 *BufLen
|
||||
);
|
||||
#endif
|
||||
|
@@ -1,54 +1,54 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Output.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_OUTPUT_H__
|
||||
#define __EFI_IP4_OUTPUT_H__
|
||||
|
||||
VOID
|
||||
Ip4SysPacketSent (
|
||||
IP4_PROTOCOL *Ip4Instance,
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 Flag,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Output (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
IN NET_BUF *Data,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN IP4_FRAME_CALLBACK Callback,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CancelPacket (
|
||||
IN IP4_INTERFACE *IpIf,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus
|
||||
);
|
||||
|
||||
extern UINT16 mIp4Id;
|
||||
#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:
|
||||
|
||||
Ip4Output.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_OUTPUT_H__
|
||||
#define __EFI_IP4_OUTPUT_H__
|
||||
|
||||
VOID
|
||||
Ip4SysPacketSent (
|
||||
IP4_PROTOCOL *Ip4Instance,
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 Flag,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4Output (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance, OPTIONAL
|
||||
IN NET_BUF *Data,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN IP4_FRAME_CALLBACK Callback,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4CancelPacket (
|
||||
IN IP4_INTERFACE *IpIf,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus
|
||||
);
|
||||
|
||||
extern UINT16 mIp4Id;
|
||||
#endif
|
||||
|
@@ -1,151 +1,151 @@
|
||||
/** @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:
|
||||
|
||||
Ip4Route.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI IP4 route table and route cache table defintions.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_ROUTE_H__
|
||||
#define __EFI_IP4_ROUTE_H__
|
||||
|
||||
#include "IP4Common.h"
|
||||
|
||||
enum {
|
||||
IP4_DIRECT_ROUTE = 0x00000001,
|
||||
|
||||
IP4_ROUTE_CACHE_HASH = 31,
|
||||
IP4_ROUTE_CACHE_MAX = 64 // Max NO. of cache entry per hash bucket
|
||||
};
|
||||
|
||||
#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH)
|
||||
|
||||
//
|
||||
// The route entry in the route table. Dest/Netmask is the destion
|
||||
// network. The nexthop is the gateway to send the packet to in
|
||||
// order to reach the Dest/Netmask. If the Flag has IP4_DIRECT_ROUTE
|
||||
// on, the gateway is the destination of the IP packet itself. Route
|
||||
// enties of the connected network have the flag on.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Netmask;
|
||||
IP4_ADDR NextHop;
|
||||
UINT32 Flag;
|
||||
} IP4_ROUTE_ENTRY;
|
||||
|
||||
//
|
||||
// The route cache entry. The route cache entry is optional.
|
||||
// But it is necessary to support the ICMP redirect message.
|
||||
// Check Ip4ProcessIcmpRedirect for information.
|
||||
//
|
||||
// The cache entry field Tag is used to tag all the route
|
||||
// cache entry spawned from a route table entry. This makes
|
||||
// it simple to delete all the route cache entries from a
|
||||
// to-be-deleted route entry.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Src;
|
||||
IP4_ADDR NextHop;
|
||||
UINTN Tag;
|
||||
} IP4_ROUTE_CACHE_ENTRY;
|
||||
|
||||
//
|
||||
// The route cache table is organized as a hash table. Each
|
||||
// IP4 route table has a embedded route cache. For now the
|
||||
// route cache and route table are binded togehter. But keep
|
||||
// the route cache a seperated structure in case we want to
|
||||
// detach them later.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH];
|
||||
} IP4_ROUTE_CACHE;
|
||||
|
||||
//
|
||||
// Each IP4 instance has its own route table. Each ServiceBinding
|
||||
// instance has a default route table and default address.
|
||||
//
|
||||
// All the route table entries with the same mask are linked
|
||||
// together in one route area. For example, RouteArea[0] contains
|
||||
// the default routes. A route table also contains a route cache.
|
||||
//
|
||||
typedef struct _IP4_ROUTE_TABLE IP4_ROUTE_TABLE;
|
||||
|
||||
struct _IP4_ROUTE_TABLE {
|
||||
INTN RefCnt;
|
||||
UINT32 TotalNum;
|
||||
NET_LIST_ENTRY RouteArea[IP4_MASK_NUM];
|
||||
IP4_ROUTE_TABLE *Next;
|
||||
IP4_ROUTE_CACHE Cache;
|
||||
};
|
||||
|
||||
IP4_ROUTE_TABLE*
|
||||
Ip4CreateRouteTable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4FreeRouteTable (
|
||||
IN IP4_ROUTE_TABLE *RouteTable
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4AddRoute (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4DelRoute (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
);
|
||||
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4FindRouteCache (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4FreeRouteCacheEntry (
|
||||
IN IP4_ROUTE_CACHE_ENTRY *RtCacheEntry
|
||||
);
|
||||
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4Route (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4BuildEfiRouteTable (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
#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:
|
||||
|
||||
Ip4Route.h
|
||||
|
||||
Abstract:
|
||||
|
||||
EFI IP4 route table and route cache table defintions.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_IP4_ROUTE_H__
|
||||
#define __EFI_IP4_ROUTE_H__
|
||||
|
||||
#include "IP4Common.h"
|
||||
|
||||
enum {
|
||||
IP4_DIRECT_ROUTE = 0x00000001,
|
||||
|
||||
IP4_ROUTE_CACHE_HASH = 31,
|
||||
IP4_ROUTE_CACHE_MAX = 64 // Max NO. of cache entry per hash bucket
|
||||
};
|
||||
|
||||
#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH)
|
||||
|
||||
//
|
||||
// The route entry in the route table. Dest/Netmask is the destion
|
||||
// network. The nexthop is the gateway to send the packet to in
|
||||
// order to reach the Dest/Netmask. If the Flag has IP4_DIRECT_ROUTE
|
||||
// on, the gateway is the destination of the IP packet itself. Route
|
||||
// enties of the connected network have the flag on.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Netmask;
|
||||
IP4_ADDR NextHop;
|
||||
UINT32 Flag;
|
||||
} IP4_ROUTE_ENTRY;
|
||||
|
||||
//
|
||||
// The route cache entry. The route cache entry is optional.
|
||||
// But it is necessary to support the ICMP redirect message.
|
||||
// Check Ip4ProcessIcmpRedirect for information.
|
||||
//
|
||||
// The cache entry field Tag is used to tag all the route
|
||||
// cache entry spawned from a route table entry. This makes
|
||||
// it simple to delete all the route cache entries from a
|
||||
// to-be-deleted route entry.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Src;
|
||||
IP4_ADDR NextHop;
|
||||
UINTN Tag;
|
||||
} IP4_ROUTE_CACHE_ENTRY;
|
||||
|
||||
//
|
||||
// The route cache table is organized as a hash table. Each
|
||||
// IP4 route table has a embedded route cache. For now the
|
||||
// route cache and route table are binded togehter. But keep
|
||||
// the route cache a seperated structure in case we want to
|
||||
// detach them later.
|
||||
//
|
||||
typedef struct {
|
||||
NET_LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH];
|
||||
} IP4_ROUTE_CACHE;
|
||||
|
||||
//
|
||||
// Each IP4 instance has its own route table. Each ServiceBinding
|
||||
// instance has a default route table and default address.
|
||||
//
|
||||
// All the route table entries with the same mask are linked
|
||||
// together in one route area. For example, RouteArea[0] contains
|
||||
// the default routes. A route table also contains a route cache.
|
||||
//
|
||||
typedef struct _IP4_ROUTE_TABLE IP4_ROUTE_TABLE;
|
||||
|
||||
struct _IP4_ROUTE_TABLE {
|
||||
INTN RefCnt;
|
||||
UINT32 TotalNum;
|
||||
NET_LIST_ENTRY RouteArea[IP4_MASK_NUM];
|
||||
IP4_ROUTE_TABLE *Next;
|
||||
IP4_ROUTE_CACHE Cache;
|
||||
};
|
||||
|
||||
IP4_ROUTE_TABLE*
|
||||
Ip4CreateRouteTable (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4FreeRouteTable (
|
||||
IN IP4_ROUTE_TABLE *RouteTable
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4AddRoute (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4DelRoute (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
);
|
||||
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4FindRouteCache (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
VOID
|
||||
Ip4FreeRouteCacheEntry (
|
||||
IN IP4_ROUTE_CACHE_ENTRY *RtCacheEntry
|
||||
);
|
||||
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4Route (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Ip4BuildEfiRouteTable (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user