NetworkPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the NetworkPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
2f88bd3a12
commit
d1050b9dff
@@ -10,6 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@@ -57,7 +58,6 @@ Ip4ComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@@ -129,14 +129,13 @@ Ip4ComponentNameGetDriverName (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4ComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@@ -149,14 +148,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ComponentName = {
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ip4ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ip4ComponentNameGetControllerName,
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Ip4ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Ip4ComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable[] = {
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4DriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
L"IP4 Network Service Driver"
|
||||
@@ -223,7 +221,6 @@ Ip4ComponentNameGetDriverName (
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gIp4ComponentName)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,12 +235,12 @@ Ip4ComponentNameGetDriverName (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UpdateName (
|
||||
IN EFI_IP4_PROTOCOL *Ip4
|
||||
IN EFI_IP4_PROTOCOL *Ip4
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR16 HandleName[80];
|
||||
EFI_IP4_MODE_DATA Ip4ModeData;
|
||||
EFI_STATUS Status;
|
||||
CHAR16 HandleName[80];
|
||||
EFI_IP4_MODE_DATA Ip4ModeData;
|
||||
|
||||
if (Ip4 == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -261,7 +258,9 @@ UpdateName (
|
||||
if (!Ip4ModeData.IsStarted || !Ip4ModeData.IsConfigured) {
|
||||
UnicodeSPrint (HandleName, sizeof (HandleName), L"IPv4 (Not started)");
|
||||
} else {
|
||||
UnicodeSPrint (HandleName, sizeof (HandleName),
|
||||
UnicodeSPrint (
|
||||
HandleName,
|
||||
sizeof (HandleName),
|
||||
L"IPv4 (SrcIP=%d.%d.%d.%d)",
|
||||
Ip4ModeData.ConfigData.StationAddress.Addr[0],
|
||||
Ip4ModeData.ConfigData.StationAddress.Addr[1],
|
||||
@@ -274,6 +273,7 @@ UpdateName (
|
||||
FreeUnicodeStringTable (gIp4ControllerNameTable);
|
||||
gIp4ControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
Status = AddUnicodeString2 (
|
||||
"eng",
|
||||
gIp4ComponentName.SupportedLanguages,
|
||||
@@ -365,15 +365,15 @@ UpdateName (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4ComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_IP4_PROTOCOL *Ip4;
|
||||
EFI_STATUS Status;
|
||||
EFI_IP4_PROTOCOL *Ip4;
|
||||
|
||||
//
|
||||
// Only provide names for child handles.
|
||||
@@ -425,4 +425,3 @@ Ip4ComponentNameGetControllerName (
|
||||
(BOOLEAN)(This == &gIp4ComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Return the cast type (Unicast/Broadcast) specific to an
|
||||
interface. All the addresses are host byte ordered.
|
||||
@@ -25,25 +24,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
INTN
|
||||
Ip4GetNetCast (
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
)
|
||||
{
|
||||
if (IpAddr == IpIf->Ip) {
|
||||
return IP4_LOCAL_HOST;
|
||||
|
||||
} else if (IpAddr == IpIf->SubnetBrdcast) {
|
||||
return IP4_SUBNET_BROADCAST;
|
||||
|
||||
} else if (IpAddr == IpIf->NetBrdcast) {
|
||||
return IP4_NET_BROADCAST;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the cast type of the packet related to the local host.
|
||||
This isn't the same as link layer cast type. For example, DHCP
|
||||
@@ -62,15 +57,15 @@ Ip4GetNetCast (
|
||||
**/
|
||||
INTN
|
||||
Ip4GetHostCast (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
INTN Type;
|
||||
INTN Class;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
INTN Type;
|
||||
INTN Class;
|
||||
|
||||
Type = 0;
|
||||
|
||||
@@ -106,18 +101,16 @@ Ip4GetHostCast (
|
||||
if (Dst == IP4_ALLONE_ADDRESS) {
|
||||
IpIf = Ip4FindNet (IpSb, Src);
|
||||
|
||||
if (IpIf != NULL && !IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf))) {
|
||||
if ((IpIf != NULL) && !IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf))) {
|
||||
return IP4_LOCAL_BROADCAST;
|
||||
}
|
||||
|
||||
} else if (IP4_IS_MULTICAST (Dst) && Ip4FindGroup (&IpSb->IgmpCtrl, Dst) != NULL) {
|
||||
} else if (IP4_IS_MULTICAST (Dst) && (Ip4FindGroup (&IpSb->IgmpCtrl, Dst) != NULL)) {
|
||||
return IP4_MULTICAST;
|
||||
}
|
||||
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find an interface whose configured IP address is Ip.
|
||||
|
||||
@@ -129,12 +122,12 @@ Ip4GetHostCast (
|
||||
**/
|
||||
IP4_INTERFACE *
|
||||
Ip4FindInterface (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
|
||||
IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
|
||||
@@ -147,7 +140,6 @@ Ip4FindInterface (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find an interface that Ip is on that connected network.
|
||||
|
||||
@@ -159,12 +151,12 @@ Ip4FindInterface (
|
||||
**/
|
||||
IP4_INTERFACE *
|
||||
Ip4FindNet (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
|
||||
IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
|
||||
@@ -177,7 +169,6 @@ Ip4FindNet (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find an interface of the service with the same Ip/Netmask pair.
|
||||
|
||||
@@ -190,13 +181,13 @@ Ip4FindNet (
|
||||
**/
|
||||
IP4_INTERFACE *
|
||||
Ip4FindStationAddress (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
|
||||
IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
|
||||
@@ -209,7 +200,6 @@ Ip4FindStationAddress (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the MAC address for a multicast IP address. Call
|
||||
Mnp's McastIpToMac to find the MAC address in stead of
|
||||
@@ -226,18 +216,17 @@ Ip4FindStationAddress (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4GetMulticastMac (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN IP4_ADDR Multicast,
|
||||
OUT EFI_MAC_ADDRESS *Mac
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN IP4_ADDR Multicast,
|
||||
OUT EFI_MAC_ADDRESS *Mac
|
||||
)
|
||||
{
|
||||
EFI_IP_ADDRESS EfiIp;
|
||||
EFI_IP_ADDRESS EfiIp;
|
||||
|
||||
EFI_IP4 (EfiIp.v4) = HTONL (Multicast);
|
||||
return Mnp->McastIpToMac (Mnp, FALSE, &EfiIp, Mac);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert the multibyte field in IP header's byter order.
|
||||
In spite of its name, it can also be used to convert from
|
||||
@@ -250,19 +239,18 @@ Ip4GetMulticastMac (
|
||||
**/
|
||||
IP4_HEAD *
|
||||
Ip4NtohHead (
|
||||
IN IP4_HEAD *Head
|
||||
IN IP4_HEAD *Head
|
||||
)
|
||||
{
|
||||
Head->TotalLen = NTOHS (Head->TotalLen);
|
||||
Head->Id = NTOHS (Head->Id);
|
||||
Head->Fragment = NTOHS (Head->Fragment);
|
||||
Head->Src = NTOHL (Head->Src);
|
||||
Head->Dst = NTOHL (Head->Dst);
|
||||
Head->TotalLen = NTOHS (Head->TotalLen);
|
||||
Head->Id = NTOHS (Head->Id);
|
||||
Head->Fragment = NTOHS (Head->Fragment);
|
||||
Head->Src = NTOHL (Head->Src);
|
||||
Head->Dst = NTOHL (Head->Dst);
|
||||
|
||||
return Head;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Validate that Ip/Netmask pair is OK to be used as station
|
||||
address. Only continuous netmasks are supported. and check
|
||||
@@ -277,15 +265,15 @@ Ip4NtohHead (
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4StationAddressValid (
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
)
|
||||
{
|
||||
//
|
||||
// Only support the station address with 0.0.0.0/0 to enable DHCP client.
|
||||
//
|
||||
if (Netmask == IP4_ALLZERO_ADDRESS) {
|
||||
return (BOOLEAN) (Ip == IP4_ALLZERO_ADDRESS);
|
||||
return (BOOLEAN)(Ip == IP4_ALLZERO_ADDRESS);
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -13,14 +13,14 @@ typedef struct _IP4_INTERFACE IP4_INTERFACE;
|
||||
typedef struct _IP4_PROTOCOL IP4_PROTOCOL;
|
||||
typedef struct _IP4_SERVICE IP4_SERVICE;
|
||||
|
||||
#define IP4_ETHER_PROTO 0x0800
|
||||
#define IP4_ETHER_PROTO 0x0800
|
||||
|
||||
//
|
||||
// The packet is received as link level broadcast/multicast/promiscuous.
|
||||
//
|
||||
#define IP4_LINK_BROADCAST 0x00000001
|
||||
#define IP4_LINK_MULTICAST 0x00000002
|
||||
#define IP4_LINK_PROMISC 0x00000004
|
||||
#define IP4_LINK_BROADCAST 0x00000001
|
||||
#define IP4_LINK_MULTICAST 0x00000002
|
||||
#define IP4_LINK_PROMISC 0x00000004
|
||||
|
||||
//
|
||||
// IP4 address cast type classification. Keep it true that any
|
||||
@@ -40,10 +40,10 @@ typedef struct _IP4_SERVICE IP4_SERVICE;
|
||||
#define IP4_HEAD_MF_MASK 0x2000
|
||||
#define 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
|
||||
#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.
|
||||
@@ -60,13 +60,13 @@ typedef struct _IP4_SERVICE IP4_SERVICE;
|
||||
#define IP4_DO_NOT_FRAGMENT(FragmentField) \
|
||||
((BOOLEAN)(((FragmentField) & IP4_HEAD_DF_MASK) == IP4_HEAD_DF_MASK))
|
||||
|
||||
#define IP4_IS_BROADCAST(CastType) ((CastType) >= IP4_LOCAL_BROADCAST)
|
||||
#define IP4_IS_BROADCAST(CastType) ((CastType) >= IP4_LOCAL_BROADCAST)
|
||||
|
||||
///
|
||||
/// Convert 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)
|
||||
#define IP4_US_TO_SEC(Us) (((Us) + 999999) / 1000000)
|
||||
|
||||
/**
|
||||
Return the cast type (Unicast/Broadcast) specific to an
|
||||
@@ -85,8 +85,8 @@ typedef struct _IP4_SERVICE IP4_SERVICE;
|
||||
**/
|
||||
INTN
|
||||
Ip4GetNetCast (
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -107,9 +107,9 @@ Ip4GetNetCast (
|
||||
**/
|
||||
INTN
|
||||
Ip4GetHostCast (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -123,8 +123,8 @@ Ip4GetHostCast (
|
||||
**/
|
||||
IP4_INTERFACE *
|
||||
Ip4FindInterface (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -138,8 +138,8 @@ Ip4FindInterface (
|
||||
**/
|
||||
IP4_INTERFACE *
|
||||
Ip4FindNet (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -154,9 +154,9 @@ Ip4FindNet (
|
||||
**/
|
||||
IP4_INTERFACE *
|
||||
Ip4FindStationAddress (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -175,9 +175,9 @@ Ip4FindStationAddress (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4GetMulticastMac (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN IP4_ADDR Multicast,
|
||||
OUT EFI_MAC_ADDRESS *Mac
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
|
||||
IN IP4_ADDR Multicast,
|
||||
OUT EFI_MAC_ADDRESS *Mac
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -192,10 +192,9 @@ Ip4GetMulticastMac (
|
||||
**/
|
||||
IP4_HEAD *
|
||||
Ip4NtohHead (
|
||||
IN IP4_HEAD *Head
|
||||
IN IP4_HEAD *Head
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Validate that Ip/Netmask pair is OK to be used as station
|
||||
address. Only continuous netmasks are supported. and check
|
||||
@@ -210,8 +209,8 @@ Ip4NtohHead (
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4StationAddressValid (
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
IN IP4_ADDR Ip,
|
||||
IN IP4_ADDR Netmask
|
||||
);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -14,14 +14,14 @@
|
||||
#define IP4_CONFIG2_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', 'C', '2')
|
||||
#define IP4_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'F', 'C', 'I')
|
||||
|
||||
#define IP4_CONFIG2_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
|
||||
#define IP4_CONFIG2_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
|
||||
|
||||
#define DATA_ATTRIB_SIZE_FIXED 0x1
|
||||
#define DATA_ATTRIB_VOLATILE 0x2
|
||||
#define DATA_ATTRIB_SIZE_FIXED 0x1
|
||||
#define DATA_ATTRIB_VOLATILE 0x2
|
||||
|
||||
#define DATA_ATTRIB_SET(Attrib, Bits) (BOOLEAN)((Attrib) & (Bits))
|
||||
#define SET_DATA_ATTRIB(Attrib, Bits) ((Attrib) |= (Bits))
|
||||
#define REMOVE_DATA_ATTRIB(Attrib, Bits) ((Attrib) &= (~Bits))
|
||||
#define DATA_ATTRIB_SET(Attrib, Bits) (BOOLEAN)((Attrib) & (Bits))
|
||||
#define SET_DATA_ATTRIB(Attrib, Bits) ((Attrib) |= (Bits))
|
||||
#define REMOVE_DATA_ATTRIB(Attrib, Bits) ((Attrib) &= (~Bits))
|
||||
|
||||
typedef struct _IP4_CONFIG2_INSTANCE IP4_CONFIG2_INSTANCE;
|
||||
|
||||
@@ -69,9 +69,9 @@ typedef struct _IP4_CONFIG2_INSTANCE IP4_CONFIG2_INSTANCE;
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*IP4_CONFIG2_SET_DATA) (
|
||||
IN IP4_CONFIG2_INSTANCE *Instance,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
IN IP4_CONFIG2_INSTANCE *Instance,
|
||||
IN UINTN DataSize,
|
||||
IN VOID *Data
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -93,34 +93,34 @@ EFI_STATUS
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*IP4_CONFIG2_GET_DATA) (
|
||||
IN IP4_CONFIG2_INSTANCE *Instance,
|
||||
IN OUT UINTN *DataSize,
|
||||
IN VOID *Data OPTIONAL
|
||||
IN IP4_CONFIG2_INSTANCE *Instance,
|
||||
IN OUT UINTN *DataSize,
|
||||
IN VOID *Data OPTIONAL
|
||||
);
|
||||
|
||||
typedef union {
|
||||
VOID *Ptr;
|
||||
EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;
|
||||
EFI_IP4_CONFIG2_POLICY *Policy;
|
||||
EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress;
|
||||
EFI_IPv4_ADDRESS *Gateway;
|
||||
EFI_IPv4_ADDRESS *DnsServers;
|
||||
VOID *Ptr;
|
||||
EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;
|
||||
EFI_IP4_CONFIG2_POLICY *Policy;
|
||||
EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress;
|
||||
EFI_IPv4_ADDRESS *Gateway;
|
||||
EFI_IPv4_ADDRESS *DnsServers;
|
||||
} IP4_CONFIG2_DATA;
|
||||
|
||||
typedef struct {
|
||||
IP4_CONFIG2_SET_DATA SetData;
|
||||
IP4_CONFIG2_GET_DATA GetData;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Attribute;
|
||||
NET_MAP EventMap;
|
||||
IP4_CONFIG2_DATA Data;
|
||||
UINTN DataSize;
|
||||
IP4_CONFIG2_SET_DATA SetData;
|
||||
IP4_CONFIG2_GET_DATA GetData;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Attribute;
|
||||
NET_MAP EventMap;
|
||||
IP4_CONFIG2_DATA Data;
|
||||
UINTN DataSize;
|
||||
} IP4_CONFIG2_DATA_ITEM;
|
||||
|
||||
typedef struct {
|
||||
UINT16 Offset;
|
||||
UINT32 DataSize;
|
||||
EFI_IP4_CONFIG2_DATA_TYPE DataType;
|
||||
UINT16 Offset;
|
||||
UINT32 DataSize;
|
||||
EFI_IP4_CONFIG2_DATA_TYPE DataType;
|
||||
} IP4_CONFIG2_DATA_RECORD;
|
||||
|
||||
#pragma pack(1)
|
||||
@@ -137,57 +137,57 @@ typedef struct {
|
||||
// EFI_IPv4_ADDRESS DnsServers[];
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Checksum;
|
||||
UINT16 DataRecordCount;
|
||||
IP4_CONFIG2_DATA_RECORD DataRecord[1];
|
||||
UINT16 Checksum;
|
||||
UINT16 DataRecordCount;
|
||||
IP4_CONFIG2_DATA_RECORD DataRecord[1];
|
||||
} IP4_CONFIG2_VARIABLE;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
typedef struct {
|
||||
EFI_IP4_CONFIG2_POLICY Policy; ///< manual or automatic
|
||||
EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress; ///< IP addresses
|
||||
UINT32 ManualAddressCount; ///< IP addresses count
|
||||
EFI_IPv4_ADDRESS *GatewayAddress; ///< Gateway address
|
||||
UINT32 GatewayAddressCount; ///< Gateway address count
|
||||
EFI_IPv4_ADDRESS *DnsAddress; ///< DNS server address
|
||||
UINT32 DnsAddressCount; ///< DNS server address count
|
||||
EFI_IP4_CONFIG2_POLICY Policy; ///< manual or automatic
|
||||
EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress; ///< IP addresses
|
||||
UINT32 ManualAddressCount; ///< IP addresses count
|
||||
EFI_IPv4_ADDRESS *GatewayAddress; ///< Gateway address
|
||||
UINT32 GatewayAddressCount; ///< Gateway address count
|
||||
EFI_IPv4_ADDRESS *DnsAddress; ///< DNS server address
|
||||
UINT32 DnsAddressCount; ///< DNS server address count
|
||||
} IP4_CONFIG2_NVDATA;
|
||||
|
||||
typedef struct _IP4_FORM_CALLBACK_INFO {
|
||||
UINT32 Signature;
|
||||
EFI_HANDLE ChildHandle;
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccessProtocol;
|
||||
EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
|
||||
EFI_HII_HANDLE RegisteredHandle;
|
||||
UINT32 Signature;
|
||||
EFI_HANDLE ChildHandle;
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccessProtocol;
|
||||
EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
|
||||
EFI_HII_HANDLE RegisteredHandle;
|
||||
} IP4_FORM_CALLBACK_INFO;
|
||||
|
||||
struct _IP4_CONFIG2_INSTANCE {
|
||||
UINT32 Signature;
|
||||
BOOLEAN Configured;
|
||||
LIST_ENTRY Link;
|
||||
UINT16 IfIndex;
|
||||
UINT32 Signature;
|
||||
BOOLEAN Configured;
|
||||
LIST_ENTRY Link;
|
||||
UINT16 IfIndex;
|
||||
|
||||
EFI_IP4_CONFIG2_PROTOCOL Ip4Config2;
|
||||
EFI_IP4_CONFIG2_PROTOCOL Ip4Config2;
|
||||
|
||||
EFI_IP4_CONFIG2_INTERFACE_INFO InterfaceInfo;
|
||||
EFI_IP4_CONFIG2_POLICY Policy;
|
||||
IP4_CONFIG2_DATA_ITEM DataItem[Ip4Config2DataTypeMaximum];
|
||||
EFI_IP4_CONFIG2_INTERFACE_INFO InterfaceInfo;
|
||||
EFI_IP4_CONFIG2_POLICY Policy;
|
||||
IP4_CONFIG2_DATA_ITEM DataItem[Ip4Config2DataTypeMaximum];
|
||||
|
||||
EFI_EVENT Dhcp4SbNotifyEvent;
|
||||
VOID *Registration;
|
||||
EFI_HANDLE Dhcp4Handle;
|
||||
EFI_DHCP4_PROTOCOL *Dhcp4;
|
||||
BOOLEAN DhcpSuccess;
|
||||
BOOLEAN OtherInfoOnly;
|
||||
EFI_EVENT Dhcp4Event;
|
||||
UINT32 FailedIaAddressCount;
|
||||
EFI_IPv4_ADDRESS *DeclineAddress;
|
||||
UINT32 DeclineAddressCount;
|
||||
EFI_EVENT Dhcp4SbNotifyEvent;
|
||||
VOID *Registration;
|
||||
EFI_HANDLE Dhcp4Handle;
|
||||
EFI_DHCP4_PROTOCOL *Dhcp4;
|
||||
BOOLEAN DhcpSuccess;
|
||||
BOOLEAN OtherInfoOnly;
|
||||
EFI_EVENT Dhcp4Event;
|
||||
UINT32 FailedIaAddressCount;
|
||||
EFI_IPv4_ADDRESS *DeclineAddress;
|
||||
UINT32 DeclineAddressCount;
|
||||
|
||||
IP4_FORM_CALLBACK_INFO CallbackInfo;
|
||||
IP4_FORM_CALLBACK_INFO CallbackInfo;
|
||||
|
||||
IP4_CONFIG2_NVDATA Ip4NvData;
|
||||
IP4_CONFIG2_NVDATA Ip4NvData;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -196,9 +196,9 @@ struct _IP4_CONFIG2_INSTANCE {
|
||||
//
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
EFI_DHCP4_PACKET_OPTION Head;
|
||||
UINT8 Route;
|
||||
UINT8 Dns;
|
||||
EFI_DHCP4_PACKET_OPTION Head;
|
||||
UINT8 Route;
|
||||
UINT8 Dns;
|
||||
} IP4_CONFIG2_DHCP4_OPTION;
|
||||
#pragma pack()
|
||||
|
||||
@@ -218,8 +218,8 @@ typedef struct {
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Config2ReadConfigData (
|
||||
IN CHAR16 *VarName,
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
IN CHAR16 *VarName,
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -235,7 +235,7 @@ Ip4Config2ReadConfigData (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4StartAutoConfig (
|
||||
IN IP4_CONFIG2_INSTANCE *Instance
|
||||
IN IP4_CONFIG2_INSTANCE *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -273,8 +273,8 @@ Ip4Config2CleanInstance (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4AutoReconfigCallBack (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
CHAR16 mIp4Config2StorageName[] = L"IP4_CONFIG2_IFR_NVDATA";
|
||||
CHAR16 mIp4Config2StorageName[] = L"IP4_CONFIG2_IFR_NVDATA";
|
||||
|
||||
/**
|
||||
Calculate the prefix length of the IPv4 subnet mask.
|
||||
@@ -48,7 +48,7 @@ GetSubnetMaskPrefixLength (
|
||||
Len++;
|
||||
}
|
||||
|
||||
return (UINT8) (32 - Len);
|
||||
return (UINT8)(32 - Len);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,13 +67,12 @@ Ip4Config2StrToIp (
|
||||
OUT EFI_IPv4_ADDRESS *Ip
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Number;
|
||||
UINTN Index;
|
||||
UINTN Number;
|
||||
|
||||
Index = 0;
|
||||
|
||||
while (*Str != L'\0') {
|
||||
|
||||
if (Index > 3) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@@ -88,7 +87,7 @@ Ip4Config2StrToIp (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Ip->Addr[Index] = (UINT8) Number;
|
||||
Ip->Addr[Index] = (UINT8)Number;
|
||||
|
||||
if ((*Str != L'\0') && (*Str != L'.')) {
|
||||
//
|
||||
@@ -134,12 +133,12 @@ Ip4Config2StrToIpList (
|
||||
OUT UINTN *IpCount
|
||||
)
|
||||
{
|
||||
UINTN BeginIndex;
|
||||
UINTN EndIndex;
|
||||
UINTN Index;
|
||||
UINTN IpIndex;
|
||||
CHAR16 *StrTemp;
|
||||
BOOLEAN SpaceTag;
|
||||
UINTN BeginIndex;
|
||||
UINTN EndIndex;
|
||||
UINTN Index;
|
||||
UINTN IpIndex;
|
||||
CHAR16 *StrTemp;
|
||||
BOOLEAN SpaceTag;
|
||||
|
||||
BeginIndex = 0;
|
||||
EndIndex = BeginIndex;
|
||||
@@ -178,7 +177,7 @@ Ip4Config2StrToIpList (
|
||||
//
|
||||
// Allocate buffer for IpList.
|
||||
//
|
||||
*PtrIpList = AllocateZeroPool(*IpCount * sizeof(EFI_IPv4_ADDRESS));
|
||||
*PtrIpList = AllocateZeroPool (*IpCount * sizeof (EFI_IPv4_ADDRESS));
|
||||
if (*PtrIpList == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -189,30 +188,30 @@ Ip4Config2StrToIpList (
|
||||
Index = 0;
|
||||
while (*(Str + Index) != L'\0') {
|
||||
if (*(Str + Index) == L' ') {
|
||||
if(!SpaceTag) {
|
||||
StrTemp = AllocateZeroPool((EndIndex - BeginIndex + 1) * sizeof(CHAR16));
|
||||
if (!SpaceTag) {
|
||||
StrTemp = AllocateZeroPool ((EndIndex - BeginIndex + 1) * sizeof (CHAR16));
|
||||
if (StrTemp == NULL) {
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
*IpCount = 0;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof(CHAR16));
|
||||
CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof (CHAR16));
|
||||
*(StrTemp + (EndIndex - BeginIndex)) = L'\0';
|
||||
|
||||
if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) {
|
||||
FreePool(StrTemp);
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (StrTemp);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
*IpCount = 0;
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
BeginIndex = EndIndex;
|
||||
IpIndex++;
|
||||
|
||||
FreePool(StrTemp);
|
||||
FreePool (StrTemp);
|
||||
}
|
||||
|
||||
BeginIndex++;
|
||||
@@ -227,26 +226,26 @@ Ip4Config2StrToIpList (
|
||||
|
||||
if (*(Str + Index) == L'\0') {
|
||||
if (!SpaceTag) {
|
||||
StrTemp = AllocateZeroPool((EndIndex - BeginIndex + 1) * sizeof(CHAR16));
|
||||
StrTemp = AllocateZeroPool ((EndIndex - BeginIndex + 1) * sizeof (CHAR16));
|
||||
if (StrTemp == NULL) {
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
*IpCount = 0;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof(CHAR16));
|
||||
CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) * sizeof (CHAR16));
|
||||
*(StrTemp + (EndIndex - BeginIndex)) = L'\0';
|
||||
|
||||
if (Ip4Config2StrToIp (StrTemp, &((*PtrIpList)[IpIndex])) != EFI_SUCCESS) {
|
||||
FreePool(StrTemp);
|
||||
FreePool(*PtrIpList);
|
||||
FreePool (StrTemp);
|
||||
FreePool (*PtrIpList);
|
||||
*PtrIpList = NULL;
|
||||
*IpCount = 0;
|
||||
*IpCount = 0;
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FreePool(StrTemp);
|
||||
FreePool (StrTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,7 +277,6 @@ Ip4Config2IpToStr (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert the IPv4 address list into string consists of several decimal
|
||||
dotted IPv4 addresses separated by space.
|
||||
@@ -299,11 +297,11 @@ Ip4Config2IpListToStr (
|
||||
OUT CHAR16 *Str
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN TemIndex;
|
||||
UINTN StrIndex;
|
||||
CHAR16 *TempStr;
|
||||
EFI_IPv4_ADDRESS *TempIp;
|
||||
UINTN Index;
|
||||
UINTN TemIndex;
|
||||
UINTN StrIndex;
|
||||
CHAR16 *TempStr;
|
||||
EFI_IPv4_ADDRESS *TempIp;
|
||||
|
||||
Index = 0;
|
||||
TemIndex = 0;
|
||||
@@ -311,10 +309,10 @@ Ip4Config2IpListToStr (
|
||||
TempStr = NULL;
|
||||
TempIp = NULL;
|
||||
|
||||
for (Index = 0; Index < IpCount; Index ++) {
|
||||
for (Index = 0; Index < IpCount; Index++) {
|
||||
TempIp = Ip + Index;
|
||||
if (TempStr == NULL) {
|
||||
TempStr = AllocateZeroPool(2 * IP4_STR_MAX_SIZE);
|
||||
TempStr = AllocateZeroPool (2 * IP4_STR_MAX_SIZE);
|
||||
if (TempStr == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -330,13 +328,14 @@ Ip4Config2IpListToStr (
|
||||
TempIp->Addr[3]
|
||||
);
|
||||
|
||||
for (TemIndex = 0; TemIndex < IP4_STR_MAX_SIZE; TemIndex ++) {
|
||||
for (TemIndex = 0; TemIndex < IP4_STR_MAX_SIZE; TemIndex++) {
|
||||
if (*(TempStr + TemIndex) == L'\0') {
|
||||
if (Index == IpCount - 1) {
|
||||
Str[StrIndex++] = L'\0';
|
||||
} else {
|
||||
Str[StrIndex++] = L' ';
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
Str[StrIndex++] = *(TempStr + TemIndex);
|
||||
@@ -345,7 +344,7 @@ Ip4Config2IpListToStr (
|
||||
}
|
||||
|
||||
if (TempStr != NULL) {
|
||||
FreePool(TempStr);
|
||||
FreePool (TempStr);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -361,11 +360,11 @@ Ip4Config2IpListToStr (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4Config2ManualAddressNotify (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,21 +381,21 @@ Ip4Config2ManualAddressNotify (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Config2ConvertConfigNvDataToIfrNvData (
|
||||
IN IP4_CONFIG2_INSTANCE *Instance,
|
||||
IN OUT IP4_CONFIG2_IFR_NVDATA *IfrNvData
|
||||
IN IP4_CONFIG2_INSTANCE *Instance,
|
||||
IN OUT IP4_CONFIG2_IFR_NVDATA *IfrNvData
|
||||
)
|
||||
{
|
||||
IP4_SERVICE *IpSb;
|
||||
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
|
||||
EFI_IP4_CONFIG2_INTERFACE_INFO *Ip4Info;
|
||||
EFI_IP4_CONFIG2_POLICY Policy;
|
||||
UINTN DataSize;
|
||||
UINTN GatewaySize;
|
||||
EFI_IPv4_ADDRESS GatewayAddress;
|
||||
EFI_STATUS Status;
|
||||
UINTN DnsSize;
|
||||
UINTN DnsCount;
|
||||
EFI_IPv4_ADDRESS *DnsAddress;
|
||||
IP4_SERVICE *IpSb;
|
||||
EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
|
||||
EFI_IP4_CONFIG2_INTERFACE_INFO *Ip4Info;
|
||||
EFI_IP4_CONFIG2_POLICY Policy;
|
||||
UINTN DataSize;
|
||||
UINTN GatewaySize;
|
||||
EFI_IPv4_ADDRESS GatewayAddress;
|
||||
EFI_STATUS Status;
|
||||
UINTN DnsSize;
|
||||
UINTN DnsCount;
|
||||
EFI_IPv4_ADDRESS *DnsAddress;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Ip4Config2 = &Instance->Ip4Config2;
|
||||
@@ -443,13 +442,13 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
|
||||
//
|
||||
// Get the interface info.
|
||||
//
|
||||
DataSize = 0;
|
||||
Status = Ip4Config2->GetData (
|
||||
Ip4Config2,
|
||||
Ip4Config2DataTypeInterfaceInfo,
|
||||
&DataSize,
|
||||
NULL
|
||||
);
|
||||
DataSize = 0;
|
||||
Status = Ip4Config2->GetData (
|
||||
Ip4Config2,
|
||||
Ip4Config2DataTypeInterfaceInfo,
|
||||
&DataSize,
|
||||
NULL
|
||||
);
|
||||
if (Status != EFI_BUFFER_TOO_SMALL) {
|
||||
return Status;
|
||||
}
|
||||
@@ -487,20 +486,20 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
|
||||
// Get the Dns info.
|
||||
//
|
||||
DnsSize = 0;
|
||||
Status = Ip4Config2->GetData (
|
||||
Ip4Config2,
|
||||
Ip4Config2DataTypeDnsServer,
|
||||
&DnsSize,
|
||||
NULL
|
||||
);
|
||||
Status = Ip4Config2->GetData (
|
||||
Ip4Config2,
|
||||
Ip4Config2DataTypeDnsServer,
|
||||
&DnsSize,
|
||||
NULL
|
||||
);
|
||||
if ((Status != EFI_BUFFER_TOO_SMALL) && (Status != EFI_NOT_FOUND)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
DnsCount = (UINT32) (DnsSize / sizeof (EFI_IPv4_ADDRESS));
|
||||
DnsCount = (UINT32)(DnsSize / sizeof (EFI_IPv4_ADDRESS));
|
||||
|
||||
if (DnsSize > 0) {
|
||||
DnsAddress = AllocateZeroPool(DnsSize);
|
||||
DnsAddress = AllocateZeroPool (DnsSize);
|
||||
if (DnsAddress == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
@@ -525,11 +524,11 @@ Ip4Config2ConvertConfigNvDataToIfrNvData (
|
||||
Exit:
|
||||
|
||||
if (DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
|
||||
if (Ip4Info != NULL) {
|
||||
FreePool(Ip4Info);
|
||||
FreePool (Ip4Info);
|
||||
}
|
||||
|
||||
return Status;
|
||||
@@ -550,41 +549,39 @@ Exit:
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
IN IP4_CONFIG2_IFR_NVDATA *IfrFormNvData,
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
IN IP4_CONFIG2_IFR_NVDATA *IfrFormNvData,
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
|
||||
IP4_CONFIG2_NVDATA *Ip4NvData;
|
||||
EFI_STATUS Status;
|
||||
EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
|
||||
IP4_CONFIG2_NVDATA *Ip4NvData;
|
||||
|
||||
EFI_IP_ADDRESS StationAddress;
|
||||
EFI_IP_ADDRESS SubnetMask;
|
||||
EFI_IP_ADDRESS Gateway;
|
||||
IP4_ADDR Ip;
|
||||
EFI_IPv4_ADDRESS *DnsAddress;
|
||||
UINTN DnsCount;
|
||||
UINTN Index;
|
||||
EFI_IP_ADDRESS StationAddress;
|
||||
EFI_IP_ADDRESS SubnetMask;
|
||||
EFI_IP_ADDRESS Gateway;
|
||||
IP4_ADDR Ip;
|
||||
EFI_IPv4_ADDRESS *DnsAddress;
|
||||
UINTN DnsCount;
|
||||
UINTN Index;
|
||||
|
||||
EFI_EVENT TimeoutEvent;
|
||||
EFI_EVENT SetAddressEvent;
|
||||
BOOLEAN IsAddressOk;
|
||||
UINTN DataSize;
|
||||
EFI_INPUT_KEY Key;
|
||||
EFI_EVENT TimeoutEvent;
|
||||
EFI_EVENT SetAddressEvent;
|
||||
BOOLEAN IsAddressOk;
|
||||
UINTN DataSize;
|
||||
EFI_INPUT_KEY Key;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Ip4Cfg2 = &Instance->Ip4Config2;
|
||||
Ip4NvData = &Instance->Ip4NvData;
|
||||
Status = EFI_SUCCESS;
|
||||
Ip4Cfg2 = &Instance->Ip4Config2;
|
||||
Ip4NvData = &Instance->Ip4NvData;
|
||||
|
||||
DnsCount = 0;
|
||||
DnsAddress = NULL;
|
||||
DnsCount = 0;
|
||||
DnsAddress = NULL;
|
||||
|
||||
TimeoutEvent = NULL;
|
||||
SetAddressEvent = NULL;
|
||||
|
||||
|
||||
|
||||
if (Instance == NULL || IfrFormNvData == NULL) {
|
||||
if ((Instance == NULL) || (IfrFormNvData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -601,7 +598,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
sizeof (EFI_IP4_CONFIG2_POLICY),
|
||||
&Ip4NvData->Policy
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
@@ -618,26 +615,28 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);
|
||||
if (EFI_ERROR (Status) ||
|
||||
(SubnetMask.Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) ||
|
||||
!Ip4StationAddressValid (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) {
|
||||
((SubnetMask.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) ||
|
||||
!Ip4StationAddressValid (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0])))
|
||||
{
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
|
||||
if (EFI_ERROR (Status) ||
|
||||
(Gateway.Addr[0] != 0 && SubnetMask.Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0])))) {
|
||||
((Gateway.Addr[0] != 0) && (SubnetMask.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0]))))
|
||||
{
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount);
|
||||
if (!EFI_ERROR (Status) && DnsCount > 0) {
|
||||
for (Index = 0; Index < DnsCount; Index ++) {
|
||||
if (!EFI_ERROR (Status) && (DnsCount > 0)) {
|
||||
for (Index = 0; Index < DnsCount; Index++) {
|
||||
CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));
|
||||
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@@ -648,37 +647,43 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
}
|
||||
|
||||
if (Ip4NvData->ManualAddress != NULL) {
|
||||
FreePool(Ip4NvData->ManualAddress);
|
||||
FreePool (Ip4NvData->ManualAddress);
|
||||
}
|
||||
|
||||
Ip4NvData->ManualAddressCount = 1;
|
||||
Ip4NvData->ManualAddress = AllocateZeroPool(sizeof(EFI_IP4_CONFIG2_MANUAL_ADDRESS));
|
||||
Ip4NvData->ManualAddress = AllocateZeroPool (sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS));
|
||||
if (Ip4NvData->ManualAddress == NULL) {
|
||||
if (DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
CopyMem(&Ip4NvData->ManualAddress->Address, &StationAddress.v4, sizeof(EFI_IPv4_ADDRESS));
|
||||
CopyMem(&Ip4NvData->ManualAddress->SubnetMask, &SubnetMask.v4, sizeof(EFI_IPv4_ADDRESS));
|
||||
|
||||
CopyMem (&Ip4NvData->ManualAddress->Address, &StationAddress.v4, sizeof (EFI_IPv4_ADDRESS));
|
||||
CopyMem (&Ip4NvData->ManualAddress->SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));
|
||||
|
||||
if (Ip4NvData->GatewayAddress != NULL) {
|
||||
FreePool(Ip4NvData->GatewayAddress);
|
||||
FreePool (Ip4NvData->GatewayAddress);
|
||||
}
|
||||
|
||||
Ip4NvData->GatewayAddressCount = 1;
|
||||
Ip4NvData->GatewayAddress = AllocateZeroPool(sizeof(EFI_IPv4_ADDRESS));
|
||||
Ip4NvData->GatewayAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS));
|
||||
if (Ip4NvData->GatewayAddress == NULL) {
|
||||
if (DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
CopyMem(Ip4NvData->GatewayAddress, &Gateway.v4, sizeof(EFI_IPv4_ADDRESS));
|
||||
|
||||
CopyMem (Ip4NvData->GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));
|
||||
|
||||
if (Ip4NvData->DnsAddress != NULL) {
|
||||
FreePool(Ip4NvData->DnsAddress);
|
||||
FreePool (Ip4NvData->DnsAddress);
|
||||
}
|
||||
Ip4NvData->DnsAddressCount = (UINT32) DnsCount;
|
||||
|
||||
Ip4NvData->DnsAddressCount = (UINT32)DnsCount;
|
||||
Ip4NvData->DnsAddress = DnsAddress;
|
||||
|
||||
//
|
||||
@@ -690,7 +695,7 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
sizeof (EFI_IP4_CONFIG2_POLICY),
|
||||
&Ip4NvData->Policy
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -734,12 +739,12 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
// Set ManualAddress.
|
||||
//
|
||||
DataSize = Ip4NvData->ManualAddressCount * sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS);
|
||||
Status = Ip4Cfg2->SetData (
|
||||
Ip4Cfg2,
|
||||
Ip4Config2DataTypeManualAddress,
|
||||
DataSize,
|
||||
(VOID *) Ip4NvData->ManualAddress
|
||||
);
|
||||
Status = Ip4Cfg2->SetData (
|
||||
Ip4Cfg2,
|
||||
Ip4Config2DataTypeManualAddress,
|
||||
DataSize,
|
||||
(VOID *)Ip4NvData->ManualAddress
|
||||
);
|
||||
|
||||
if (Status == EFI_NOT_READY) {
|
||||
gBS->SetTimer (TimeoutEvent, TimerRelative, 50000000);
|
||||
@@ -764,12 +769,12 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
// Set gateway.
|
||||
//
|
||||
DataSize = Ip4NvData->GatewayAddressCount * sizeof (EFI_IPv4_ADDRESS);
|
||||
Status = Ip4Cfg2->SetData (
|
||||
Ip4Cfg2,
|
||||
Ip4Config2DataTypeGateway,
|
||||
DataSize,
|
||||
Ip4NvData->GatewayAddress
|
||||
);
|
||||
Status = Ip4Cfg2->SetData (
|
||||
Ip4Cfg2,
|
||||
Ip4Config2DataTypeGateway,
|
||||
DataSize,
|
||||
Ip4NvData->GatewayAddress
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
@@ -777,14 +782,14 @@ Ip4Config2ConvertIfrNvDataToConfigNvData (
|
||||
//
|
||||
// Set DNS addresses.
|
||||
//
|
||||
if (Ip4NvData->DnsAddressCount > 0 && Ip4NvData->DnsAddress != NULL) {
|
||||
if ((Ip4NvData->DnsAddressCount > 0) && (Ip4NvData->DnsAddress != NULL)) {
|
||||
DataSize = Ip4NvData->DnsAddressCount * sizeof (EFI_IPv4_ADDRESS);
|
||||
Status = Ip4Cfg2->SetData (
|
||||
Ip4Cfg2,
|
||||
Ip4Config2DataTypeDnsServer,
|
||||
DataSize,
|
||||
Ip4NvData->DnsAddress
|
||||
);
|
||||
Status = Ip4Cfg2->SetData (
|
||||
Ip4Cfg2,
|
||||
Ip4Config2DataTypeDnsServer,
|
||||
DataSize,
|
||||
Ip4NvData->DnsAddress
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
@@ -863,24 +868,24 @@ Exit:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4FormExtractConfig (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Request,
|
||||
OUT EFI_STRING *Progress,
|
||||
OUT EFI_STRING *Results
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Request,
|
||||
OUT EFI_STRING *Progress,
|
||||
OUT EFI_STRING *Results
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
IP4_CONFIG2_INSTANCE *Ip4Config2Instance;
|
||||
IP4_FORM_CALLBACK_INFO *Private;
|
||||
IP4_CONFIG2_IFR_NVDATA *IfrFormNvData;
|
||||
EFI_STRING ConfigRequestHdr;
|
||||
EFI_STRING ConfigRequest;
|
||||
BOOLEAN AllocatedRequest;
|
||||
EFI_STRING FormResult;
|
||||
UINTN Size;
|
||||
UINTN BufferSize;
|
||||
EFI_STATUS Status;
|
||||
IP4_CONFIG2_INSTANCE *Ip4Config2Instance;
|
||||
IP4_FORM_CALLBACK_INFO *Private;
|
||||
IP4_CONFIG2_IFR_NVDATA *IfrFormNvData;
|
||||
EFI_STRING ConfigRequestHdr;
|
||||
EFI_STRING ConfigRequest;
|
||||
BOOLEAN AllocatedRequest;
|
||||
EFI_STRING FormResult;
|
||||
UINTN Size;
|
||||
UINTN BufferSize;
|
||||
|
||||
if (Progress == NULL || Results == NULL) {
|
||||
if ((Progress == NULL) || (Results == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -891,8 +896,8 @@ Ip4FormExtractConfig (
|
||||
Size = 0;
|
||||
AllocatedRequest = FALSE;
|
||||
ConfigRequest = Request;
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private);
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
|
||||
BufferSize = sizeof (IP4_CONFIG2_IFR_NVDATA);
|
||||
*Progress = Request;
|
||||
|
||||
@@ -914,12 +919,13 @@ Ip4FormExtractConfig (
|
||||
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
|
||||
//
|
||||
ConfigRequestHdr = HiiConstructConfigHdr (&gIp4Config2NvDataGuid, mIp4Config2StorageName, Private->ChildHandle);
|
||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||
ConfigRequest = AllocateZeroPool (Size);
|
||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||
ConfigRequest = AllocateZeroPool (Size);
|
||||
if (ConfigRequest == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
AllocatedRequest = TRUE;
|
||||
|
||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||
@@ -932,7 +938,7 @@ Ip4FormExtractConfig (
|
||||
Status = gHiiConfigRouting->BlockToConfig (
|
||||
gHiiConfigRouting,
|
||||
ConfigRequest,
|
||||
(UINT8 *) IfrFormNvData,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
BufferSize,
|
||||
&FormResult,
|
||||
Progress
|
||||
@@ -953,7 +959,7 @@ Ip4FormExtractConfig (
|
||||
}
|
||||
}
|
||||
|
||||
if (Request == NULL || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
|
||||
if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
|
||||
*Results = FormResult;
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
@@ -1008,28 +1014,28 @@ Failure:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4FormRouteConfig (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Configuration,
|
||||
OUT EFI_STRING *Progress
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN CONST EFI_STRING Configuration,
|
||||
OUT EFI_STRING *Progress
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
IP4_CONFIG2_IFR_NVDATA *IfrFormNvData;
|
||||
IP4_CONFIG2_INSTANCE *Ip4Config2Instance;
|
||||
IP4_FORM_CALLBACK_INFO *Private;
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
IP4_CONFIG2_IFR_NVDATA *IfrFormNvData;
|
||||
IP4_CONFIG2_INSTANCE *Ip4Config2Instance;
|
||||
IP4_FORM_CALLBACK_INFO *Private;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
IfrFormNvData = NULL;
|
||||
|
||||
if (Configuration == NULL || Progress == NULL) {
|
||||
if ((Configuration == NULL) || (Progress == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Progress = Configuration;
|
||||
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private);
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
|
||||
Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
|
||||
|
||||
//
|
||||
// Check Routing data in <ConfigHdr>.
|
||||
@@ -1048,7 +1054,7 @@ Ip4FormRouteConfig (
|
||||
Status = gHiiConfigRouting->ConfigToBlock (
|
||||
gHiiConfigRouting,
|
||||
Configuration,
|
||||
(UINT8 *) IfrFormNvData,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
&BufferSize,
|
||||
Progress
|
||||
);
|
||||
@@ -1059,7 +1065,7 @@ Ip4FormRouteConfig (
|
||||
Status = gHiiConfigRouting->ConfigToBlock (
|
||||
gHiiConfigRouting,
|
||||
Configuration,
|
||||
(UINT8 *) IfrFormNvData,
|
||||
(UINT8 *)IfrFormNvData,
|
||||
&BufferSize,
|
||||
Progress
|
||||
);
|
||||
@@ -1073,7 +1079,6 @@ Ip4FormRouteConfig (
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1106,35 +1111,35 @@ Ip4FormRouteConfig (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4FormCallback (
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN EFI_BROWSER_ACTION Action,
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN UINT8 Type,
|
||||
IN EFI_IFR_TYPE_VALUE *Value,
|
||||
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
||||
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
IN EFI_BROWSER_ACTION Action,
|
||||
IN EFI_QUESTION_ID QuestionId,
|
||||
IN UINT8 Type,
|
||||
IN EFI_IFR_TYPE_VALUE *Value,
|
||||
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
IP4_CONFIG2_INSTANCE *Instance;
|
||||
IP4_CONFIG2_IFR_NVDATA *IfrFormNvData;
|
||||
IP4_FORM_CALLBACK_INFO *Private;
|
||||
EFI_STATUS Status;
|
||||
IP4_CONFIG2_INSTANCE *Instance;
|
||||
IP4_CONFIG2_IFR_NVDATA *IfrFormNvData;
|
||||
IP4_FORM_CALLBACK_INFO *Private;
|
||||
|
||||
EFI_IP_ADDRESS StationAddress;
|
||||
EFI_IP_ADDRESS SubnetMask;
|
||||
EFI_IP_ADDRESS Gateway;
|
||||
IP4_ADDR Ip;
|
||||
EFI_IPv4_ADDRESS *DnsAddress;
|
||||
UINTN DnsCount;
|
||||
UINTN Index;
|
||||
EFI_INPUT_KEY Key;
|
||||
EFI_IP_ADDRESS StationAddress;
|
||||
EFI_IP_ADDRESS SubnetMask;
|
||||
EFI_IP_ADDRESS Gateway;
|
||||
IP4_ADDR Ip;
|
||||
EFI_IPv4_ADDRESS *DnsAddress;
|
||||
UINTN DnsCount;
|
||||
UINTN Index;
|
||||
EFI_INPUT_KEY Key;
|
||||
|
||||
IfrFormNvData = NULL;
|
||||
DnsCount = 0;
|
||||
DnsAddress = NULL;
|
||||
|
||||
if (Action == EFI_BROWSER_ACTION_CHANGED) {
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This);
|
||||
Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private);
|
||||
Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
|
||||
Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
|
||||
|
||||
IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG2_IFR_NVDATA));
|
||||
if (IfrFormNvData == NULL) {
|
||||
@@ -1144,7 +1149,7 @@ Ip4FormCallback (
|
||||
//
|
||||
// Retrieve uncommitted data from Browser
|
||||
//
|
||||
if (!HiiGetBrowserData (&gIp4Config2NvDataGuid, mIp4Config2StorageName, sizeof (IP4_CONFIG2_IFR_NVDATA), (UINT8 *) IfrFormNvData)) {
|
||||
if (!HiiGetBrowserData (&gIp4Config2NvDataGuid, mIp4Config2StorageName, sizeof (IP4_CONFIG2_IFR_NVDATA), (UINT8 *)IfrFormNvData)) {
|
||||
FreePool (IfrFormNvData);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@@ -1152,59 +1157,63 @@ Ip4FormCallback (
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
switch (QuestionId) {
|
||||
case KEY_LOCAL_IP:
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);
|
||||
if (EFI_ERROR (Status) || IP4_IS_UNSPECIFIED (NTOHL (StationAddress.Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (StationAddress.Addr[0]))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
break;
|
||||
case KEY_LOCAL_IP:
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->StationAddress, &StationAddress.v4);
|
||||
if (EFI_ERROR (Status) || IP4_IS_UNSPECIFIED (NTOHL (StationAddress.Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (StationAddress.Addr[0]))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
case KEY_SUBNET_MASK:
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->SubnetMask, &SubnetMask.v4);
|
||||
if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (GetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case KEY_GATE_WAY:
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
|
||||
if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST(NTOHL(Gateway.Addr[0]))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
break;
|
||||
case KEY_SUBNET_MASK:
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->SubnetMask, &SubnetMask.v4);
|
||||
if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (GetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
case KEY_DNS:
|
||||
Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount);
|
||||
if (!EFI_ERROR (Status) && DnsCount > 0) {
|
||||
for (Index = 0; Index < DnsCount; Index ++) {
|
||||
CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));
|
||||
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
|
||||
break;
|
||||
|
||||
case KEY_GATE_WAY:
|
||||
Status = Ip4Config2StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4);
|
||||
if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST (NTOHL (Gateway.Addr[0]))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case KEY_DNS:
|
||||
Status = Ip4Config2StrToIpList (IfrFormNvData->DnsAddress, &DnsAddress, &DnsCount);
|
||||
if (!EFI_ERROR (Status) && (DnsCount > 0)) {
|
||||
for (Index = 0; Index < DnsCount; Index++) {
|
||||
CopyMem (&Ip, &DnsAddress[Index], sizeof (IP4_ADDR));
|
||||
if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (EFI_ERROR (Status)) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (EFI_ERROR (Status)) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Dns Server!", NULL);
|
||||
|
||||
if (DnsAddress != NULL) {
|
||||
FreePool (DnsAddress);
|
||||
}
|
||||
}
|
||||
|
||||
if(DnsAddress != NULL) {
|
||||
FreePool(DnsAddress);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case KEY_SAVE_CHANGES:
|
||||
Status = Ip4Config2ConvertIfrNvDataToConfigNvData (IfrFormNvData, Instance);
|
||||
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
|
||||
break;
|
||||
case KEY_SAVE_CHANGES:
|
||||
Status = Ip4Config2ConvertIfrNvDataToConfigNvData (IfrFormNvData, Instance);
|
||||
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
FreePool (IfrFormNvData);
|
||||
@@ -1230,20 +1239,20 @@ Ip4FormCallback (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Config2FormInit (
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_FORM_CALLBACK_INFO *CallbackInfo;
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
||||
VENDOR_DEVICE_PATH VendorDeviceNode;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *MnpSb;
|
||||
CHAR16 *MacString;
|
||||
CHAR16 MenuString[128];
|
||||
CHAR16 PortString[128];
|
||||
CHAR16 *OldMenuString;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_STATUS Status;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_FORM_CALLBACK_INFO *CallbackInfo;
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
||||
VENDOR_DEVICE_PATH VendorDeviceNode;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *MnpSb;
|
||||
CHAR16 *MacString;
|
||||
CHAR16 MenuString[128];
|
||||
CHAR16 PortString[128];
|
||||
CHAR16 *OldMenuString;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
|
||||
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
|
||||
ASSERT (IpSb != NULL);
|
||||
@@ -1255,7 +1264,7 @@ Ip4Config2FormInit (
|
||||
Status = gBS->HandleProtocol (
|
||||
IpSb->Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath
|
||||
(VOID **)&ParentDevicePath
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@@ -1275,7 +1284,7 @@ Ip4Config2FormInit (
|
||||
SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
|
||||
CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
|
||||
ParentDevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
|
||||
);
|
||||
if (CallbackInfo->HiiVendorDevicePath == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@@ -1306,7 +1315,7 @@ Ip4Config2FormInit (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpSb->Controller,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
(VOID **) &MnpSb,
|
||||
(VOID **)&MnpSb,
|
||||
IpSb->Image,
|
||||
CallbackInfo->ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@@ -1377,12 +1386,12 @@ Error:
|
||||
**/
|
||||
VOID
|
||||
Ip4Config2FormUnload (
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_FORM_CALLBACK_INFO *CallbackInfo;
|
||||
IP4_CONFIG2_NVDATA *Ip4NvData;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_FORM_CALLBACK_INFO *CallbackInfo;
|
||||
IP4_CONFIG2_NVDATA *Ip4NvData;
|
||||
|
||||
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
|
||||
ASSERT (IpSb != NULL);
|
||||
@@ -1426,16 +1435,16 @@ Ip4Config2FormUnload (
|
||||
|
||||
Ip4NvData = &Instance->Ip4NvData;
|
||||
|
||||
if(Ip4NvData->ManualAddress != NULL) {
|
||||
FreePool(Ip4NvData->ManualAddress);
|
||||
if (Ip4NvData->ManualAddress != NULL) {
|
||||
FreePool (Ip4NvData->ManualAddress);
|
||||
}
|
||||
|
||||
if(Ip4NvData->GatewayAddress != NULL) {
|
||||
FreePool(Ip4NvData->GatewayAddress);
|
||||
if (Ip4NvData->GatewayAddress != NULL) {
|
||||
FreePool (Ip4NvData->GatewayAddress);
|
||||
}
|
||||
|
||||
if(Ip4NvData->DnsAddress != NULL) {
|
||||
FreePool(Ip4NvData->DnsAddress);
|
||||
if (Ip4NvData->DnsAddress != NULL) {
|
||||
FreePool (Ip4NvData->DnsAddress);
|
||||
}
|
||||
|
||||
Ip4NvData->ManualAddressCount = 0;
|
||||
|
@@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
extern UINT8 Ip4Config2Bin[];
|
||||
extern UINT8 Ip4DxeStrings[];
|
||||
|
||||
#define NIC_ITEM_CONFIG_SIZE (sizeof (IP4_CONFIG2_INSTANCE) + (sizeof (EFI_IPv4_ADDRESS) * MAX_IP4_CONFIG_DNS))
|
||||
#define NIC_ITEM_CONFIG_SIZE (sizeof (IP4_CONFIG2_INSTANCE) + (sizeof (EFI_IPv4_ADDRESS) * MAX_IP4_CONFIG_DNS))
|
||||
|
||||
/**
|
||||
Install HII Config Access protocol for network device and allocate resource.
|
||||
@@ -28,7 +28,7 @@ extern UINT8 Ip4DxeStrings[];
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Config2FormInit (
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ Ip4Config2FormInit (
|
||||
**/
|
||||
VOID
|
||||
Ip4Config2FormUnload (
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
IN OUT IP4_CONFIG2_INSTANCE *Instance
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding = {
|
||||
EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding = {
|
||||
Ip4DriverBindingSupported,
|
||||
Ip4DriverBindingStart,
|
||||
Ip4DriverBindingStop,
|
||||
@@ -35,13 +35,14 @@ IpSec2InstalledCallback (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Test if protocol was even found.
|
||||
// Notification function will be called at least once.
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec);
|
||||
if (Status == EFI_SUCCESS && mIpSec != NULL) {
|
||||
if ((Status == EFI_SUCCESS) && (mIpSec != NULL)) {
|
||||
//
|
||||
// Close the event so it does not get called again.
|
||||
//
|
||||
@@ -69,11 +70,11 @@ IpSec2InstalledCallback (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
VOID *Registration;
|
||||
VOID *Registration;
|
||||
|
||||
EfiCreateProtocolNotifyEvent (
|
||||
&gEfiIpSec2ProtocolGuid,
|
||||
@@ -114,12 +115,12 @@ Ip4DriverEntryPoint (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Test for the MNP service binding Protocol
|
||||
@@ -167,10 +168,9 @@ Ip4DriverBindingSupported (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4CleanService (
|
||||
IN IP4_SERVICE *IpSb
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Create a new IP4 driver service binding private instance.
|
||||
|
||||
@@ -187,13 +187,13 @@ Ip4CleanService (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4CreateService (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
OUT IP4_SERVICE **Service
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
OUT IP4_SERVICE **Service
|
||||
)
|
||||
{
|
||||
IP4_SERVICE *IpSb;
|
||||
EFI_STATUS Status;
|
||||
IP4_SERVICE *IpSb;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (Service != NULL);
|
||||
|
||||
@@ -215,23 +215,23 @@ Ip4CreateService (
|
||||
IpSb->ServiceBinding.DestroyChild = Ip4ServiceBindingDestroyChild;
|
||||
IpSb->State = IP4_SERVICE_UNSTARTED;
|
||||
|
||||
IpSb->NumChildren = 0;
|
||||
IpSb->NumChildren = 0;
|
||||
InitializeListHead (&IpSb->Children);
|
||||
|
||||
InitializeListHead (&IpSb->Interfaces);
|
||||
IpSb->DefaultInterface = NULL;
|
||||
IpSb->DefaultRouteTable = NULL;
|
||||
IpSb->DefaultInterface = NULL;
|
||||
IpSb->DefaultRouteTable = NULL;
|
||||
|
||||
Ip4InitAssembleTable (&IpSb->Assemble);
|
||||
|
||||
IpSb->IgmpCtrl.Igmpv1QuerySeen = 0;
|
||||
IpSb->IgmpCtrl.Igmpv1QuerySeen = 0;
|
||||
InitializeListHead (&IpSb->IgmpCtrl.Groups);
|
||||
|
||||
IpSb->Image = ImageHandle;
|
||||
IpSb->Controller = Controller;
|
||||
IpSb->Image = ImageHandle;
|
||||
IpSb->Controller = Controller;
|
||||
|
||||
IpSb->MnpChildHandle = NULL;
|
||||
IpSb->Mnp = NULL;
|
||||
IpSb->MnpChildHandle = NULL;
|
||||
IpSb->Mnp = NULL;
|
||||
|
||||
IpSb->MnpConfigData.ReceivedQueueTimeoutValue = 0;
|
||||
IpSb->MnpConfigData.TransmitQueueTimeoutValue = 0;
|
||||
@@ -246,7 +246,7 @@ Ip4CreateService (
|
||||
|
||||
ZeroMem (&IpSb->SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE));
|
||||
|
||||
IpSb->Timer = NULL;
|
||||
IpSb->Timer = NULL;
|
||||
IpSb->ReconfigCheckTimer = NULL;
|
||||
|
||||
IpSb->ReconfigEvent = NULL;
|
||||
@@ -316,7 +316,7 @@ Ip4CreateService (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpSb->MnpChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
(VOID **) &IpSb->Mnp,
|
||||
(VOID **)&IpSb->Mnp,
|
||||
ImageHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@@ -345,7 +345,7 @@ Ip4CreateService (
|
||||
}
|
||||
|
||||
IpSb->MacString = NULL;
|
||||
Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);
|
||||
Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
@@ -375,8 +375,9 @@ Ip4CreateService (
|
||||
//
|
||||
IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN;
|
||||
}
|
||||
|
||||
IpSb->OldMaxPacketSize = IpSb->MaxPacketSize;
|
||||
*Service = IpSb;
|
||||
*Service = IpSb;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@@ -387,7 +388,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up a IP4 service binding instance. It will release all
|
||||
the resource allocated by the instance. The instance may be
|
||||
@@ -403,12 +403,12 @@ ON_ERROR:
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4CleanService (
|
||||
IN IP4_SERVICE *IpSb
|
||||
IN IP4_SERVICE *IpSb
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
IpSb->State = IP4_SERVICE_DESTROY;
|
||||
IpSb->State = IP4_SERVICE_DESTROY;
|
||||
|
||||
if (IpSb->Timer != NULL) {
|
||||
gBS->SetTimer (IpSb->Timer, TimerCancel, 0);
|
||||
@@ -493,8 +493,8 @@ Ip4CleanService (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DestroyChildEntryInHandleBuffer (
|
||||
IN LIST_ENTRY *Entry,
|
||||
IN VOID *Context
|
||||
IN LIST_ENTRY *Entry,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
@@ -502,14 +502,14 @@ Ip4DestroyChildEntryInHandleBuffer (
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
|
||||
if (Entry == NULL || Context == NULL) {
|
||||
if ((Entry == NULL) || (Context == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);
|
||||
ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
|
||||
NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
|
||||
IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);
|
||||
ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
|
||||
NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
|
||||
ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
|
||||
|
||||
if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
|
||||
return EFI_SUCCESS;
|
||||
@@ -544,11 +544,11 @@ Ip4DriverBindingStart (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
IP4_SERVICE *IpSb;
|
||||
EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
|
||||
UINTN Index;
|
||||
IP4_CONFIG2_DATA_ITEM *DataItem;
|
||||
EFI_STATUS Status;
|
||||
IP4_SERVICE *IpSb;
|
||||
EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
|
||||
UINTN Index;
|
||||
IP4_CONFIG2_DATA_ITEM *DataItem;
|
||||
|
||||
IpSb = NULL;
|
||||
Ip4Cfg2 = NULL;
|
||||
@@ -578,7 +578,7 @@ Ip4DriverBindingStart (
|
||||
|
||||
ASSERT (IpSb != NULL);
|
||||
|
||||
Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2;
|
||||
Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2;
|
||||
|
||||
//
|
||||
// Install the Ip4ServiceBinding Protocol onto ControllerHandle
|
||||
@@ -617,11 +617,11 @@ Ip4DriverBindingStart (
|
||||
DataItem->DataSize,
|
||||
DataItem->Data.Ptr
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto UNINSTALL_PROTOCOL;
|
||||
}
|
||||
|
||||
if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {
|
||||
if ((Index == Ip4Config2DataTypePolicy) && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -634,7 +634,7 @@ Ip4DriverBindingStart (
|
||||
//
|
||||
Status = Ip4ReceiveFrame (IpSb->DefaultInterface, NULL, Ip4AccpetFrame, IpSb);
|
||||
|
||||
if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||
goto UNINSTALL_PROTOCOL;
|
||||
}
|
||||
|
||||
@@ -673,7 +673,6 @@ FREE_SERVICE:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service DisconnectController(). In order to
|
||||
@@ -711,9 +710,9 @@ Ip4DriverBindingStop (
|
||||
IP4_INTERFACE *IpIf;
|
||||
IP4_ROUTE_TABLE *RouteTable;
|
||||
|
||||
BOOLEAN IsDhcp4;
|
||||
BOOLEAN IsDhcp4;
|
||||
|
||||
IsDhcp4 = FALSE;
|
||||
IsDhcp4 = FALSE;
|
||||
|
||||
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
|
||||
if (NicHandle == NULL) {
|
||||
@@ -731,7 +730,7 @@ Ip4DriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiIp4ServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@@ -747,18 +746,17 @@ Ip4DriverBindingStop (
|
||||
gBS->CloseEvent (IpSb->Ip4Config2Instance.Dhcp4Event);
|
||||
IpSb->Ip4Config2Instance.Dhcp4Event = NULL;
|
||||
} else if (NumberOfChildren != 0) {
|
||||
List = &IpSb->Children;
|
||||
List = &IpSb->Children;
|
||||
Context.ServiceBinding = ServiceBinding;
|
||||
Context.NumberOfChildren = NumberOfChildren;
|
||||
Context.ChildHandleBuffer = ChildHandleBuffer;
|
||||
Status = NetDestroyLinkList (
|
||||
List,
|
||||
Ip4DestroyChildEntryInHandleBuffer,
|
||||
&Context,
|
||||
NULL
|
||||
);
|
||||
Status = NetDestroyLinkList (
|
||||
List,
|
||||
Ip4DestroyChildEntryInHandleBuffer,
|
||||
&Context,
|
||||
NULL
|
||||
);
|
||||
} else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {
|
||||
|
||||
//
|
||||
// The ARP protocol for the default interface is being uninstalled and all
|
||||
// its IP child handles should have been destroyed before. So, release the
|
||||
@@ -772,21 +770,21 @@ Ip4DriverBindingStop (
|
||||
if (IpIf == NULL) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
RouteTable = Ip4CreateRouteTable ();
|
||||
if (RouteTable == NULL) {
|
||||
Ip4FreeInterface (IpIf, NULL);
|
||||
goto ON_ERROR;;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
IpSb->DefaultInterface = IpIf;
|
||||
IpSb->DefaultInterface = IpIf;
|
||||
InsertHeadList (&IpSb->Interfaces, &IpIf->Link);
|
||||
IpSb->DefaultRouteTable = RouteTable;
|
||||
Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
|
||||
|
||||
IpSb->State = IP4_SERVICE_UNSTARTED;
|
||||
|
||||
} else if (IsListEmpty (&IpSb->Children)) {
|
||||
State = IpSb->State;
|
||||
State = IpSb->State;
|
||||
//
|
||||
// OK, clean other resources then uninstall the service binding protocol.
|
||||
//
|
||||
@@ -809,6 +807,7 @@ Ip4DriverBindingStop (
|
||||
FreeUnicodeStringTable (gIp4ControllerNameTable);
|
||||
gIp4ControllerNameTable = NULL;
|
||||
}
|
||||
|
||||
FreePool (IpSb);
|
||||
}
|
||||
|
||||
@@ -816,7 +815,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
@@ -843,11 +841,11 @@ Ip4ServiceBindingCreateChild (
|
||||
IN OUT EFI_HANDLE *ChildHandle
|
||||
)
|
||||
{
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
VOID *Mnp;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
VOID *Mnp;
|
||||
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -884,7 +882,7 @@ Ip4ServiceBindingCreateChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
IpSb->MnpChildHandle,
|
||||
&gEfiManagedNetworkProtocolGuid,
|
||||
(VOID **) &Mnp,
|
||||
(VOID **)&Mnp,
|
||||
gIp4DriverBinding.DriverBindingHandle,
|
||||
IpInstance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@@ -913,7 +911,6 @@ Ip4ServiceBindingCreateChild (
|
||||
ON_ERROR:
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
Ip4CleanProtocol (IpInstance);
|
||||
|
||||
FreePool (IpInstance);
|
||||
@@ -922,7 +919,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
@@ -948,11 +944,11 @@ Ip4ServiceBindingDestroyChild (
|
||||
IN EFI_HANDLE ChildHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_IP4_PROTOCOL *Ip4;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_STATUS Status;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_IP4_PROTOCOL *Ip4;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -961,12 +957,12 @@ Ip4ServiceBindingDestroyChild (
|
||||
//
|
||||
// Retrieve the private context data structures
|
||||
//
|
||||
IpSb = IP4_SERVICE_FROM_PROTOCOL (This);
|
||||
IpSb = IP4_SERVICE_FROM_PROTOCOL (This);
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiIp4ProtocolGuid,
|
||||
(VOID **) &Ip4,
|
||||
(VOID **)&Ip4,
|
||||
gIp4DriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@@ -1007,7 +1003,7 @@ Ip4ServiceBindingDestroyChild (
|
||||
ChildHandle
|
||||
);
|
||||
|
||||
if (IpInstance->Interface != NULL && IpInstance->Interface->Arp != NULL) {
|
||||
if ((IpInstance->Interface != NULL) && (IpInstance->Interface->Arp != NULL)) {
|
||||
gBS->CloseProtocol (
|
||||
IpInstance->Interface->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
|
@@ -16,14 +16,15 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ComponentName2;
|
||||
extern EFI_UNICODE_STRING_TABLE *gIp4ControllerNameTable;
|
||||
|
||||
typedef struct {
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
UINTN NumberOfChildren;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
} IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
|
||||
|
||||
//
|
||||
// Function prototype for the driver's entry point
|
||||
//
|
||||
|
||||
/**
|
||||
This is the declaration of an EFI image entry point. This entry point is
|
||||
the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
|
||||
@@ -42,13 +43,14 @@ typedef struct {
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
//
|
||||
// Function prototypes for the Driver Binding Protocol
|
||||
//
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. This service
|
||||
is called by the EFI boot service ConnectController(). In
|
||||
@@ -70,9 +72,9 @@ Ip4DriverEntryPoint (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -96,9 +98,9 @@ Ip4DriverBindingSupported (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4DriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL * This,
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -131,6 +133,7 @@ Ip4DriverBindingStop (
|
||||
//
|
||||
// Function prototypes for the ServiceBinding Protocol
|
||||
//
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
@@ -181,4 +184,5 @@ Ip4ServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -8,61 +8,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
IP4_ICMP_CLASS
|
||||
mIcmpClass[] = {
|
||||
{ICMP_ECHO_REPLY, ICMP_QUERY_MESSAGE },
|
||||
{1, ICMP_INVALID_MESSAGE},
|
||||
{2, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_SOURCE_QUENCH, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_REDIRECT, ICMP_ERROR_MESSAGE },
|
||||
{6, ICMP_INVALID_MESSAGE},
|
||||
{7, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_ECHO_REQUEST, ICMP_QUERY_MESSAGE },
|
||||
{9, ICMP_INVALID_MESSAGE},
|
||||
{10, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_TIME_EXCEEDED, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_PARAMETER_PROBLEM, ICMP_ERROR_MESSAGE },
|
||||
{ICMP_TIMESTAMP , ICMP_QUERY_MESSAGE },
|
||||
{14, ICMP_INVALID_MESSAGE},
|
||||
{ICMP_INFO_REQUEST , ICMP_QUERY_MESSAGE },
|
||||
{ICMP_INFO_REPLY , ICMP_QUERY_MESSAGE },
|
||||
mIcmpClass[] = {
|
||||
{ ICMP_ECHO_REPLY, ICMP_QUERY_MESSAGE },
|
||||
{ 1, ICMP_INVALID_MESSAGE },
|
||||
{ 2, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_SOURCE_QUENCH, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_REDIRECT, ICMP_ERROR_MESSAGE },
|
||||
{ 6, ICMP_INVALID_MESSAGE },
|
||||
{ 7, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_ECHO_REQUEST, ICMP_QUERY_MESSAGE },
|
||||
{ 9, ICMP_INVALID_MESSAGE },
|
||||
{ 10, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_TIME_EXCEEDED, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_PARAMETER_PROBLEM, ICMP_ERROR_MESSAGE },
|
||||
{ ICMP_TIMESTAMP, ICMP_QUERY_MESSAGE },
|
||||
{ 14, ICMP_INVALID_MESSAGE },
|
||||
{ ICMP_INFO_REQUEST, ICMP_QUERY_MESSAGE },
|
||||
{ ICMP_INFO_REPLY, ICMP_QUERY_MESSAGE },
|
||||
};
|
||||
|
||||
EFI_IP4_ICMP_TYPE
|
||||
mIp4SupportedIcmp[23] = {
|
||||
{ICMP_ECHO_REPLY, ICMP_DEFAULT_CODE },
|
||||
mIp4SupportedIcmp[23] = {
|
||||
{ ICMP_ECHO_REPLY, ICMP_DEFAULT_CODE },
|
||||
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_PROTO_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACHABLE },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_FRAGMENT_FAILED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_SOURCEROUTE_FAILED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNKNOWN },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNKNOWN },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_SOURCE_ISOLATED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_PROHIBITED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_PROHIBITED },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE_TOS },
|
||||
{ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE_TOS},
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_PROTO_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_PORT_UNREACHABLE },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_FRAGMENT_FAILED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_SOURCEROUTE_FAILED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_UNKNOWN },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_HOST_UNKNOWN },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_SOURCE_ISOLATED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_PROHIBITED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_HOST_PROHIBITED },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_NET_UNREACHABLE_TOS },
|
||||
{ ICMP_DEST_UNREACHABLE, ICMP_HOST_UNREACHABLE_TOS },
|
||||
|
||||
{ICMP_SOURCE_QUENCH, ICMP_DEFAULT_CODE },
|
||||
{ ICMP_SOURCE_QUENCH, ICMP_DEFAULT_CODE },
|
||||
|
||||
{ICMP_REDIRECT, ICMP_NET_REDIRECT },
|
||||
{ICMP_REDIRECT, ICMP_HOST_REDIRECT },
|
||||
{ICMP_REDIRECT, ICMP_NET_TOS_REDIRECT },
|
||||
{ICMP_REDIRECT, ICMP_HOST_TOS_REDIRECT },
|
||||
{ ICMP_REDIRECT, ICMP_NET_REDIRECT },
|
||||
{ ICMP_REDIRECT, ICMP_HOST_REDIRECT },
|
||||
{ ICMP_REDIRECT, ICMP_NET_TOS_REDIRECT },
|
||||
{ ICMP_REDIRECT, ICMP_HOST_TOS_REDIRECT },
|
||||
|
||||
{ICMP_ECHO_REQUEST, ICMP_DEFAULT_CODE },
|
||||
{ ICMP_ECHO_REQUEST, ICMP_DEFAULT_CODE },
|
||||
|
||||
{ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_IN_TRANSIT },
|
||||
{ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_REASSEMBLE },
|
||||
{ ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_IN_TRANSIT },
|
||||
{ ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_REASSEMBLE },
|
||||
|
||||
{ICMP_PARAMETER_PROBLEM, ICMP_DEFAULT_CODE },
|
||||
{ ICMP_PARAMETER_PROBLEM, ICMP_DEFAULT_CODE },
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Process the ICMP redirect. Find the instance then update
|
||||
its route cache.
|
||||
@@ -88,19 +86,19 @@ mIp4SupportedIcmp[23] = {
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4ProcessIcmpRedirect (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_ICMP_ERROR_HEAD *Icmp
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_ICMP_ERROR_HEAD *Icmp
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_PROTOCOL *Ip4Instance;
|
||||
IP4_ROUTE_CACHE_ENTRY *CacheEntry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
IP4_ADDR Gateway;
|
||||
IP4_ADDR Src;
|
||||
IP4_ADDR Dst;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_PROTOCOL *Ip4Instance;
|
||||
IP4_ROUTE_CACHE_ENTRY *CacheEntry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
IP4_ADDR Gateway;
|
||||
IP4_ADDR Src;
|
||||
IP4_ADDR Dst;
|
||||
|
||||
//
|
||||
// Find the interface whose IP address is the source of the
|
||||
@@ -129,8 +127,8 @@ Ip4ProcessIcmpRedirect (
|
||||
continue;
|
||||
}
|
||||
|
||||
Dst = NTOHL (Icmp->IpHead.Dst);
|
||||
Src = NTOHL (Icmp->IpHead.Src);
|
||||
Dst = NTOHL (Icmp->IpHead.Dst);
|
||||
Src = NTOHL (Icmp->IpHead.Src);
|
||||
CacheEntry = Ip4FindRouteCache (Ip4Instance->RouteTable, Dst, Src);
|
||||
|
||||
//
|
||||
@@ -146,7 +144,6 @@ Ip4ProcessIcmpRedirect (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the ICMP error packet. If it is an ICMP redirect packet,
|
||||
update call Ip4ProcessIcmpRedirect to update the IP instance's
|
||||
@@ -164,19 +161,19 @@ Ip4ProcessIcmpRedirect (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4ProcessIcmpError (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_ICMP_ERROR_HEAD Icmp;
|
||||
IP4_ICMP_ERROR_HEAD Icmp;
|
||||
|
||||
if (Packet->TotalSize < sizeof (Icmp)) {
|
||||
NetbufFree (Packet);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
|
||||
|
||||
//
|
||||
// If it is an ICMP redirect error, update the route cache
|
||||
@@ -190,7 +187,6 @@ Ip4ProcessIcmpError (
|
||||
return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Replay an ICMP echo request.
|
||||
|
||||
@@ -206,15 +202,15 @@ Ip4ProcessIcmpError (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4IcmpReplyEcho (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_ICMP_QUERY_HEAD *Icmp;
|
||||
NET_BUF *Data;
|
||||
EFI_STATUS Status;
|
||||
IP4_HEAD ReplyHead;
|
||||
IP4_ICMP_QUERY_HEAD *Icmp;
|
||||
NET_BUF *Data;
|
||||
EFI_STATUS Status;
|
||||
IP4_HEAD ReplyHead;
|
||||
|
||||
//
|
||||
// make a copy the packet, it is really a bad idea to
|
||||
@@ -233,17 +229,17 @@ Ip4IcmpReplyEcho (
|
||||
// use specific destination. See RFC1122. SRR/RR option
|
||||
// update is omitted.
|
||||
//
|
||||
Icmp = (IP4_ICMP_QUERY_HEAD *) NetbufGetByte (Data, 0, NULL);
|
||||
Icmp = (IP4_ICMP_QUERY_HEAD *)NetbufGetByte (Data, 0, NULL);
|
||||
ASSERT (Icmp != NULL);
|
||||
Icmp->Head.Type = ICMP_ECHO_REPLY;
|
||||
Icmp->Head.Checksum = 0;
|
||||
Icmp->Head.Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Icmp, Data->TotalSize));
|
||||
Icmp->Head.Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)Icmp, Data->TotalSize));
|
||||
|
||||
ReplyHead.Tos = 0;
|
||||
ReplyHead.Fragment = 0;
|
||||
ReplyHead.Ttl = 64;
|
||||
ReplyHead.Protocol = EFI_IP_PROTO_ICMP;
|
||||
ReplyHead.Src = 0;
|
||||
ReplyHead.Tos = 0;
|
||||
ReplyHead.Fragment = 0;
|
||||
ReplyHead.Ttl = 64;
|
||||
ReplyHead.Protocol = EFI_IP_PROTO_ICMP;
|
||||
ReplyHead.Src = 0;
|
||||
|
||||
//
|
||||
// Ip4Output will select a source for us
|
||||
@@ -270,7 +266,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process the ICMP query message. If it is an ICMP echo
|
||||
request, answer it. Otherwise deliver it to upper layer.
|
||||
@@ -287,19 +282,19 @@ ON_EXIT:
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4ProcessIcmpQuery (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_ICMP_QUERY_HEAD Icmp;
|
||||
IP4_ICMP_QUERY_HEAD Icmp;
|
||||
|
||||
if (Packet->TotalSize < sizeof (Icmp)) {
|
||||
NetbufFree (Packet);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
|
||||
|
||||
if (Icmp.Head.Type == ICMP_ECHO_REQUEST) {
|
||||
return Ip4IcmpReplyEcho (IpSb, Head, Packet);
|
||||
@@ -308,7 +303,6 @@ Ip4ProcessIcmpQuery (
|
||||
return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle the ICMP packet. First validate the message format,
|
||||
then according to the message types, process it as query or
|
||||
@@ -326,35 +320,33 @@ Ip4ProcessIcmpQuery (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4IcmpHandle (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_ICMP_HEAD Icmp;
|
||||
UINT16 Checksum;
|
||||
IP4_ICMP_HEAD Icmp;
|
||||
UINT16 Checksum;
|
||||
|
||||
if (Packet->TotalSize < sizeof (Icmp)) {
|
||||
goto DROP;
|
||||
}
|
||||
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
|
||||
|
||||
if (Icmp.Type > ICMP_TYPE_MAX) {
|
||||
goto DROP;
|
||||
}
|
||||
|
||||
Checksum = (UINT16) (~NetbufChecksum (Packet));
|
||||
Checksum = (UINT16)(~NetbufChecksum (Packet));
|
||||
if ((Icmp.Checksum != 0) && (Checksum != 0)) {
|
||||
goto DROP;
|
||||
}
|
||||
|
||||
if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_ERROR_MESSAGE) {
|
||||
return Ip4ProcessIcmpError (IpSb, Head, Packet);
|
||||
|
||||
} else if (mIcmpClass[Icmp.Type].IcmpClass == ICMP_QUERY_MESSAGE) {
|
||||
return Ip4ProcessIcmpQuery (IpSb, Head, Packet);
|
||||
|
||||
}
|
||||
|
||||
DROP:
|
||||
|
@@ -9,26 +9,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef __EFI_IP4_ICMP_H__
|
||||
#define __EFI_IP4_ICMP_H__
|
||||
|
||||
//
|
||||
// ICMP type definitions
|
||||
//
|
||||
#define ICMP_ECHO_REPLY 0
|
||||
#define ICMP_DEST_UNREACHABLE 3
|
||||
#define ICMP_SOURCE_QUENCH 4
|
||||
#define ICMP_REDIRECT 5
|
||||
#define ICMP_ECHO_REQUEST 8
|
||||
#define ICMP_TIME_EXCEEDED 11
|
||||
#define ICMP_PARAMETER_PROBLEM 12
|
||||
#define ICMP_TIMESTAMP 13
|
||||
#define ICMP_INFO_REQUEST 15
|
||||
#define ICMP_INFO_REPLY 16
|
||||
#define ICMP_TYPE_MAX ICMP_INFO_REPLY
|
||||
//
|
||||
// ICMP type definitions
|
||||
//
|
||||
#define ICMP_ECHO_REPLY 0
|
||||
#define ICMP_DEST_UNREACHABLE 3
|
||||
#define ICMP_SOURCE_QUENCH 4
|
||||
#define ICMP_REDIRECT 5
|
||||
#define ICMP_ECHO_REQUEST 8
|
||||
#define ICMP_TIME_EXCEEDED 11
|
||||
#define ICMP_PARAMETER_PROBLEM 12
|
||||
#define ICMP_TIMESTAMP 13
|
||||
#define ICMP_INFO_REQUEST 15
|
||||
#define ICMP_INFO_REPLY 16
|
||||
#define ICMP_TYPE_MAX ICMP_INFO_REPLY
|
||||
|
||||
#define ICMP_DEFAULT_CODE 0
|
||||
#define ICMP_DEFAULT_CODE 0
|
||||
|
||||
//
|
||||
// ICMP code definitions for ICMP_DEST_UNREACHABLE
|
||||
//
|
||||
//
|
||||
// ICMP code definitions for ICMP_DEST_UNREACHABLE
|
||||
//
|
||||
#define ICMP_NET_UNREACHABLE 0
|
||||
#define ICMP_HOST_UNREACHABLE 1
|
||||
#define ICMP_PROTO_UNREACHABLE 2 // Host may generate
|
||||
@@ -43,31 +43,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define ICMP_NET_UNREACHABLE_TOS 11
|
||||
#define ICMP_HOST_UNREACHABLE_TOS 12
|
||||
|
||||
//
|
||||
// ICMP code definitions for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
#define ICMP_TIMEOUT_IN_TRANSIT 0
|
||||
#define ICMP_TIMEOUT_REASSEMBLE 1 // Host may generate
|
||||
//
|
||||
// ICMP code definitions for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
#define ICMP_TIMEOUT_IN_TRANSIT 0
|
||||
#define ICMP_TIMEOUT_REASSEMBLE 1 // Host may generate
|
||||
|
||||
//
|
||||
// ICMP code definitions for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
#define ICMP_NET_REDIRECT 0
|
||||
#define ICMP_HOST_REDIRECT 1
|
||||
#define ICMP_NET_TOS_REDIRECT 2
|
||||
#define ICMP_HOST_TOS_REDIRECT 3
|
||||
//
|
||||
// ICMP code definitions for ICMP_TIME_EXCEEDED
|
||||
//
|
||||
#define ICMP_NET_REDIRECT 0
|
||||
#define ICMP_HOST_REDIRECT 1
|
||||
#define ICMP_NET_TOS_REDIRECT 2
|
||||
#define ICMP_HOST_TOS_REDIRECT 3
|
||||
|
||||
//
|
||||
// ICMP message classes, each class of ICMP message shares
|
||||
// a common message format. INVALID_MESSAGE is only a flag.
|
||||
//
|
||||
#define ICMP_INVALID_MESSAGE 0
|
||||
#define ICMP_ERROR_MESSAGE 1
|
||||
#define ICMP_QUERY_MESSAGE 2
|
||||
//
|
||||
// ICMP message classes, each class of ICMP message shares
|
||||
// a common message format. INVALID_MESSAGE is only a flag.
|
||||
//
|
||||
#define ICMP_INVALID_MESSAGE 0
|
||||
#define ICMP_ERROR_MESSAGE 1
|
||||
#define ICMP_QUERY_MESSAGE 2
|
||||
|
||||
typedef struct {
|
||||
UINT8 IcmpType;
|
||||
UINT8 IcmpClass;
|
||||
UINT8 IcmpType;
|
||||
UINT8 IcmpClass;
|
||||
} IP4_ICMP_CLASS;
|
||||
|
||||
extern IP4_ICMP_CLASS mIcmpClass[];
|
||||
@@ -90,8 +90,9 @@ extern EFI_IP4_ICMP_TYPE mIp4SupportedIcmp[];
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4IcmpHandle (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -24,7 +24,7 @@ EFI_MAC_ADDRESS mZeroMacAddress;
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameSentDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -37,8 +37,8 @@ Ip4OnFrameSentDpc (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameSent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ Ip4OnFrameSent (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnArpResolvedDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -67,8 +67,8 @@ Ip4OnArpResolvedDpc (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnArpResolved (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ Ip4OnArpResolved (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameReceivedDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -98,8 +98,8 @@ Ip4OnFrameReceivedDpc (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameReceived (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -115,13 +115,12 @@ Ip4OnFrameReceived (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelFrameArp (
|
||||
IN IP4_ARP_QUE *ArpQue,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
IN IP4_ARP_QUE *ArpQue,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Wrap a transmit request into a newly allocated IP4_LINK_TX_TOKEN.
|
||||
|
||||
@@ -140,12 +139,12 @@ Ip4CancelFrameArp (
|
||||
**/
|
||||
IP4_LINK_TX_TOKEN *
|
||||
Ip4WrapLinkTxToken (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context,
|
||||
IN IP4_SERVICE *IpSb
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context,
|
||||
IN IP4_SERVICE *IpSb
|
||||
)
|
||||
{
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
|
||||
@@ -154,8 +153,10 @@ Ip4WrapLinkTxToken (
|
||||
EFI_STATUS Status;
|
||||
UINT32 Count;
|
||||
|
||||
Token = AllocatePool (sizeof (IP4_LINK_TX_TOKEN) + \
|
||||
(Packet->BlockOpNum - 1) * sizeof (EFI_MANAGED_NETWORK_FRAGMENT_DATA));
|
||||
Token = AllocatePool (
|
||||
sizeof (IP4_LINK_TX_TOKEN) + \
|
||||
(Packet->BlockOpNum - 1) * sizeof (EFI_MANAGED_NETWORK_FRAGMENT_DATA)
|
||||
);
|
||||
|
||||
if (Token == NULL) {
|
||||
return NULL;
|
||||
@@ -173,8 +174,8 @@ Ip4WrapLinkTxToken (
|
||||
CopyMem (&Token->DstMac, &mZeroMacAddress, sizeof (Token->DstMac));
|
||||
CopyMem (&Token->SrcMac, &Interface->Mac, sizeof (Token->SrcMac));
|
||||
|
||||
MnpToken = &(Token->MnpToken);
|
||||
MnpToken->Status = EFI_NOT_READY;
|
||||
MnpToken = &(Token->MnpToken);
|
||||
MnpToken->Status = EFI_NOT_READY;
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@@ -189,8 +190,8 @@ Ip4WrapLinkTxToken (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MnpTxData = &Token->MnpTxData;
|
||||
MnpToken->Packet.TxData = MnpTxData;
|
||||
MnpTxData = &Token->MnpTxData;
|
||||
MnpToken->Packet.TxData = MnpTxData;
|
||||
|
||||
MnpTxData->DestinationAddress = &Token->DstMac;
|
||||
MnpTxData->SourceAddress = &Token->SrcMac;
|
||||
@@ -198,15 +199,14 @@ Ip4WrapLinkTxToken (
|
||||
MnpTxData->DataLength = Packet->TotalSize;
|
||||
MnpTxData->HeaderLength = 0;
|
||||
|
||||
Count = Packet->BlockOpNum;
|
||||
Count = Packet->BlockOpNum;
|
||||
|
||||
NetbufBuildExt (Packet, (NET_FRAGMENT *) MnpTxData->FragmentTable, &Count);
|
||||
MnpTxData->FragmentCount = (UINT16)Count;
|
||||
NetbufBuildExt (Packet, (NET_FRAGMENT *)MnpTxData->FragmentTable, &Count);
|
||||
MnpTxData->FragmentCount = (UINT16)Count;
|
||||
|
||||
return Token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the link layer transmit token. It will close the event
|
||||
then free the memory used.
|
||||
@@ -216,7 +216,7 @@ Ip4WrapLinkTxToken (
|
||||
**/
|
||||
VOID
|
||||
Ip4FreeLinkTxToken (
|
||||
IN IP4_LINK_TX_TOKEN *Token
|
||||
IN IP4_LINK_TX_TOKEN *Token
|
||||
)
|
||||
{
|
||||
NET_CHECK_SIGNATURE (Token, IP4_FRAME_TX_SIGNATURE);
|
||||
@@ -225,7 +225,6 @@ Ip4FreeLinkTxToken (
|
||||
FreePool (Token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create an IP_ARP_QUE structure to request ARP service.
|
||||
|
||||
@@ -238,12 +237,12 @@ Ip4FreeLinkTxToken (
|
||||
**/
|
||||
IP4_ARP_QUE *
|
||||
Ip4CreateArpQue (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR DestIp
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR DestIp
|
||||
)
|
||||
{
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
EFI_STATUS Status;
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ArpQue = AllocatePool (sizeof (IP4_ARP_QUE));
|
||||
|
||||
@@ -270,13 +269,12 @@ Ip4CreateArpQue (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ArpQue->Ip = DestIp;
|
||||
ArpQue->Ip = DestIp;
|
||||
CopyMem (&ArpQue->Mac, &mZeroMacAddress, sizeof (ArpQue->Mac));
|
||||
|
||||
return ArpQue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove all the transmit requests queued on the ARP queue, then free it.
|
||||
|
||||
@@ -287,8 +285,8 @@ Ip4CreateArpQue (
|
||||
**/
|
||||
VOID
|
||||
Ip4FreeArpQue (
|
||||
IN IP4_ARP_QUE *ArpQue,
|
||||
IN EFI_STATUS IoStatus
|
||||
IN IP4_ARP_QUE *ArpQue,
|
||||
IN EFI_STATUS IoStatus
|
||||
)
|
||||
{
|
||||
NET_CHECK_SIGNATURE (ArpQue, IP4_FRAME_ARP_SIGNATURE);
|
||||
@@ -302,7 +300,6 @@ Ip4FreeArpQue (
|
||||
FreePool (ArpQue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a link layer receive token to wrap the receive request
|
||||
|
||||
@@ -317,10 +314,10 @@ Ip4FreeArpQue (
|
||||
**/
|
||||
IP4_LINK_RX_TOKEN *
|
||||
Ip4CreateLinkRxToken (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
|
||||
@@ -338,8 +335,8 @@ Ip4CreateLinkRxToken (
|
||||
Token->CallBack = CallBack;
|
||||
Token->Context = Context;
|
||||
|
||||
MnpToken = &Token->MnpToken;
|
||||
MnpToken->Status = EFI_NOT_READY;
|
||||
MnpToken = &Token->MnpToken;
|
||||
MnpToken->Status = EFI_NOT_READY;
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@@ -358,7 +355,6 @@ Ip4CreateLinkRxToken (
|
||||
return Token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the link layer request token. It will close the event
|
||||
then free the memory used.
|
||||
@@ -368,17 +364,15 @@ Ip4CreateLinkRxToken (
|
||||
**/
|
||||
VOID
|
||||
Ip4FreeFrameRxToken (
|
||||
IN IP4_LINK_RX_TOKEN *Token
|
||||
IN IP4_LINK_RX_TOKEN *Token
|
||||
)
|
||||
{
|
||||
|
||||
NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE);
|
||||
|
||||
gBS->CloseEvent (Token->MnpToken.Event);
|
||||
FreePool (Token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove all the frames on the ARP queue that pass the FrameToCancel,
|
||||
that is, either FrameToCancel is NULL or it returns true for the frame.
|
||||
@@ -392,15 +386,15 @@ Ip4FreeFrameRxToken (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelFrameArp (
|
||||
IN IP4_ARP_QUE *ArpQue,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
IN IP4_ARP_QUE *ArpQue,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &ArpQue->Frames) {
|
||||
Token = NET_LIST_USER_STRUCT (Entry, IP4_LINK_TX_TOKEN, Link);
|
||||
@@ -414,7 +408,6 @@ Ip4CancelFrameArp (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove all the frames on the interface that pass the FrameToCancel,
|
||||
either queued on ARP queues or that have already been delivered to
|
||||
@@ -430,16 +423,16 @@ Ip4CancelFrameArp (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelFrames (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
|
||||
//
|
||||
// Cancel all the pending frames on ARP requests
|
||||
@@ -467,7 +460,6 @@ Ip4CancelFrames (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create an IP4_INTERFACE. Delay the creation of ARP instance until
|
||||
the interface is configured.
|
||||
@@ -488,8 +480,8 @@ Ip4CreateInterface (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
)
|
||||
{
|
||||
IP4_INTERFACE *Interface;
|
||||
EFI_SIMPLE_NETWORK_MODE SnpMode;
|
||||
IP4_INTERFACE *Interface;
|
||||
EFI_SIMPLE_NETWORK_MODE SnpMode;
|
||||
|
||||
if (Mnp == NULL) {
|
||||
return NULL;
|
||||
@@ -503,7 +495,7 @@ Ip4CreateInterface (
|
||||
|
||||
Interface->Signature = IP4_INTERFACE_SIGNATURE;
|
||||
InitializeListHead (&Interface->Link);
|
||||
Interface->RefCnt = 1;
|
||||
Interface->RefCnt = 1;
|
||||
|
||||
Interface->Ip = IP4_ALLZERO_ADDRESS;
|
||||
Interface->SubnetMask = IP4_ALLZERO_ADDRESS;
|
||||
@@ -530,7 +522,7 @@ Ip4CreateInterface (
|
||||
|
||||
CopyMem (&Interface->Mac, &SnpMode.CurrentAddress, sizeof (Interface->Mac));
|
||||
CopyMem (&Interface->BroadcastMac, &SnpMode.BroadcastAddress, sizeof (Interface->BroadcastMac));
|
||||
Interface->HwaddrLen = SnpMode.HwAddressSize;
|
||||
Interface->HwaddrLen = SnpMode.HwAddressSize;
|
||||
|
||||
InitializeListHead (&Interface->IpInstances);
|
||||
Interface->PromiscRecv = FALSE;
|
||||
@@ -538,7 +530,6 @@ Ip4CreateInterface (
|
||||
return Interface;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the interface's address, create and configure
|
||||
the ARP child if necessary.
|
||||
@@ -554,13 +545,13 @@ Ip4CreateInterface (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4SetAddress (
|
||||
IN OUT IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_ADDR SubnetMask
|
||||
IN OUT IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_ADDR SubnetMask
|
||||
)
|
||||
{
|
||||
EFI_ARP_CONFIG_DATA ArpConfig;
|
||||
EFI_STATUS Status;
|
||||
EFI_ARP_CONFIG_DATA ArpConfig;
|
||||
EFI_STATUS Status;
|
||||
|
||||
NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE);
|
||||
|
||||
@@ -572,10 +563,10 @@ Ip4SetAddress (
|
||||
// RFC793. If that isn't the case, we are aggregating the
|
||||
// networks, use the subnet's mask instead.
|
||||
//
|
||||
Interface->Ip = IpAddr;
|
||||
Interface->SubnetMask = SubnetMask;
|
||||
Interface->SubnetBrdcast = (IpAddr | ~SubnetMask);
|
||||
Interface->NetBrdcast = (IpAddr | ~SubnetMask);
|
||||
Interface->Ip = IpAddr;
|
||||
Interface->SubnetMask = SubnetMask;
|
||||
Interface->SubnetBrdcast = (IpAddr | ~SubnetMask);
|
||||
Interface->NetBrdcast = (IpAddr | ~SubnetMask);
|
||||
|
||||
//
|
||||
// Do clean up for Arp child
|
||||
@@ -621,7 +612,7 @@ Ip4SetAddress (
|
||||
Status = gBS->OpenProtocol (
|
||||
Interface->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
(VOID **) &Interface->Arp,
|
||||
(VOID **)&Interface->Arp,
|
||||
Interface->Image,
|
||||
Interface->Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@@ -667,7 +658,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Filter function to cancel all the frame related to an IP instance.
|
||||
|
||||
@@ -682,19 +672,17 @@ ON_ERROR:
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4CancelInstanceFrame (
|
||||
IN IP4_LINK_TX_TOKEN *Frame,
|
||||
IN VOID *Context
|
||||
IN IP4_LINK_TX_TOKEN *Frame,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
if (Frame->IpInstance == (IP4_PROTOCOL *) Context) {
|
||||
if (Frame->IpInstance == (IP4_PROTOCOL *)Context) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
If there is a pending receive request, cancel it. Don't call
|
||||
the receive request's callback because this function can be only
|
||||
@@ -709,11 +697,11 @@ Ip4CancelInstanceFrame (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelReceive (
|
||||
IN IP4_INTERFACE *Interface
|
||||
IN IP4_INTERFACE *Interface
|
||||
)
|
||||
{
|
||||
EFI_TPL OldTpl;
|
||||
IP4_LINK_RX_TOKEN *Token;
|
||||
EFI_TPL OldTpl;
|
||||
IP4_LINK_RX_TOKEN *Token;
|
||||
|
||||
if ((Token = Interface->RecvRequest) != NULL) {
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
@@ -725,7 +713,6 @@ Ip4CancelReceive (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the interface used by IpInstance. All the IP instance with
|
||||
the same Ip/Netmask pair share the same interface. It is reference
|
||||
@@ -742,8 +729,8 @@ Ip4CancelReceive (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4FreeInterface (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL
|
||||
)
|
||||
{
|
||||
NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE);
|
||||
@@ -773,11 +760,11 @@ Ip4FreeInterface (
|
||||
|
||||
if (Interface->Arp != NULL) {
|
||||
gBS->CloseProtocol (
|
||||
Interface->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
Interface->Image,
|
||||
Interface->Controller
|
||||
);
|
||||
Interface->ArpHandle,
|
||||
&gEfiArpProtocolGuid,
|
||||
Interface->Image,
|
||||
Interface->Controller
|
||||
);
|
||||
|
||||
NetLibDestroyServiceChild (
|
||||
Interface->Controller,
|
||||
@@ -805,16 +792,16 @@ Ip4FreeInterface (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4SendFrameToDefaultRoute (
|
||||
IN IP4_ARP_QUE *ArpQue
|
||||
IN IP4_ARP_QUE *ArpQue
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
IP4_ADDR Gateway;
|
||||
EFI_STATUS Status;
|
||||
IP4_ROUTE_ENTRY *DefaultRoute;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
IP4_ADDR Gateway;
|
||||
EFI_STATUS Status;
|
||||
IP4_ROUTE_ENTRY *DefaultRoute;
|
||||
|
||||
//
|
||||
// ARP resolve failed when using /32 subnet mask.
|
||||
@@ -830,18 +817,22 @@ Ip4SendFrameToDefaultRoute (
|
||||
if (Token->IpInstance != NULL) {
|
||||
RtCacheEntry = Ip4FindRouteCache (Token->IpInstance->RouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip);
|
||||
}
|
||||
|
||||
if (RtCacheEntry == NULL) {
|
||||
RtCacheEntry = Ip4FindRouteCache (Token->IpSb->DefaultRouteTable, NTOHL (ArpQue->Ip), Token->Interface->Ip);
|
||||
}
|
||||
|
||||
if (RtCacheEntry == NULL) {
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
DefaultRoute = (IP4_ROUTE_ENTRY*)RtCacheEntry->Tag;
|
||||
|
||||
DefaultRoute = (IP4_ROUTE_ENTRY *)RtCacheEntry->Tag;
|
||||
if (DefaultRoute == NULL) {
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to send the frame to the default route.
|
||||
//
|
||||
@@ -850,15 +841,17 @@ Ip4SendFrameToDefaultRoute (
|
||||
//
|
||||
// ARP resolve for the default route is failed, return error to caller.
|
||||
//
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
RtCacheEntry->NextHop = Gateway;
|
||||
Status = Ip4SendFrame (Token->Interface,Token->IpInstance,Token->Packet,Gateway,Token->CallBack,Token->Context,Token->IpSb);
|
||||
Status = Ip4SendFrame (Token->Interface, Token->IpInstance, Token->Packet, Gateway, Token->CallBack, Token->Context, Token->IpSb);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status= EFI_NO_MAPPING;
|
||||
Status = EFI_NO_MAPPING;
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Ip4FreeRouteCacheEntry (RtCacheEntry);
|
||||
}
|
||||
|
||||
@@ -868,12 +861,12 @@ ON_ERROR:
|
||||
if (RtCacheEntry != NULL) {
|
||||
Ip4FreeRouteCacheEntry (RtCacheEntry);
|
||||
}
|
||||
|
||||
Token->CallBack (Token->IpInstance, Token->Packet, Status, 0, Token->Context);
|
||||
Ip4FreeLinkTxToken (Token);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Callback function when ARP request are finished. It will cancel
|
||||
all the queued frame if the ARP requests failed. Or transmit them
|
||||
@@ -886,18 +879,18 @@ ON_ERROR:
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnArpResolvedDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
IP4_INTERFACE *Interface;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS IoStatus;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
IP4_INTERFACE *Interface;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS IoStatus;
|
||||
|
||||
ArpQue = (IP4_ARP_QUE *) Context;
|
||||
ArpQue = (IP4_ARP_QUE *)Context;
|
||||
NET_CHECK_SIGNATURE (ArpQue, IP4_FRAME_ARP_SIGNATURE);
|
||||
|
||||
RemoveEntryList (&ArpQue->Link);
|
||||
@@ -919,6 +912,7 @@ Ip4OnArpResolvedDpc (
|
||||
//
|
||||
IoStatus = Ip4SendFrameToDefaultRoute (ArpQue);
|
||||
}
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@@ -927,13 +921,13 @@ Ip4OnArpResolvedDpc (
|
||||
// queue. It isn't necessary for us to cache the ARP binding because
|
||||
// we always check the ARP cache first before transmit.
|
||||
//
|
||||
IoStatus = EFI_SUCCESS;
|
||||
IoStatus = EFI_SUCCESS;
|
||||
Interface = ArpQue->Interface;
|
||||
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &ArpQue->Frames) {
|
||||
RemoveEntryList (Entry);
|
||||
|
||||
Token = NET_LIST_USER_STRUCT (Entry, IP4_LINK_TX_TOKEN, Link);
|
||||
Token = NET_LIST_USER_STRUCT (Entry, IP4_LINK_TX_TOKEN, Link);
|
||||
CopyMem (&Token->DstMac, &ArpQue->Mac, sizeof (Token->DstMac));
|
||||
|
||||
//
|
||||
@@ -970,8 +964,8 @@ ON_EXIT:
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnArpResolved (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -980,8 +974,6 @@ Ip4OnArpResolved (
|
||||
QueueDpc (TPL_CALLBACK, Ip4OnArpResolvedDpc, Context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Callback function when frame transmission is finished. It will
|
||||
call the frame owner's callback function to tell it the result.
|
||||
@@ -992,23 +984,23 @@ Ip4OnArpResolved (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameSentDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
|
||||
Token = (IP4_LINK_TX_TOKEN *) Context;
|
||||
Token = (IP4_LINK_TX_TOKEN *)Context;
|
||||
NET_CHECK_SIGNATURE (Token, IP4_FRAME_TX_SIGNATURE);
|
||||
|
||||
RemoveEntryList (&Token->Link);
|
||||
|
||||
Token->CallBack (
|
||||
Token->IpInstance,
|
||||
Token->Packet,
|
||||
Token->MnpToken.Status,
|
||||
0,
|
||||
Token->Context
|
||||
);
|
||||
Token->IpInstance,
|
||||
Token->Packet,
|
||||
Token->MnpToken.Status,
|
||||
0,
|
||||
Token->Context
|
||||
);
|
||||
|
||||
Ip4FreeLinkTxToken (Token);
|
||||
}
|
||||
@@ -1023,8 +1015,8 @@ Ip4OnFrameSentDpc (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameSent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1033,8 +1025,6 @@ Ip4OnFrameSent (
|
||||
QueueDpc (TPL_CALLBACK, Ip4OnFrameSentDpc, Context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Send a frame from the interface. If the next hop is broadcast or
|
||||
multicast address, it is transmitted immediately. If the next hop
|
||||
@@ -1060,20 +1050,20 @@ Ip4OnFrameSent (
|
||||
**/
|
||||
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,
|
||||
IN IP4_SERVICE *IpSb
|
||||
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,
|
||||
IN IP4_SERVICE *IpSb
|
||||
)
|
||||
{
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
EFI_ARP_PROTOCOL *Arp;
|
||||
EFI_STATUS Status;
|
||||
IP4_LINK_TX_TOKEN *Token;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ARP_QUE *ArpQue;
|
||||
EFI_ARP_PROTOCOL *Arp;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (Interface->Configured);
|
||||
|
||||
@@ -1092,9 +1082,7 @@ Ip4SendFrame (
|
||||
if (NextHop == IP4_ALLONE_ADDRESS) {
|
||||
CopyMem (&Token->DstMac, &Interface->BroadcastMac, sizeof (Token->DstMac));
|
||||
goto SEND_NOW;
|
||||
|
||||
} else if (IP4_IS_MULTICAST (NextHop)) {
|
||||
|
||||
Status = Ip4GetMulticastMac (Interface->Mnp, NextHop, &Token->DstMac);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -1120,7 +1108,6 @@ Ip4SendFrame (
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
goto SEND_NOW;
|
||||
|
||||
} else if (Status != EFI_NOT_READY) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
@@ -1187,7 +1174,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Call back function when the received packet is freed.
|
||||
Check Ip4OnFrameReceived for information.
|
||||
@@ -1198,19 +1184,18 @@ ON_ERROR:
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4RecycleFrame (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
IP4_LINK_RX_TOKEN *Frame;
|
||||
IP4_LINK_RX_TOKEN *Frame;
|
||||
|
||||
Frame = (IP4_LINK_RX_TOKEN *) Context;
|
||||
Frame = (IP4_LINK_RX_TOKEN *)Context;
|
||||
NET_CHECK_SIGNATURE (Frame, IP4_FRAME_RX_SIGNATURE);
|
||||
|
||||
gBS->SignalEvent (Frame->MnpToken.Packet.RxData->RecycleEvent);
|
||||
Ip4FreeFrameRxToken (Frame);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Received a frame from MNP, wrap it in net buffer then deliver
|
||||
it to IP's input function. The ownship of the packet also
|
||||
@@ -1225,7 +1210,7 @@ Ip4RecycleFrame (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameReceivedDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
|
||||
@@ -1235,7 +1220,7 @@ Ip4OnFrameReceivedDpc (
|
||||
NET_BUF *Packet;
|
||||
UINT32 Flag;
|
||||
|
||||
Token = (IP4_LINK_RX_TOKEN *) Context;
|
||||
Token = (IP4_LINK_RX_TOKEN *)Context;
|
||||
NET_CHECK_SIGNATURE (Token, IP4_FRAME_RX_SIGNATURE);
|
||||
|
||||
//
|
||||
@@ -1251,7 +1236,7 @@ Ip4OnFrameReceivedDpc (
|
||||
Token->CallBack (Token->IpInstance, NULL, MnpToken->Status, 0, Token->Context);
|
||||
Ip4FreeFrameRxToken (Token);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1269,7 +1254,7 @@ Ip4OnFrameReceivedDpc (
|
||||
Token->CallBack (Token->IpInstance, NULL, EFI_OUT_OF_RESOURCES, 0, Token->Context);
|
||||
Ip4FreeFrameRxToken (Token);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Flag = (MnpRxData->BroadcastFlag ? IP4_LINK_BROADCAST : 0);
|
||||
@@ -1289,8 +1274,8 @@ Ip4OnFrameReceivedDpc (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFrameReceived (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1299,7 +1284,6 @@ Ip4OnFrameReceived (
|
||||
QueueDpc (TPL_CALLBACK, Ip4OnFrameReceivedDpc, Context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Request to receive the packet from the interface.
|
||||
|
||||
@@ -1317,14 +1301,14 @@ Ip4OnFrameReceived (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4ReceiveFrame (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
IP4_LINK_RX_TOKEN *Token;
|
||||
EFI_STATUS Status;
|
||||
IP4_LINK_RX_TOKEN *Token;
|
||||
EFI_STATUS Status;
|
||||
|
||||
NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE);
|
||||
|
||||
@@ -1339,11 +1323,12 @@ Ip4ReceiveFrame (
|
||||
}
|
||||
|
||||
Interface->RecvRequest = Token;
|
||||
Status = Interface->Mnp->Receive (Interface->Mnp, &Token->MnpToken);
|
||||
Status = Interface->Mnp->Receive (Interface->Mnp, &Token->MnpToken);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Interface->RecvRequest = NULL;
|
||||
Ip4FreeFrameRxToken (Token);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef __EFI_IP4_IF_H__
|
||||
#define __EFI_IP4_IF_H__
|
||||
|
||||
#define IP4_FRAME_RX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'R')
|
||||
#define IP4_FRAME_TX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'T')
|
||||
#define IP4_FRAME_ARP_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'A')
|
||||
#define IP4_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', 'I', 'F')
|
||||
#define IP4_FRAME_RX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'R')
|
||||
#define IP4_FRAME_TX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'T')
|
||||
#define IP4_FRAME_ARP_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'A')
|
||||
#define IP4_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', 'I', 'F')
|
||||
|
||||
/**
|
||||
This prototype is used by both receive and transmission.
|
||||
@@ -40,11 +40,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
typedef
|
||||
VOID
|
||||
(*IP4_FRAME_CALLBACK)(
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 LinkFlag,
|
||||
IN VOID *Context
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 LinkFlag,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
///
|
||||
@@ -54,14 +54,14 @@ VOID
|
||||
/// Reference MNP's spec for information.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
IP4_INTERFACE *Interface;
|
||||
UINT32 Signature;
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
VOID *Context;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
VOID *Context;
|
||||
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
} IP4_LINK_RX_TOKEN;
|
||||
|
||||
///
|
||||
@@ -69,22 +69,22 @@ typedef struct {
|
||||
/// Upon completion, the Callback will be called.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
IP4_INTERFACE *Interface;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_INTERFACE *Interface;
|
||||
IP4_SERVICE *IpSb;
|
||||
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
NET_BUF *Packet;
|
||||
VOID *Context;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_FRAME_CALLBACK CallBack;
|
||||
NET_BUF *Packet;
|
||||
VOID *Context;
|
||||
|
||||
EFI_MAC_ADDRESS DstMac;
|
||||
EFI_MAC_ADDRESS SrcMac;
|
||||
EFI_MAC_ADDRESS DstMac;
|
||||
EFI_MAC_ADDRESS SrcMac;
|
||||
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
|
||||
EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;
|
||||
} IP4_LINK_TX_TOKEN;
|
||||
|
||||
///
|
||||
@@ -94,18 +94,18 @@ typedef struct {
|
||||
/// be sent all at once the ARP requests succeed.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
LIST_ENTRY Frames;
|
||||
IP4_INTERFACE *Interface;
|
||||
LIST_ENTRY Frames;
|
||||
IP4_INTERFACE *Interface;
|
||||
|
||||
//
|
||||
// ARP requesting staffs
|
||||
//
|
||||
EFI_EVENT OnResolved;
|
||||
IP4_ADDR Ip;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
EFI_EVENT OnResolved;
|
||||
IP4_ADDR Ip;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
} IP4_ARP_QUE;
|
||||
|
||||
/**
|
||||
@@ -121,8 +121,8 @@ typedef struct {
|
||||
typedef
|
||||
BOOLEAN
|
||||
(*IP4_FRAME_TO_CANCEL)(
|
||||
IP4_LINK_TX_TOKEN *Frame,
|
||||
VOID *Context
|
||||
IP4_LINK_TX_TOKEN *Frame,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
//
|
||||
@@ -133,53 +133,53 @@ BOOLEAN
|
||||
// with 0.0.0.0/0.0.0.0.
|
||||
//
|
||||
struct _IP4_INTERFACE {
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
UINT32 Signature;
|
||||
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 fields
|
||||
// are invalid if (Configured == FALSE)
|
||||
//
|
||||
IP4_ADDR Ip;
|
||||
IP4_ADDR SubnetMask;
|
||||
IP4_ADDR SubnetBrdcast;
|
||||
IP4_ADDR NetBrdcast;
|
||||
BOOLEAN Configured;
|
||||
IP4_ADDR Ip;
|
||||
IP4_ADDR SubnetMask;
|
||||
IP4_ADDR SubnetBrdcast;
|
||||
IP4_ADDR NetBrdcast;
|
||||
BOOLEAN Configured;
|
||||
|
||||
//
|
||||
// Handle used to create/destroy ARP child. All the IP children
|
||||
// share one MNP which is owned by IP service binding.
|
||||
//
|
||||
EFI_HANDLE Controller;
|
||||
EFI_HANDLE Image;
|
||||
EFI_HANDLE Controller;
|
||||
EFI_HANDLE Image;
|
||||
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
EFI_ARP_PROTOCOL *Arp;
|
||||
EFI_HANDLE ArpHandle;
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
EFI_ARP_PROTOCOL *Arp;
|
||||
EFI_HANDLE ArpHandle;
|
||||
|
||||
//
|
||||
// Queues to keep the frames sent and waiting ARP request.
|
||||
//
|
||||
LIST_ENTRY ArpQues;
|
||||
LIST_ENTRY SentFrames;
|
||||
IP4_LINK_RX_TOKEN *RecvRequest;
|
||||
LIST_ENTRY ArpQues;
|
||||
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;
|
||||
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.
|
||||
//
|
||||
LIST_ENTRY IpInstances;
|
||||
BOOLEAN PromiscRecv;
|
||||
LIST_ENTRY IpInstances;
|
||||
BOOLEAN PromiscRecv;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -217,9 +217,9 @@ Ip4CreateInterface (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4SetAddress (
|
||||
IN OUT IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_ADDR SubnetMask
|
||||
IN OUT IP4_INTERFACE *Interface,
|
||||
IN IP4_ADDR IpAddr,
|
||||
IN IP4_ADDR SubnetMask
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -238,8 +238,8 @@ Ip4SetAddress (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4FreeInterface (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -267,13 +267,13 @@ Ip4FreeInterface (
|
||||
**/
|
||||
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,
|
||||
IN IP4_SERVICE *IpSb
|
||||
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,
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -291,10 +291,10 @@ Ip4SendFrame (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelFrames (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -311,7 +311,7 @@ Ip4CancelFrames (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelReceive (
|
||||
IN IP4_INTERFACE *Interface
|
||||
IN IP4_INTERFACE *Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -331,10 +331,10 @@ Ip4CancelReceive (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4ReceiveFrame (
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
IN IP4_INTERFACE *Interface,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN IP4_FRAME_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
UINT32 mRouteAlertOption = 0x00000494;
|
||||
|
||||
|
||||
/**
|
||||
Init the IGMP control data of the IP4 service instance, configure
|
||||
MNP to receive ALL SYSTEM multicast.
|
||||
@@ -28,7 +27,7 @@ UINT32 mRouteAlertOption = 0x00000494;
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4InitIgmp (
|
||||
IN OUT IP4_SERVICE *IpSb
|
||||
IN OUT IP4_SERVICE *IpSb
|
||||
)
|
||||
{
|
||||
IGMP_SERVICE_DATA *IgmpCtrl;
|
||||
@@ -41,13 +40,13 @@ Ip4InitIgmp (
|
||||
//
|
||||
// Configure MNP to receive ALL_SYSTEM multicast
|
||||
//
|
||||
Group = AllocatePool (sizeof (IGMP_GROUP));
|
||||
Group = AllocatePool (sizeof (IGMP_GROUP));
|
||||
|
||||
if (Group == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Mnp = IpSb->Mnp;
|
||||
Mnp = IpSb->Mnp;
|
||||
|
||||
Group->Address = IP4_ALLSYSTEM_ADDRESS;
|
||||
Group->RefCnt = 1;
|
||||
@@ -74,7 +73,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the IGMP_GROUP structure which contains the status of multicast
|
||||
group Address in this IGMP control block
|
||||
@@ -89,12 +87,12 @@ ON_ERROR:
|
||||
**/
|
||||
IGMP_GROUP *
|
||||
Ip4FindGroup (
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN IP4_ADDR Address
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN IP4_ADDR Address
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IGMP_GROUP *Group;
|
||||
LIST_ENTRY *Entry;
|
||||
IGMP_GROUP *Group;
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IgmpCtrl->Groups) {
|
||||
Group = NET_LIST_USER_STRUCT (Entry, IGMP_GROUP, Link);
|
||||
@@ -107,7 +105,6 @@ Ip4FindGroup (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Count the number of IP4 multicast groups that are mapped to the
|
||||
same MAC address. Several IP4 multicast address may be mapped to
|
||||
@@ -122,13 +119,13 @@ Ip4FindGroup (
|
||||
**/
|
||||
INTN
|
||||
Ip4FindMac (
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN EFI_MAC_ADDRESS *Mac
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN EFI_MAC_ADDRESS *Mac
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IGMP_GROUP *Group;
|
||||
INTN Count;
|
||||
LIST_ENTRY *Entry;
|
||||
IGMP_GROUP *Group;
|
||||
INTN Count;
|
||||
|
||||
Count = 0;
|
||||
|
||||
@@ -143,7 +140,6 @@ Ip4FindMac (
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send an IGMP protocol message to the Dst, such as IGMP v1 membership report.
|
||||
|
||||
@@ -161,15 +157,15 @@ Ip4FindMac (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4SendIgmpMessage (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN UINT8 Type,
|
||||
IN IP4_ADDR Group
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN UINT8 Type,
|
||||
IN IP4_ADDR Group
|
||||
)
|
||||
{
|
||||
IP4_HEAD Head;
|
||||
NET_BUF *Packet;
|
||||
IGMP_HEAD *Igmp;
|
||||
IP4_HEAD Head;
|
||||
NET_BUF *Packet;
|
||||
IGMP_HEAD *Igmp;
|
||||
|
||||
//
|
||||
// Allocate a net buffer to hold the message
|
||||
@@ -185,7 +181,7 @@ Ip4SendIgmpMessage (
|
||||
//
|
||||
NetbufReserve (Packet, IP4_MAX_HEADLEN);
|
||||
|
||||
Igmp = (IGMP_HEAD *) NetbufAllocSpace (Packet, sizeof (IGMP_HEAD), FALSE);
|
||||
Igmp = (IGMP_HEAD *)NetbufAllocSpace (Packet, sizeof (IGMP_HEAD), FALSE);
|
||||
if (Igmp == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -194,21 +190,21 @@ Ip4SendIgmpMessage (
|
||||
Igmp->MaxRespTime = 0;
|
||||
Igmp->Checksum = 0;
|
||||
Igmp->Group = HTONL (Group);
|
||||
Igmp->Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Igmp, sizeof (IGMP_HEAD)));
|
||||
Igmp->Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)Igmp, sizeof (IGMP_HEAD)));
|
||||
|
||||
Head.Tos = 0;
|
||||
Head.Protocol = IP4_PROTO_IGMP;
|
||||
Head.Ttl = 1;
|
||||
Head.Fragment = 0;
|
||||
Head.Dst = Dst;
|
||||
Head.Src = IP4_ALLZERO_ADDRESS;
|
||||
Head.Tos = 0;
|
||||
Head.Protocol = IP4_PROTO_IGMP;
|
||||
Head.Ttl = 1;
|
||||
Head.Fragment = 0;
|
||||
Head.Dst = Dst;
|
||||
Head.Src = IP4_ALLZERO_ADDRESS;
|
||||
|
||||
return Ip4Output (
|
||||
IpSb,
|
||||
NULL,
|
||||
Packet,
|
||||
&Head,
|
||||
(UINT8 *) &mRouteAlertOption,
|
||||
(UINT8 *)&mRouteAlertOption,
|
||||
sizeof (UINT32),
|
||||
IP4_ALLZERO_ADDRESS,
|
||||
Ip4SysPacketSent,
|
||||
@@ -216,7 +212,6 @@ Ip4SendIgmpMessage (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send an IGMP membership report. Depends on whether the server is
|
||||
v1 or v2, it will send either a V1 or V2 membership report.
|
||||
@@ -232,8 +227,8 @@ Ip4SendIgmpMessage (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4SendIgmpReport (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Group
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Group
|
||||
)
|
||||
{
|
||||
if (IpSb->IgmpCtrl.Igmpv1QuerySeen != 0) {
|
||||
@@ -243,7 +238,6 @@ Ip4SendIgmpReport (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Join the multicast group on behalf of this IP4 child
|
||||
|
||||
@@ -257,8 +251,8 @@ Ip4SendIgmpReport (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4JoinGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
)
|
||||
{
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
@@ -267,15 +261,15 @@ Ip4JoinGroup (
|
||||
IGMP_GROUP *Group;
|
||||
EFI_STATUS Status;
|
||||
|
||||
IpSb = IpInstance->Service;
|
||||
IgmpCtrl = &IpSb->IgmpCtrl;
|
||||
Mnp = IpSb->Mnp;
|
||||
IpSb = IpInstance->Service;
|
||||
IgmpCtrl = &IpSb->IgmpCtrl;
|
||||
Mnp = IpSb->Mnp;
|
||||
|
||||
//
|
||||
// If the IP service already is a member in the group, just
|
||||
// increase the reference count and return.
|
||||
//
|
||||
Group = Ip4FindGroup (IgmpCtrl, Address);
|
||||
Group = Ip4FindGroup (IgmpCtrl, Address);
|
||||
|
||||
if (Group != NULL) {
|
||||
Group->RefCnt++;
|
||||
@@ -323,7 +317,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Leave the IP4 multicast group on behalf of IpInstance.
|
||||
|
||||
@@ -338,8 +331,8 @@ ON_ERROR:
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4LeaveGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
)
|
||||
{
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
@@ -348,11 +341,11 @@ Ip4LeaveGroup (
|
||||
IGMP_GROUP *Group;
|
||||
EFI_STATUS Status;
|
||||
|
||||
IpSb = IpInstance->Service;
|
||||
IgmpCtrl = &IpSb->IgmpCtrl;
|
||||
Mnp = IpSb->Mnp;
|
||||
IpSb = IpInstance->Service;
|
||||
IgmpCtrl = &IpSb->IgmpCtrl;
|
||||
Mnp = IpSb->Mnp;
|
||||
|
||||
Group = Ip4FindGroup (IgmpCtrl, Address);
|
||||
Group = Ip4FindGroup (IgmpCtrl, Address);
|
||||
|
||||
if (Group == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
@@ -383,7 +376,7 @@ Ip4LeaveGroup (
|
||||
// Send a leave report if the membership is reported by us
|
||||
// and we are talking IGMPv2.
|
||||
//
|
||||
if (Group->ReportByUs && IgmpCtrl->Igmpv1QuerySeen == 0) {
|
||||
if (Group->ReportByUs && (IgmpCtrl->Igmpv1QuerySeen == 0)) {
|
||||
Ip4SendIgmpMessage (IpSb, IP4_ALLROUTER_ADDRESS, IGMP_LEAVE_GROUP, Group->Address);
|
||||
}
|
||||
|
||||
@@ -393,7 +386,6 @@ Ip4LeaveGroup (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Handle the received IGMP message for the IP4 service instance.
|
||||
|
||||
@@ -407,16 +399,16 @@ Ip4LeaveGroup (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4IgmpHandle (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IGMP_SERVICE_DATA *IgmpCtrl;
|
||||
IGMP_HEAD Igmp;
|
||||
IGMP_GROUP *Group;
|
||||
IP4_ADDR Address;
|
||||
LIST_ENTRY *Entry;
|
||||
IGMP_SERVICE_DATA *IgmpCtrl;
|
||||
IGMP_HEAD Igmp;
|
||||
IGMP_GROUP *Group;
|
||||
IP4_ADDR Address;
|
||||
LIST_ENTRY *Entry;
|
||||
|
||||
IgmpCtrl = &IpSb->IgmpCtrl;
|
||||
|
||||
@@ -436,65 +428,64 @@ Ip4IgmpHandle (
|
||||
NetbufCopy (Packet, 0, sizeof (IGMP_HEAD), (UINT8 *)&Igmp);
|
||||
|
||||
switch (Igmp.Type) {
|
||||
case IGMP_MEMBERSHIP_QUERY:
|
||||
//
|
||||
// If MaxRespTime is zero, it is most likely that we are
|
||||
// talking to a V1 router
|
||||
//
|
||||
if (Igmp.MaxRespTime == 0) {
|
||||
IgmpCtrl->Igmpv1QuerySeen = IGMP_V1ROUTER_PRESENT;
|
||||
Igmp.MaxRespTime = 100;
|
||||
}
|
||||
|
||||
//
|
||||
// Igmp is ticking once per second but MaxRespTime is in
|
||||
// the unit of 100ms.
|
||||
//
|
||||
Igmp.MaxRespTime /= 10;
|
||||
Address = NTOHL (Igmp.Group);
|
||||
|
||||
if (Address == IP4_ALLSYSTEM_ADDRESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IgmpCtrl->Groups) {
|
||||
Group = NET_LIST_USER_STRUCT (Entry, IGMP_GROUP, Link);
|
||||
case IGMP_MEMBERSHIP_QUERY:
|
||||
//
|
||||
// If MaxRespTime is zero, it is most likely that we are
|
||||
// talking to a V1 router
|
||||
//
|
||||
if (Igmp.MaxRespTime == 0) {
|
||||
IgmpCtrl->Igmpv1QuerySeen = IGMP_V1ROUTER_PRESENT;
|
||||
Igmp.MaxRespTime = 100;
|
||||
}
|
||||
|
||||
//
|
||||
// If address is all zero, all the memberships will be reported.
|
||||
// otherwise only one is reported.
|
||||
// Igmp is ticking once per second but MaxRespTime is in
|
||||
// the unit of 100ms.
|
||||
//
|
||||
if ((Address == IP4_ALLZERO_ADDRESS) || (Address == Group->Address)) {
|
||||
Igmp.MaxRespTime /= 10;
|
||||
Address = NTOHL (Igmp.Group);
|
||||
|
||||
if (Address == IP4_ALLSYSTEM_ADDRESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IgmpCtrl->Groups) {
|
||||
Group = NET_LIST_USER_STRUCT (Entry, IGMP_GROUP, Link);
|
||||
|
||||
//
|
||||
// If the timer is pending, only update it if the time left
|
||||
// is longer than the MaxRespTime. TODO: randomize the DelayTime.
|
||||
// If address is all zero, all the memberships will be reported.
|
||||
// otherwise only one is reported.
|
||||
//
|
||||
if ((Group->DelayTime == 0) || (Group->DelayTime > Igmp.MaxRespTime)) {
|
||||
Group->DelayTime = MAX (1, Igmp.MaxRespTime);
|
||||
if ((Address == IP4_ALLZERO_ADDRESS) || (Address == Group->Address)) {
|
||||
//
|
||||
// If the timer is pending, only update it if the time left
|
||||
// is longer than the MaxRespTime. TODO: randomize the DelayTime.
|
||||
//
|
||||
if ((Group->DelayTime == 0) || (Group->DelayTime > Igmp.MaxRespTime)) {
|
||||
Group->DelayTime = MAX (1, Igmp.MaxRespTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case IGMP_V1_MEMBERSHIP_REPORT:
|
||||
case IGMP_V2_MEMBERSHIP_REPORT:
|
||||
Address = NTOHL (Igmp.Group);
|
||||
Group = Ip4FindGroup (IgmpCtrl, Address);
|
||||
case IGMP_V1_MEMBERSHIP_REPORT:
|
||||
case IGMP_V2_MEMBERSHIP_REPORT:
|
||||
Address = NTOHL (Igmp.Group);
|
||||
Group = Ip4FindGroup (IgmpCtrl, Address);
|
||||
|
||||
if ((Group != NULL) && (Group->DelayTime > 0)) {
|
||||
Group->DelayTime = 0;
|
||||
Group->ReportByUs = FALSE;
|
||||
}
|
||||
if ((Group != NULL) && (Group->DelayTime > 0)) {
|
||||
Group->DelayTime = 0;
|
||||
Group->ReportByUs = FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
NetbufFree (Packet);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The periodical timer function for IGMP. It does the following
|
||||
things:
|
||||
@@ -508,12 +499,12 @@ Ip4IgmpHandle (
|
||||
**/
|
||||
VOID
|
||||
Ip4IgmpTicking (
|
||||
IN IP4_SERVICE *IpSb
|
||||
IN IP4_SERVICE *IpSb
|
||||
)
|
||||
{
|
||||
IGMP_SERVICE_DATA *IgmpCtrl;
|
||||
LIST_ENTRY *Entry;
|
||||
IGMP_GROUP *Group;
|
||||
IGMP_SERVICE_DATA *IgmpCtrl;
|
||||
LIST_ENTRY *Entry;
|
||||
IGMP_GROUP *Group;
|
||||
|
||||
IgmpCtrl = &IpSb->IgmpCtrl;
|
||||
|
||||
@@ -539,7 +530,6 @@ Ip4IgmpTicking (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add a group address to the array of group addresses.
|
||||
The caller should make sure that no duplicated address
|
||||
@@ -557,12 +547,12 @@ Ip4IgmpTicking (
|
||||
**/
|
||||
IP4_ADDR *
|
||||
Ip4CombineGroups (
|
||||
IN IP4_ADDR *Source,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
IN IP4_ADDR *Source,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
)
|
||||
{
|
||||
IP4_ADDR *Groups;
|
||||
IP4_ADDR *Groups;
|
||||
|
||||
Groups = AllocatePool (sizeof (IP4_ADDR) * (Count + 1));
|
||||
|
||||
@@ -576,7 +566,6 @@ Ip4CombineGroups (
|
||||
return Groups;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove a group address from the array of group addresses.
|
||||
Although the function doesn't assume the byte order of the
|
||||
@@ -593,12 +582,12 @@ Ip4CombineGroups (
|
||||
**/
|
||||
INTN
|
||||
Ip4RemoveGroupAddr (
|
||||
IN OUT IP4_ADDR *Groups,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
IN OUT IP4_ADDR *Groups,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
UINT32 Index;
|
||||
|
||||
for (Index = 0; Index < Count; Index++) {
|
||||
if (Groups[Index] == Addr) {
|
||||
|
@@ -16,15 +16,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define IGMP_V2_MEMBERSHIP_REPORT 0x16
|
||||
#define IGMP_LEAVE_GROUP 0x17
|
||||
|
||||
#define IGMP_V1ROUTER_PRESENT 400
|
||||
#define IGMP_UNSOLICIATED_REPORT 10
|
||||
#define IGMP_V1ROUTER_PRESENT 400
|
||||
#define IGMP_UNSOLICIATED_REPORT 10
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 MaxRespTime;
|
||||
UINT16 Checksum;
|
||||
IP4_ADDR Group;
|
||||
UINT8 Type;
|
||||
UINT8 MaxRespTime;
|
||||
UINT16 Checksum;
|
||||
IP4_ADDR Group;
|
||||
} IGMP_HEAD;
|
||||
#pragma pack()
|
||||
|
||||
@@ -35,12 +35,12 @@ typedef struct {
|
||||
/// "idle member" state.
|
||||
///
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Address;
|
||||
INTN DelayTime;
|
||||
BOOLEAN ReportByUs;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Address;
|
||||
INTN DelayTime;
|
||||
BOOLEAN ReportByUs;
|
||||
EFI_MAC_ADDRESS Mac;
|
||||
} IGMP_GROUP;
|
||||
|
||||
///
|
||||
@@ -49,8 +49,8 @@ typedef struct {
|
||||
/// connected network is v1 or v2.
|
||||
///
|
||||
typedef struct {
|
||||
INTN Igmpv1QuerySeen;
|
||||
LIST_ENTRY Groups;
|
||||
INTN Igmpv1QuerySeen;
|
||||
LIST_ENTRY Groups;
|
||||
} IGMP_SERVICE_DATA;
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ typedef struct {
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4InitIgmp (
|
||||
IN OUT IP4_SERVICE *IpSb
|
||||
IN OUT IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -82,8 +82,8 @@ Ip4InitIgmp (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4JoinGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -100,8 +100,8 @@ Ip4JoinGroup (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4LeaveGroup (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -117,9 +117,9 @@ Ip4LeaveGroup (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4IgmpHandle (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ Ip4IgmpHandle (
|
||||
**/
|
||||
VOID
|
||||
Ip4IgmpTicking (
|
||||
IN IP4_SERVICE *IpSb
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -155,9 +155,9 @@ Ip4IgmpTicking (
|
||||
**/
|
||||
IP4_ADDR *
|
||||
Ip4CombineGroups (
|
||||
IN IP4_ADDR *Source,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
IN IP4_ADDR *Source,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -176,9 +176,9 @@ Ip4CombineGroups (
|
||||
**/
|
||||
INTN
|
||||
Ip4RemoveGroupAddr (
|
||||
IN OUT IP4_ADDR *Groups,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
IN OUT IP4_ADDR *Groups,
|
||||
IN UINT32 Count,
|
||||
IN IP4_ADDR Addr
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -195,7 +195,8 @@ Ip4RemoveGroupAddr (
|
||||
**/
|
||||
IGMP_GROUP *
|
||||
Ip4FindGroup (
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN IP4_ADDR Address
|
||||
IN IGMP_SERVICE_DATA *IgmpCtrl,
|
||||
IN IP4_ADDR Address
|
||||
);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -60,8 +60,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// successfully configured, it goes to CONFIGED. if configure NULL
|
||||
// is called, it becomes UNCONFIGED again.
|
||||
//
|
||||
#define IP4_STATE_UNCONFIGED 0
|
||||
#define IP4_STATE_CONFIGED 1
|
||||
#define IP4_STATE_UNCONFIGED 0
|
||||
#define IP4_STATE_CONFIGED 1
|
||||
|
||||
//
|
||||
// The state of IP4 service. It starts from UNSTARTED. It transits
|
||||
@@ -69,11 +69,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// configured, it becomes CONFIGED. and if partly destroyed, it goes
|
||||
// to DESTROY.
|
||||
//
|
||||
#define IP4_SERVICE_UNSTARTED 0
|
||||
#define IP4_SERVICE_STARTED 1
|
||||
#define IP4_SERVICE_CONFIGED 2
|
||||
#define IP4_SERVICE_DESTROY 3
|
||||
|
||||
#define IP4_SERVICE_UNSTARTED 0
|
||||
#define IP4_SERVICE_STARTED 1
|
||||
#define IP4_SERVICE_CONFIGED 2
|
||||
#define IP4_SERVICE_DESTROY 3
|
||||
|
||||
///
|
||||
/// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.
|
||||
@@ -85,12 +84,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
/// user's event signalled.
|
||||
///
|
||||
typedef struct {
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
EFI_EVENT IpSecRecycleSignal;
|
||||
NET_BUF *Packet;
|
||||
BOOLEAN Sent;
|
||||
INTN Life;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
EFI_EVENT IpSecRecycleSignal;
|
||||
NET_BUF *Packet;
|
||||
BOOLEAN Sent;
|
||||
INTN Life;
|
||||
} IP4_TXTOKEN_WRAP;
|
||||
|
||||
///
|
||||
@@ -100,8 +99,8 @@ typedef struct {
|
||||
/// to notice IPsec to free the resources.
|
||||
///
|
||||
typedef struct {
|
||||
EFI_EVENT IpSecRecycleSignal;
|
||||
NET_BUF *Packet;
|
||||
EFI_EVENT IpSecRecycleSignal;
|
||||
NET_BUF *Packet;
|
||||
} IP4_IPSEC_WRAP;
|
||||
|
||||
///
|
||||
@@ -114,111 +113,109 @@ typedef struct {
|
||||
/// fragments will be freed at last.
|
||||
///
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
NET_BUF *Packet;
|
||||
EFI_IP4_RECEIVE_DATA RxData;
|
||||
LIST_ENTRY Link;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
NET_BUF *Packet;
|
||||
EFI_IP4_RECEIVE_DATA RxData;
|
||||
} IP4_RXDATA_WRAP;
|
||||
|
||||
|
||||
struct _IP4_PROTOCOL {
|
||||
UINT32 Signature;
|
||||
UINT32 Signature;
|
||||
|
||||
EFI_IP4_PROTOCOL Ip4Proto;
|
||||
EFI_HANDLE Handle;
|
||||
INTN State;
|
||||
EFI_IP4_PROTOCOL Ip4Proto;
|
||||
EFI_HANDLE Handle;
|
||||
INTN State;
|
||||
|
||||
BOOLEAN InDestroy;
|
||||
BOOLEAN InDestroy;
|
||||
|
||||
IP4_SERVICE *Service;
|
||||
LIST_ENTRY Link; // Link to all the IP protocol from the service
|
||||
IP4_SERVICE *Service;
|
||||
LIST_ENTRY Link; // Link to all the IP protocol from the service
|
||||
|
||||
//
|
||||
// User's transmit/receive tokens, and received/delivered packets
|
||||
//
|
||||
NET_MAP RxTokens;
|
||||
NET_MAP TxTokens; // map between (User's Token, IP4_TXTOKE_WRAP)
|
||||
LIST_ENTRY Received; // Received but not delivered packet
|
||||
LIST_ENTRY Delivered; // Delivered and to be recycled packets
|
||||
EFI_LOCK RecycleLock;
|
||||
NET_MAP RxTokens;
|
||||
NET_MAP TxTokens; // map between (User's Token, IP4_TXTOKE_WRAP)
|
||||
LIST_ENTRY Received; // Received but not delivered packet
|
||||
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;
|
||||
LIST_ENTRY AddrLink; // Ip instances with the same IP address.
|
||||
IP4_ROUTE_TABLE *RouteTable;
|
||||
IP4_INTERFACE *Interface;
|
||||
LIST_ENTRY AddrLink; // Ip instances with the same IP address.
|
||||
IP4_ROUTE_TABLE *RouteTable;
|
||||
|
||||
EFI_IP4_ROUTE_TABLE *EfiRouteTable;
|
||||
UINT32 EfiRouteCount;
|
||||
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;
|
||||
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;
|
||||
UINT32 Signature;
|
||||
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
||||
INTN State;
|
||||
|
||||
//
|
||||
// List of all the IP instances and interfaces, and default
|
||||
// interface and route table and caches.
|
||||
//
|
||||
UINTN NumChildren;
|
||||
LIST_ENTRY Children;
|
||||
UINTN NumChildren;
|
||||
LIST_ENTRY Children;
|
||||
|
||||
LIST_ENTRY Interfaces;
|
||||
LIST_ENTRY Interfaces;
|
||||
|
||||
IP4_INTERFACE *DefaultInterface;
|
||||
IP4_ROUTE_TABLE *DefaultRouteTable;
|
||||
IP4_INTERFACE *DefaultInterface;
|
||||
IP4_ROUTE_TABLE *DefaultRouteTable;
|
||||
|
||||
//
|
||||
// Ip reassemble utilities, and IGMP data
|
||||
//
|
||||
IP4_ASSEMBLE_TABLE Assemble;
|
||||
IGMP_SERVICE_DATA IgmpCtrl;
|
||||
IP4_ASSEMBLE_TABLE Assemble;
|
||||
IGMP_SERVICE_DATA IgmpCtrl;
|
||||
|
||||
//
|
||||
// Low level protocol used by this service instance
|
||||
//
|
||||
EFI_HANDLE Image;
|
||||
EFI_HANDLE Controller;
|
||||
EFI_HANDLE Image;
|
||||
EFI_HANDLE Controller;
|
||||
|
||||
EFI_HANDLE MnpChildHandle;
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
EFI_HANDLE MnpChildHandle;
|
||||
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
|
||||
|
||||
EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
|
||||
EFI_SIMPLE_NETWORK_MODE SnpMode;
|
||||
EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
|
||||
EFI_SIMPLE_NETWORK_MODE SnpMode;
|
||||
|
||||
EFI_EVENT Timer;
|
||||
EFI_EVENT ReconfigCheckTimer;
|
||||
EFI_EVENT ReconfigEvent;
|
||||
EFI_EVENT Timer;
|
||||
EFI_EVENT ReconfigCheckTimer;
|
||||
EFI_EVENT ReconfigEvent;
|
||||
|
||||
BOOLEAN Reconfig;
|
||||
BOOLEAN Reconfig;
|
||||
|
||||
//
|
||||
// Underlying media present status.
|
||||
//
|
||||
BOOLEAN MediaPresent;
|
||||
BOOLEAN MediaPresent;
|
||||
|
||||
//
|
||||
// IPv4 Configuration II Protocol instance
|
||||
//
|
||||
IP4_CONFIG2_INSTANCE Ip4Config2Instance;
|
||||
IP4_CONFIG2_INSTANCE Ip4Config2Instance;
|
||||
|
||||
CHAR16 *MacString;
|
||||
CHAR16 *MacString;
|
||||
|
||||
UINT32 MaxPacketSize;
|
||||
UINT32 OldMaxPacketSize; ///< The MTU before IPsec enable.
|
||||
UINT32 MaxPacketSize;
|
||||
UINT32 OldMaxPacketSize; ///< The MTU before IPsec enable.
|
||||
};
|
||||
|
||||
#define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \
|
||||
@@ -230,10 +227,9 @@ struct _IP4_SERVICE {
|
||||
#define IP4_SERVICE_FROM_CONFIG2_INSTANCE(This) \
|
||||
CR (This, IP4_SERVICE, Ip4Config2Instance, IP4_SERVICE_SIGNATURE)
|
||||
|
||||
#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
|
||||
|
||||
#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
|
||||
|
||||
extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
|
||||
extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
|
||||
|
||||
/**
|
||||
Config the MNP parameter used by IP. The IP driver use one MNP
|
||||
@@ -255,8 +251,8 @@ extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4ServiceConfigMnp (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN BOOLEAN Force
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN BOOLEAN Force
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -268,8 +264,8 @@ Ip4ServiceConfigMnp (
|
||||
**/
|
||||
VOID
|
||||
Ip4InitProtocol (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN OUT IP4_PROTOCOL *IpInstance
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN OUT IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -283,7 +279,7 @@ Ip4InitProtocol (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4CleanProtocol (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -301,8 +297,8 @@ Ip4CleanProtocol (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Cancel (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -322,9 +318,9 @@ Ip4Cancel (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Groups (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN BOOLEAN JoinFlag,
|
||||
IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -339,8 +335,8 @@ Ip4Groups (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4TimerTicking (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -358,8 +354,8 @@ Ip4TimerTicking (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4TimerReconfigChecking (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -379,9 +375,9 @@ Ip4TimerReconfigChecking (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Ip4SentPacketTicking (
|
||||
IN NET_MAP *Map,
|
||||
IN NET_MAP_ITEM *Item,
|
||||
IN VOID *Context
|
||||
IN NET_MAP *Map,
|
||||
IN NET_MAP_ITEM *Item,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -408,10 +404,10 @@ Ip4SentPacketTicking (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4FreeTxToken (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
extern EFI_IPSEC2_PROTOCOL *mIpSec;
|
||||
extern BOOLEAN mIpSec2Installed;
|
||||
extern EFI_IPSEC2_PROTOCOL *mIpSec;
|
||||
extern BOOLEAN mIpSec2Installed;
|
||||
|
||||
#endif
|
||||
|
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Create an empty assemble entry for the packet identified by
|
||||
(Dst, Src, Id, Protocol). The default life for the packet is
|
||||
@@ -27,14 +26,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
IP4_ASSEMBLE_ENTRY *
|
||||
Ip4CreateAssembleEntry (
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src,
|
||||
IN UINT16 Id,
|
||||
IN UINT8 Protocol
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src,
|
||||
IN UINT16 Id,
|
||||
IN UINT8 Protocol
|
||||
)
|
||||
{
|
||||
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
|
||||
Assemble = AllocatePool (sizeof (IP4_ASSEMBLE_ENTRY));
|
||||
|
||||
@@ -58,7 +56,6 @@ Ip4CreateAssembleEntry (
|
||||
return Assemble;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release all the fragments of a packet, then free the assemble entry.
|
||||
|
||||
@@ -67,12 +64,12 @@ Ip4CreateAssembleEntry (
|
||||
**/
|
||||
VOID
|
||||
Ip4FreeAssembleEntry (
|
||||
IN IP4_ASSEMBLE_ENTRY *Assemble
|
||||
IN IP4_ASSEMBLE_ENTRY *Assemble
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
NET_BUF *Fragment;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
NET_BUF *Fragment;
|
||||
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Assemble->Fragments) {
|
||||
Fragment = NET_LIST_USER_STRUCT (Entry, NET_BUF, List);
|
||||
@@ -84,7 +81,6 @@ Ip4FreeAssembleEntry (
|
||||
FreePool (Assemble);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize an already allocated assemble table. This is generally
|
||||
the assemble table embedded in the IP4 service instance.
|
||||
@@ -94,17 +90,16 @@ Ip4FreeAssembleEntry (
|
||||
**/
|
||||
VOID
|
||||
Ip4InitAssembleTable (
|
||||
IN OUT IP4_ASSEMBLE_TABLE *Table
|
||||
IN OUT IP4_ASSEMBLE_TABLE *Table
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
UINT32 Index;
|
||||
|
||||
for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {
|
||||
InitializeListHead (&Table->Bucket[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up the assemble table: remove all the fragments
|
||||
and assemble entries.
|
||||
@@ -114,13 +109,13 @@ Ip4InitAssembleTable (
|
||||
**/
|
||||
VOID
|
||||
Ip4CleanAssembleTable (
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
UINT32 Index;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
UINT32 Index;
|
||||
|
||||
for (Index = 0; Index < IP4_ASSEMLE_HASH_SIZE; Index++) {
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Table->Bucket[Index]) {
|
||||
@@ -132,7 +127,6 @@ Ip4CleanAssembleTable (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Trim the packet to fit in [Start, End), and update the per
|
||||
packet information.
|
||||
@@ -144,23 +138,23 @@ Ip4CleanAssembleTable (
|
||||
**/
|
||||
VOID
|
||||
Ip4TrimPacket (
|
||||
IN OUT NET_BUF *Packet,
|
||||
IN INTN Start,
|
||||
IN INTN End
|
||||
IN OUT NET_BUF *Packet,
|
||||
IN INTN Start,
|
||||
IN INTN End
|
||||
)
|
||||
{
|
||||
IP4_CLIP_INFO *Info;
|
||||
INTN Len;
|
||||
IP4_CLIP_INFO *Info;
|
||||
INTN Len;
|
||||
|
||||
Info = IP4_GET_CLIP_INFO (Packet);
|
||||
|
||||
ASSERT (Info->Start + Info->Length == Info->End);
|
||||
ASSERT ((Info->Start < End) && (Start < Info->End));
|
||||
|
||||
if (Info->Start < Start) {
|
||||
if (Info->Start < Start) {
|
||||
Len = Start - Info->Start;
|
||||
|
||||
NetbufTrim (Packet, (UINT32) Len, NET_BUF_HEAD);
|
||||
NetbufTrim (Packet, (UINT32)Len, NET_BUF_HEAD);
|
||||
Info->Start = Start;
|
||||
Info->Length -= Len;
|
||||
}
|
||||
@@ -168,13 +162,12 @@ Ip4TrimPacket (
|
||||
if (End < Info->End) {
|
||||
Len = End - Info->End;
|
||||
|
||||
NetbufTrim (Packet, (UINT32) Len, NET_BUF_TAIL);
|
||||
NetbufTrim (Packet, (UINT32)Len, NET_BUF_TAIL);
|
||||
Info->End = End;
|
||||
Info->Length -= Len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release all the fragments of the packet. This is the callback for
|
||||
the assembled packet's OnFree. It will free the assemble entry,
|
||||
@@ -186,13 +179,12 @@ Ip4TrimPacket (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnFreeFragments (
|
||||
IN VOID *Arg
|
||||
IN VOID *Arg
|
||||
)
|
||||
{
|
||||
Ip4FreeAssembleEntry ((IP4_ASSEMBLE_ENTRY *) Arg);
|
||||
Ip4FreeAssembleEntry ((IP4_ASSEMBLE_ENTRY *)Arg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reassemble the IP fragments. If all the fragments of the packet
|
||||
have been received, it will wrap the packet in a net buffer then
|
||||
@@ -210,37 +202,38 @@ Ip4OnFreeFragments (
|
||||
**/
|
||||
NET_BUF *
|
||||
Ip4Reassemble (
|
||||
IN OUT IP4_ASSEMBLE_TABLE *Table,
|
||||
IN OUT NET_BUF *Packet
|
||||
IN OUT IP4_ASSEMBLE_TABLE *Table,
|
||||
IN OUT NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_HEAD *IpHead;
|
||||
IP4_CLIP_INFO *This;
|
||||
IP4_CLIP_INFO *Node;
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Prev;
|
||||
LIST_ENTRY *Cur;
|
||||
NET_BUF *Fragment;
|
||||
NET_BUF *NewPacket;
|
||||
INTN Index;
|
||||
IP4_HEAD *IpHead;
|
||||
IP4_CLIP_INFO *This;
|
||||
IP4_CLIP_INFO *Node;
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Prev;
|
||||
LIST_ENTRY *Cur;
|
||||
NET_BUF *Fragment;
|
||||
NET_BUF *NewPacket;
|
||||
INTN Index;
|
||||
|
||||
IpHead = Packet->Ip.Ip4;
|
||||
This = IP4_GET_CLIP_INFO (Packet);
|
||||
IpHead = Packet->Ip.Ip4;
|
||||
This = IP4_GET_CLIP_INFO (Packet);
|
||||
|
||||
ASSERT (IpHead != NULL);
|
||||
|
||||
//
|
||||
// First: find the related assemble entry
|
||||
//
|
||||
Assemble = NULL;
|
||||
Index = IP4_ASSEMBLE_HASH (IpHead->Dst, IpHead->Src, IpHead->Id, IpHead->Protocol);
|
||||
Assemble = NULL;
|
||||
Index = IP4_ASSEMBLE_HASH (IpHead->Dst, IpHead->Src, IpHead->Id, IpHead->Protocol);
|
||||
|
||||
NET_LIST_FOR_EACH (Cur, &Table->Bucket[Index]) {
|
||||
Assemble = NET_LIST_USER_STRUCT (Cur, IP4_ASSEMBLE_ENTRY, Link);
|
||||
|
||||
if ((Assemble->Dst == IpHead->Dst) && (Assemble->Src == IpHead->Src) &&
|
||||
(Assemble->Id == IpHead->Id) && (Assemble->Protocol == IpHead->Protocol)) {
|
||||
(Assemble->Id == IpHead->Id) && (Assemble->Protocol == IpHead->Protocol))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -262,6 +255,7 @@ Ip4Reassemble (
|
||||
|
||||
InsertHeadList (&Table->Bucket[Index], &Assemble->Link);
|
||||
}
|
||||
|
||||
//
|
||||
// Assemble shouldn't be NULL here
|
||||
//
|
||||
@@ -289,8 +283,8 @@ Ip4Reassemble (
|
||||
// overlaps, trim the overlapped part off THIS fragment.
|
||||
//
|
||||
if ((Prev = Cur->BackLink) != Head) {
|
||||
Fragment = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);
|
||||
Node = IP4_GET_CLIP_INFO (Fragment);
|
||||
Fragment = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);
|
||||
Node = IP4_GET_CLIP_INFO (Fragment);
|
||||
|
||||
if (This->Start < Node->End) {
|
||||
if (This->End <= Node->End) {
|
||||
@@ -364,8 +358,8 @@ Ip4Reassemble (
|
||||
//
|
||||
ASSERT (Assemble->Head == NULL);
|
||||
|
||||
Assemble->Head = IpHead;
|
||||
Assemble->Info = IP4_GET_CLIP_INFO (Packet);
|
||||
Assemble->Head = IpHead;
|
||||
Assemble->Info = IP4_GET_CLIP_INFO (Packet);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -383,7 +377,6 @@ Ip4Reassemble (
|
||||
// queue ends at the total length, all data is received.
|
||||
//
|
||||
if ((Assemble->TotalLen != 0) && (Assemble->CurLen >= Assemble->TotalLen)) {
|
||||
|
||||
RemoveEntryList (&Assemble->Link);
|
||||
|
||||
//
|
||||
@@ -444,12 +437,12 @@ DROP:
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4IpSecFree (
|
||||
IN VOID *Arg
|
||||
IN VOID *Arg
|
||||
)
|
||||
{
|
||||
IP4_IPSEC_WRAP *Wrap;
|
||||
IP4_IPSEC_WRAP *Wrap;
|
||||
|
||||
Wrap = (IP4_IPSEC_WRAP *) Arg;
|
||||
Wrap = (IP4_IPSEC_WRAP *)Arg;
|
||||
|
||||
if (Wrap->IpSecRecycleSignal != NULL) {
|
||||
gBS->SignalEvent (Wrap->IpSecRecycleSignal);
|
||||
@@ -496,29 +489,30 @@ Ip4IpSecProcessPacket (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
NET_FRAGMENT *FragmentTable;
|
||||
NET_FRAGMENT *OriginalFragmentTable;
|
||||
UINT32 FragmentCount;
|
||||
UINT32 OriginalFragmentCount;
|
||||
EFI_EVENT RecycleEvent;
|
||||
NET_BUF *Packet;
|
||||
IP4_TXTOKEN_WRAP *TxWrap;
|
||||
IP4_IPSEC_WRAP *IpSecWrap;
|
||||
EFI_STATUS Status;
|
||||
IP4_HEAD ZeroHead;
|
||||
NET_FRAGMENT *FragmentTable;
|
||||
NET_FRAGMENT *OriginalFragmentTable;
|
||||
UINT32 FragmentCount;
|
||||
UINT32 OriginalFragmentCount;
|
||||
EFI_EVENT RecycleEvent;
|
||||
NET_BUF *Packet;
|
||||
IP4_TXTOKEN_WRAP *TxWrap;
|
||||
IP4_IPSEC_WRAP *IpSecWrap;
|
||||
EFI_STATUS Status;
|
||||
IP4_HEAD ZeroHead;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
if (!mIpSec2Installed) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
ASSERT (mIpSec != NULL);
|
||||
|
||||
Packet = *Netbuf;
|
||||
RecycleEvent = NULL;
|
||||
IpSecWrap = NULL;
|
||||
FragmentTable = NULL;
|
||||
TxWrap = (IP4_TXTOKEN_WRAP *) Context;
|
||||
TxWrap = (IP4_TXTOKEN_WRAP *)Context;
|
||||
FragmentCount = Packet->BlockOpNum;
|
||||
|
||||
ZeroMem (&ZeroHead, sizeof (IP4_HEAD));
|
||||
@@ -571,11 +565,11 @@ Ip4IpSecProcessPacket (
|
||||
mIpSec,
|
||||
IpSb->Controller,
|
||||
IP_VERSION_4,
|
||||
(VOID *) (*Head),
|
||||
(VOID *)(*Head),
|
||||
&(*Head)->Protocol,
|
||||
(VOID **) Options,
|
||||
(VOID **)Options,
|
||||
OptionsLen,
|
||||
(EFI_IPSEC_FRAGMENT_DATA **) (&FragmentTable),
|
||||
(EFI_IPSEC_FRAGMENT_DATA **)(&FragmentTable),
|
||||
&FragmentCount,
|
||||
Direction,
|
||||
&RecycleEvent
|
||||
@@ -590,7 +584,7 @@ Ip4IpSecProcessPacket (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if (OriginalFragmentTable == FragmentTable && OriginalFragmentCount == FragmentCount) {
|
||||
if ((OriginalFragmentTable == FragmentTable) && (OriginalFragmentCount == FragmentCount)) {
|
||||
//
|
||||
// For ByPass Packet
|
||||
//
|
||||
@@ -603,8 +597,7 @@ Ip4IpSecProcessPacket (
|
||||
FreePool (OriginalFragmentTable);
|
||||
}
|
||||
|
||||
if (Direction == EfiIPsecOutBound && TxWrap != NULL) {
|
||||
|
||||
if ((Direction == EfiIPsecOutBound) && (TxWrap != NULL)) {
|
||||
TxWrap->IpSecRecycleSignal = RecycleEvent;
|
||||
TxWrap->Packet = NetbufFromExt (
|
||||
FragmentTable,
|
||||
@@ -620,7 +613,7 @@ Ip4IpSecProcessPacket (
|
||||
// the TxWrap.
|
||||
//
|
||||
TxWrap->Packet = *Netbuf;
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@@ -629,9 +622,7 @@ Ip4IpSecProcessPacket (
|
||||
//
|
||||
NetIpSecNetbufFree (*Netbuf);
|
||||
*Netbuf = TxWrap->Packet;
|
||||
|
||||
} else {
|
||||
|
||||
IpSecWrap = AllocateZeroPool (sizeof (IP4_IPSEC_WRAP));
|
||||
|
||||
if (IpSecWrap == NULL) {
|
||||
@@ -659,7 +650,7 @@ Ip4IpSecProcessPacket (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
if (Direction == EfiIPsecInBound && 0 != CompareMem (*Head, &ZeroHead, sizeof (IP4_HEAD))) {
|
||||
if ((Direction == EfiIPsecInBound) && (0 != CompareMem (*Head, &ZeroHead, sizeof (IP4_HEAD)))) {
|
||||
Ip4PrependHead (Packet, *Head, *Options, *OptionsLen);
|
||||
Ip4NtohHead (Packet->Ip.Ip4);
|
||||
NetbufTrim (Packet, ((*Head)->HeadLen << 2), TRUE);
|
||||
@@ -670,6 +661,7 @@ Ip4IpSecProcessPacket (
|
||||
sizeof (IP4_CLIP_INFO)
|
||||
);
|
||||
}
|
||||
|
||||
*Netbuf = Packet;
|
||||
}
|
||||
|
||||
@@ -695,18 +687,18 @@ ON_EXIT:
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4PreProcessPacket (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN OUT NET_BUF **Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN UINT32 Flag
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN OUT NET_BUF **Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN UINT32 Flag
|
||||
)
|
||||
{
|
||||
IP4_CLIP_INFO *Info;
|
||||
UINT32 HeadLen;
|
||||
UINT32 TotalLen;
|
||||
UINT16 Checksum;
|
||||
IP4_CLIP_INFO *Info;
|
||||
UINT32 HeadLen;
|
||||
UINT32 TotalLen;
|
||||
UINT16 Checksum;
|
||||
|
||||
//
|
||||
// Check if the IP4 header is correctly formatted.
|
||||
@@ -722,14 +714,15 @@ Ip4PreProcessPacket (
|
||||
}
|
||||
|
||||
if ((Head->Ver != 4) || (HeadLen < IP4_MIN_HEADLEN) ||
|
||||
(TotalLen < HeadLen) || (TotalLen != (*Packet)->TotalSize)) {
|
||||
(TotalLen < HeadLen) || (TotalLen != (*Packet)->TotalSize))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Some OS may send IP packets without checksum.
|
||||
//
|
||||
Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Head, HeadLen));
|
||||
Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)Head, HeadLen));
|
||||
|
||||
if ((Head->Checksum != 0) && (Checksum != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -738,15 +731,15 @@ Ip4PreProcessPacket (
|
||||
//
|
||||
// Convert the IP header to host byte order, then get the per packet info.
|
||||
//
|
||||
(*Packet)->Ip.Ip4 = Ip4NtohHead (Head);
|
||||
(*Packet)->Ip.Ip4 = Ip4NtohHead (Head);
|
||||
|
||||
Info = IP4_GET_CLIP_INFO (*Packet);
|
||||
Info->LinkFlag = Flag;
|
||||
Info->CastType = Ip4GetHostCast (IpSb, Head->Dst, Head->Src);
|
||||
Info->Start = (Head->Fragment & IP4_HEAD_OFFSET_MASK) << 3;
|
||||
Info->Length = Head->TotalLen - HeadLen;
|
||||
Info->End = Info->Start + Info->Length;
|
||||
Info->Status = EFI_SUCCESS;
|
||||
Info = IP4_GET_CLIP_INFO (*Packet);
|
||||
Info->LinkFlag = Flag;
|
||||
Info->CastType = Ip4GetHostCast (IpSb, Head->Dst, Head->Src);
|
||||
Info->Start = (Head->Fragment & IP4_HEAD_OFFSET_MASK) << 3;
|
||||
Info->Length = Head->TotalLen - HeadLen;
|
||||
Info->End = Info->Start + Info->Length;
|
||||
Info->Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// The packet is destinated to us if the CastType is non-zero.
|
||||
@@ -815,7 +808,7 @@ Ip4PreProcessPacket (
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4IsValidPacketLength (
|
||||
IN NET_BUF *Packet
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -843,21 +836,21 @@ Ip4IsValidPacketLength (
|
||||
**/
|
||||
VOID
|
||||
Ip4AccpetFrame (
|
||||
IN IP4_PROTOCOL *Ip4Instance,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 Flag,
|
||||
IN VOID *Context
|
||||
IN IP4_PROTOCOL *Ip4Instance,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 Flag,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_HEAD *Head;
|
||||
EFI_STATUS Status;
|
||||
IP4_HEAD ZeroHead;
|
||||
UINT8 *Option;
|
||||
UINT32 OptionLen;
|
||||
IP4_SERVICE *IpSb;
|
||||
IP4_HEAD *Head;
|
||||
EFI_STATUS Status;
|
||||
IP4_HEAD ZeroHead;
|
||||
UINT8 *Option;
|
||||
UINT32 OptionLen;
|
||||
|
||||
IpSb = (IP4_SERVICE *) Context;
|
||||
IpSb = (IP4_SERVICE *)Context;
|
||||
Option = NULL;
|
||||
|
||||
if (EFI_ERROR (IoStatus) || (IpSb->State == IP4_SERVICE_DESTROY)) {
|
||||
@@ -868,11 +861,11 @@ Ip4AccpetFrame (
|
||||
goto RESTART;
|
||||
}
|
||||
|
||||
Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
|
||||
Head = (IP4_HEAD *)NetbufGetByte (Packet, 0, NULL);
|
||||
ASSERT (Head != NULL);
|
||||
OptionLen = (Head->HeadLen << 2) - IP4_MIN_HEADLEN;
|
||||
if (OptionLen > 0) {
|
||||
Option = (UINT8 *) (Head + 1);
|
||||
Option = (UINT8 *)(Head + 1);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -922,7 +915,7 @@ Ip4AccpetFrame (
|
||||
goto RESTART;
|
||||
}
|
||||
|
||||
Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
|
||||
Head = (IP4_HEAD *)NetbufGetByte (Packet, 0, NULL);
|
||||
ASSERT (Head != NULL);
|
||||
Status = Ip4PreProcessPacket (
|
||||
IpSb,
|
||||
@@ -938,20 +931,20 @@ Ip4AccpetFrame (
|
||||
}
|
||||
|
||||
ASSERT (Packet != NULL);
|
||||
Head = Packet->Ip.Ip4;
|
||||
Head = Packet->Ip.Ip4;
|
||||
IP4_GET_CLIP_INFO (Packet)->Status = EFI_SUCCESS;
|
||||
|
||||
switch (Head->Protocol) {
|
||||
case EFI_IP_PROTO_ICMP:
|
||||
Ip4IcmpHandle (IpSb, Head, Packet);
|
||||
break;
|
||||
case EFI_IP_PROTO_ICMP:
|
||||
Ip4IcmpHandle (IpSb, Head, Packet);
|
||||
break;
|
||||
|
||||
case IP4_PROTO_IGMP:
|
||||
Ip4IgmpHandle (IpSb, Head, Packet);
|
||||
break;
|
||||
case IP4_PROTO_IGMP:
|
||||
Ip4IgmpHandle (IpSb, Head, Packet);
|
||||
break;
|
||||
|
||||
default:
|
||||
Ip4Demultiplex (IpSb, Head, Packet, Option, OptionLen);
|
||||
default:
|
||||
Ip4Demultiplex (IpSb, Head, Packet, Option, OptionLen);
|
||||
}
|
||||
|
||||
Packet = NULL;
|
||||
@@ -970,10 +963,9 @@ DROP:
|
||||
NetbufFree (Packet);
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether this IP child accepts the packet.
|
||||
|
||||
@@ -987,16 +979,16 @@ DROP:
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4InstanceFrameAcceptable (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_ICMP_ERROR_HEAD Icmp;
|
||||
EFI_IP4_CONFIG_DATA *Config;
|
||||
IP4_CLIP_INFO *Info;
|
||||
UINT16 Proto;
|
||||
UINT32 Index;
|
||||
IP4_ICMP_ERROR_HEAD Icmp;
|
||||
EFI_IP4_CONFIG_DATA *Config;
|
||||
IP4_CLIP_INFO *Info;
|
||||
UINT16 Proto;
|
||||
UINT32 Index;
|
||||
|
||||
Config = &IpInstance->ConfigData;
|
||||
|
||||
@@ -1024,14 +1016,14 @@ Ip4InstanceFrameAcceptable (
|
||||
Proto = Head->Protocol;
|
||||
|
||||
if ((Proto == EFI_IP_PROTO_ICMP) && (!Config->AcceptAnyProtocol) && (Proto != Config->DefaultProtocol)) {
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp.Head), (UINT8 *) &Icmp.Head);
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp.Head), (UINT8 *)&Icmp.Head);
|
||||
|
||||
if (mIcmpClass[Icmp.Head.Type].IcmpClass == ICMP_ERROR_MESSAGE) {
|
||||
if (!Config->AcceptIcmpErrors) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
|
||||
NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
|
||||
Proto = Icmp.IpHead.Protocol;
|
||||
}
|
||||
}
|
||||
@@ -1076,7 +1068,6 @@ Ip4InstanceFrameAcceptable (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enqueue a shared copy of the packet to the IP4 child if the
|
||||
packet is acceptable to it. Here the data of the packet is
|
||||
@@ -1094,13 +1085,13 @@ Ip4InstanceFrameAcceptable (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4InstanceEnquePacket (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_CLIP_INFO *Info;
|
||||
NET_BUF *Clone;
|
||||
IP4_CLIP_INFO *Info;
|
||||
NET_BUF *Clone;
|
||||
|
||||
//
|
||||
// Check whether the packet is acceptable to this instance.
|
||||
@@ -1126,14 +1117,13 @@ Ip4InstanceEnquePacket (
|
||||
// Set the receive time out for the assembled packet. If it expires,
|
||||
// packet will be removed from the queue.
|
||||
//
|
||||
Info = IP4_GET_CLIP_INFO (Clone);
|
||||
Info->Life = IP4_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);
|
||||
Info = IP4_GET_CLIP_INFO (Clone);
|
||||
Info->Life = IP4_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);
|
||||
|
||||
InsertTailList (&IpInstance->Received, &Clone->List);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The signal handle of IP4's recycle event. It is called back
|
||||
when the upper layer release the packet.
|
||||
@@ -1146,13 +1136,13 @@ Ip4InstanceEnquePacket (
|
||||
VOID
|
||||
EFIAPI
|
||||
Ip4OnRecyclePacket (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
IP4_RXDATA_WRAP *Wrap;
|
||||
IP4_RXDATA_WRAP *Wrap;
|
||||
|
||||
Wrap = (IP4_RXDATA_WRAP *) Context;
|
||||
Wrap = (IP4_RXDATA_WRAP *)Context;
|
||||
|
||||
EfiAcquireLockOrFail (&Wrap->IpInstance->RecycleLock);
|
||||
RemoveEntryList (&Wrap->Link);
|
||||
@@ -1165,7 +1155,6 @@ Ip4OnRecyclePacket (
|
||||
FreePool (Wrap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Wrap the received packet to a IP4_RXDATA_WRAP, which will be
|
||||
delivered to the upper layer. Each IP4 child that accepts the
|
||||
@@ -1183,14 +1172,14 @@ Ip4OnRecyclePacket (
|
||||
**/
|
||||
IP4_RXDATA_WRAP *
|
||||
Ip4WrapRxData (
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN NET_BUF *Packet
|
||||
IN IP4_PROTOCOL *IpInstance,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
IP4_RXDATA_WRAP *Wrap;
|
||||
EFI_IP4_RECEIVE_DATA *RxData;
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN RawData;
|
||||
IP4_RXDATA_WRAP *Wrap;
|
||||
EFI_IP4_RECEIVE_DATA *RxData;
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN RawData;
|
||||
|
||||
Wrap = AllocatePool (IP4_RXDATA_WRAP_SIZE (Packet->BlockOpNum));
|
||||
|
||||
@@ -1200,9 +1189,9 @@ Ip4WrapRxData (
|
||||
|
||||
InitializeListHead (&Wrap->Link);
|
||||
|
||||
Wrap->IpInstance = IpInstance;
|
||||
Wrap->Packet = Packet;
|
||||
RxData = &Wrap->RxData;
|
||||
Wrap->IpInstance = IpInstance;
|
||||
Wrap->Packet = Packet;
|
||||
RxData = &Wrap->RxData;
|
||||
|
||||
ZeroMem (RxData, sizeof (EFI_IP4_RECEIVE_DATA));
|
||||
|
||||
@@ -1229,27 +1218,26 @@ Ip4WrapRxData (
|
||||
//
|
||||
if (!RawData) {
|
||||
RxData->HeaderLength = (Packet->Ip.Ip4->HeadLen << 2);
|
||||
RxData->Header = (EFI_IP4_HEADER *) Ip4NtohHead (Packet->Ip.Ip4);
|
||||
RxData->Header = (EFI_IP4_HEADER *)Ip4NtohHead (Packet->Ip.Ip4);
|
||||
RxData->OptionsLength = RxData->HeaderLength - IP4_MIN_HEADLEN;
|
||||
RxData->Options = NULL;
|
||||
|
||||
if (RxData->OptionsLength != 0) {
|
||||
RxData->Options = (VOID *) (RxData->Header + 1);
|
||||
RxData->Options = (VOID *)(RxData->Header + 1);
|
||||
}
|
||||
}
|
||||
|
||||
RxData->DataLength = Packet->TotalSize;
|
||||
RxData->DataLength = Packet->TotalSize;
|
||||
|
||||
//
|
||||
// Build the fragment table to be delivered up.
|
||||
//
|
||||
RxData->FragmentCount = Packet->BlockOpNum;
|
||||
NetbufBuildExt (Packet, (NET_FRAGMENT *) RxData->FragmentTable, &RxData->FragmentCount);
|
||||
NetbufBuildExt (Packet, (NET_FRAGMENT *)RxData->FragmentTable, &RxData->FragmentCount);
|
||||
|
||||
return Wrap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Deliver the received packets to upper layer if there are both received
|
||||
requests and enqueued packets. If the enqueued packet is shared, it will
|
||||
@@ -1266,7 +1254,7 @@ Ip4WrapRxData (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4InstanceDeliverPacket (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
)
|
||||
{
|
||||
EFI_IP4_COMPLETION_TOKEN *Token;
|
||||
@@ -1280,8 +1268,8 @@ Ip4InstanceDeliverPacket (
|
||||
// Deliver a packet if there are both a packet and a receive token.
|
||||
//
|
||||
while (!IsListEmpty (&IpInstance->Received) &&
|
||||
!NetMapIsEmpty (&IpInstance->RxTokens)) {
|
||||
|
||||
!NetMapIsEmpty (&IpInstance->RxTokens))
|
||||
{
|
||||
Packet = NET_LIST_HEAD (&IpInstance->Received, NET_BUF, List);
|
||||
|
||||
if (!NET_BUF_SHARED (Packet)) {
|
||||
@@ -1295,7 +1283,6 @@ Ip4InstanceDeliverPacket (
|
||||
}
|
||||
|
||||
RemoveEntryList (&Packet->List);
|
||||
|
||||
} else {
|
||||
//
|
||||
// Create a duplicated packet if this packet is shared
|
||||
@@ -1321,7 +1308,7 @@ Ip4InstanceDeliverPacket (
|
||||
Head = NetbufAllocSpace (Dup, IP4_MAX_HEADLEN, NET_BUF_HEAD);
|
||||
ASSERT (Head != NULL);
|
||||
|
||||
Dup->Ip.Ip4 = (IP4_HEAD *) Head;
|
||||
Dup->Ip.Ip4 = (IP4_HEAD *)Head;
|
||||
|
||||
CopyMem (Head, Packet->Ip.Ip4, Packet->Ip.Ip4->HeadLen << 2);
|
||||
NetbufTrim (Dup, IP4_MAX_HEADLEN, TRUE);
|
||||
@@ -1358,7 +1345,6 @@ Ip4InstanceDeliverPacket (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enqueue a received packet to all the IP children that share
|
||||
the same interface.
|
||||
@@ -1375,20 +1361,20 @@ Ip4InstanceDeliverPacket (
|
||||
**/
|
||||
INTN
|
||||
Ip4InterfaceEnquePacket (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
)
|
||||
{
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_CLIP_INFO *Info;
|
||||
LIST_ENTRY *Entry;
|
||||
INTN Enqueued;
|
||||
INTN LocalType;
|
||||
INTN SavedType;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_CLIP_INFO *Info;
|
||||
LIST_ENTRY *Entry;
|
||||
INTN Enqueued;
|
||||
INTN LocalType;
|
||||
INTN SavedType;
|
||||
|
||||
//
|
||||
// First, check that the packet is acceptable to this interface
|
||||
@@ -1406,7 +1392,6 @@ Ip4InterfaceEnquePacket (
|
||||
// that later.
|
||||
//
|
||||
LocalType = Info->CastType;
|
||||
|
||||
} else {
|
||||
//
|
||||
// Check the destination against local IP. If the station
|
||||
@@ -1416,7 +1401,6 @@ Ip4InterfaceEnquePacket (
|
||||
//
|
||||
if (IpIf->Ip == IP4_ALLZERO_ADDRESS) {
|
||||
LocalType = IP4_LOCAL_HOST;
|
||||
|
||||
} else {
|
||||
LocalType = Ip4GetNetCast (Head->Dst, IpIf);
|
||||
|
||||
@@ -1436,10 +1420,10 @@ Ip4InterfaceEnquePacket (
|
||||
// and pass the local cast type to the IP children on the
|
||||
// interface. The global cast type will be restored later.
|
||||
//
|
||||
SavedType = Info->CastType;
|
||||
Info->CastType = LocalType;
|
||||
SavedType = Info->CastType;
|
||||
Info->CastType = LocalType;
|
||||
|
||||
Enqueued = 0;
|
||||
Enqueued = 0;
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
|
||||
IpInstance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink);
|
||||
@@ -1448,7 +1432,7 @@ Ip4InterfaceEnquePacket (
|
||||
//
|
||||
// In RawData mode, add IPv4 headers and options back to packet.
|
||||
//
|
||||
if ((IpInstance->ConfigData.RawData) && (Option != NULL) && (OptionLen != 0)){
|
||||
if ((IpInstance->ConfigData.RawData) && (Option != NULL) && (OptionLen != 0)) {
|
||||
Ip4PrependHead (Packet, Head, Option, OptionLen);
|
||||
}
|
||||
|
||||
@@ -1461,7 +1445,6 @@ Ip4InterfaceEnquePacket (
|
||||
return Enqueued;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Deliver the packet for each IP4 child on the interface.
|
||||
|
||||
@@ -1473,12 +1456,12 @@ Ip4InterfaceEnquePacket (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4InterfaceDeliverPacket (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
)
|
||||
{
|
||||
IP4_PROTOCOL *Ip4Instance;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_PROTOCOL *Ip4Instance;
|
||||
LIST_ENTRY *Entry;
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
|
||||
Ip4Instance = NET_LIST_USER_STRUCT (Entry, IP4_PROTOCOL, AddrLink);
|
||||
@@ -1488,7 +1471,6 @@ Ip4InterfaceDeliverPacket (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Demultiple the packet. the packet delivery is processed in two
|
||||
passes. The first pass will enqueue a shared copy of the packet
|
||||
@@ -1511,16 +1493,16 @@ Ip4InterfaceDeliverPacket (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Demultiplex (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
INTN Enqueued;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
INTN Enqueued;
|
||||
|
||||
//
|
||||
// Two pass delivery: first, enqueue a shared copy of the packet
|
||||
@@ -1565,7 +1547,6 @@ Ip4Demultiplex (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Timeout the fragment and enqueued packets.
|
||||
|
||||
@@ -1574,17 +1555,17 @@ Ip4Demultiplex (
|
||||
**/
|
||||
VOID
|
||||
Ip4PacketTimerTicking (
|
||||
IN IP4_SERVICE *IpSb
|
||||
IN IP4_SERVICE *IpSb
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *InstanceEntry;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
NET_BUF *Packet;
|
||||
IP4_CLIP_INFO *Info;
|
||||
UINT32 Index;
|
||||
LIST_ENTRY *InstanceEntry;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_PROTOCOL *IpInstance;
|
||||
IP4_ASSEMBLE_ENTRY *Assemble;
|
||||
NET_BUF *Packet;
|
||||
IP4_CLIP_INFO *Info;
|
||||
UINT32 Index;
|
||||
|
||||
//
|
||||
// First, time out the fragments. The packet's life is counting down
|
||||
|
@@ -8,8 +8,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef __EFI_IP4_INPUT_H__
|
||||
#define __EFI_IP4_INPUT_H__
|
||||
|
||||
#define IP4_MIN_HEADLEN 20
|
||||
#define IP4_MAX_HEADLEN 60
|
||||
#define IP4_MIN_HEADLEN 20
|
||||
#define IP4_MAX_HEADLEN 60
|
||||
///
|
||||
/// 8(ESP header) + 16(max IV) + 16(max padding) + 2(ESP tail) + 12(max ICV) = 54
|
||||
///
|
||||
@@ -30,37 +30,37 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
/// 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;
|
||||
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 {
|
||||
LIST_ENTRY Link;
|
||||
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;
|
||||
IP4_ADDR Dst;
|
||||
IP4_ADDR Src;
|
||||
UINT16 Id;
|
||||
UINT8 Protocol;
|
||||
|
||||
INTN TotalLen;
|
||||
INTN CurLen;
|
||||
LIST_ENTRY Fragments; // List of all the fragments of this packet
|
||||
INTN TotalLen;
|
||||
INTN CurLen;
|
||||
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_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;
|
||||
|
||||
///
|
||||
@@ -69,10 +69,10 @@ typedef struct {
|
||||
/// as hash table.
|
||||
///
|
||||
typedef struct {
|
||||
LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];
|
||||
LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];
|
||||
} IP4_ASSEMBLE_TABLE;
|
||||
|
||||
#define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))
|
||||
#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)
|
||||
@@ -89,7 +89,7 @@ typedef struct {
|
||||
**/
|
||||
VOID
|
||||
Ip4InitAssembleTable (
|
||||
IN OUT IP4_ASSEMBLE_TABLE *Table
|
||||
IN OUT IP4_ASSEMBLE_TABLE *Table
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ Ip4InitAssembleTable (
|
||||
**/
|
||||
VOID
|
||||
Ip4CleanAssembleTable (
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
IN IP4_ASSEMBLE_TABLE *Table
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -119,11 +119,11 @@ Ip4CleanAssembleTable (
|
||||
**/
|
||||
VOID
|
||||
Ip4AccpetFrame (
|
||||
IN IP4_PROTOCOL *Ip4Instance,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 Flag,
|
||||
IN VOID *Context
|
||||
IN IP4_PROTOCOL *Ip4Instance,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UINT32 Flag,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -148,11 +148,11 @@ Ip4AccpetFrame (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Demultiplex (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -171,12 +171,12 @@ Ip4Demultiplex (
|
||||
**/
|
||||
INTN
|
||||
Ip4InterfaceEnquePacket (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_HEAD *Head,
|
||||
IN NET_BUF *Packet,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN IP4_INTERFACE *IpIf
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -195,7 +195,7 @@ Ip4InterfaceEnquePacket (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4InstanceDeliverPacket (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -206,7 +206,7 @@ Ip4InstanceDeliverPacket (
|
||||
**/
|
||||
VOID
|
||||
Ip4PacketTimerTicking (
|
||||
IN IP4_SERVICE *IpSb
|
||||
IN IP4_SERVICE *IpSb
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -14,32 +14,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#define FORMID_MAIN_FORM 1
|
||||
#define FORMID_DEVICE_FORM 2
|
||||
|
||||
#define KEY_ENABLE 0x100
|
||||
#define KEY_DHCP_ENABLE 0x101
|
||||
#define KEY_LOCAL_IP 0x102
|
||||
#define KEY_SUBNET_MASK 0x103
|
||||
#define KEY_GATE_WAY 0x104
|
||||
#define KEY_DNS 0x105
|
||||
#define KEY_SAVE_CHANGES 0x106
|
||||
#define KEY_ENABLE 0x100
|
||||
#define KEY_DHCP_ENABLE 0x101
|
||||
#define KEY_LOCAL_IP 0x102
|
||||
#define KEY_SUBNET_MASK 0x103
|
||||
#define KEY_GATE_WAY 0x104
|
||||
#define KEY_DNS 0x105
|
||||
#define KEY_SAVE_CHANGES 0x106
|
||||
|
||||
#define IP_MIN_SIZE 7
|
||||
#define IP_MAX_SIZE 15
|
||||
#define IP4_STR_MAX_SIZE 16
|
||||
#define ADDRESS_STR_MAX_SIZE 255
|
||||
#define MAX_IP4_CONFIG_DNS 16
|
||||
#define IP_MIN_SIZE 7
|
||||
#define IP_MAX_SIZE 15
|
||||
#define IP4_STR_MAX_SIZE 16
|
||||
#define ADDRESS_STR_MAX_SIZE 255
|
||||
#define MAX_IP4_CONFIG_DNS 16
|
||||
|
||||
///
|
||||
/// IP4_CONFIG2_IFR_NVDATA contains the IP4 configure
|
||||
/// parameters for that NIC.
|
||||
///
|
||||
typedef struct {
|
||||
UINT8 Configure; ///< NIC configure status
|
||||
UINT8 DhcpEnable; ///< Static or DHCP
|
||||
CHAR16 StationAddress[IP4_STR_MAX_SIZE]; ///< IP addresses
|
||||
CHAR16 SubnetMask[IP4_STR_MAX_SIZE]; ///< Subnet address
|
||||
CHAR16 GatewayAddress[IP4_STR_MAX_SIZE]; ///< Gateway address
|
||||
CHAR16 DnsAddress[ADDRESS_STR_MAX_SIZE]; ///< DNS server address
|
||||
UINT8 Configure; ///< NIC configure status
|
||||
UINT8 DhcpEnable; ///< Static or DHCP
|
||||
CHAR16 StationAddress[IP4_STR_MAX_SIZE]; ///< IP addresses
|
||||
CHAR16 SubnetMask[IP4_STR_MAX_SIZE]; ///< Subnet address
|
||||
CHAR16 GatewayAddress[IP4_STR_MAX_SIZE]; ///< Gateway address
|
||||
CHAR16 DnsAddress[ADDRESS_STR_MAX_SIZE]; ///< DNS server address
|
||||
} IP4_CONFIG2_IFR_NVDATA;
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Validate the IP4 option format for both the packets we received
|
||||
and will transmit.
|
||||
@@ -24,75 +23,73 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4OptionIsValid (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN Rcvd
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN Rcvd
|
||||
)
|
||||
{
|
||||
UINT32 Cur;
|
||||
UINT32 Len;
|
||||
UINT32 Point;
|
||||
UINT32 Cur;
|
||||
UINT32 Len;
|
||||
UINT32 Point;
|
||||
|
||||
Cur = 0;
|
||||
Cur = 0;
|
||||
|
||||
while (Cur < OptionLen) {
|
||||
switch (Option[Cur]) {
|
||||
case IP4_OPTION_NOP:
|
||||
Cur++;
|
||||
break;
|
||||
case IP4_OPTION_NOP:
|
||||
Cur++;
|
||||
break;
|
||||
|
||||
case IP4_OPTION_EOP:
|
||||
Cur = OptionLen;
|
||||
break;
|
||||
case IP4_OPTION_EOP:
|
||||
Cur = OptionLen;
|
||||
break;
|
||||
|
||||
case IP4_OPTION_LSRR:
|
||||
case IP4_OPTION_SSRR:
|
||||
case IP4_OPTION_RR:
|
||||
Len = Option[Cur + 1];
|
||||
Point = Option[Cur + 2];
|
||||
case IP4_OPTION_LSRR:
|
||||
case IP4_OPTION_SSRR:
|
||||
case IP4_OPTION_RR:
|
||||
Len = Option[Cur + 1];
|
||||
Point = Option[Cur + 2];
|
||||
|
||||
//
|
||||
// SRR/RR options are formatted as |Type|Len|Point|Ip1|Ip2|...
|
||||
//
|
||||
if ((OptionLen - Cur < Len) || (Len < 3) || ((Len - 3) % 4 != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
//
|
||||
// SRR/RR options are formatted as |Type|Len|Point|Ip1|Ip2|...
|
||||
//
|
||||
if ((OptionLen - Cur < Len) || (Len < 3) || ((Len - 3) % 4 != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((Point > Len + 1) || (Point % 4 != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
if ((Point > Len + 1) || (Point % 4 != 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// The Point must point pass the last entry if the packet is received
|
||||
// by us. It must point to 4 if the packet is to be sent by us for
|
||||
// source route option.
|
||||
//
|
||||
if ((Option[Cur] != IP4_OPTION_RR) &&
|
||||
((Rcvd && (Point != Len + 1)) || (!Rcvd && (Point != 4)))) {
|
||||
//
|
||||
// The Point must point pass the last entry if the packet is received
|
||||
// by us. It must point to 4 if the packet is to be sent by us for
|
||||
// source route option.
|
||||
//
|
||||
if ((Option[Cur] != IP4_OPTION_RR) &&
|
||||
((Rcvd && (Point != Len + 1)) || (!Rcvd && (Point != 4))))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
Cur += Len;
|
||||
break;
|
||||
|
||||
Cur += Len;
|
||||
break;
|
||||
default:
|
||||
Len = Option[Cur + 1];
|
||||
|
||||
default:
|
||||
Len = Option[Cur + 1];
|
||||
if ((OptionLen - Cur < Len) || (Len < 2)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((OptionLen - Cur < Len) || (Len < 2)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Cur = Cur + Len;
|
||||
break;
|
||||
Cur = Cur + Len;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copy the option from the original option to buffer. It
|
||||
handles the details such as:
|
||||
@@ -112,27 +109,27 @@ Ip4OptionIsValid (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4CopyOption (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN FirstFragment,
|
||||
IN OUT UINT8 *Buf OPTIONAL,
|
||||
IN OUT UINT32 *BufLen
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN FirstFragment,
|
||||
IN OUT UINT8 *Buf OPTIONAL,
|
||||
IN OUT UINT32 *BufLen
|
||||
)
|
||||
{
|
||||
UINT8 OptBuf[40];
|
||||
UINT32 Cur;
|
||||
UINT32 Next;
|
||||
UINT8 Type;
|
||||
UINT32 Len;
|
||||
UINT8 OptBuf[40];
|
||||
UINT32 Cur;
|
||||
UINT32 Next;
|
||||
UINT8 Type;
|
||||
UINT32 Len;
|
||||
|
||||
ASSERT ((BufLen != NULL) && (OptionLen <= 40));
|
||||
|
||||
Cur = 0;
|
||||
Next = 0;
|
||||
Cur = 0;
|
||||
Next = 0;
|
||||
|
||||
while (Cur < OptionLen) {
|
||||
Type = Option[Cur];
|
||||
Len = Option[Cur + 1];
|
||||
Type = Option[Cur];
|
||||
Len = Option[Cur + 1];
|
||||
|
||||
if (Type == IP4_OPTION_NOP) {
|
||||
//
|
||||
@@ -142,18 +139,16 @@ Ip4CopyOption (
|
||||
OptBuf[Next] = IP4_OPTION_NOP;
|
||||
Next++;
|
||||
Cur++;
|
||||
|
||||
} else if (Type == IP4_OPTION_EOP) {
|
||||
//
|
||||
// Don't append the EOP to avoid including only a EOP option
|
||||
//
|
||||
break;
|
||||
|
||||
} else {
|
||||
//
|
||||
// don't copy options that is only valid for the first fragment
|
||||
//
|
||||
if (FirstFragment || (Type & IP4_OPTION_COPY_MASK) != 0) {
|
||||
if (FirstFragment || ((Type & IP4_OPTION_COPY_MASK) != 0)) {
|
||||
CopyMem (OptBuf + Next, Option + Cur, Len);
|
||||
Next += Len;
|
||||
}
|
||||
|
@@ -9,11 +9,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef __EFI_IP4_OPTION_H__
|
||||
#define __EFI_IP4_OPTION_H__
|
||||
|
||||
#define IP4_OPTION_EOP 0
|
||||
#define IP4_OPTION_NOP 1
|
||||
#define IP4_OPTION_LSRR 131 // Loss source and record routing, 10000011
|
||||
#define IP4_OPTION_SSRR 137 // Strict source and record routing, 10001001
|
||||
#define IP4_OPTION_RR 7 // Record routing, 00000111
|
||||
#define IP4_OPTION_EOP 0
|
||||
#define IP4_OPTION_NOP 1
|
||||
#define IP4_OPTION_LSRR 131 // Loss source and record routing, 10000011
|
||||
#define IP4_OPTION_SSRR 137 // Strict source and record routing, 10001001
|
||||
#define IP4_OPTION_RR 7 // Record routing, 00000111
|
||||
|
||||
#define IP4_OPTION_COPY_MASK 0x80
|
||||
|
||||
@@ -33,9 +33,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4OptionIsValid (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN Rcvd
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN Rcvd
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -57,10 +57,11 @@ Ip4OptionIsValid (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4CopyOption (
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN FirstFragment,
|
||||
IN OUT UINT8 *Buf OPTIONAL,
|
||||
IN OUT UINT32 *BufLen
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptionLen,
|
||||
IN BOOLEAN FirstFragment,
|
||||
IN OUT UINT8 *Buf OPTIONAL,
|
||||
IN OUT UINT32 *BufLen
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
UINT16 mIp4Id;
|
||||
|
||||
|
||||
/**
|
||||
Prepend an IP4 head to the Packet. It will copy the options and
|
||||
build the IP4 header fields. Used for IP4 fragmentation.
|
||||
@@ -31,16 +30,16 @@ UINT16 mIp4Id;
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4PrependHead (
|
||||
IN OUT NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen
|
||||
IN OUT NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen
|
||||
)
|
||||
{
|
||||
UINT32 HeadLen;
|
||||
UINT32 Len;
|
||||
IP4_HEAD *PacketHead;
|
||||
BOOLEAN FirstFragment;
|
||||
UINT32 HeadLen;
|
||||
UINT32 Len;
|
||||
IP4_HEAD *PacketHead;
|
||||
BOOLEAN FirstFragment;
|
||||
|
||||
//
|
||||
// Prepend the options: first get the option length, then copy it over.
|
||||
@@ -53,35 +52,34 @@ Ip4PrependHead (
|
||||
HeadLen = IP4_MIN_HEADLEN + Len;
|
||||
ASSERT (((Len % 4) == 0) && (HeadLen <= IP4_MAX_HEADLEN));
|
||||
|
||||
PacketHead = (IP4_HEAD *) NetbufAllocSpace (Packet, HeadLen, NET_BUF_HEAD);
|
||||
PacketHead = (IP4_HEAD *)NetbufAllocSpace (Packet, HeadLen, NET_BUF_HEAD);
|
||||
|
||||
if (PacketHead == NULL) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
Ip4CopyOption (Option, OptLen, FirstFragment, (UINT8 *) (PacketHead + 1), &Len);
|
||||
Ip4CopyOption (Option, OptLen, FirstFragment, (UINT8 *)(PacketHead + 1), &Len);
|
||||
|
||||
//
|
||||
// Set the head up, convert the host byte order to network byte order
|
||||
//
|
||||
PacketHead->Ver = 4;
|
||||
PacketHead->HeadLen = (UINT8) (HeadLen >> 2);
|
||||
PacketHead->Tos = Head->Tos;
|
||||
PacketHead->TotalLen = HTONS ((UINT16) Packet->TotalSize);
|
||||
PacketHead->Id = HTONS (Head->Id);
|
||||
PacketHead->Fragment = HTONS (Head->Fragment);
|
||||
PacketHead->Checksum = 0;
|
||||
PacketHead->Ttl = Head->Ttl;
|
||||
PacketHead->Protocol = Head->Protocol;
|
||||
PacketHead->Src = HTONL (Head->Src);
|
||||
PacketHead->Dst = HTONL (Head->Dst);
|
||||
PacketHead->Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) PacketHead, HeadLen));
|
||||
PacketHead->Ver = 4;
|
||||
PacketHead->HeadLen = (UINT8)(HeadLen >> 2);
|
||||
PacketHead->Tos = Head->Tos;
|
||||
PacketHead->TotalLen = HTONS ((UINT16)Packet->TotalSize);
|
||||
PacketHead->Id = HTONS (Head->Id);
|
||||
PacketHead->Fragment = HTONS (Head->Fragment);
|
||||
PacketHead->Checksum = 0;
|
||||
PacketHead->Ttl = Head->Ttl;
|
||||
PacketHead->Protocol = Head->Protocol;
|
||||
PacketHead->Src = HTONL (Head->Src);
|
||||
PacketHead->Dst = HTONL (Head->Dst);
|
||||
PacketHead->Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)PacketHead, HeadLen));
|
||||
|
||||
Packet->Ip.Ip4 = PacketHead;
|
||||
Packet->Ip.Ip4 = PacketHead;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Select an interface to send the packet generated in the IP4 driver
|
||||
itself, that is, not by the requests of IP4 child's consumer. Such
|
||||
@@ -97,14 +95,14 @@ Ip4PrependHead (
|
||||
**/
|
||||
IP4_INTERFACE *
|
||||
Ip4SelectInterface (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src
|
||||
)
|
||||
{
|
||||
IP4_INTERFACE *IpIf;
|
||||
IP4_INTERFACE *Selected;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_INTERFACE *IpIf;
|
||||
IP4_INTERFACE *Selected;
|
||||
LIST_ENTRY *Entry;
|
||||
|
||||
//
|
||||
// Select the interface the Dst is on if one of the connected
|
||||
@@ -143,7 +141,6 @@ Ip4SelectInterface (
|
||||
return Selected;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The default callback function for system generated packet.
|
||||
It will free the packet.
|
||||
@@ -159,17 +156,16 @@ Ip4SelectInterface (
|
||||
**/
|
||||
VOID
|
||||
Ip4SysPacketSent (
|
||||
IP4_PROTOCOL *Ip4Instance,
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 LinkFlag,
|
||||
VOID *Context
|
||||
IP4_PROTOCOL *Ip4Instance,
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 LinkFlag,
|
||||
VOID *Context
|
||||
)
|
||||
{
|
||||
NetbufFree (Packet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Transmit an IP4 packet. The packet comes either from the IP4
|
||||
child's consumer (IpInstance != NULL) or the IP4 driver itself
|
||||
@@ -207,29 +203,29 @@ Ip4SysPacketSent (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Output (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN IP4_FRAME_CALLBACK Callback,
|
||||
IN VOID *Context
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN IP4_FRAME_CALLBACK Callback,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
IP4_INTERFACE *IpIf;
|
||||
IP4_ROUTE_CACHE_ENTRY *CacheEntry;
|
||||
IP4_ADDR Dest;
|
||||
EFI_STATUS Status;
|
||||
NET_BUF *Fragment;
|
||||
UINT32 Index;
|
||||
UINT32 HeadLen;
|
||||
UINT32 PacketLen;
|
||||
UINT32 Offset;
|
||||
UINT32 Mtu;
|
||||
UINT32 Num;
|
||||
BOOLEAN RawData;
|
||||
IP4_INTERFACE *IpIf;
|
||||
IP4_ROUTE_CACHE_ENTRY *CacheEntry;
|
||||
IP4_ADDR Dest;
|
||||
EFI_STATUS Status;
|
||||
NET_BUF *Fragment;
|
||||
UINT32 Index;
|
||||
UINT32 HeadLen;
|
||||
UINT32 PacketLen;
|
||||
UINT32 Offset;
|
||||
UINT32 Mtu;
|
||||
UINT32 Num;
|
||||
BOOLEAN RawData;
|
||||
|
||||
//
|
||||
// Select an interface/source for system packet, application
|
||||
@@ -256,12 +252,12 @@ Ip4Output (
|
||||
HeadLen = sizeof (IP4_HEAD) + ((OptLen + 3) & (~0x03));
|
||||
|
||||
if ((IpInstance != NULL) && IpInstance->ConfigData.RawData) {
|
||||
RawData = TRUE;
|
||||
RawData = TRUE;
|
||||
} else {
|
||||
Head->HeadLen = (UINT8) (HeadLen >> 2);
|
||||
Head->Id = mIp4Id++;
|
||||
Head->Ver = 4;
|
||||
RawData = FALSE;
|
||||
Head->HeadLen = (UINT8)(HeadLen >> 2);
|
||||
Head->Id = mIp4Id++;
|
||||
Head->Ver = 4;
|
||||
RawData = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -277,7 +273,7 @@ Ip4Output (
|
||||
Context
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -289,7 +285,6 @@ Ip4Output (
|
||||
// it is local broadcast.
|
||||
//
|
||||
GateWay = IP4_ALLONE_ADDRESS;
|
||||
|
||||
} else if (IP4_IS_MULTICAST (Dest)) {
|
||||
//
|
||||
// Set the gateway to the destination if it is an multicast
|
||||
@@ -297,7 +292,6 @@ Ip4Output (
|
||||
// broadcast and multicast.
|
||||
//
|
||||
GateWay = Head->Dst;
|
||||
|
||||
} else if (GateWay == IP4_ALLZERO_ADDRESS) {
|
||||
//
|
||||
// Route the packet unless overridden, that is, GateWay isn't zero.
|
||||
@@ -343,8 +337,8 @@ Ip4Output (
|
||||
// fragment is NOT sent in this loop. First compute how many
|
||||
// fragments there are.
|
||||
//
|
||||
Mtu = (Mtu - HeadLen) & (~0x07);
|
||||
Num = (Packet->TotalSize + Mtu - 1) / Mtu;
|
||||
Mtu = (Mtu - HeadLen) & (~0x07);
|
||||
Num = (Packet->TotalSize + Mtu - 1) / Mtu;
|
||||
|
||||
//
|
||||
// Initialize the packet length and Offset. Other than the last
|
||||
@@ -437,7 +431,6 @@ ON_ERROR:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The filter function to find a packet and all its fragments.
|
||||
The packet's fragments have their Context set to the packet.
|
||||
@@ -451,18 +444,17 @@ ON_ERROR:
|
||||
**/
|
||||
BOOLEAN
|
||||
Ip4CancelPacketFragments (
|
||||
IN IP4_LINK_TX_TOKEN *Frame,
|
||||
IN VOID *Context
|
||||
IN IP4_LINK_TX_TOKEN *Frame,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
if ((Frame->Packet == (NET_BUF *) Context) || (Frame->Context == Context)) {
|
||||
if ((Frame->Packet == (NET_BUF *)Context) || (Frame->Context == Context)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Cancel the Packet and all its fragments.
|
||||
|
||||
@@ -473,9 +465,9 @@ Ip4CancelPacketFragments (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelPacket (
|
||||
IN IP4_INTERFACE *IpIf,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus
|
||||
IN IP4_INTERFACE *IpIf,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus
|
||||
)
|
||||
{
|
||||
Ip4CancelFrames (IpIf, IoStatus, Ip4CancelPacketFragments, Packet);
|
||||
|
@@ -23,11 +23,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
VOID
|
||||
Ip4SysPacketSent (
|
||||
IP4_PROTOCOL *Ip4Instance,
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 LinkFlag,
|
||||
VOID *Context
|
||||
IP4_PROTOCOL *Ip4Instance,
|
||||
NET_BUF *Packet,
|
||||
EFI_STATUS IoStatus,
|
||||
UINT32 LinkFlag,
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -63,15 +63,15 @@ Ip4SysPacketSent (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4Output (
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN IP4_FRAME_CALLBACK Callback,
|
||||
IN VOID *Context
|
||||
IN IP4_SERVICE *IpSb,
|
||||
IN IP4_PROTOCOL *IpInstance OPTIONAL,
|
||||
IN NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN IP4_FRAME_CALLBACK Callback,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -84,9 +84,9 @@ Ip4Output (
|
||||
**/
|
||||
VOID
|
||||
Ip4CancelPacket (
|
||||
IN IP4_INTERFACE *IpIf,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus
|
||||
IN IP4_INTERFACE *IpIf,
|
||||
IN NET_BUF *Packet,
|
||||
IN EFI_STATUS IoStatus
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -109,10 +109,10 @@ Ip4CancelPacket (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4PrependHead (
|
||||
IN OUT NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen
|
||||
IN OUT NET_BUF *Packet,
|
||||
IN IP4_HEAD *Head,
|
||||
IN UINT8 *Option,
|
||||
IN UINT32 OptLen
|
||||
);
|
||||
|
||||
extern UINT16 mIp4Id;
|
||||
|
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Allocate a route entry then initialize it with the Dest/Netmask
|
||||
and Gateway.
|
||||
@@ -22,12 +21,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
IP4_ROUTE_ENTRY *
|
||||
Ip4CreateRouteEntry (
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR GateWay
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR GateWay
|
||||
)
|
||||
{
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
|
||||
RtEntry = AllocatePool (sizeof (IP4_ROUTE_ENTRY));
|
||||
|
||||
@@ -46,7 +45,6 @@ Ip4CreateRouteEntry (
|
||||
return RtEntry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the route table entry. It is reference counted.
|
||||
|
||||
@@ -55,7 +53,7 @@ Ip4CreateRouteEntry (
|
||||
**/
|
||||
VOID
|
||||
Ip4FreeRouteEntry (
|
||||
IN IP4_ROUTE_ENTRY *RtEntry
|
||||
IN IP4_ROUTE_ENTRY *RtEntry
|
||||
)
|
||||
{
|
||||
ASSERT (RtEntry->RefCnt > 0);
|
||||
@@ -65,7 +63,6 @@ Ip4FreeRouteEntry (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allocate and initialize an IP4 route cache entry.
|
||||
|
||||
@@ -81,13 +78,13 @@ Ip4FreeRouteEntry (
|
||||
**/
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4CreateRouteCacheEntry (
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN UINTN Tag
|
||||
IN IP4_ADDR Dst,
|
||||
IN IP4_ADDR Src,
|
||||
IN IP4_ADDR GateWay,
|
||||
IN UINTN Tag
|
||||
)
|
||||
{
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
|
||||
RtCacheEntry = AllocatePool (sizeof (IP4_ROUTE_CACHE_ENTRY));
|
||||
|
||||
@@ -106,7 +103,6 @@ Ip4CreateRouteCacheEntry (
|
||||
return RtCacheEntry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the route cache entry. It is reference counted.
|
||||
|
||||
@@ -125,7 +121,6 @@ Ip4FreeRouteCacheEntry (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize an empty route cache table.
|
||||
|
||||
@@ -134,17 +129,16 @@ Ip4FreeRouteCacheEntry (
|
||||
**/
|
||||
VOID
|
||||
Ip4InitRouteCache (
|
||||
IN OUT IP4_ROUTE_CACHE *RtCache
|
||||
IN OUT IP4_ROUTE_CACHE *RtCache
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
UINT32 Index;
|
||||
|
||||
for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) {
|
||||
InitializeListHead (&(RtCache->CacheBucket[Index]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up a route cache, that is free all the route cache
|
||||
entries enqueued in the cache.
|
||||
@@ -154,13 +148,13 @@ Ip4InitRouteCache (
|
||||
**/
|
||||
VOID
|
||||
Ip4CleanRouteCache (
|
||||
IN IP4_ROUTE_CACHE *RtCache
|
||||
IN IP4_ROUTE_CACHE *RtCache
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
UINT32 Index;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
UINT32 Index;
|
||||
|
||||
for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) {
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtCache->CacheBucket[Index])) {
|
||||
@@ -172,8 +166,6 @@ Ip4CleanRouteCache (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Create an empty route table, includes its internal route cache
|
||||
|
||||
@@ -186,8 +178,8 @@ Ip4CreateRouteTable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
IP4_ROUTE_TABLE *RtTable;
|
||||
UINT32 Index;
|
||||
IP4_ROUTE_TABLE *RtTable;
|
||||
UINT32 Index;
|
||||
|
||||
RtTable = AllocatePool (sizeof (IP4_ROUTE_TABLE));
|
||||
|
||||
@@ -208,7 +200,6 @@ Ip4CreateRouteTable (
|
||||
return RtTable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the route table and its associated route cache. Route
|
||||
table is reference counted.
|
||||
@@ -218,18 +209,18 @@ Ip4CreateRouteTable (
|
||||
**/
|
||||
VOID
|
||||
Ip4FreeRouteTable (
|
||||
IN IP4_ROUTE_TABLE *RtTable
|
||||
IN IP4_ROUTE_TABLE *RtTable
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
UINT32 Index;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
UINT32 Index;
|
||||
|
||||
ASSERT (RtTable->RefCnt > 0);
|
||||
|
||||
if (--RtTable->RefCnt > 0) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -249,8 +240,6 @@ Ip4FreeRouteTable (
|
||||
FreePool (RtTable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Remove all the cache entries bearing the Tag. When a route cache
|
||||
entry is created, it is tagged with the address of route entry
|
||||
@@ -263,18 +252,17 @@ Ip4FreeRouteTable (
|
||||
**/
|
||||
VOID
|
||||
Ip4PurgeRouteCache (
|
||||
IN OUT IP4_ROUTE_CACHE *RtCache,
|
||||
IN UINTN Tag
|
||||
IN OUT IP4_ROUTE_CACHE *RtCache,
|
||||
IN UINTN Tag
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
UINT32 Index;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
UINT32 Index;
|
||||
|
||||
for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) {
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtCache->CacheBucket[Index]) {
|
||||
|
||||
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link);
|
||||
|
||||
if (RtCacheEntry->Tag == Tag) {
|
||||
@@ -285,7 +273,6 @@ Ip4PurgeRouteCache (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add a route entry to the route table. All the IP4_ADDRs are in
|
||||
host byte order.
|
||||
@@ -302,15 +289,15 @@ Ip4PurgeRouteCache (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4AddRoute (
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
|
||||
//
|
||||
// All the route entries with the same netmask length are
|
||||
@@ -348,7 +335,6 @@ Ip4AddRoute (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove a route entry and all the route caches spawn from it.
|
||||
|
||||
@@ -364,16 +350,16 @@ Ip4AddRoute (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4DelRoute (
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
|
||||
Head = &(RtTable->RouteArea[NetGetMaskLength (Netmask)]);
|
||||
|
||||
@@ -381,9 +367,9 @@ Ip4DelRoute (
|
||||
RtEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_ENTRY, Link);
|
||||
|
||||
if (IP4_NET_EQUAL (RtEntry->Dest, Dest, Netmask) && (RtEntry->NextHop == Gateway)) {
|
||||
Ip4PurgeRouteCache (&RtTable->Cache, (UINTN) RtEntry);
|
||||
Ip4PurgeRouteCache (&RtTable->Cache, (UINTN)RtEntry);
|
||||
RemoveEntryList (Entry);
|
||||
Ip4FreeRouteEntry (RtEntry);
|
||||
Ip4FreeRouteEntry (RtEntry);
|
||||
|
||||
RtTable->TotalNum--;
|
||||
return EFI_SUCCESS;
|
||||
@@ -393,7 +379,6 @@ Ip4DelRoute (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find a route cache with the dst and src. This is used by ICMP
|
||||
redirect message process. All kinds of redirect is treated as
|
||||
@@ -410,14 +395,14 @@ Ip4DelRoute (
|
||||
**/
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4FindRouteCache (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
UINT32 Index;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
UINT32 Index;
|
||||
|
||||
Index = IP4_ROUTE_CACHE_HASH (Dest, Src);
|
||||
|
||||
@@ -433,7 +418,6 @@ Ip4FindRouteCache (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Search the route table for a most specific match to the Dst. It searches
|
||||
from the longest route area (mask length == 32) to the shortest route area
|
||||
@@ -452,14 +436,14 @@ Ip4FindRouteCache (
|
||||
**/
|
||||
IP4_ROUTE_ENTRY *
|
||||
Ip4FindRouteEntry (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dst
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dst
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
IP4_ROUTE_TABLE *Table;
|
||||
INTN Index;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
IP4_ROUTE_TABLE *Table;
|
||||
INTN Index;
|
||||
|
||||
RtEntry = NULL;
|
||||
|
||||
@@ -476,11 +460,9 @@ Ip4FindRouteEntry (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Search the route table to route the packet. Return/create a route
|
||||
cache if there is a route to the destination.
|
||||
@@ -500,26 +482,26 @@ Ip4FindRouteEntry (
|
||||
**/
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4Route (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src,
|
||||
IN IP4_ADDR SubnetMask,
|
||||
IN BOOLEAN AlwaysTryDestAddr
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src,
|
||||
IN IP4_ADDR SubnetMask,
|
||||
IN BOOLEAN AlwaysTryDestAddr
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
IP4_ROUTE_CACHE_ENTRY *Cache;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
IP4_ADDR NextHop;
|
||||
UINT32 Count;
|
||||
LIST_ENTRY *Head;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
IP4_ROUTE_CACHE_ENTRY *RtCacheEntry;
|
||||
IP4_ROUTE_CACHE_ENTRY *Cache;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
IP4_ADDR NextHop;
|
||||
UINT32 Count;
|
||||
|
||||
ASSERT (RtTable != NULL);
|
||||
|
||||
Head = &RtTable->Cache.CacheBucket[IP4_ROUTE_CACHE_HASH (Dest, Src)];
|
||||
RtCacheEntry = Ip4FindRouteCache (RtTable, Dest, Src);
|
||||
Head = &RtTable->Cache.CacheBucket[IP4_ROUTE_CACHE_HASH (Dest, Src)];
|
||||
RtCacheEntry = Ip4FindRouteCache (RtTable, Dest, Src);
|
||||
|
||||
//
|
||||
// If found, promote the cache entry to the head of the hash bucket. LRU
|
||||
@@ -552,7 +534,7 @@ Ip4Route (
|
||||
// When using /32 subnet mask, the packet will always be sent to the direct
|
||||
// destination first, if we can't find a matching route cache.
|
||||
//
|
||||
if (SubnetMask == IP4_ALLONE_ADDRESS || ((RtEntry->Flag & IP4_DIRECT_ROUTE) != 0)) {
|
||||
if ((SubnetMask == IP4_ALLONE_ADDRESS) || ((RtEntry->Flag & IP4_DIRECT_ROUTE) != 0)) {
|
||||
NextHop = Dest;
|
||||
} else {
|
||||
NextHop = RtEntry->NextHop;
|
||||
@@ -567,7 +549,7 @@ Ip4Route (
|
||||
// For /32 subnet mask, the default route in RtEntry will be used if failed
|
||||
// to send the packet to driect destination address.
|
||||
//
|
||||
RtCacheEntry = Ip4CreateRouteCacheEntry (Dest, Src, NextHop, (UINTN) RtEntry);
|
||||
RtCacheEntry = Ip4CreateRouteCacheEntry (Dest, Src, NextHop, (UINTN)RtEntry);
|
||||
|
||||
if (RtCacheEntry == NULL) {
|
||||
return NULL;
|
||||
@@ -596,7 +578,6 @@ Ip4Route (
|
||||
return RtCacheEntry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build a EFI_IP4_ROUTE_TABLE to be returned to the caller of
|
||||
GetModeData. The EFI_IP4_ROUTE_TABLE is clumsy to use in the
|
||||
@@ -610,15 +591,15 @@ Ip4Route (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4BuildEfiRouteTable (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_TABLE *RtTable;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
EFI_IP4_ROUTE_TABLE *Table;
|
||||
UINT32 Count;
|
||||
INT32 Index;
|
||||
LIST_ENTRY *Entry;
|
||||
IP4_ROUTE_TABLE *RtTable;
|
||||
IP4_ROUTE_ENTRY *RtEntry;
|
||||
EFI_IP4_ROUTE_TABLE *Table;
|
||||
UINT32 Count;
|
||||
INT32 Index;
|
||||
|
||||
RtTable = IpInstance->RouteTable;
|
||||
|
||||
|
@@ -11,10 +11,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ip4Common.h"
|
||||
|
||||
#define IP4_DIRECT_ROUTE 0x00000001
|
||||
#define IP4_DIRECT_ROUTE 0x00000001
|
||||
|
||||
#define IP4_ROUTE_CACHE_HASH_VALUE 31
|
||||
#define IP4_ROUTE_CACHE_MAX 64 // Max NO. of cache entry per hash bucket
|
||||
#define IP4_ROUTE_CACHE_HASH_VALUE 31
|
||||
#define 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_VALUE)
|
||||
|
||||
@@ -26,12 +26,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
/// enties of the connected network have the flag on.
|
||||
///
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Netmask;
|
||||
IP4_ADDR NextHop;
|
||||
UINT32 Flag;
|
||||
LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Netmask;
|
||||
IP4_ADDR NextHop;
|
||||
UINT32 Flag;
|
||||
} IP4_ROUTE_ENTRY;
|
||||
|
||||
///
|
||||
@@ -45,12 +45,12 @@ typedef struct {
|
||||
/// to-be-deleted route entry.
|
||||
///
|
||||
typedef struct {
|
||||
LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Src;
|
||||
IP4_ADDR NextHop;
|
||||
UINTN Tag;
|
||||
LIST_ENTRY Link;
|
||||
INTN RefCnt;
|
||||
IP4_ADDR Dest;
|
||||
IP4_ADDR Src;
|
||||
IP4_ADDR NextHop;
|
||||
UINTN Tag;
|
||||
} IP4_ROUTE_CACHE_ENTRY;
|
||||
|
||||
///
|
||||
@@ -61,7 +61,7 @@ typedef struct {
|
||||
/// detach them later.
|
||||
///
|
||||
typedef struct {
|
||||
LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH_VALUE];
|
||||
LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH_VALUE];
|
||||
} IP4_ROUTE_CACHE;
|
||||
|
||||
///
|
||||
@@ -75,11 +75,11 @@ typedef struct {
|
||||
typedef struct _IP4_ROUTE_TABLE IP4_ROUTE_TABLE;
|
||||
|
||||
struct _IP4_ROUTE_TABLE {
|
||||
INTN RefCnt;
|
||||
UINT32 TotalNum;
|
||||
LIST_ENTRY RouteArea[IP4_MASK_NUM];
|
||||
IP4_ROUTE_TABLE *Next;
|
||||
IP4_ROUTE_CACHE Cache;
|
||||
INTN RefCnt;
|
||||
UINT32 TotalNum;
|
||||
LIST_ENTRY RouteArea[IP4_MASK_NUM];
|
||||
IP4_ROUTE_TABLE *Next;
|
||||
IP4_ROUTE_CACHE Cache;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ Ip4CreateRouteTable (
|
||||
**/
|
||||
VOID
|
||||
Ip4FreeRouteTable (
|
||||
IN IP4_ROUTE_TABLE *RtTable
|
||||
IN IP4_ROUTE_TABLE *RtTable
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -122,10 +122,10 @@ Ip4FreeRouteTable (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4AddRoute (
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -143,10 +143,10 @@ Ip4AddRoute (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4DelRoute (
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
IN OUT IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Netmask,
|
||||
IN IP4_ADDR Gateway
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -165,9 +165,9 @@ Ip4DelRoute (
|
||||
**/
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4FindRouteCache (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -200,11 +200,11 @@ Ip4FreeRouteCacheEntry (
|
||||
**/
|
||||
IP4_ROUTE_CACHE_ENTRY *
|
||||
Ip4Route (
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src,
|
||||
IN IP4_ADDR SubnetMask,
|
||||
IN BOOLEAN AlwaysTryDestAddr
|
||||
IN IP4_ROUTE_TABLE *RtTable,
|
||||
IN IP4_ADDR Dest,
|
||||
IN IP4_ADDR Src,
|
||||
IN IP4_ADDR SubnetMask,
|
||||
IN BOOLEAN AlwaysTryDestAddr
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -220,6 +220,7 @@ Ip4Route (
|
||||
**/
|
||||
EFI_STATUS
|
||||
Ip4BuildEfiRouteTable (
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
IN IP4_PROTOCOL *IpInstance
|
||||
);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user