diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:07 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | d1050b9dff1cace252aff86630bfdb59dff5f507 (patch) | |
tree | 77f796143980742d97a883f62ce339a270474801 /NetworkPkg/Ip6Dxe | |
parent | 2f88bd3a1296c522317f1c21377876de63de5be7 (diff) | |
download | edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.zip edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.gz edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.bz2 |
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>
Diffstat (limited to 'NetworkPkg/Ip6Dxe')
28 files changed, 3622 insertions, 3643 deletions
diff --git a/NetworkPkg/Ip6Dxe/ComponentName.c b/NetworkPkg/Ip6Dxe/ComponentName.c index e57fe5e..b59c6d2 100644 --- a/NetworkPkg/Ip6Dxe/ComponentName.c +++ b/NetworkPkg/Ip6Dxe/ComponentName.c @@ -132,17 +132,17 @@ Ip6ComponentNameGetDriverName ( EFI_STATUS
EFIAPI
Ip6ComponentNameGetControllerName (
- 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.
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName = {
Ip6ComponentNameGetDriverName,
Ip6ComponentNameGetControllerName,
"eng"
@@ -152,12 +152,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName = // EFI Component Name 2 Protocol.
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ip6ComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ip6ComponentNameGetControllerName,
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Ip6ComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Ip6ComponentNameGetControllerName,
"en"
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp6DriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp6DriverNameTable[] = {
{
"eng;en",
L"IP6 Network Service Driver"
@@ -168,7 +168,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp6DriverNameTable[ }
};
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gIp6ControllerNameTable = NULL;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gIp6ControllerNameTable = NULL;
/**
Retrieves a Unicode string that is the user-readable name of the driver.
@@ -218,13 +218,12 @@ Ip6ComponentNameGetDriverName ( )
{
return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mIp6DriverNameTable,
- DriverName,
- (BOOLEAN) (This == &gIp6ComponentName)
- );
-
+ Language,
+ This->SupportedLanguages,
+ mIp6DriverNameTable,
+ DriverName,
+ (BOOLEAN)(This == &gIp6ComponentName)
+ );
}
/**
@@ -239,14 +238,14 @@ Ip6ComponentNameGetDriverName ( **/
EFI_STATUS
UpdateName (
- IN EFI_IP6_PROTOCOL *Ip6
+ IN EFI_IP6_PROTOCOL *Ip6
)
{
- EFI_STATUS Status;
- CHAR16 HandleName[128];
- EFI_IP6_MODE_DATA Ip6ModeData;
- UINTN Offset;
- CHAR16 Address[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
+ EFI_STATUS Status;
+ CHAR16 HandleName[128];
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ UINTN Offset;
+ CHAR16 Address[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
if (Ip6 == NULL) {
return EFI_INVALID_PARAMETER;
@@ -284,35 +283,37 @@ UpdateName ( }
if (!EFI_ERROR (Status) && Ip6ModeData.IsStarted) {
- Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.StationAddress, Address, sizeof(Address));
+ Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.StationAddress, Address, sizeof (Address));
if (EFI_ERROR (Status)) {
return Status;
}
+
Offset += UnicodeSPrint (
HandleName,
- sizeof(HandleName),
+ sizeof (HandleName),
L"IPv6(StationAddress=%s, ",
Address
);
- Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.DestinationAddress, Address, sizeof(Address));
+ Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.DestinationAddress, Address, sizeof (Address));
if (EFI_ERROR (Status)) {
return Status;
}
+
UnicodeSPrint (
HandleName + Offset,
- sizeof(HandleName) - Offset * sizeof (CHAR16),
+ sizeof (HandleName) - Offset * sizeof (CHAR16),
L"DestinationAddress=%s)",
Address
);
} else if (!Ip6ModeData.IsStarted) {
- UnicodeSPrint (HandleName, sizeof(HandleName), L"IPv6(Not started)");
+ UnicodeSPrint (HandleName, sizeof (HandleName), L"IPv6(Not started)");
} else {
- UnicodeSPrint (HandleName, sizeof(HandleName), L"IPv6(%r)", Status);
+ UnicodeSPrint (HandleName, sizeof (HandleName), L"IPv6(%r)", Status);
}
if (gIp6ControllerNameTable != NULL) {
- FreeUnicodeStringTable (gIp6ControllerNameTable);
- gIp6ControllerNameTable = NULL;
+ FreeUnicodeStringTable (gIp6ControllerNameTable);
+ gIp6ControllerNameTable = NULL;
}
Status = AddUnicodeString2 (
@@ -406,15 +407,15 @@ UpdateName ( EFI_STATUS
EFIAPI
Ip6ComponentNameGetControllerName (
- 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_IP6_PROTOCOL *Ip6;
+ EFI_STATUS Status;
+ EFI_IP6_PROTOCOL *Ip6;
//
// Only provide names for child handles.
diff --git a/NetworkPkg/Ip6Dxe/Ip6Common.c b/NetworkPkg/Ip6Dxe/Ip6Common.c index 840fff0..6622cf8 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Common.c +++ b/NetworkPkg/Ip6Dxe/Ip6Common.c @@ -101,16 +101,16 @@ Ip6BuildEfiAddressList ( **/
EFI_STATUS
Ip6SetToAllNodeMulticast (
- IN BOOLEAN Router,
- IN UINT8 Scope,
- OUT EFI_IPv6_ADDRESS *Ip6Addr
+ IN BOOLEAN Router,
+ IN UINT8 Scope,
+ OUT EFI_IPv6_ADDRESS *Ip6Addr
)
{
if (Ip6Addr == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (!Router && Scope == IP6_SITE_LOCAL_SCOPE) {
+ if (!Router && (Scope == IP6_SITE_LOCAL_SCOPE)) {
return EFI_INVALID_PARAMETER;
}
@@ -140,13 +140,13 @@ Ip6SetToAllNodeMulticast ( **/
UINT8 *
Ip6CreateInterfaceID (
- IN OUT IP6_SERVICE *IpSb
+ IN OUT IP6_SERVICE *IpSb
)
{
- UINT8 InterfaceId[8];
- UINT8 Byte;
- EFI_MAC_ADDRESS *MacAddr;
- UINT32 AddrLen;
+ UINT8 InterfaceId[8];
+ UINT8 Byte;
+ EFI_MAC_ADDRESS *MacAddr;
+ UINT32 AddrLen;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -155,7 +155,7 @@ Ip6CreateInterfaceID ( //
// Currently only IEEE 802 48-bit MACs are supported to create link local address.
//
- if (AddrLen != IP6_MAC_LEN || IpSb->InterfaceIdLen != IP6_IF_ID_LEN) {
+ if ((AddrLen != IP6_MAC_LEN) || (IpSb->InterfaceIdLen != IP6_IF_ID_LEN)) {
return NULL;
}
@@ -171,7 +171,7 @@ Ip6CreateInterfaceID ( InterfaceId[4] = 0xFE;
CopyMem (&InterfaceId[5], &MacAddr->Addr[3], 3);
- Byte = (UINT8) (InterfaceId[0] & IP6_U_BIT);
+ Byte = (UINT8)(InterfaceId[0] & IP6_U_BIT);
if (Byte == IP6_U_BIT) {
InterfaceId[0] &= ~IP6_U_BIT;
} else {
@@ -198,7 +198,7 @@ Ip6CreateInterfaceID ( **/
EFI_IPv6_ADDRESS *
Ip6CreateLinkLocalAddr (
- IN OUT IP6_SERVICE *IpSb
+ IN OUT IP6_SERVICE *IpSb
)
{
EFI_IPv6_ADDRESS *Ip6Addr;
@@ -289,8 +289,8 @@ Ip6CreateLinkLocalAddr ( **/
VOID
Ip6CreateSNMulticastAddr (
- IN EFI_IPv6_ADDRESS *Ip6Addr,
- OUT EFI_IPv6_ADDRESS *MulticastAddr
+ IN EFI_IPv6_ADDRESS *Ip6Addr,
+ OUT EFI_IPv6_ADDRESS *MulticastAddr
)
{
ASSERT (Ip6Addr != NULL && MulticastAddr != NULL);
@@ -314,8 +314,8 @@ Ip6CreateSNMulticastAddr ( **/
VOID
Ip6AddAddr (
- IN OUT IP6_INTERFACE *IpIf,
- IN IP6_ADDRESS_INFO *AddrInfo
+ IN OUT IP6_INTERFACE *IpIf,
+ IN IP6_ADDRESS_INFO *AddrInfo
)
{
InsertHeadList (&IpIf->AddressList, &AddrInfo->Link);
@@ -335,17 +335,17 @@ Ip6AddAddr ( EFI_STATUS
EFIAPI
Ip6DestroyChildEntryByAddr (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
IP6_PROTOCOL *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
EFI_IPv6_ADDRESS *Address;
- Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
- ServiceBinding = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->ServiceBinding;
- Address = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->Address;
+ Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
+ ServiceBinding = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT *)Context)->ServiceBinding;
+ Address = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT *)Context)->Address;
if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) {
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
@@ -368,14 +368,14 @@ Ip6DestroyInstanceByAddress ( IN EFI_IPv6_ADDRESS *Address
)
{
- LIST_ENTRY *List;
+ LIST_ENTRY *List;
IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
- List = &IpSb->Children;
+ List = &IpSb->Children;
Context.ServiceBinding = &IpSb->ServiceBinding;
- Context.Address = Address;
+ Context.Address = Address;
NetDestroyLinkList (
List,
Ip6DestroyChildEntryByAddr,
@@ -416,13 +416,13 @@ Ip6RemoveAddr ( IN UINT8 PrefixLength
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_ADDRESS_INFO *AddrInfo;
- EFI_IPv6_ADDRESS SnMCastAddr;
+ EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_ADDRESS_INFO *AddrInfo;
+ EFI_IPv6_ADDRESS SnMCastAddr;
- if (IsListEmpty (AddressList) || *AddressCount < 1 || PrefixLength > IP6_PREFIX_MAX) {
+ if (IsListEmpty (AddressList) || (*AddressCount < 1) || (PrefixLength > IP6_PREFIX_MAX)) {
return EFI_INVALID_PARAMETER;
}
@@ -431,10 +431,11 @@ Ip6RemoveAddr ( NET_LIST_FOR_EACH_SAFE (Entry, Next, AddressList) {
AddrInfo = NET_LIST_USER_STRUCT_S (Entry, IP6_ADDRESS_INFO, Link, IP6_ADDR_INFO_SIGNATURE);
- if (Prefix == NULL ||
- (PrefixLength == 128 && EFI_IP6_EQUAL (Prefix, &AddrInfo->Address)) ||
- (PrefixLength == AddrInfo->PrefixLength && NetIp6IsNetEqual (Prefix, &AddrInfo->Address, PrefixLength))
- ) {
+ if ((Prefix == NULL) ||
+ ((PrefixLength == 128) && EFI_IP6_EQUAL (Prefix, &AddrInfo->Address)) ||
+ ((PrefixLength == AddrInfo->PrefixLength) && NetIp6IsNetEqual (Prefix, &AddrInfo->Address, PrefixLength))
+ )
+ {
if (IpSb != NULL) {
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
Ip6CreateSNMulticastAddr (&AddrInfo->Address, &SnMCastAddr);
@@ -468,11 +469,11 @@ Ip6RemoveAddr ( **/
BOOLEAN
Ip6IsSNMulticastAddr (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
)
{
- EFI_IPv6_ADDRESS Sn;
- BOOLEAN Flag;
+ EFI_IPv6_ADDRESS Sn;
+ BOOLEAN Flag;
Ip6CreateSNMulticastAddr (Ip6, &Sn);
Flag = FALSE;
@@ -501,16 +502,16 @@ Ip6IsSNMulticastAddr ( **/
BOOLEAN
Ip6IsOneOfSetAddress (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Address,
- OUT IP6_INTERFACE **Interface OPTIONAL,
- OUT IP6_ADDRESS_INFO **AddressInfo OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Address,
+ OUT IP6_INTERFACE **Interface OPTIONAL,
+ OUT IP6_ADDRESS_INFO **AddressInfo OPTIONAL
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Entry2;
- IP6_INTERFACE *IpIf;
- IP6_ADDRESS_INFO *TmpAddressInfo;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry2;
+ IP6_INTERFACE *IpIf;
+ IP6_ADDRESS_INFO *TmpAddressInfo;
//
// Check link-local address first
@@ -566,7 +567,7 @@ Ip6IsValidLinkAddress ( IN EFI_MAC_ADDRESS *LinkAddress
)
{
- UINT32 Index;
+ UINT32 Index;
//
// TODO: might be updated later to be more acceptable.
@@ -590,29 +591,29 @@ Ip6IsValidLinkAddress ( **/
VOID
Ip6CopyAddressByPrefix (
- OUT EFI_IPv6_ADDRESS *Dest,
- IN EFI_IPv6_ADDRESS *Src,
- IN UINT8 PrefixLength
+ OUT EFI_IPv6_ADDRESS *Dest,
+ IN EFI_IPv6_ADDRESS *Src,
+ IN UINT8 PrefixLength
)
{
- UINT8 Byte;
- UINT8 Bit;
- UINT8 Mask;
+ UINT8 Byte;
+ UINT8 Bit;
+ UINT8 Mask;
ASSERT (Dest != NULL && Src != NULL);
ASSERT (PrefixLength <= IP6_PREFIX_MAX);
- Byte = (UINT8) (PrefixLength / 8);
- Bit = (UINT8) (PrefixLength % 8);
+ Byte = (UINT8)(PrefixLength / 8);
+ Bit = (UINT8)(PrefixLength % 8);
ZeroMem (Dest, sizeof (EFI_IPv6_ADDRESS));
CopyMem (Dest, Src, Byte);
if (Bit > 0) {
- Mask = (UINT8) (0xFF << (8 - Bit));
+ Mask = (UINT8)(0xFF << (8 - Bit));
ASSERT (Byte < 16);
- Dest->Addr[Byte] = (UINT8) (Src->Addr[Byte] & Mask);
+ Dest->Addr[Byte] = (UINT8)(Src->Addr[Byte] & Mask);
}
}
@@ -632,12 +633,12 @@ Ip6CopyAddressByPrefix ( **/
EFI_STATUS
Ip6GetMulticastMac (
- IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
- IN EFI_IPv6_ADDRESS *Multicast,
- OUT EFI_MAC_ADDRESS *Mac
+ IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
+ IN EFI_IPv6_ADDRESS *Multicast,
+ OUT EFI_MAC_ADDRESS *Mac
)
{
- EFI_IP_ADDRESS EfiIp;
+ EFI_IP_ADDRESS EfiIp;
IP6_COPY_ADDRESS (&EfiIp.v6, Multicast);
@@ -656,7 +657,7 @@ Ip6GetMulticastMac ( **/
EFI_IP6_HEADER *
Ip6NtohHead (
- IN OUT EFI_IP6_HEADER *Head
+ IN OUT EFI_IP6_HEADER *Head
)
{
Head->FlowLabelL = NTOHS (Head->FlowLabelL);
@@ -664,4 +665,3 @@ Ip6NtohHead ( return Head;
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Common.h b/NetworkPkg/Ip6Dxe/Ip6Common.h index 18723f8..cfa9bb5 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Common.h +++ b/NetworkPkg/Ip6Dxe/Ip6Common.h @@ -10,59 +10,59 @@ #ifndef __EFI_IP6_COMMON_H__
#define __EFI_IP6_COMMON_H__
-#define IP6_LINK_EQUAL(Mac1, Mac2) (CompareMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)) == 0)
+#define IP6_LINK_EQUAL(Mac1, Mac2) (CompareMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)) == 0)
//
// Convert the Microsecond to second. IP transmit/receive time is
// in the unit of microsecond. IP ticks once per second.
//
-#define IP6_US_TO_SEC(Us) (((Us) + 999999) / 1000000)
+#define IP6_US_TO_SEC(Us) (((Us) + 999999) / 1000000)
-#define IP6_ETHER_PROTO 0x86DD
+#define IP6_ETHER_PROTO 0x86DD
-#define IP6_MAC_LEN 6
-#define IP6_IF_ID_LEN 8
+#define IP6_MAC_LEN 6
+#define IP6_IF_ID_LEN 8
-#define IP6_INTERFACE_LOCAL_SCOPE 1
-#define IP6_LINK_LOCAL_SCOPE 2
-#define IP6_SITE_LOCAL_SCOPE 5
+#define IP6_INTERFACE_LOCAL_SCOPE 1
+#define IP6_LINK_LOCAL_SCOPE 2
+#define IP6_SITE_LOCAL_SCOPE 5
-#define IP6_INFINIT_LIFETIME 0xFFFFFFFF
+#define IP6_INFINIT_LIFETIME 0xFFFFFFFF
-#define IP6_HOP_LIMIT 255
+#define IP6_HOP_LIMIT 255
//
// Make it to 64 since all 54 bits are zero.
//
-#define IP6_LINK_LOCAL_PREFIX_LENGTH 64
+#define IP6_LINK_LOCAL_PREFIX_LENGTH 64
-#define IP6_TIMER_INTERVAL_IN_MS 100
-#define IP6_ONE_SECOND_IN_MS 1000
+#define IP6_TIMER_INTERVAL_IN_MS 100
+#define IP6_ONE_SECOND_IN_MS 1000
//
// The packet is received as link level broadcast/multicast/promiscuous.
//
-#define IP6_LINK_BROADCAST 0x00000001
-#define IP6_LINK_MULTICAST 0x00000002
-#define IP6_LINK_PROMISC 0x00000004
+#define IP6_LINK_BROADCAST 0x00000001
+#define IP6_LINK_MULTICAST 0x00000002
+#define IP6_LINK_PROMISC 0x00000004
-#define IP6_U_BIT 0x02
+#define IP6_U_BIT 0x02
typedef enum {
- Ip6Promiscuous = 1,
+ Ip6Promiscuous = 1,
Ip6Unicast,
Ip6Multicast,
Ip6AnyCast
} IP6_ADDRESS_TYPE;
typedef struct {
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- EFI_IPv6_ADDRESS *Address;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ EFI_IPv6_ADDRESS *Address;
} IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT;
-typedef struct _IP6_INTERFACE IP6_INTERFACE;
-typedef struct _IP6_PROTOCOL IP6_PROTOCOL;
-typedef struct _IP6_SERVICE IP6_SERVICE;
-typedef struct _IP6_ADDRESS_INFO IP6_ADDRESS_INFO;
+typedef struct _IP6_INTERFACE IP6_INTERFACE;
+typedef struct _IP6_PROTOCOL IP6_PROTOCOL;
+typedef struct _IP6_SERVICE IP6_SERVICE;
+typedef struct _IP6_ADDRESS_INFO IP6_ADDRESS_INFO;
/**
Build a array of EFI_IP6_ADDRESS_INFO to be returned to the caller. The number
@@ -105,9 +105,9 @@ Ip6BuildEfiAddressList ( **/
EFI_STATUS
Ip6SetToAllNodeMulticast (
- IN BOOLEAN Router,
- IN UINT8 Scope,
- OUT EFI_IPv6_ADDRESS *Ip6Addr
+ IN BOOLEAN Router,
+ IN UINT8 Scope,
+ OUT EFI_IPv6_ADDRESS *Ip6Addr
);
/**
@@ -123,7 +123,7 @@ Ip6SetToAllNodeMulticast ( **/
UINT8 *
Ip6CreateInterfaceID (
- IN OUT IP6_SERVICE *IpSb
+ IN OUT IP6_SERVICE *IpSb
);
/**
@@ -140,7 +140,7 @@ Ip6CreateInterfaceID ( **/
EFI_IPv6_ADDRESS *
Ip6CreateLinkLocalAddr (
- IN OUT IP6_SERVICE *IpSb
+ IN OUT IP6_SERVICE *IpSb
);
/**
@@ -155,8 +155,8 @@ Ip6CreateLinkLocalAddr ( **/
VOID
Ip6CreateSNMulticastAddr (
- IN EFI_IPv6_ADDRESS *Ip6Addr,
- OUT EFI_IPv6_ADDRESS *MulticastAddr
+ IN EFI_IPv6_ADDRESS *Ip6Addr,
+ OUT EFI_IPv6_ADDRESS *MulticastAddr
);
/**
@@ -170,7 +170,7 @@ Ip6CreateSNMulticastAddr ( **/
BOOLEAN
Ip6IsSNMulticastAddr (
- IN EFI_IPv6_ADDRESS *Ip6
+ IN EFI_IPv6_ADDRESS *Ip6
);
/**
@@ -190,10 +190,10 @@ Ip6IsSNMulticastAddr ( **/
BOOLEAN
Ip6IsOneOfSetAddress (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Address,
- OUT IP6_INTERFACE **Interface OPTIONAL,
- OUT IP6_ADDRESS_INFO **AddressInfo OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Address,
+ OUT IP6_INTERFACE **Interface OPTIONAL,
+ OUT IP6_ADDRESS_INFO **AddressInfo OPTIONAL
);
/**
@@ -212,7 +212,6 @@ Ip6IsValidLinkAddress ( IN EFI_MAC_ADDRESS *LinkAddress
);
-
/**
Copy the PrefixLength bits from Src to Dest.
@@ -223,9 +222,9 @@ Ip6IsValidLinkAddress ( **/
VOID
Ip6CopyAddressByPrefix (
- OUT EFI_IPv6_ADDRESS *Dest,
- IN EFI_IPv6_ADDRESS *Src,
- IN UINT8 PrefixLength
+ OUT EFI_IPv6_ADDRESS *Dest,
+ IN EFI_IPv6_ADDRESS *Src,
+ IN UINT8 PrefixLength
);
/**
@@ -237,8 +236,8 @@ Ip6CopyAddressByPrefix ( **/
VOID
Ip6AddAddr (
- IN OUT IP6_INTERFACE *IpIf,
- IN IP6_ADDRESS_INFO *AddrInfo
+ IN OUT IP6_INTERFACE *IpIf,
+ IN IP6_ADDRESS_INFO *AddrInfo
);
/**
@@ -289,9 +288,9 @@ Ip6RemoveAddr ( **/
EFI_STATUS
Ip6GetMulticastMac (
- IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
- IN EFI_IPv6_ADDRESS *Multicast,
- OUT EFI_MAC_ADDRESS *Mac
+ IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
+ IN EFI_IPv6_ADDRESS *Multicast,
+ OUT EFI_MAC_ADDRESS *Mac
);
/**
@@ -306,7 +305,7 @@ Ip6GetMulticastMac ( **/
EFI_IP6_HEADER *
Ip6NtohHead (
- IN OUT EFI_IP6_HEADER *Head
+ IN OUT EFI_IP6_HEADER *Head
);
#endif
diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c index ab38013..70e232c 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c @@ -10,7 +10,7 @@ #include "Ip6Impl.h"
-LIST_ENTRY mIp6ConfigInstanceList = {&mIp6ConfigInstanceList, &mIp6ConfigInstanceList};
+LIST_ENTRY mIp6ConfigInstanceList = { &mIp6ConfigInstanceList, &mIp6ConfigInstanceList };
/**
The event process routine when the DHCPv6 service binding protocol is installed
@@ -42,15 +42,15 @@ Ip6ConfigOnPolicyChanged ( IN EFI_IP6_CONFIG_POLICY NewPolicy
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Entry2;
- LIST_ENTRY *Next;
- IP6_INTERFACE *IpIf;
- IP6_DAD_ENTRY *DadEntry;
- IP6_DELAY_JOIN_LIST *DelayNode;
- IP6_ADDRESS_INFO *AddrInfo;
- IP6_PROTOCOL *Instance;
- BOOLEAN Recovery;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry2;
+ LIST_ENTRY *Next;
+ IP6_INTERFACE *IpIf;
+ IP6_DAD_ENTRY *DadEntry;
+ IP6_DELAY_JOIN_LIST *DelayNode;
+ IP6_ADDRESS_INFO *AddrInfo;
+ IP6_PROTOCOL *Instance;
+ BOOLEAN Recovery;
Recovery = FALSE;
@@ -73,14 +73,14 @@ Ip6ConfigOnPolicyChanged ( Ip6CreatePrefixListEntry (
IpSb,
TRUE,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
IP6_LINK_LOCAL_PREFIX_LENGTH,
&IpSb->LinkLocalAddr
);
}
- if (!IsListEmpty (&IpSb->DefaultInterface->AddressList) && IpSb->DefaultInterface->AddressCount > 0) {
+ if (!IsListEmpty (&IpSb->DefaultInterface->AddressList) && (IpSb->DefaultInterface->AddressCount > 0)) {
//
// If any IPv6 children (Instance) in configured state and use global unicast address, it will be
// destroyed in Ip6RemoveAddr() function later. Then, the upper layer driver's Stop() function will be
@@ -114,7 +114,7 @@ Ip6ConfigOnPolicyChanged ( 0
);
- if (IpSb->Controller != NULL && Recovery) {
+ if ((IpSb->Controller != NULL) && Recovery) {
//
// ConnectController() to recover the upper layer network stacks.
//
@@ -122,7 +122,6 @@ Ip6ConfigOnPolicyChanged ( }
}
-
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
//
// remove all pending delay node and DAD entries for the global addresses.
@@ -158,7 +157,7 @@ Ip6ConfigOnPolicyChanged ( //
// delay 1 second
//
- IpSb->Ticks = (UINT32) IP6_GET_TICKS (IP6_ONE_SECOND_IN_MS);
+ IpSb->Ticks = (UINT32)IP6_GET_TICKS (IP6_ONE_SECOND_IN_MS);
}
}
@@ -216,7 +215,7 @@ Ip6ConfigStartStatefulAutoConfig ( &gEfiDhcp6ServiceBindingProtocolGuid,
TPL_CALLBACK,
Ip6ConfigOnDhcp6SbInstalled,
- (VOID *) Instance,
+ (VOID *)Instance,
&Instance->Registration
);
}
@@ -233,7 +232,7 @@ Ip6ConfigStartStatefulAutoConfig ( Status = gBS->OpenProtocol (
Instance->Dhcp6Handle,
&gEfiDhcp6ProtocolGuid,
- (VOID **) &Instance->Dhcp6,
+ (VOID **)&Instance->Dhcp6,
IpSb->Image,
IpSb->Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -247,13 +246,13 @@ Ip6ConfigStartStatefulAutoConfig ( // Set the exta options to send. Here we only want the option request option
// with DNS SERVERS.
//
- Oro = (EFI_DHCP6_PACKET_OPTION *) OptBuf;
- Oro->OpCode = HTONS (DHCP6_OPT_ORO);
- Oro->OpLen = HTONS (2);
- *((UINT16 *) &Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS);
- OptList[0] = Oro;
+ Oro = (EFI_DHCP6_PACKET_OPTION *)OptBuf;
+ Oro->OpCode = HTONS (DHCP6_OPT_ORO);
+ Oro->OpLen = HTONS (2);
+ *((UINT16 *)&Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS);
+ OptList[0] = Oro;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
if (!OtherInfoOnly) {
//
@@ -273,13 +272,11 @@ Ip6ConfigStartStatefulAutoConfig ( Status = Dhcp6->Configure (Dhcp6, &Dhcp6CfgData);
if (!EFI_ERROR (Status)) {
-
if (IpSb->LinkLocalOk) {
Status = Dhcp6->Start (Dhcp6);
} else {
IpSb->Dhcp6NeedStart = TRUE;
}
-
}
} else {
//
@@ -306,7 +303,6 @@ Ip6ConfigStartStatefulAutoConfig ( } else {
IpSb->Dhcp6NeedInfoRequest = TRUE;
}
-
}
return Status;
@@ -323,12 +319,12 @@ Ip6ConfigStartStatefulAutoConfig ( EFI_STATUS
EFIAPI
Ip6ConfigSignalEvent (
- IN NET_MAP *Map,
- IN NET_MAP_ITEM *Item,
- IN VOID *Arg
+ IN NET_MAP *Map,
+ IN NET_MAP_ITEM *Item,
+ IN VOID *Arg
)
{
- gBS->SignalEvent ((EFI_EVENT) Item->Key);
+ gBS->SignalEvent ((EFI_EVENT)Item->Key);
return EFI_SUCCESS;
}
@@ -389,7 +385,7 @@ Ip6ConfigReadConfigData ( &VarSize,
Variable
);
- if (EFI_ERROR (Status) || (UINT16) (~NetblockChecksum ((UINT8 *) Variable, (UINT32) VarSize)) != 0) {
+ if (EFI_ERROR (Status) || ((UINT16)(~NetblockChecksum ((UINT8 *)Variable, (UINT32)VarSize)) != 0)) {
//
// GetVariable error or the variable is corrupted.
//
@@ -402,13 +398,13 @@ Ip6ConfigReadConfigData ( Instance->IaId = Variable->IaId;
for (Index = 0; Index < Variable->DataRecordCount; Index++) {
-
CopyMem (&DataRecord, &Variable->DataRecord[Index], sizeof (DataRecord));
DataItem = &Instance->DataItem[DataRecord.DataType];
if (DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED) &&
(DataItem->DataSize != DataRecord.DataSize)
- ) {
+ )
+ {
//
// Perhaps a corrupted data record...
//
@@ -433,7 +429,7 @@ Ip6ConfigReadConfigData ( }
}
- Data = (CHAR8 *) Variable + DataRecord.Offset;
+ Data = (CHAR8 *)Variable + DataRecord.Offset;
CopyMem (DataItem->Data.Ptr, Data, DataRecord.DataSize);
DataItem->DataSize = DataRecord.DataSize;
@@ -496,10 +492,8 @@ Ip6ConfigWriteConfigData ( VarSize = sizeof (IP6_CONFIG_VARIABLE) - sizeof (IP6_CONFIG_DATA_RECORD);
for (Index = 0; Index < Ip6ConfigDataTypeMaximum; Index++) {
-
DataItem = &Instance->DataItem[Index];
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) {
-
VarSize += sizeof (IP6_CONFIG_DATA_RECORD) + DataItem->DataSize;
}
}
@@ -510,28 +504,26 @@ Ip6ConfigWriteConfigData ( }
Variable->IaId = Instance->IaId;
- Heap = (CHAR8 *) Variable + VarSize;
+ Heap = (CHAR8 *)Variable + VarSize;
Variable->DataRecordCount = 0;
for (Index = 0; Index < Ip6ConfigDataTypeMaximum; Index++) {
-
DataItem = &Instance->DataItem[Index];
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_VOLATILE) && !EFI_ERROR (DataItem->Status)) {
-
Heap -= DataItem->DataSize;
CopyMem (Heap, DataItem->Data.Ptr, DataItem->DataSize);
DataRecord = &Variable->DataRecord[Variable->DataRecordCount];
- DataRecord->DataType = (EFI_IP6_CONFIG_DATA_TYPE) Index;
- DataRecord->DataSize = (UINT32) DataItem->DataSize;
- DataRecord->Offset = (UINT16) (Heap - (CHAR8 *) Variable);
+ DataRecord->DataType = (EFI_IP6_CONFIG_DATA_TYPE)Index;
+ DataRecord->DataSize = (UINT32)DataItem->DataSize;
+ DataRecord->Offset = (UINT16)(Heap - (CHAR8 *)Variable);
Variable->DataRecordCount++;
}
}
Variable->Checksum = 0;
- Variable->Checksum = (UINT16) ~NetblockChecksum ((UINT8 *) Variable, (UINT32) VarSize);
+ Variable->Checksum = (UINT16) ~NetblockChecksum ((UINT8 *)Variable, (UINT32)VarSize);
Status = gRT->SetVariable (
VarName,
@@ -597,20 +589,20 @@ Ip6ConfigGetIfInfo ( //
// Copy the fixed size part of the interface info.
//
- Item = &Instance->DataItem[Ip6ConfigDataTypeInterfaceInfo];
- IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data;
+ Item = &Instance->DataItem[Ip6ConfigDataTypeInterfaceInfo];
+ IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *)Data;
CopyMem (IfInfo, Item->Data.Ptr, sizeof (EFI_IP6_CONFIG_INTERFACE_INFO));
//
// AddressInfo
//
- IfInfo->AddressInfo = (EFI_IP6_ADDRESS_INFO *) (IfInfo + 1);
+ IfInfo->AddressInfo = (EFI_IP6_ADDRESS_INFO *)(IfInfo + 1);
Ip6BuildEfiAddressList (IpSb, &IfInfo->AddressInfoCount, &IfInfo->AddressInfo);
//
// RouteTable
//
- IfInfo->RouteTable = (EFI_IP6_ROUTE_TABLE *) (IfInfo->AddressInfo + IfInfo->AddressInfoCount);
+ IfInfo->RouteTable = (EFI_IP6_ROUTE_TABLE *)(IfInfo->AddressInfo + IfInfo->AddressInfoCount);
Ip6BuildEfiRouteTable (IpSb->RouteTable, &IfInfo->RouteCount, &IfInfo->RouteTable);
if (IfInfo->AddressInfoCount == 0) {
@@ -657,7 +649,7 @@ Ip6ConfigSetAltIfId ( DataItem = &Instance->DataItem[Ip6ConfigDataTypeAltInterfaceId];
OldIfId = DataItem->Data.AltIfId;
- NewIfId = (EFI_IP6_CONFIG_INTERFACE_ID *) Data;
+ NewIfId = (EFI_IP6_CONFIG_INTERFACE_ID *)Data;
CopyMem (OldIfId, NewIfId, DataSize);
DataItem->Status = EFI_SUCCESS;
@@ -696,33 +688,34 @@ Ip6ConfigSetPolicy ( return EFI_BAD_BUFFER_SIZE;
}
- NewPolicy = *((EFI_IP6_CONFIG_POLICY *) Data);
+ NewPolicy = *((EFI_IP6_CONFIG_POLICY *)Data);
if (NewPolicy > Ip6ConfigPolicyAutomatic) {
return EFI_INVALID_PARAMETER;
}
if (NewPolicy == Instance->Policy) {
-
return EFI_ABORTED;
} else {
//
// Clean the ManualAddress, Gateway and DnsServers, shrink the variable
// data size, and fire up all the related events.
//
- DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
+ DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
+
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL);
- DataItem = &Instance->DataItem[Ip6ConfigDataTypeGateway];
+ DataItem = &Instance->DataItem[Ip6ConfigDataTypeGateway];
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
+
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
@@ -784,12 +777,10 @@ Ip6ConfigSetDadXmits ( OldDadXmits = Instance->DataItem[Ip6ConfigDataTypeDupAddrDetectTransmits].Data.DadXmits;
- if ((*(UINT32 *) Data) == OldDadXmits->DupAddrDetectTransmits) {
-
+ if ((*(UINT32 *)Data) == OldDadXmits->DupAddrDetectTransmits) {
return EFI_ABORTED;
} else {
-
- OldDadXmits->DupAddrDetectTransmits = *((UINT32 *) Data);
+ OldDadXmits->DupAddrDetectTransmits = *((UINT32 *)Data);
return EFI_SUCCESS;
}
}
@@ -820,7 +811,7 @@ Ip6ManualAddrDadCallback ( UINTN DadFailCount;
IP6_SERVICE *IpSb;
- Instance = (IP6_CONFIG_INSTANCE *) Context;
+ Instance = (IP6_CONFIG_INSTANCE *)Context;
NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
Item = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
ManualAddr = NULL;
@@ -872,20 +863,20 @@ Ip6ManualAddrDadCallback ( // Part of addresses are detected to be duplicates, so update the
// data with those passed.
//
- PassedAddr = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) AllocatePool (Item->DataSize);
+ PassedAddr = (EFI_IP6_CONFIG_MANUAL_ADDRESS *)AllocatePool (Item->DataSize);
ASSERT (PassedAddr != NULL);
Item->Data.Ptr = PassedAddr;
Item->Status = EFI_SUCCESS;
while (!NetMapIsEmpty (&Instance->DadPassedMap)) {
- ManualAddr = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) NetMapRemoveHead (&Instance->DadPassedMap, NULL);
+ ManualAddr = (EFI_IP6_CONFIG_MANUAL_ADDRESS *)NetMapRemoveHead (&Instance->DadPassedMap, NULL);
CopyMem (PassedAddr, ManualAddr, sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS));
PassedAddr++;
}
- ASSERT ((UINTN) PassedAddr - (UINTN) Item->Data.Ptr == Item->DataSize);
+ ASSERT ((UINTN)PassedAddr - (UINTN)Item->Data.Ptr == Item->DataSize);
}
} else {
//
@@ -991,16 +982,16 @@ Ip6ConfigSetManualAddress ( DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
- if (Data != NULL && DataSize != 0) {
+ if ((Data != NULL) && (DataSize != 0)) {
NewAddressCount = DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS);
- NewAddress = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) Data;
+ NewAddress = (EFI_IP6_CONFIG_MANUAL_ADDRESS *)Data;
for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) {
-
if (NetIp6IsLinkLocalAddr (&NewAddress->Address) ||
!NetIp6IsValidUnicast (&NewAddress->Address) ||
(NewAddress->PrefixLength > 128)
- ) {
+ )
+ {
//
// make sure the IPv6 address is unicast and not link-local address &&
// the prefix length is valid.
@@ -1014,7 +1005,6 @@ Ip6ConfigSetManualAddress ( // Any two addresses in the array can't be equal.
//
if (EFI_IP6_EQUAL (&TmpAddress->Address, &NewAddress->Address)) {
-
return EFI_INVALID_PARAMETER;
}
}
@@ -1032,7 +1022,7 @@ Ip6ConfigSetManualAddress ( NET_LIST_FOR_EACH (Entry2, &IpIf->AddressList) {
CurrentAddrInfo = NET_LIST_USER_STRUCT_S (Entry2, IP6_ADDRESS_INFO, Link, IP6_ADDR_INFO_SIGNATURE);
- Copy = AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), CurrentAddrInfo);
+ Copy = AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), CurrentAddrInfo);
if (Copy == NULL) {
break;
}
@@ -1059,6 +1049,7 @@ Ip6ConfigSetManualAddress ( if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
+
DataItem->Data.Ptr = NewAddress;
DataItem->DataSize = DataSize;
DataItem->Status = EFI_NOT_READY;
@@ -1066,7 +1057,7 @@ Ip6ConfigSetManualAddress ( //
// Trigger DAD, it's an asynchronous process.
//
- IsUpdated = FALSE;
+ IsUpdated = FALSE;
for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) {
if (Ip6IsOneOfSetAddress (IpSb, &NewAddress->Address, NULL, &CurrentAddrInfo)) {
@@ -1113,7 +1104,7 @@ Ip6ConfigSetManualAddress ( // Save the prefix length.
//
CurrentAddrInfo->PrefixLength = NewAddress->PrefixLength;
- IsUpdated = TRUE;
+ IsUpdated = TRUE;
}
//
@@ -1129,8 +1120,8 @@ Ip6ConfigSetManualAddress ( Ip6CreatePrefixListEntry (
IpSb,
TRUE,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
NewAddress->PrefixLength,
&NewAddress->Address
);
@@ -1156,8 +1147,8 @@ Ip6ConfigSetManualAddress ( &NewAddress->Address,
NewAddress->IsAnycast,
NewAddress->PrefixLength,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
Ip6ManualAddrDadCallback,
Instance
);
@@ -1230,6 +1221,7 @@ Ip6ConfigSetManualAddress ( if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
+
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
DataItem->Status = EFI_NOT_FOUND;
@@ -1243,8 +1235,8 @@ Ip6ConfigSetManualAddress ( Ip6CreatePrefixListEntry (
IpSb,
TRUE,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
IP6_LINK_LOCAL_PREFIX_LENGTH,
&IpSb->LinkLocalAddr
);
@@ -1330,13 +1322,13 @@ Ip6ConfigSetGateway ( IP6_DEFAULT_ROUTER *DefaultRouter;
VOID *Tmp;
- OldGateway = NULL;
- NewGateway = NULL;
- Item = NULL;
- DefaultRouter = NULL;
- Tmp = NULL;
- OneRemoved = FALSE;
- OneAdded = FALSE;
+ OldGateway = NULL;
+ NewGateway = NULL;
+ Item = NULL;
+ DefaultRouter = NULL;
+ Tmp = NULL;
+ OneRemoved = FALSE;
+ OneAdded = FALSE;
if ((DataSize != 0) && (DataSize % sizeof (EFI_IPv6_ADDRESS) != 0)) {
return EFI_BAD_BUFFER_SIZE;
@@ -1362,13 +1354,11 @@ Ip6ConfigSetGateway ( }
}
- if (Data != NULL && DataSize != 0) {
- NewGateway = (EFI_IPv6_ADDRESS *) Data;
+ if ((Data != NULL) && (DataSize != 0)) {
+ NewGateway = (EFI_IPv6_ADDRESS *)Data;
NewGatewayCount = DataSize / sizeof (EFI_IPv6_ADDRESS);
for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {
-
if (!NetIp6IsValidUnicast (NewGateway + Index1)) {
-
return EFI_INVALID_PARAMETER;
}
@@ -1389,7 +1379,6 @@ Ip6ConfigSetGateway ( }
for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {
-
DefaultRouter = Ip6FindDefaultRouter (IpSb, NewGateway + Index1);
if (DefaultRouter == NULL) {
Ip6CreateDefaultRouter (IpSb, NewGateway + Index1, IP6_INF_ROUTER_LIFETIME);
@@ -1401,11 +1390,11 @@ Ip6ConfigSetGateway ( Item->Status = EFI_SUCCESS;
return EFI_ABORTED;
} else {
-
if (Tmp != NULL) {
if (Item->Data.Ptr != NULL) {
FreePool (Item->Data.Ptr);
}
+
Item->Data.Ptr = Tmp;
}
@@ -1421,6 +1410,7 @@ Ip6ConfigSetGateway ( if (Item->Data.Ptr != NULL) {
FreePool (Item->Data.Ptr);
}
+
Item->Data.Ptr = NULL;
Item->DataSize = 0;
Item->Status = EFI_NOT_FOUND;
@@ -1483,8 +1473,8 @@ Ip6ConfigSetDnsServer ( Item = &Instance->DataItem[Ip6ConfigDataTypeDnsServer];
- if (Data != NULL && DataSize != 0) {
- NewDns = (EFI_IPv6_ADDRESS *) Data;
+ if ((Data != NULL) && (DataSize != 0)) {
+ NewDns = (EFI_IPv6_ADDRESS *)Data;
OldDns = Item->Data.DnsServers;
NewDnsCount = DataSize / sizeof (EFI_IPv6_ADDRESS);
OldDnsCount = Item->DataSize / sizeof (EFI_IPv6_ADDRESS);
@@ -1500,7 +1490,6 @@ Ip6ConfigSetDnsServer ( }
for (NewIndex = 0; NewIndex < NewDnsCount; NewIndex++) {
-
if (!NetIp6IsValidUnicast (NewDns + NewIndex)) {
//
// The dns server address must be unicast.
@@ -1508,6 +1497,7 @@ Ip6ConfigSetDnsServer ( if (Tmp != NULL) {
FreePool (Tmp);
}
+
return EFI_INVALID_PARAMETER;
}
@@ -1544,6 +1534,7 @@ Ip6ConfigSetDnsServer ( if (Item->Data.Ptr != NULL) {
FreePool (Item->Data.Ptr);
}
+
Item->Data.Ptr = Tmp;
}
@@ -1551,13 +1542,14 @@ Ip6ConfigSetDnsServer ( Item->DataSize = DataSize;
Item->Status = EFI_SUCCESS;
}
- } else {
+ } else {
//
// DataSize is 0 and Data is NULL, clean up the DnsServer address.
//
if (Item->Data.Ptr != NULL) {
FreePool (Item->Data.Ptr);
}
+
Item->Data.Ptr = NULL;
Item->DataSize = 0;
Item->Status = EFI_NOT_FOUND;
@@ -1585,7 +1577,7 @@ Ip6ConfigInitIfInfo ( sizeof (IfInfo->Name),
L"eth%d",
IpSb->Ip6ConfigInstance.IfIndex
- );
+ );
IfInfo->IfType = IpSb->SnpMode.IfType;
IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;
@@ -1607,9 +1599,9 @@ Ip6ConfigInitIfInfo ( **/
EFI_STATUS
Ip6ConfigParseDhcpReply (
- IN EFI_DHCP6_PROTOCOL *Dhcp6,
- IN OUT IP6_CONFIG_INSTANCE *Instance,
- IN EFI_DHCP6_PACKET *Reply
+ IN EFI_DHCP6_PROTOCOL *Dhcp6,
+ IN OUT IP6_CONFIG_INSTANCE *Instance,
+ IN EFI_DHCP6_PACKET *Reply
)
{
EFI_STATUS Status;
@@ -1669,7 +1661,7 @@ Ip6ConfigParseDhcpReply ( //
// Validate the DnsServers: whether they are unicast addresses.
//
- DnsServer = (EFI_IPv6_ADDRESS *) OptList[Index]->Data;
+ DnsServer = (EFI_IPv6_ADDRESS *)OptList[Index]->Data;
for (Index2 = 0; Index2 < Length / sizeof (EFI_IPv6_ADDRESS); Index2++) {
if (!NetIp6IsValidUnicast (DnsServer)) {
Status = EFI_NOT_READY;
@@ -1728,7 +1720,7 @@ Ip6ConfigSetStatefulAddrCallback ( {
IP6_CONFIG_INSTANCE *Instance;
- Instance = (IP6_CONFIG_INSTANCE *) Context;
+ Instance = (IP6_CONFIG_INSTANCE *)Context;
NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
//
@@ -1769,6 +1761,7 @@ Ip6ConfigSetStatefulAddrCallback ( if (Instance->DeclineAddress != NULL) {
FreePool (Instance->DeclineAddress);
}
+
Instance->DeclineAddress = NULL;
Instance->DeclineAddressCount = 0;
}
@@ -1788,25 +1781,25 @@ Ip6ConfigOnDhcp6Event ( IN VOID *Context
)
{
- IP6_CONFIG_INSTANCE *Instance;
- EFI_DHCP6_PROTOCOL *Dhcp6;
- EFI_STATUS Status;
- EFI_DHCP6_MODE_DATA Dhcp6ModeData;
- EFI_DHCP6_IA *Ia;
- EFI_DHCP6_IA_ADDRESS *IaAddr;
- UINT32 Index;
- IP6_SERVICE *IpSb;
- IP6_ADDRESS_INFO *AddrInfo;
- IP6_INTERFACE *IpIf;
+ IP6_CONFIG_INSTANCE *Instance;
+ EFI_DHCP6_PROTOCOL *Dhcp6;
+ EFI_STATUS Status;
+ EFI_DHCP6_MODE_DATA Dhcp6ModeData;
+ EFI_DHCP6_IA *Ia;
+ EFI_DHCP6_IA_ADDRESS *IaAddr;
+ UINT32 Index;
+ IP6_SERVICE *IpSb;
+ IP6_ADDRESS_INFO *AddrInfo;
+ IP6_INTERFACE *IpIf;
- Instance = (IP6_CONFIG_INSTANCE *) Context;
+ Instance = (IP6_CONFIG_INSTANCE *)Context;
if ((Instance->Policy != Ip6ConfigPolicyAutomatic) || Instance->OtherInfoOnly) {
//
// IPv6 is not operating in the automatic policy now or
// the DHCPv6 information request message exchange is aborted.
//
- return ;
+ return;
}
//
@@ -1816,7 +1809,7 @@ Ip6ConfigOnDhcp6Event ( Status = Dhcp6->GetModeData (Dhcp6, &Dhcp6ModeData, NULL);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance);
@@ -1828,16 +1821,16 @@ Ip6ConfigOnDhcp6Event ( FreePool (Instance->DeclineAddress);
}
- Instance->DeclineAddress = (EFI_IPv6_ADDRESS *) AllocatePool (Ia->IaAddressCount * sizeof (EFI_IPv6_ADDRESS));
+ Instance->DeclineAddress = (EFI_IPv6_ADDRESS *)AllocatePool (Ia->IaAddressCount * sizeof (EFI_IPv6_ADDRESS));
if (Instance->DeclineAddress == NULL) {
goto ON_EXIT;
}
Instance->FailedIaAddressCount = Ia->IaAddressCount;
- Instance->DeclineAddressCount = 0;
+ Instance->DeclineAddressCount = 0;
for (Index = 0; Index < Ia->IaAddressCount; Index++, IaAddr++) {
- if (Ia->IaAddress[Index].ValidLifetime != 0 && Ia->State == Dhcp6Bound) {
+ if ((Ia->IaAddress[Index].ValidLifetime != 0) && (Ia->State == Dhcp6Bound)) {
//
// Set this address, either it's a new address or with updated lifetimes.
// An appropriate prefix length will be set.
@@ -1908,7 +1901,7 @@ Ip6ConfigOnDhcp6Reply ( IN EFI_DHCP6_PACKET *Packet
)
{
- return Ip6ConfigParseDhcpReply (This, (IP6_CONFIG_INSTANCE *) Context, Packet);
+ return Ip6ConfigParseDhcpReply (This, (IP6_CONFIG_INSTANCE *)Context, Packet);
}
/**
@@ -1928,13 +1921,13 @@ Ip6ConfigOnDhcp6SbInstalled ( {
IP6_CONFIG_INSTANCE *Instance;
- Instance = (IP6_CONFIG_INSTANCE *) Context;
+ Instance = (IP6_CONFIG_INSTANCE *)Context;
if ((Instance->Dhcp6Handle != NULL) || (Instance->Policy != Ip6ConfigPolicyAutomatic)) {
//
// The DHCP6 child is already created or the policy is no longer AUTOMATIC.
//
- return ;
+ return;
}
Ip6ConfigStartStatefulAutoConfig (Instance, Instance->OtherInfoOnly);
@@ -1990,10 +1983,10 @@ Ip6ConfigOnDhcp6SbInstalled ( EFI_STATUS
EFIAPI
EfiIp6ConfigSetData (
- IN EFI_IP6_CONFIG_PROTOCOL *This,
- IN EFI_IP6_CONFIG_DATA_TYPE DataType,
- IN UINTN DataSize,
- IN VOID *Data
+ IN EFI_IP6_CONFIG_PROTOCOL *This,
+ IN EFI_IP6_CONFIG_DATA_TYPE DataType,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
EFI_TPL OldTpl;
@@ -2001,7 +1994,7 @@ EfiIp6ConfigSetData ( IP6_CONFIG_INSTANCE *Instance;
IP6_SERVICE *IpSb;
- if ((This == NULL) || (Data == NULL && DataSize != 0) || (Data != NULL && DataSize == 0)) {
+ if ((This == NULL) || ((Data == NULL) && (DataSize != 0)) || ((Data != NULL) && (DataSize == 0))) {
return EFI_INVALID_PARAMETER;
}
@@ -2021,14 +2014,12 @@ EfiIp6ConfigSetData ( Status = Instance->DataItem[DataType].Status;
if (Status != EFI_NOT_READY) {
-
if (Instance->DataItem[DataType].SetData == NULL) {
//
// This type of data is readonly.
//
Status = EFI_WRITE_PROTECTED;
} else {
-
Status = Instance->DataItem[DataType].SetData (Instance, DataSize, Data);
if (!EFI_ERROR (Status)) {
//
@@ -2098,10 +2089,10 @@ EfiIp6ConfigSetData ( EFI_STATUS
EFIAPI
EfiIp6ConfigGetData (
- IN EFI_IP6_CONFIG_PROTOCOL *This,
- IN EFI_IP6_CONFIG_DATA_TYPE DataType,
- IN OUT UINTN *DataSize,
- IN VOID *Data OPTIONAL
+ IN EFI_IP6_CONFIG_PROTOCOL *This,
+ IN EFI_IP6_CONFIG_DATA_TYPE DataType,
+ IN OUT UINTN *DataSize,
+ IN VOID *Data OPTIONAL
)
{
EFI_TPL OldTpl;
@@ -2122,11 +2113,9 @@ EfiIp6ConfigGetData ( Instance = IP6_CONFIG_INSTANCE_FROM_PROTOCOL (This);
DataItem = &Instance->DataItem[DataType];
- Status = Instance->DataItem[DataType].Status;
+ Status = Instance->DataItem[DataType].Status;
if (!EFI_ERROR (Status)) {
-
if (DataItem->GetData != NULL) {
-
Status = DataItem->GetData (Instance, DataSize, Data);
} else if (*DataSize < Instance->DataItem[DataType].DataSize) {
//
@@ -2135,7 +2124,6 @@ EfiIp6ConfigGetData ( *DataSize = Instance->DataItem[DataType].DataSize;
Status = EFI_BUFFER_TOO_SMALL;
} else {
-
*DataSize = Instance->DataItem[DataType].DataSize;
CopyMem (Data, Instance->DataItem[DataType].Data.Ptr, *DataSize);
}
@@ -2171,9 +2159,9 @@ EfiIp6ConfigGetData ( EFI_STATUS
EFIAPI
EfiIp6ConfigRegisterDataNotify (
- IN EFI_IP6_CONFIG_PROTOCOL *This,
- IN EFI_IP6_CONFIG_DATA_TYPE DataType,
- IN EFI_EVENT Event
+ IN EFI_IP6_CONFIG_PROTOCOL *This,
+ IN EFI_IP6_CONFIG_DATA_TYPE DataType,
+ IN EFI_EVENT Event
)
{
EFI_TPL OldTpl;
@@ -2190,26 +2178,22 @@ EfiIp6ConfigRegisterDataNotify ( return EFI_UNSUPPORTED;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- Instance = IP6_CONFIG_INSTANCE_FROM_PROTOCOL (This);
- EventMap = &Instance->DataItem[DataType].EventMap;
+ Instance = IP6_CONFIG_INSTANCE_FROM_PROTOCOL (This);
+ EventMap = &Instance->DataItem[DataType].EventMap;
//
// Check whether this event is already registered for this DataType.
//
Item = NetMapFindKey (EventMap, Event);
if (Item == NULL) {
-
Status = NetMapInsertTail (EventMap, Event, NULL);
if (EFI_ERROR (Status)) {
-
Status = EFI_OUT_OF_RESOURCES;
}
-
} else {
-
Status = EFI_ACCESS_DENIED;
}
@@ -2236,9 +2220,9 @@ EfiIp6ConfigRegisterDataNotify ( EFI_STATUS
EFIAPI
EfiIp6ConfigUnregisterDataNotify (
- IN EFI_IP6_CONFIG_PROTOCOL *This,
- IN EFI_IP6_CONFIG_DATA_TYPE DataType,
- IN EFI_EVENT Event
+ IN EFI_IP6_CONFIG_PROTOCOL *This,
+ IN EFI_IP6_CONFIG_DATA_TYPE DataType,
+ IN EFI_EVENT Event
)
{
EFI_TPL OldTpl;
@@ -2260,11 +2244,9 @@ EfiIp6ConfigUnregisterDataNotify ( Item = NetMapFindKey (&Instance->DataItem[DataType].EventMap, Event);
if (Item != NULL) {
-
NetMapRemoveItem (&Instance->DataItem[DataType].EventMap, Item, NULL);
Status = EFI_SUCCESS;
} else {
-
Status = EFI_NOT_FOUND;
}
@@ -2357,24 +2339,24 @@ Ip6ConfigInitInstance ( Instance->Policy = Ip6ConfigPolicyManual;
SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED);
- DataItem = &Instance->DataItem[Ip6ConfigDataTypeDupAddrDetectTransmits];
- DataItem->SetData = Ip6ConfigSetDadXmits;
- DataItem->Data.Ptr = &Instance->DadXmits;
- DataItem->DataSize = sizeof (Instance->DadXmits);
+ DataItem = &Instance->DataItem[Ip6ConfigDataTypeDupAddrDetectTransmits];
+ DataItem->SetData = Ip6ConfigSetDadXmits;
+ DataItem->Data.Ptr = &Instance->DadXmits;
+ DataItem->DataSize = sizeof (Instance->DadXmits);
Instance->DadXmits.DupAddrDetectTransmits = IP6_CONFIG_DEFAULT_DAD_XMITS;
SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED);
- DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
- DataItem->SetData = Ip6ConfigSetManualAddress;
- DataItem->Status = EFI_NOT_FOUND;
+ DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress];
+ DataItem->SetData = Ip6ConfigSetManualAddress;
+ DataItem->Status = EFI_NOT_FOUND;
- DataItem = &Instance->DataItem[Ip6ConfigDataTypeGateway];
- DataItem->SetData = Ip6ConfigSetGateway;
- DataItem->Status = EFI_NOT_FOUND;
+ DataItem = &Instance->DataItem[Ip6ConfigDataTypeGateway];
+ DataItem->SetData = Ip6ConfigSetGateway;
+ DataItem->Status = EFI_NOT_FOUND;
- DataItem = &Instance->DataItem[Ip6ConfigDataTypeDnsServer];
- DataItem->SetData = Ip6ConfigSetDnsServer;
- DataItem->Status = EFI_NOT_FOUND;
+ DataItem = &Instance->DataItem[Ip6ConfigDataTypeDnsServer];
+ DataItem->SetData = Ip6ConfigSetDnsServer;
+ DataItem->Status = EFI_NOT_FOUND;
//
// Create the event used for DHCP.
@@ -2388,7 +2370,7 @@ Ip6ConfigInitInstance ( );
ASSERT_EFI_ERROR (Status);
- Instance->Configured = TRUE;
+ Instance->Configured = TRUE;
//
// Try to read the config data from NV variable.
@@ -2415,7 +2397,6 @@ Ip6ConfigInitInstance ( Instance->Ip6Config.RegisterDataNotify = EfiIp6ConfigRegisterDataNotify;
Instance->Ip6Config.UnregisterDataNotify = EfiIp6ConfigUnregisterDataNotify;
-
//
// Publish the IP6 configuration form
//
@@ -2441,11 +2422,10 @@ Ip6ConfigCleanInstance ( }
if (!Instance->Configured) {
- return ;
+ return;
}
if (Instance->Dhcp6Handle != NULL) {
-
Ip6ConfigDestroyDhcp6 (Instance);
}
@@ -2460,13 +2440,13 @@ Ip6ConfigCleanInstance ( NetMapClean (&Instance->DadFailedMap);
for (Index = 0; Index < Ip6ConfigDataTypeMaximum; Index++) {
-
DataItem = &Instance->DataItem[Index];
if (!DATA_ATTRIB_SET (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED)) {
if (DataItem->Data.Ptr != NULL) {
FreePool (DataItem->Data.Ptr);
}
+
DataItem->Data.Ptr = NULL;
DataItem->DataSize = 0;
}
@@ -2493,9 +2473,9 @@ Ip6ConfigDestroyDhcp6 ( IN OUT IP6_CONFIG_INSTANCE *Instance
)
{
- IP6_SERVICE *IpSb;
- EFI_STATUS Status;
- EFI_DHCP6_PROTOCOL *Dhcp6;
+ IP6_SERVICE *IpSb;
+ EFI_STATUS Status;
+ EFI_DHCP6_PROTOCOL *Dhcp6;
Dhcp6 = Instance->Dhcp6;
ASSERT (Dhcp6 != NULL);
@@ -2530,4 +2510,3 @@ Ip6ConfigDestroyDhcp6 ( return Status;
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h index 1c2eede..66b730a 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h @@ -10,17 +10,17 @@ #ifndef __IP6_CONFIG_IMPL_H__
#define __IP6_CONFIG_IMPL_H__
-#define IP6_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'C')
-#define IP6_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'F', 'C', 'I')
-#define IP6_CONFIG_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
+#define IP6_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'C')
+#define IP6_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'F', 'C', 'I')
+#define IP6_CONFIG_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
-#define IP6_CONFIG_DEFAULT_DAD_XMITS 1
+#define IP6_CONFIG_DEFAULT_DAD_XMITS 1
-#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 DATA_ATTRIB_SET(Attrib, Bits) (BOOLEAN)((Attrib) & (Bits))
+#define SET_DATA_ATTRIB(Attrib, Bits) ((Attrib) |= (Bits))
typedef struct _IP6_CONFIG_INSTANCE IP6_CONFIG_INSTANCE;
@@ -31,7 +31,6 @@ typedef struct _IP6_CONFIG_INSTANCE IP6_CONFIG_INSTANCE; IP6_CONFIG_INSTANCE_SIGNATURE \
)
-
#define IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK(Callback) \
CR ((Callback), \
IP6_CONFIG_INSTANCE, \
@@ -99,30 +98,30 @@ EFI_STATUS );
typedef union {
- VOID *Ptr;
- EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
- EFI_IP6_CONFIG_INTERFACE_ID *AltIfId;
- EFI_IP6_CONFIG_POLICY *Policy;
- EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS *DadXmits;
- EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
- EFI_IPv6_ADDRESS *Gateway;
- EFI_IPv6_ADDRESS *DnsServers;
+ VOID *Ptr;
+ EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
+ EFI_IP6_CONFIG_INTERFACE_ID *AltIfId;
+ EFI_IP6_CONFIG_POLICY *Policy;
+ EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS *DadXmits;
+ EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
+ EFI_IPv6_ADDRESS *Gateway;
+ EFI_IPv6_ADDRESS *DnsServers;
} IP6_CONFIG_DATA;
typedef struct {
- IP6_CONFIG_SET_DATA SetData;
- IP6_CONFIG_GET_DATA GetData;
- EFI_STATUS Status;
- UINT8 Attribute;
- NET_MAP EventMap;
- IP6_CONFIG_DATA Data;
- UINTN DataSize;
+ IP6_CONFIG_SET_DATA SetData;
+ IP6_CONFIG_GET_DATA GetData;
+ EFI_STATUS Status;
+ UINT8 Attribute;
+ NET_MAP EventMap;
+ IP6_CONFIG_DATA Data;
+ UINTN DataSize;
} IP6_CONFIG_DATA_ITEM;
typedef struct {
- UINT16 Offset;
- UINT32 DataSize;
- EFI_IP6_CONFIG_DATA_TYPE DataType;
+ UINT16 Offset;
+ UINT32 DataSize;
+ EFI_IP6_CONFIG_DATA_TYPE DataType;
} IP6_CONFIG_DATA_RECORD;
#pragma pack(1)
@@ -142,69 +141,69 @@ typedef struct { // EFI_IPv6_ADDRESS DnsServers[];
//
typedef struct {
- UINT32 IaId;
- UINT16 Checksum;
- UINT16 DataRecordCount;
- IP6_CONFIG_DATA_RECORD DataRecord[1];
+ UINT32 IaId;
+ UINT16 Checksum;
+ UINT16 DataRecordCount;
+ IP6_CONFIG_DATA_RECORD DataRecord[1];
} IP6_CONFIG_VARIABLE;
#pragma pack()
typedef struct {
- LIST_ENTRY Link;
- EFI_IP6_ADDRESS_INFO AddrInfo;
+ LIST_ENTRY Link;
+ EFI_IP6_ADDRESS_INFO AddrInfo;
} IP6_ADDRESS_INFO_ENTRY;
typedef struct {
- EFI_IP6_CONFIG_POLICY Policy; ///< manual or automatic
- EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadTransmitCount; ///< dad transmits count
- EFI_IP6_CONFIG_INTERFACE_ID InterfaceId; ///< alternative interface id
- LIST_ENTRY ManualAddress; ///< IP addresses
- UINT32 ManualAddressCount; ///< IP addresses count
- LIST_ENTRY GatewayAddress; ///< Gateway address
- UINT32 GatewayAddressCount; ///< Gateway address count
- LIST_ENTRY DnsAddress; ///< DNS server address
- UINT32 DnsAddressCount; ///< DNS server address count
+ EFI_IP6_CONFIG_POLICY Policy; ///< manual or automatic
+ EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadTransmitCount; ///< dad transmits count
+ EFI_IP6_CONFIG_INTERFACE_ID InterfaceId; ///< alternative interface id
+ LIST_ENTRY ManualAddress; ///< IP addresses
+ UINT32 ManualAddressCount; ///< IP addresses count
+ LIST_ENTRY GatewayAddress; ///< Gateway address
+ UINT32 GatewayAddressCount; ///< Gateway address count
+ LIST_ENTRY DnsAddress; ///< DNS server address
+ UINT32 DnsAddressCount; ///< DNS server address count
} IP6_CONFIG_NVDATA;
typedef struct _IP6_FORM_CALLBACK_INFO {
- UINT32 Signature;
- EFI_HANDLE ChildHandle;
- EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccess;
- EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
- EFI_HII_HANDLE RegisteredHandle;
+ UINT32 Signature;
+ EFI_HANDLE ChildHandle;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccess;
+ EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
+ EFI_HII_HANDLE RegisteredHandle;
} IP6_FORM_CALLBACK_INFO;
struct _IP6_CONFIG_INSTANCE {
- UINT32 Signature;
- BOOLEAN Configured;
- LIST_ENTRY Link;
- UINT16 IfIndex;
-
- EFI_IP6_CONFIG_INTERFACE_INFO InterfaceInfo;
- EFI_IP6_CONFIG_INTERFACE_ID AltIfId;
- EFI_IP6_CONFIG_POLICY Policy;
- EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
-
- IP6_CONFIG_DATA_ITEM DataItem[Ip6ConfigDataTypeMaximum];
- NET_MAP DadFailedMap;
- NET_MAP DadPassedMap;
-
- EFI_IP6_CONFIG_PROTOCOL Ip6Config;
-
- EFI_EVENT Dhcp6SbNotifyEvent;
- VOID *Registration;
- EFI_HANDLE Dhcp6Handle;
- EFI_DHCP6_PROTOCOL *Dhcp6;
- BOOLEAN OtherInfoOnly;
- UINT32 IaId;
- EFI_EVENT Dhcp6Event;
- UINT32 FailedIaAddressCount;
- EFI_IPv6_ADDRESS *DeclineAddress;
- UINT32 DeclineAddressCount;
-
- IP6_FORM_CALLBACK_INFO CallbackInfo;
- IP6_CONFIG_NVDATA Ip6NvData;
+ UINT32 Signature;
+ BOOLEAN Configured;
+ LIST_ENTRY Link;
+ UINT16 IfIndex;
+
+ EFI_IP6_CONFIG_INTERFACE_INFO InterfaceInfo;
+ EFI_IP6_CONFIG_INTERFACE_ID AltIfId;
+ EFI_IP6_CONFIG_POLICY Policy;
+ EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
+
+ IP6_CONFIG_DATA_ITEM DataItem[Ip6ConfigDataTypeMaximum];
+ NET_MAP DadFailedMap;
+ NET_MAP DadPassedMap;
+
+ EFI_IP6_CONFIG_PROTOCOL Ip6Config;
+
+ EFI_EVENT Dhcp6SbNotifyEvent;
+ VOID *Registration;
+ EFI_HANDLE Dhcp6Handle;
+ EFI_DHCP6_PROTOCOL *Dhcp6;
+ BOOLEAN OtherInfoOnly;
+ UINT32 IaId;
+ EFI_EVENT Dhcp6Event;
+ UINT32 FailedIaAddressCount;
+ EFI_IPv6_ADDRESS *DeclineAddress;
+ UINT32 DeclineAddressCount;
+
+ IP6_FORM_CALLBACK_INFO CallbackInfo;
+ IP6_CONFIG_NVDATA Ip6NvData;
};
/**
diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c b/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c index a0727d2..1ed4039 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c @@ -9,7 +9,7 @@ #include "Ip6Impl.h"
-CHAR16 mIp6ConfigStorageName[] = L"IP6_CONFIG_IFR_NVDATA";
+CHAR16 mIp6ConfigStorageName[] = L"IP6_CONFIG_IFR_NVDATA";
/**
The notify function of create event when performing a manual configuration.
@@ -21,11 +21,11 @@ CHAR16 mIp6ConfigStorageName[] = L"IP6_CONFIG_IFR_NVDATA"; VOID
EFIAPI
Ip6ConfigManualAddressNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- *((BOOLEAN *) Context) = TRUE;
+ *((BOOLEAN *)Context) = TRUE;
}
/**
@@ -52,27 +52,27 @@ Ip6ConfigManualAddressNotify ( **/
EFI_STATUS
Ip6ConfigNvGetData (
- IN EFI_IP6_CONFIG_PROTOCOL *Ip6Config,
- IN EFI_IP6_CONFIG_DATA_TYPE DataType,
- OUT UINTN *DataSize,
- OUT VOID **Data
+ IN EFI_IP6_CONFIG_PROTOCOL *Ip6Config,
+ IN EFI_IP6_CONFIG_DATA_TYPE DataType,
+ OUT UINTN *DataSize,
+ OUT VOID **Data
)
{
- UINTN BufferSize;
- VOID *Buffer;
- EFI_STATUS Status;
+ UINTN BufferSize;
+ VOID *Buffer;
+ EFI_STATUS Status;
if ((Ip6Config == NULL) || (Data == NULL) || (DataSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
BufferSize = 0;
- Status = Ip6Config->GetData (
- Ip6Config,
- DataType,
- &BufferSize,
- NULL
- );
+ Status = Ip6Config->GetData (
+ Ip6Config,
+ DataType,
+ &BufferSize,
+ NULL
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
return Status;
}
@@ -108,12 +108,12 @@ Ip6ConfigNvGetData ( **/
VOID
Ip6FreeAddressInfoList (
- IN LIST_ENTRY *ListHead
+ IN LIST_ENTRY *ListHead
)
{
- IP6_ADDRESS_INFO_ENTRY *Node;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
+ IP6_ADDRESS_INFO_ENTRY *Node;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *NextEntry;
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, ListHead) {
Node = NET_LIST_USER_STRUCT (Entry, IP6_ADDRESS_INFO_ENTRY, Link);
@@ -135,19 +135,20 @@ Ip6ToStr ( OUT CHAR16 *Str
)
{
- UINTN Index;
- BOOLEAN Short;
- UINTN Number;
- CHAR16 FormatString[8];
+ UINTN Index;
+ BOOLEAN Short;
+ UINTN Number;
+ CHAR16 FormatString[8];
Short = FALSE;
for (Index = 0; Index < 15; Index = Index + 2) {
if (!Short &&
- Index % 2 == 0 &&
- Ip6->Addr[Index] == 0 &&
- Ip6->Addr[Index + 1] == 0
- ) {
+ (Index % 2 == 0) &&
+ (Ip6->Addr[Index] == 0) &&
+ (Ip6->Addr[Index + 1] == 0)
+ )
+ {
//
// Deal with the case of ::.
//
@@ -156,8 +157,8 @@ Ip6ToStr ( *(Str + 1) = L':';
Str = Str + 2;
} else {
- *Str = L':';
- Str = Str + 1;
+ *Str = L':';
+ Str = Str + 1;
}
while ((Index < 15) && (Ip6->Addr[Index] == 0) && (Ip6->Addr[Index + 1] == 0)) {
@@ -178,7 +179,7 @@ Ip6ToStr ( ASSERT (Index < 15);
if (Ip6->Addr[Index] == 0) {
- Number = UnicodeSPrint (Str, 2 * IP6_STR_MAX_SIZE, L"%x:", (UINTN) Ip6->Addr[Index + 1]);
+ Number = UnicodeSPrint (Str, 2 * IP6_STR_MAX_SIZE, L"%x:", (UINTN)Ip6->Addr[Index + 1]);
} else {
if (Ip6->Addr[Index + 1] < 0x10) {
CopyMem (FormatString, L"%x0%x:", StrSize (L"%x0%x:"));
@@ -189,9 +190,9 @@ Ip6ToStr ( Number = UnicodeSPrint (
Str,
2 * IP6_STR_MAX_SIZE,
- (CONST CHAR16 *) FormatString,
- (UINTN) Ip6->Addr[Index],
- (UINTN) Ip6->Addr[Index + 1]
+ (CONST CHAR16 *)FormatString,
+ (UINTN)Ip6->Addr[Index],
+ (UINTN)Ip6->Addr[Index + 1]
);
}
@@ -218,12 +219,12 @@ Ip6ToStr ( **/
EFI_STATUS
Ip6ConvertInterfaceIdToString (
- OUT CHAR16 *String,
- IN EFI_IP6_CONFIG_INTERFACE_ID *IfId
+ OUT CHAR16 *String,
+ IN EFI_IP6_CONFIG_INTERFACE_ID *IfId
)
{
- UINT8 Index;
- UINTN Number;
+ UINT8 Index;
+ UINTN Number;
if ((String == NULL) || (IfId == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -234,7 +235,7 @@ Ip6ConvertInterfaceIdToString ( String,
2 * INTERFACE_ID_STR_STORAGE,
L"%x:",
- (UINTN) IfId->Id[Index]
+ (UINTN)IfId->Id[Index]
);
String = String + Number;
}
@@ -256,20 +257,20 @@ Ip6ConvertInterfaceIdToString ( **/
EFI_STATUS
Ip6ParseInterfaceIdFromString (
- IN CONST CHAR16 *String,
- OUT EFI_IP6_CONFIG_INTERFACE_ID *IfId
+ IN CONST CHAR16 *String,
+ OUT EFI_IP6_CONFIG_INTERFACE_ID *IfId
)
{
- UINT8 Index;
- CHAR16 *IfIdStr;
- CHAR16 *TempStr;
- UINTN NodeVal;
+ UINT8 Index;
+ CHAR16 *IfIdStr;
+ CHAR16 *TempStr;
+ UINTN NodeVal;
if ((String == NULL) || (IfId == NULL)) {
return EFI_INVALID_PARAMETER;
}
- IfIdStr = (CHAR16 *) String;
+ IfIdStr = (CHAR16 *)String;
ZeroMem (IfId, sizeof (EFI_IP6_CONFIG_INTERFACE_ID));
@@ -297,7 +298,7 @@ Ip6ParseInterfaceIdFromString ( return EFI_INVALID_PARAMETER;
}
- IfId->Id[Index] = (UINT8) NodeVal;
+ IfId->Id[Index] = (UINT8)NodeVal;
IfIdStr++;
}
@@ -323,18 +324,18 @@ Ip6ParseInterfaceIdFromString ( **/
EFI_STATUS
Ip6CreateOpCode (
- IN UINT16 StartLabelNumber,
- OUT VOID **StartOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **StartLabel,
- OUT VOID **EndOpCodeHandle,
- OUT EFI_IFR_GUID_LABEL **EndLabel
+ IN UINT16 StartLabelNumber,
+ OUT VOID **StartOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **StartLabel,
+ OUT VOID **EndOpCodeHandle,
+ OUT EFI_IFR_GUID_LABEL **EndLabel
)
{
- EFI_STATUS Status;
- EFI_IFR_GUID_LABEL *InternalStartLabel;
- EFI_IFR_GUID_LABEL *InternalEndLabel;
+ EFI_STATUS Status;
+ EFI_IFR_GUID_LABEL *InternalStartLabel;
+ EFI_IFR_GUID_LABEL *InternalEndLabel;
- if (StartOpCodeHandle == NULL || StartLabel == NULL || EndOpCodeHandle == NULL || EndLabel == NULL) {
+ if ((StartOpCodeHandle == NULL) || (StartLabel == NULL) || (EndOpCodeHandle == NULL) || (EndLabel == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -358,12 +359,12 @@ Ip6CreateOpCode ( //
// Create Hii Extend Label OpCode as the start opcode.
//
- InternalStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- *StartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ InternalStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ *StartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
if (InternalStartLabel == NULL) {
goto Exit;
}
@@ -374,12 +375,12 @@ Ip6CreateOpCode ( //
// Create Hii Extend Label OpCode as the end opcode.
//
- InternalEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- *EndOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ InternalEndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ *EndOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
if (InternalEndLabel == NULL) {
goto Exit;
}
@@ -429,26 +430,26 @@ Exit: **/
EFI_STATUS
Ip6ConvertAddressListToString (
- IN OUT CHAR16 *String,
- IN EFI_HII_HANDLE HiiHandle,
- IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType,
- IN VOID *AddressInfo,
- IN UINTN AddressCount
+ IN OUT CHAR16 *String,
+ IN EFI_HII_HANDLE HiiHandle,
+ IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType,
+ IN VOID *AddressInfo,
+ IN UINTN AddressCount
)
{
- UINTN Index;
- UINTN Number;
- CHAR16 *TempStr;
- EFI_STATUS Status;
- VOID *StartOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *EndLabel;
- UINT16 StartLabelNumber;
- EFI_STRING_ID TextTwo;
- UINT8 *AddressHead;
- UINT8 PrefixLength;
- EFI_IPv6_ADDRESS *Address;
+ UINTN Index;
+ UINTN Number;
+ CHAR16 *TempStr;
+ EFI_STATUS Status;
+ VOID *StartOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ UINT16 StartLabelNumber;
+ EFI_STRING_ID TextTwo;
+ UINT8 *AddressHead;
+ UINT8 PrefixLength;
+ EFI_IPv6_ADDRESS *Address;
if ((String == NULL) || (HiiHandle == NULL) || (AddressInfo == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -478,15 +479,15 @@ Ip6ConvertAddressListToString ( return Status;
}
- AddressHead = (UINT8 *) AddressInfo;
+ AddressHead = (UINT8 *)AddressInfo;
for (Index = 0; Index < AddressCount; Index++) {
if (AddressType == Ip6ConfigNvHostAddress) {
AddressInfo = AddressHead + sizeof (EFI_IP6_ADDRESS_INFO) * Index;
- Address = &((EFI_IP6_ADDRESS_INFO *) AddressInfo)->Address;
+ Address = &((EFI_IP6_ADDRESS_INFO *)AddressInfo)->Address;
} else if (AddressType == Ip6ConfigNvRouteTable) {
AddressInfo = AddressHead + sizeof (EFI_IP6_ROUTE_TABLE) * Index;
- Address = &((EFI_IP6_ROUTE_TABLE *) AddressInfo)->Destination;
+ Address = &((EFI_IP6_ROUTE_TABLE *)AddressInfo)->Destination;
} else {
AddressInfo = AddressHead + sizeof (EFI_IPv6_ADDRESS) * Index;
Address = AddressInfo;
@@ -500,9 +501,9 @@ Ip6ConvertAddressListToString ( if ((AddressType == Ip6ConfigNvHostAddress) || (AddressType == Ip6ConfigNvRouteTable)) {
if (AddressType == Ip6ConfigNvHostAddress) {
- PrefixLength = ((EFI_IP6_ADDRESS_INFO *) AddressInfo)->PrefixLength;
+ PrefixLength = ((EFI_IP6_ADDRESS_INFO *)AddressInfo)->PrefixLength;
} else {
- PrefixLength = ((EFI_IP6_ROUTE_TABLE *) AddressInfo)->PrefixLength;
+ PrefixLength = ((EFI_IP6_ROUTE_TABLE *)AddressInfo)->PrefixLength;
}
//
@@ -518,13 +519,13 @@ Ip6ConvertAddressListToString ( //
// Append " >> " to the string.
//
- Number = UnicodeSPrint (TempStr, 8, L" >> ");
- TempStr = TempStr + Number;
+ Number = UnicodeSPrint (TempStr, 8, L" >> ");
+ TempStr = TempStr + Number;
//
// Append the gateway address to the string.
//
- Ip6ToStr (&((EFI_IP6_ROUTE_TABLE *) AddressInfo)->Gateway, TempStr);
+ Ip6ToStr (&((EFI_IP6_ROUTE_TABLE *)AddressInfo)->Gateway, TempStr);
TempStr = TempStr + StrLen (TempStr);
}
@@ -539,7 +540,7 @@ Ip6ConvertAddressListToString ( HiiCreateTextOpCode (StartOpCodeHandle, STR_NULL, STR_NULL, TextTwo);
- String = TempStr;
+ String = TempStr;
*String = IP6_ADDRESS_DELIMITER;
String++;
}
@@ -576,26 +577,26 @@ Exit: **/
EFI_STATUS
Ip6ParseAddressListFromString (
- IN CONST CHAR16 *String,
- OUT LIST_ENTRY *ListHead,
- OUT UINT32 *AddressCount
+ IN CONST CHAR16 *String,
+ OUT LIST_ENTRY *ListHead,
+ OUT UINT32 *AddressCount
)
{
- EFI_STATUS Status;
- CHAR16 *LocalString;
- CHAR16 *Temp;
- CHAR16 *TempStr;
- EFI_IP6_ADDRESS_INFO AddressInfo;
- IP6_ADDRESS_INFO_ENTRY *Node;
- BOOLEAN Last;
- UINT32 Count;
+ EFI_STATUS Status;
+ CHAR16 *LocalString;
+ CHAR16 *Temp;
+ CHAR16 *TempStr;
+ EFI_IP6_ADDRESS_INFO AddressInfo;
+ IP6_ADDRESS_INFO_ENTRY *Node;
+ BOOLEAN Last;
+ UINT32 Count;
if ((String == NULL) || (ListHead == NULL) || (AddressCount == NULL)) {
return EFI_INVALID_PARAMETER;
}
ZeroMem (&AddressInfo, sizeof (EFI_IP6_ADDRESS_INFO));
- LocalString = (CHAR16 *) AllocateCopyPool (StrSize (String), String);
+ LocalString = (CHAR16 *)AllocateCopyPool (StrSize (String), String);
if (LocalString == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -684,12 +685,12 @@ Ip6ConvertInterfaceInfoToString ( IN OUT IP6_CONFIG_IFR_NVDATA *IfrNvData
)
{
- UINT32 Index;
- UINTN Number;
- CHAR16 *String;
- CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
- CHAR16 FormatString[8];
- EFI_STRING_ID StringId;
+ UINT32 Index;
+ UINTN Number;
+ CHAR16 *String;
+ CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
+ CHAR16 FormatString[8];
+ EFI_STRING_ID StringId;
if ((IfInfo == NULL) || (HiiHandle == NULL) || (IfrNvData == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -739,7 +740,6 @@ Ip6ConvertInterfaceInfoToString ( ASSERT (IfInfo->HwAddressSize <= 32);
for (Index = 0; Index < IfInfo->HwAddressSize; Index++) {
-
if (IfInfo->HwAddress.Addr[Index] < 0x10) {
CopyMem (FormatString, L"0%x-", sizeof (L"0%x-"));
} else {
@@ -749,8 +749,8 @@ Ip6ConvertInterfaceInfoToString ( Number = UnicodeSPrint (
String,
8,
- (CONST CHAR16 *) FormatString,
- (UINTN) IfInfo->HwAddress.Addr[Index]
+ (CONST CHAR16 *)FormatString,
+ (UINTN)IfInfo->HwAddress.Addr[Index]
);
String = String + Number;
}
@@ -792,21 +792,21 @@ Ip6ConvertInterfaceInfoToString ( **/
EFI_STATUS
Ip6BuildNvAddressInfo (
- IN IP6_CONFIG_INSTANCE *Instance,
- IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType,
- OUT VOID **AddressInfo,
- OUT UINTN *AddressSize
+ IN IP6_CONFIG_INSTANCE *Instance,
+ IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType,
+ OUT VOID **AddressInfo,
+ OUT UINTN *AddressSize
)
{
- IP6_CONFIG_NVDATA *Ip6NvData;
- LIST_ENTRY *Entry;
- LIST_ENTRY *ListHead;
- IP6_ADDRESS_INFO_ENTRY *Node;
- VOID *AddressList;
- VOID *TmpStr;
- UINTN DataSize;
- EFI_IPv6_ADDRESS *Ip6Address;
- EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
+ IP6_CONFIG_NVDATA *Ip6NvData;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *ListHead;
+ IP6_ADDRESS_INFO_ENTRY *Node;
+ VOID *AddressList;
+ VOID *TmpStr;
+ UINTN DataSize;
+ EFI_IPv6_ADDRESS *Ip6Address;
+ EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
if ((Instance == NULL) || (AddressInfo == NULL) || (AddressSize == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -839,14 +839,14 @@ Ip6BuildNvAddressInfo ( NET_LIST_FOR_EACH (Entry, ListHead) {
Node = NET_LIST_USER_STRUCT (Entry, IP6_ADDRESS_INFO_ENTRY, Link);
if (AddressType == Ip6ConfigNvHostAddress) {
- ManualAddress = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) AddressList;
+ ManualAddress = (EFI_IP6_CONFIG_MANUAL_ADDRESS *)AddressList;
IP6_COPY_ADDRESS (&ManualAddress->Address, &Node->AddrInfo.Address);
ManualAddress->PrefixLength = Node->AddrInfo.PrefixLength;
- AddressList = (UINT8 *) AddressList + sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS);
+ AddressList = (UINT8 *)AddressList + sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS);
} else {
- Ip6Address = (EFI_IPv6_ADDRESS *) AddressList;
+ Ip6Address = (EFI_IPv6_ADDRESS *)AddressList;
IP6_COPY_ADDRESS (Ip6Address, &Node->AddrInfo.Address);
- AddressList = (UINT8 *) AddressList + sizeof (EFI_IPv6_ADDRESS);
+ AddressList = (UINT8 *)AddressList + sizeof (EFI_IPv6_ADDRESS);
}
}
@@ -869,18 +869,18 @@ Ip6BuildNvAddressInfo ( **/
EFI_STATUS
Ip6ConvertConfigNvDataToIfrNvData (
- IN OUT IP6_CONFIG_IFR_NVDATA *IfrNvData,
- IN IP6_CONFIG_INSTANCE *Instance
+ IN OUT IP6_CONFIG_IFR_NVDATA *IfrNvData,
+ IN IP6_CONFIG_INSTANCE *Instance
)
{
- IP6_CONFIG_NVDATA *Ip6NvData;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
- UINTN DataSize;
- VOID *Data;
- EFI_STATUS Status;
- EFI_IP6_CONFIG_POLICY Policy;
- EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
- EFI_HII_HANDLE HiiHandle;
+ IP6_CONFIG_NVDATA *Ip6NvData;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ UINTN DataSize;
+ VOID *Data;
+ EFI_STATUS Status;
+ EFI_IP6_CONFIG_POLICY Policy;
+ EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;
+ EFI_HII_HANDLE HiiHandle;
if ((IfrNvData == NULL) || (Instance == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -901,7 +901,7 @@ Ip6ConvertConfigNvDataToIfrNvData ( Ip6Config,
Ip6ConfigDataTypeInterfaceInfo,
&DataSize,
- (VOID **) &Data
+ (VOID **)&Data
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -911,7 +911,7 @@ Ip6ConvertConfigNvDataToIfrNvData ( // Convert the interface info to string and print.
//
Status = Ip6ConvertInterfaceInfoToString (
- (EFI_IP6_CONFIG_INTERFACE_INFO *) Data,
+ (EFI_IP6_CONFIG_INTERFACE_INFO *)Data,
HiiHandle,
IfrNvData
);
@@ -980,7 +980,7 @@ Ip6ConvertConfigNvDataToIfrNvData ( Exit:
if (Data != NULL) {
- FreePool (Data);
+ FreePool (Data);
}
return Status;
@@ -1000,13 +1000,13 @@ Exit: **/
EFI_STATUS
Ip6ConvertIfrNvDataToConfigNvDataGeneral (
- IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
- IN OUT IP6_CONFIG_INSTANCE *Instance
+ IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
+ IN OUT IP6_CONFIG_INSTANCE *Instance
)
{
- IP6_CONFIG_NVDATA *Ip6NvData;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
- EFI_STATUS Status;
+ IP6_CONFIG_NVDATA *Ip6NvData;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ EFI_STATUS Status;
if ((IfrNvData == NULL) || (Instance == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -1083,19 +1083,19 @@ Ip6ConvertIfrNvDataToConfigNvDataGeneral ( **/
EFI_STATUS
Ip6ConvertIfrNvDataToConfigNvDataAdvanced (
- IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
- IN OUT IP6_CONFIG_INSTANCE *Instance
+ IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
+ IN OUT IP6_CONFIG_INSTANCE *Instance
)
{
- IP6_CONFIG_NVDATA *Ip6NvData;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
- EFI_STATUS Status;
- EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
- EFI_IPv6_ADDRESS *Address;
- BOOLEAN IsAddressOk;
- EFI_EVENT SetAddressEvent;
- EFI_EVENT TimeoutEvent;
- UINTN DataSize;
+ IP6_CONFIG_NVDATA *Ip6NvData;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ EFI_STATUS Status;
+ EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
+ EFI_IPv6_ADDRESS *Address;
+ BOOLEAN IsAddressOk;
+ EFI_EVENT SetAddressEvent;
+ EFI_EVENT TimeoutEvent;
+ UINTN DataSize;
if ((IfrNvData == NULL) || (Instance == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -1164,7 +1164,7 @@ Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( Status = Ip6BuildNvAddressInfo (
Instance,
Ip6ConfigNvHostAddress,
- (VOID **) &ManualAddress,
+ (VOID **)&ManualAddress,
&DataSize
);
if (EFI_ERROR (Status)) {
@@ -1186,7 +1186,7 @@ Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( Ip6Config,
Ip6ConfigDataTypeManualAddress,
DataSize,
- (VOID *) ManualAddress
+ (VOID *)ManualAddress
);
if (Status == EFI_NOT_READY) {
gBS->SetTimer (TimeoutEvent, TimerRelative, 50000000);
@@ -1194,6 +1194,7 @@ Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( if (IsAddressOk) {
Status = EFI_SUCCESS;
}
+
break;
}
}
@@ -1215,7 +1216,7 @@ Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( Status = Ip6BuildNvAddressInfo (
Instance,
Ip6ConfigNvGatewayAddress,
- (VOID **) &Address,
+ (VOID **)&Address,
&DataSize
);
if (EFI_ERROR (Status)) {
@@ -1226,7 +1227,7 @@ Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( Ip6Config,
Ip6ConfigDataTypeGateway,
DataSize,
- (VOID *) Address
+ (VOID *)Address
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -1243,7 +1244,7 @@ Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( Status = Ip6BuildNvAddressInfo (
Instance,
Ip6ConfigNvDnsAddress,
- (VOID **) &Address,
+ (VOID **)&Address,
&DataSize
);
if (EFI_ERROR (Status)) {
@@ -1254,7 +1255,7 @@ Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( Ip6Config,
Ip6ConfigDataTypeDnsServer,
DataSize,
- (VOID *) Address
+ (VOID *)Address
);
if (EFI_ERROR (Status)) {
goto Exit;
@@ -1283,7 +1284,6 @@ Exit: return Status;
}
-
/**
This function allows the caller to request the current
configuration for one or more named elements. The resulting
@@ -1349,30 +1349,30 @@ Exit: EFI_STATUS
EFIAPI
Ip6FormExtractConfig (
- 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;
+ IP6_FORM_CALLBACK_INFO *Private;
+ IP6_CONFIG_INSTANCE *Ip6ConfigInstance;
+ IP6_CONFIG_IFR_NVDATA *IfrNvData;
+ EFI_STRING ConfigRequestHdr;
+ EFI_STRING ConfigRequest;
+ BOOLEAN AllocatedRequest;
+ UINTN Size;
+ UINTN BufferSize;
- EFI_STATUS Status;
- IP6_FORM_CALLBACK_INFO *Private;
- IP6_CONFIG_INSTANCE *Ip6ConfigInstance;
- IP6_CONFIG_IFR_NVDATA *IfrNvData;
- EFI_STRING ConfigRequestHdr;
- EFI_STRING ConfigRequest;
- BOOLEAN AllocatedRequest;
- UINTN Size;
- UINTN BufferSize;
-
- if (This == NULL || Progress == NULL || Results == NULL) {
+ if ((This == NULL) || (Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
*Progress = Request;
if ((Request != NULL) &&
- !HiiIsConfigHdrMatch (Request, &gIp6ConfigNvDataGuid, mIp6ConfigStorageName)) {
+ !HiiIsConfigHdrMatch (Request, &gIp6ConfigNvDataGuid, mIp6ConfigStorageName))
+ {
return EFI_NOT_FOUND;
}
@@ -1381,11 +1381,11 @@ Ip6FormExtractConfig ( AllocatedRequest = FALSE;
Size = 0;
- Private = IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
+ Private = IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
Ip6ConfigInstance = IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private);
- BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
+ BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
- IfrNvData = (IP6_CONFIG_IFR_NVDATA *) AllocateZeroPool (BufferSize);
+ IfrNvData = (IP6_CONFIG_IFR_NVDATA *)AllocateZeroPool (BufferSize);
if (IfrNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1407,7 +1407,7 @@ Ip6FormExtractConfig ( mIp6ConfigStorageName,
Private->ChildHandle
);
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
@@ -1416,7 +1416,7 @@ Ip6FormExtractConfig ( Size,
L"%s&OFFSET=0&WIDTH=%016LX",
ConfigRequestHdr,
- (UINT64) BufferSize
+ (UINT64)BufferSize
);
FreePool (ConfigRequestHdr);
}
@@ -1427,7 +1427,7 @@ Ip6FormExtractConfig ( Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
ConfigRequest,
- (UINT8 *) IfrNvData,
+ (UINT8 *)IfrNvData,
BufferSize,
Results,
Progress
@@ -1442,6 +1442,7 @@ Exit: FreePool (ConfigRequest);
ConfigRequest = NULL;
}
+
//
// Set Progress string to the original request string.
//
@@ -1490,12 +1491,12 @@ Exit: EFI_STATUS
EFIAPI
Ip6FormRouteConfig (
- 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
)
{
- if (This == NULL || Configuration == NULL || Progress == NULL) {
+ if ((This == NULL) || (Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1525,17 +1526,16 @@ Ip6FormRouteConfig ( **/
EFI_STATUS
Ip6GetCurrentSetting (
- IN IP6_CONFIG_INSTANCE *Instance
+ IN IP6_CONFIG_INSTANCE *Instance
)
{
- EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
- EFI_HII_HANDLE HiiHandle;
- EFI_IP6_CONFIG_INTERFACE_INFO *Data;
- UINTN DataSize;
- EFI_STATUS Status;
- CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
- EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
-
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_IP6_CONFIG_INTERFACE_INFO *Data;
+ UINTN DataSize;
+ EFI_STATUS Status;
+ CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
+ EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
Ip6Config = &Instance->Ip6Config;
HiiHandle = Instance->CallbackInfo.RegisteredHandle;
@@ -1548,7 +1548,7 @@ Ip6GetCurrentSetting ( Ip6Config,
Ip6ConfigDataTypeInterfaceInfo,
&DataSize,
- (VOID **) &Data
+ (VOID **)&Data
);
if (EFI_ERROR (Status)) {
return Status;
@@ -1557,7 +1557,7 @@ Ip6GetCurrentSetting ( //
// Generate dynamic text opcode for host address and draw it.
//
- IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data;
+ IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *)Data;
Status = Ip6ConvertAddressListToString (
PortString,
HiiHandle,
@@ -1590,17 +1590,18 @@ Ip6GetCurrentSetting ( //
FreePool (Data);
DataSize = 0;
- Data = NULL;
- Status = Ip6ConfigNvGetData (
- Ip6Config,
- Ip6ConfigDataTypeDnsServer,
- &DataSize,
- (VOID **) &Data
- );
+ Data = NULL;
+ Status = Ip6ConfigNvGetData (
+ Ip6Config,
+ Ip6ConfigDataTypeDnsServer,
+ &DataSize,
+ (VOID **)&Data
+ );
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
if (Data != NULL) {
FreePool (Data);
}
+
return Status;
}
@@ -1629,17 +1630,18 @@ Ip6GetCurrentSetting ( }
DataSize = 0;
- Data = NULL;
- Status = Ip6ConfigNvGetData (
- Ip6Config,
- Ip6ConfigDataTypeGateway,
- &DataSize,
- (VOID **) &Data
- );
+ Data = NULL;
+ Status = Ip6ConfigNvGetData (
+ Ip6Config,
+ Ip6ConfigDataTypeGateway,
+ &DataSize,
+ (VOID **)&Data
+ );
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
if (Data != NULL) {
FreePool (Data);
}
+
return Status;
}
@@ -1697,21 +1699,21 @@ Ip6GetCurrentSetting ( EFI_STATUS
EFIAPI
Ip6FormCallback (
- 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
)
{
- IP6_FORM_CALLBACK_INFO *Private;
- UINTN BufferSize;
- IP6_CONFIG_IFR_NVDATA *IfrNvData;
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- IP6_CONFIG_INSTANCE *Instance;
- IP6_CONFIG_NVDATA *Ip6NvData;
+ IP6_FORM_CALLBACK_INFO *Private;
+ UINTN BufferSize;
+ IP6_CONFIG_IFR_NVDATA *IfrNvData;
+ EFI_STATUS Status;
+ EFI_INPUT_KEY Key;
+ IP6_CONFIG_INSTANCE *Instance;
+ IP6_CONFIG_NVDATA *Ip6NvData;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1721,11 +1723,11 @@ Ip6FormCallback ( Instance = IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private);
Ip6NvData = &Instance->Ip6NvData;
- if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)){
+ if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {
return EFI_SUCCESS;
}
- if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {
+ if ((Action != EFI_BROWSER_ACTION_CHANGING) && (Action != EFI_BROWSER_ACTION_CHANGED)) {
return EFI_UNSUPPORTED;
}
@@ -1738,123 +1740,124 @@ Ip6FormCallback ( //
BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
- IfrNvData = AllocateZeroPool (BufferSize);
+ IfrNvData = AllocateZeroPool (BufferSize);
if (IfrNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_SUCCESS;
- HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);
+ HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *)IfrNvData);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (QuestionId) {
- case KEY_GET_CURRENT_SETTING:
- Status = Ip6GetCurrentSetting (Instance);
- break;
+ case KEY_GET_CURRENT_SETTING:
+ Status = Ip6GetCurrentSetting (Instance);
+ break;
- default:
- break;
+ default:
+ break;
}
} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
switch (QuestionId) {
- case KEY_SAVE_CONFIG_CHANGES:
- Status = Ip6ConvertIfrNvDataToConfigNvDataAdvanced (IfrNvData, Instance);
- if (EFI_ERROR (Status)) {
- break;
- }
+ case KEY_SAVE_CONFIG_CHANGES:
+ Status = Ip6ConvertIfrNvDataToConfigNvDataAdvanced (IfrNvData, Instance);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
- Status = Ip6GetCurrentSetting (Instance);
+ Status = Ip6GetCurrentSetting (Instance);
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
- break;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
+ break;
- case KEY_IGNORE_CONFIG_CHANGES:
- Ip6FreeAddressInfoList (&Ip6NvData->ManualAddress);
- Ip6FreeAddressInfoList (&Ip6NvData->GatewayAddress);
- Ip6FreeAddressInfoList (&Ip6NvData->DnsAddress);
+ case KEY_IGNORE_CONFIG_CHANGES:
+ Ip6FreeAddressInfoList (&Ip6NvData->ManualAddress);
+ Ip6FreeAddressInfoList (&Ip6NvData->GatewayAddress);
+ Ip6FreeAddressInfoList (&Ip6NvData->DnsAddress);
- Ip6NvData->ManualAddressCount = 0;
- Ip6NvData->GatewayAddressCount = 0;
- Ip6NvData->DnsAddressCount = 0;
+ Ip6NvData->ManualAddressCount = 0;
+ Ip6NvData->GatewayAddressCount = 0;
+ Ip6NvData->DnsAddressCount = 0;
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
- break;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
+ break;
+
+ case KEY_SAVE_CHANGES:
+ Status = Ip6ConvertIfrNvDataToConfigNvDataGeneral (IfrNvData, Instance);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
- case KEY_SAVE_CHANGES:
- Status = Ip6ConvertIfrNvDataToConfigNvDataGeneral (IfrNvData, Instance);
- if (EFI_ERROR (Status)) {
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
break;
- }
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
- break;
- case KEY_INTERFACE_ID:
- Status = Ip6ParseInterfaceIdFromString (IfrNvData->InterfaceId, &Ip6NvData->InterfaceId);
- if (EFI_ERROR (Status)) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Invalid Interface ID!",
- NULL
- );
- }
+ case KEY_INTERFACE_ID:
+ Status = Ip6ParseInterfaceIdFromString (IfrNvData->InterfaceId, &Ip6NvData->InterfaceId);
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Interface ID!",
+ NULL
+ );
+ }
- break;
+ break;
- case KEY_MANUAL_ADDRESS:
- Status = Ip6ParseAddressListFromString (
- IfrNvData->ManualAddress,
- &Ip6NvData->ManualAddress,
- &Ip6NvData->ManualAddressCount
- );
- if (EFI_ERROR (Status)) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Invalid Host Addresses!",
- NULL
- );
- }
+ case KEY_MANUAL_ADDRESS:
+ Status = Ip6ParseAddressListFromString (
+ IfrNvData->ManualAddress,
+ &Ip6NvData->ManualAddress,
+ &Ip6NvData->ManualAddressCount
+ );
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Host Addresses!",
+ NULL
+ );
+ }
- break;
+ break;
- case KEY_GATEWAY_ADDRESS:
- Status = Ip6ParseAddressListFromString (
- IfrNvData->GatewayAddress,
- &Ip6NvData->GatewayAddress,
- &Ip6NvData->GatewayAddressCount
- );
- if (EFI_ERROR (Status)) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Invalid Gateway Addresses!",
- NULL
- );
- }
+ case KEY_GATEWAY_ADDRESS:
+ Status = Ip6ParseAddressListFromString (
+ IfrNvData->GatewayAddress,
+ &Ip6NvData->GatewayAddress,
+ &Ip6NvData->GatewayAddressCount
+ );
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid Gateway Addresses!",
+ NULL
+ );
+ }
- break;
+ break;
- case KEY_DNS_ADDRESS:
- Status = Ip6ParseAddressListFromString (
- IfrNvData->DnsAddress,
- &Ip6NvData->DnsAddress,
- &Ip6NvData->DnsAddressCount
- );
- if (EFI_ERROR (Status)) {
- CreatePopUp (
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
- &Key,
- L"Invalid DNS Addresses!",
- NULL
- );
- }
+ case KEY_DNS_ADDRESS:
+ Status = Ip6ParseAddressListFromString (
+ IfrNvData->DnsAddress,
+ &Ip6NvData->DnsAddress,
+ &Ip6NvData->DnsAddressCount
+ );
+ if (EFI_ERROR (Status)) {
+ CreatePopUp (
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
+ &Key,
+ L"Invalid DNS Addresses!",
+ NULL
+ );
+ }
- break;
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -1863,7 +1866,7 @@ Ip6FormCallback ( // Pass changed uncommitted data back to Form Browser.
//
BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
- HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData, NULL);
+ HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8 *)IfrNvData, NULL);
}
FreePool (IfrNvData);
@@ -1882,20 +1885,20 @@ Ip6FormCallback ( **/
EFI_STATUS
Ip6ConfigFormInit (
- IN OUT IP6_CONFIG_INSTANCE *Instance
+ IN OUT IP6_CONFIG_INSTANCE *Instance
)
{
- EFI_STATUS Status;
- IP6_SERVICE *IpSb;
- IP6_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;
+ IP6_SERVICE *IpSb;
+ IP6_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 = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance);
ASSERT (IpSb != NULL);
@@ -1903,13 +1906,13 @@ Ip6ConfigFormInit ( Status = gBS->HandleProtocol (
IpSb->Controller,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath
+ (VOID **)&ParentDevicePath
);
if (EFI_ERROR (Status)) {
return Status;
}
- CallbackInfo = &Instance->CallbackInfo;
+ CallbackInfo = &Instance->CallbackInfo;
CallbackInfo->Signature = IP6_FORM_CALLBACK_INFO_SIGNATURE;
//
@@ -1926,7 +1929,7 @@ Ip6ConfigFormInit ( 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;
@@ -1956,7 +1959,7 @@ Ip6ConfigFormInit ( Status = gBS->OpenProtocol (
IpSb->Controller,
&gEfiManagedNetworkServiceBindingProtocolGuid,
- (VOID **) &MnpSb,
+ (VOID **)&MnpSb,
IpSb->Image,
CallbackInfo->ChildHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -1990,8 +1993,9 @@ Ip6ConfigFormInit ( OldMenuString = HiiGetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP),
- NULL)
- ;
+ NULL
+ )
+ ;
UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
@@ -2030,12 +2034,12 @@ Error: **/
VOID
Ip6ConfigFormUnload (
- IN OUT IP6_CONFIG_INSTANCE *Instance
+ IN OUT IP6_CONFIG_INSTANCE *Instance
)
{
- IP6_SERVICE *IpSb;
- IP6_FORM_CALLBACK_INFO *CallbackInfo;
- IP6_CONFIG_NVDATA *Ip6NvData;
+ IP6_SERVICE *IpSb;
+ IP6_FORM_CALLBACK_INFO *CallbackInfo;
+ IP6_CONFIG_NVDATA *Ip6NvData;
IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance);
ASSERT (IpSb != NULL);
@@ -2043,7 +2047,6 @@ Ip6ConfigFormUnload ( CallbackInfo = &Instance->CallbackInfo;
if (CallbackInfo->ChildHandle != NULL) {
-
//
// Close the child handle
//
diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigNv.h b/NetworkPkg/Ip6Dxe/Ip6ConfigNv.h index d484027..063bc8e 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigNv.h +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigNv.h @@ -16,10 +16,10 @@ extern UINT8 Ip6ConfigBin[];
extern UINT8 Ip6DxeStrings[];
-#define IP6_ETHERNET L"Ethernet"
-#define IP6_EXPERIMENTAL_ETHERNET L"Experimental Ethernet"
-#define IP6_ADDRESS_DELIMITER L' '
-#define IP6_LINK_LOCAL_PREFIX L"FE80::"
+#define IP6_ETHERNET L"Ethernet"
+#define IP6_EXPERIMENTAL_ETHERNET L"Experimental Ethernet"
+#define IP6_ADDRESS_DELIMITER L' '
+#define IP6_LINK_LOCAL_PREFIX L"FE80::"
typedef enum {
Ip6InterfaceTypeEthernet = 1,
@@ -45,7 +45,7 @@ typedef enum { **/
EFI_STATUS
Ip6ConfigFormInit (
- IN OUT IP6_CONFIG_INSTANCE *Instance
+ IN OUT IP6_CONFIG_INSTANCE *Instance
);
/**
@@ -56,7 +56,7 @@ Ip6ConfigFormInit ( **/
VOID
Ip6ConfigFormUnload (
- IN OUT IP6_CONFIG_INSTANCE *Instance
+ IN OUT IP6_CONFIG_INSTANCE *Instance
);
#endif
diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c index 80ce5b5..b483a7d 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Driver.c +++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c @@ -10,7 +10,7 @@ #include "Ip6Impl.h"
-EFI_DRIVER_BINDING_PROTOCOL gIp6DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gIp6DriverBinding = {
Ip6DriverBindingSupported,
Ip6DriverBindingStart,
Ip6DriverBindingStop,
@@ -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
Ip6DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- VOID *Registration;
+ VOID *Registration;
EfiCreateProtocolNotifyEvent (
&gEfiIpSec2ProtocolGuid,
@@ -142,14 +143,14 @@ Ip6DriverBindingSupported ( **/
EFI_STATUS
Ip6CleanService (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- EFI_STATUS Status;
- EFI_IPv6_ADDRESS AllNodes;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
+ EFI_STATUS Status;
+ EFI_IPv6_ADDRESS AllNodes;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
- IpSb->State = IP6_SERVICE_DESTROY;
+ IpSb->State = IP6_SERVICE_DESTROY;
if (IpSb->Timer != NULL) {
gBS->SetTimer (IpSb->Timer, TimerCancel, 0);
@@ -207,11 +208,11 @@ Ip6CleanService ( IpSb->Mnp->Cancel (IpSb->Mnp, NULL);
IpSb->Mnp->Configure (IpSb->Mnp, NULL);
gBS->CloseProtocol (
- IpSb->MnpChildHandle,
- &gEfiManagedNetworkProtocolGuid,
- IpSb->Image,
- IpSb->Controller
- );
+ IpSb->MnpChildHandle,
+ &gEfiManagedNetworkProtocolGuid,
+ IpSb->Image,
+ IpSb->Controller
+ );
IpSb->Mnp = NULL;
}
@@ -256,9 +257,9 @@ Ip6CleanService ( **/
EFI_STATUS
Ip6CreateService (
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE ImageHandle,
- OUT IP6_SERVICE **Service
+ IN EFI_HANDLE Controller,
+ IN EFI_HANDLE ImageHandle,
+ OUT IP6_SERVICE **Service
)
{
IP6_SERVICE *IpSb;
@@ -286,60 +287,60 @@ Ip6CreateService ( IpSb->ServiceBinding.DestroyChild = Ip6ServiceBindingDestroyChild;
IpSb->State = IP6_SERVICE_UNSTARTED;
- IpSb->NumChildren = 0;
+ IpSb->NumChildren = 0;
InitializeListHead (&IpSb->Children);
InitializeListHead (&IpSb->Interfaces);
- IpSb->DefaultInterface = NULL;
- IpSb->RouteTable = NULL;
+ IpSb->DefaultInterface = NULL;
+ IpSb->RouteTable = NULL;
- IpSb->RecvRequest.Signature = IP6_LINK_RX_SIGNATURE;
- IpSb->RecvRequest.CallBack = NULL;
- IpSb->RecvRequest.Context = NULL;
- MnpToken = &IpSb->RecvRequest.MnpToken;
- MnpToken->Event = NULL;
- MnpToken->Status = EFI_NOT_READY;
- MnpToken->Packet.RxData = NULL;
+ IpSb->RecvRequest.Signature = IP6_LINK_RX_SIGNATURE;
+ IpSb->RecvRequest.CallBack = NULL;
+ IpSb->RecvRequest.Context = NULL;
+ MnpToken = &IpSb->RecvRequest.MnpToken;
+ MnpToken->Event = NULL;
+ MnpToken->Status = EFI_NOT_READY;
+ MnpToken->Packet.RxData = NULL;
Ip6CreateAssembleTable (&IpSb->Assemble);
- IpSb->MldCtrl.Mldv1QuerySeen = 0;
+ IpSb->MldCtrl.Mldv1QuerySeen = 0;
InitializeListHead (&IpSb->MldCtrl.Groups);
ZeroMem (&IpSb->LinkLocalAddr, sizeof (EFI_IPv6_ADDRESS));
- IpSb->LinkLocalOk = FALSE;
- IpSb->LinkLocalDadFail = FALSE;
- IpSb->Dhcp6NeedStart = FALSE;
- IpSb->Dhcp6NeedInfoRequest = FALSE;
-
- IpSb->CurHopLimit = IP6_HOP_LIMIT;
- IpSb->LinkMTU = IP6_MIN_LINK_MTU;
- IpSb->BaseReachableTime = IP6_REACHABLE_TIME;
+ IpSb->LinkLocalOk = FALSE;
+ IpSb->LinkLocalDadFail = FALSE;
+ IpSb->Dhcp6NeedStart = FALSE;
+ IpSb->Dhcp6NeedInfoRequest = FALSE;
+
+ IpSb->CurHopLimit = IP6_HOP_LIMIT;
+ IpSb->LinkMTU = IP6_MIN_LINK_MTU;
+ IpSb->BaseReachableTime = IP6_REACHABLE_TIME;
Ip6UpdateReachableTime (IpSb);
//
// RFC4861 RETRANS_TIMER: 1,000 milliseconds
//
- IpSb->RetransTimer = IP6_RETRANS_TIMER;
+ IpSb->RetransTimer = IP6_RETRANS_TIMER;
- IpSb->RoundRobin = 0;
+ IpSb->RoundRobin = 0;
InitializeListHead (&IpSb->NeighborTable);
InitializeListHead (&IpSb->DefaultRouterList);
InitializeListHead (&IpSb->OnlinkPrefix);
InitializeListHead (&IpSb->AutonomousPrefix);
- IpSb->InterfaceIdLen = IP6_IF_ID_LEN;
- IpSb->InterfaceId = NULL;
+ IpSb->InterfaceIdLen = IP6_IF_ID_LEN;
+ IpSb->InterfaceId = NULL;
- IpSb->RouterAdvertiseReceived = FALSE;
- IpSb->SolicitTimer = IP6_MAX_RTR_SOLICITATIONS;
- IpSb->Ticks = 0;
+ IpSb->RouterAdvertiseReceived = FALSE;
+ IpSb->SolicitTimer = IP6_MAX_RTR_SOLICITATIONS;
+ IpSb->Ticks = 0;
- IpSb->Image = ImageHandle;
- IpSb->Controller = Controller;
+ IpSb->Image = ImageHandle;
+ IpSb->Controller = Controller;
- IpSb->MnpChildHandle = NULL;
- IpSb->Mnp = NULL;
+ IpSb->MnpChildHandle = NULL;
+ IpSb->Mnp = NULL;
Config = &IpSb->MnpConfigData;
Config->ReceivedQueueTimeoutValue = 0;
@@ -355,12 +356,12 @@ Ip6CreateService ( ZeroMem (&IpSb->SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE));
- IpSb->Timer = NULL;
- IpSb->FasterTimer = NULL;
+ IpSb->Timer = NULL;
+ IpSb->FasterTimer = NULL;
ZeroMem (&IpSb->Ip6ConfigInstance, sizeof (IP6_CONFIG_INSTANCE));
- IpSb->MacString = NULL;
+ IpSb->MacString = NULL;
//
// Create various resources. First create the route table, timer
@@ -408,7 +409,7 @@ Ip6CreateService ( Status = gBS->OpenProtocol (
IpSb->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid,
- (VOID **) (&IpSb->Mnp),
+ (VOID **)(&IpSb->Mnp),
ImageHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -434,6 +435,7 @@ Ip6CreateService ( //
IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN;
}
+
IpSb->OldMaxPacketSize = IpSb->MaxPacketSize;
//
@@ -489,7 +491,6 @@ ON_ERROR: return Status;
}
-
/**
Start this driver on ControllerHandle.
@@ -511,10 +512,10 @@ Ip6DriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
- IP6_SERVICE *IpSb;
- EFI_STATUS Status;
- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
- IP6_CONFIG_DATA_ITEM *DataItem;
+ IP6_SERVICE *IpSb;
+ EFI_STATUS Status;
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
+ IP6_CONFIG_DATA_ITEM *DataItem;
IpSb = NULL;
Ip6Cfg = NULL;
@@ -544,7 +545,7 @@ Ip6DriverBindingStart ( ASSERT (IpSb != NULL);
- Ip6Cfg = &IpSb->Ip6ConfigInstance.Ip6Config;
+ Ip6Cfg = &IpSb->Ip6ConfigInstance.Ip6Config;
//
// Install the Ip6ServiceBinding Protocol onto ControllerHandle
@@ -581,7 +582,7 @@ Ip6DriverBindingStart ( DataItem->DataSize,
DataItem->Data.Ptr
);
- if (Status == EFI_INVALID_PARAMETER || Status == EFI_BAD_BUFFER_SIZE) {
+ if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_BAD_BUFFER_SIZE)) {
//
// Clean the invalid ManualAddress configuration.
//
@@ -606,7 +607,7 @@ Ip6DriverBindingStart ( DataItem->DataSize,
DataItem->Data.Ptr
);
- if (Status == EFI_INVALID_PARAMETER || Status == EFI_BAD_BUFFER_SIZE) {
+ if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_BAD_BUFFER_SIZE)) {
//
// Clean the invalid Gateway configuration.
//
@@ -688,8 +689,8 @@ FREE_SERVICE: EFI_STATUS
EFIAPI
Ip6DestroyChildEntryInHandleBuffer (
- IN LIST_ENTRY *Entry,
- IN VOID *Context
+ IN LIST_ENTRY *Entry,
+ IN VOID *Context
)
{
IP6_PROTOCOL *IpInstance;
@@ -697,14 +698,14 @@ Ip6DestroyChildEntryInHandleBuffer ( 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, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
- ServiceBinding = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
- NumberOfChildren = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
- ChildHandleBuffer = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+ IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);
+ ServiceBinding = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
+ NumberOfChildren = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
+ ChildHandleBuffer = ((IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) {
return EFI_SUCCESS;
@@ -736,14 +737,14 @@ Ip6DriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- IP6_SERVICE *IpSb;
- EFI_HANDLE NicHandle;
- EFI_STATUS Status;
- LIST_ENTRY *List;
- INTN State;
- BOOLEAN IsDhcp6;
- IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ IP6_SERVICE *IpSb;
+ EFI_HANDLE NicHandle;
+ EFI_STATUS Status;
+ LIST_ENTRY *List;
+ INTN State;
+ BOOLEAN IsDhcp6;
+ IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
IsDhcp6 = FALSE;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);
@@ -759,7 +760,7 @@ Ip6DriverBindingStop ( Status = gBS->OpenProtocol (
NicHandle,
&gEfiIp6ServiceBindingProtocolGuid,
- (VOID **) &ServiceBinding,
+ (VOID **)&ServiceBinding,
This->DriverBindingHandle,
NicHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -778,18 +779,18 @@ Ip6DriverBindingStop ( //
// NumberOfChildren is not zero, destroy the IP6 children instances in ChildHandleBuffer.
//
- List = &IpSb->Children;
+ List = &IpSb->Children;
Context.ServiceBinding = ServiceBinding;
Context.NumberOfChildren = NumberOfChildren;
Context.ChildHandleBuffer = ChildHandleBuffer;
- Status = NetDestroyLinkList (
- List,
- Ip6DestroyChildEntryInHandleBuffer,
- &Context,
- NULL
- );
+ Status = NetDestroyLinkList (
+ List,
+ Ip6DestroyChildEntryInHandleBuffer,
+ &Context,
+ NULL
+ );
} else if (IsListEmpty (&IpSb->Children)) {
- State = IpSb->State;
+ State = IpSb->State;
Status = Ip6CleanService (IpSb);
if (EFI_ERROR (Status)) {
IpSb->State = State;
@@ -813,7 +814,6 @@ Exit: return Status;
}
-
/**
Creates a child handle with a set of I/O services.
@@ -836,17 +836,17 @@ Ip6ServiceBindingCreateChild ( IN EFI_HANDLE *ChildHandle
)
{
- IP6_SERVICE *IpSb;
- IP6_PROTOCOL *IpInstance;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- VOID *Mnp;
+ IP6_SERVICE *IpSb;
+ IP6_PROTOCOL *IpInstance;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ VOID *Mnp;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
- IpSb = IP6_SERVICE_FROM_PROTOCOL (This);
+ IpSb = IP6_SERVICE_FROM_PROTOCOL (This);
if (IpSb->LinkLocalDadFail) {
return EFI_DEVICE_ERROR;
@@ -881,7 +881,7 @@ Ip6ServiceBindingCreateChild ( Status = gBS->OpenProtocol (
IpSb->MnpChildHandle,
&gEfiManagedNetworkProtocolGuid,
- (VOID **) &Mnp,
+ (VOID **)&Mnp,
gIp6DriverBinding.DriverBindingHandle,
IpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -910,7 +910,6 @@ Ip6ServiceBindingCreateChild ( ON_ERROR:
if (EFI_ERROR (Status)) {
-
Ip6CleanProtocol (IpInstance);
FreePool (IpInstance);
@@ -942,11 +941,11 @@ Ip6ServiceBindingDestroyChild ( IN EFI_HANDLE ChildHandle
)
{
- EFI_STATUS Status;
- IP6_SERVICE *IpSb;
- IP6_PROTOCOL *IpInstance;
- EFI_IP6_PROTOCOL *Ip6;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ IP6_SERVICE *IpSb;
+ IP6_PROTOCOL *IpInstance;
+ EFI_IP6_PROTOCOL *Ip6;
+ EFI_TPL OldTpl;
if ((This == NULL) || (ChildHandle == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -955,12 +954,12 @@ Ip6ServiceBindingDestroyChild ( //
// Retrieve the private context data structures
//
- IpSb = IP6_SERVICE_FROM_PROTOCOL (This);
+ IpSb = IP6_SERVICE_FROM_PROTOCOL (This);
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiIp6ProtocolGuid,
- (VOID **) &Ip6,
+ (VOID **)&Ip6,
gIp6DriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.h b/NetworkPkg/Ip6Dxe/Ip6Driver.h index 007f687..996dbe4 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Driver.h +++ b/NetworkPkg/Ip6Dxe/Ip6Driver.h @@ -10,16 +10,16 @@ #ifndef __EFI_IP6_DRIVER_H__
#define __EFI_IP6_DRIVER_H__
-extern EFI_DRIVER_BINDING_PROTOCOL gIp6DriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2;
-extern EFI_UNICODE_STRING_TABLE *gIp6ControllerNameTable;
+extern EFI_DRIVER_BINDING_PROTOCOL gIp6DriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gIp6ComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gIp6ComponentName2;
+extern EFI_UNICODE_STRING_TABLE *gIp6ControllerNameTable;
typedef struct {
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
- UINTN NumberOfChildren;
- EFI_HANDLE *ChildHandleBuffer;
-}IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
+ UINTN NumberOfChildren;
+ EFI_HANDLE *ChildHandleBuffer;
+} IP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
/**
Clean up an IP6 service binding instance. It releases all
@@ -36,7 +36,7 @@ typedef struct { **/
EFI_STATUS
Ip6CleanService (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
);
//
@@ -61,8 +61,8 @@ Ip6CleanService ( EFI_STATUS
EFIAPI
Ip6DriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
//
diff --git a/NetworkPkg/Ip6Dxe/Ip6Icmp.c b/NetworkPkg/Ip6Dxe/Ip6Icmp.c index d43121e..a0e4d25 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Icmp.c +++ b/NetworkPkg/Ip6Dxe/Ip6Icmp.c @@ -10,8 +10,7 @@ #include "Ip6Impl.h"
-EFI_IP6_ICMP_TYPE mIp6SupportedIcmp[23] = {
-
+EFI_IP6_ICMP_TYPE mIp6SupportedIcmp[23] = {
{
ICMP_V6_DEST_UNREACHABLE,
ICMP_V6_NO_ROUTE_TO_DEST
@@ -127,15 +126,15 @@ EFI_IP6_ICMP_TYPE mIp6SupportedIcmp[23] = { **/
EFI_STATUS
Ip6IcmpReplyEcho (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD *Icmp;
- NET_BUF *Data;
- EFI_STATUS Status;
- EFI_IP6_HEADER ReplyHead;
+ IP6_ICMP_INFORMATION_HEAD *Icmp;
+ NET_BUF *Data;
+ EFI_STATUS Status;
+ EFI_IP6_HEADER ReplyHead;
Status = EFI_OUT_OF_RESOURCES;
//
@@ -153,7 +152,7 @@ Ip6IcmpReplyEcho ( // use specific destination. See RFC1122. SRR/RR option
// update is omitted.
//
- Icmp = (IP6_ICMP_INFORMATION_HEAD *) NetbufGetByte (Data, 0, NULL);
+ Icmp = (IP6_ICMP_INFORMATION_HEAD *)NetbufGetByte (Data, 0, NULL);
if (Icmp == NULL) {
NetbufFree (Data);
goto Exit;
@@ -169,9 +168,9 @@ Ip6IcmpReplyEcho ( //
ZeroMem (&ReplyHead, sizeof (EFI_IP6_HEADER));
- ReplyHead.PayloadLength = HTONS ((UINT16) (Packet->TotalSize));
- ReplyHead.NextHeader = IP6_ICMP;
- ReplyHead.HopLimit = IpSb->CurHopLimit;
+ ReplyHead.PayloadLength = HTONS ((UINT16)(Packet->TotalSize));
+ ReplyHead.NextHeader = IP6_ICMP;
+ ReplyHead.HopLimit = IpSb->CurHopLimit;
IP6_COPY_ADDRESS (&ReplyHead.DestinationAddress, &Head->SourceAddress);
if (Ip6IsOneOfSetAddress (IpSb, &Head->DestinationAddress, NULL, NULL)) {
@@ -218,17 +217,17 @@ Exit: **/
EFI_STATUS
Ip6ProcessPacketTooBig (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_ERROR_HEAD Icmp;
- UINT32 Mtu;
- IP6_ROUTE_ENTRY *RouteEntry;
- EFI_IPv6_ADDRESS *DestAddress;
+ IP6_ICMP_ERROR_HEAD Icmp;
+ UINT32 Mtu;
+ IP6_ROUTE_ENTRY *RouteEntry;
+ EFI_IPv6_ADDRESS *DestAddress;
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
Mtu = NTOHL (Icmp.Fourth);
DestAddress = &Icmp.IpHead.DestinationAddress;
@@ -280,12 +279,12 @@ Ip6ProcessPacketTooBig ( **/
EFI_STATUS
Ip6ProcessIcmpError (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_ERROR_HEAD Icmp;
+ IP6_ICMP_ERROR_HEAD Icmp;
//
// Check the validity of the packet
@@ -294,7 +293,7 @@ Ip6ProcessIcmpError ( goto DROP;
}
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
if (Icmp.Head.Type == ICMP_V6_PACKET_TOO_BIG) {
return Ip6ProcessPacketTooBig (IpSb, Head, Packet);
}
@@ -329,55 +328,56 @@ DROP: **/
EFI_STATUS
Ip6ProcessIcmpInformation (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD Icmp;
- EFI_STATUS Status;
+ IP6_ICMP_INFORMATION_HEAD Icmp;
+ EFI_STATUS Status;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
NET_CHECK_SIGNATURE (Packet, NET_BUF_SIGNATURE);
ASSERT (Head != NULL);
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
Status = EFI_INVALID_PARAMETER;
switch (Icmp.Head.Type) {
- case ICMP_V6_ECHO_REQUEST:
- //
- // If ICMPv6 echo, reply it
- //
- if (Icmp.Head.Code == 0) {
- Status = Ip6IcmpReplyEcho (IpSb, Head, Packet);
- }
- break;
- case ICMP_V6_LISTENER_QUERY:
- Status = Ip6ProcessMldQuery (IpSb, Head, Packet);
- break;
- case ICMP_V6_LISTENER_REPORT:
- case ICMP_V6_LISTENER_REPORT_2:
- Status = Ip6ProcessMldReport (IpSb, Head, Packet);
- break;
- case ICMP_V6_NEIGHBOR_SOLICIT:
- Status = Ip6ProcessNeighborSolicit (IpSb, Head, Packet);
- break;
- case ICMP_V6_NEIGHBOR_ADVERTISE:
- Status = Ip6ProcessNeighborAdvertise (IpSb, Head, Packet);
- break;
- case ICMP_V6_ROUTER_ADVERTISE:
- Status = Ip6ProcessRouterAdvertise (IpSb, Head, Packet);
- break;
- case ICMP_V6_REDIRECT:
- Status = Ip6ProcessRedirect (IpSb, Head, Packet);
- break;
- case ICMP_V6_ECHO_REPLY:
- Status = Ip6Demultiplex (IpSb, Head, Packet);
- break;
- default:
- Status = EFI_INVALID_PARAMETER;
- break;
+ case ICMP_V6_ECHO_REQUEST:
+ //
+ // If ICMPv6 echo, reply it
+ //
+ if (Icmp.Head.Code == 0) {
+ Status = Ip6IcmpReplyEcho (IpSb, Head, Packet);
+ }
+
+ break;
+ case ICMP_V6_LISTENER_QUERY:
+ Status = Ip6ProcessMldQuery (IpSb, Head, Packet);
+ break;
+ case ICMP_V6_LISTENER_REPORT:
+ case ICMP_V6_LISTENER_REPORT_2:
+ Status = Ip6ProcessMldReport (IpSb, Head, Packet);
+ break;
+ case ICMP_V6_NEIGHBOR_SOLICIT:
+ Status = Ip6ProcessNeighborSolicit (IpSb, Head, Packet);
+ break;
+ case ICMP_V6_NEIGHBOR_ADVERTISE:
+ Status = Ip6ProcessNeighborAdvertise (IpSb, Head, Packet);
+ break;
+ case ICMP_V6_ROUTER_ADVERTISE:
+ Status = Ip6ProcessRouterAdvertise (IpSb, Head, Packet);
+ break;
+ case ICMP_V6_REDIRECT:
+ Status = Ip6ProcessRedirect (IpSb, Head, Packet);
+ break;
+ case ICMP_V6_ECHO_REPLY:
+ Status = Ip6Demultiplex (IpSb, Head, Packet);
+ break;
+ default:
+ Status = EFI_INVALID_PARAMETER;
+ break;
}
return Status;
@@ -400,14 +400,14 @@ Ip6ProcessIcmpInformation ( **/
EFI_STATUS
Ip6IcmpHandle (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_HEAD Icmp;
- UINT16 PseudoCheckSum;
- UINT16 CheckSum;
+ IP6_ICMP_HEAD Icmp;
+ UINT16 PseudoCheckSum;
+ UINT16 CheckSum;
//
// Check the validity of the incoming packet.
@@ -416,7 +416,7 @@ Ip6IcmpHandle ( goto DROP;
}
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
//
// Make sure checksum is valid.
@@ -458,28 +458,28 @@ DROP: **/
VOID
Ip6GetPrefix (
- IN UINT8 PrefixLength,
- IN OUT EFI_IPv6_ADDRESS *Prefix
+ IN UINT8 PrefixLength,
+ IN OUT EFI_IPv6_ADDRESS *Prefix
)
{
- UINT8 Byte;
- UINT8 Bit;
- UINT8 Mask;
- UINT8 Value;
+ UINT8 Byte;
+ UINT8 Bit;
+ UINT8 Mask;
+ UINT8 Value;
ASSERT ((Prefix != NULL) && (PrefixLength < IP6_PREFIX_MAX));
if (PrefixLength == 0) {
ZeroMem (Prefix, sizeof (EFI_IPv6_ADDRESS));
- return ;
+ return;
}
if (PrefixLength >= IP6_PREFIX_MAX) {
- return ;
+ return;
}
- Byte = (UINT8) (PrefixLength / 8);
- Bit = (UINT8) (PrefixLength % 8);
+ Byte = (UINT8)(PrefixLength / 8);
+ Bit = (UINT8)(PrefixLength % 8);
Value = Prefix->Addr[Byte];
if (Byte > 0) {
@@ -487,10 +487,9 @@ Ip6GetPrefix ( }
if (Bit > 0) {
- Mask = (UINT8) (0xFF << (8 - Bit));
- Prefix->Addr[Byte] = (UINT8) (Value & Mask);
+ Mask = (UINT8)(0xFF << (8 - Bit));
+ Prefix->Addr[Byte] = (UINT8)(Value & Mask);
}
-
}
/**
@@ -505,13 +504,13 @@ Ip6GetPrefix ( **/
BOOLEAN
Ip6IsAnycast (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *DestinationAddress
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *DestinationAddress
)
{
- IP6_PREFIX_LIST_ENTRY *PrefixEntry;
- EFI_IPv6_ADDRESS Prefix;
- BOOLEAN Flag;
+ IP6_PREFIX_LIST_ENTRY *PrefixEntry;
+ EFI_IPv6_ADDRESS Prefix;
+ BOOLEAN Flag;
ZeroMem (&Prefix, sizeof (EFI_IPv6_ADDRESS));
@@ -563,21 +562,21 @@ Ip6IsAnycast ( **/
EFI_STATUS
Ip6SendIcmpError (
- IN IP6_SERVICE *IpSb,
- IN NET_BUF *Packet,
- IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
- IN EFI_IPv6_ADDRESS *DestinationAddress,
- IN UINT8 Type,
- IN UINT8 Code,
- IN UINT32 *Pointer OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN NET_BUF *Packet,
+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
+ IN EFI_IPv6_ADDRESS *DestinationAddress,
+ IN UINT8 Type,
+ IN UINT8 Code,
+ IN UINT32 *Pointer OPTIONAL
)
{
- UINT32 PacketLen;
- NET_BUF *ErrorMsg;
- UINT16 PayloadLen;
- EFI_IP6_HEADER Head;
- IP6_ICMP_INFORMATION_HEAD *IcmpHead;
- UINT8 *ErrorBody;
+ UINT32 PacketLen;
+ NET_BUF *ErrorMsg;
+ UINT16 PayloadLen;
+ EFI_IP6_HEADER Head;
+ IP6_ICMP_INFORMATION_HEAD *IcmpHead;
+ UINT8 *ErrorBody;
if (DestinationAddress == NULL) {
return EFI_INVALID_PARAMETER;
@@ -592,24 +591,25 @@ Ip6SendIcmpError ( if (NetIp6IsUnspecifiedAddr (DestinationAddress) ||
IP6_IS_MULTICAST (DestinationAddress) ||
Ip6IsAnycast (IpSb, DestinationAddress)
- ) {
+ )
+ {
return EFI_INVALID_PARAMETER;
}
switch (Type) {
- case ICMP_V6_DEST_UNREACHABLE:
- case ICMP_V6_TIME_EXCEEDED:
- break;
+ case ICMP_V6_DEST_UNREACHABLE:
+ case ICMP_V6_TIME_EXCEEDED:
+ break;
- case ICMP_V6_PARAMETER_PROBLEM:
- if (Pointer == NULL) {
- return EFI_INVALID_PARAMETER;
- }
+ case ICMP_V6_PARAMETER_PROBLEM:
+ if (Pointer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
- break;
+ break;
- default:
- return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_INVALID_PARAMETER;
}
PacketLen = sizeof (IP6_ICMP_ERROR_HEAD) + Packet->TotalSize;
@@ -623,16 +623,16 @@ Ip6SendIcmpError ( return EFI_OUT_OF_RESOURCES;
}
- PayloadLen = (UINT16) (PacketLen - sizeof (EFI_IP6_HEADER));
+ PayloadLen = (UINT16)(PacketLen - sizeof (EFI_IP6_HEADER));
//
// Create the basic IPv6 header.
//
ZeroMem (&Head, sizeof (EFI_IP6_HEADER));
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_ICMP;
- Head.HopLimit = IpSb->CurHopLimit;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_ICMP;
+ Head.HopLimit = IpSb->CurHopLimit;
if (SourceAddress != NULL) {
IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress);
@@ -647,7 +647,7 @@ Ip6SendIcmpError ( //
// Fill in the ICMP error message head
//
- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (ErrorMsg, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (ErrorMsg, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
if (IcmpHead == NULL) {
NetbufFree (ErrorMsg);
return EFI_OUT_OF_RESOURCES;
@@ -665,7 +665,7 @@ Ip6SendIcmpError ( // Fill in the ICMP error message body
//
PayloadLen -= sizeof (IP6_ICMP_INFORMATION_HEAD);
- ErrorBody = NetbufAllocSpace (ErrorMsg, PayloadLen, FALSE);
+ ErrorBody = NetbufAllocSpace (ErrorMsg, PayloadLen, FALSE);
if (ErrorBody != NULL) {
ZeroMem (ErrorBody, PayloadLen);
NetbufCopy (Packet, 0, PayloadLen, ErrorBody);
@@ -676,4 +676,3 @@ Ip6SendIcmpError ( //
return Ip6Output (IpSb, NULL, NULL, ErrorMsg, &Head, NULL, 0, Ip6SysPacketSent, NULL);
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Icmp.h b/NetworkPkg/Ip6Dxe/Ip6Icmp.h index c63adb0..09a06ac 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Icmp.h +++ b/NetworkPkg/Ip6Dxe/Ip6Icmp.h @@ -10,18 +10,17 @@ #ifndef __EFI_IP6_ICMP_H__
#define __EFI_IP6_ICMP_H__
-#define ICMP_V6_DEFAULT_CODE 0
+#define ICMP_V6_DEFAULT_CODE 0
-#define ICMP_V6_ERROR_MAX 127
+#define ICMP_V6_ERROR_MAX 127
//
// ICMPv6 message classes, each class of ICMPv6 message shares
// a common message format. INVALID_MESSAGE is only a flag.
//
-#define ICMP_V6_INVALID_MESSAGE 0
-#define ICMP_V6_ERROR_MESSAGE 1
-#define ICMP_V6_INFORMATION_MESSAGE 2
-
+#define ICMP_V6_INVALID_MESSAGE 0
+#define ICMP_V6_ERROR_MESSAGE 1
+#define ICMP_V6_INFORMATION_MESSAGE 2
extern EFI_IP6_ICMP_TYPE mIp6SupportedIcmp[];
@@ -42,9 +41,9 @@ extern EFI_IP6_ICMP_TYPE mIp6SupportedIcmp[]; **/
EFI_STATUS
Ip6IcmpHandle (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
/**
@@ -59,8 +58,8 @@ Ip6IcmpHandle ( **/
BOOLEAN
Ip6IsAnycast (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *DestinationAddress
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *DestinationAddress
);
/**
@@ -89,14 +88,13 @@ Ip6IsAnycast ( **/
EFI_STATUS
Ip6SendIcmpError (
- IN IP6_SERVICE *IpSb,
- IN NET_BUF *Packet,
- IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
- IN EFI_IPv6_ADDRESS *DestinationAddress,
- IN UINT8 Type,
- IN UINT8 Code,
- IN UINT32 *Pointer OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN NET_BUF *Packet,
+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
+ IN EFI_IPv6_ADDRESS *DestinationAddress,
+ IN UINT8 Type,
+ IN UINT8 Code,
+ IN UINT32 *Pointer OPTIONAL
);
#endif
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6If.c b/NetworkPkg/Ip6Dxe/Ip6If.c index 5b46971..4629c05 100644 --- a/NetworkPkg/Ip6Dxe/Ip6If.c +++ b/NetworkPkg/Ip6Dxe/Ip6If.c @@ -19,8 +19,8 @@ VOID
EFIAPI
Ip6OnFrameSent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -37,11 +37,11 @@ Ip6OnFrameSent ( **/
BOOLEAN
Ip6CancelInstanceFrame (
- IN IP6_LINK_TX_TOKEN *Frame,
- IN VOID *Context
+ IN IP6_LINK_TX_TOKEN *Frame,
+ IN VOID *Context
)
{
- if (Frame->IpInstance == (IP6_PROTOCOL *) Context) {
+ if (Frame->IpInstance == (IP6_PROTOCOL *)Context) {
return TRUE;
}
@@ -73,14 +73,14 @@ Ip6CancelInstanceFrame ( **/
EFI_STATUS
Ip6SetAddress (
- IN IP6_INTERFACE *Interface,
- IN EFI_IPv6_ADDRESS *Ip6Addr,
- IN BOOLEAN IsAnycast,
- IN UINT8 PrefixLength,
- IN UINT32 ValidLifetime,
- IN UINT32 PreferredLifetime,
- IN IP6_DAD_CALLBACK DadCallback OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN EFI_IPv6_ADDRESS *Ip6Addr,
+ IN BOOLEAN IsAnycast,
+ IN UINT8 PrefixLength,
+ IN UINT32 ValidLifetime,
+ IN UINT32 PreferredLifetime,
+ IN IP6_DAD_CALLBACK DadCallback OPTIONAL,
+ IN VOID *Context OPTIONAL
)
{
IP6_SERVICE *IpSb;
@@ -109,12 +109,12 @@ Ip6SetAddress ( return EFI_SUCCESS;
}
- AddressInfo = (IP6_ADDRESS_INFO *) AllocatePool (sizeof (IP6_ADDRESS_INFO));
+ AddressInfo = (IP6_ADDRESS_INFO *)AllocatePool (sizeof (IP6_ADDRESS_INFO));
if (AddressInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- AddressInfo->Signature = IP6_ADDR_INFO_SIGNATURE;
+ AddressInfo->Signature = IP6_ADDR_INFO_SIGNATURE;
IP6_COPY_ADDRESS (&AddressInfo->Address, Ip6Addr);
AddressInfo->IsAnycast = IsAnycast;
AddressInfo->PrefixLength = PrefixLength;
@@ -158,24 +158,23 @@ Ip6SetAddress ( AddressInfo->PrefixLength = IP6_LINK_LOCAL_PREFIX_LENGTH;
}
-
//
// Node should delay joining the solicited-node multicast address by a random delay
// between 0 and MAX_RTR_SOLICITATION_DELAY (1 second).
// Thus queue the address to be processed in Duplicate Address Detection module
// after the delay time (in milliseconds).
//
- Delay = (UINT64) NET_RANDOM (NetRandomInitSeed ());
+ Delay = (UINT64)NET_RANDOM (NetRandomInitSeed ());
Delay = MultU64x32 (Delay, IP6_ONE_SECOND_IN_MS);
Delay = RShiftU64 (Delay, 32);
- DelayNode = (IP6_DELAY_JOIN_LIST *) AllocatePool (sizeof (IP6_DELAY_JOIN_LIST));
+ DelayNode = (IP6_DELAY_JOIN_LIST *)AllocatePool (sizeof (IP6_DELAY_JOIN_LIST));
if (DelayNode == NULL) {
FreePool (AddressInfo);
return EFI_OUT_OF_RESOURCES;
}
- DelayNode->DelayTime = (UINT32) (DivU64x32 (Delay, IP6_TIMER_INTERVAL_IN_MS));
+ DelayNode->DelayTime = (UINT32)(DivU64x32 (Delay, IP6_TIMER_INTERVAL_IN_MS));
DelayNode->Interface = Interface;
DelayNode->AddressInfo = AddressInfo;
DelayNode->DadCallback = DadCallback;
@@ -197,13 +196,13 @@ Ip6SetAddress ( **/
IP6_INTERFACE *
Ip6CreateInterface (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN LinkLocal
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN LinkLocal
)
{
- EFI_STATUS Status;
- IP6_INTERFACE *Interface;
- EFI_IPv6_ADDRESS *Ip6Addr;
+ EFI_STATUS Status;
+ IP6_INTERFACE *Interface;
+ EFI_IPv6_ADDRESS *Ip6Addr;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -212,27 +211,27 @@ Ip6CreateInterface ( return NULL;
}
- Interface->Signature = IP6_INTERFACE_SIGNATURE;
- Interface->RefCnt = 1;
+ Interface->Signature = IP6_INTERFACE_SIGNATURE;
+ Interface->RefCnt = 1;
InitializeListHead (&Interface->AddressList);
- Interface->AddressCount = 0;
- Interface->Configured = FALSE;
+ Interface->AddressCount = 0;
+ Interface->Configured = FALSE;
- Interface->Service = IpSb;
- Interface->Controller = IpSb->Controller;
- Interface->Image = IpSb->Image;
+ Interface->Service = IpSb;
+ Interface->Controller = IpSb->Controller;
+ Interface->Image = IpSb->Image;
InitializeListHead (&Interface->ArpQues);
InitializeListHead (&Interface->SentFrames);
- Interface->DupAddrDetect = IpSb->Ip6ConfigInstance.DadXmits.DupAddrDetectTransmits;
+ Interface->DupAddrDetect = IpSb->Ip6ConfigInstance.DadXmits.DupAddrDetectTransmits;
InitializeListHead (&Interface->DupAddrDetectList);
InitializeListHead (&Interface->DelayJoinList);
InitializeListHead (&Interface->IpInstances);
- Interface->PromiscRecv = FALSE;
+ Interface->PromiscRecv = FALSE;
if (!LinkLocal) {
return Interface;
@@ -254,8 +253,8 @@ Ip6CreateInterface ( Ip6Addr,
FALSE,
IP6_LINK_LOCAL_PREFIX_LENGTH,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
NULL,
NULL
);
@@ -288,12 +287,12 @@ ON_ERROR: **/
VOID
Ip6CleanInterface (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL
)
{
- IP6_DAD_ENTRY *Duplicate;
- IP6_DELAY_JOIN_LIST *Delay;
+ IP6_DAD_ENTRY *Duplicate;
+ IP6_DELAY_JOIN_LIST *Delay;
NET_CHECK_SIGNATURE (Interface, IP6_INTERFACE_SIGNATURE);
ASSERT (Interface->RefCnt > 0);
@@ -352,11 +351,11 @@ Ip6CleanInterface ( **/
IP6_LINK_TX_TOKEN *
Ip6CreateLinkTxToken (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL,
- IN NET_BUF *Packet,
- IN IP6_FRAME_CALLBACK CallBack,
- IN VOID *Context
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL,
+ IN NET_BUF *Packet,
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN VOID *Context
)
{
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
@@ -381,8 +380,8 @@ Ip6CreateLinkTxToken ( ZeroMem (&Token->DstMac, sizeof (EFI_MAC_ADDRESS));
IP6_COPY_LINK_ADDRESS (&Token->SrcMac, &Interface->Service->SnpMode.CurrentAddress);
- MnpToken = &(Token->MnpToken);
- MnpToken->Status = EFI_NOT_READY;
+ MnpToken = &(Token->MnpToken);
+ MnpToken->Status = EFI_NOT_READY;
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
@@ -397,8 +396,8 @@ Ip6CreateLinkTxToken ( return NULL;
}
- MnpTxData = &Token->MnpTxData;
- MnpToken->Packet.TxData = MnpTxData;
+ MnpTxData = &Token->MnpTxData;
+ MnpToken->Packet.TxData = MnpTxData;
MnpTxData->DestinationAddress = &Token->DstMac;
MnpTxData->SourceAddress = &Token->SrcMac;
@@ -406,10 +405,10 @@ Ip6CreateLinkTxToken ( 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;
}
@@ -423,7 +422,7 @@ Ip6CreateLinkTxToken ( **/
VOID
Ip6FreeLinkTxToken (
- IN IP6_LINK_TX_TOKEN *Token
+ IN IP6_LINK_TX_TOKEN *Token
)
{
NET_CHECK_SIGNATURE (Token, IP6_LINK_TX_SIGNATURE);
@@ -442,12 +441,12 @@ Ip6FreeLinkTxToken ( VOID
EFIAPI
Ip6RecycleFrame (
- IN VOID *Context
+ IN VOID *Context
)
{
EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData;
- RxData = (EFI_MANAGED_NETWORK_RECEIVE_DATA *) Context;
+ RxData = (EFI_MANAGED_NETWORK_RECEIVE_DATA *)Context;
gBS->SignalEvent (RxData->RecycleEvent);
}
@@ -466,7 +465,7 @@ Ip6RecycleFrame ( VOID
EFIAPI
Ip6OnFrameReceivedDpc (
- IN VOID *Context
+ IN VOID *Context
)
{
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken;
@@ -477,23 +476,22 @@ Ip6OnFrameReceivedDpc ( UINT32 Flag;
IP6_SERVICE *IpSb;
- Token = (IP6_LINK_RX_TOKEN *) Context;
+ Token = (IP6_LINK_RX_TOKEN *)Context;
NET_CHECK_SIGNATURE (Token, IP6_LINK_RX_SIGNATURE);
//
// First clear the interface's receive request in case the
// caller wants to call Ip6ReceiveFrame in the callback.
//
- IpSb = (IP6_SERVICE *) Token->Context;
+ IpSb = (IP6_SERVICE *)Token->Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
-
MnpToken = &Token->MnpToken;
MnpRxData = MnpToken->Packet.RxData;
if (EFI_ERROR (MnpToken->Status) || (MnpRxData == NULL)) {
Token->CallBack (NULL, MnpToken->Status, 0, Token->Context);
- return ;
+ return;
}
//
@@ -510,7 +508,7 @@ Ip6OnFrameReceivedDpc ( Token->CallBack (NULL, EFI_OUT_OF_RESOURCES, 0, Token->Context);
- return ;
+ return;
}
Flag = (MnpRxData->BroadcastFlag ? IP6_LINK_BROADCAST : 0);
@@ -530,8 +528,8 @@ Ip6OnFrameReceivedDpc ( VOID
EFIAPI
Ip6OnFrameReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -553,18 +551,18 @@ Ip6OnFrameReceived ( **/
EFI_STATUS
Ip6ReceiveFrame (
- IN IP6_FRAME_CALLBACK CallBack,
- IN IP6_SERVICE *IpSb
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN IP6_SERVICE *IpSb
)
{
- EFI_STATUS Status;
- IP6_LINK_RX_TOKEN *Token;
+ EFI_STATUS Status;
+ IP6_LINK_RX_TOKEN *Token;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
Token = &IpSb->RecvRequest;
Token->CallBack = CallBack;
- Token->Context = (VOID *) IpSb;
+ Token->Context = (VOID *)IpSb;
Status = IpSb->Mnp->Receive (IpSb->Mnp, &Token->MnpToken);
if (EFI_ERROR (Status)) {
@@ -584,22 +582,22 @@ Ip6ReceiveFrame ( VOID
EFIAPI
Ip6OnFrameSentDpc (
- IN VOID *Context
+ IN VOID *Context
)
{
- IP6_LINK_TX_TOKEN *Token;
+ IP6_LINK_TX_TOKEN *Token;
- Token = (IP6_LINK_TX_TOKEN *) Context;
+ Token = (IP6_LINK_TX_TOKEN *)Context;
NET_CHECK_SIGNATURE (Token, IP6_LINK_TX_SIGNATURE);
RemoveEntryList (&Token->Link);
Token->CallBack (
- Token->Packet,
- Token->MnpToken.Status,
- 0,
- Token->Context
- );
+ Token->Packet,
+ Token->MnpToken.Status,
+ 0,
+ Token->Context
+ );
Ip6FreeLinkTxToken (Token);
}
@@ -614,8 +612,8 @@ Ip6OnFrameSentDpc ( VOID
EFIAPI
Ip6OnFrameSent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -646,20 +644,20 @@ Ip6OnFrameSent ( **/
EFI_STATUS
Ip6SendFrame (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL,
- IN NET_BUF *Packet,
- IN EFI_IPv6_ADDRESS *NextHop,
- IN IP6_FRAME_CALLBACK CallBack,
- IN VOID *Context
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL,
+ IN NET_BUF *Packet,
+ IN EFI_IPv6_ADDRESS *NextHop,
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN VOID *Context
)
{
- IP6_SERVICE *IpSb;
- IP6_LINK_TX_TOKEN *Token;
- EFI_STATUS Status;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- LIST_ENTRY *Entry;
- IP6_NEIGHBOR_ENTRY *ArpQue;
+ IP6_SERVICE *IpSb;
+ IP6_LINK_TX_TOKEN *Token;
+ EFI_STATUS Status;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ LIST_ENTRY *Entry;
+ IP6_NEIGHBOR_ENTRY *ArpQue;
IpSb = Interface->Service;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -706,21 +704,21 @@ Ip6SendFrame ( }
switch (NeighborCache->State) {
- case EfiNeighborStale:
- NeighborCache->State = EfiNeighborDelay;
- NeighborCache->Ticks = (UINT32) IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
+ case EfiNeighborStale:
+ NeighborCache->State = EfiNeighborDelay;
+ NeighborCache->Ticks = (UINT32)IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
//
// Fall through
//
- case EfiNeighborReachable:
- case EfiNeighborDelay:
- case EfiNeighborProbe:
- IP6_COPY_LINK_ADDRESS (&Token->DstMac, &NeighborCache->LinkAddress);
- goto SendNow;
- break;
-
- default:
- break;
+ case EfiNeighborReachable:
+ case EfiNeighborDelay:
+ case EfiNeighborProbe:
+ IP6_COPY_LINK_ADDRESS (&Token->DstMac, &NeighborCache->LinkAddress);
+ goto SendNow;
+ break;
+
+ default:
+ break;
}
//
@@ -747,7 +745,7 @@ Ip6SendFrame ( return EFI_SUCCESS;
SendNow:
- //
+ //
// Insert the tx token into the SentFrames list before calling Mnp->Transmit.
// Remove it if the returned status is not EFI_SUCCESS.
//
@@ -777,13 +775,13 @@ Error: VOID
EFIAPI
Ip6TimerTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- IP6_SERVICE *IpSb;
+ IP6_SERVICE *IpSb;
- IpSb = (IP6_SERVICE *) Context;
+ IpSb = (IP6_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
Ip6PacketTimerTicking (IpSb);
diff --git a/NetworkPkg/Ip6Dxe/Ip6If.h b/NetworkPkg/Ip6Dxe/Ip6If.h index ab43d8e..1f058e2 100644 --- a/NetworkPkg/Ip6Dxe/Ip6If.h +++ b/NetworkPkg/Ip6Dxe/Ip6If.h @@ -10,10 +10,10 @@ #ifndef __EFI_IP6_IF_H__
#define __EFI_IP6_IF_H__
-#define IP6_LINK_RX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'R')
-#define IP6_LINK_TX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'T')
-#define IP6_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'I')
-#define IP6_ADDR_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', 'A', 'I')
+#define IP6_LINK_RX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'R')
+#define IP6_LINK_TX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'T')
+#define IP6_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'I')
+#define IP6_ADDR_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', 'A', 'I')
//
// This prototype is used by both receive and transmission.
@@ -33,10 +33,10 @@ typedef
VOID
(*IP6_FRAME_CALLBACK) (
- NET_BUF *Packet,
- EFI_STATUS IoStatus,
- UINT32 LinkFlag,
- VOID *Context
+ NET_BUF *Packet,
+ EFI_STATUS IoStatus,
+ UINT32 LinkFlag,
+ VOID *Context
);
//
@@ -46,10 +46,10 @@ VOID // Reference MNP's spec for information.
//
typedef struct {
- UINT32 Signature;
- IP6_FRAME_CALLBACK CallBack;
- VOID *Context;
- EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
+ UINT32 Signature;
+ IP6_FRAME_CALLBACK CallBack;
+ VOID *Context;
+ EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
} IP6_LINK_RX_TOKEN;
//
@@ -57,29 +57,29 @@ typedef struct { // Upon completion, the Callback will be called.
//
typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
+ UINT32 Signature;
+ LIST_ENTRY Link;
- IP6_PROTOCOL *IpInstance;
- IP6_FRAME_CALLBACK CallBack;
- NET_BUF *Packet;
- VOID *Context;
+ IP6_PROTOCOL *IpInstance;
+ IP6_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;
} IP6_LINK_TX_TOKEN;
struct _IP6_ADDRESS_INFO {
- UINT32 Signature;
- LIST_ENTRY Link;
- EFI_IPv6_ADDRESS Address;
- BOOLEAN IsAnycast;
- UINT8 PrefixLength;
- UINT32 ValidLifetime;
- UINT32 PreferredLifetime;
+ UINT32 Signature;
+ LIST_ENTRY Link;
+ EFI_IPv6_ADDRESS Address;
+ BOOLEAN IsAnycast;
+ UINT8 PrefixLength;
+ UINT32 ValidLifetime;
+ UINT32 PreferredLifetime;
};
//
@@ -89,50 +89,48 @@ struct _IP6_ADDRESS_INFO { typedef
BOOLEAN
(*IP6_FRAME_TO_CANCEL) (
- IP6_LINK_TX_TOKEN *Frame,
- VOID *Context
+ IP6_LINK_TX_TOKEN *Frame,
+ VOID *Context
);
struct _IP6_INTERFACE {
- UINT32 Signature;
- LIST_ENTRY Link;
- INTN RefCnt;
+ UINT32 Signature;
+ LIST_ENTRY Link;
+ INTN RefCnt;
//
// IP address and prefix length of the interface. The fileds
// are invalid if (Configured == FALSE)
//
- LIST_ENTRY AddressList;
- UINT32 AddressCount;
- BOOLEAN Configured;
+ LIST_ENTRY AddressList;
+ UINT32 AddressCount;
+ BOOLEAN Configured;
- IP6_SERVICE *Service;
-
- EFI_HANDLE Controller;
- EFI_HANDLE Image;
+ IP6_SERVICE *Service;
+ EFI_HANDLE Controller;
+ EFI_HANDLE Image;
//
// Queues to keep the frames sent and waiting ARP request.
//
- LIST_ENTRY ArpQues;
- LIST_ENTRY SentFrames;
-
+ LIST_ENTRY ArpQues;
+ LIST_ENTRY SentFrames;
//
// The interface's configuration variables
//
- UINT32 DupAddrDetect;
- LIST_ENTRY DupAddrDetectList;
- LIST_ENTRY DelayJoinList;
+ UINT32 DupAddrDetect;
+ LIST_ENTRY DupAddrDetectList;
+ LIST_ENTRY DelayJoinList;
//
// 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;
};
/**
@@ -147,8 +145,8 @@ struct _IP6_INTERFACE { **/
IP6_INTERFACE *
Ip6CreateInterface (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN LinkLocal
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN LinkLocal
);
/**
@@ -165,8 +163,8 @@ Ip6CreateInterface ( **/
VOID
Ip6CleanInterface (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL
);
/**
@@ -178,7 +176,7 @@ Ip6CleanInterface ( **/
VOID
Ip6FreeLinkTxToken (
- IN IP6_LINK_TX_TOKEN *Token
+ IN IP6_LINK_TX_TOKEN *Token
);
/**
@@ -191,8 +189,8 @@ Ip6FreeLinkTxToken ( VOID
EFIAPI
Ip6OnFrameReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -208,8 +206,8 @@ Ip6OnFrameReceived ( **/
EFI_STATUS
Ip6ReceiveFrame (
- IN IP6_FRAME_CALLBACK CallBack,
- IN IP6_SERVICE *IpSb
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN IP6_SERVICE *IpSb
);
/**
@@ -234,12 +232,12 @@ Ip6ReceiveFrame ( **/
EFI_STATUS
Ip6SendFrame (
- IN IP6_INTERFACE *Interface,
- IN IP6_PROTOCOL *IpInstance OPTIONAL,
- IN NET_BUF *Packet,
- IN EFI_IPv6_ADDRESS *NextHop,
- IN IP6_FRAME_CALLBACK CallBack,
- IN VOID *Context
+ IN IP6_INTERFACE *Interface,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL,
+ IN NET_BUF *Packet,
+ IN EFI_IPv6_ADDRESS *NextHop,
+ IN IP6_FRAME_CALLBACK CallBack,
+ IN VOID *Context
);
/**
@@ -254,8 +252,8 @@ Ip6SendFrame ( VOID
EFIAPI
Ip6TimerTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
#endif
diff --git a/NetworkPkg/Ip6Dxe/Ip6Impl.c b/NetworkPkg/Ip6Dxe/Ip6Impl.c index 826a5c2..a4bfd0f 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Impl.c +++ b/NetworkPkg/Ip6Dxe/Ip6Impl.c @@ -10,9 +10,9 @@ #include "Ip6Impl.h"
-EFI_IPSEC2_PROTOCOL *mIpSec = NULL;
+EFI_IPSEC2_PROTOCOL *mIpSec = NULL;
-EFI_IP6_PROTOCOL mEfiIp6ProtocolTemplete = {
+EFI_IP6_PROTOCOL mEfiIp6ProtocolTemplete = {
EfiIp6GetModeData,
EfiIp6Configure,
EfiIp6Groups,
@@ -44,18 +44,18 @@ EFI_IP6_PROTOCOL mEfiIp6ProtocolTemplete = { EFI_STATUS
EFIAPI
EfiIp6GetModeData (
- IN EFI_IP6_PROTOCOL *This,
- OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ IN EFI_IP6_PROTOCOL *This,
+ OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
)
{
- IP6_PROTOCOL *IpInstance;
- IP6_SERVICE *IpSb;
- IP6_INTERFACE *IpIf;
- EFI_IP6_CONFIG_DATA *Config;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ IP6_PROTOCOL *IpInstance;
+ IP6_SERVICE *IpSb;
+ IP6_INTERFACE *IpIf;
+ EFI_IP6_CONFIG_DATA *Config;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -75,25 +75,25 @@ EfiIp6GetModeData ( // IsStarted is "whether the EfiIp6Configure has been called".
// IsConfigured is "whether the station address has been configured"
//
- Ip6ModeData->IsStarted = (BOOLEAN) (IpInstance->State == IP6_STATE_CONFIGED);
+ Ip6ModeData->IsStarted = (BOOLEAN)(IpInstance->State == IP6_STATE_CONFIGED);
Ip6ModeData->MaxPacketSize = IpSb->MaxPacketSize;
CopyMem (&Ip6ModeData->ConfigData, &IpInstance->ConfigData, sizeof (EFI_IP6_CONFIG_DATA));
- Ip6ModeData->IsConfigured = FALSE;
+ Ip6ModeData->IsConfigured = FALSE;
- Ip6ModeData->AddressCount = 0;
- Ip6ModeData->AddressList = NULL;
+ Ip6ModeData->AddressCount = 0;
+ Ip6ModeData->AddressList = NULL;
- Ip6ModeData->GroupCount = IpInstance->GroupCount;
- Ip6ModeData->GroupTable = NULL;
+ Ip6ModeData->GroupCount = IpInstance->GroupCount;
+ Ip6ModeData->GroupTable = NULL;
- Ip6ModeData->RouteCount = 0;
- Ip6ModeData->RouteTable = NULL;
+ Ip6ModeData->RouteCount = 0;
+ Ip6ModeData->RouteTable = NULL;
Ip6ModeData->NeighborCount = 0;
Ip6ModeData->NeighborCache = NULL;
- Ip6ModeData->PrefixCount = 0;
- Ip6ModeData->PrefixTable = NULL;
+ Ip6ModeData->PrefixCount = 0;
+ Ip6ModeData->PrefixTable = NULL;
Ip6ModeData->IcmpTypeCount = 23;
Ip6ModeData->IcmpTypeList = AllocateCopyPool (
@@ -160,6 +160,7 @@ EfiIp6GetModeData ( goto Error;
}
}
+
//
// Return the neighbor cache entries
//
@@ -183,7 +184,6 @@ EfiIp6GetModeData ( if (EFI_ERROR (Status)) {
goto Error;
}
-
}
}
@@ -242,15 +242,16 @@ Exit: **/
BOOLEAN
Ip6IsValidAddress (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip,
- IN BOOLEAN Flag
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip,
+ IN BOOLEAN Flag
)
{
if (!NetIp6IsUnspecifiedAddr (Ip)) {
- if (!NetIp6IsValidUnicast(Ip)) {
+ if (!NetIp6IsValidUnicast (Ip)) {
return FALSE;
}
+
if (Ip6IsOneOfSetAddress (IpSb, Ip, NULL, NULL)) {
return Flag;
}
@@ -273,14 +274,14 @@ Ip6IsValidAddress ( **/
BOOLEAN
Ip6IsIllegalProtocol (
- IN UINT8 Protocol
+ IN UINT8 Protocol
)
{
- if (Protocol == IP6_HOP_BY_HOP || Protocol == EFI_IP_PROTO_ICMP || Protocol == IP4_PROTO_IGMP) {
+ if ((Protocol == IP6_HOP_BY_HOP) || (Protocol == EFI_IP_PROTO_ICMP) || (Protocol == IP4_PROTO_IGMP)) {
return TRUE;
}
- if (Protocol == 41 || Protocol == 43 || Protocol == 44 || Protocol == 59 || Protocol == 60 || Protocol == 124) {
+ if ((Protocol == 41) || (Protocol == 43) || (Protocol == 44) || (Protocol == 59) || (Protocol == 60) || (Protocol == 124)) {
return TRUE;
}
@@ -296,8 +297,8 @@ Ip6IsIllegalProtocol ( **/
VOID
Ip6InitProtocol (
- IN IP6_SERVICE *IpSb,
- IN OUT IP6_PROTOCOL *IpInstance
+ IN IP6_SERVICE *IpSb,
+ IN OUT IP6_PROTOCOL *IpInstance
)
{
ASSERT ((IpSb != NULL) && (IpInstance != NULL));
@@ -310,8 +311,8 @@ Ip6InitProtocol ( IpInstance->GroupList = NULL;
CopyMem (&IpInstance->Ip6Proto, &mEfiIp6ProtocolTemplete, sizeof (EFI_IP6_PROTOCOL));
- NetMapInit (&IpInstance->RxTokens);
- NetMapInit (&IpInstance->TxTokens);
+ NetMapInit (&IpInstance->RxTokens);
+ NetMapInit (&IpInstance->TxTokens);
InitializeListHead (&IpInstance->Received);
InitializeListHead (&IpInstance->Delivered);
@@ -340,19 +341,19 @@ Ip6InitProtocol ( **/
EFI_STATUS
Ip6ConfigProtocol (
- IN OUT IP6_PROTOCOL *IpInstance,
- IN EFI_IP6_CONFIG_DATA *Config
+ IN OUT IP6_PROTOCOL *IpInstance,
+ IN EFI_IP6_CONFIG_DATA *Config
)
{
- IP6_SERVICE *IpSb;
- IP6_INTERFACE *IpIf;
- EFI_STATUS Status;
- EFI_IP6_CONFIG_DATA *Current;
- IP6_ADDRESS_INFO *AddressInfo;
- BOOLEAN StationZero;
- BOOLEAN DestZero;
- EFI_IPv6_ADDRESS Source;
- BOOLEAN AddrOk;
+ IP6_SERVICE *IpSb;
+ IP6_INTERFACE *IpIf;
+ EFI_STATUS Status;
+ EFI_IP6_CONFIG_DATA *Current;
+ IP6_ADDRESS_INFO *AddressInfo;
+ BOOLEAN StationZero;
+ BOOLEAN DestZero;
+ EFI_IPv6_ADDRESS Source;
+ BOOLEAN AddrOk;
IpSb = IpInstance->Service;
Current = &IpInstance->ConfigData;
@@ -419,7 +420,6 @@ Ip6ConfigProtocol ( return EFI_INVALID_PARAMETER;
}
-
NET_GET_REF (IpIf);
IpInstance->Interface = IpIf;
InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink);
@@ -442,7 +442,7 @@ Ip6ConfigProtocol ( **/
EFI_STATUS
Ip6CleanProtocol (
- IN OUT IP6_PROTOCOL *IpInstance
+ IN OUT IP6_PROTOCOL *IpInstance
)
{
if (EFI_ERROR (Ip6Cancel (IpInstance, NULL))) {
@@ -459,7 +459,6 @@ Ip6CleanProtocol ( // hasn't been called. Just leave it alone.
//
if (!IsListEmpty (&IpInstance->Delivered)) {
- ;
}
if (IpInstance->Interface != NULL) {
@@ -470,8 +469,8 @@ Ip6CleanProtocol ( if (IpInstance->GroupList != NULL) {
FreePool (IpInstance->GroupList);
- IpInstance->GroupList = NULL;
- IpInstance->GroupCount = 0;
+ IpInstance->GroupList = NULL;
+ IpInstance->GroupCount = 0;
}
NetMapClean (&IpInstance->TxTokens);
@@ -501,17 +500,17 @@ Ip6CleanProtocol ( **/
EFI_STATUS
Ip6ServiceConfigMnp (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN Force
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN Force
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *ProtoEntry;
- IP6_INTERFACE *IpIf;
- IP6_PROTOCOL *IpInstance;
- BOOLEAN Reconfig;
- BOOLEAN PromiscReceive;
- EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *ProtoEntry;
+ IP6_INTERFACE *IpIf;
+ IP6_PROTOCOL *IpInstance;
+ BOOLEAN Reconfig;
+ BOOLEAN PromiscReceive;
+ EFI_STATUS Status;
Reconfig = FALSE;
PromiscReceive = FALSE;
@@ -523,7 +522,6 @@ Ip6ServiceConfigMnp ( // filter also.
//
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
-
IpIf = NET_LIST_USER_STRUCT (Entry, IP6_INTERFACE, Link);
IpIf->PromiscRecv = FALSE;
@@ -544,7 +542,7 @@ Ip6ServiceConfigMnp ( return EFI_SUCCESS;
}
- Reconfig = TRUE;
+ Reconfig = TRUE;
IpSb->MnpConfigData.EnablePromiscuousReceive = PromiscReceive;
}
@@ -610,15 +608,15 @@ Ip6ServiceConfigMnp ( EFI_STATUS
EFIAPI
EfiIp6Configure (
- IN EFI_IP6_PROTOCOL *This,
- IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL
+ IN EFI_IP6_PROTOCOL *This,
+ IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL
)
{
- IP6_PROTOCOL *IpInstance;
- EFI_IP6_CONFIG_DATA *Current;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- IP6_SERVICE *IpSb;
+ IP6_PROTOCOL *IpInstance;
+ EFI_IP6_CONFIG_DATA *Current;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ IP6_SERVICE *IpSb;
//
// First, validate the parameters
@@ -630,13 +628,13 @@ EfiIp6Configure ( IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This);
IpSb = IpInstance->Service;
- if (IpSb->LinkLocalDadFail && Ip6ConfigData != NULL) {
+ if (IpSb->LinkLocalDadFail && (Ip6ConfigData != NULL)) {
return EFI_DEVICE_ERROR;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- Status = EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
//
// Validate the configuration first.
@@ -646,8 +644,9 @@ EfiIp6Configure ( // Check whether the station address is valid.
//
if (!Ip6IsValidAddress (IpSb, &Ip6ConfigData->StationAddress, TRUE)) {
- goto Exit;
+ goto Exit;
}
+
//
// Check whether the default protocol is valid.
//
@@ -744,16 +743,16 @@ EfiIp6Groups ( IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
)
{
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- IP6_PROTOCOL *IpInstance;
- IP6_SERVICE *IpSb;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ IP6_PROTOCOL *IpInstance;
+ IP6_SERVICE *IpSb;
- if ((This == NULL) || (JoinFlag && GroupAddress == NULL)) {
+ if ((This == NULL) || (JoinFlag && (GroupAddress == NULL))) {
return EFI_INVALID_PARAMETER;
}
- if (GroupAddress != NULL && !IP6_IS_MULTICAST (GroupAddress)) {
+ if ((GroupAddress != NULL) && !IP6_IS_MULTICAST (GroupAddress)) {
return EFI_INVALID_PARAMETER;
}
@@ -764,7 +763,7 @@ EfiIp6Groups ( return EFI_DEVICE_ERROR;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (IpInstance->State != IP6_STATE_CONFIGED) {
Status = EFI_NOT_STARTED;
@@ -824,17 +823,17 @@ ON_EXIT: EFI_STATUS
EFIAPI
EfiIp6Routes (
- IN EFI_IP6_PROTOCOL *This,
- IN BOOLEAN DeleteRoute,
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
+ IN EFI_IP6_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
)
{
- IP6_PROTOCOL *IpInstance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- IP6_SERVICE *IpSb;
+ IP6_PROTOCOL *IpInstance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ IP6_SERVICE *IpSb;
if ((This == NULL) || (PrefixLength > IP6_PREFIX_MAX)) {
return EFI_INVALID_PARAMETER;
@@ -855,7 +854,7 @@ EfiIp6Routes ( return EFI_INVALID_PARAMETER;
}
- if (!DeleteRoute && (Destination == NULL || GatewayAddress == NULL)) {
+ if (!DeleteRoute && ((Destination == NULL) || (GatewayAddress == NULL))) {
return EFI_INVALID_PARAMETER;
}
@@ -866,7 +865,8 @@ EfiIp6Routes ( if (!NetIp6IsUnspecifiedAddr (GatewayAddress) &&
!NetIp6IsNetEqual (GatewayAddress, &IpInstance->ConfigData.StationAddress, PrefixLength)
- ) {
+ )
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -935,20 +935,20 @@ EfiIp6Routes ( EFI_STATUS
EFIAPI
EfiIp6Neighbors (
- IN EFI_IP6_PROTOCOL *This,
- IN BOOLEAN DeleteFlag,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN EFI_IP6_PROTOCOL *This,
+ IN BOOLEAN DeleteFlag,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
)
{
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- IP6_PROTOCOL *IpInstance;
- IP6_SERVICE *IpSb;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ IP6_PROTOCOL *IpInstance;
+ IP6_SERVICE *IpSb;
- if (This == NULL || TargetIp6Address == NULL) {
+ if ((This == NULL) || (TargetIp6Address == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1011,18 +1011,18 @@ Exit: EFI_STATUS
EFIAPI
Ip6TokenExist (
- IN NET_MAP *Map,
- IN NET_MAP_ITEM *Item,
- IN VOID *Context
+ IN NET_MAP *Map,
+ IN NET_MAP_ITEM *Item,
+ IN VOID *Context
)
{
EFI_IP6_COMPLETION_TOKEN *Token;
EFI_IP6_COMPLETION_TOKEN *TokenInItem;
- Token = (EFI_IP6_COMPLETION_TOKEN *) Context;
- TokenInItem = (EFI_IP6_COMPLETION_TOKEN *) Item->Key;
+ Token = (EFI_IP6_COMPLETION_TOKEN *)Context;
+ TokenInItem = (EFI_IP6_COMPLETION_TOKEN *)Item->Key;
- if (Token == TokenInItem || Token->Event == TokenInItem->Event) {
+ if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
return EFI_ACCESS_DENIED;
}
@@ -1041,29 +1041,29 @@ Ip6TokenExist ( **/
EFI_STATUS
Ip6TxTokenValid (
- IN EFI_IP6_COMPLETION_TOKEN *Token
+ IN EFI_IP6_COMPLETION_TOKEN *Token
)
{
- EFI_IP6_TRANSMIT_DATA *TxData;
- UINT32 Index;
- UINT32 DataLength;
+ EFI_IP6_TRANSMIT_DATA *TxData;
+ UINT32 Index;
+ UINT32 DataLength;
- if (Token == NULL || Token->Event == NULL) {
+ if ((Token == NULL) || (Token->Event == NULL)) {
return EFI_INVALID_PARAMETER;
}
TxData = Token->Packet.TxData;
- if (TxData == NULL || (TxData->ExtHdrsLength != 0 && TxData->ExtHdrs == NULL)) {
+ if ((TxData == NULL) || ((TxData->ExtHdrsLength != 0) && (TxData->ExtHdrs == NULL))) {
return EFI_INVALID_PARAMETER;
}
- if (TxData->FragmentCount == 0 || TxData->DataLength == 0) {
+ if ((TxData->FragmentCount == 0) || (TxData->DataLength == 0)) {
return EFI_INVALID_PARAMETER;
}
for (DataLength = 0, Index = 0; Index < TxData->FragmentCount; Index++) {
- if (TxData->FragmentTable[Index].FragmentLength == 0 || TxData->FragmentTable[Index].FragmentBuffer == NULL) {
+ if ((TxData->FragmentTable[Index].FragmentLength == 0) || (TxData->FragmentTable[Index].FragmentBuffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1115,13 +1115,13 @@ Ip6TxTokenValid ( VOID
EFIAPI
Ip6FreeTxToken (
- IN VOID *Context
+ IN VOID *Context
)
{
- IP6_TXTOKEN_WRAP *Wrap;
- NET_MAP_ITEM *Item;
+ IP6_TXTOKEN_WRAP *Wrap;
+ NET_MAP_ITEM *Item;
- Wrap = (IP6_TXTOKEN_WRAP *) Context;
+ Wrap = (IP6_TXTOKEN_WRAP *)Context;
//
// Signal IpSecRecycleEvent to inform IPsec free the memory
@@ -1152,7 +1152,6 @@ Ip6FreeTxToken ( FreePool (Wrap);
}
-
/**
The callback function to Ip6Output to update the transmit status.
@@ -1164,19 +1163,19 @@ Ip6FreeTxToken ( **/
VOID
Ip6OnPacketSent (
- IN NET_BUF *Packet,
- IN EFI_STATUS IoStatus,
- IN UINT32 Flag,
- IN VOID *Context
+ IN NET_BUF *Packet,
+ IN EFI_STATUS IoStatus,
+ IN UINT32 Flag,
+ IN VOID *Context
)
{
- IP6_TXTOKEN_WRAP *Wrap;
+ IP6_TXTOKEN_WRAP *Wrap;
//
// This is the transmission request from upper layer,
// not the IP6 driver itself.
//
- Wrap = (IP6_TXTOKEN_WRAP *) Context;
+ Wrap = (IP6_TXTOKEN_WRAP *)Context;
Wrap->Token->Status = IoStatus;
NetbufFree (Wrap->Packet);
@@ -1241,16 +1240,16 @@ EfiIp6Transmit ( IN EFI_IP6_COMPLETION_TOKEN *Token
)
{
- IP6_SERVICE *IpSb;
- IP6_PROTOCOL *IpInstance;
- EFI_IP6_CONFIG_DATA *Config;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- EFI_IP6_HEADER Head;
- EFI_IP6_TRANSMIT_DATA *TxData;
- EFI_IP6_OVERRIDE_DATA *Override;
- IP6_TXTOKEN_WRAP *Wrap;
- UINT8 *ExtHdrs;
+ IP6_SERVICE *IpSb;
+ IP6_PROTOCOL *IpInstance;
+ EFI_IP6_CONFIG_DATA *Config;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ EFI_IP6_HEADER Head;
+ EFI_IP6_TRANSMIT_DATA *TxData;
+ EFI_IP6_OVERRIDE_DATA *Override;
+ IP6_TXTOKEN_WRAP *Wrap;
+ UINT8 *ExtHdrs;
//
// Check input parameters.
@@ -1273,7 +1272,7 @@ EfiIp6Transmit ( return EFI_DEVICE_ERROR;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (IpInstance->State != IP6_STATE_CONFIGED) {
Status = EFI_NOT_STARTED;
@@ -1293,7 +1292,7 @@ EfiIp6Transmit ( //
// Build the IP header, fill in the information from ConfigData or OverrideData
//
- ZeroMem (&Head, sizeof(EFI_IP6_HEADER));
+ ZeroMem (&Head, sizeof (EFI_IP6_HEADER));
TxData = Token->Packet.TxData;
IP6_COPY_ADDRESS (&Head.SourceAddress, &Config->StationAddress);
IP6_COPY_ADDRESS (&Head.DestinationAddress, &Config->DestinationAddress);
@@ -1306,7 +1305,6 @@ EfiIp6Transmit ( }
ASSERT (!NetIp6IsUnspecifiedAddr (&Config->StationAddress));
-
} else {
//
// StationAddress is unspecified only when ConfigData.Dest is unspecified.
@@ -1342,15 +1340,15 @@ EfiIp6Transmit ( Override = TxData->OverrideData;
Head.NextHeader = Override->Protocol;
Head.HopLimit = Override->HopLimit;
- Head.FlowLabelL = HTONS ((UINT16) Override->FlowLabel);
- Head.FlowLabelH = (UINT8) ((Override->FlowLabel >> 16) & 0x0F);
+ Head.FlowLabelL = HTONS ((UINT16)Override->FlowLabel);
+ Head.FlowLabelH = (UINT8)((Override->FlowLabel >> 16) & 0x0F);
} else {
Head.HopLimit = Config->HopLimit;
- Head.FlowLabelL = HTONS ((UINT16) Config->FlowLabel);
- Head.FlowLabelH = (UINT8) ((Config->FlowLabel >> 16) & 0x0F);
+ Head.FlowLabelL = HTONS ((UINT16)Config->FlowLabel);
+ Head.FlowLabelH = (UINT8)((Config->FlowLabel >> 16) & 0x0F);
}
- Head.PayloadLength = HTONS ((UINT16) (TxData->ExtHdrsLength + TxData->DataLength));
+ Head.PayloadLength = HTONS ((UINT16)(TxData->ExtHdrsLength + TxData->DataLength));
//
// OK, it survives all the validation check. Wrap the token in
@@ -1362,18 +1360,18 @@ EfiIp6Transmit ( goto Exit;
}
- Wrap->IpInstance = IpInstance;
- Wrap->Token = Token;
- Wrap->Sent = FALSE;
- Wrap->Life = IP6_US_TO_SEC (Config->TransmitTimeout);
- Wrap->Packet = NetbufFromExt (
- (NET_FRAGMENT *) TxData->FragmentTable,
- TxData->FragmentCount,
- IP6_MAX_HEADLEN,
- 0,
- Ip6FreeTxToken,
- Wrap
- );
+ Wrap->IpInstance = IpInstance;
+ Wrap->Token = Token;
+ Wrap->Sent = FALSE;
+ Wrap->Life = IP6_US_TO_SEC (Config->TransmitTimeout);
+ Wrap->Packet = NetbufFromExt (
+ (NET_FRAGMENT *)TxData->FragmentTable,
+ TxData->FragmentCount,
+ IP6_MAX_HEADLEN,
+ 0,
+ Ip6FreeTxToken,
+ Wrap
+ );
if (Wrap->Packet == NULL) {
FreePool (Wrap);
@@ -1397,8 +1395,8 @@ EfiIp6Transmit ( // Allocate a new buffer to store IPv6 extension headers to avoid updating
// the original data in EFI_IP6_COMPLETION_TOKEN.
//
- if (TxData->ExtHdrsLength != 0 && TxData->ExtHdrs != NULL) {
- ExtHdrs = (UINT8 *) AllocateCopyPool (TxData->ExtHdrsLength, TxData->ExtHdrs);
+ if ((TxData->ExtHdrsLength != 0) && (TxData->ExtHdrs != NULL)) {
+ ExtHdrs = (UINT8 *)AllocateCopyPool (TxData->ExtHdrsLength, TxData->ExtHdrs);
if (ExtHdrs == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
@@ -1485,12 +1483,12 @@ EfiIp6Receive ( IN EFI_IP6_COMPLETION_TOKEN *Token
)
{
- IP6_PROTOCOL *IpInstance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- IP6_SERVICE *IpSb;
+ IP6_PROTOCOL *IpInstance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ IP6_SERVICE *IpSb;
- if (This == NULL || Token == NULL || Token->Event == NULL) {
+ if ((This == NULL) || (Token == NULL) || (Token->Event == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1540,7 +1538,6 @@ Exit: return Status;
}
-
/**
Cancel the transmitted but not recycled packet. If a matching
token is found, it will call Ip6CancelPacket to cancel the
@@ -1561,15 +1558,15 @@ Exit: EFI_STATUS
EFIAPI
Ip6CancelTxTokens (
- IN NET_MAP *Map,
- IN NET_MAP_ITEM *Item,
- IN VOID *Context
+ IN NET_MAP *Map,
+ IN NET_MAP_ITEM *Item,
+ IN VOID *Context
)
{
EFI_IP6_COMPLETION_TOKEN *Token;
IP6_TXTOKEN_WRAP *Wrap;
- Token = (EFI_IP6_COMPLETION_TOKEN *) Context;
+ Token = (EFI_IP6_COMPLETION_TOKEN *)Context;
//
// Return EFI_SUCCESS to check the next item in the map if
@@ -1579,7 +1576,7 @@ Ip6CancelTxTokens ( return EFI_SUCCESS;
}
- Wrap = (IP6_TXTOKEN_WRAP *) Item->Value;
+ Wrap = (IP6_TXTOKEN_WRAP *)Item->Value;
ASSERT (Wrap != NULL);
//
@@ -1599,7 +1596,6 @@ Ip6CancelTxTokens ( return EFI_SUCCESS;
}
-
/**
Cancel the receive request. This is simple, because
it is only enqueued in our local receive map.
@@ -1618,15 +1614,15 @@ Ip6CancelTxTokens ( EFI_STATUS
EFIAPI
Ip6CancelRxTokens (
- IN NET_MAP *Map,
- IN NET_MAP_ITEM *Item,
- IN VOID *Context
+ IN NET_MAP *Map,
+ IN NET_MAP_ITEM *Item,
+ IN VOID *Context
)
{
EFI_IP6_COMPLETION_TOKEN *Token;
EFI_IP6_COMPLETION_TOKEN *This;
- Token = (EFI_IP6_COMPLETION_TOKEN *) Context;
+ Token = (EFI_IP6_COMPLETION_TOKEN *)Context;
This = Item->Key;
if ((Token != NULL) && (Token != This)) {
@@ -1662,11 +1658,11 @@ Ip6CancelRxTokens ( **/
EFI_STATUS
Ip6Cancel (
- IN IP6_PROTOCOL *IpInstance,
- IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
+ IN IP6_PROTOCOL *IpInstance,
+ IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// First check the transmitted packet. Ip6CancelTxTokens returns
@@ -1713,7 +1709,6 @@ Ip6Cancel ( // all of them are cancelled.
//
if (!NetMapIsEmpty (&IpInstance->TxTokens) || !NetMapIsEmpty (&IpInstance->RxTokens)) {
-
return EFI_DEVICE_ERROR;
}
@@ -1755,9 +1750,9 @@ EfiIp6Cancel ( IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
)
{
- IP6_PROTOCOL *IpInstance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ IP6_PROTOCOL *IpInstance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1807,7 +1802,7 @@ Exit: EFI_STATUS
EFIAPI
EfiIp6Poll (
- IN EFI_IP6_PROTOCOL *This
+ IN EFI_IP6_PROTOCOL *This
)
{
IP6_PROTOCOL *IpInstance;
@@ -1836,6 +1831,4 @@ EfiIp6Poll ( // the packet polled up.
//
return Mnp->Poll (Mnp);
-
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Impl.h b/NetworkPkg/Ip6Dxe/Ip6Impl.h index 8919e94..9802c33 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Impl.h +++ b/NetworkPkg/Ip6Dxe/Ip6Impl.h @@ -54,8 +54,8 @@ #include "Ip6ConfigNv.h"
#include "Ip6ConfigImpl.h"
-#define IP6_PROTOCOL_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'P')
-#define IP6_SERVICE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'S')
+#define IP6_PROTOCOL_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'P')
+#define IP6_SERVICE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'S')
//
// The state of IP6 protocol. It starts from UNCONFIGED. if it is
@@ -63,8 +63,8 @@ // is called, it becomes UNCONFIGED again. If (partly) destroyed, it
// becomes DESTROY.
//
-#define IP6_STATE_UNCONFIGED 0
-#define IP6_STATE_CONFIGED 1
+#define IP6_STATE_UNCONFIGED 0
+#define IP6_STATE_CONFIGED 1
//
// The state of IP6 service. It starts from UNSTARTED. It transits
@@ -83,10 +83,10 @@ #define IP6_SERVICE_FROM_PROTOCOL(Sb) \
CR ((Sb), IP6_SERVICE, ServiceBinding, IP6_SERVICE_SIGNATURE)
-#define IP6_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
+#define IP6_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
-extern EFI_IPSEC2_PROTOCOL *mIpSec;
-extern BOOLEAN mIpSec2Installed;
+extern EFI_IPSEC2_PROTOCOL *mIpSec;
+extern BOOLEAN mIpSec2Installed;
//
// IP6_TXTOKEN_WRAP wraps the upper layer's transmit token.
@@ -98,17 +98,17 @@ extern BOOLEAN mIpSec2Installed; // user's event signalled.
//
typedef struct {
- IP6_PROTOCOL *IpInstance;
- EFI_IP6_COMPLETION_TOKEN *Token;
- EFI_EVENT IpSecRecycleSignal;
- NET_BUF *Packet;
- BOOLEAN Sent;
- INTN Life;
+ IP6_PROTOCOL *IpInstance;
+ EFI_IP6_COMPLETION_TOKEN *Token;
+ EFI_EVENT IpSecRecycleSignal;
+ NET_BUF *Packet;
+ BOOLEAN Sent;
+ INTN Life;
} IP6_TXTOKEN_WRAP;
typedef struct {
- EFI_EVENT IpSecRecycleSignal;
- NET_BUF *Packet;
+ EFI_EVENT IpSecRecycleSignal;
+ NET_BUF *Packet;
} IP6_IPSEC_WRAP;
//
@@ -121,123 +121,123 @@ typedef struct { // fragments will be freed at last.
//
typedef struct {
- LIST_ENTRY Link;
- IP6_PROTOCOL *IpInstance;
- NET_BUF *Packet;
- EFI_IP6_RECEIVE_DATA RxData;
+ LIST_ENTRY Link;
+ IP6_PROTOCOL *IpInstance;
+ NET_BUF *Packet;
+ EFI_IP6_RECEIVE_DATA RxData;
} IP6_RXDATA_WRAP;
struct _IP6_PROTOCOL {
- UINT32 Signature;
+ UINT32 Signature;
- EFI_IP6_PROTOCOL Ip6Proto;
- EFI_HANDLE Handle;
- INTN State;
+ EFI_IP6_PROTOCOL Ip6Proto;
+ EFI_HANDLE Handle;
+ INTN State;
- IP6_SERVICE *Service;
- LIST_ENTRY Link; // Link to all the IP protocol from the service
+ IP6_SERVICE *Service;
+ LIST_ENTRY Link; // Link to all the IP protocol from the service
- UINT8 PrefixLength; // PrefixLength of the configured station address.
+ UINT8 PrefixLength; // PrefixLength of the configured station address.
//
// User's transmit/receive tokens, and received/delivered packets
//
- NET_MAP RxTokens;
- NET_MAP TxTokens; // map between (User's Token, IP6_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, IP6_TXTOKE_WRAP)
+ LIST_ENTRY Received; // Received but not delivered packet
+ LIST_ENTRY Delivered; // Delivered and to be recycled packets
+ EFI_LOCK RecycleLock;
- IP6_INTERFACE *Interface;
- LIST_ENTRY AddrLink; // Ip instances with the same IP address.
+ IP6_INTERFACE *Interface;
+ LIST_ENTRY AddrLink; // Ip instances with the same IP address.
- EFI_IPv6_ADDRESS *GroupList; // stored in network order.
- UINT32 GroupCount;
+ EFI_IPv6_ADDRESS *GroupList; // stored in network order.
+ UINT32 GroupCount;
- EFI_IP6_CONFIG_DATA ConfigData;
- BOOLEAN InDestroy;
+ EFI_IP6_CONFIG_DATA ConfigData;
+ BOOLEAN InDestroy;
};
struct _IP6_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;
- IP6_INTERFACE *DefaultInterface;
- IP6_ROUTE_TABLE *RouteTable;
+ IP6_INTERFACE *DefaultInterface;
+ IP6_ROUTE_TABLE *RouteTable;
- IP6_LINK_RX_TOKEN RecvRequest;
+ IP6_LINK_RX_TOKEN RecvRequest;
//
// Ip reassemble utilities and MLD data
//
- IP6_ASSEMBLE_TABLE Assemble;
- IP6_MLD_SERVICE_DATA MldCtrl;
+ IP6_ASSEMBLE_TABLE Assemble;
+ IP6_MLD_SERVICE_DATA MldCtrl;
- EFI_IPv6_ADDRESS LinkLocalAddr;
- BOOLEAN LinkLocalOk;
- BOOLEAN LinkLocalDadFail;
- BOOLEAN Dhcp6NeedStart;
- BOOLEAN Dhcp6NeedInfoRequest;
+ EFI_IPv6_ADDRESS LinkLocalAddr;
+ BOOLEAN LinkLocalOk;
+ BOOLEAN LinkLocalDadFail;
+ BOOLEAN Dhcp6NeedStart;
+ BOOLEAN Dhcp6NeedInfoRequest;
//
// ND data
//
- UINT8 CurHopLimit;
- UINT32 LinkMTU;
- UINT32 BaseReachableTime;
- UINT32 ReachableTime;
- UINT32 RetransTimer;
- LIST_ENTRY NeighborTable;
+ UINT8 CurHopLimit;
+ UINT32 LinkMTU;
+ UINT32 BaseReachableTime;
+ UINT32 ReachableTime;
+ UINT32 RetransTimer;
+ LIST_ENTRY NeighborTable;
- LIST_ENTRY OnlinkPrefix;
- LIST_ENTRY AutonomousPrefix;
+ LIST_ENTRY OnlinkPrefix;
+ LIST_ENTRY AutonomousPrefix;
- LIST_ENTRY DefaultRouterList;
- UINT32 RoundRobin;
+ LIST_ENTRY DefaultRouterList;
+ UINT32 RoundRobin;
- UINT8 InterfaceIdLen;
- UINT8 *InterfaceId;
+ UINT8 InterfaceIdLen;
+ UINT8 *InterfaceId;
- BOOLEAN RouterAdvertiseReceived;
- UINT8 SolicitTimer;
- UINT32 Ticks;
+ BOOLEAN RouterAdvertiseReceived;
+ UINT8 SolicitTimer;
+ UINT32 Ticks;
//
// 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 FasterTimer;
+ EFI_EVENT Timer;
+ EFI_EVENT FasterTimer;
//
// IPv6 Configuration Protocol instance
//
- IP6_CONFIG_INSTANCE Ip6ConfigInstance;
+ IP6_CONFIG_INSTANCE Ip6ConfigInstance;
//
// The string representation of the current mac address of the
// NIC this IP6_SERVICE works on.
//
- CHAR16 *MacString;
- UINT32 MaxPacketSize;
- UINT32 OldMaxPacketSize;
+ CHAR16 *MacString;
+ UINT32 MaxPacketSize;
+ UINT32 OldMaxPacketSize;
};
/**
@@ -264,7 +264,7 @@ struct _IP6_SERVICE { VOID
EFIAPI
Ip6FreeTxToken (
- IN VOID *Context
+ IN VOID *Context
);
/**
@@ -287,8 +287,8 @@ Ip6FreeTxToken ( **/
EFI_STATUS
Ip6ServiceConfigMnp (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN Force
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN Force
);
/**
@@ -307,8 +307,8 @@ Ip6ServiceConfigMnp ( **/
EFI_STATUS
Ip6Cancel (
- IN IP6_PROTOCOL *IpInstance,
- IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
+ IN IP6_PROTOCOL *IpInstance,
+ IN EFI_IP6_COMPLETION_TOKEN *Token OPTIONAL
);
/**
@@ -320,8 +320,8 @@ Ip6Cancel ( **/
VOID
Ip6InitProtocol (
- IN IP6_SERVICE *IpSb,
- IN OUT IP6_PROTOCOL *IpInstance
+ IN IP6_SERVICE *IpSb,
+ IN OUT IP6_PROTOCOL *IpInstance
);
/**
@@ -335,7 +335,7 @@ Ip6InitProtocol ( **/
EFI_STATUS
Ip6CleanProtocol (
- IN OUT IP6_PROTOCOL *IpInstance
+ IN OUT IP6_PROTOCOL *IpInstance
);
//
@@ -362,10 +362,10 @@ Ip6CleanProtocol ( EFI_STATUS
EFIAPI
EfiIp6GetModeData (
- IN EFI_IP6_PROTOCOL *This,
- OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ IN EFI_IP6_PROTOCOL *This,
+ OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
);
/**
@@ -418,8 +418,8 @@ EfiIp6GetModeData ( EFI_STATUS
EFIAPI
EfiIp6Configure (
- IN EFI_IP6_PROTOCOL *This,
- IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL
+ IN EFI_IP6_PROTOCOL *This,
+ IN EFI_IP6_CONFIG_DATA *Ip6ConfigData OPTIONAL
);
/**
@@ -507,11 +507,11 @@ EfiIp6Groups ( EFI_STATUS
EFIAPI
EfiIp6Routes (
- IN EFI_IP6_PROTOCOL *This,
- IN BOOLEAN DeleteRoute,
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
+ IN EFI_IP6_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
);
/**
@@ -563,12 +563,12 @@ EfiIp6Routes ( EFI_STATUS
EFIAPI
EfiIp6Neighbors (
- IN EFI_IP6_PROTOCOL *This,
- IN BOOLEAN DeleteFlag,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN EFI_IP6_PROTOCOL *This,
+ IN BOOLEAN DeleteFlag,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
);
/**
@@ -742,7 +742,7 @@ EfiIp6Cancel ( EFI_STATUS
EFIAPI
EfiIp6Poll (
- IN EFI_IP6_PROTOCOL *This
+ IN EFI_IP6_PROTOCOL *This
);
#endif
diff --git a/NetworkPkg/Ip6Dxe/Ip6Input.c b/NetworkPkg/Ip6Dxe/Ip6Input.c index c42baa3..fe6a364 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Input.c +++ b/NetworkPkg/Ip6Dxe/Ip6Input.c @@ -24,12 +24,12 @@ **/
IP6_ASSEMBLE_ENTRY *
Ip6CreateAssembleEntry (
- IN EFI_IPv6_ADDRESS *Dst,
- IN EFI_IPv6_ADDRESS *Src,
- IN UINT32 Id
+ IN EFI_IPv6_ADDRESS *Dst,
+ IN EFI_IPv6_ADDRESS *Src,
+ IN UINT32 Id
)
{
- IP6_ASSEMBLE_ENTRY *Assemble;
+ IP6_ASSEMBLE_ENTRY *Assemble;
Assemble = AllocatePool (sizeof (IP6_ASSEMBLE_ENTRY));
if (Assemble == NULL) {
@@ -40,8 +40,8 @@ Ip6CreateAssembleEntry ( IP6_COPY_ADDRESS (&Assemble->Src, Src);
InitializeListHead (&Assemble->Fragments);
- Assemble->Id = Id;
- Assemble->Life = IP6_FRAGMENT_LIFE + 1;
+ Assemble->Id = Id;
+ Assemble->Life = IP6_FRAGMENT_LIFE + 1;
Assemble->TotalLen = 0;
Assemble->CurLen = 0;
@@ -60,12 +60,12 @@ Ip6CreateAssembleEntry ( **/
VOID
Ip6FreeAssembleEntry (
- IN IP6_ASSEMBLE_ENTRY *Assemble
+ IN IP6_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);
@@ -92,10 +92,10 @@ Ip6FreeAssembleEntry ( VOID
EFIAPI
Ip6OnFreeFragments (
- IN VOID *Arg
+ IN VOID *Arg
)
{
- Ip6FreeAssembleEntry ((IP6_ASSEMBLE_ENTRY *) Arg);
+ Ip6FreeAssembleEntry ((IP6_ASSEMBLE_ENTRY *)Arg);
}
/**
@@ -109,33 +109,33 @@ Ip6OnFreeFragments ( **/
VOID
Ip6TrimPacket (
- IN OUT NET_BUF *Packet,
- IN INTN Start,
- IN INTN End
+ IN OUT NET_BUF *Packet,
+ IN INTN Start,
+ IN INTN End
)
{
- IP6_CLIP_INFO *Info;
- INTN Len;
+ IP6_CLIP_INFO *Info;
+ INTN Len;
Info = IP6_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);
- Info->Start = (UINT32) Start;
- Info->Length -= (UINT32) Len;
+ NetbufTrim (Packet, (UINT32)Len, NET_BUF_HEAD);
+ Info->Start = (UINT32)Start;
+ Info->Length -= (UINT32)Len;
}
if (End < Info->End) {
Len = End - Info->End;
- NetbufTrim (Packet, (UINT32) Len, NET_BUF_TAIL);
- Info->End = (UINT32) End;
- Info->Length -= (UINT32) Len;
+ NetbufTrim (Packet, (UINT32)Len, NET_BUF_TAIL);
+ Info->End = (UINT32)End;
+ Info->Length -= (UINT32)Len;
}
}
@@ -156,26 +156,26 @@ Ip6TrimPacket ( **/
NET_BUF *
Ip6Reassemble (
- IN OUT IP6_ASSEMBLE_TABLE *Table,
- IN NET_BUF *Packet
+ IN OUT IP6_ASSEMBLE_TABLE *Table,
+ IN NET_BUF *Packet
)
{
- EFI_IP6_HEADER *Head;
- IP6_CLIP_INFO *This;
- IP6_CLIP_INFO *Node;
- IP6_ASSEMBLE_ENTRY *Assemble;
- IP6_ASSEMBLE_ENTRY *Entry;
- LIST_ENTRY *ListHead;
- LIST_ENTRY *Prev;
- LIST_ENTRY *Cur;
- NET_BUF *Fragment;
- NET_BUF *TmpPacket;
- NET_BUF *NewPacket;
- NET_BUF *Duplicate;
- UINT8 *DupHead;
- INTN Index;
- UINT16 UnFragmentLen;
- UINT8 *NextHeader;
+ EFI_IP6_HEADER *Head;
+ IP6_CLIP_INFO *This;
+ IP6_CLIP_INFO *Node;
+ IP6_ASSEMBLE_ENTRY *Assemble;
+ IP6_ASSEMBLE_ENTRY *Entry;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *Prev;
+ LIST_ENTRY *Cur;
+ NET_BUF *Fragment;
+ NET_BUF *TmpPacket;
+ NET_BUF *NewPacket;
+ NET_BUF *Duplicate;
+ UINT8 *DupHead;
+ INTN Index;
+ UINT16 UnFragmentLen;
+ UINT8 *NextHeader;
Head = Packet->Ip.Ip6;
This = IP6_GET_CLIP_INFO (Packet);
@@ -185,16 +185,17 @@ Ip6Reassemble ( //
// Find the corresponding assemble entry by (Dst, Src, Id)
//
- Assemble = NULL;
- Index = IP6_ASSEMBLE_HASH (&Head->DestinationAddress, &Head->SourceAddress, This->Id);
+ Assemble = NULL;
+ Index = IP6_ASSEMBLE_HASH (&Head->DestinationAddress, &Head->SourceAddress, This->Id);
NET_LIST_FOR_EACH (Cur, &Table->Bucket[Index]) {
Entry = NET_LIST_USER_STRUCT (Cur, IP6_ASSEMBLE_ENTRY, Link);
- if (Entry->Id == This->Id &&
+ if ((Entry->Id == This->Id) &&
EFI_IP6_EQUAL (&Entry->Src, &Head->SourceAddress) &&
EFI_IP6_EQUAL (&Entry->Dst, &Head->DestinationAddress)
- ) {
+ )
+ {
Assemble = Entry;
break;
}
@@ -239,8 +240,8 @@ Ip6Reassemble ( // overlaps, trim the overlapped part off THIS fragment.
//
if ((Prev = Cur->BackLink) != ListHead) {
- Fragment = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);
- Node = IP6_GET_CLIP_INFO (Fragment);
+ Fragment = NET_LIST_USER_STRUCT (Prev, NET_BUF, List);
+ Node = IP6_GET_CLIP_INFO (Fragment);
if (This->Start < Node->End) {
if (This->End <= Node->End) {
@@ -331,13 +332,13 @@ Ip6Reassemble ( //
DupHead = NetbufGetByte (Duplicate, 0, NULL);
ASSERT (DupHead != NULL);
- Duplicate->Ip.Ip6 = Ip6NtohHead ((EFI_IP6_HEADER *) DupHead);
+ Duplicate->Ip.Ip6 = Ip6NtohHead ((EFI_IP6_HEADER *)DupHead);
Assemble->Packet = Duplicate;
//
// Adjust the unfragmentable part in first fragment
//
- UnFragmentLen = (UINT16) (This->HeadLen - sizeof (EFI_IP6_HEADER));
+ UnFragmentLen = (UINT16)(This->HeadLen - sizeof (EFI_IP6_HEADER));
if (UnFragmentLen == 0) {
//
// There is not any unfragmentable extension header.
@@ -376,7 +377,6 @@ Ip6Reassemble ( // queue ends at the total length, all data is received.
//
if ((Assemble->TotalLen != 0) && (Assemble->CurLen >= Assemble->TotalLen)) {
-
RemoveEntryList (&Assemble->Link);
//
@@ -385,7 +385,7 @@ Ip6Reassemble ( // is a fake, drop it now.
//
Fragment = NET_LIST_USER_STRUCT (ListHead->BackLink, NET_BUF, List);
- if (IP6_GET_CLIP_INFO (Fragment)->End != (INTN) Assemble->TotalLen) {
+ if (IP6_GET_CLIP_INFO (Fragment)->End != (INTN)Assemble->TotalLen) {
Ip6FreeAssembleEntry (Assemble);
goto Error;
}
@@ -441,7 +441,6 @@ Error: return NULL;
}
-
/**
The callback function for the net buffer that wraps the packet processed by
IPsec. It releases the wrap packet and also signals IPsec to free the resources.
@@ -452,12 +451,12 @@ Error: VOID
EFIAPI
Ip6IpSecFree (
- IN VOID *Arg
+ IN VOID *Arg
)
{
- IP6_IPSEC_WRAP *Wrap;
+ IP6_IPSEC_WRAP *Wrap;
- Wrap = (IP6_IPSEC_WRAP *) Arg;
+ Wrap = (IP6_IPSEC_WRAP *)Arg;
if (Wrap->IpSecRecycleSignal != NULL) {
gBS->SignalEvent (Wrap->IpSecRecycleSignal);
@@ -506,24 +505,25 @@ Ip6IpSecProcessPacket ( IN VOID *Context
)
{
- NET_FRAGMENT *FragmentTable;
- NET_FRAGMENT *OriginalFragmentTable;
- UINT32 FragmentCount;
- UINT32 OriginalFragmentCount;
- EFI_EVENT RecycleEvent;
- NET_BUF *Packet;
- IP6_TXTOKEN_WRAP *TxWrap;
- IP6_IPSEC_WRAP *IpSecWrap;
- EFI_STATUS Status;
- EFI_IP6_HEADER *PacketHead;
- UINT8 *Buf;
- EFI_IP6_HEADER ZeroHead;
-
- Status = EFI_SUCCESS;
+ NET_FRAGMENT *FragmentTable;
+ NET_FRAGMENT *OriginalFragmentTable;
+ UINT32 FragmentCount;
+ UINT32 OriginalFragmentCount;
+ EFI_EVENT RecycleEvent;
+ NET_BUF *Packet;
+ IP6_TXTOKEN_WRAP *TxWrap;
+ IP6_IPSEC_WRAP *IpSecWrap;
+ EFI_STATUS Status;
+ EFI_IP6_HEADER *PacketHead;
+ UINT8 *Buf;
+ EFI_IP6_HEADER ZeroHead;
+
+ Status = EFI_SUCCESS;
if (!mIpSec2Installed) {
goto ON_EXIT;
}
+
ASSERT (mIpSec != NULL);
Packet = *Netbuf;
@@ -532,7 +532,7 @@ Ip6IpSecProcessPacket ( FragmentTable = NULL;
PacketHead = NULL;
Buf = NULL;
- TxWrap = (IP6_TXTOKEN_WRAP *) Context;
+ TxWrap = (IP6_TXTOKEN_WRAP *)Context;
FragmentCount = Packet->BlockOpNum;
ZeroMem (&ZeroHead, sizeof (EFI_IP6_HEADER));
@@ -552,7 +552,6 @@ Ip6IpSecProcessPacket ( IpSb->MaxPacketSize = IpSb->OldMaxPacketSize - IP6_MAX_IPSEC_HEADLEN;
}
-
//
// Bypass all multicast inbound or outbound traffic.
//
@@ -570,11 +569,11 @@ Ip6IpSecProcessPacket ( goto ON_EXIT;
}
- Status = NetbufBuildExt (Packet, FragmentTable, &FragmentCount);
+ Status = NetbufBuildExt (Packet, FragmentTable, &FragmentCount);
OriginalFragmentTable = FragmentTable;
OriginalFragmentCount = FragmentCount;
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
FreePool (FragmentTable);
goto ON_EXIT;
}
@@ -588,11 +587,11 @@ Ip6IpSecProcessPacket ( mIpSec,
IpSb->Controller,
IP_VERSION_6,
- (VOID *) (*Head),
+ (VOID *)(*Head),
LastHead,
- (VOID **) ExtHdrs,
+ (VOID **)ExtHdrs,
ExtHdrsLen,
- (EFI_IPSEC_FRAGMENT_DATA **) (&FragmentTable),
+ (EFI_IPSEC_FRAGMENT_DATA **)(&FragmentTable),
&FragmentCount,
Direction,
&RecycleEvent
@@ -607,7 +606,7 @@ Ip6IpSecProcessPacket ( goto ON_EXIT;
}
- if (OriginalFragmentCount == FragmentCount && OriginalFragmentTable == FragmentTable) {
+ if ((OriginalFragmentCount == FragmentCount) && (OriginalFragmentTable == FragmentTable)) {
//
// For ByPass Packet
//
@@ -620,7 +619,7 @@ Ip6IpSecProcessPacket ( FreePool (OriginalFragmentTable);
}
- if (Direction == EfiIPsecOutBound && TxWrap != NULL) {
+ if ((Direction == EfiIPsecOutBound) && (TxWrap != NULL)) {
TxWrap->IpSecRecycleSignal = RecycleEvent;
TxWrap->Packet = NetbufFromExt (
FragmentTable,
@@ -632,7 +631,7 @@ Ip6IpSecProcessPacket ( );
if (TxWrap->Packet == NULL) {
TxWrap->Packet = *Netbuf;
- Status = EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
@@ -642,11 +641,9 @@ Ip6IpSecProcessPacket ( sizeof (IP6_CLIP_INFO)
);
- NetIpSecNetbufFree(Packet);
+ NetIpSecNetbufFree (Packet);
*Netbuf = TxWrap->Packet;
-
} else {
-
IpSecWrap = AllocateZeroPool (sizeof (IP6_IPSEC_WRAP));
if (IpSecWrap == NULL) {
@@ -674,13 +671,12 @@ Ip6IpSecProcessPacket ( goto ON_EXIT;
}
- if (Direction == EfiIPsecInBound && 0 != CompareMem (&ZeroHead, *Head, sizeof (EFI_IP6_HEADER))) {
-
- PacketHead = (EFI_IP6_HEADER *) NetbufAllocSpace (
- Packet,
- sizeof (EFI_IP6_HEADER) + *ExtHdrsLen,
- NET_BUF_HEAD
- );
+ if ((Direction == EfiIPsecInBound) && (0 != CompareMem (&ZeroHead, *Head, sizeof (EFI_IP6_HEADER)))) {
+ PacketHead = (EFI_IP6_HEADER *)NetbufAllocSpace (
+ Packet,
+ sizeof (EFI_IP6_HEADER) + *ExtHdrsLen,
+ NET_BUF_HEAD
+ );
if (PacketHead == NULL) {
*Netbuf = Packet;
Status = EFI_OUT_OF_RESOURCES;
@@ -688,11 +684,11 @@ Ip6IpSecProcessPacket ( }
CopyMem (PacketHead, *Head, sizeof (EFI_IP6_HEADER));
- *Head = PacketHead;
+ *Head = PacketHead;
Packet->Ip.Ip6 = PacketHead;
if (*ExtHdrs != NULL) {
- Buf = (UINT8 *) (PacketHead + 1);
+ Buf = (UINT8 *)(PacketHead + 1);
CopyMem (Buf, *ExtHdrs, *ExtHdrsLen);
}
@@ -703,6 +699,7 @@ Ip6IpSecProcessPacket ( sizeof (IP6_CLIP_INFO)
);
}
+
*Netbuf = Packet;
}
@@ -733,25 +730,25 @@ ON_EXIT: **/
EFI_STATUS
Ip6PreProcessPacket (
- IN IP6_SERVICE *IpSb,
- IN OUT NET_BUF **Packet,
- IN UINT32 Flag,
- OUT UINT8 **Payload,
- OUT UINT8 **LastHead,
- OUT UINT32 *ExtHdrsLen,
- OUT UINT32 *UnFragmentLen,
- OUT BOOLEAN *Fragmented,
- OUT EFI_IP6_HEADER **Head
+ IN IP6_SERVICE *IpSb,
+ IN OUT NET_BUF **Packet,
+ IN UINT32 Flag,
+ OUT UINT8 **Payload,
+ OUT UINT8 **LastHead,
+ OUT UINT32 *ExtHdrsLen,
+ OUT UINT32 *UnFragmentLen,
+ OUT BOOLEAN *Fragmented,
+ OUT EFI_IP6_HEADER **Head
)
{
- UINT16 PayloadLen;
- UINT16 TotalLen;
- UINT32 FormerHeadOffset;
- UINT32 HeadLen;
- IP6_FRAGMENT_HEADER *FragmentHead;
- UINT16 FragmentOffset;
- IP6_CLIP_INFO *Info;
- EFI_IPv6_ADDRESS Loopback;
+ UINT16 PayloadLen;
+ UINT16 TotalLen;
+ UINT32 FormerHeadOffset;
+ UINT32 HeadLen;
+ IP6_FRAGMENT_HEADER *FragmentHead;
+ UINT16 FragmentOffset;
+ IP6_CLIP_INFO *Info;
+ EFI_IPv6_ADDRESS Loopback;
HeadLen = 0;
PayloadLen = 0;
@@ -765,7 +762,7 @@ Ip6PreProcessPacket ( //
// Get header information of the packet.
//
- *Head = (EFI_IP6_HEADER *) NetbufGetByte (*Packet, 0, NULL);
+ *Head = (EFI_IP6_HEADER *)NetbufGetByte (*Packet, 0, NULL);
if (*Head == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -783,7 +780,8 @@ Ip6PreProcessPacket ( ZeroMem (&Loopback, sizeof (EFI_IPv6_ADDRESS));
Loopback.Addr[15] = 0x1;
if ((CompareMem (&Loopback, &(*Head)->DestinationAddress, sizeof (EFI_IPv6_ADDRESS)) == 0) ||
- (NetIp6IsUnspecifiedAddr (&(*Head)->DestinationAddress))) {
+ (NetIp6IsUnspecifiedAddr (&(*Head)->DestinationAddress)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -818,17 +816,16 @@ Ip6PreProcessPacket ( return EFI_INVALID_PARAMETER;
}
-
PayloadLen = (*Head)->PayloadLength;
Info->Start = 0;
Info->Length = PayloadLen;
Info->End = Info->Start + Info->Length;
- Info->HeadLen = (UINT16) sizeof (EFI_IP6_HEADER);
+ Info->HeadLen = (UINT16)sizeof (EFI_IP6_HEADER);
Info->Status = EFI_SUCCESS;
Info->LastFrag = FALSE;
- TotalLen = (UINT16) (PayloadLen + sizeof (EFI_IP6_HEADER));
+ TotalLen = (UINT16)(PayloadLen + sizeof (EFI_IP6_HEADER));
//
// Mnp may deliver frame trailer sequence up, trim it off.
@@ -845,7 +842,7 @@ Ip6PreProcessPacket ( // Check the extension headers, if exist validate them
//
if (PayloadLen != 0) {
- *Payload = AllocatePool ((UINTN) PayloadLen);
+ *Payload = AllocatePool ((UINTN)PayloadLen);
if (*Payload == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -858,24 +855,25 @@ Ip6PreProcessPacket ( *Packet,
&(*Head)->NextHeader,
*Payload,
- (UINT32) PayloadLen,
+ (UINT32)PayloadLen,
TRUE,
&FormerHeadOffset,
LastHead,
ExtHdrsLen,
UnFragmentLen,
Fragmented
- )) {
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
- HeadLen = sizeof (EFI_IP6_HEADER) + *UnFragmentLen;
+ HeadLen = sizeof (EFI_IP6_HEADER) + *UnFragmentLen;
if (*Fragmented) {
//
// Get the fragment offset from the Fragment header
//
- FragmentHead = (IP6_FRAGMENT_HEADER *) NetbufGetByte (*Packet, HeadLen, NULL);
+ FragmentHead = (IP6_FRAGMENT_HEADER *)NetbufGetByte (*Packet, HeadLen, NULL);
if (FragmentHead == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -895,10 +893,10 @@ Ip6PreProcessPacket ( Info->NextHeader = FragmentHead->NextHeader;
}
- Info->HeadLen = (UINT16) HeadLen;
- HeadLen += sizeof (IP6_FRAGMENT_HEADER);
+ Info->HeadLen = (UINT16)HeadLen;
+ HeadLen += sizeof (IP6_FRAGMENT_HEADER);
Info->Start = FragmentOffset;
- Info->Length = TotalLen - (UINT16) HeadLen;
+ Info->Length = TotalLen - (UINT16)HeadLen;
Info->End = Info->Start + Info->Length;
Info->Id = FragmentHead->Identification;
Info->FormerNextHeader = FormerHeadOffset;
@@ -921,14 +919,14 @@ Ip6PreProcessPacket ( //
// Re-check the assembled packet to get the right values.
//
- *Head = (*Packet)->Ip.Ip6;
- PayloadLen = (*Head)->PayloadLength;
+ *Head = (*Packet)->Ip.Ip6;
+ PayloadLen = (*Head)->PayloadLength;
if (PayloadLen != 0) {
if (*Payload != NULL) {
FreePool (*Payload);
}
- *Payload = AllocatePool ((UINTN) PayloadLen);
+ *Payload = AllocatePool ((UINTN)PayloadLen);
if (*Payload == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -941,14 +939,15 @@ Ip6PreProcessPacket ( *Packet,
&(*Head)->NextHeader,
*Payload,
- (UINT32) PayloadLen,
+ (UINT32)PayloadLen,
TRUE,
NULL,
LastHead,
ExtHdrsLen,
UnFragmentLen,
Fragmented
- )) {
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -975,23 +974,23 @@ Ip6PreProcessPacket ( **/
VOID
Ip6AcceptFrame (
- IN NET_BUF *Packet,
- IN EFI_STATUS IoStatus,
- IN UINT32 Flag,
- IN VOID *Context
+ IN NET_BUF *Packet,
+ IN EFI_STATUS IoStatus,
+ IN UINT32 Flag,
+ IN VOID *Context
)
{
- IP6_SERVICE *IpSb;
- EFI_IP6_HEADER *Head;
- UINT8 *Payload;
- UINT8 *LastHead;
- UINT32 UnFragmentLen;
- UINT32 ExtHdrsLen;
- BOOLEAN Fragmented;
- EFI_STATUS Status;
- EFI_IP6_HEADER ZeroHead;
-
- IpSb = (IP6_SERVICE *) Context;
+ IP6_SERVICE *IpSb;
+ EFI_IP6_HEADER *Head;
+ UINT8 *Payload;
+ UINT8 *LastHead;
+ UINT32 UnFragmentLen;
+ UINT32 ExtHdrsLen;
+ BOOLEAN Fragmented;
+ EFI_STATUS Status;
+ EFI_IP6_HEADER ZeroHead;
+
+ IpSb = (IP6_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
Payload = NULL;
@@ -1021,6 +1020,7 @@ Ip6AcceptFrame ( if (EFI_ERROR (Status)) {
goto Restart;
}
+
//
// After trim off, the packet is a esp/ah/udp/tcp/icmp6 net buffer,
// and no need consider any other ahead ext headers.
@@ -1072,15 +1072,15 @@ Ip6AcceptFrame ( // Packet may have been changed. The ownership of the packet
// is transferred to the packet process logic.
//
- Head = Packet->Ip.Ip6;
+ Head = Packet->Ip.Ip6;
IP6_GET_CLIP_INFO (Packet)->Status = EFI_SUCCESS;
switch (*LastHead) {
- case IP6_ICMP:
- Ip6IcmpHandle (IpSb, Head, Packet);
- break;
- default:
- Ip6Demultiplex (IpSb, Head, Packet);
+ case IP6_ICMP:
+ Ip6IcmpHandle (IpSb, Head, Packet);
+ break;
+ default:
+ Ip6Demultiplex (IpSb, Head, Packet);
}
Packet = NULL;
@@ -1103,7 +1103,7 @@ Drop: NetbufFree (Packet);
}
- return ;
+ return;
}
/**
@@ -1115,10 +1115,10 @@ Drop: **/
VOID
Ip6CreateAssembleTable (
- IN OUT IP6_ASSEMBLE_TABLE *Table
+ IN OUT IP6_ASSEMBLE_TABLE *Table
)
{
- UINT32 Index;
+ UINT32 Index;
for (Index = 0; Index < IP6_ASSEMLE_HASH_SIZE; Index++) {
InitializeListHead (&Table->Bucket[Index]);
@@ -1134,13 +1134,13 @@ Ip6CreateAssembleTable ( **/
VOID
Ip6CleanAssembleTable (
- IN OUT IP6_ASSEMBLE_TABLE *Table
+ IN OUT IP6_ASSEMBLE_TABLE *Table
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_ASSEMBLE_ENTRY *Assemble;
- UINT32 Index;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_ASSEMBLE_ENTRY *Assemble;
+ UINT32 Index;
for (Index = 0; Index < IP6_ASSEMLE_HASH_SIZE; Index++) {
NET_LIST_FOR_EACH_SAFE (Entry, Next, &Table->Bucket[Index]) {
@@ -1152,7 +1152,6 @@ Ip6CleanAssembleTable ( }
}
-
/**
The signal handle of IP6's recycle event. It is called back
when the upper layer releases the packet.
@@ -1164,13 +1163,13 @@ Ip6CleanAssembleTable ( VOID
EFIAPI
Ip6OnRecyclePacket (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- IP6_RXDATA_WRAP *Wrap;
+ IP6_RXDATA_WRAP *Wrap;
- Wrap = (IP6_RXDATA_WRAP *) Context;
+ Wrap = (IP6_RXDATA_WRAP *)Context;
EfiAcquireLockOrFail (&Wrap->IpInstance->RecycleLock);
RemoveEntryList (&Wrap->Link);
@@ -1199,13 +1198,13 @@ Ip6OnRecyclePacket ( **/
IP6_RXDATA_WRAP *
Ip6WrapRxData (
- IN IP6_PROTOCOL *IpInstance,
- IN NET_BUF *Packet
+ IN IP6_PROTOCOL *IpInstance,
+ IN NET_BUF *Packet
)
{
- IP6_RXDATA_WRAP *Wrap;
- EFI_IP6_RECEIVE_DATA *RxData;
- EFI_STATUS Status;
+ IP6_RXDATA_WRAP *Wrap;
+ EFI_IP6_RECEIVE_DATA *RxData;
+ EFI_STATUS Status;
Wrap = AllocatePool (IP6_RXDATA_WRAP_SIZE (Packet->BlockOpNum));
@@ -1215,9 +1214,9 @@ Ip6WrapRxData ( InitializeListHead (&Wrap->Link);
- Wrap->IpInstance = IpInstance;
- Wrap->Packet = Packet;
- RxData = &Wrap->RxData;
+ Wrap->IpInstance = IpInstance;
+ Wrap->Packet = Packet;
+ RxData = &Wrap->RxData;
ZeroMem (&RxData->TimeStamp, sizeof (EFI_TIME));
@@ -1239,15 +1238,15 @@ Ip6WrapRxData ( //
// The application expects a network byte order header.
//
- RxData->HeaderLength = sizeof (EFI_IP6_HEADER);
- RxData->Header = (EFI_IP6_HEADER *) Ip6NtohHead (Packet->Ip.Ip6);
- RxData->DataLength = Packet->TotalSize;
+ RxData->HeaderLength = sizeof (EFI_IP6_HEADER);
+ RxData->Header = (EFI_IP6_HEADER *)Ip6NtohHead (Packet->Ip.Ip6);
+ 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;
}
@@ -1265,19 +1264,19 @@ Ip6WrapRxData ( **/
BOOLEAN
Ip6InstanceFrameAcceptable (
- IN IP6_PROTOCOL *IpInstance,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_PROTOCOL *IpInstance,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_ERROR_HEAD Icmp;
- EFI_IP6_CONFIG_DATA *Config;
- IP6_CLIP_INFO *Info;
- UINT8 *Proto;
- UINT32 Index;
- UINT8 *ExtHdrs;
- UINT16 ErrMsgPayloadLen;
- UINT8 *ErrMsgPayload;
+ IP6_ICMP_ERROR_HEAD Icmp;
+ EFI_IP6_CONFIG_DATA *Config;
+ IP6_CLIP_INFO *Info;
+ UINT8 *Proto;
+ UINT32 Index;
+ UINT8 *ExtHdrs;
+ UINT16 ErrMsgPayloadLen;
+ UINT8 *ErrMsgPayload;
Config = &IpInstance->ConfigData;
Proto = NULL;
@@ -1308,14 +1307,15 @@ Ip6InstanceFrameAcceptable ( Packet,
&Head->NextHeader,
ExtHdrs,
- (UINT32) Head->PayloadLength,
+ (UINT32)Head->PayloadLength,
TRUE,
NULL,
&Proto,
NULL,
NULL,
NULL
- )) {
+ ))
+ {
return FALSE;
}
@@ -1324,7 +1324,7 @@ Ip6InstanceFrameAcceptable ( // invoked by its packet, like UDP.
//
if ((*Proto == IP6_ICMP) && (!Config->AcceptAnyProtocol) && (*Proto != Config->DefaultProtocol)) {
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
if (Icmp.Head.Type <= ICMP_V6_ERROR_MAX) {
if (!Config->AcceptIcmpErrors) {
@@ -1349,7 +1349,8 @@ Ip6InstanceFrameAcceptable ( NULL,
NULL,
NULL
- )) {
+ ))
+ {
return FALSE;
}
}
@@ -1408,13 +1409,13 @@ Ip6InstanceFrameAcceptable ( **/
EFI_STATUS
Ip6InstanceEnquePacket (
- IN IP6_PROTOCOL *IpInstance,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_PROTOCOL *IpInstance,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_CLIP_INFO *Info;
- NET_BUF *Clone;
+ IP6_CLIP_INFO *Info;
+ NET_BUF *Clone;
//
// Check whether the packet is acceptable to this instance.
@@ -1440,8 +1441,8 @@ Ip6InstanceEnquePacket ( // Set the receive time out for the assembled packet. If it expires,
// packet will be removed from the queue.
//
- Info = IP6_GET_CLIP_INFO (Clone);
- Info->Life = IP6_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);
+ Info = IP6_GET_CLIP_INFO (Clone);
+ Info->Life = IP6_US_TO_SEC (IpInstance->ConfigData.ReceiveTimeout);
InsertTailList (&IpInstance->Received, &Clone->List);
return EFI_SUCCESS;
@@ -1463,7 +1464,7 @@ Ip6InstanceEnquePacket ( **/
EFI_STATUS
Ip6InstanceDeliverPacket (
- IN IP6_PROTOCOL *IpInstance
+ IN IP6_PROTOCOL *IpInstance
)
{
EFI_IP6_COMPLETION_TOKEN *Token;
@@ -1476,7 +1477,6 @@ Ip6InstanceDeliverPacket ( // Deliver a packet if there are both a packet and a receive token.
//
while (!IsListEmpty (&IpInstance->Received) && !NetMapIsEmpty (&IpInstance->RxTokens)) {
-
Packet = NET_LIST_HEAD (&IpInstance->Received, NET_BUF, List);
if (!NET_BUF_SHARED (Packet)) {
@@ -1490,7 +1490,6 @@ Ip6InstanceDeliverPacket ( }
RemoveEntryList (&Packet->List);
-
} else {
//
// Create a duplicated packet if this packet is shared
@@ -1506,9 +1505,9 @@ Ip6InstanceDeliverPacket ( // headless. Trim the head off after copy. The IP head
// may be not continuous before the data.
//
- Head = NetbufAllocSpace (Dup, sizeof (EFI_IP6_HEADER), NET_BUF_HEAD);
+ Head = NetbufAllocSpace (Dup, sizeof (EFI_IP6_HEADER), NET_BUF_HEAD);
ASSERT (Head != NULL);
- Dup->Ip.Ip6 = (EFI_IP6_HEADER *) Head;
+ Dup->Ip.Ip6 = (EFI_IP6_HEADER *)Head;
CopyMem (Head, Packet->Ip.Ip6, sizeof (EFI_IP6_HEADER));
NetbufTrim (Dup, sizeof (EFI_IP6_HEADER), TRUE);
@@ -1558,18 +1557,18 @@ Ip6InstanceDeliverPacket ( **/
INTN
Ip6InterfaceEnquePacket (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet,
- IN IP6_INTERFACE *IpIf
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet,
+ IN IP6_INTERFACE *IpIf
)
{
- IP6_PROTOCOL *IpInstance;
- IP6_CLIP_INFO *Info;
- LIST_ENTRY *Entry;
- INTN Enqueued;
- INTN LocalType;
- INTN SavedType;
+ IP6_PROTOCOL *IpInstance;
+ IP6_CLIP_INFO *Info;
+ LIST_ENTRY *Entry;
+ INTN Enqueued;
+ INTN LocalType;
+ INTN SavedType;
//
// First, check that the packet is acceptable to this interface
@@ -1590,10 +1589,10 @@ Ip6InterfaceEnquePacket ( // 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 = (UINT32) LocalType;
+ SavedType = Info->CastType;
+ Info->CastType = (UINT32)LocalType;
- Enqueued = 0;
+ Enqueued = 0;
NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
IpInstance = NET_LIST_USER_STRUCT (Entry, IP6_PROTOCOL, AddrLink);
@@ -1604,7 +1603,7 @@ Ip6InterfaceEnquePacket ( }
}
- Info->CastType = (UINT32) SavedType;
+ Info->CastType = (UINT32)SavedType;
return Enqueued;
}
@@ -1617,12 +1616,12 @@ Ip6InterfaceEnquePacket ( **/
VOID
Ip6InterfaceDeliverPacket (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *IpIf
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *IpIf
)
{
- IP6_PROTOCOL *IpInstance;
- LIST_ENTRY *Entry;
+ IP6_PROTOCOL *IpInstance;
+ LIST_ENTRY *Entry;
NET_LIST_FOR_EACH (Entry, &IpIf->IpInstances) {
IpInstance = NET_LIST_USER_STRUCT (Entry, IP6_PROTOCOL, AddrLink);
@@ -1650,15 +1649,14 @@ Ip6InterfaceDeliverPacket ( **/
EFI_STATUS
Ip6Demultiplex (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
-
- LIST_ENTRY *Entry;
- IP6_INTERFACE *IpIf;
- INTN Enqueued;
+ LIST_ENTRY *Entry;
+ IP6_INTERFACE *IpIf;
+ INTN Enqueued;
//
// Two pass delivery: first, enqueue a shared copy of the packet
@@ -1714,14 +1712,14 @@ Ip6Demultiplex ( EFI_STATUS
EFIAPI
Ip6SentPacketTicking (
- IN NET_MAP *Map,
- IN NET_MAP_ITEM *Item,
- IN VOID *Context
+ IN NET_MAP *Map,
+ IN NET_MAP_ITEM *Item,
+ IN VOID *Context
)
{
- IP6_TXTOKEN_WRAP *Wrap;
+ IP6_TXTOKEN_WRAP *Wrap;
- Wrap = (IP6_TXTOKEN_WRAP *) Item->Value;
+ Wrap = (IP6_TXTOKEN_WRAP *)Item->Value;
ASSERT (Wrap != NULL);
if ((Wrap->Life > 0) && (--Wrap->Life == 0)) {
@@ -1739,17 +1737,17 @@ Ip6SentPacketTicking ( **/
VOID
Ip6PacketTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- LIST_ENTRY *InstanceEntry;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_PROTOCOL *IpInstance;
- IP6_ASSEMBLE_ENTRY *Assemble;
- NET_BUF *Packet;
- IP6_CLIP_INFO *Info;
- UINT32 Index;
+ LIST_ENTRY *InstanceEntry;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_PROTOCOL *IpInstance;
+ IP6_ASSEMBLE_ENTRY *Assemble;
+ NET_BUF *Packet;
+ IP6_CLIP_INFO *Info;
+ UINT32 Index;
//
// First, time out the fragments. The packet's life is counting down
@@ -1766,7 +1764,8 @@ Ip6PacketTimerTicking ( // Time Exceeded message should be sent to the source of that fragment.
//
if ((Assemble->Packet != NULL) &&
- !IP6_IS_MULTICAST (&Assemble->Head->DestinationAddress)) {
+ !IP6_IS_MULTICAST (&Assemble->Head->DestinationAddress))
+ {
Ip6SendIcmpError (
IpSb,
Assemble->Packet,
@@ -1812,4 +1811,3 @@ Ip6PacketTimerTicking ( NetMapIterate (&IpInstance->TxTokens, Ip6SentPacketTicking, NULL);
}
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Input.h b/NetworkPkg/Ip6Dxe/Ip6Input.h index 76a4edb..5fcf4af 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Input.h +++ b/NetworkPkg/Ip6Dxe/Ip6Input.h @@ -10,23 +10,21 @@ #ifndef __EFI_IP6_INPUT_H__
#define __EFI_IP6_INPUT_H__
-#define IP6_MIN_HEADLEN 40
-#define IP6_MAX_HEADLEN 120
+#define IP6_MIN_HEADLEN 40
+#define IP6_MAX_HEADLEN 120
///
/// 8(ESP header) + 16(max IV) + 16(max padding) + 2(ESP tail) + 12(max ICV) = 54
///
-#define IP6_MAX_IPSEC_HEADLEN 54
+#define IP6_MAX_IPSEC_HEADLEN 54
-
-#define IP6_ASSEMLE_HASH_SIZE 127
+#define IP6_ASSEMLE_HASH_SIZE 127
///
/// Lift time in seconds.
///
-#define IP6_FRAGMENT_LIFE 60
-#define IP6_MAX_PACKET_SIZE 65535
-
+#define IP6_FRAGMENT_LIFE 60
+#define IP6_MAX_PACKET_SIZE 65535
-#define IP6_GET_CLIP_INFO(Packet) ((IP6_CLIP_INFO *) ((Packet)->ProtoData))
+#define IP6_GET_CLIP_INFO(Packet) ((IP6_CLIP_INFO *) ((Packet)->ProtoData))
#define IP6_ASSEMBLE_HASH(Dst, Src, Id) \
((*((UINT32 *) (Dst)) + *((UINT32 *) (Src)) + (Id)) % IP6_ASSEMLE_HASH_SIZE)
@@ -45,42 +43,42 @@ // life. If it isn't consumed before Life reaches zero, the packet is released.
//
typedef struct {
- UINT32 LinkFlag;
- INT32 CastType;
- INT32 Start;
- INT32 End;
- INT32 Length;
- UINT32 Life;
- EFI_STATUS Status;
- UINT32 Id;
- UINT16 HeadLen;
- UINT8 NextHeader;
- UINT8 LastFrag;
- UINT32 FormerNextHeader;
+ UINT32 LinkFlag;
+ INT32 CastType;
+ INT32 Start;
+ INT32 End;
+ INT32 Length;
+ UINT32 Life;
+ EFI_STATUS Status;
+ UINT32 Id;
+ UINT16 HeadLen;
+ UINT8 NextHeader;
+ UINT8 LastFrag;
+ UINT32 FormerNextHeader;
} IP6_CLIP_INFO;
//
// Structure used to assemble IP packets.
//
typedef struct {
- LIST_ENTRY Link;
- LIST_ENTRY Fragments; // List of all the fragments of this packet
+ LIST_ENTRY Link;
+ LIST_ENTRY Fragments; // List of all the fragments of this packet
//
// Identity of one IP6 packet. Each fragment of a packet has
// the same (Dst, Src, Id).
//
- EFI_IPv6_ADDRESS Dst;
- EFI_IPv6_ADDRESS Src;
- UINT32 Id;
+ EFI_IPv6_ADDRESS Dst;
+ EFI_IPv6_ADDRESS Src;
+ UINT32 Id;
- UINT32 TotalLen;
- UINT32 CurLen;
- UINT32 Life; // Count down life for the packet.
+ UINT32 TotalLen;
+ UINT32 CurLen;
+ UINT32 Life; // Count down life for the packet.
- EFI_IP6_HEADER *Head; // IP head of the first fragment
- IP6_CLIP_INFO *Info; // Per packet information of the first fragment
- NET_BUF *Packet; // The first fragment of the packet
+ EFI_IP6_HEADER *Head; // IP head of the first fragment
+ IP6_CLIP_INFO *Info; // Per packet information of the first fragment
+ NET_BUF *Packet; // The first fragment of the packet
} IP6_ASSEMBLE_ENTRY;
//
@@ -89,7 +87,7 @@ typedef struct { // as hash table.
//
typedef struct {
- LIST_ENTRY Bucket[IP6_ASSEMLE_HASH_SIZE];
+ LIST_ENTRY Bucket[IP6_ASSEMLE_HASH_SIZE];
} IP6_ASSEMBLE_TABLE;
/**
@@ -105,10 +103,10 @@ typedef struct { **/
VOID
Ip6AcceptFrame (
- IN NET_BUF *Packet,
- IN EFI_STATUS IoStatus,
- IN UINT32 Flag,
- IN VOID *Context
+ IN NET_BUF *Packet,
+ IN EFI_STATUS IoStatus,
+ IN UINT32 Flag,
+ IN VOID *Context
);
/**
@@ -127,7 +125,7 @@ Ip6AcceptFrame ( **/
EFI_STATUS
Ip6InstanceDeliverPacket (
- IN IP6_PROTOCOL *IpInstance
+ IN IP6_PROTOCOL *IpInstance
);
/**
@@ -175,7 +173,7 @@ Ip6IpSecProcessPacket ( **/
VOID
Ip6CreateAssembleTable (
- IN OUT IP6_ASSEMBLE_TABLE *Table
+ IN OUT IP6_ASSEMBLE_TABLE *Table
);
/**
@@ -187,7 +185,7 @@ Ip6CreateAssembleTable ( **/
VOID
Ip6CleanAssembleTable (
- IN OUT IP6_ASSEMBLE_TABLE *Table
+ IN OUT IP6_ASSEMBLE_TABLE *Table
);
/**
@@ -210,9 +208,9 @@ Ip6CleanAssembleTable ( **/
EFI_STATUS
Ip6Demultiplex (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
/**
@@ -223,7 +221,7 @@ Ip6Demultiplex ( **/
VOID
Ip6PacketTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
);
#endif
diff --git a/NetworkPkg/Ip6Dxe/Ip6Mld.c b/NetworkPkg/Ip6Dxe/Ip6Mld.c index ba12089..e6b2b65 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Mld.c +++ b/NetworkPkg/Ip6Dxe/Ip6Mld.c @@ -21,12 +21,12 @@ **/
IP6_MLD_GROUP *
Ip6CreateMldEntry (
- IN OUT IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *MulticastAddr,
- IN UINT32 DelayTimer
+ IN OUT IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *MulticastAddr,
+ IN UINT32 DelayTimer
)
{
- IP6_MLD_GROUP *Entry;
+ IP6_MLD_GROUP *Entry;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -54,12 +54,12 @@ Ip6CreateMldEntry ( **/
IP6_MLD_GROUP *
Ip6FindMldEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *MulticastAddr
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *MulticastAddr
)
{
- LIST_ENTRY *Entry;
- IP6_MLD_GROUP *Group;
+ LIST_ENTRY *Entry;
+ IP6_MLD_GROUP *Group;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -88,13 +88,13 @@ Ip6FindMldEntry ( **/
INTN
Ip6FindMac (
- IN IP6_MLD_SERVICE_DATA *MldCtrl,
- IN EFI_MAC_ADDRESS *Mac
+ IN IP6_MLD_SERVICE_DATA *MldCtrl,
+ IN EFI_MAC_ADDRESS *Mac
)
{
- LIST_ENTRY *Entry;
- IP6_MLD_GROUP *Group;
- INTN Count;
+ LIST_ENTRY *Entry;
+ IP6_MLD_GROUP *Group;
+ INTN Count;
Count = 0;
@@ -125,20 +125,20 @@ Ip6FindMac ( **/
EFI_STATUS
Ip6SendMldReport (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface OPTIONAL,
- IN EFI_IPv6_ADDRESS *MulticastAddr
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface OPTIONAL,
+ IN EFI_IPv6_ADDRESS *MulticastAddr
)
{
- IP6_MLD_HEAD *MldHead;
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- UINT16 PayloadLen;
- UINTN OptionLen;
- UINT8 *Options;
- EFI_STATUS Status;
- UINT16 HeadChecksum;
- UINT16 PseudoChecksum;
+ IP6_MLD_HEAD *MldHead;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ UINT16 PayloadLen;
+ UINTN OptionLen;
+ UINT8 *Options;
+ EFI_STATUS Status;
+ UINT16 HeadChecksum;
+ UINT16 PseudoChecksum;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -149,11 +149,11 @@ Ip6SendMldReport ( //
OptionLen = 0;
- Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
+ Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
- PayloadLen = (UINT16) (OptionLen + sizeof (IP6_MLD_HEAD));
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ PayloadLen = (UINT16)(OptionLen + sizeof (IP6_MLD_HEAD));
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -163,11 +163,11 @@ Ip6SendMldReport ( // RFC3590: Use link-local address as source address if it is available,
// otherwise use the unspecified address.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_HOP_BY_HOP;
- Head.HopLimit = 1;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_HOP_BY_HOP;
+ Head.HopLimit = 1;
IP6_COPY_ADDRESS (&Head.DestinationAddress, MulticastAddr);
//
@@ -180,7 +180,7 @@ Ip6SendMldReport ( //
// Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header
//
- Options = NetbufAllocSpace (Packet, (UINT32) OptionLen, FALSE);
+ Options = NetbufAllocSpace (Packet, (UINT32)OptionLen, FALSE);
ASSERT (Options != NULL);
Status = Ip6FillHopByHop (Options, &OptionLen, IP6_ICMP);
if (EFI_ERROR (Status)) {
@@ -192,14 +192,14 @@ Ip6SendMldReport ( //
// Fill in MLD message - Report
//
- MldHead = (IP6_MLD_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
+ MldHead = (IP6_MLD_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
ASSERT (MldHead != NULL);
ZeroMem (MldHead, sizeof (IP6_MLD_HEAD));
MldHead->Head.Type = ICMP_V6_LISTENER_REPORT;
MldHead->Head.Code = 0;
IP6_COPY_ADDRESS (&MldHead->Group, MulticastAddr);
- HeadChecksum = NetblockChecksum ((UINT8 *) MldHead, sizeof (IP6_MLD_HEAD));
+ HeadChecksum = NetblockChecksum ((UINT8 *)MldHead, sizeof (IP6_MLD_HEAD));
PseudoChecksum = NetIp6PseudoHeadChecksum (
&Head.SourceAddress,
&Head.DestinationAddress,
@@ -229,20 +229,20 @@ Ip6SendMldReport ( **/
EFI_STATUS
Ip6SendMldDone (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *MulticastAddr
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *MulticastAddr
)
{
- IP6_MLD_HEAD *MldHead;
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- UINT16 PayloadLen;
- UINTN OptionLen;
- UINT8 *Options;
- EFI_STATUS Status;
- EFI_IPv6_ADDRESS Destination;
- UINT16 HeadChecksum;
- UINT16 PseudoChecksum;
+ IP6_MLD_HEAD *MldHead;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ UINT16 PayloadLen;
+ UINTN OptionLen;
+ UINT8 *Options;
+ EFI_STATUS Status;
+ EFI_IPv6_ADDRESS Destination;
+ UINT16 HeadChecksum;
+ UINT16 PseudoChecksum;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr));
@@ -253,11 +253,11 @@ Ip6SendMldDone ( //
OptionLen = 0;
- Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
+ Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP);
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
- PayloadLen = (UINT16) (OptionLen + sizeof (IP6_MLD_HEAD));
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ PayloadLen = (UINT16)(OptionLen + sizeof (IP6_MLD_HEAD));
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -265,11 +265,11 @@ Ip6SendMldDone ( //
// Create the basic IPv6 header.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_HOP_BY_HOP;
- Head.HopLimit = 1;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_HOP_BY_HOP;
+ Head.HopLimit = 1;
//
// If Link-Local address is not ready, we use unspecified address.
@@ -284,7 +284,7 @@ Ip6SendMldDone ( //
// Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header
//
- Options = NetbufAllocSpace (Packet, (UINT32) OptionLen, FALSE);
+ Options = NetbufAllocSpace (Packet, (UINT32)OptionLen, FALSE);
ASSERT (Options != NULL);
Status = Ip6FillHopByHop (Options, &OptionLen, IP6_ICMP);
if (EFI_ERROR (Status)) {
@@ -296,14 +296,14 @@ Ip6SendMldDone ( //
// Fill in MLD message - Done
//
- MldHead = (IP6_MLD_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
+ MldHead = (IP6_MLD_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE);
ASSERT (MldHead != NULL);
ZeroMem (MldHead, sizeof (IP6_MLD_HEAD));
MldHead->Head.Type = ICMP_V6_LISTENER_DONE;
MldHead->Head.Code = 0;
IP6_COPY_ADDRESS (&MldHead->Group, MulticastAddr);
- HeadChecksum = NetblockChecksum ((UINT8 *) MldHead, sizeof (IP6_MLD_HEAD));
+ HeadChecksum = NetblockChecksum ((UINT8 *)MldHead, sizeof (IP6_MLD_HEAD));
PseudoChecksum = NetIp6PseudoHeadChecksum (
&Head.SourceAddress,
&Head.DestinationAddress,
@@ -332,12 +332,12 @@ Ip6SendMldDone ( **/
EFI_STATUS
Ip6InitMld (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- EFI_IPv6_ADDRESS AllNodes;
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ EFI_IPv6_ADDRESS AllNodes;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
//
// Join the link-scope all-nodes multicast address (FF02::1).
@@ -347,7 +347,7 @@ Ip6InitMld ( Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
- Group = Ip6CreateMldEntry (IpSb, &AllNodes, (UINT32) IP6_INFINIT_LIFETIME);
+ Group = Ip6CreateMldEntry (IpSb, &AllNodes, (UINT32)IP6_INFINIT_LIFETIME);
if (Group == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -388,11 +388,11 @@ ERROR: **/
EFI_STATUS
Ip6CombineGroups (
- IN OUT IP6_PROTOCOL *IpInstance,
- IN EFI_IPv6_ADDRESS *Group
+ IN OUT IP6_PROTOCOL *IpInstance,
+ IN EFI_IPv6_ADDRESS *Group
)
{
- EFI_IPv6_ADDRESS *GroupList;
+ EFI_IPv6_ADDRESS *GroupList;
NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
ASSERT (Group != NULL && IP6_IS_MULTICAST (Group));
@@ -437,12 +437,12 @@ Ip6CombineGroups ( **/
EFI_STATUS
Ip6RemoveGroup (
- IN OUT IP6_PROTOCOL *IpInstance,
- IN EFI_IPv6_ADDRESS *Group
+ IN OUT IP6_PROTOCOL *IpInstance,
+ IN EFI_IPv6_ADDRESS *Group
)
{
- UINT32 Index;
- UINT32 Count;
+ UINT32 Index;
+ UINT32 Count;
Count = IpInstance->GroupCount;
@@ -481,13 +481,13 @@ Ip6RemoveGroup ( **/
EFI_STATUS
Ip6JoinGroup (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface,
- IN EFI_IPv6_ADDRESS *Address
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface,
+ IN EFI_IPv6_ADDRESS *Address
)
{
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
Group = Ip6FindMldEntry (IpSb, Address);
if (Group != NULL) {
@@ -545,12 +545,12 @@ ERROR: **/
EFI_STATUS
Ip6LeaveGroup (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Address
)
{
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
Group = Ip6FindMldEntry (IpSb, Address);
if (Group == NULL) {
@@ -611,15 +611,15 @@ Ip6LeaveGroup ( **/
EFI_STATUS
Ip6Groups (
- IN IP6_PROTOCOL *IpInstance,
- IN BOOLEAN JoinFlag,
- IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
+ IN IP6_PROTOCOL *IpInstance,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
)
{
- EFI_STATUS Status;
- IP6_SERVICE *IpSb;
- UINT32 Index;
- EFI_IPv6_ADDRESS *Group;
+ EFI_STATUS Status;
+ IP6_SERVICE *IpSb;
+ UINT32 Index;
+ EFI_IPv6_ADDRESS *Group;
IpSb = IpInstance->Service;
@@ -690,13 +690,13 @@ Ip6Groups ( **/
EFI_STATUS
Ip6UpdateDelayTimer (
- IN IP6_SERVICE *IpSb,
- IN UINT16 MaxRespDelay,
- IN EFI_IPv6_ADDRESS *MulticastAddr,
- IN OUT IP6_MLD_GROUP *Group
+ IN IP6_SERVICE *IpSb,
+ IN UINT16 MaxRespDelay,
+ IN EFI_IPv6_ADDRESS *MulticastAddr,
+ IN OUT IP6_MLD_GROUP *Group
)
{
- UINT32 Delay;
+ UINT32 Delay;
//
// If the Query packet specifies a Maximum Response Delay of zero, perform timer
@@ -707,14 +707,14 @@ Ip6UpdateDelayTimer ( return Ip6SendMldReport (IpSb, NULL, MulticastAddr);
}
- Delay = (UINT32) (MaxRespDelay / 1000);
+ Delay = (UINT32)(MaxRespDelay / 1000);
//
// Sets a delay timer to a random value selected from the range [0, Maximum Response Delay]
// If a timer is already running, resets it if the request Maximum Response Delay
// is less than the remaining value of the running timer.
//
- if (Group->DelayTimer == 0 || Delay < Group->DelayTimer) {
+ if ((Group->DelayTimer == 0) || (Delay < Group->DelayTimer)) {
Group->DelayTimer = Delay / 4294967295UL * NET_RANDOM (NetRandomInitSeed ());
}
@@ -736,16 +736,16 @@ Ip6UpdateDelayTimer ( **/
EFI_STATUS
Ip6ProcessMldQuery (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- EFI_IPv6_ADDRESS AllNodes;
- IP6_MLD_GROUP *Group;
- IP6_MLD_HEAD MldPacket;
- LIST_ENTRY *Entry;
- EFI_STATUS Status;
+ EFI_IPv6_ADDRESS AllNodes;
+ IP6_MLD_GROUP *Group;
+ IP6_MLD_HEAD MldPacket;
+ LIST_ENTRY *Entry;
+ EFI_STATUS Status;
Status = EFI_INVALID_PARAMETER;
@@ -756,14 +756,14 @@ Ip6ProcessMldQuery ( goto Exit;
}
- if (Head->HopLimit != 1 || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
+ if ((Head->HopLimit != 1) || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
goto Exit;
}
//
// The Packet points to MLD report raw data without Hop-By-Hop option.
//
- NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *) &MldPacket);
+ NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *)&MldPacket);
MldPacket.MaxRespDelay = NTOHS (MldPacket.MaxRespDelay);
Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes);
@@ -774,6 +774,7 @@ Ip6ProcessMldQuery ( if (!EFI_IP6_EQUAL (&Head->DestinationAddress, &MldPacket.Group)) {
goto Exit;
}
+
//
// The node is not listening but it receives the specific query. Just return.
//
@@ -824,14 +825,14 @@ Exit: **/
EFI_STATUS
Ip6ProcessMldReport (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_MLD_HEAD MldPacket;
- IP6_MLD_GROUP *Group;
- EFI_STATUS Status;
+ IP6_MLD_HEAD MldPacket;
+ IP6_MLD_GROUP *Group;
+ EFI_STATUS Status;
Status = EFI_INVALID_PARAMETER;
@@ -842,14 +843,14 @@ Ip6ProcessMldReport ( goto Exit;
}
- if (Head->HopLimit != 1 || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
+ if ((Head->HopLimit != 1) || !IP6_IS_MULTICAST (&Head->DestinationAddress)) {
goto Exit;
}
//
// The Packet points to MLD report raw data without Hop-By-Hop option.
//
- NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *) &MldPacket);
+ NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *)&MldPacket);
if (!EFI_IP6_EQUAL (&Head->DestinationAddress, &MldPacket.Group)) {
goto Exit;
}
@@ -883,11 +884,11 @@ Exit: **/
VOID
Ip6MldTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- IP6_MLD_GROUP *Group;
- LIST_ENTRY *Entry;
+ IP6_MLD_GROUP *Group;
+ LIST_ENTRY *Entry;
//
// Send solicited report when timer expires
@@ -899,4 +900,3 @@ Ip6MldTimerTicking ( }
}
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Mld.h b/NetworkPkg/Ip6Dxe/Ip6Mld.h index 89dd6c2..0b1fa21 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Mld.h +++ b/NetworkPkg/Ip6Dxe/Ip6Mld.h @@ -10,14 +10,14 @@ #ifndef __EFI_IP6_MLD_H__
#define __EFI_IP6_MLD_H__
-#define IP6_UNSOLICITED_REPORT_INTERVAL 10
+#define IP6_UNSOLICITED_REPORT_INTERVAL 10
#pragma pack(1)
typedef struct {
- IP6_ICMP_HEAD Head;
- UINT16 MaxRespDelay;
- UINT16 Reserved;
- EFI_IPv6_ADDRESS Group;
+ IP6_ICMP_HEAD Head;
+ UINT16 MaxRespDelay;
+ UINT16 Reserved;
+ EFI_IPv6_ADDRESS Group;
} IP6_MLD_HEAD;
#pragma pack()
@@ -28,12 +28,12 @@ typedef struct { // "idle listener" state.
//
typedef struct {
- LIST_ENTRY Link;
- INTN RefCnt;
- EFI_IPv6_ADDRESS Address;
- UINT32 DelayTimer;
- BOOLEAN SendByUs;
- EFI_MAC_ADDRESS Mac;
+ LIST_ENTRY Link;
+ INTN RefCnt;
+ EFI_IPv6_ADDRESS Address;
+ UINT32 DelayTimer;
+ BOOLEAN SendByUs;
+ EFI_MAC_ADDRESS Mac;
} IP6_MLD_GROUP;
//
@@ -42,8 +42,8 @@ typedef struct { // connected network is v1 or v2.
//
typedef struct {
- INTN Mldv1QuerySeen;
- LIST_ENTRY Groups;
+ INTN Mldv1QuerySeen;
+ LIST_ENTRY Groups;
} IP6_MLD_SERVICE_DATA;
/**
@@ -57,8 +57,8 @@ typedef struct { **/
IP6_MLD_GROUP *
Ip6FindMldEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *MulticastAddr
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *MulticastAddr
);
/**
@@ -74,7 +74,7 @@ Ip6FindMldEntry ( **/
EFI_STATUS
Ip6InitMld (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
);
/**
@@ -91,9 +91,9 @@ Ip6InitMld ( **/
EFI_STATUS
Ip6JoinGroup (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface,
- IN EFI_IPv6_ADDRESS *Address
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface,
+ IN EFI_IPv6_ADDRESS *Address
);
/**
@@ -109,8 +109,8 @@ Ip6JoinGroup ( **/
EFI_STATUS
Ip6LeaveGroup (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Address
);
/**
@@ -131,9 +131,9 @@ Ip6LeaveGroup ( **/
EFI_STATUS
Ip6Groups (
- IN IP6_PROTOCOL *IpInstance,
- IN BOOLEAN JoinFlag,
- IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
+ IN IP6_PROTOCOL *IpInstance,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL
);
/**
@@ -151,9 +151,9 @@ Ip6Groups ( **/
EFI_STATUS
Ip6ProcessMldQuery (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
/**
@@ -170,12 +170,11 @@ Ip6ProcessMldQuery ( **/
EFI_STATUS
Ip6ProcessMldReport (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
-
/**
The heartbeat timer of the MLD module. It sends out solicited MLD report when
DelayTimer expires.
@@ -185,8 +184,7 @@ Ip6ProcessMldReport ( **/
VOID
Ip6MldTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
);
#endif
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.c b/NetworkPkg/Ip6Dxe/Ip6Nd.c index 0780a98..c10c701 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Nd.c +++ b/NetworkPkg/Ip6Dxe/Ip6Nd.c @@ -9,7 +9,7 @@ #include "Ip6Impl.h"
-EFI_MAC_ADDRESS mZeroMacAddress;
+EFI_MAC_ADDRESS mZeroMacAddress;
/**
Update the ReachableTime in IP6 service binding instance data, in milliseconds.
@@ -22,10 +22,10 @@ Ip6UpdateReachableTime ( IN OUT IP6_SERVICE *IpSb
)
{
- UINT32 Random;
+ UINT32 Random;
- Random = (NetRandomInitSeed () / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE;
- Random = Random + IP6_MIN_RANDOM_FACTOR_SCALED;
+ Random = (NetRandomInitSeed () / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE;
+ Random = Random + IP6_MIN_RANDOM_FACTOR_SCALED;
IpSb->ReachableTime = (IpSb->BaseReachableTime * Random) / IP6_RANDOM_FACTOR_SCALE;
}
@@ -43,17 +43,17 @@ Ip6UpdateReachableTime ( **/
EFI_STATUS
Ip6BuildEfiNeighborCache (
- IN IP6_PROTOCOL *IpInstance,
- OUT UINT32 *NeighborCount,
- OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache
+ IN IP6_PROTOCOL *IpInstance,
+ OUT UINT32 *NeighborCount,
+ OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache
)
{
- IP6_NEIGHBOR_ENTRY *Neighbor;
- LIST_ENTRY *Entry;
- IP6_SERVICE *IpSb;
- UINT32 Count;
- EFI_IP6_NEIGHBOR_CACHE *EfiNeighborCache;
- EFI_IP6_NEIGHBOR_CACHE *NeighborCacheTmp;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
+ LIST_ENTRY *Entry;
+ IP6_SERVICE *IpSb;
+ UINT32 Count;
+ EFI_IP6_NEIGHBOR_CACHE *EfiNeighborCache;
+ EFI_IP6_NEIGHBOR_CACHE *NeighborCacheTmp;
NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
ASSERT (NeighborCount != NULL && NeighborCache != NULL);
@@ -82,7 +82,7 @@ Ip6BuildEfiNeighborCache ( EfiNeighborCache = NeighborCacheTmp + Count;
- EfiNeighborCache->State = Neighbor->State;
+ EfiNeighborCache->State = Neighbor->State;
IP6_COPY_ADDRESS (&EfiNeighborCache->Neighbor, &Neighbor->Neighbor);
IP6_COPY_LINK_ADDRESS (&EfiNeighborCache->LinkAddress, &Neighbor->LinkAddress);
@@ -114,12 +114,12 @@ Ip6BuildPrefixTable ( OUT EFI_IP6_ADDRESS_INFO **PrefixTable
)
{
- LIST_ENTRY *Entry;
- IP6_SERVICE *IpSb;
- UINT32 Count;
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- EFI_IP6_ADDRESS_INFO *EfiPrefix;
- EFI_IP6_ADDRESS_INFO *PrefixTableTmp;
+ LIST_ENTRY *Entry;
+ IP6_SERVICE *IpSb;
+ UINT32 Count;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ EFI_IP6_ADDRESS_INFO *EfiPrefix;
+ EFI_IP6_ADDRESS_INFO *PrefixTableTmp;
NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE);
ASSERT (PrefixCount != NULL && PrefixTable != NULL);
@@ -178,21 +178,21 @@ Ip6BuildPrefixTable ( **/
IP6_PREFIX_LIST_ENTRY *
Ip6CreatePrefixListEntry (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN OnLinkOrAuto,
- IN UINT32 ValidLifetime,
- IN UINT32 PreferredLifetime,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *Prefix
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN OnLinkOrAuto,
+ IN UINT32 ValidLifetime,
+ IN UINT32 PreferredLifetime,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *Prefix
)
{
- IP6_PREFIX_LIST_ENTRY *PrefixEntry;
- IP6_ROUTE_ENTRY *RtEntry;
- LIST_ENTRY *ListHead;
- LIST_ENTRY *Entry;
- IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry;
+ IP6_PREFIX_LIST_ENTRY *PrefixEntry;
+ IP6_ROUTE_ENTRY *RtEntry;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *Entry;
+ IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry;
- if (Prefix == NULL || PreferredLifetime > ValidLifetime || PrefixLength > IP6_PREFIX_MAX) {
+ if ((Prefix == NULL) || (PreferredLifetime > ValidLifetime) || (PrefixLength > IP6_PREFIX_MAX)) {
return NULL;
}
@@ -205,7 +205,7 @@ Ip6CreatePrefixListEntry ( Prefix
);
if (PrefixEntry != NULL) {
- PrefixEntry->RefCnt ++;
+ PrefixEntry->RefCnt++;
return PrefixEntry;
}
@@ -242,7 +242,7 @@ Ip6CreatePrefixListEntry ( // is put ahead in the list.
//
NET_LIST_FOR_EACH (Entry, ListHead) {
- TmpPrefixEntry = NET_LIST_USER_STRUCT(Entry, IP6_PREFIX_LIST_ENTRY, Link);
+ TmpPrefixEntry = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
if (TmpPrefixEntry->PrefixLength < PrefixEntry->PrefixLength) {
break;
@@ -274,26 +274,26 @@ Ip6DestroyPrefixListEntry ( IN BOOLEAN ImmediateDelete
)
{
- LIST_ENTRY *Entry;
- IP6_INTERFACE *IpIf;
- EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ IP6_INTERFACE *IpIf;
+ EFI_STATUS Status;
if ((!ImmediateDelete) && (PrefixEntry->RefCnt > 0) && ((--PrefixEntry->RefCnt) > 0)) {
- return ;
+ return;
}
if (OnLinkOrAuto) {
- //
- // Remove the direct route for onlink prefix from route table.
- //
- do {
- Status = Ip6DelRoute (
- IpSb->RouteTable,
- &PrefixEntry->Prefix,
- PrefixEntry->PrefixLength,
- NULL
- );
- } while (Status != EFI_NOT_FOUND);
+ //
+ // Remove the direct route for onlink prefix from route table.
+ //
+ do {
+ Status = Ip6DelRoute (
+ IpSb->RouteTable,
+ &PrefixEntry->Prefix,
+ PrefixEntry->PrefixLength,
+ NULL
+ );
+ } while (Status != EFI_NOT_FOUND);
} else {
//
// Remove the corresponding addresses generated from this autonomous prefix.
@@ -324,15 +324,15 @@ Ip6DestroyPrefixListEntry ( **/
IP6_PREFIX_LIST_ENTRY *
Ip6FindPrefixListEntry (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN OnLinkOrAuto,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *Prefix
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN OnLinkOrAuto,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *Prefix
)
{
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- LIST_ENTRY *Entry;
- LIST_ENTRY *ListHead;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *ListHead;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Prefix != NULL);
@@ -349,8 +349,9 @@ Ip6FindPrefixListEntry ( //
// Perform exactly prefix match.
//
- if (PrefixList->PrefixLength == PrefixLength &&
- NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength)) {
+ if ((PrefixList->PrefixLength == PrefixLength) &&
+ NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength))
+ {
return PrefixList;
}
} else {
@@ -377,14 +378,14 @@ Ip6FindPrefixListEntry ( **/
VOID
Ip6CleanPrefixListTable (
- IN IP6_SERVICE *IpSb,
- IN LIST_ENTRY *ListHead
+ IN IP6_SERVICE *IpSb,
+ IN LIST_ENTRY *ListHead
)
{
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- BOOLEAN OnLink;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ BOOLEAN OnLink;
- OnLink = (BOOLEAN) (ListHead == &IpSb->OnlinkPrefix);
+ OnLink = (BOOLEAN)(ListHead == &IpSb->OnlinkPrefix);
while (!IsListEmpty (ListHead)) {
PrefixList = NET_LIST_HEAD (ListHead, IP6_PREFIX_LIST_ENTRY, Link);
@@ -402,25 +403,25 @@ Ip6CleanPrefixListTable ( **/
VOID
Ip6OnArpResolved (
- IN VOID *Context
+ IN VOID *Context
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_NEIGHBOR_ENTRY *ArpQue;
- IP6_SERVICE *IpSb;
- IP6_LINK_TX_TOKEN *Token;
- EFI_STATUS Status;
- BOOLEAN Sent;
-
- ArpQue = (IP6_NEIGHBOR_ENTRY *) Context;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_NEIGHBOR_ENTRY *ArpQue;
+ IP6_SERVICE *IpSb;
+ IP6_LINK_TX_TOKEN *Token;
+ EFI_STATUS Status;
+ BOOLEAN Sent;
+
+ ArpQue = (IP6_NEIGHBOR_ENTRY *)Context;
if ((ArpQue == NULL) || (ArpQue->Interface == NULL)) {
- return ;
+ return;
}
- IpSb = ArpQue->Interface->Service;
+ IpSb = ArpQue->Interface->Service;
if ((IpSb == NULL) || (IpSb->Signature != IP6_SERVICE_SIGNATURE)) {
- return ;
+ return;
}
//
@@ -430,7 +431,7 @@ Ip6OnArpResolved ( //
if (NET_MAC_EQUAL (&ArpQue->LinkAddress, &mZeroMacAddress, IpSb->SnpMode.HwAddressSize)) {
Ip6FreeNeighborEntry (IpSb, ArpQue, FALSE, TRUE, EFI_NO_MAPPING, NULL, NULL);
- return ;
+ return;
}
//
@@ -471,7 +472,7 @@ Ip6OnArpResolved ( if (Sent && (ArpQue->State == EfiNeighborStale)) {
ArpQue->State = EfiNeighborDelay;
- ArpQue->Ticks = (UINT32) IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
+ ArpQue->Ticks = (UINT32)IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME);
}
}
@@ -491,17 +492,17 @@ Ip6OnArpResolved ( **/
IP6_NEIGHBOR_ENTRY *
Ip6CreateNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN IP6_ARP_CALLBACK CallBack,
- IN EFI_IPv6_ADDRESS *Ip6Address,
- IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_ARP_CALLBACK CallBack,
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL
)
{
- IP6_NEIGHBOR_ENTRY *Entry;
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_NEIGHBOR_ENTRY *Entry;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
- ASSERT (Ip6Address!= NULL);
+ ASSERT (Ip6Address != NULL);
Entry = AllocateZeroPool (sizeof (IP6_NEIGHBOR_ENTRY));
if (Entry == NULL) {
@@ -552,13 +553,13 @@ Ip6CreateNeighborEntry ( **/
IP6_NEIGHBOR_ENTRY *
Ip6FindNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Ip6Address != NULL);
@@ -599,25 +600,25 @@ Ip6FindNeighborEntry ( **/
EFI_STATUS
Ip6FreeNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN IP6_NEIGHBOR_ENTRY *NeighborCache,
- IN BOOLEAN SendIcmpError,
- IN BOOLEAN FullFree,
- IN EFI_STATUS IoStatus,
- IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_NEIGHBOR_ENTRY *NeighborCache,
+ IN BOOLEAN SendIcmpError,
+ IN BOOLEAN FullFree,
+ IN EFI_STATUS IoStatus,
+ IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
+ IN VOID *Context OPTIONAL
)
{
- IP6_LINK_TX_TOKEN *TxToken;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_LINK_TX_TOKEN *TxToken;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
//
// If FrameToCancel fails, the token will not be released.
// To avoid the memory leak, stop this usage model.
//
- if (FullFree && FrameToCancel != NULL) {
+ if (FullFree && (FrameToCancel != NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -677,13 +678,13 @@ Ip6FreeNeighborEntry ( **/
IP6_DEFAULT_ROUTER *
Ip6CreateDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address,
- IN UINT16 RouterLifetime
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ IN UINT16 RouterLifetime
)
{
- IP6_DEFAULT_ROUTER *Entry;
- IP6_ROUTE_ENTRY *RtEntry;
+ IP6_DEFAULT_ROUTER *Entry;
+ IP6_ROUTE_ENTRY *RtEntry;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Ip6Address != NULL);
@@ -724,11 +725,11 @@ Ip6CreateDefaultRouter ( **/
VOID
Ip6DestroyDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN IP6_DEFAULT_ROUTER *DefaultRouter
+ IN IP6_SERVICE *IpSb,
+ IN IP6_DEFAULT_ROUTER *DefaultRouter
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
RemoveEntryList (&DefaultRouter->Link);
@@ -751,10 +752,10 @@ Ip6DestroyDefaultRouter ( **/
VOID
Ip6CleanDefaultRouterList (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
while (!IsListEmpty (&IpSb->DefaultRouterList)) {
DefaultRouter = NET_LIST_HEAD (&IpSb->DefaultRouterList, IP6_DEFAULT_ROUTER, Link);
@@ -774,12 +775,12 @@ Ip6CleanDefaultRouterList ( **/
IP6_DEFAULT_ROUTER *
Ip6FindDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address
)
{
- LIST_ENTRY *Entry;
- IP6_DEFAULT_ROUTER *DefaultRouter;
+ LIST_ENTRY *Entry;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Ip6Address != NULL);
@@ -846,10 +847,10 @@ Ip6OnDADFinished ( // Set the exta options to send. Here we only want the option request option
// with DNS SERVERS.
//
- Oro = (EFI_DHCP6_PACKET_OPTION *) OptBuf;
- Oro->OpCode = HTONS (DHCP6_OPT_ORO);
- Oro->OpLen = HTONS (2);
- *((UINT16 *) &Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS);
+ Oro = (EFI_DHCP6_PACKET_OPTION *)OptBuf;
+ Oro->OpCode = HTONS (DHCP6_OPT_ORO);
+ Oro->OpLen = HTONS (2);
+ *((UINT16 *)&Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS);
InfoReqReXmit.Irt = 4;
InfoReqReXmit.Mrc = 64;
@@ -875,12 +876,11 @@ Ip6OnDADFinished ( Ip6CreatePrefixListEntry (
IpSb,
TRUE,
- (UINT32) IP6_INFINIT_LIFETIME,
- (UINT32) IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
+ (UINT32)IP6_INFINIT_LIFETIME,
IP6_LINK_LOCAL_PREFIX_LENGTH,
&IpSb->LinkLocalAddr
);
-
} else {
//
// Global scope unicast address.
@@ -928,7 +928,7 @@ Ip6OnDADFinished ( IpSb->Mnp->Configure (IpSb->Mnp, NULL);
gBS->SetTimer (IpSb->Timer, TimerCancel, 0);
gBS->SetTimer (IpSb->FasterTimer, TimerCancel, 0);
- return ;
+ return;
}
if (!IsDadPassed || NetIp6IsLinkLocalAddr (&AddrInfo->Address)) {
@@ -961,10 +961,10 @@ Ip6OnDADFinished ( **/
EFI_STATUS
Ip6InitDADProcess (
- IN IP6_INTERFACE *IpIf,
- IN IP6_ADDRESS_INFO *AddressInfo,
- IN IP6_DAD_CALLBACK Callback OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *IpIf,
+ IN IP6_ADDRESS_INFO *AddressInfo,
+ IN IP6_DAD_CALLBACK Callback OPTIONAL,
+ IN VOID *Context OPTIONAL
)
{
IP6_DAD_ENTRY *Entry;
@@ -1009,15 +1009,15 @@ Ip6InitDADProcess ( return Status;
}
- Entry->Signature = IP6_DAD_ENTRY_SIGNATURE;
- Entry->MaxTransmit = DadXmits->DupAddrDetectTransmits;
- Entry->Transmit = 0;
- Entry->Receive = 0;
- MaxDelayTick = IP6_MAX_RTR_SOLICITATION_DELAY / IP6_TIMER_INTERVAL_IN_MS;
- Entry->RetransTick = (MaxDelayTick * ((NET_RANDOM (NetRandomInitSeed ()) % 5) + 1)) / 5;
- Entry->AddressInfo = AddressInfo;
- Entry->Callback = Callback;
- Entry->Context = Context;
+ Entry->Signature = IP6_DAD_ENTRY_SIGNATURE;
+ Entry->MaxTransmit = DadXmits->DupAddrDetectTransmits;
+ Entry->Transmit = 0;
+ Entry->Receive = 0;
+ MaxDelayTick = IP6_MAX_RTR_SOLICITATION_DELAY / IP6_TIMER_INTERVAL_IN_MS;
+ Entry->RetransTick = (MaxDelayTick * ((NET_RANDOM (NetRandomInitSeed ()) % 5) + 1)) / 5;
+ Entry->AddressInfo = AddressInfo;
+ Entry->Callback = Callback;
+ Entry->Context = Context;
InsertTailList (&IpIf->DupAddrDetectList, &Entry->Link);
if (Entry->MaxTransmit == 0) {
@@ -1044,16 +1044,16 @@ Ip6InitDADProcess ( **/
IP6_DAD_ENTRY *
Ip6FindDADEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Target,
- OUT IP6_INTERFACE **Interface OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Target,
+ OUT IP6_INTERFACE **Interface OPTIONAL
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Entry2;
- IP6_INTERFACE *IpIf;
- IP6_DAD_ENTRY *DupAddrDetect;
- IP6_ADDRESS_INFO *AddrInfo;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry2;
+ IP6_INTERFACE *IpIf;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ IP6_ADDRESS_INFO *AddrInfo;
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
IpIf = NET_LIST_USER_STRUCT (Entry, IP6_INTERFACE, Link);
@@ -1065,6 +1065,7 @@ Ip6FindDADEntry ( if (Interface != NULL) {
*Interface = IpIf;
}
+
return DupAddrDetect;
}
}
@@ -1093,24 +1094,24 @@ Ip6FindDADEntry ( **/
EFI_STATUS
Ip6SendRouterSolicit (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface OPTIONAL,
- IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
- IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL,
- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface OPTIONAL,
+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
+ IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL,
+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
)
{
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- IP6_ICMP_INFORMATION_HEAD *IcmpHead;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- UINT16 PayloadLen;
- IP6_INTERFACE *IpIf;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ IP6_ICMP_INFORMATION_HEAD *IcmpHead;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ UINT16 PayloadLen;
+ IP6_INTERFACE *IpIf;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
IpIf = Interface;
- if (IpIf == NULL && IpSb->DefaultInterface != NULL) {
+ if ((IpIf == NULL) && (IpSb->DefaultInterface != NULL)) {
IpIf = IpSb->DefaultInterface;
}
@@ -1118,12 +1119,12 @@ Ip6SendRouterSolicit ( // Generate the packet to be sent
//
- PayloadLen = (UINT16) sizeof (IP6_ICMP_INFORMATION_HEAD);
+ PayloadLen = (UINT16)sizeof (IP6_ICMP_INFORMATION_HEAD);
if (SourceLinkAddress != NULL) {
PayloadLen += sizeof (IP6_ETHER_ADDR_OPTION);
}
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1131,11 +1132,11 @@ Ip6SendRouterSolicit ( //
// Create the basic IPv6 header.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_ICMP;
- Head.HopLimit = IP6_HOP_LIMIT;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_ICMP;
+ Head.HopLimit = IP6_HOP_LIMIT;
if (SourceAddress != NULL) {
IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress);
@@ -1143,7 +1144,6 @@ Ip6SendRouterSolicit ( ZeroMem (&Head.SourceAddress, sizeof (EFI_IPv6_ADDRESS));
}
-
if (DestinationAddress != NULL) {
IP6_COPY_ADDRESS (&Head.DestinationAddress, DestinationAddress);
} else {
@@ -1156,7 +1156,7 @@ Ip6SendRouterSolicit ( // Fill in the ICMP header, and Source link-layer address if contained.
//
- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
ASSERT (IcmpHead != NULL);
ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD));
IcmpHead->Head.Type = ICMP_V6_ROUTER_SOLICIT;
@@ -1164,14 +1164,14 @@ Ip6SendRouterSolicit ( LinkLayerOption = NULL;
if (SourceLinkAddress != NULL) {
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace (
- Packet,
- sizeof (IP6_ETHER_ADDR_OPTION),
- FALSE
- );
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace (
+ Packet,
+ sizeof (IP6_ETHER_ADDR_OPTION),
+ FALSE
+ );
ASSERT (LinkLayerOption != NULL);
LinkLayerOption->Type = Ip6OptionEtherSource;
- LinkLayerOption->Length = (UINT8) sizeof (IP6_ETHER_ADDR_OPTION);
+ LinkLayerOption->Length = (UINT8)sizeof (IP6_ETHER_ADDR_OPTION);
CopyMem (LinkLayerOption->EtherAddr, SourceLinkAddress, 6);
}
@@ -1205,22 +1205,22 @@ Ip6SendRouterSolicit ( **/
EFI_STATUS
Ip6SendNeighborAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *SourceAddress,
- IN EFI_IPv6_ADDRESS *DestinationAddress,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress,
- IN BOOLEAN IsRouter,
- IN BOOLEAN Override,
- IN BOOLEAN Solicited
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *SourceAddress,
+ IN EFI_IPv6_ADDRESS *DestinationAddress,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress,
+ IN BOOLEAN IsRouter,
+ IN BOOLEAN Override,
+ IN BOOLEAN Solicited
)
{
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- IP6_ICMP_INFORMATION_HEAD *IcmpHead;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- EFI_IPv6_ADDRESS *Target;
- UINT16 PayloadLen;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ IP6_ICMP_INFORMATION_HEAD *IcmpHead;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ EFI_IPv6_ADDRESS *Target;
+ UINT16 PayloadLen;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -1232,13 +1232,13 @@ Ip6SendNeighborAdvertise ( //
ASSERT (DestinationAddress != NULL && TargetIp6Address != NULL && TargetLinkAddress != NULL);
- PayloadLen = (UINT16) (sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS) + sizeof (IP6_ETHER_ADDR_OPTION));
+ PayloadLen = (UINT16)(sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS) + sizeof (IP6_ETHER_ADDR_OPTION));
//
// Generate the packet to be sent
//
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1246,11 +1246,11 @@ Ip6SendNeighborAdvertise ( //
// Create the basic IPv6 header.
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_ICMP;
- Head.HopLimit = IP6_HOP_LIMIT;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_ICMP;
+ Head.HopLimit = IP6_HOP_LIMIT;
IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress);
IP6_COPY_ADDRESS (&Head.DestinationAddress, DestinationAddress);
@@ -1262,7 +1262,7 @@ Ip6SendNeighborAdvertise ( // Set the Router flag, Solicited flag and Override flag.
//
- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
ASSERT (IcmpHead != NULL);
ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD));
IcmpHead->Head.Type = ICMP_V6_NEIGHBOR_ADVERTISE;
@@ -1280,15 +1280,15 @@ Ip6SendNeighborAdvertise ( IcmpHead->Fourth |= IP6_OVERRIDE_FLAG;
}
- Target = (EFI_IPv6_ADDRESS *) NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
+ Target = (EFI_IPv6_ADDRESS *)NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
ASSERT (Target != NULL);
IP6_COPY_ADDRESS (Target, TargetIp6Address);
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace (
- Packet,
- sizeof (IP6_ETHER_ADDR_OPTION),
- FALSE
- );
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace (
+ Packet,
+ sizeof (IP6_ETHER_ADDR_OPTION),
+ FALSE
+ );
ASSERT (LinkLayerOption != NULL);
LinkLayerOption->Type = Ip6OptionEtherTarget;
LinkLayerOption->Length = 1;
@@ -1320,33 +1320,33 @@ Ip6SendNeighborAdvertise ( **/
EFI_STATUS
Ip6SendNeighborSolicit (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *SourceAddress,
- IN EFI_IPv6_ADDRESS *DestinationAddress,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *SourceAddress,
+ IN EFI_IPv6_ADDRESS *DestinationAddress,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
)
{
- NET_BUF *Packet;
- EFI_IP6_HEADER Head;
- IP6_ICMP_INFORMATION_HEAD *IcmpHead;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- EFI_IPv6_ADDRESS *Target;
- BOOLEAN IsDAD;
- UINT16 PayloadLen;
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ NET_BUF *Packet;
+ EFI_IP6_HEADER Head;
+ IP6_ICMP_INFORMATION_HEAD *IcmpHead;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ EFI_IPv6_ADDRESS *Target;
+ BOOLEAN IsDAD;
+ UINT16 PayloadLen;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
//
// Check input parameters
//
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
- if (DestinationAddress == NULL || TargetIp6Address == NULL) {
+ if ((DestinationAddress == NULL) || (TargetIp6Address == NULL)) {
return EFI_INVALID_PARAMETER;
}
IsDAD = FALSE;
- if (SourceAddress == NULL || (SourceAddress != NULL && NetIp6IsUnspecifiedAddr (SourceAddress))) {
+ if ((SourceAddress == NULL) || ((SourceAddress != NULL) && NetIp6IsUnspecifiedAddr (SourceAddress))) {
IsDAD = TRUE;
}
@@ -1355,21 +1355,21 @@ Ip6SendNeighborSolicit ( // if the solicitation is not sent by performing DAD - Duplicate Address Detection.
// Otherwise must not include it.
//
- PayloadLen = (UINT16) (sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS));
+ PayloadLen = (UINT16)(sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS));
if (!IsDAD) {
if (SourceLinkAddress == NULL) {
return EFI_INVALID_PARAMETER;
}
- PayloadLen = (UINT16) (PayloadLen + sizeof (IP6_ETHER_ADDR_OPTION));
+ PayloadLen = (UINT16)(PayloadLen + sizeof (IP6_ETHER_ADDR_OPTION));
}
//
// Generate the packet to be sent
//
- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen);
+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen);
if (Packet == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1377,11 +1377,11 @@ Ip6SendNeighborSolicit ( //
// Create the basic IPv6 header
//
- Head.FlowLabelL = 0;
- Head.FlowLabelH = 0;
- Head.PayloadLength = HTONS (PayloadLen);
- Head.NextHeader = IP6_ICMP;
- Head.HopLimit = IP6_HOP_LIMIT;
+ Head.FlowLabelL = 0;
+ Head.FlowLabelH = 0;
+ Head.PayloadLength = HTONS (PayloadLen);
+ Head.NextHeader = IP6_ICMP;
+ Head.HopLimit = IP6_HOP_LIMIT;
if (SourceAddress != NULL) {
IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress);
@@ -1396,27 +1396,26 @@ Ip6SendNeighborSolicit ( //
// Fill in the ICMP header, Target address, and Source link-layer address.
//
- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
ASSERT (IcmpHead != NULL);
ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD));
IcmpHead->Head.Type = ICMP_V6_NEIGHBOR_SOLICIT;
IcmpHead->Head.Code = 0;
- Target = (EFI_IPv6_ADDRESS *) NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
+ Target = (EFI_IPv6_ADDRESS *)NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE);
ASSERT (Target != NULL);
IP6_COPY_ADDRESS (Target, TargetIp6Address);
LinkLayerOption = NULL;
if (!IsDAD) {
-
//
// Fill in the source link-layer address option
//
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace (
- Packet,
- sizeof (IP6_ETHER_ADDR_OPTION),
- FALSE
- );
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace (
+ Packet,
+ sizeof (IP6_ETHER_ADDR_OPTION),
+ FALSE
+ );
ASSERT (LinkLayerOption != NULL);
LinkLayerOption->Type = Ip6OptionEtherSource;
LinkLayerOption->Length = 1;
@@ -1457,30 +1456,30 @@ Ip6SendNeighborSolicit ( **/
EFI_STATUS
Ip6ProcessNeighborSolicit (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD Icmp;
- EFI_IPv6_ADDRESS Target;
- IP6_ETHER_ADDR_OPTION LinkLayerOption;
- BOOLEAN IsDAD;
- BOOLEAN IsUnicast;
- BOOLEAN IsMaintained;
- IP6_DAD_ENTRY *DupAddrDetect;
- IP6_INTERFACE *IpIf;
- IP6_NEIGHBOR_ENTRY *Neighbor;
- BOOLEAN Solicited;
- BOOLEAN UpdateCache;
- EFI_IPv6_ADDRESS Dest;
- UINT16 OptionLen;
- UINT8 *Option;
- BOOLEAN Provided;
- EFI_STATUS Status;
- VOID *MacAddress;
-
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ IP6_ICMP_INFORMATION_HEAD Icmp;
+ EFI_IPv6_ADDRESS Target;
+ IP6_ETHER_ADDR_OPTION LinkLayerOption;
+ BOOLEAN IsDAD;
+ BOOLEAN IsUnicast;
+ BOOLEAN IsMaintained;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ IP6_INTERFACE *IpIf;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
+ BOOLEAN Solicited;
+ BOOLEAN UpdateCache;
+ EFI_IPv6_ADDRESS Dest;
+ UINT16 OptionLen;
+ UINT8 *Option;
+ BOOLEAN Provided;
+ EFI_STATUS Status;
+ VOID *MacAddress;
+
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
NetbufCopy (Packet, sizeof (Icmp), sizeof (Target), Target.Addr);
//
@@ -1492,7 +1491,7 @@ Ip6ProcessNeighborSolicit ( //
Status = EFI_INVALID_PARAMETER;
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 || !NetIp6IsValidUnicast (&Target)) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) || !NetIp6IsValidUnicast (&Target)) {
goto Exit;
}
@@ -1503,9 +1502,9 @@ Ip6ProcessNeighborSolicit ( if (Head->PayloadLength < IP6_ND_LENGTH) {
goto Exit;
} else {
- OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_ND_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
ASSERT (Option != NULL);
//
@@ -1527,7 +1526,7 @@ Ip6ProcessNeighborSolicit ( Packet,
IP6_ND_LENGTH,
sizeof (IP6_ETHER_ADDR_OPTION),
- (UINT8 *) &LinkLayerOption
+ (UINT8 *)&LinkLayerOption
);
//
// The solicitation for neighbor discovery should include a source link-layer
@@ -1591,7 +1590,8 @@ Ip6ProcessNeighborSolicit ( MacAddress,
&IpSb->SnpMode.CurrentAddress,
IpSb->SnpMode.HwAddressSize
- ) != 0) {
+ ) != 0)
+ {
//
// The NS is from another node to performing DAD on the same address.
// Fail DAD for the tentative address.
@@ -1607,6 +1607,7 @@ Ip6ProcessNeighborSolicit ( }
}
}
+
goto Exit;
}
@@ -1624,6 +1625,7 @@ Ip6ProcessNeighborSolicit ( Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
+
UpdateCache = TRUE;
} else {
if (CompareMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6) != 0) {
@@ -1633,12 +1635,12 @@ Ip6ProcessNeighborSolicit ( if (UpdateCache) {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
CopyMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6);
//
// Send queued packets if exist.
//
- Neighbor->CallBack ((VOID *) Neighbor);
+ Neighbor->CallBack ((VOID *)Neighbor);
}
}
@@ -1686,28 +1688,28 @@ Exit: **/
EFI_STATUS
Ip6ProcessNeighborAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD Icmp;
- EFI_IPv6_ADDRESS Target;
- IP6_ETHER_ADDR_OPTION LinkLayerOption;
- BOOLEAN Provided;
- INTN Compare;
- IP6_NEIGHBOR_ENTRY *Neighbor;
- IP6_DEFAULT_ROUTER *DefaultRouter;
- BOOLEAN Solicited;
- BOOLEAN IsRouter;
- BOOLEAN Override;
- IP6_DAD_ENTRY *DupAddrDetect;
- IP6_INTERFACE *IpIf;
- UINT16 OptionLen;
- UINT8 *Option;
- EFI_STATUS Status;
-
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ IP6_ICMP_INFORMATION_HEAD Icmp;
+ EFI_IPv6_ADDRESS Target;
+ IP6_ETHER_ADDR_OPTION LinkLayerOption;
+ BOOLEAN Provided;
+ INTN Compare;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
+ BOOLEAN Solicited;
+ BOOLEAN IsRouter;
+ BOOLEAN Override;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ IP6_INTERFACE *IpIf;
+ UINT16 OptionLen;
+ UINT8 *Option;
+ EFI_STATUS Status;
+
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
NetbufCopy (Packet, sizeof (Icmp), sizeof (Target), Target.Addr);
//
@@ -1720,7 +1722,7 @@ Ip6ProcessNeighborAdvertise ( // ICMP Code is 0.
// Target Address is not a multicast address.
//
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 || !NetIp6IsValidUnicast (&Target)) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) || !NetIp6IsValidUnicast (&Target)) {
goto Exit;
}
@@ -1732,9 +1734,9 @@ Ip6ProcessNeighborAdvertise ( if (Head->PayloadLength < IP6_ND_LENGTH) {
goto Exit;
} else {
- OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_ND_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL);
ASSERT (Option != NULL);
//
@@ -1753,6 +1755,7 @@ Ip6ProcessNeighborAdvertise ( if ((Icmp.Fourth & IP6_SOLICITED_FLAG) == IP6_SOLICITED_FLAG) {
Solicited = TRUE;
}
+
if (IP6_IS_MULTICAST (&Head->DestinationAddress) && Solicited) {
goto Exit;
}
@@ -1787,6 +1790,7 @@ Ip6ProcessNeighborAdvertise ( if ((Icmp.Fourth & IP6_IS_ROUTER_FLAG) == IP6_IS_ROUTER_FLAG) {
IsRouter = TRUE;
}
+
if ((Icmp.Fourth & IP6_OVERRIDE_FLAG) == IP6_OVERRIDE_FLAG) {
Override = TRUE;
}
@@ -1799,7 +1803,7 @@ Ip6ProcessNeighborAdvertise ( Packet,
IP6_ND_LENGTH,
sizeof (IP6_ETHER_ADDR_OPTION),
- (UINT8 *) &LinkLayerOption
+ (UINT8 *)&LinkLayerOption
);
if (LinkLayerOption.Type == Ip6OptionEtherTarget) {
@@ -1828,6 +1832,7 @@ Ip6ProcessNeighborAdvertise ( if (!Provided) {
goto Exit;
}
+
//
// Update the Neighbor Cache
//
@@ -1837,17 +1842,16 @@ Ip6ProcessNeighborAdvertise ( Neighbor->Ticks = IP6_GET_TICKS (IpSb->ReachableTime);
} else {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
//
// Send any packets queued for the neighbor awaiting address resolution.
//
- Neighbor->CallBack ((VOID *) Neighbor);
+ Neighbor->CallBack ((VOID *)Neighbor);
}
Neighbor->IsRouter = IsRouter;
-
} else {
- if (!Override && Compare != 0) {
+ if (!Override && (Compare != 0)) {
//
// When the Override Flag is clear and supplied link-layer address differs from
// that in the cache, if the state of the entry is not REACHABLE, ignore the
@@ -1856,12 +1860,13 @@ Ip6ProcessNeighborAdvertise ( //
if (Neighbor->State == EfiNeighborReachable) {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
}
} else {
if (Compare != 0) {
CopyMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6);
}
+
//
// Update the entry's state
//
@@ -1871,7 +1876,7 @@ Ip6ProcessNeighborAdvertise ( } else {
if (Compare != 0) {
Neighbor->State = EfiNeighborStale;
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
}
}
@@ -1892,7 +1897,7 @@ Ip6ProcessNeighborAdvertise ( }
if (Neighbor->State == EfiNeighborReachable) {
- Neighbor->CallBack ((VOID *) Neighbor);
+ Neighbor->CallBack ((VOID *)Neighbor);
}
Status = EFI_SUCCESS;
@@ -1918,36 +1923,36 @@ Exit: **/
EFI_STATUS
Ip6ProcessRouterAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD Icmp;
- UINT32 ReachableTime;
- UINT32 RetransTimer;
- UINT16 RouterLifetime;
- UINT32 Offset;
- UINT8 Type;
- UINT8 Length;
- IP6_ETHER_ADDR_OPTION LinkLayerOption;
- UINT32 Fourth;
- UINT8 CurHopLimit;
- BOOLEAN Mflag;
- BOOLEAN Oflag;
- IP6_DEFAULT_ROUTER *DefaultRouter;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- EFI_MAC_ADDRESS LinkLayerAddress;
- IP6_MTU_OPTION MTUOption;
- IP6_PREFIX_INFO_OPTION PrefixOption;
- IP6_PREFIX_LIST_ENTRY *PrefixList;
- BOOLEAN OnLink;
- BOOLEAN Autonomous;
- EFI_IPv6_ADDRESS StatelessAddress;
- EFI_STATUS Status;
- UINT16 OptionLen;
- UINT8 *Option;
- INTN Result;
+ IP6_ICMP_INFORMATION_HEAD Icmp;
+ UINT32 ReachableTime;
+ UINT32 RetransTimer;
+ UINT16 RouterLifetime;
+ UINT32 Offset;
+ UINT8 Type;
+ UINT8 Length;
+ IP6_ETHER_ADDR_OPTION LinkLayerOption;
+ UINT32 Fourth;
+ UINT8 CurHopLimit;
+ BOOLEAN Mflag;
+ BOOLEAN Oflag;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ EFI_MAC_ADDRESS LinkLayerAddress;
+ IP6_MTU_OPTION MTUOption;
+ IP6_PREFIX_INFO_OPTION PrefixOption;
+ IP6_PREFIX_LIST_ENTRY *PrefixList;
+ BOOLEAN OnLink;
+ BOOLEAN Autonomous;
+ EFI_IPv6_ADDRESS StatelessAddress;
+ EFI_STATUS Status;
+ UINT16 OptionLen;
+ UINT8 *Option;
+ INTN Result;
Status = EFI_INVALID_PARAMETER;
@@ -1958,7 +1963,7 @@ Ip6ProcessRouterAdvertise ( goto Exit;
}
- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp);
+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp);
//
// Validate the incoming Router Advertisement
@@ -1970,23 +1975,25 @@ Ip6ProcessRouterAdvertise ( if (!NetIp6IsLinkLocalAddr (&Head->SourceAddress)) {
goto Exit;
}
+
//
// The IP Hop Limit field has a value of 255, i.e. the packet
// could not possibly have been forwarded by a router.
// ICMP Code is 0.
// ICMP length (derived from the IP length) is 16 or more octets.
//
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 ||
- Head->PayloadLength < IP6_RA_LENGTH) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) ||
+ (Head->PayloadLength < IP6_RA_LENGTH))
+ {
goto Exit;
}
//
// All included options have a length that is greater than zero.
//
- OptionLen = (UINT16) (Head->PayloadLength - IP6_RA_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_RA_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL);
ASSERT (Option != NULL);
if (!Ip6IsNDOptionValid (Option, OptionLen)) {
@@ -2035,17 +2042,17 @@ Ip6ProcessRouterAdvertise ( }
}
- CurHopLimit = *((UINT8 *) &Fourth + 3);
+ CurHopLimit = *((UINT8 *)&Fourth + 3);
if (CurHopLimit != 0) {
IpSb->CurHopLimit = CurHopLimit;
}
Mflag = FALSE;
Oflag = FALSE;
- if ((*((UINT8 *) &Fourth + 2) & IP6_M_ADDR_CONFIG_FLAG) == IP6_M_ADDR_CONFIG_FLAG) {
+ if ((*((UINT8 *)&Fourth + 2) & IP6_M_ADDR_CONFIG_FLAG) == IP6_M_ADDR_CONFIG_FLAG) {
Mflag = TRUE;
} else {
- if ((*((UINT8 *) &Fourth + 2) & IP6_O_CONFIG_FLAG) == IP6_O_CONFIG_FLAG) {
+ if ((*((UINT8 *)&Fourth + 2) & IP6_O_CONFIG_FLAG) == IP6_O_CONFIG_FLAG) {
Oflag = TRUE;
}
}
@@ -2060,12 +2067,12 @@ Ip6ProcessRouterAdvertise ( //
// Process Reachable Time and Retrans Timer fields.
//
- NetbufCopy (Packet, sizeof (Icmp), sizeof (UINT32), (UINT8 *) &ReachableTime);
- NetbufCopy (Packet, sizeof (Icmp) + sizeof (UINT32), sizeof (UINT32), (UINT8 *) &RetransTimer);
+ NetbufCopy (Packet, sizeof (Icmp), sizeof (UINT32), (UINT8 *)&ReachableTime);
+ NetbufCopy (Packet, sizeof (Icmp) + sizeof (UINT32), sizeof (UINT32), (UINT8 *)&RetransTimer);
ReachableTime = NTOHL (ReachableTime);
RetransTimer = NTOHL (RetransTimer);
- if (ReachableTime != 0 && ReachableTime != IpSb->BaseReachableTime) {
+ if ((ReachableTime != 0) && (ReachableTime != IpSb->BaseReachableTime)) {
//
// If new value is not unspecified and differs from the previous one, record it
// in BaseReachableTime and recompute a ReachableTime.
@@ -2098,262 +2105,266 @@ Ip6ProcessRouterAdvertise ( // fit within the input packet.
//
Offset = 16;
- while (Offset < (UINT32) Head->PayloadLength) {
+ while (Offset < (UINT32)Head->PayloadLength) {
NetbufCopy (Packet, Offset, sizeof (UINT8), &Type);
switch (Type) {
- case Ip6OptionEtherSource:
- //
- // Update the neighbor cache
- //
- NetbufCopy (Packet, Offset, sizeof (IP6_ETHER_ADDR_OPTION), (UINT8 *) &LinkLayerOption);
+ case Ip6OptionEtherSource:
+ //
+ // Update the neighbor cache
+ //
+ NetbufCopy (Packet, Offset, sizeof (IP6_ETHER_ADDR_OPTION), (UINT8 *)&LinkLayerOption);
- //
- // Option size validity ensured by Ip6IsNDOptionValid().
- //
- ASSERT (LinkLayerOption.Length != 0);
- ASSERT (Offset + (UINT32) LinkLayerOption.Length * 8 <= (UINT32) Head->PayloadLength);
+ //
+ // Option size validity ensured by Ip6IsNDOptionValid().
+ //
+ ASSERT (LinkLayerOption.Length != 0);
+ ASSERT (Offset + (UINT32)LinkLayerOption.Length * 8 <= (UINT32)Head->PayloadLength);
- ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS));
- CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6);
+ ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS));
+ CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6);
- if (NeighborCache == NULL) {
- NeighborCache = Ip6CreateNeighborEntry (
- IpSb,
- Ip6OnArpResolved,
- &Head->SourceAddress,
- &LinkLayerAddress
- );
if (NeighborCache == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
+ NeighborCache = Ip6CreateNeighborEntry (
+ IpSb,
+ Ip6OnArpResolved,
+ &Head->SourceAddress,
+ &LinkLayerAddress
+ );
+ if (NeighborCache == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+
+ NeighborCache->IsRouter = TRUE;
+ NeighborCache->State = EfiNeighborStale;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
+ } else {
+ Result = CompareMem (&LinkLayerAddress, &NeighborCache->LinkAddress, 6);
+
+ //
+ // If the link-local address is the same as that already in the cache,
+ // the cache entry's state remains unchanged. Otherwise update the
+ // reachability state to STALE.
+ //
+ if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) {
+ CopyMem (&NeighborCache->LinkAddress, &LinkLayerAddress, 6);
+
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
+
+ if (NeighborCache->State == EfiNeighborInComplete) {
+ //
+ // Send queued packets if exist.
+ //
+ NeighborCache->State = EfiNeighborStale;
+ NeighborCache->CallBack ((VOID *)NeighborCache);
+ } else {
+ NeighborCache->State = EfiNeighborStale;
+ }
+ }
}
- NeighborCache->IsRouter = TRUE;
- NeighborCache->State = EfiNeighborStale;
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
- } else {
- Result = CompareMem (&LinkLayerAddress, &NeighborCache->LinkAddress, 6);
+
+ Offset += (UINT32)LinkLayerOption.Length * 8;
+ break;
+ case Ip6OptionPrefixInfo:
+ NetbufCopy (Packet, Offset, sizeof (IP6_PREFIX_INFO_OPTION), (UINT8 *)&PrefixOption);
//
- // If the link-local address is the same as that already in the cache,
- // the cache entry's state remains unchanged. Otherwise update the
- // reachability state to STALE.
+ // Option size validity ensured by Ip6IsNDOptionValid().
//
- if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) {
- CopyMem (&NeighborCache->LinkAddress, &LinkLayerAddress, 6);
+ ASSERT (PrefixOption.Length == 4);
+ ASSERT (Offset + (UINT32)PrefixOption.Length * 8 <= (UINT32)Head->PayloadLength);
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime);
+ PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime);
- if (NeighborCache->State == EfiNeighborInComplete) {
- //
- // Send queued packets if exist.
- //
- NeighborCache->State = EfiNeighborStale;
- NeighborCache->CallBack ((VOID *) NeighborCache);
- } else {
- NeighborCache->State = EfiNeighborStale;
- }
+ //
+ // Get L and A flag, recorded in the lower 2 bits of Reserved1
+ //
+ OnLink = FALSE;
+ if ((PrefixOption.Reserved1 & IP6_ON_LINK_FLAG) == IP6_ON_LINK_FLAG) {
+ OnLink = TRUE;
}
- }
-
- Offset += (UINT32) LinkLayerOption.Length * 8;
- break;
- case Ip6OptionPrefixInfo:
- NetbufCopy (Packet, Offset, sizeof (IP6_PREFIX_INFO_OPTION), (UINT8 *) &PrefixOption);
- //
- // Option size validity ensured by Ip6IsNDOptionValid().
- //
- ASSERT (PrefixOption.Length == 4);
- ASSERT (Offset + (UINT32) PrefixOption.Length * 8 <= (UINT32) Head->PayloadLength);
-
- PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime);
- PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime);
+ Autonomous = FALSE;
+ if ((PrefixOption.Reserved1 & IP6_AUTO_CONFIG_FLAG) == IP6_AUTO_CONFIG_FLAG) {
+ Autonomous = TRUE;
+ }
- //
- // Get L and A flag, recorded in the lower 2 bits of Reserved1
- //
- OnLink = FALSE;
- if ((PrefixOption.Reserved1 & IP6_ON_LINK_FLAG) == IP6_ON_LINK_FLAG) {
- OnLink = TRUE;
- }
- Autonomous = FALSE;
- if ((PrefixOption.Reserved1 & IP6_AUTO_CONFIG_FLAG) == IP6_AUTO_CONFIG_FLAG) {
- Autonomous = TRUE;
- }
+ //
+ // If the prefix is the link-local prefix, silently ignore the prefix option.
+ //
+ if ((PrefixOption.PrefixLength == IP6_LINK_LOCAL_PREFIX_LENGTH) &&
+ NetIp6IsLinkLocalAddr (&PrefixOption.Prefix)
+ )
+ {
+ Offset += sizeof (IP6_PREFIX_INFO_OPTION);
+ break;
+ }
- //
- // If the prefix is the link-local prefix, silently ignore the prefix option.
- //
- if (PrefixOption.PrefixLength == IP6_LINK_LOCAL_PREFIX_LENGTH &&
- NetIp6IsLinkLocalAddr (&PrefixOption.Prefix)
- ) {
- Offset += sizeof (IP6_PREFIX_INFO_OPTION);
- break;
- }
- //
- // Do following if on-link flag is set according to RFC4861.
- //
- if (OnLink) {
- PrefixList = Ip6FindPrefixListEntry (
- IpSb,
- TRUE,
- PrefixOption.PrefixLength,
- &PrefixOption.Prefix
- );
//
- // Create a new entry for the prefix, if the ValidLifetime is zero,
- // silently ignore the prefix option.
+ // Do following if on-link flag is set according to RFC4861.
//
- if (PrefixList == NULL && PrefixOption.ValidLifetime != 0) {
- PrefixList = Ip6CreatePrefixListEntry (
+ if (OnLink) {
+ PrefixList = Ip6FindPrefixListEntry (
IpSb,
TRUE,
- PrefixOption.ValidLifetime,
- PrefixOption.PreferredLifetime,
PrefixOption.PrefixLength,
&PrefixOption.Prefix
);
- if (PrefixList == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
- } else if (PrefixList != NULL) {
- if (PrefixOption.ValidLifetime != 0) {
- PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
- } else {
- //
- // If the prefix exists and incoming ValidLifetime is zero, immediately
- // remove the prefix.
- Ip6DestroyPrefixListEntry (IpSb, PrefixList, OnLink, TRUE);
- }
- }
- }
-
- //
- // Do following if Autonomous flag is set according to RFC4862.
- //
- if (Autonomous && PrefixOption.PreferredLifetime <= PrefixOption.ValidLifetime) {
- PrefixList = Ip6FindPrefixListEntry (
- IpSb,
- FALSE,
- PrefixOption.PrefixLength,
- &PrefixOption.Prefix
- );
- //
- // Create a new entry for the prefix, and form an address by prefix + interface id
- // If the sum of the prefix length and interface identifier length
- // does not equal 128 bits, the Prefix Information option MUST be ignored.
- //
- if (PrefixList == NULL &&
- PrefixOption.ValidLifetime != 0 &&
- PrefixOption.PrefixLength + IpSb->InterfaceIdLen * 8 == 128
- ) {
//
- // Form the address in network order.
+ // Create a new entry for the prefix, if the ValidLifetime is zero,
+ // silently ignore the prefix option.
//
- CopyMem (&StatelessAddress, &PrefixOption.Prefix, sizeof (UINT64));
- CopyMem (&StatelessAddress.Addr[8], IpSb->InterfaceId, sizeof (UINT64));
-
- //
- // If the address is not yet in the assigned address list, adds it into.
- //
- if (!Ip6IsOneOfSetAddress (IpSb, &StatelessAddress, NULL, NULL)) {
- //
- // And also not in the DAD process, check its uniqueness firstly.
- //
- if (Ip6FindDADEntry (IpSb, &StatelessAddress, NULL) == NULL) {
- Status = Ip6SetAddress (
- IpSb->DefaultInterface,
- &StatelessAddress,
- FALSE,
- PrefixOption.PrefixLength,
- PrefixOption.ValidLifetime,
- PrefixOption.PreferredLifetime,
- NULL,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
+ if ((PrefixList == NULL) && (PrefixOption.ValidLifetime != 0)) {
+ PrefixList = Ip6CreatePrefixListEntry (
+ IpSb,
+ TRUE,
+ PrefixOption.ValidLifetime,
+ PrefixOption.PreferredLifetime,
+ PrefixOption.PrefixLength,
+ &PrefixOption.Prefix
+ );
+ if (PrefixList == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+ } else if (PrefixList != NULL) {
+ if (PrefixOption.ValidLifetime != 0) {
+ PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
+ } else {
+ //
+ // If the prefix exists and incoming ValidLifetime is zero, immediately
+ // remove the prefix.
+ Ip6DestroyPrefixListEntry (IpSb, PrefixList, OnLink, TRUE);
}
}
+ }
- //
- // Adds the prefix option to stateless prefix option list.
- //
- PrefixList = Ip6CreatePrefixListEntry (
+ //
+ // Do following if Autonomous flag is set according to RFC4862.
+ //
+ if (Autonomous && (PrefixOption.PreferredLifetime <= PrefixOption.ValidLifetime)) {
+ PrefixList = Ip6FindPrefixListEntry (
IpSb,
FALSE,
- PrefixOption.ValidLifetime,
- PrefixOption.PreferredLifetime,
PrefixOption.PrefixLength,
&PrefixOption.Prefix
);
- if (PrefixList == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
- } else if (PrefixList != NULL) {
-
//
- // Reset the preferred lifetime of the address if the advertised prefix exists.
- // Perform specific action to valid lifetime together.
+ // Create a new entry for the prefix, and form an address by prefix + interface id
+ // If the sum of the prefix length and interface identifier length
+ // does not equal 128 bits, the Prefix Information option MUST be ignored.
//
- PrefixList->PreferredLifetime = PrefixOption.PreferredLifetime;
- if ((PrefixOption.ValidLifetime > 7200) ||
- (PrefixOption.ValidLifetime > PrefixList->ValidLifetime)) {
+ if ((PrefixList == NULL) &&
+ (PrefixOption.ValidLifetime != 0) &&
+ (PrefixOption.PrefixLength + IpSb->InterfaceIdLen * 8 == 128)
+ )
+ {
//
- // If the received Valid Lifetime is greater than 2 hours or
- // greater than RemainingLifetime, set the valid lifetime of the
- // corresponding address to the advertised Valid Lifetime.
+ // Form the address in network order.
//
- PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
+ CopyMem (&StatelessAddress, &PrefixOption.Prefix, sizeof (UINT64));
+ CopyMem (&StatelessAddress.Addr[8], IpSb->InterfaceId, sizeof (UINT64));
- } else if (PrefixList->ValidLifetime <= 7200) {
//
- // If RemainingLifetime is less than or equals to 2 hours, ignore the
- // Prefix Information option with regards to the valid lifetime.
- // TODO: If this option has been authenticated, set the valid lifetime.
+ // If the address is not yet in the assigned address list, adds it into.
//
- } else {
+ if (!Ip6IsOneOfSetAddress (IpSb, &StatelessAddress, NULL, NULL)) {
+ //
+ // And also not in the DAD process, check its uniqueness firstly.
+ //
+ if (Ip6FindDADEntry (IpSb, &StatelessAddress, NULL) == NULL) {
+ Status = Ip6SetAddress (
+ IpSb->DefaultInterface,
+ &StatelessAddress,
+ FALSE,
+ PrefixOption.PrefixLength,
+ PrefixOption.ValidLifetime,
+ PrefixOption.PreferredLifetime,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto Exit;
+ }
+ }
+ }
+
//
- // Otherwise, reset the valid lifetime of the corresponding
- // address to 2 hours.
+ // Adds the prefix option to stateless prefix option list.
+ //
+ PrefixList = Ip6CreatePrefixListEntry (
+ IpSb,
+ FALSE,
+ PrefixOption.ValidLifetime,
+ PrefixOption.PreferredLifetime,
+ PrefixOption.PrefixLength,
+ &PrefixOption.Prefix
+ );
+ if (PrefixList == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+ } else if (PrefixList != NULL) {
//
- PrefixList->ValidLifetime = 7200;
+ // Reset the preferred lifetime of the address if the advertised prefix exists.
+ // Perform specific action to valid lifetime together.
+ //
+ PrefixList->PreferredLifetime = PrefixOption.PreferredLifetime;
+ if ((PrefixOption.ValidLifetime > 7200) ||
+ (PrefixOption.ValidLifetime > PrefixList->ValidLifetime))
+ {
+ //
+ // If the received Valid Lifetime is greater than 2 hours or
+ // greater than RemainingLifetime, set the valid lifetime of the
+ // corresponding address to the advertised Valid Lifetime.
+ //
+ PrefixList->ValidLifetime = PrefixOption.ValidLifetime;
+ } else if (PrefixList->ValidLifetime <= 7200) {
+ //
+ // If RemainingLifetime is less than or equals to 2 hours, ignore the
+ // Prefix Information option with regards to the valid lifetime.
+ // TODO: If this option has been authenticated, set the valid lifetime.
+ //
+ } else {
+ //
+ // Otherwise, reset the valid lifetime of the corresponding
+ // address to 2 hours.
+ //
+ PrefixList->ValidLifetime = 7200;
+ }
}
}
- }
- Offset += sizeof (IP6_PREFIX_INFO_OPTION);
- break;
- case Ip6OptionMtu:
- NetbufCopy (Packet, Offset, sizeof (IP6_MTU_OPTION), (UINT8 *) &MTUOption);
+ Offset += sizeof (IP6_PREFIX_INFO_OPTION);
+ break;
+ case Ip6OptionMtu:
+ NetbufCopy (Packet, Offset, sizeof (IP6_MTU_OPTION), (UINT8 *)&MTUOption);
- //
- // Option size validity ensured by Ip6IsNDOptionValid().
- //
- ASSERT (MTUOption.Length == 1);
- ASSERT (Offset + (UINT32) MTUOption.Length * 8 <= (UINT32) Head->PayloadLength);
+ //
+ // Option size validity ensured by Ip6IsNDOptionValid().
+ //
+ ASSERT (MTUOption.Length == 1);
+ ASSERT (Offset + (UINT32)MTUOption.Length * 8 <= (UINT32)Head->PayloadLength);
- //
- // Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order
- // to omit implementation of Path MTU Discovery. Thus ignore the MTU option
- // in Router Advertisement.
- //
+ //
+ // Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order
+ // to omit implementation of Path MTU Discovery. Thus ignore the MTU option
+ // in Router Advertisement.
+ //
- Offset += sizeof (IP6_MTU_OPTION);
- break;
- default:
- //
- // Silently ignore unrecognized options
- //
- NetbufCopy (Packet, Offset + sizeof (UINT8), sizeof (UINT8), &Length);
+ Offset += sizeof (IP6_MTU_OPTION);
+ break;
+ default:
+ //
+ // Silently ignore unrecognized options
+ //
+ NetbufCopy (Packet, Offset + sizeof (UINT8), sizeof (UINT8), &Length);
- ASSERT (Length != 0);
+ ASSERT (Length != 0);
- Offset += (UINT32) Length * 8;
- break;
+ Offset += (UINT32)Length * 8;
+ break;
}
}
@@ -2382,31 +2393,31 @@ Exit: **/
EFI_STATUS
Ip6ProcessRedirect (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
)
{
- IP6_ICMP_INFORMATION_HEAD *Icmp;
- EFI_IPv6_ADDRESS *Target;
- EFI_IPv6_ADDRESS *IcmpDest;
- UINT8 *Option;
- UINT16 OptionLen;
- IP6_ROUTE_ENTRY *RouteEntry;
- IP6_ROUTE_CACHE_ENTRY *RouteCache;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- INT32 Length;
- UINT8 OptLen;
- IP6_ETHER_ADDR_OPTION *LinkLayerOption;
- EFI_MAC_ADDRESS Mac;
- UINT32 Index;
- BOOLEAN IsRouter;
- EFI_STATUS Status;
- INTN Result;
+ IP6_ICMP_INFORMATION_HEAD *Icmp;
+ EFI_IPv6_ADDRESS *Target;
+ EFI_IPv6_ADDRESS *IcmpDest;
+ UINT8 *Option;
+ UINT16 OptionLen;
+ IP6_ROUTE_ENTRY *RouteEntry;
+ IP6_ROUTE_CACHE_ENTRY *RouteCache;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ INT32 Length;
+ UINT8 OptLen;
+ IP6_ETHER_ADDR_OPTION *LinkLayerOption;
+ EFI_MAC_ADDRESS Mac;
+ UINT32 Index;
+ BOOLEAN IsRouter;
+ EFI_STATUS Status;
+ INTN Result;
Status = EFI_INVALID_PARAMETER;
- Icmp = (IP6_ICMP_INFORMATION_HEAD *) NetbufGetByte (Packet, 0, NULL);
+ Icmp = (IP6_ICMP_INFORMATION_HEAD *)NetbufGetByte (Packet, 0, NULL);
if (Icmp == NULL) {
goto Exit;
}
@@ -2421,8 +2432,9 @@ Ip6ProcessRedirect ( // ICMP Code is 0.
// ICMP length (derived from the IP length) is 40 or more octets.
//
- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp->Head.Code != 0 ||
- Head->PayloadLength < IP6_REDITECT_LENGTH) {
+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp->Head.Code != 0) ||
+ (Head->PayloadLength < IP6_REDITECT_LENGTH))
+ {
goto Exit;
}
@@ -2443,9 +2455,9 @@ Ip6ProcessRedirect ( //
// All included options have a length that is greater than zero.
//
- OptionLen = (UINT16) (Head->PayloadLength - IP6_REDITECT_LENGTH);
+ OptionLen = (UINT16)(Head->PayloadLength - IP6_REDITECT_LENGTH);
if (OptionLen != 0) {
- Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL);
+ Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL);
ASSERT (Option != NULL);
if (!Ip6IsNDOptionValid (Option, OptionLen)) {
@@ -2453,7 +2465,7 @@ Ip6ProcessRedirect ( }
}
- Target = (EFI_IPv6_ADDRESS *) (Icmp + 1);
+ Target = (EFI_IPv6_ADDRESS *)(Icmp + 1);
IcmpDest = Target + 1;
//
@@ -2479,32 +2491,34 @@ Ip6ProcessRedirect ( // address option.
//
Length = Packet->TotalSize - 40;
- Option = (UINT8 *) (IcmpDest + 1);
+ Option = (UINT8 *)(IcmpDest + 1);
LinkLayerOption = NULL;
while (Length > 0) {
switch (*Option) {
- case Ip6OptionEtherTarget:
+ case Ip6OptionEtherTarget:
- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) Option;
- OptLen = LinkLayerOption->Length;
- if (OptLen != 1) {
- //
- // For ethernet, the length must be 1.
- //
- goto Exit;
- }
- break;
+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)Option;
+ OptLen = LinkLayerOption->Length;
+ if (OptLen != 1) {
+ //
+ // For ethernet, the length must be 1.
+ //
+ goto Exit;
+ }
- default:
+ break;
- OptLen = *(Option + 1);
- if (OptLen == 0) {
- //
- // A length of 0 is invalid.
- //
- goto Exit;
- }
- break;
+ default:
+
+ OptLen = *(Option + 1);
+ if (OptLen == 0) {
+ //
+ // A length of 0 is invalid.
+ //
+ goto Exit;
+ }
+
+ break;
}
Length -= 8 * OptLen;
@@ -2535,10 +2549,9 @@ Ip6ProcessRedirect ( IP6_COPY_ADDRESS (&RouteCache->NextHop, Target);
if (!IsRouter) {
- RouteEntry = (IP6_ROUTE_ENTRY *) RouteCache->Tag;
+ RouteEntry = (IP6_ROUTE_ENTRY *)RouteCache->Tag;
RouteEntry->Flag = RouteEntry->Flag | IP6_DIRECT_ROUTE;
}
-
} else {
//
// Get the Route Entry.
@@ -2563,7 +2576,7 @@ Ip6ProcessRedirect ( IcmpDest,
&Head->DestinationAddress,
Target,
- (UINTN) RouteEntry
+ (UINTN)RouteEntry
);
if (RouteCache == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -2600,7 +2613,7 @@ Ip6ProcessRedirect ( }
NeighborCache->State = EfiNeighborStale;
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
} else {
Result = CompareMem (LinkLayerOption->EtherAddr, &NeighborCache->LinkAddress, 6);
@@ -2612,14 +2625,14 @@ Ip6ProcessRedirect ( if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) {
CopyMem (&NeighborCache->LinkAddress, LinkLayerOption->EtherAddr, 6);
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
if (NeighborCache->State == EfiNeighborInComplete) {
//
// Send queued packets if exist.
//
NeighborCache->State = EfiNeighborStale;
- NeighborCache->CallBack ((VOID *) NeighborCache);
+ NeighborCache->CallBack ((VOID *)NeighborCache);
} else {
NeighborCache->State = EfiNeighborStale;
}
@@ -2627,7 +2640,7 @@ Ip6ProcessRedirect ( }
}
- if (NeighborCache != NULL && IsRouter) {
+ if ((NeighborCache != NULL) && IsRouter) {
//
// The Target is a router, set IsRouter to TRUE.
//
@@ -2667,14 +2680,14 @@ Exit: **/
EFI_STATUS
Ip6AddNeighbor (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
)
{
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
Neighbor = Ip6FindNeighborEntry (IpSb, TargetIp6Address);
if (Neighbor != NULL) {
@@ -2702,7 +2715,7 @@ Ip6AddNeighbor ( Neighbor->Ticks = IP6_GET_TICKS (Timeout / TICKS_PER_MS);
Neighbor->Dynamic = TRUE;
} else {
- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
}
return EFI_SUCCESS;
@@ -2729,14 +2742,14 @@ Ip6AddNeighbor ( **/
EFI_STATUS
Ip6DelNeighbor (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
)
{
- IP6_NEIGHBOR_ENTRY *Neighbor;
+ IP6_NEIGHBOR_ENTRY *Neighbor;
Neighbor = Ip6FindNeighborEntry (IpSb, TargetIp6Address);
if (Neighbor == NULL) {
@@ -2761,24 +2774,24 @@ Ip6DelNeighbor ( VOID
EFIAPI
Ip6NdFasterTimerTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- LIST_ENTRY *Entry2;
- IP6_INTERFACE *IpIf;
- IP6_DELAY_JOIN_LIST *DelayNode;
- EFI_IPv6_ADDRESS Source;
- IP6_DAD_ENTRY *DupAddrDetect;
- EFI_STATUS Status;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- EFI_IPv6_ADDRESS Destination;
- IP6_SERVICE *IpSb;
- BOOLEAN Flag;
-
- IpSb = (IP6_SERVICE *) Context;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ LIST_ENTRY *Entry2;
+ IP6_INTERFACE *IpIf;
+ IP6_DELAY_JOIN_LIST *DelayNode;
+ EFI_IPv6_ADDRESS Source;
+ IP6_DAD_ENTRY *DupAddrDetect;
+ EFI_STATUS Status;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ EFI_IPv6_ADDRESS Destination;
+ IP6_SERVICE *IpSb;
+ BOOLEAN Flag;
+
+ IpSb = (IP6_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ZeroMem (&Source, sizeof (EFI_IPv6_ADDRESS));
@@ -2790,13 +2803,14 @@ Ip6NdFasterTimerTicking ( //
if ((IpSb->Ip6ConfigInstance.Policy == Ip6ConfigPolicyAutomatic) &&
!IpSb->RouterAdvertiseReceived &&
- IpSb->SolicitTimer > 0
- ) {
+ (IpSb->SolicitTimer > 0)
+ )
+ {
if ((IpSb->Ticks == 0) || (--IpSb->Ticks == 0)) {
Status = Ip6SendRouterSolicit (IpSb, NULL, NULL, NULL, NULL);
if (!EFI_ERROR (Status)) {
IpSb->SolicitTimer--;
- IpSb->Ticks = (UINT32) IP6_GET_TICKS (IP6_RTR_SOLICITATION_INTERVAL);
+ IpSb->Ticks = (UINT32)IP6_GET_TICKS (IP6_RTR_SOLICITATION_INTERVAL);
}
}
}
@@ -2864,7 +2878,8 @@ Ip6NdFasterTimerTicking ( //
Flag = FALSE;
if ((DupAddrDetect->Receive == 0) ||
- (DupAddrDetect->Transmit <= DupAddrDetect->Receive)) {
+ (DupAddrDetect->Transmit <= DupAddrDetect->Receive))
+ {
Flag = TRUE;
}
@@ -2881,149 +2896,111 @@ Ip6NdFasterTimerTicking ( NeighborCache = NET_LIST_USER_STRUCT (Entry, IP6_NEIGHBOR_ENTRY, Link);
switch (NeighborCache->State) {
- case EfiNeighborInComplete:
- if (NeighborCache->Ticks > 0) {
- --NeighborCache->Ticks;
- }
-
- //
- // Retransmit Neighbor Solicitation messages approximately every
- // RetransTimer milliseconds while awaiting a response.
- //
- if (NeighborCache->Ticks == 0) {
- if (NeighborCache->Transmit > 1) {
- //
- // Send out multicast neighbor solicitation for address resolution.
- // After last neighbor solicitation message has been sent out, wait
- // for RetransTimer and then remove entry if no response is received.
- //
- Ip6CreateSNMulticastAddr (&NeighborCache->Neighbor, &Destination);
- Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
- if (EFI_ERROR (Status)) {
- return;
- }
-
- Status = Ip6SendNeighborSolicit (
- IpSb,
- &Source,
- &Destination,
- &NeighborCache->Neighbor,
- &IpSb->SnpMode.CurrentAddress
- );
- if (EFI_ERROR (Status)) {
- return;
- }
+ case EfiNeighborInComplete:
+ if (NeighborCache->Ticks > 0) {
+ --NeighborCache->Ticks;
}
//
- // Update the retransmit times.
+ // Retransmit Neighbor Solicitation messages approximately every
+ // RetransTimer milliseconds while awaiting a response.
//
- if (NeighborCache->Transmit > 0) {
- --NeighborCache->Transmit;
- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
- }
- }
-
- if (NeighborCache->Transmit == 0) {
- //
- // Timeout, send ICMP destination unreachable packet and then remove entry
- //
- Status = Ip6FreeNeighborEntry (
- IpSb,
- NeighborCache,
- TRUE,
- TRUE,
- EFI_ICMP_ERROR,
- NULL,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return;
- }
- }
+ if (NeighborCache->Ticks == 0) {
+ if (NeighborCache->Transmit > 1) {
+ //
+ // Send out multicast neighbor solicitation for address resolution.
+ // After last neighbor solicitation message has been sent out, wait
+ // for RetransTimer and then remove entry if no response is received.
+ //
+ Ip6CreateSNMulticastAddr (&NeighborCache->Neighbor, &Destination);
+ Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
- break;
+ Status = Ip6SendNeighborSolicit (
+ IpSb,
+ &Source,
+ &Destination,
+ &NeighborCache->Neighbor,
+ &IpSb->SnpMode.CurrentAddress
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ }
- case EfiNeighborReachable:
- //
- // This entry is inserted by EfiIp6Neighbors() as static entry
- // and will not timeout.
- //
- if (!NeighborCache->Dynamic && (NeighborCache->Ticks == IP6_INFINIT_LIFETIME)) {
- break;
- }
+ //
+ // Update the retransmit times.
+ //
+ if (NeighborCache->Transmit > 0) {
+ --NeighborCache->Transmit;
+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ }
+ }
- if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
- if (NeighborCache->Dynamic) {
+ if (NeighborCache->Transmit == 0) {
//
- // This entry is inserted by EfiIp6Neighbors() as dynamic entry
- // and will be deleted after timeout.
+ // Timeout, send ICMP destination unreachable packet and then remove entry
//
Status = Ip6FreeNeighborEntry (
IpSb,
NeighborCache,
- FALSE,
TRUE,
- EFI_TIMEOUT,
+ TRUE,
+ EFI_ICMP_ERROR,
NULL,
NULL
);
if (EFI_ERROR (Status)) {
return;
}
- } else {
- NeighborCache->State = EfiNeighborStale;
- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME;
}
- }
- break;
-
- case EfiNeighborDelay:
- if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
+ break;
- NeighborCache->State = EfiNeighborProbe;
- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
- NeighborCache->Transmit = IP6_MAX_UNICAST_SOLICIT + 1;
+ case EfiNeighborReachable:
//
- // Send out unicast neighbor solicitation for Neighbor Unreachability Detection
+ // This entry is inserted by EfiIp6Neighbors() as static entry
+ // and will not timeout.
//
- Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
- if (EFI_ERROR (Status)) {
- return;
+ if (!NeighborCache->Dynamic && (NeighborCache->Ticks == IP6_INFINIT_LIFETIME)) {
+ break;
}
- Status = Ip6SendNeighborSolicit (
- IpSb,
- &Source,
- &NeighborCache->Neighbor,
- &NeighborCache->Neighbor,
- &IpSb->SnpMode.CurrentAddress
- );
- if (EFI_ERROR (Status)) {
- return;
+ if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
+ if (NeighborCache->Dynamic) {
+ //
+ // This entry is inserted by EfiIp6Neighbors() as dynamic entry
+ // and will be deleted after timeout.
+ //
+ Status = Ip6FreeNeighborEntry (
+ IpSb,
+ NeighborCache,
+ FALSE,
+ TRUE,
+ EFI_TIMEOUT,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ } else {
+ NeighborCache->State = EfiNeighborStale;
+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME;
+ }
}
- NeighborCache->Transmit--;
- }
-
- break;
-
- case EfiNeighborProbe:
- if (NeighborCache->Ticks > 0) {
- --NeighborCache->Ticks;
- }
+ break;
- //
- // Retransmit Neighbor Solicitation messages approximately every
- // RetransTimer milliseconds while awaiting a response.
- //
- if (NeighborCache->Ticks == 0) {
- if (NeighborCache->Transmit > 1) {
+ case EfiNeighborDelay:
+ if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) {
+ NeighborCache->State = EfiNeighborProbe;
+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ NeighborCache->Transmit = IP6_MAX_UNICAST_SOLICIT + 1;
//
- // Send out unicast neighbor solicitation for Neighbor Unreachability
- // Detection. After last neighbor solicitation message has been sent out,
- // wait for RetransTimer and then remove entry if no response is received.
+ // Send out unicast neighbor solicitation for Neighbor Unreachability Detection
//
Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
if (EFI_ERROR (Status)) {
@@ -3040,39 +3017,76 @@ Ip6NdFasterTimerTicking ( if (EFI_ERROR (Status)) {
return;
}
+
+ NeighborCache->Transmit--;
}
- //
- // Update the retransmit times.
- //
- if (NeighborCache->Transmit > 0) {
- --NeighborCache->Transmit;
- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ break;
+
+ case EfiNeighborProbe:
+ if (NeighborCache->Ticks > 0) {
+ --NeighborCache->Ticks;
}
- }
- if (NeighborCache->Transmit == 0) {
//
- // Delete the neighbor entry.
+ // Retransmit Neighbor Solicitation messages approximately every
+ // RetransTimer milliseconds while awaiting a response.
//
- Status = Ip6FreeNeighborEntry (
- IpSb,
- NeighborCache,
- FALSE,
- TRUE,
- EFI_TIMEOUT,
- NULL,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return;
+ if (NeighborCache->Ticks == 0) {
+ if (NeighborCache->Transmit > 1) {
+ //
+ // Send out unicast neighbor solicitation for Neighbor Unreachability
+ // Detection. After last neighbor solicitation message has been sent out,
+ // wait for RetransTimer and then remove entry if no response is received.
+ //
+ Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ Status = Ip6SendNeighborSolicit (
+ IpSb,
+ &Source,
+ &NeighborCache->Neighbor,
+ &NeighborCache->Neighbor,
+ &IpSb->SnpMode.CurrentAddress
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ }
+
+ //
+ // Update the retransmit times.
+ //
+ if (NeighborCache->Transmit > 0) {
+ --NeighborCache->Transmit;
+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer);
+ }
}
- }
- break;
+ if (NeighborCache->Transmit == 0) {
+ //
+ // Delete the neighbor entry.
+ //
+ Status = Ip6FreeNeighborEntry (
+ IpSb,
+ NeighborCache,
+ FALSE,
+ TRUE,
+ EFI_TIMEOUT,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+ }
- default:
- break;
+ break;
+
+ default:
+ break;
}
}
}
@@ -3087,15 +3101,15 @@ Ip6NdFasterTimerTicking ( **/
VOID
Ip6NdTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_DEFAULT_ROUTER *DefaultRouter;
- IP6_PREFIX_LIST_ENTRY *PrefixOption;
- UINT8 Index;
- IP6_ROUTE_CACHE_ENTRY *RouteCache;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_DEFAULT_ROUTER *DefaultRouter;
+ IP6_PREFIX_LIST_ENTRY *PrefixOption;
+ UINT8 Index;
+ IP6_ROUTE_CACHE_ENTRY *RouteCache;
//
// Decrease the lifetime of default router, if expires remove it from default router list.
@@ -3114,11 +3128,12 @@ Ip6NdTimerTicking ( //
NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->AutonomousPrefix) {
PrefixOption = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
- if (PrefixOption->ValidLifetime != (UINT32) IP6_INFINIT_LIFETIME) {
+ if (PrefixOption->ValidLifetime != (UINT32)IP6_INFINIT_LIFETIME) {
if ((PrefixOption->ValidLifetime > 0) && (--PrefixOption->ValidLifetime > 0)) {
- if ((PrefixOption->PreferredLifetime != (UINT32) IP6_INFINIT_LIFETIME) &&
+ if ((PrefixOption->PreferredLifetime != (UINT32)IP6_INFINIT_LIFETIME) &&
(PrefixOption->PreferredLifetime > 0)
- ) {
+ )
+ {
--PrefixOption->PreferredLifetime;
}
} else {
@@ -3129,7 +3144,7 @@ Ip6NdTimerTicking ( NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->OnlinkPrefix) {
PrefixOption = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link);
- if (PrefixOption->ValidLifetime != (UINT32) IP6_INFINIT_LIFETIME) {
+ if (PrefixOption->ValidLifetime != (UINT32)IP6_INFINIT_LIFETIME) {
if ((PrefixOption->ValidLifetime == 0) || (--PrefixOption->ValidLifetime == 0)) {
Ip6DestroyPrefixListEntry (IpSb, PrefixOption, TRUE, TRUE);
}
@@ -3156,4 +3171,3 @@ Ip6NdTimerTicking ( }
}
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.h b/NetworkPkg/Ip6Dxe/Ip6Nd.h index 5f1bd6f..860934a 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Nd.h +++ b/NetworkPkg/Ip6Dxe/Ip6Nd.h @@ -13,82 +13,82 @@ #define IP6_GET_TICKS(Ms) (((Ms) + IP6_TIMER_INTERVAL_IN_MS - 1) / IP6_TIMER_INTERVAL_IN_MS)
enum {
- IP6_INF_ROUTER_LIFETIME = 0xFFFF,
+ IP6_INF_ROUTER_LIFETIME = 0xFFFF,
IP6_MAX_RTR_SOLICITATION_DELAY = 1000, ///< 1000 milliseconds
IP6_MAX_RTR_SOLICITATIONS = 3,
IP6_RTR_SOLICITATION_INTERVAL = 4000,
- IP6_MIN_RANDOM_FACTOR_SCALED = 1,
- IP6_MAX_RANDOM_FACTOR_SCALED = 3,
- IP6_RANDOM_FACTOR_SCALE = 2,
+ IP6_MIN_RANDOM_FACTOR_SCALED = 1,
+ IP6_MAX_RANDOM_FACTOR_SCALED = 3,
+ IP6_RANDOM_FACTOR_SCALE = 2,
- IP6_MAX_MULTICAST_SOLICIT = 3,
- IP6_MAX_UNICAST_SOLICIT = 3,
- IP6_MAX_ANYCAST_DELAY_TIME = 1,
- IP6_MAX_NEIGHBOR_ADV = 3,
- IP6_REACHABLE_TIME = 30000,
- IP6_RETRANS_TIMER = 1000,
- IP6_DELAY_FIRST_PROBE_TIME = 5000,
+ IP6_MAX_MULTICAST_SOLICIT = 3,
+ IP6_MAX_UNICAST_SOLICIT = 3,
+ IP6_MAX_ANYCAST_DELAY_TIME = 1,
+ IP6_MAX_NEIGHBOR_ADV = 3,
+ IP6_REACHABLE_TIME = 30000,
+ IP6_RETRANS_TIMER = 1000,
+ IP6_DELAY_FIRST_PROBE_TIME = 5000,
- IP6_MIN_LINK_MTU = 1280,
- IP6_MAX_LINK_MTU = 1500,
+ IP6_MIN_LINK_MTU = 1280,
+ IP6_MAX_LINK_MTU = 1500,
- IP6_IS_ROUTER_FLAG = 0x80,
- IP6_SOLICITED_FLAG = 0x40,
- IP6_OVERRIDE_FLAG = 0x20,
+ IP6_IS_ROUTER_FLAG = 0x80,
+ IP6_SOLICITED_FLAG = 0x40,
+ IP6_OVERRIDE_FLAG = 0x20,
- IP6_M_ADDR_CONFIG_FLAG = 0x80,
- IP6_O_CONFIG_FLAG = 0x40,
+ IP6_M_ADDR_CONFIG_FLAG = 0x80,
+ IP6_O_CONFIG_FLAG = 0x40,
- IP6_ON_LINK_FLAG = 0x80,
- IP6_AUTO_CONFIG_FLAG = 0x40,
+ IP6_ON_LINK_FLAG = 0x80,
+ IP6_AUTO_CONFIG_FLAG = 0x40,
- IP6_ND_LENGTH = 24,
- IP6_RA_LENGTH = 16,
- IP6_REDITECT_LENGTH = 40,
- IP6_DAD_ENTRY_SIGNATURE = SIGNATURE_32 ('I', 'P', 'D', 'E')
+ IP6_ND_LENGTH = 24,
+ IP6_RA_LENGTH = 16,
+ IP6_REDITECT_LENGTH = 40,
+ IP6_DAD_ENTRY_SIGNATURE = SIGNATURE_32 ('I', 'P', 'D', 'E')
};
typedef
VOID
(*IP6_ARP_CALLBACK) (
- VOID *Context
+ VOID *Context
);
typedef struct _IP6_OPTION_HEADER {
- UINT8 Type;
- UINT8 Length;
+ UINT8 Type;
+ UINT8 Length;
} IP6_OPTION_HEADER;
STATIC_ASSERT (sizeof (IP6_OPTION_HEADER) == 2, "IP6_OPTION_HEADER is expected to be exactly 2 bytes long.");
typedef struct _IP6_ETHE_ADDR_OPTION {
- UINT8 Type;
- UINT8 Length;
- UINT8 EtherAddr[6];
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 EtherAddr[6];
} IP6_ETHER_ADDR_OPTION;
STATIC_ASSERT (sizeof (IP6_ETHER_ADDR_OPTION) == 8, "IP6_ETHER_ADDR_OPTION is expected to be exactly 8 bytes long.");
typedef struct _IP6_MTU_OPTION {
- UINT8 Type;
- UINT8 Length;
- UINT16 Reserved;
- UINT32 Mtu;
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Reserved;
+ UINT32 Mtu;
} IP6_MTU_OPTION;
STATIC_ASSERT (sizeof (IP6_MTU_OPTION) == 8, "IP6_MTU_OPTION is expected to be exactly 8 bytes long.");
typedef struct _IP6_PREFIX_INFO_OPTION {
- UINT8 Type;
- UINT8 Length;
- UINT8 PrefixLength;
- UINT8 Reserved1;
- UINT32 ValidLifetime;
- UINT32 PreferredLifetime;
- UINT32 Reserved2;
- EFI_IPv6_ADDRESS Prefix;
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 PrefixLength;
+ UINT8 Reserved1;
+ UINT32 ValidLifetime;
+ UINT32 PreferredLifetime;
+ UINT32 Reserved2;
+ EFI_IPv6_ADDRESS Prefix;
} IP6_PREFIX_INFO_OPTION;
STATIC_ASSERT (sizeof (IP6_PREFIX_INFO_OPTION) == 32, "IP6_PREFIX_INFO_OPTION is expected to be exactly 32 bytes long.");
@@ -102,25 +102,25 @@ VOID );
typedef struct _IP6_DAD_ENTRY {
- UINT32 Signature;
- LIST_ENTRY Link;
- UINT32 MaxTransmit;
- UINT32 Transmit;
- UINT32 Receive;
- UINT32 RetransTick;
- IP6_ADDRESS_INFO *AddressInfo;
- EFI_IPv6_ADDRESS Destination;
- IP6_DAD_CALLBACK Callback;
- VOID *Context;
+ UINT32 Signature;
+ LIST_ENTRY Link;
+ UINT32 MaxTransmit;
+ UINT32 Transmit;
+ UINT32 Receive;
+ UINT32 RetransTick;
+ IP6_ADDRESS_INFO *AddressInfo;
+ EFI_IPv6_ADDRESS Destination;
+ IP6_DAD_CALLBACK Callback;
+ VOID *Context;
} IP6_DAD_ENTRY;
typedef struct _IP6_DELAY_JOIN_LIST {
- LIST_ENTRY Link;
- UINT32 DelayTime; ///< in tick per 50 milliseconds
- IP6_INTERFACE *Interface;
- IP6_ADDRESS_INFO *AddressInfo;
- IP6_DAD_CALLBACK DadCallback;
- VOID *Context;
+ LIST_ENTRY Link;
+ UINT32 DelayTime; ///< in tick per 50 milliseconds
+ IP6_INTERFACE *Interface;
+ IP6_ADDRESS_INFO *AddressInfo;
+ IP6_DAD_CALLBACK DadCallback;
+ VOID *Context;
} IP6_DELAY_JOIN_LIST;
typedef struct _IP6_NEIGHBOR_ENTRY {
@@ -142,20 +142,20 @@ typedef struct _IP6_NEIGHBOR_ENTRY { } IP6_NEIGHBOR_ENTRY;
typedef struct _IP6_DEFAULT_ROUTER {
- LIST_ENTRY Link;
- INTN RefCnt;
- UINT16 Lifetime;
- EFI_IPv6_ADDRESS Router;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
+ LIST_ENTRY Link;
+ INTN RefCnt;
+ UINT16 Lifetime;
+ EFI_IPv6_ADDRESS Router;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
} IP6_DEFAULT_ROUTER;
typedef struct _IP6_PREFIX_LIST_ENTRY {
- LIST_ENTRY Link;
- INTN RefCnt;
- UINT32 ValidLifetime;
- UINT32 PreferredLifetime;
- UINT8 PrefixLength;
- EFI_IPv6_ADDRESS Prefix;
+ LIST_ENTRY Link;
+ INTN RefCnt;
+ UINT32 ValidLifetime;
+ UINT32 PreferredLifetime;
+ UINT8 PrefixLength;
+ EFI_IPv6_ADDRESS Prefix;
} IP6_PREFIX_LIST_ENTRY;
/**
@@ -172,9 +172,9 @@ typedef struct _IP6_PREFIX_LIST_ENTRY { **/
EFI_STATUS
Ip6BuildEfiNeighborCache (
- IN IP6_PROTOCOL *IpInstance,
- OUT UINT32 *NeighborCount,
- OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache
+ IN IP6_PROTOCOL *IpInstance,
+ OUT UINT32 *NeighborCount,
+ OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache
);
/**
@@ -210,9 +210,9 @@ Ip6BuildPrefixTable ( **/
IP6_DEFAULT_ROUTER *
Ip6CreateDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address,
- IN UINT16 RouterLifetime
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ IN UINT16 RouterLifetime
);
/**
@@ -224,8 +224,8 @@ Ip6CreateDefaultRouter ( **/
VOID
Ip6DestroyDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN IP6_DEFAULT_ROUTER *DefaultRouter
+ IN IP6_SERVICE *IpSb,
+ IN IP6_DEFAULT_ROUTER *DefaultRouter
);
/**
@@ -236,7 +236,7 @@ Ip6DestroyDefaultRouter ( **/
VOID
Ip6CleanDefaultRouterList (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
);
/**
@@ -251,8 +251,8 @@ Ip6CleanDefaultRouterList ( **/
IP6_DEFAULT_ROUTER *
Ip6FindDefaultRouter (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address
);
/**
@@ -289,10 +289,10 @@ Ip6OnDADFinished ( **/
EFI_STATUS
Ip6InitDADProcess (
- IN IP6_INTERFACE *IpIf,
- IN IP6_ADDRESS_INFO *AddressInfo,
- IN IP6_DAD_CALLBACK Callback OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *IpIf,
+ IN IP6_ADDRESS_INFO *AddressInfo,
+ IN IP6_DAD_CALLBACK Callback OPTIONAL,
+ IN VOID *Context OPTIONAL
);
/**
@@ -309,9 +309,9 @@ Ip6InitDADProcess ( **/
IP6_DAD_ENTRY *
Ip6FindDADEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Target,
- OUT IP6_INTERFACE **Interface OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Target,
+ OUT IP6_INTERFACE **Interface OPTIONAL
);
/**
@@ -334,12 +334,12 @@ Ip6FindDADEntry ( **/
IP6_PREFIX_LIST_ENTRY *
Ip6CreatePrefixListEntry (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN OnLinkOrAuto,
- IN UINT32 ValidLifetime,
- IN UINT32 PreferredLifetime,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *Prefix
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN OnLinkOrAuto,
+ IN UINT32 ValidLifetime,
+ IN UINT32 PreferredLifetime,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *Prefix
);
/**
@@ -377,10 +377,10 @@ Ip6DestroyPrefixListEntry ( **/
IP6_PREFIX_LIST_ENTRY *
Ip6FindPrefixListEntry (
- IN IP6_SERVICE *IpSb,
- IN BOOLEAN OnLinkOrAuto,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *Prefix
+ IN IP6_SERVICE *IpSb,
+ IN BOOLEAN OnLinkOrAuto,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *Prefix
);
/**
@@ -393,8 +393,8 @@ Ip6FindPrefixListEntry ( **/
VOID
Ip6CleanPrefixListTable (
- IN IP6_SERVICE *IpSb,
- IN LIST_ENTRY *ListHead
+ IN IP6_SERVICE *IpSb,
+ IN LIST_ENTRY *ListHead
);
/**
@@ -413,10 +413,10 @@ Ip6CleanPrefixListTable ( **/
IP6_NEIGHBOR_ENTRY *
Ip6CreateNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN IP6_ARP_CALLBACK CallBack,
- IN EFI_IPv6_ADDRESS *Ip6Address,
- IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_ARP_CALLBACK CallBack,
+ IN EFI_IPv6_ADDRESS *Ip6Address,
+ IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL
);
/**
@@ -431,8 +431,8 @@ Ip6CreateNeighborEntry ( **/
IP6_NEIGHBOR_ENTRY *
Ip6FindNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Ip6Address
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Ip6Address
);
/**
@@ -458,13 +458,13 @@ Ip6FindNeighborEntry ( **/
EFI_STATUS
Ip6FreeNeighborEntry (
- IN IP6_SERVICE *IpSb,
- IN IP6_NEIGHBOR_ENTRY *NeighborCache,
- IN BOOLEAN SendIcmpError,
- IN BOOLEAN FullFree,
- IN EFI_STATUS IoStatus,
- IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_NEIGHBOR_ENTRY *NeighborCache,
+ IN BOOLEAN SendIcmpError,
+ IN BOOLEAN FullFree,
+ IN EFI_STATUS IoStatus,
+ IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
+ IN VOID *Context OPTIONAL
);
/**
@@ -493,11 +493,11 @@ Ip6FreeNeighborEntry ( **/
EFI_STATUS
Ip6AddNeighbor (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
);
/**
@@ -521,11 +521,11 @@ Ip6AddNeighbor ( **/
EFI_STATUS
Ip6DelNeighbor (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
- IN UINT32 Timeout,
- IN BOOLEAN Override
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL,
+ IN UINT32 Timeout,
+ IN BOOLEAN Override
);
/**
@@ -544,9 +544,9 @@ Ip6DelNeighbor ( **/
EFI_STATUS
Ip6ProcessNeighborSolicit (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
/**
@@ -564,9 +564,9 @@ Ip6ProcessNeighborSolicit ( **/
EFI_STATUS
Ip6ProcessNeighborAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
/**
@@ -584,9 +584,9 @@ Ip6ProcessNeighborAdvertise ( **/
EFI_STATUS
Ip6ProcessRouterAdvertise (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
/**
@@ -607,9 +607,9 @@ Ip6ProcessRouterAdvertise ( **/
EFI_STATUS
Ip6ProcessRedirect (
- IN IP6_SERVICE *IpSb,
- IN EFI_IP6_HEADER *Head,
- IN NET_BUF *Packet
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IP6_HEADER *Head,
+ IN NET_BUF *Packet
);
/**
@@ -631,11 +631,11 @@ Ip6ProcessRedirect ( **/
EFI_STATUS
Ip6SendRouterSolicit (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface OPTIONAL,
- IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
- IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL,
- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface OPTIONAL,
+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL,
+ IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL,
+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
);
/**
@@ -658,11 +658,11 @@ Ip6SendRouterSolicit ( **/
EFI_STATUS
Ip6SendNeighborSolicit (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *SourceAddress,
- IN EFI_IPv6_ADDRESS *DestinationAddress,
- IN EFI_IPv6_ADDRESS *TargetIp6Address,
- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *SourceAddress,
+ IN EFI_IPv6_ADDRESS *DestinationAddress,
+ IN EFI_IPv6_ADDRESS *TargetIp6Address,
+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL
);
/**
@@ -690,14 +690,14 @@ Ip6SendNeighborSolicit ( **/
EFI_STATUS
Ip6SetAddress (
- IN IP6_INTERFACE *Interface,
- IN EFI_IPv6_ADDRESS *Ip6Addr,
- IN BOOLEAN IsAnycast,
- IN UINT8 PrefixLength,
- IN UINT32 ValidLifetime,
- IN UINT32 PreferredLifetime,
- IN IP6_DAD_CALLBACK DadCallback OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN EFI_IPv6_ADDRESS *Ip6Addr,
+ IN BOOLEAN IsAnycast,
+ IN UINT8 PrefixLength,
+ IN UINT32 ValidLifetime,
+ IN UINT32 PreferredLifetime,
+ IN IP6_DAD_CALLBACK DadCallback OPTIONAL,
+ IN VOID *Context OPTIONAL
);
/**
@@ -712,8 +712,8 @@ Ip6SetAddress ( VOID
EFIAPI
Ip6NdFasterTimerTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -726,7 +726,7 @@ Ip6NdFasterTimerTicking ( **/
VOID
Ip6NdTimerTicking (
- IN IP6_SERVICE *IpSb
+ IN IP6_SERVICE *IpSb
);
/**
@@ -739,7 +739,7 @@ Ip6NdTimerTicking ( **/
VOID
Ip6OnArpResolved (
- IN VOID *Context
+ IN VOID *Context
);
/**
diff --git a/NetworkPkg/Ip6Dxe/Ip6NvData.h b/NetworkPkg/Ip6Dxe/Ip6NvData.h index eb36d7e..d1c1c13 100644 --- a/NetworkPkg/Ip6Dxe/Ip6NvData.h +++ b/NetworkPkg/Ip6Dxe/Ip6NvData.h @@ -12,35 +12,35 @@ #include <Guid/Ip6ConfigHii.h>
-#define FORMID_MAIN_FORM 1
-#define FORMID_MANUAL_CONFIG_FORM 2
-#define FORMID_HEAD_FORM 3
-
-#define IP6_POLICY_AUTO 0
-#define IP6_POLICY_MANUAL 1
-#define DAD_MAX_TRANSMIT_COUNT 10
-
-#define KEY_INTERFACE_ID 0x101
-#define KEY_MANUAL_ADDRESS 0x102
-#define KEY_GATEWAY_ADDRESS 0x103
-#define KEY_DNS_ADDRESS 0x104
-#define KEY_SAVE_CHANGES 0x105
-#define KEY_SAVE_CONFIG_CHANGES 0x106
-#define KEY_IGNORE_CONFIG_CHANGES 0x107
-#define KEY_GET_CURRENT_SETTING 0x108
-
-#define HOST_ADDRESS_LABEL 0x9000
-#define ROUTE_TABLE_LABEL 0xa000
-#define GATEWAY_ADDRESS_LABEL 0xb000
-#define DNS_ADDRESS_LABEL 0xc000
-#define LABEL_END 0xffff
-
-#define INTERFACE_ID_STR_MIN_SIZE 1
-#define INTERFACE_ID_STR_MAX_SIZE 23
-#define INTERFACE_ID_STR_STORAGE 25
-#define IP6_STR_MAX_SIZE 40
-#define ADDRESS_STR_MIN_SIZE 2
-#define ADDRESS_STR_MAX_SIZE 255
+#define FORMID_MAIN_FORM 1
+#define FORMID_MANUAL_CONFIG_FORM 2
+#define FORMID_HEAD_FORM 3
+
+#define IP6_POLICY_AUTO 0
+#define IP6_POLICY_MANUAL 1
+#define DAD_MAX_TRANSMIT_COUNT 10
+
+#define KEY_INTERFACE_ID 0x101
+#define KEY_MANUAL_ADDRESS 0x102
+#define KEY_GATEWAY_ADDRESS 0x103
+#define KEY_DNS_ADDRESS 0x104
+#define KEY_SAVE_CHANGES 0x105
+#define KEY_SAVE_CONFIG_CHANGES 0x106
+#define KEY_IGNORE_CONFIG_CHANGES 0x107
+#define KEY_GET_CURRENT_SETTING 0x108
+
+#define HOST_ADDRESS_LABEL 0x9000
+#define ROUTE_TABLE_LABEL 0xa000
+#define GATEWAY_ADDRESS_LABEL 0xb000
+#define DNS_ADDRESS_LABEL 0xc000
+#define LABEL_END 0xffff
+
+#define INTERFACE_ID_STR_MIN_SIZE 1
+#define INTERFACE_ID_STR_MAX_SIZE 23
+#define INTERFACE_ID_STR_STORAGE 25
+#define IP6_STR_MAX_SIZE 40
+#define ADDRESS_STR_MIN_SIZE 2
+#define ADDRESS_STR_MAX_SIZE 255
///
/// IP6_CONFIG_IFR_NVDATA contains the IP6 configure
@@ -48,16 +48,15 @@ ///
#pragma pack(1)
typedef struct {
- UINT8 IfType; ///< interface type
- UINT8 Padding[3];
- UINT32 Policy; ///< manual or automatic
- UINT32 DadTransmitCount; ///< dad transmits count
- CHAR16 InterfaceId[INTERFACE_ID_STR_STORAGE]; ///< alternative interface id
- CHAR16 ManualAddress[ADDRESS_STR_MAX_SIZE]; ///< IP addresses
- CHAR16 GatewayAddress[ADDRESS_STR_MAX_SIZE]; ///< Gateway address
- CHAR16 DnsAddress[ADDRESS_STR_MAX_SIZE]; ///< DNS server address
+ UINT8 IfType; ///< interface type
+ UINT8 Padding[3];
+ UINT32 Policy; ///< manual or automatic
+ UINT32 DadTransmitCount; ///< dad transmits count
+ CHAR16 InterfaceId[INTERFACE_ID_STR_STORAGE]; ///< alternative interface id
+ CHAR16 ManualAddress[ADDRESS_STR_MAX_SIZE]; ///< IP addresses
+ CHAR16 GatewayAddress[ADDRESS_STR_MAX_SIZE]; ///< Gateway address
+ CHAR16 DnsAddress[ADDRESS_STR_MAX_SIZE]; ///< DNS server address
} IP6_CONFIG_IFR_NVDATA;
#pragma pack()
#endif
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Option.c b/NetworkPkg/Ip6Dxe/Ip6Option.c index 6b4b029..199eea1 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Option.c +++ b/NetworkPkg/Ip6Dxe/Ip6Option.c @@ -28,15 +28,15 @@ **/
BOOLEAN
Ip6IsOptionValid (
- IN IP6_SERVICE *IpSb,
- IN NET_BUF *Packet,
- IN UINT8 *Option,
- IN UINT8 OptionLen,
- IN UINT32 Pointer
+ IN IP6_SERVICE *IpSb,
+ IN NET_BUF *Packet,
+ IN UINT8 *Option,
+ IN UINT8 OptionLen,
+ IN UINT32 Pointer
)
{
- UINT8 Offset;
- UINT8 OptionType;
+ UINT8 Offset;
+ UINT8 OptionType;
Offset = 0;
@@ -44,68 +44,67 @@ Ip6IsOptionValid ( OptionType = *(Option + Offset);
switch (OptionType) {
- case Ip6OptionPad1:
- //
- // It is a Pad1 option
- //
- Offset++;
- break;
- case Ip6OptionPadN:
- //
- // It is a PadN option
- //
- Offset = (UINT8) (Offset + *(Option + Offset + 1) + 2);
- break;
- case Ip6OptionRouterAlert:
- //
- // It is a Router Alert Option
- //
- Offset += 4;
- break;
- default:
- //
- // The highest-order two bits specify the action must be taken if
- // the processing IPv6 node does not recognize the option type.
- //
- switch (OptionType & Ip6OptionMask) {
- case Ip6OptionSkip:
- Offset = (UINT8) (Offset + *(Option + Offset + 1));
+ case Ip6OptionPad1:
+ //
+ // It is a Pad1 option
+ //
+ Offset++;
break;
- case Ip6OptionDiscard:
- return FALSE;
- case Ip6OptionParameterProblem:
- Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER);
- Ip6SendIcmpError (
- IpSb,
- Packet,
- NULL,
- &Packet->Ip.Ip6->SourceAddress,
- ICMP_V6_PARAMETER_PROBLEM,
- 2,
- &Pointer
- );
- return FALSE;
- case Ip6OptionMask:
- if (!IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) {
- Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER);
- Ip6SendIcmpError (
- IpSb,
- Packet,
- NULL,
- &Packet->Ip.Ip6->SourceAddress,
- ICMP_V6_PARAMETER_PROBLEM,
- 2,
- &Pointer
- );
+ case Ip6OptionPadN:
+ //
+ // It is a PadN option
+ //
+ Offset = (UINT8)(Offset + *(Option + Offset + 1) + 2);
+ break;
+ case Ip6OptionRouterAlert:
+ //
+ // It is a Router Alert Option
+ //
+ Offset += 4;
+ break;
+ default:
+ //
+ // The highest-order two bits specify the action must be taken if
+ // the processing IPv6 node does not recognize the option type.
+ //
+ switch (OptionType & Ip6OptionMask) {
+ case Ip6OptionSkip:
+ Offset = (UINT8)(Offset + *(Option + Offset + 1));
+ break;
+ case Ip6OptionDiscard:
+ return FALSE;
+ case Ip6OptionParameterProblem:
+ Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER);
+ Ip6SendIcmpError (
+ IpSb,
+ Packet,
+ NULL,
+ &Packet->Ip.Ip6->SourceAddress,
+ ICMP_V6_PARAMETER_PROBLEM,
+ 2,
+ &Pointer
+ );
+ return FALSE;
+ case Ip6OptionMask:
+ if (!IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) {
+ Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER);
+ Ip6SendIcmpError (
+ IpSb,
+ Packet,
+ NULL,
+ &Packet->Ip.Ip6->SourceAddress,
+ ICMP_V6_PARAMETER_PROBLEM,
+ 2,
+ &Pointer
+ );
+ }
+
+ return FALSE;
+ break;
}
- return FALSE;
break;
- }
-
- break;
}
-
}
return TRUE;
@@ -125,13 +124,13 @@ Ip6IsOptionValid ( **/
BOOLEAN
Ip6IsNDOptionValid (
- IN UINT8 *Option,
- IN UINT16 OptionLen
+ IN UINT8 *Option,
+ IN UINT16 OptionLen
)
{
- UINT32 Offset;
- UINT16 Length;
- IP6_OPTION_HEADER *OptionHeader;
+ UINT32 Offset;
+ UINT16 Length;
+ IP6_OPTION_HEADER *OptionHeader;
if (Option == NULL) {
ASSERT (Option != NULL);
@@ -146,50 +145,54 @@ Ip6IsNDOptionValid ( // fit within the input buffer.
//
while (Offset + sizeof (IP6_OPTION_HEADER) - 1 < OptionLen) {
- OptionHeader = (IP6_OPTION_HEADER*) (Option + Offset);
- Length = (UINT16) OptionHeader->Length * 8;
+ OptionHeader = (IP6_OPTION_HEADER *)(Option + Offset);
+ Length = (UINT16)OptionHeader->Length * 8;
switch (OptionHeader->Type) {
- case Ip6OptionPrefixInfo:
- if (Length != 32) {
- return FALSE;
- }
- break;
+ case Ip6OptionPrefixInfo:
+ if (Length != 32) {
+ return FALSE;
+ }
- case Ip6OptionMtu:
- if (Length != 8) {
- return FALSE;
- }
- break;
+ break;
- default:
- // RFC 4861 states that Length field cannot be 0.
- if (Length == 0) {
- return FALSE;
- }
- break;
+ case Ip6OptionMtu:
+ if (Length != 8) {
+ return FALSE;
+ }
+
+ break;
+
+ default:
+ // RFC 4861 states that Length field cannot be 0.
+ if (Length == 0) {
+ return FALSE;
+ }
+
+ break;
}
//
// Check whether recognized options are within the input buffer's scope.
//
switch (OptionHeader->Type) {
- case Ip6OptionEtherSource:
- case Ip6OptionEtherTarget:
- case Ip6OptionPrefixInfo:
- case Ip6OptionRedirected:
- case Ip6OptionMtu:
- if (Offset + Length > (UINT32) OptionLen) {
- return FALSE;
- }
- break;
+ case Ip6OptionEtherSource:
+ case Ip6OptionEtherTarget:
+ case Ip6OptionPrefixInfo:
+ case Ip6OptionRedirected:
+ case Ip6OptionMtu:
+ if (Offset + Length > (UINT32)OptionLen) {
+ return FALSE;
+ }
- default:
- //
- // Unrecognized options can be either valid (but unused) or invalid
- // (garbage in between or right after valid options). Silently ignore.
- //
- break;
+ break;
+
+ default:
+ //
+ // Unrecognized options can be either valid (but unused) or invalid
+ // (garbage in between or right after valid options). Silently ignore.
+ //
+ break;
}
//
@@ -202,7 +205,6 @@ Ip6IsNDOptionValid ( return TRUE;
}
-
/**
Validate whether the NextHeader is a known valid protocol or one of the user configured
protocols from the upper layer.
@@ -216,18 +218,19 @@ Ip6IsNDOptionValid ( **/
BOOLEAN
Ip6IsValidProtocol (
- IN IP6_SERVICE *IpSb,
- IN UINT8 NextHeader
+ IN IP6_SERVICE *IpSb,
+ IN UINT8 NextHeader
)
{
- LIST_ENTRY *Entry;
- IP6_PROTOCOL *IpInstance;
-
- if (NextHeader == EFI_IP_PROTO_TCP ||
- NextHeader == EFI_IP_PROTO_UDP ||
- NextHeader == IP6_ICMP ||
- NextHeader == IP6_ESP
- ) {
+ LIST_ENTRY *Entry;
+ IP6_PROTOCOL *IpInstance;
+
+ if ((NextHeader == EFI_IP_PROTO_TCP) ||
+ (NextHeader == EFI_IP_PROTO_UDP) ||
+ (NextHeader == IP6_ICMP) ||
+ (NextHeader == IP6_ESP)
+ )
+ {
return TRUE;
}
@@ -281,29 +284,29 @@ Ip6IsValidProtocol ( **/
BOOLEAN
Ip6IsExtsValid (
- IN IP6_SERVICE *IpSb OPTIONAL,
- IN NET_BUF *Packet OPTIONAL,
- IN UINT8 *NextHeader,
- IN UINT8 *ExtHdrs,
- IN UINT32 ExtHdrsLen,
- IN BOOLEAN Rcvd,
- OUT UINT32 *FormerHeader OPTIONAL,
- OUT UINT8 **LastHeader,
- OUT UINT32 *RealExtsLen OPTIONAL,
- OUT UINT32 *UnFragmentLen OPTIONAL,
- OUT BOOLEAN *Fragmented OPTIONAL
+ IN IP6_SERVICE *IpSb OPTIONAL,
+ IN NET_BUF *Packet OPTIONAL,
+ IN UINT8 *NextHeader,
+ IN UINT8 *ExtHdrs,
+ IN UINT32 ExtHdrsLen,
+ IN BOOLEAN Rcvd,
+ OUT UINT32 *FormerHeader OPTIONAL,
+ OUT UINT8 **LastHeader,
+ OUT UINT32 *RealExtsLen OPTIONAL,
+ OUT UINT32 *UnFragmentLen OPTIONAL,
+ OUT BOOLEAN *Fragmented OPTIONAL
)
{
- UINT32 Pointer;
- UINT32 Offset;
- UINT8 *Option;
- UINT8 OptionLen;
- BOOLEAN Flag;
- UINT8 CountD;
- UINT8 CountA;
- IP6_FRAGMENT_HEADER *FragmentHead;
- UINT16 FragmentOffset;
- IP6_ROUTING_HEADER *RoutingHead;
+ UINT32 Pointer;
+ UINT32 Offset;
+ UINT8 *Option;
+ UINT8 OptionLen;
+ BOOLEAN Flag;
+ UINT8 CountD;
+ UINT8 CountA;
+ IP6_FRAGMENT_HEADER *FragmentHead;
+ UINT16 FragmentOffset;
+ IP6_ROUTING_HEADER *RoutingHead;
if (RealExtsLen != NULL) {
*RealExtsLen = 0;
@@ -319,11 +322,11 @@ Ip6IsExtsValid ( *LastHeader = NextHeader;
- if (ExtHdrs == NULL && ExtHdrsLen == 0) {
+ if ((ExtHdrs == NULL) && (ExtHdrsLen == 0)) {
return TRUE;
}
- if ((ExtHdrs == NULL && ExtHdrsLen != 0) || (ExtHdrs != NULL && ExtHdrsLen == 0)) {
+ if (((ExtHdrs == NULL) && (ExtHdrsLen != 0)) || ((ExtHdrs != NULL) && (ExtHdrsLen == 0))) {
return FALSE;
}
@@ -334,236 +337,240 @@ Ip6IsExtsValid ( CountA = 0;
while (Offset <= ExtHdrsLen) {
-
switch (*NextHeader) {
- case IP6_HOP_BY_HOP:
- if (Offset != 0) {
- if (!Rcvd) {
+ case IP6_HOP_BY_HOP:
+ if (Offset != 0) {
+ if (!Rcvd) {
+ return FALSE;
+ }
+
+ //
+ // Hop-by-Hop Options header is restricted to appear immediately after an IPv6 header only.
+ // If not, generate a ICMP parameter problem message with code value of 1.
+ //
+ if (Pointer == 0) {
+ Pointer = sizeof (EFI_IP6_HEADER);
+ } else {
+ Pointer = Offset + sizeof (EFI_IP6_HEADER);
+ }
+
+ if ((IpSb != NULL) && (Packet != NULL) &&
+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
+ {
+ Ip6SendIcmpError (
+ IpSb,
+ Packet,
+ NULL,
+ &Packet->Ip.Ip6->SourceAddress,
+ ICMP_V6_PARAMETER_PROBLEM,
+ 1,
+ &Pointer
+ );
+ }
+
return FALSE;
}
- //
- // Hop-by-Hop Options header is restricted to appear immediately after an IPv6 header only.
- // If not, generate a ICMP parameter problem message with code value of 1.
- //
- if (Pointer == 0) {
- Pointer = sizeof (EFI_IP6_HEADER);
- } else {
- Pointer = Offset + sizeof (EFI_IP6_HEADER);
+
+ Flag = TRUE;
+
+ //
+ // Fall through
+ //
+ case IP6_DESTINATION:
+ if (*NextHeader == IP6_DESTINATION) {
+ CountD++;
}
- if ((IpSb != NULL) && (Packet != NULL) &&
- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) {
- Ip6SendIcmpError (
- IpSb,
- Packet,
- NULL,
- &Packet->Ip.Ip6->SourceAddress,
- ICMP_V6_PARAMETER_PROBLEM,
- 1,
- &Pointer
- );
+ if (CountD > 2) {
+ return FALSE;
}
- return FALSE;
- }
- Flag = TRUE;
+ NextHeader = ExtHdrs + Offset;
+ Pointer = Offset;
- //
- // Fall through
- //
- case IP6_DESTINATION:
- if (*NextHeader == IP6_DESTINATION) {
- CountD++;
- }
+ Offset++;
+ Option = ExtHdrs + Offset;
+ OptionLen = (UINT8)((*Option + 1) * 8 - 2);
+ Option++;
+ Offset++;
- if (CountD > 2) {
- return FALSE;
- }
+ if ((IpSb != NULL) && (Packet != NULL) && !Ip6IsOptionValid (IpSb, Packet, Option, OptionLen, Offset)) {
+ return FALSE;
+ }
- NextHeader = ExtHdrs + Offset;
- Pointer = Offset;
+ Offset = Offset + OptionLen;
- Offset++;
- Option = ExtHdrs + Offset;
- OptionLen = (UINT8) ((*Option + 1) * 8 - 2);
- Option++;
- Offset++;
+ if (Flag) {
+ if (UnFragmentLen != NULL) {
+ *UnFragmentLen = Offset;
+ }
- if (IpSb != NULL && Packet != NULL && !Ip6IsOptionValid (IpSb, Packet, Option, OptionLen, Offset)) {
- return FALSE;
- }
+ Flag = FALSE;
+ }
+
+ break;
- Offset = Offset + OptionLen;
+ case IP6_ROUTING:
+ NextHeader = ExtHdrs + Offset;
+ RoutingHead = (IP6_ROUTING_HEADER *)NextHeader;
- if (Flag) {
- if (UnFragmentLen != NULL) {
- *UnFragmentLen = Offset;
+ //
+ // Type 0 routing header is defined in RFC2460 and deprecated in RFC5095.
+ // Thus all routing types are processed as unrecognized.
+ //
+ if (RoutingHead->SegmentsLeft == 0) {
+ //
+ // Ignore the routing header and proceed to process the next header.
+ //
+ Offset = Offset + (RoutingHead->HeaderLen + 1) * 8;
+
+ if (UnFragmentLen != NULL) {
+ *UnFragmentLen = Offset;
+ }
+ } else {
+ //
+ // Discard the packet and send an ICMP Parameter Problem, Code 0, message
+ // to the packet's source address, pointing to the unrecognized routing
+ // type.
+ //
+ Pointer = Offset + 2 + sizeof (EFI_IP6_HEADER);
+ if ((IpSb != NULL) && (Packet != NULL) &&
+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
+ {
+ Ip6SendIcmpError (
+ IpSb,
+ Packet,
+ NULL,
+ &Packet->Ip.Ip6->SourceAddress,
+ ICMP_V6_PARAMETER_PROBLEM,
+ 0,
+ &Pointer
+ );
+ }
+
+ return FALSE;
}
- Flag = FALSE;
- }
+ break;
- break;
+ case IP6_FRAGMENT:
- case IP6_ROUTING:
- NextHeader = ExtHdrs + Offset;
- RoutingHead = (IP6_ROUTING_HEADER *) NextHeader;
+ //
+ // RFC2402, AH header should after fragment header.
+ //
+ if (CountA > 1) {
+ return FALSE;
+ }
- //
- // Type 0 routing header is defined in RFC2460 and deprecated in RFC5095.
- // Thus all routing types are processed as unrecognized.
- //
- if (RoutingHead->SegmentsLeft == 0) {
//
- // Ignore the routing header and proceed to process the next header.
+ // RFC2460, ICMP Parameter Problem message with code 0 should be sent
+ // if the length of a fragment is not a multiple of 8 octets and the M
+ // flag of that fragment is 1, pointing to the Payload length field of the
+ // fragment packet.
//
- Offset = Offset + (RoutingHead->HeaderLen + 1) * 8;
+ if ((IpSb != NULL) && (Packet != NULL) && ((ExtHdrsLen % 8) != 0)) {
+ //
+ // Check whether it is the last fragment.
+ //
+ FragmentHead = (IP6_FRAGMENT_HEADER *)(ExtHdrs + Offset);
+ if (FragmentHead == NULL) {
+ return FALSE;
+ }
+
+ FragmentOffset = NTOHS (FragmentHead->FragmentOffset);
+
+ if (((FragmentOffset & 0x1) == 0x1) &&
+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
+ {
+ Pointer = sizeof (UINT32);
+ Ip6SendIcmpError (
+ IpSb,
+ Packet,
+ NULL,
+ &Packet->Ip.Ip6->SourceAddress,
+ ICMP_V6_PARAMETER_PROBLEM,
+ 0,
+ &Pointer
+ );
+ return FALSE;
+ }
+ }
+
+ if (Fragmented != NULL) {
+ *Fragmented = TRUE;
+ }
+
+ if (Rcvd && (FormerHeader != NULL)) {
+ *FormerHeader = (UINT32)(NextHeader - ExtHdrs);
+ }
+
+ NextHeader = ExtHdrs + Offset;
+ Offset = Offset + 8;
+ break;
- if (UnFragmentLen != NULL) {
- *UnFragmentLen = Offset;
+ case IP6_AH:
+ if (++CountA > 1) {
+ return FALSE;
}
- } else {
+ Option = ExtHdrs + Offset;
+ NextHeader = Option;
+ Option++;
//
- // Discard the packet and send an ICMP Parameter Problem, Code 0, message
- // to the packet's source address, pointing to the unrecognized routing
- // type.
+ // RFC2402, Payload length is specified in 32-bit words, minus "2".
//
- Pointer = Offset + 2 + sizeof (EFI_IP6_HEADER);
- if ((IpSb != NULL) && (Packet != NULL) &&
- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) {
- Ip6SendIcmpError (
- IpSb,
- Packet,
- NULL,
- &Packet->Ip.Ip6->SourceAddress,
- ICMP_V6_PARAMETER_PROBLEM,
- 0,
- &Pointer
- );
- }
+ OptionLen = (UINT8)((*Option + 2) * 4);
+ Offset = Offset + OptionLen;
+ break;
+ case IP6_NO_NEXT_HEADER:
+ *LastHeader = NextHeader;
return FALSE;
- }
+ break;
- break;
+ default:
+ if (Ip6IsValidProtocol (IpSb, *NextHeader)) {
+ *LastHeader = NextHeader;
- case IP6_FRAGMENT:
+ if (RealExtsLen != NULL) {
+ *RealExtsLen = Offset;
+ }
- //
- // RFC2402, AH header should after fragment header.
- //
- if (CountA > 1) {
- return FALSE;
- }
+ return TRUE;
+ }
- //
- // RFC2460, ICMP Parameter Problem message with code 0 should be sent
- // if the length of a fragment is not a multiple of 8 octets and the M
- // flag of that fragment is 1, pointing to the Payload length field of the
- // fragment packet.
- //
- if (IpSb != NULL && Packet != NULL && (ExtHdrsLen % 8) != 0) {
//
- // Check whether it is the last fragment.
+ // The Next Header value is unrecognized by the node, discard the packet and
+ // send an ICMP parameter problem message with code value of 1.
//
- FragmentHead = (IP6_FRAGMENT_HEADER *) (ExtHdrs + Offset);
- if (FragmentHead == NULL) {
- return FALSE;
+ if (Offset == 0) {
+ //
+ // The Next Header directly follows IPv6 basic header.
+ //
+ Pointer = 6;
+ } else {
+ if (Pointer == 0) {
+ Pointer = sizeof (EFI_IP6_HEADER);
+ } else {
+ Pointer = Offset + sizeof (EFI_IP6_HEADER);
+ }
}
- FragmentOffset = NTOHS (FragmentHead->FragmentOffset);
-
- if (((FragmentOffset & 0x1) == 0x1) &&
- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) {
- Pointer = sizeof (UINT32);
+ if ((IpSb != NULL) && (Packet != NULL) &&
+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress))
+ {
Ip6SendIcmpError (
IpSb,
Packet,
NULL,
&Packet->Ip.Ip6->SourceAddress,
ICMP_V6_PARAMETER_PROBLEM,
- 0,
+ 1,
&Pointer
);
- return FALSE;
}
- }
-
- if (Fragmented != NULL) {
- *Fragmented = TRUE;
- }
- if (Rcvd && FormerHeader != NULL) {
- *FormerHeader = (UINT32) (NextHeader - ExtHdrs);
- }
-
- NextHeader = ExtHdrs + Offset;
- Offset = Offset + 8;
- break;
-
- case IP6_AH:
- if (++CountA > 1) {
return FALSE;
- }
-
- Option = ExtHdrs + Offset;
- NextHeader = Option;
- Option++;
- //
- // RFC2402, Payload length is specified in 32-bit words, minus "2".
- //
- OptionLen = (UINT8) ((*Option + 2) * 4);
- Offset = Offset + OptionLen;
- break;
-
- case IP6_NO_NEXT_HEADER:
- *LastHeader = NextHeader;
- return FALSE;
- break;
-
- default:
- if (Ip6IsValidProtocol (IpSb, *NextHeader)) {
-
- *LastHeader = NextHeader;
-
- if (RealExtsLen != NULL) {
- *RealExtsLen = Offset;
- }
-
- return TRUE;
- }
-
- //
- // The Next Header value is unrecognized by the node, discard the packet and
- // send an ICMP parameter problem message with code value of 1.
- //
- if (Offset == 0) {
- //
- // The Next Header directly follows IPv6 basic header.
- //
- Pointer = 6;
- } else {
- if (Pointer == 0) {
- Pointer = sizeof (EFI_IP6_HEADER);
- } else {
- Pointer = Offset + sizeof (EFI_IP6_HEADER);
- }
- }
-
- if ((IpSb != NULL) && (Packet != NULL) &&
- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) {
- Ip6SendIcmpError (
- IpSb,
- Packet,
- NULL,
- &Packet->Ip.Ip6->SourceAddress,
- ICMP_V6_PARAMETER_PROBLEM,
- 1,
- &Pointer
- );
- }
- return FALSE;
}
}
@@ -592,12 +599,12 @@ Ip6IsExtsValid ( **/
EFI_STATUS
Ip6FillHopByHop (
- OUT UINT8 *Buffer,
- IN OUT UINTN *BufferLen,
- IN UINT8 NextHeader
+ OUT UINT8 *Buffer,
+ IN OUT UINTN *BufferLen,
+ IN UINT8 NextHeader
)
{
- UINT8 BufferArray[8];
+ UINT8 BufferArray[8];
if (*BufferLen < 8) {
*BufferLen = 8;
@@ -640,23 +647,23 @@ Ip6FillHopByHop ( **/
EFI_STATUS
Ip6FillFragmentHeader (
- IN IP6_SERVICE *IpSb,
- IN UINT8 NextHeader,
- IN UINT8 LastHeader,
- IN UINT8 *ExtHdrs,
- IN UINT32 ExtHdrsLen,
- IN UINT16 FragmentOffset,
- OUT UINT8 **UpdatedExtHdrs
+ IN IP6_SERVICE *IpSb,
+ IN UINT8 NextHeader,
+ IN UINT8 LastHeader,
+ IN UINT8 *ExtHdrs,
+ IN UINT32 ExtHdrsLen,
+ IN UINT16 FragmentOffset,
+ OUT UINT8 **UpdatedExtHdrs
)
{
- UINT32 Length;
- UINT8 *Buffer;
- UINT32 FormerHeader;
- UINT32 Offset;
- UINT32 Part1Len;
- UINT32 HeaderLen;
- UINT8 Current;
- IP6_FRAGMENT_HEADER FragmentHead;
+ UINT32 Length;
+ UINT8 *Buffer;
+ UINT32 FormerHeader;
+ UINT32 Offset;
+ UINT32 Part1Len;
+ UINT32 HeaderLen;
+ UINT8 Current;
+ IP6_FRAGMENT_HEADER FragmentHead;
if (UpdatedExtHdrs == NULL) {
return EFI_INVALID_PARAMETER;
@@ -668,82 +675,81 @@ Ip6FillFragmentHeader ( return EFI_OUT_OF_RESOURCES;
}
- Offset = 0;
- Part1Len = 0;
- FormerHeader = 0;
- Current = NextHeader;
+ Offset = 0;
+ Part1Len = 0;
+ FormerHeader = 0;
+ Current = NextHeader;
while ((ExtHdrs != NULL) && (Offset <= ExtHdrsLen)) {
switch (NextHeader) {
- case IP6_ROUTING:
- case IP6_HOP_BY_HOP:
- case IP6_DESTINATION:
- Current = NextHeader;
- NextHeader = *(ExtHdrs + Offset);
+ case IP6_ROUTING:
+ case IP6_HOP_BY_HOP:
+ case IP6_DESTINATION:
+ Current = NextHeader;
+ NextHeader = *(ExtHdrs + Offset);
+
+ if ((Current == IP6_DESTINATION) && (NextHeader != IP6_ROUTING)) {
+ //
+ // Destination Options header should occur at most twice, once before
+ // a Routing header and once before the upper-layer header. Here we
+ // find the one before the upper-layer header. Insert the Fragment
+ // Header before it.
+ //
+ CopyMem (Buffer, ExtHdrs, Part1Len);
+ *(Buffer + FormerHeader) = IP6_FRAGMENT;
+ //
+ // Exit the loop.
+ //
+ Offset = ExtHdrsLen + 1;
+ break;
+ }
- if ((Current == IP6_DESTINATION) && (NextHeader != IP6_ROUTING)) {
- //
- // Destination Options header should occur at most twice, once before
- // a Routing header and once before the upper-layer header. Here we
- // find the one before the upper-layer header. Insert the Fragment
- // Header before it.
- //
- CopyMem (Buffer, ExtHdrs, Part1Len);
- *(Buffer + FormerHeader) = IP6_FRAGMENT;
- //
- // Exit the loop.
- //
- Offset = ExtHdrsLen + 1;
+ FormerHeader = Offset;
+ HeaderLen = (*(ExtHdrs + Offset + 1) + 1) * 8;
+ Part1Len = Part1Len + HeaderLen;
+ Offset = Offset + HeaderLen;
break;
- }
-
- FormerHeader = Offset;
- HeaderLen = (*(ExtHdrs + Offset + 1) + 1) * 8;
- Part1Len = Part1Len + HeaderLen;
- Offset = Offset + HeaderLen;
- break;
-
- case IP6_FRAGMENT:
- Current = NextHeader;
-
- if (Part1Len != 0) {
- CopyMem (Buffer, ExtHdrs, Part1Len);
- }
-
- *(Buffer + FormerHeader) = IP6_FRAGMENT;
-
- //
- // Exit the loop.
- //
- Offset = ExtHdrsLen + 1;
- break;
+ case IP6_FRAGMENT:
+ Current = NextHeader;
- case IP6_AH:
- Current = NextHeader;
- NextHeader = *(ExtHdrs + Offset);
- //
- // RFC2402, Payload length is specified in 32-bit words, minus "2".
- //
- HeaderLen = (*(ExtHdrs + Offset + 1) + 2) * 4;
- Part1Len = Part1Len + HeaderLen;
- Offset = Offset + HeaderLen;
- break;
+ if (Part1Len != 0) {
+ CopyMem (Buffer, ExtHdrs, Part1Len);
+ }
- default:
- if (Ip6IsValidProtocol (IpSb, NextHeader)) {
- Current = NextHeader;
- CopyMem (Buffer, ExtHdrs, Part1Len);
*(Buffer + FormerHeader) = IP6_FRAGMENT;
+
//
// Exit the loop.
//
Offset = ExtHdrsLen + 1;
break;
- }
- FreePool (Buffer);
- return EFI_UNSUPPORTED;
+ case IP6_AH:
+ Current = NextHeader;
+ NextHeader = *(ExtHdrs + Offset);
+ //
+ // RFC2402, Payload length is specified in 32-bit words, minus "2".
+ //
+ HeaderLen = (*(ExtHdrs + Offset + 1) + 2) * 4;
+ Part1Len = Part1Len + HeaderLen;
+ Offset = Offset + HeaderLen;
+ break;
+
+ default:
+ if (Ip6IsValidProtocol (IpSb, NextHeader)) {
+ Current = NextHeader;
+ CopyMem (Buffer, ExtHdrs, Part1Len);
+ *(Buffer + FormerHeader) = IP6_FRAGMENT;
+ //
+ // Exit the loop.
+ //
+ Offset = ExtHdrsLen + 1;
+ break;
+ }
+
+ FreePool (Buffer);
+ return EFI_UNSUPPORTED;
}
}
@@ -778,4 +784,3 @@ Ip6FillFragmentHeader ( return EFI_SUCCESS;
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Option.h b/NetworkPkg/Ip6Dxe/Ip6Option.h index c81b3fd..bd8e223 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Option.h +++ b/NetworkPkg/Ip6Dxe/Ip6Option.h @@ -10,20 +10,20 @@ #ifndef __EFI_IP6_OPTION_H__
#define __EFI_IP6_OPTION_H__
-#define IP6_FRAGMENT_OFFSET_MASK (~0x3)
+#define IP6_FRAGMENT_OFFSET_MASK (~0x3)
typedef struct _IP6_FRAGMENT_HEADER {
- UINT8 NextHeader;
- UINT8 Reserved;
- UINT16 FragmentOffset;
- UINT32 Identification;
+ UINT8 NextHeader;
+ UINT8 Reserved;
+ UINT16 FragmentOffset;
+ UINT32 Identification;
} IP6_FRAGMENT_HEADER;
typedef struct _IP6_ROUTING_HEADER {
- UINT8 NextHeader;
- UINT8 HeaderLen;
- UINT8 RoutingType;
- UINT8 SegmentsLeft;
+ UINT8 NextHeader;
+ UINT8 HeaderLen;
+ UINT8 RoutingType;
+ UINT8 SegmentsLeft;
} IP6_ROUTING_HEADER;
typedef enum {
@@ -35,11 +35,11 @@ typedef enum { Ip6OptionParameterProblem = 0x80,
Ip6OptionMask = 0xc0,
- Ip6OptionEtherSource = 1,
- Ip6OptionEtherTarget = 2,
- Ip6OptionPrefixInfo = 3,
- Ip6OptionRedirected = 4,
- Ip6OptionMtu = 5
+ Ip6OptionEtherSource = 1,
+ Ip6OptionEtherTarget = 2,
+ Ip6OptionPrefixInfo = 3,
+ Ip6OptionRedirected = 4,
+ Ip6OptionMtu = 5
} IP6_OPTION_TYPE;
/**
@@ -72,17 +72,17 @@ typedef enum { **/
BOOLEAN
Ip6IsExtsValid (
- IN IP6_SERVICE *IpSb OPTIONAL,
- IN NET_BUF *Packet OPTIONAL,
- IN UINT8 *NextHeader,
- IN UINT8 *ExtHdrs,
- IN UINT32 ExtHdrsLen,
- IN BOOLEAN Rcvd,
- OUT UINT32 *FormerHeader OPTIONAL,
- OUT UINT8 **LastHeader,
- OUT UINT32 *RealExtsLen OPTIONAL,
- OUT UINT32 *UnFragmentLen OPTIONAL,
- OUT BOOLEAN *Fragmented OPTIONAL
+ IN IP6_SERVICE *IpSb OPTIONAL,
+ IN NET_BUF *Packet OPTIONAL,
+ IN UINT8 *NextHeader,
+ IN UINT8 *ExtHdrs,
+ IN UINT32 ExtHdrsLen,
+ IN BOOLEAN Rcvd,
+ OUT UINT32 *FormerHeader OPTIONAL,
+ OUT UINT8 **LastHeader,
+ OUT UINT32 *RealExtsLen OPTIONAL,
+ OUT UINT32 *UnFragmentLen OPTIONAL,
+ OUT BOOLEAN *Fragmented OPTIONAL
);
/**
@@ -101,9 +101,9 @@ Ip6IsExtsValid ( **/
EFI_STATUS
Ip6FillHopByHop (
- OUT UINT8 *Buffer,
- IN OUT UINTN *BufferLen,
- IN UINT8 NextHeader
+ OUT UINT8 *Buffer,
+ IN OUT UINTN *BufferLen,
+ IN UINT8 NextHeader
);
/**
@@ -127,13 +127,13 @@ Ip6FillHopByHop ( **/
EFI_STATUS
Ip6FillFragmentHeader (
- IN IP6_SERVICE *IpSb,
- IN UINT8 NextHeader,
- IN UINT8 LastHeader,
- IN UINT8 *ExtHdrs,
- IN UINT32 ExtHdrsLen,
- IN UINT16 FragmentOffset,
- OUT UINT8 **UpdatedExtHdrs
+ IN IP6_SERVICE *IpSb,
+ IN UINT8 NextHeader,
+ IN UINT8 LastHeader,
+ IN UINT8 *ExtHdrs,
+ IN UINT32 ExtHdrsLen,
+ IN UINT16 FragmentOffset,
+ OUT UINT8 **UpdatedExtHdrs
);
/**
@@ -155,13 +155,13 @@ Ip6FillFragmentHeader ( **/
EFI_STATUS
Ip6CopyExts (
- IN UINT8 NextHeader,
- IN UINT8 *ExtHdrs,
- IN UINT8 *LastHeader,
- IN UINT16 FragmentOffset,
- IN UINT32 UnFragmentHdrLen,
- IN OUT UINT8 *Buf,
- IN OUT UINT32 *BufLen
+ IN UINT8 NextHeader,
+ IN UINT8 *ExtHdrs,
+ IN UINT8 *LastHeader,
+ IN UINT16 FragmentOffset,
+ IN UINT32 UnFragmentHdrLen,
+ IN OUT UINT8 *Buf,
+ IN OUT UINT32 *BufLen
);
/**
@@ -178,8 +178,8 @@ Ip6CopyExts ( **/
BOOLEAN
Ip6IsNDOptionValid (
- IN UINT8 *Option,
- IN UINT16 OptionLen
+ IN UINT8 *Option,
+ IN UINT16 OptionLen
);
#endif
diff --git a/NetworkPkg/Ip6Dxe/Ip6Output.c b/NetworkPkg/Ip6Dxe/Ip6Output.c index 2a2eae4..9a100f1 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Output.c +++ b/NetworkPkg/Ip6Dxe/Ip6Output.c @@ -9,7 +9,7 @@ #include "Ip6Impl.h"
-UINT32 mIp6Id;
+UINT32 mIp6Id;
/**
Output all the available source addresses to a list entry head SourceList. The
@@ -28,16 +28,16 @@ UINT32 mIp6Id; **/
EFI_STATUS
Ip6CandidateSource (
- IN IP6_SERVICE *IpSb,
- OUT LIST_ENTRY *SourceList,
- OUT UINT32 *SourceCount
+ IN IP6_SERVICE *IpSb,
+ OUT LIST_ENTRY *SourceList,
+ OUT UINT32 *SourceCount
)
{
- IP6_INTERFACE *IpIf;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Entry2;
- IP6_ADDRESS_INFO *AddrInfo;
- IP6_ADDRESS_INFO *Copy;
+ IP6_INTERFACE *IpIf;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Entry2;
+ IP6_ADDRESS_INFO *AddrInfo;
+ IP6_ADDRESS_INFO *Copy;
*SourceCount = 0;
@@ -47,12 +47,12 @@ Ip6CandidateSource ( return EFI_OUT_OF_RESOURCES;
}
- Copy->Signature = IP6_ADDR_INFO_SIGNATURE;
+ Copy->Signature = IP6_ADDR_INFO_SIGNATURE;
IP6_COPY_ADDRESS (&Copy->Address, &IpSb->LinkLocalAddr);
Copy->IsAnycast = FALSE;
Copy->PrefixLength = IP6_LINK_LOCAL_PREFIX_LENGTH;
- Copy->ValidLifetime = (UINT32) IP6_INFINIT_LIFETIME;
- Copy->PreferredLifetime = (UINT32) IP6_INFINIT_LIFETIME;
+ Copy->ValidLifetime = (UINT32)IP6_INFINIT_LIFETIME;
+ Copy->PreferredLifetime = (UINT32)IP6_INFINIT_LIFETIME;
InsertTailList (SourceList, &Copy->Link);
(*SourceCount)++;
@@ -95,15 +95,15 @@ Ip6CandidateSource ( **/
UINT8
Ip6CommonPrefixLen (
- IN EFI_IPv6_ADDRESS *AddressA,
- IN EFI_IPv6_ADDRESS *AddressB
+ IN EFI_IPv6_ADDRESS *AddressA,
+ IN EFI_IPv6_ADDRESS *AddressB
)
{
- UINT8 Count;
- UINT8 Index;
- UINT8 ByteA;
- UINT8 ByteB;
- UINT8 NumBits;
+ UINT8 Count;
+ UINT8 Index;
+ UINT8 ByteA;
+ UINT8 ByteB;
+ UINT8 NumBits;
Count = 0;
Index = 0;
@@ -122,14 +122,14 @@ Ip6CommonPrefixLen ( // Check how many bits are common between the two bytes.
//
NumBits = 8;
- ByteA = (UINT8) (ByteA ^ ByteB);
+ ByteA = (UINT8)(ByteA ^ ByteB);
while (ByteA != 0) {
NumBits--;
- ByteA = (UINT8) (ByteA >> 1);
+ ByteA = (UINT8)(ByteA >> 1);
}
- return (UINT8) (Count + NumBits);
+ return (UINT8)(Count + NumBits);
}
return Count;
@@ -151,21 +151,21 @@ Ip6CommonPrefixLen ( **/
EFI_STATUS
Ip6SelectSourceAddress (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Destination,
- OUT EFI_IPv6_ADDRESS *Source
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Destination,
+ OUT EFI_IPv6_ADDRESS *Source
)
{
- EFI_STATUS Status;
- LIST_ENTRY SourceList;
- UINT32 SourceCount;
- UINT8 ScopeD;
- LIST_ENTRY *Entry;
- IP6_ADDRESS_INFO *AddrInfo;
- IP6_PREFIX_LIST_ENTRY *Prefix;
- UINT8 LastCommonLength;
- UINT8 CurrentCommonLength;
- EFI_IPv6_ADDRESS *TmpAddress;
+ EFI_STATUS Status;
+ LIST_ENTRY SourceList;
+ UINT32 SourceCount;
+ UINT8 ScopeD;
+ LIST_ENTRY *Entry;
+ IP6_ADDRESS_INFO *AddrInfo;
+ IP6_PREFIX_LIST_ENTRY *Prefix;
+ UINT8 LastCommonLength;
+ UINT8 CurrentCommonLength;
+ EFI_IPv6_ADDRESS *TmpAddress;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -188,7 +188,7 @@ Ip6SelectSourceAddress ( // Rule 2: Prefer appropriate scope.
//
if (IP6_IS_MULTICAST (Destination)) {
- ScopeD = (UINT8) (Destination->Addr[1] >> 4);
+ ScopeD = (UINT8)(Destination->Addr[1] >> 4);
} else if (NetIp6IsLinkLocalAddr (Destination)) {
ScopeD = 0x2;
} else {
@@ -284,15 +284,15 @@ Exit: **/
IP6_INTERFACE *
Ip6SelectInterface (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Destination,
- IN OUT EFI_IPv6_ADDRESS *Source
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Destination,
+ IN OUT EFI_IPv6_ADDRESS *Source
)
{
- EFI_STATUS Status;
- EFI_IPv6_ADDRESS SelectedSource;
- IP6_INTERFACE *IpIf;
- BOOLEAN Exist;
+ EFI_STATUS Status;
+ EFI_IPv6_ADDRESS SelectedSource;
+ IP6_INTERFACE *IpIf;
+ BOOLEAN Exist;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Destination != NULL && Source != NULL);
@@ -335,10 +335,10 @@ Ip6SelectInterface ( **/
VOID
Ip6SysPacketSent (
- NET_BUF *Packet,
- EFI_STATUS IoStatus,
- UINT32 LinkFlag,
- VOID *Context
+ NET_BUF *Packet,
+ EFI_STATUS IoStatus,
+ UINT32 LinkFlag,
+ VOID *Context
)
{
NetbufFree (Packet);
@@ -365,22 +365,22 @@ Ip6SysPacketSent ( **/
EFI_STATUS
Ip6PrependHead (
- IN IP6_SERVICE *IpSb,
- IN NET_BUF *Packet,
- IN EFI_IP6_HEADER *Head,
- IN UINT16 FragmentOffset,
- IN UINT8 *ExtHdrs,
- IN UINT32 ExtHdrsLen,
- IN UINT8 LastHeader,
- IN UINT32 HeadLen
+ IN IP6_SERVICE *IpSb,
+ IN NET_BUF *Packet,
+ IN EFI_IP6_HEADER *Head,
+ IN UINT16 FragmentOffset,
+ IN UINT8 *ExtHdrs,
+ IN UINT32 ExtHdrsLen,
+ IN UINT8 LastHeader,
+ IN UINT32 HeadLen
)
{
- UINT32 Len;
- UINT32 UnFragExtHdrsLen;
- EFI_IP6_HEADER *PacketHead;
- UINT8 *UpdatedExtHdrs;
- EFI_STATUS Status;
- UINT8 NextHeader;
+ UINT32 Len;
+ UINT32 UnFragExtHdrsLen;
+ EFI_IP6_HEADER *PacketHead;
+ UINT8 *UpdatedExtHdrs;
+ EFI_STATUS Status;
+ UINT8 NextHeader;
UpdatedExtHdrs = NULL;
@@ -388,7 +388,7 @@ Ip6PrependHead ( // HeadLen is the length of the fixed part of the sequences of fragments, i.e.
// the unfragment part.
//
- PacketHead = (EFI_IP6_HEADER *) NetbufAllocSpace (Packet, HeadLen, NET_BUF_HEAD);
+ PacketHead = (EFI_IP6_HEADER *)NetbufAllocSpace (Packet, HeadLen, NET_BUF_HEAD);
if (PacketHead == NULL) {
return EFI_BAD_BUFFER_SIZE;
}
@@ -397,7 +397,7 @@ Ip6PrependHead ( // Set the head up, convert the host byte order to network byte order
//
CopyMem (PacketHead, Head, sizeof (EFI_IP6_HEADER));
- PacketHead->PayloadLength = HTONS ((UINT16) (Packet->TotalSize - sizeof (EFI_IP6_HEADER)));
+ PacketHead->PayloadLength = HTONS ((UINT16)(Packet->TotalSize - sizeof (EFI_IP6_HEADER)));
Packet->Ip.Ip6 = PacketHead;
Len = HeadLen - sizeof (EFI_IP6_HEADER);
@@ -431,7 +431,7 @@ Ip6PrependHead ( }
CopyMem (
- (UINT8 *) (PacketHead + 1),
+ (UINT8 *)(PacketHead + 1),
UpdatedExtHdrs,
UnFragExtHdrsLen + sizeof (IP6_FRAGMENT_HEADER)
);
@@ -474,52 +474,52 @@ Ip6PrependHead ( **/
EFI_STATUS
Ip6Output (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface OPTIONAL,
- IN IP6_PROTOCOL *IpInstance OPTIONAL,
- IN NET_BUF *Packet,
- IN EFI_IP6_HEADER *Head,
- IN UINT8 *ExtHdrs,
- IN UINT32 ExtHdrsLen,
- IN IP6_FRAME_CALLBACK Callback,
- IN VOID *Context
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface OPTIONAL,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL,
+ IN NET_BUF *Packet,
+ IN EFI_IP6_HEADER *Head,
+ IN UINT8 *ExtHdrs,
+ IN UINT32 ExtHdrsLen,
+ IN IP6_FRAME_CALLBACK Callback,
+ IN VOID *Context
)
{
- IP6_INTERFACE *IpIf;
- EFI_IPv6_ADDRESS NextHop;
- IP6_NEIGHBOR_ENTRY *NeighborCache;
- IP6_ROUTE_CACHE_ENTRY *RouteCache;
- EFI_STATUS Status;
- UINT32 Mtu;
- UINT32 HeadLen;
- UINT16 FragmentOffset;
- UINT8 *LastHeader;
- UINT32 UnFragmentLen;
- UINT32 UnFragmentHdrsLen;
- UINT32 FragmentHdrsLen;
- UINT16 *Checksum;
- UINT16 PacketChecksum;
- UINT16 PseudoChecksum;
- UINT32 Index;
- UINT32 PacketLen;
- UINT32 RealExtLen;
- UINT32 Offset;
- NET_BUF *TmpPacket;
- NET_BUF *Fragment;
- UINT32 Num;
- UINT8 *Buf;
- EFI_IP6_HEADER *PacketHead;
- IP6_ICMP_HEAD *IcmpHead;
- IP6_TXTOKEN_WRAP *Wrap;
- IP6_ROUTE_ENTRY *RouteEntry;
- UINT8 *UpdatedExtHdrs;
- UINT8 NextHeader;
- UINT8 LastHeaderBackup;
- BOOLEAN FragmentHeadInserted;
- UINT8 *ExtHdrsBackup;
- UINT8 NextHeaderBackup;
- EFI_IPv6_ADDRESS Source;
- EFI_IPv6_ADDRESS Destination;
+ IP6_INTERFACE *IpIf;
+ EFI_IPv6_ADDRESS NextHop;
+ IP6_NEIGHBOR_ENTRY *NeighborCache;
+ IP6_ROUTE_CACHE_ENTRY *RouteCache;
+ EFI_STATUS Status;
+ UINT32 Mtu;
+ UINT32 HeadLen;
+ UINT16 FragmentOffset;
+ UINT8 *LastHeader;
+ UINT32 UnFragmentLen;
+ UINT32 UnFragmentHdrsLen;
+ UINT32 FragmentHdrsLen;
+ UINT16 *Checksum;
+ UINT16 PacketChecksum;
+ UINT16 PseudoChecksum;
+ UINT32 Index;
+ UINT32 PacketLen;
+ UINT32 RealExtLen;
+ UINT32 Offset;
+ NET_BUF *TmpPacket;
+ NET_BUF *Fragment;
+ UINT32 Num;
+ UINT8 *Buf;
+ EFI_IP6_HEADER *PacketHead;
+ IP6_ICMP_HEAD *IcmpHead;
+ IP6_TXTOKEN_WRAP *Wrap;
+ IP6_ROUTE_ENTRY *RouteEntry;
+ UINT8 *UpdatedExtHdrs;
+ UINT8 NextHeader;
+ UINT8 LastHeaderBackup;
+ BOOLEAN FragmentHeadInserted;
+ UINT8 *ExtHdrsBackup;
+ UINT8 NextHeaderBackup;
+ EFI_IPv6_ADDRESS Source;
+ EFI_IPv6_ADDRESS Destination;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -557,7 +557,7 @@ Ip6Output ( // IpInstance->Interface is NULL when IpInstance is configured with both stationaddress
// and destinationaddress is unspecified.
//
- if (IpInstance == NULL || IpInstance->Interface == NULL) {
+ if ((IpInstance == NULL) || (IpInstance->Interface == NULL)) {
IpIf = Ip6SelectInterface (IpSb, &Head->DestinationAddress, &Head->SourceAddress);
if (IpInstance != NULL) {
IpInstance->Interface = IpIf;
@@ -578,43 +578,46 @@ Ip6Output ( Head->TrafficClassL = 0;
Head->TrafficClassH = 0;
- Checksum = NULL;
- NextHeader = *LastHeader;
+ Checksum = NULL;
+ NextHeader = *LastHeader;
switch (NextHeader) {
- case EFI_IP_PROTO_UDP:
- Packet->Udp = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
- ASSERT (Packet->Udp != NULL);
- if (Packet->Udp->Checksum == 0) {
- Checksum = &Packet->Udp->Checksum;
- }
- break;
+ case EFI_IP_PROTO_UDP:
+ Packet->Udp = (EFI_UDP_HEADER *)NetbufGetByte (Packet, 0, NULL);
+ ASSERT (Packet->Udp != NULL);
+ if (Packet->Udp->Checksum == 0) {
+ Checksum = &Packet->Udp->Checksum;
+ }
- case EFI_IP_PROTO_TCP:
- Packet->Tcp = (TCP_HEAD *) NetbufGetByte (Packet, 0, NULL);
- ASSERT (Packet->Tcp != NULL);
- if (Packet->Tcp->Checksum == 0) {
- Checksum = &Packet->Tcp->Checksum;
- }
- break;
+ break;
- case IP6_ICMP:
- //
- // Don't send ICMP packet to an IPv6 anycast address.
- //
- if (Ip6IsAnycast (IpSb, &Head->DestinationAddress)) {
- return EFI_INVALID_PARAMETER;
- }
+ case EFI_IP_PROTO_TCP:
+ Packet->Tcp = (TCP_HEAD *)NetbufGetByte (Packet, 0, NULL);
+ ASSERT (Packet->Tcp != NULL);
+ if (Packet->Tcp->Checksum == 0) {
+ Checksum = &Packet->Tcp->Checksum;
+ }
- IcmpHead = (IP6_ICMP_HEAD *) NetbufGetByte (Packet, 0, NULL);
- ASSERT (IcmpHead != NULL);
- if (IcmpHead->Checksum == 0) {
- Checksum = &IcmpHead->Checksum;
- }
- break;
+ break;
- default:
- break;
+ case IP6_ICMP:
+ //
+ // Don't send ICMP packet to an IPv6 anycast address.
+ //
+ if (Ip6IsAnycast (IpSb, &Head->DestinationAddress)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ IcmpHead = (IP6_ICMP_HEAD *)NetbufGetByte (Packet, 0, NULL);
+ ASSERT (IcmpHead != NULL);
+ if (IcmpHead->Checksum == 0) {
+ Checksum = &IcmpHead->Checksum;
+ }
+
+ break;
+
+ default:
+ break;
}
if (Checksum != NULL) {
@@ -624,11 +627,11 @@ Ip6Output ( //
PacketChecksum = NetbufChecksum (Packet);
PseudoChecksum = NetIp6PseudoHeadChecksum (
- &Head->SourceAddress,
- &Head->DestinationAddress,
- NextHeader,
- Packet->TotalSize
- );
+ &Head->SourceAddress,
+ &Head->DestinationAddress,
+ NextHeader,
+ Packet->TotalSize
+ );
*Checksum = (UINT16) ~NetAddChecksum (PacketChecksum, PseudoChecksum);
}
@@ -643,7 +646,7 @@ Ip6Output ( Context
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -663,7 +666,8 @@ Ip6Output ( &RealExtLen,
&UnFragmentHdrsLen,
NULL
- )) {
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -762,7 +766,6 @@ Ip6Output ( );
if (RouteEntry != NULL) {
if ((RouteEntry->Flag & IP6_PACKET_TOO_BIG) == IP6_PACKET_TOO_BIG) {
-
//
// FragmentHead is inserted after Hop-by-Hop Options header, Destination
// Options header (first occur), Routing header, and before Fragment header,
@@ -787,10 +790,10 @@ Ip6Output ( Head->NextHeader = IP6_FRAGMENT;
}
- ExtHdrsBackup = ExtHdrs;
- ExtHdrs = UpdatedExtHdrs;
- ExtHdrsLen = ExtHdrsLen + sizeof (IP6_FRAGMENT_HEADER);
- RealExtLen = RealExtLen + sizeof (IP6_FRAGMENT_HEADER);
+ ExtHdrsBackup = ExtHdrs;
+ ExtHdrs = UpdatedExtHdrs;
+ ExtHdrsLen = ExtHdrsLen + sizeof (IP6_FRAGMENT_HEADER);
+ RealExtLen = RealExtLen + sizeof (IP6_FRAGMENT_HEADER);
mIp6Id++;
@@ -879,8 +882,8 @@ Ip6Output ( goto Error;
}
- FragmentOffset = (UINT16) ((UINT16) Offset | 0x1);
- if (Index == Num - 1){
+ FragmentOffset = (UINT16)((UINT16)Offset | 0x1);
+ if (Index == Num - 1) {
//
// The last fragment, clear the M flag.
//
@@ -915,11 +918,11 @@ Ip6Output ( // The last fragment of upper layer packet, update the IP6 token status.
//
if ((Index == Num -1) && (Context != NULL)) {
- Wrap = (IP6_TXTOKEN_WRAP *) Context;
+ Wrap = (IP6_TXTOKEN_WRAP *)Context;
Wrap->Token->Status = Status;
}
- Offset += PacketLen;
+ Offset += PacketLen;
PacketLen = Packet->TotalSize - Offset;
if (PacketLen > Mtu) {
PacketLen = Mtu;
@@ -939,7 +942,7 @@ Ip6Output ( //
// Need not fragment the packet, send it in one frame.
//
- PacketHead = (EFI_IP6_HEADER *) NetbufAllocSpace (Packet, HeadLen, NET_BUF_HEAD);
+ PacketHead = (EFI_IP6_HEADER *)NetbufAllocSpace (Packet, HeadLen, NET_BUF_HEAD);
if (PacketHead == NULL) {
Status = EFI_BAD_BUFFER_SIZE;
goto Error;
@@ -949,7 +952,7 @@ Ip6Output ( Packet->Ip.Ip6 = PacketHead;
if (ExtHdrs != NULL) {
- Buf = (UINT8 *) (PacketHead + 1);
+ Buf = (UINT8 *)(PacketHead + 1);
CopyMem (Buf, ExtHdrs, ExtHdrsLen);
}
@@ -957,8 +960,8 @@ Ip6Output ( //
// A Fragment Header is inserted to the packet, update the payload length.
//
- PacketHead->PayloadLength = (UINT16) (NTOHS (PacketHead->PayloadLength) +
- sizeof (IP6_FRAGMENT_HEADER));
+ PacketHead->PayloadLength = (UINT16)(NTOHS (PacketHead->PayloadLength) +
+ sizeof (IP6_FRAGMENT_HEADER));
PacketHead->PayloadLength = HTONS (PacketHead->PayloadLength);
FreePool (UpdatedExtHdrs);
}
@@ -976,6 +979,7 @@ Error: if (UpdatedExtHdrs != NULL) {
FreePool (UpdatedExtHdrs);
}
+
Ip6CancelPacket (IpIf, Packet, Status);
return Status;
}
@@ -993,11 +997,11 @@ Error: **/
BOOLEAN
Ip6CancelPacketFragments (
- IN IP6_LINK_TX_TOKEN *Frame,
- IN VOID *Context
+ IN IP6_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;
}
@@ -1018,18 +1022,18 @@ Ip6CancelPacketFragments ( **/
VOID
Ip6CancelFrames (
- IN IP6_INTERFACE *Interface,
- IN EFI_STATUS IoStatus,
- IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN EFI_STATUS IoStatus,
+ IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
+ IN VOID *Context OPTIONAL
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_LINK_TX_TOKEN *Token;
- IP6_SERVICE *IpSb;
- IP6_NEIGHBOR_ENTRY *ArpQue;
- EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_LINK_TX_TOKEN *Token;
+ IP6_SERVICE *IpSb;
+ IP6_NEIGHBOR_ENTRY *ArpQue;
+ EFI_STATUS Status;
IpSb = Interface->Service;
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
@@ -1075,11 +1079,10 @@ Ip6CancelFrames ( **/
VOID
Ip6CancelPacket (
- IN IP6_INTERFACE *IpIf,
- IN NET_BUF *Packet,
- IN EFI_STATUS IoStatus
+ IN IP6_INTERFACE *IpIf,
+ IN NET_BUF *Packet,
+ IN EFI_STATUS IoStatus
)
{
Ip6CancelFrames (IpIf, IoStatus, Ip6CancelPacketFragments, Packet);
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Output.h b/NetworkPkg/Ip6Dxe/Ip6Output.h index a2aa579..6ac5003 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Output.h +++ b/NetworkPkg/Ip6Dxe/Ip6Output.h @@ -10,7 +10,7 @@ #ifndef __EFI_IP6_OUTPUT_H__
#define __EFI_IP6_OUTPUT_H__
-extern UINT32 mIp6Id;
+extern UINT32 mIp6Id;
/**
Output all the available source addresses to the list entry head SourceList. The
@@ -28,9 +28,9 @@ extern UINT32 mIp6Id; **/
EFI_STATUS
Ip6SelectSourceAddress (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Destination,
- OUT EFI_IPv6_ADDRESS *Source
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Destination,
+ OUT EFI_IPv6_ADDRESS *Source
);
/**
@@ -46,10 +46,10 @@ Ip6SelectSourceAddress ( **/
VOID
Ip6SysPacketSent (
- NET_BUF *Packet,
- EFI_STATUS IoStatus,
- UINT32 LinkFlag,
- VOID *Context
+ NET_BUF *Packet,
+ EFI_STATUS IoStatus,
+ UINT32 LinkFlag,
+ VOID *Context
);
/**
@@ -86,15 +86,15 @@ Ip6SysPacketSent ( **/
EFI_STATUS
Ip6Output (
- IN IP6_SERVICE *IpSb,
- IN IP6_INTERFACE *Interface OPTIONAL,
- IN IP6_PROTOCOL *IpInstance OPTIONAL,
- IN NET_BUF *Packet,
- IN EFI_IP6_HEADER *Head,
- IN UINT8 *ExtHdrs,
- IN UINT32 ExtHdrsLen,
- IN IP6_FRAME_CALLBACK Callback,
- IN VOID *Context
+ IN IP6_SERVICE *IpSb,
+ IN IP6_INTERFACE *Interface OPTIONAL,
+ IN IP6_PROTOCOL *IpInstance OPTIONAL,
+ IN NET_BUF *Packet,
+ IN EFI_IP6_HEADER *Head,
+ IN UINT8 *ExtHdrs,
+ IN UINT32 ExtHdrsLen,
+ IN IP6_FRAME_CALLBACK Callback,
+ IN VOID *Context
);
/**
@@ -111,10 +111,10 @@ Ip6Output ( **/
VOID
Ip6CancelFrames (
- IN IP6_INTERFACE *Interface,
- IN EFI_STATUS IoStatus,
- IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
- IN VOID *Context OPTIONAL
+ IN IP6_INTERFACE *Interface,
+ IN EFI_STATUS IoStatus,
+ IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL,
+ IN VOID *Context OPTIONAL
);
/**
@@ -127,9 +127,9 @@ Ip6CancelFrames ( **/
VOID
Ip6CancelPacket (
- IN IP6_INTERFACE *IpIf,
- IN NET_BUF *Packet,
- IN EFI_STATUS IoStatus
+ IN IP6_INTERFACE *IpIf,
+ IN NET_BUF *Packet,
+ IN EFI_STATUS IoStatus
);
#endif
diff --git a/NetworkPkg/Ip6Dxe/Ip6Route.c b/NetworkPkg/Ip6Dxe/Ip6Route.c index c24361d..2f91ba9 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Route.c +++ b/NetworkPkg/Ip6Dxe/Ip6Route.c @@ -21,17 +21,17 @@ **/
UINT32
Ip6RouteCacheHash (
- IN EFI_IPv6_ADDRESS *Ip1,
- IN EFI_IPv6_ADDRESS *Ip2
+ IN EFI_IPv6_ADDRESS *Ip1,
+ IN EFI_IPv6_ADDRESS *Ip2
)
{
- UINT32 Prefix1;
- UINT32 Prefix2;
+ UINT32 Prefix1;
+ UINT32 Prefix2;
- Prefix1 = *((UINT32 *) ((UINTN *) (Ip1)));
- Prefix2 = *((UINT32 *) ((UINTN *) (Ip2)));
+ Prefix1 = *((UINT32 *)((UINTN *)(Ip1)));
+ Prefix2 = *((UINT32 *)((UINTN *)(Ip2)));
- return ((UINT32) (Prefix1 ^ Prefix2) % IP6_ROUTE_CACHE_HASH_SIZE);
+ return ((UINT32)(Prefix1 ^ Prefix2) % IP6_ROUTE_CACHE_HASH_SIZE);
}
/**
@@ -49,12 +49,12 @@ Ip6RouteCacheHash ( **/
IP6_ROUTE_ENTRY *
Ip6CreateRouteEntry (
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
)
{
- IP6_ROUTE_ENTRY *RtEntry;
+ IP6_ROUTE_ENTRY *RtEntry;
RtEntry = AllocateZeroPool (sizeof (IP6_ROUTE_ENTRY));
@@ -85,7 +85,7 @@ Ip6CreateRouteEntry ( **/
VOID
Ip6FreeRouteEntry (
- IN OUT IP6_ROUTE_ENTRY *RtEntry
+ IN OUT IP6_ROUTE_ENTRY *RtEntry
)
{
ASSERT ((RtEntry != NULL) && (RtEntry->RefCnt > 0));
@@ -116,14 +116,14 @@ Ip6FreeRouteEntry ( **/
IP6_ROUTE_ENTRY *
Ip6FindRouteEntry (
- IN IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
- IN EFI_IPv6_ADDRESS *NextHop OPTIONAL
+ IN IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
+ IN EFI_IPv6_ADDRESS *NextHop OPTIONAL
)
{
- LIST_ENTRY *Entry;
- IP6_ROUTE_ENTRY *RtEntry;
- INTN Index;
+ LIST_ENTRY *Entry;
+ IP6_ROUTE_ENTRY *RtEntry;
+ INTN Index;
ASSERT (Destination != NULL || NextHop != NULL);
@@ -144,7 +144,6 @@ Ip6FindRouteEntry ( return RtEntry;
}
}
-
}
}
@@ -166,13 +165,13 @@ Ip6FindRouteEntry ( **/
IP6_ROUTE_CACHE_ENTRY *
Ip6CreateRouteCacheEntry (
- IN EFI_IPv6_ADDRESS *Dst,
- IN EFI_IPv6_ADDRESS *Src,
- IN EFI_IPv6_ADDRESS *GateWay,
- IN UINTN Tag
+ IN EFI_IPv6_ADDRESS *Dst,
+ IN EFI_IPv6_ADDRESS *Src,
+ IN EFI_IPv6_ADDRESS *GateWay,
+ IN UINTN Tag
)
{
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
RtCacheEntry = AllocatePool (sizeof (IP6_ROUTE_CACHE_ENTRY));
@@ -222,21 +221,21 @@ Ip6FreeRouteCacheEntry ( **/
IP6_ROUTE_CACHE_ENTRY *
Ip6FindRouteCache (
- IN IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Dest,
- IN EFI_IPv6_ADDRESS *Src
+ IN IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Dest,
+ IN EFI_IPv6_ADDRESS *Src
)
{
- LIST_ENTRY *Entry;
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
- UINT32 Index;
+ LIST_ENTRY *Entry;
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
+ UINT32 Index;
Index = IP6_ROUTE_CACHE_HASH (Dest, Src);
NET_LIST_FOR_EACH (Entry, &RtTable->Cache.CacheBucket[Index]) {
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_CACHE_ENTRY, Link);
- if (EFI_IP6_EQUAL (Dest, &RtCacheEntry->Destination)&& EFI_IP6_EQUAL (Src, &RtCacheEntry->Source)) {
+ if (EFI_IP6_EQUAL (Dest, &RtCacheEntry->Destination) && EFI_IP6_EQUAL (Src, &RtCacheEntry->Source)) {
NET_GET_REF (RtCacheEntry);
return RtCacheEntry;
}
@@ -260,16 +259,16 @@ Ip6FindRouteCache ( **/
EFI_STATUS
Ip6BuildEfiRouteTable (
- IN IP6_ROUTE_TABLE *RouteTable,
- OUT UINT32 *EfiRouteCount,
- OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL
+ IN IP6_ROUTE_TABLE *RouteTable,
+ OUT UINT32 *EfiRouteCount,
+ OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL
)
{
- LIST_ENTRY *Entry;
- IP6_ROUTE_ENTRY *RtEntry;
- EFI_IP6_ROUTE_TABLE *EfiTable;
- UINT32 Count;
- INT32 Index;
+ LIST_ENTRY *Entry;
+ IP6_ROUTE_ENTRY *RtEntry;
+ EFI_IP6_ROUTE_TABLE *EfiTable;
+ UINT32 Count;
+ INT32 Index;
ASSERT (EfiRouteCount != NULL);
@@ -295,7 +294,6 @@ Ip6BuildEfiRouteTable ( Count = 0;
for (Index = IP6_PREFIX_MAX; Index >= 0; Index--) {
-
NET_LIST_FOR_EACH (Entry, &(RouteTable->RouteArea[Index])) {
RtEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link);
@@ -329,8 +327,8 @@ Ip6CreateRouteTable ( VOID
)
{
- IP6_ROUTE_TABLE *RtTable;
- UINT32 Index;
+ IP6_ROUTE_TABLE *RtTable;
+ UINT32 Index;
RtTable = AllocatePool (sizeof (IP6_ROUTE_TABLE));
if (RtTable == NULL) {
@@ -361,19 +359,19 @@ Ip6CreateRouteTable ( **/
VOID
Ip6CleanRouteTable (
- IN OUT IP6_ROUTE_TABLE *RtTable
+ IN OUT IP6_ROUTE_TABLE *RtTable
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_ROUTE_ENTRY *RtEntry;
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
- UINT32 Index;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_ROUTE_ENTRY *RtEntry;
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
+ UINT32 Index;
ASSERT (RtTable->RefCnt > 0);
if (--RtTable->RefCnt > 0) {
- return ;
+ return;
}
//
@@ -410,18 +408,17 @@ Ip6CleanRouteTable ( **/
VOID
Ip6PurgeRouteCache (
- IN IP6_ROUTE_CACHE *RtCache,
- IN UINTN Tag
+ IN IP6_ROUTE_CACHE *RtCache,
+ IN UINTN Tag
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
- UINT32 Index;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
+ UINT32 Index;
for (Index = 0; Index < IP6_ROUTE_CACHE_HASH_SIZE; Index++) {
NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtCache->CacheBucket[Index]) {
-
RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_CACHE_ENTRY, Link);
if (RtCacheEntry->Tag == Tag) {
@@ -447,15 +444,15 @@ Ip6PurgeRouteCache ( **/
EFI_STATUS
Ip6AddRoute (
- IN OUT IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Destination,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress
+ IN OUT IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Destination,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress
)
{
- LIST_ENTRY *ListHead;
- LIST_ENTRY *Entry;
- IP6_ROUTE_ENTRY *Route;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *Entry;
+ IP6_ROUTE_ENTRY *Route;
ListHead = &RtTable->RouteArea[PrefixLength];
@@ -466,7 +463,8 @@ Ip6AddRoute ( Route = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link);
if (NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength) &&
- EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) {
+ EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop))
+ {
return EFI_ACCESS_DENIED;
}
}
@@ -506,17 +504,17 @@ Ip6AddRoute ( **/
EFI_STATUS
Ip6DelRoute (
- IN OUT IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Destination,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress
+ IN OUT IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Destination,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress
)
{
- LIST_ENTRY *ListHead;
- LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
- IP6_ROUTE_ENTRY *Route;
- UINT32 TotalNum;
+ LIST_ENTRY *ListHead;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *Next;
+ IP6_ROUTE_ENTRY *Route;
+ UINT32 TotalNum;
ListHead = &RtTable->RouteArea[PrefixLength];
TotalNum = RtTable->TotalNum;
@@ -524,14 +522,15 @@ Ip6DelRoute ( NET_LIST_FOR_EACH_SAFE (Entry, Next, ListHead) {
Route = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link);
- if (Destination != NULL && !NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength)) {
+ if ((Destination != NULL) && !NetIp6IsNetEqual (Destination, &Route->Destination, PrefixLength)) {
continue;
}
- if (GatewayAddress != NULL && !EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) {
+
+ if ((GatewayAddress != NULL) && !EFI_IP6_EQUAL (GatewayAddress, &Route->NextHop)) {
continue;
}
- Ip6PurgeRouteCache (&RtTable->Cache, (UINTN) Route);
+ Ip6PurgeRouteCache (&RtTable->Cache, (UINTN)Route);
RemoveEntryList (Entry);
Ip6FreeRouteEntry (Route);
@@ -556,17 +555,17 @@ Ip6DelRoute ( **/
IP6_ROUTE_CACHE_ENTRY *
Ip6Route (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Dest,
- IN EFI_IPv6_ADDRESS *Src
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Dest,
+ IN EFI_IPv6_ADDRESS *Src
)
{
- IP6_ROUTE_TABLE *RtTable;
- LIST_ENTRY *ListHead;
- IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
- IP6_ROUTE_ENTRY *RtEntry;
- EFI_IPv6_ADDRESS NextHop;
- UINT32 Index;
+ IP6_ROUTE_TABLE *RtTable;
+ LIST_ENTRY *ListHead;
+ IP6_ROUTE_CACHE_ENTRY *RtCacheEntry;
+ IP6_ROUTE_ENTRY *RtEntry;
+ EFI_IPv6_ADDRESS NextHop;
+ UINT32 Index;
RtTable = IpSb->RouteTable;
@@ -614,7 +613,7 @@ Ip6Route ( //
// Create a route cache entry, and tag it as spawned from this route entry
//
- RtCacheEntry = Ip6CreateRouteCacheEntry (Dest, Src, &NextHop, (UINTN) RtEntry);
+ RtCacheEntry = Ip6CreateRouteCacheEntry (Dest, Src, &NextHop, (UINTN)RtEntry);
if (RtCacheEntry == NULL) {
return NULL;
@@ -626,4 +625,3 @@ Ip6Route ( return RtCacheEntry;
}
-
diff --git a/NetworkPkg/Ip6Dxe/Ip6Route.h b/NetworkPkg/Ip6Dxe/Ip6Route.h index af20dbb..9023b21 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Route.h +++ b/NetworkPkg/Ip6Dxe/Ip6Route.h @@ -10,38 +10,38 @@ #ifndef __EFI_IP6_ROUTE_H__
#define __EFI_IP6_ROUTE_H__
-#define IP6_DIRECT_ROUTE 0x00000001
-#define IP6_PACKET_TOO_BIG 0x00000010
+#define IP6_DIRECT_ROUTE 0x00000001
+#define IP6_PACKET_TOO_BIG 0x00000010
-#define IP6_ROUTE_CACHE_HASH_SIZE 31
+#define IP6_ROUTE_CACHE_HASH_SIZE 31
///
/// Max NO. of cache entry per hash bucket
///
-#define IP6_ROUTE_CACHE_MAX 32
+#define IP6_ROUTE_CACHE_MAX 32
-#define IP6_ROUTE_CACHE_HASH(Ip1, Ip2) Ip6RouteCacheHash ((Ip1), (Ip2))
+#define IP6_ROUTE_CACHE_HASH(Ip1, Ip2) Ip6RouteCacheHash ((Ip1), (Ip2))
typedef struct {
- LIST_ENTRY Link;
- INTN RefCnt;
- UINT32 Flag;
- UINT8 PrefixLength;
- EFI_IPv6_ADDRESS Destination;
- EFI_IPv6_ADDRESS NextHop;
+ LIST_ENTRY Link;
+ INTN RefCnt;
+ UINT32 Flag;
+ UINT8 PrefixLength;
+ EFI_IPv6_ADDRESS Destination;
+ EFI_IPv6_ADDRESS NextHop;
} IP6_ROUTE_ENTRY;
typedef struct {
- LIST_ENTRY Link;
- INTN RefCnt;
- UINTN Tag;
- EFI_IPv6_ADDRESS Destination;
- EFI_IPv6_ADDRESS Source;
- EFI_IPv6_ADDRESS NextHop;
+ LIST_ENTRY Link;
+ INTN RefCnt;
+ UINTN Tag;
+ EFI_IPv6_ADDRESS Destination;
+ EFI_IPv6_ADDRESS Source;
+ EFI_IPv6_ADDRESS NextHop;
} IP6_ROUTE_CACHE_ENTRY;
typedef struct {
- LIST_ENTRY CacheBucket[IP6_ROUTE_CACHE_HASH_SIZE];
- UINT8 CacheNum[IP6_ROUTE_CACHE_HASH_SIZE];
+ LIST_ENTRY CacheBucket[IP6_ROUTE_CACHE_HASH_SIZE];
+ UINT8 CacheNum[IP6_ROUTE_CACHE_HASH_SIZE];
} IP6_ROUTE_CACHE;
//
@@ -54,10 +54,10 @@ typedef struct { //
typedef struct _IP6_ROUTE_TABLE {
- INTN RefCnt;
- UINT32 TotalNum;
- LIST_ENTRY RouteArea[IP6_PREFIX_NUM];
- IP6_ROUTE_CACHE Cache;
+ INTN RefCnt;
+ UINT32 TotalNum;
+ LIST_ENTRY RouteArea[IP6_PREFIX_NUM];
+ IP6_ROUTE_CACHE Cache;
} IP6_ROUTE_TABLE;
/**
@@ -72,8 +72,8 @@ typedef struct _IP6_ROUTE_TABLE { **/
UINT32
Ip6RouteCacheHash (
- IN EFI_IPv6_ADDRESS *Ip1,
- IN EFI_IPv6_ADDRESS *Ip2
+ IN EFI_IPv6_ADDRESS *Ip1,
+ IN EFI_IPv6_ADDRESS *Ip2
);
/**
@@ -91,10 +91,10 @@ Ip6RouteCacheHash ( **/
IP6_ROUTE_CACHE_ENTRY *
Ip6CreateRouteCacheEntry (
- IN EFI_IPv6_ADDRESS *Dst,
- IN EFI_IPv6_ADDRESS *Src,
- IN EFI_IPv6_ADDRESS *GateWay,
- IN UINTN Tag
+ IN EFI_IPv6_ADDRESS *Dst,
+ IN EFI_IPv6_ADDRESS *Src,
+ IN EFI_IPv6_ADDRESS *GateWay,
+ IN UINTN Tag
);
/**
@@ -122,9 +122,9 @@ Ip6FreeRouteCacheEntry ( **/
IP6_ROUTE_CACHE_ENTRY *
Ip6FindRouteCache (
- IN IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Dest,
- IN EFI_IPv6_ADDRESS *Src
+ IN IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Dest,
+ IN EFI_IPv6_ADDRESS *Src
);
/**
@@ -142,9 +142,9 @@ Ip6FindRouteCache ( **/
EFI_STATUS
Ip6BuildEfiRouteTable (
- IN IP6_ROUTE_TABLE *RouteTable,
- OUT UINT32 *EfiRouteCount,
- OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL
+ IN IP6_ROUTE_TABLE *RouteTable,
+ OUT UINT32 *EfiRouteCount,
+ OUT EFI_IP6_ROUTE_TABLE **EfiRouteTable OPTIONAL
);
/**
@@ -168,7 +168,7 @@ Ip6CreateRouteTable ( **/
VOID
Ip6CleanRouteTable (
- IN OUT IP6_ROUTE_TABLE *RtTable
+ IN OUT IP6_ROUTE_TABLE *RtTable
);
/**
@@ -186,9 +186,9 @@ Ip6CleanRouteTable ( **/
IP6_ROUTE_ENTRY *
Ip6CreateRouteEntry (
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress OPTIONAL
);
/**
@@ -212,9 +212,9 @@ Ip6CreateRouteEntry ( **/
IP6_ROUTE_ENTRY *
Ip6FindRouteEntry (
- IN IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
- IN EFI_IPv6_ADDRESS *NextHop OPTIONAL
+ IN IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Destination OPTIONAL,
+ IN EFI_IPv6_ADDRESS *NextHop OPTIONAL
);
/**
@@ -225,7 +225,7 @@ Ip6FindRouteEntry ( **/
VOID
Ip6FreeRouteEntry (
- IN OUT IP6_ROUTE_ENTRY *RtEntry
+ IN OUT IP6_ROUTE_ENTRY *RtEntry
);
/**
@@ -243,10 +243,10 @@ Ip6FreeRouteEntry ( **/
EFI_STATUS
Ip6AddRoute (
- IN OUT IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Destination,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress
+ IN OUT IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Destination,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress
);
/**
@@ -265,10 +265,10 @@ Ip6AddRoute ( **/
EFI_STATUS
Ip6DelRoute (
- IN OUT IP6_ROUTE_TABLE *RtTable,
- IN EFI_IPv6_ADDRESS *Destination,
- IN UINT8 PrefixLength,
- IN EFI_IPv6_ADDRESS *GatewayAddress
+ IN OUT IP6_ROUTE_TABLE *RtTable,
+ IN EFI_IPv6_ADDRESS *Destination,
+ IN UINT8 PrefixLength,
+ IN EFI_IPv6_ADDRESS *GatewayAddress
);
/**
@@ -285,9 +285,9 @@ Ip6DelRoute ( **/
IP6_ROUTE_CACHE_ENTRY *
Ip6Route (
- IN IP6_SERVICE *IpSb,
- IN EFI_IPv6_ADDRESS *Dest,
- IN EFI_IPv6_ADDRESS *Src
+ IN IP6_SERVICE *IpSb,
+ IN EFI_IPv6_ADDRESS *Dest,
+ IN EFI_IPv6_ADDRESS *Src
);
#endif
|