summaryrefslogtreecommitdiff
path: root/NetworkPkg/Ip4Dxe/Ip4Impl.c
diff options
context:
space:
mode:
Diffstat (limited to 'NetworkPkg/Ip4Dxe/Ip4Impl.c')
-rw-r--r--NetworkPkg/Ip4Dxe/Ip4Impl.c485
1 files changed, 233 insertions, 252 deletions
diff --git a/NetworkPkg/Ip4Dxe/Ip4Impl.c b/NetworkPkg/Ip4Dxe/Ip4Impl.c
index 5935d40..4786214 100644
--- a/NetworkPkg/Ip4Dxe/Ip4Impl.c
+++ b/NetworkPkg/Ip4Dxe/Ip4Impl.c
@@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "Ip4Impl.h"
-EFI_IPSEC2_PROTOCOL *mIpSec = NULL;
+EFI_IPSEC2_PROTOCOL *mIpSec = NULL;
/**
Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.
@@ -30,10 +30,10 @@ EFI_IPSEC2_PROTOCOL *mIpSec = NULL;
EFI_STATUS
EFIAPI
EfiIp4GetModeData (
- IN CONST EFI_IP4_PROTOCOL *This,
- OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ IN CONST EFI_IP4_PROTOCOL *This,
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
);
/**
@@ -82,8 +82,8 @@ EfiIp4GetModeData (
EFI_STATUS
EFIAPI
EfiIp4Configure (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
);
/**
@@ -119,9 +119,9 @@ EfiIp4Configure (
EFI_STATUS
EFIAPI
EfiIp4Groups (
- IN EFI_IP4_PROTOCOL *This,
- IN BOOLEAN JoinFlag,
- IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
+ IN EFI_IP4_PROTOCOL *This,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
);
/**
@@ -177,11 +177,11 @@ EfiIp4Groups (
EFI_STATUS
EFIAPI
EfiIp4Routes (
- IN EFI_IP4_PROTOCOL *This,
- IN BOOLEAN DeleteRoute,
- IN EFI_IPv4_ADDRESS *SubnetAddress,
- IN EFI_IPv4_ADDRESS *SubnetMask,
- IN EFI_IPv4_ADDRESS *GatewayAddress
+ IN EFI_IP4_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv4_ADDRESS *SubnetAddress,
+ IN EFI_IPv4_ADDRESS *SubnetMask,
+ IN EFI_IPv4_ADDRESS *GatewayAddress
);
/**
@@ -216,8 +216,8 @@ EfiIp4Routes (
EFI_STATUS
EFIAPI
EfiIp4Transmit (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_COMPLETION_TOKEN *Token
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token
);
/**
@@ -255,8 +255,8 @@ EfiIp4Transmit (
EFI_STATUS
EFIAPI
EfiIp4Receive (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_COMPLETION_TOKEN *Token
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token
);
/**
@@ -291,8 +291,8 @@ EfiIp4Receive (
EFI_STATUS
EFIAPI
EfiIp4Cancel (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
);
/**
@@ -325,11 +325,11 @@ EfiIp4Cancel (
EFI_STATUS
EFIAPI
EfiIp4Poll (
- IN EFI_IP4_PROTOCOL *This
+ IN EFI_IP4_PROTOCOL *This
);
EFI_IP4_PROTOCOL
-mEfiIp4ProtocolTemplete = {
+ mEfiIp4ProtocolTemplete = {
EfiIp4GetModeData,
EfiIp4Configure,
EfiIp4Groups,
@@ -361,18 +361,18 @@ mEfiIp4ProtocolTemplete = {
EFI_STATUS
EFIAPI
EfiIp4GetModeData (
- IN CONST EFI_IP4_PROTOCOL *This,
- OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ IN CONST EFI_IP4_PROTOCOL *This,
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
)
{
- IP4_PROTOCOL *IpInstance;
- IP4_SERVICE *IpSb;
- EFI_IP4_CONFIG_DATA *Config;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- IP4_ADDR Ip;
+ IP4_PROTOCOL *IpInstance;
+ IP4_SERVICE *IpSb;
+ EFI_IP4_CONFIG_DATA *Config;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ IP4_ADDR Ip;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -387,18 +387,18 @@ EfiIp4GetModeData (
// IsStarted is "whether the EfiIp4Configure has been called".
// IsConfigured is "whether the station address has been configured"
//
- Ip4ModeData->IsStarted = (BOOLEAN)(IpInstance->State == IP4_STATE_CONFIGED);
+ Ip4ModeData->IsStarted = (BOOLEAN)(IpInstance->State == IP4_STATE_CONFIGED);
CopyMem (&Ip4ModeData->ConfigData, &IpInstance->ConfigData, sizeof (Ip4ModeData->ConfigData));
- Ip4ModeData->IsConfigured = FALSE;
+ Ip4ModeData->IsConfigured = FALSE;
- Ip4ModeData->GroupCount = IpInstance->GroupCount;
- Ip4ModeData->GroupTable = (EFI_IPv4_ADDRESS *) IpInstance->Groups;
+ Ip4ModeData->GroupCount = IpInstance->GroupCount;
+ Ip4ModeData->GroupTable = (EFI_IPv4_ADDRESS *)IpInstance->Groups;
Ip4ModeData->IcmpTypeCount = 23;
Ip4ModeData->IcmpTypeList = mIp4SupportedIcmp;
- Ip4ModeData->RouteTable = NULL;
- Ip4ModeData->RouteCount = 0;
+ Ip4ModeData->RouteTable = NULL;
+ Ip4ModeData->RouteCount = 0;
Ip4ModeData->MaxPacketSize = IpSb->MaxPacketSize;
@@ -409,7 +409,7 @@ EfiIp4GetModeData (
// using the default one, such as a ftp server.
//
if (Ip4ModeData->IsStarted) {
- Config = &Ip4ModeData->ConfigData;
+ Config = &Ip4ModeData->ConfigData;
Ip = HTONL (IpInstance->Interface->Ip);
CopyMem (&Config->StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
@@ -443,7 +443,6 @@ EfiIp4GetModeData (
return Status;
}
-
/**
Config the MNP parameter used by IP. The IP driver use one MNP
child to transmit/receive frames. By default, it configures MNP
@@ -464,17 +463,17 @@ EfiIp4GetModeData (
**/
EFI_STATUS
Ip4ServiceConfigMnp (
- IN IP4_SERVICE *IpSb,
- IN BOOLEAN Force
+ IN IP4_SERVICE *IpSb,
+ IN BOOLEAN Force
)
{
- LIST_ENTRY *Entry;
- LIST_ENTRY *ProtoEntry;
- IP4_INTERFACE *IpIf;
- IP4_PROTOCOL *IpInstance;
- BOOLEAN Reconfig;
- BOOLEAN PromiscReceive;
- EFI_STATUS Status;
+ LIST_ENTRY *Entry;
+ LIST_ENTRY *ProtoEntry;
+ IP4_INTERFACE *IpIf;
+ IP4_PROTOCOL *IpInstance;
+ BOOLEAN Reconfig;
+ BOOLEAN PromiscReceive;
+ EFI_STATUS Status;
Reconfig = FALSE;
PromiscReceive = FALSE;
@@ -486,7 +485,6 @@ Ip4ServiceConfigMnp (
// filter also.
//
NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {
-
IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
IpIf->PromiscRecv = FALSE;
@@ -507,7 +505,7 @@ Ip4ServiceConfigMnp (
return EFI_SUCCESS;
}
- Reconfig = TRUE;
+ Reconfig = TRUE;
IpSb->MnpConfigData.EnablePromiscuousReceive = PromiscReceive;
}
@@ -523,7 +521,6 @@ Ip4ServiceConfigMnp (
return Status;
}
-
/**
Initialize the IP4_PROTOCOL structure to the unconfigured states.
@@ -533,8 +530,8 @@ Ip4ServiceConfigMnp (
**/
VOID
Ip4InitProtocol (
- IN IP4_SERVICE *IpSb,
- IN OUT IP4_PROTOCOL *IpInstance
+ IN IP4_SERVICE *IpSb,
+ IN OUT IP4_PROTOCOL *IpInstance
)
{
ASSERT ((IpSb != NULL) && (IpInstance != NULL));
@@ -544,12 +541,12 @@ Ip4InitProtocol (
IpInstance->Signature = IP4_PROTOCOL_SIGNATURE;
CopyMem (&IpInstance->Ip4Proto, &mEfiIp4ProtocolTemplete, sizeof (IpInstance->Ip4Proto));
IpInstance->State = IP4_STATE_UNCONFIGED;
- IpInstance->InDestroy = FALSE;
+ IpInstance->InDestroy = FALSE;
IpInstance->Service = IpSb;
InitializeListHead (&IpInstance->Link);
- NetMapInit (&IpInstance->RxTokens);
- NetMapInit (&IpInstance->TxTokens);
+ NetMapInit (&IpInstance->RxTokens);
+ NetMapInit (&IpInstance->TxTokens);
InitializeListHead (&IpInstance->Received);
InitializeListHead (&IpInstance->Delivered);
InitializeListHead (&IpInstance->AddrLink);
@@ -557,7 +554,6 @@ Ip4InitProtocol (
EfiInitializeLock (&IpInstance->RecycleLock, TPL_NOTIFY);
}
-
/**
Configure the IP4 child. If the child is already configured,
change the configuration parameter. Otherwise configure it
@@ -595,7 +591,7 @@ Ip4ConfigProtocol (
IpSb = IpInstance->Service;
- Ip4Config2 = NULL;
+ Ip4Config2 = NULL;
//
// User is changing packet filters. It must be stopped
@@ -646,7 +642,6 @@ Ip4ConfigProtocol (
if (IpIf != NULL) {
NET_GET_REF (IpIf);
-
} else {
IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
@@ -686,13 +681,13 @@ Ip4ConfigProtocol (
Policy = IpSb->Ip4Config2Instance.Policy;
if (Policy != Ip4Config2PolicyDhcp) {
Ip4Config2 = &IpSb->Ip4Config2Instance.Ip4Config2;
- Policy = Ip4Config2PolicyDhcp;
- Status= Ip4Config2->SetData (
- Ip4Config2,
- Ip4Config2DataTypePolicy,
- sizeof (EFI_IP4_CONFIG2_POLICY),
- &Policy
- );
+ Policy = Ip4Config2PolicyDhcp;
+ Status = Ip4Config2->SetData (
+ Ip4Config2,
+ Ip4Config2DataTypePolicy,
+ sizeof (EFI_IP4_CONFIG2_POLICY),
+ &Policy
+ );
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
@@ -715,11 +710,11 @@ Ip4ConfigProtocol (
IpInstance->Interface = IpIf;
if (IpIf->Arp != NULL) {
- Arp = NULL;
+ Arp = NULL;
Status = gBS->OpenProtocol (
IpIf->ArpHandle,
&gEfiArpProtocolGuid,
- (VOID **) &Arp,
+ (VOID **)&Arp,
gIp4DriverBinding.DriverBindingHandle,
IpInstance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -729,10 +724,11 @@ Ip4ConfigProtocol (
goto ON_ERROR;
}
}
+
InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink);
CopyMem (&IpInstance->ConfigData, Config, sizeof (IpInstance->ConfigData));
- IpInstance->State = IP4_STATE_CONFIGED;
+ IpInstance->State = IP4_STATE_CONFIGED;
//
// Although EFI_NO_MAPPING is an error code, the IP child has been
@@ -751,7 +747,6 @@ ON_ERROR:
return Status;
}
-
/**
Clean up the IP4 child, release all the resources used by it.
@@ -763,7 +758,7 @@ ON_ERROR:
**/
EFI_STATUS
Ip4CleanProtocol (
- IN IP4_PROTOCOL *IpInstance
+ IN IP4_PROTOCOL *IpInstance
)
{
if (EFI_ERROR (Ip4Cancel (IpInstance, NULL))) {
@@ -780,7 +775,6 @@ Ip4CleanProtocol (
// hasn't been called. Just leave it alone.
//
if (!IsListEmpty (&IpInstance->Delivered)) {
- ;
}
if (IpInstance->Interface != NULL) {
@@ -793,6 +787,7 @@ Ip4CleanProtocol (
IpInstance->Handle
);
}
+
Ip4FreeInterface (IpInstance->Interface, IpInstance);
IpInstance->Interface = NULL;
}
@@ -814,8 +809,8 @@ Ip4CleanProtocol (
if (IpInstance->Groups != NULL) {
FreePool (IpInstance->Groups);
- IpInstance->Groups = NULL;
- IpInstance->GroupCount = 0;
+ IpInstance->Groups = NULL;
+ IpInstance->GroupCount = 0;
}
NetMapClean (&IpInstance->TxTokens);
@@ -825,7 +820,6 @@ Ip4CleanProtocol (
return EFI_SUCCESS;
}
-
/**
Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
@@ -872,17 +866,17 @@ Ip4CleanProtocol (
EFI_STATUS
EFIAPI
EfiIp4Configure (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
)
{
- IP4_PROTOCOL *IpInstance;
- EFI_IP4_CONFIG_DATA *Current;
- EFI_TPL OldTpl;
- EFI_STATUS Status;
- BOOLEAN AddrOk;
- IP4_ADDR IpAddress;
- IP4_ADDR SubnetMask;
+ IP4_PROTOCOL *IpInstance;
+ EFI_IP4_CONFIG_DATA *Current;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ BOOLEAN AddrOk;
+ IP4_ADDR IpAddress;
+ IP4_ADDR SubnetMask;
//
// First, validate the parameters
@@ -898,7 +892,6 @@ EfiIp4Configure (
// Validate the configuration first.
//
if (IpConfigData != NULL) {
-
CopyMem (&IpAddress, &IpConfigData->StationAddress, sizeof (IP4_ADDR));
CopyMem (&SubnetMask, &IpConfigData->SubnetMask, sizeof (IP4_ADDR));
@@ -931,8 +924,9 @@ EfiIp4Configure (
}
if (!Current->UseDefaultAddress &&
- (!EFI_IP4_EQUAL (&Current->StationAddress, &IpConfigData->StationAddress) ||
- !EFI_IP4_EQUAL (&Current->SubnetMask, &IpConfigData->SubnetMask))) {
+ (!EFI_IP4_EQUAL (&Current->StationAddress, &IpConfigData->StationAddress) ||
+ !EFI_IP4_EQUAL (&Current->SubnetMask, &IpConfigData->SubnetMask)))
+ {
Status = EFI_ALREADY_STARTED;
goto ON_EXIT;
}
@@ -971,10 +965,8 @@ EfiIp4Configure (
ON_EXIT:
gBS->RestoreTPL (OldTpl);
return Status;
-
}
-
/**
Change the IP4 child's multicast setting. The caller
should make sure that the parameters is valid.
@@ -992,14 +984,14 @@ ON_EXIT:
**/
EFI_STATUS
Ip4Groups (
- IN IP4_PROTOCOL *IpInstance,
- IN BOOLEAN JoinFlag,
- IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
+ IN IP4_PROTOCOL *IpInstance,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
)
{
- IP4_ADDR *Members;
- IP4_ADDR Group;
- UINT32 Index;
+ IP4_ADDR *Members;
+ IP4_ADDR Group;
+ UINT32 Index;
//
// Add it to the instance's Groups, and join the group by IGMP.
@@ -1045,7 +1037,7 @@ Ip4Groups (
// Must iterate from the end to the beginning because the GroupCount
// is decremented each time an address is removed..
//
- for (Index = IpInstance->GroupCount; Index > 0 ; Index--) {
+ for (Index = IpInstance->GroupCount; Index > 0; Index--) {
ASSERT (IpInstance->Groups != NULL);
Group = IpInstance->Groups[Index - 1];
if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) {
@@ -1072,7 +1064,6 @@ Ip4Groups (
return ((GroupAddress != NULL) ? EFI_NOT_FOUND : EFI_SUCCESS);
}
-
/**
Joins and leaves multicast groups.
@@ -1106,15 +1097,15 @@ Ip4Groups (
EFI_STATUS
EFIAPI
EfiIp4Groups (
- IN EFI_IP4_PROTOCOL *This,
- IN BOOLEAN JoinFlag,
- IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
+ IN EFI_IP4_PROTOCOL *This,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
)
{
- IP4_PROTOCOL *IpInstance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- IP4_ADDR McastIp;
+ IP4_PROTOCOL *IpInstance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ IP4_ADDR McastIp;
if ((This == NULL) || (JoinFlag && (GroupAddress == NULL))) {
return EFI_INVALID_PARAMETER;
@@ -1148,7 +1139,6 @@ ON_EXIT:
return Status;
}
-
/**
Adds and deletes routing table entries.
@@ -1202,26 +1192,27 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiIp4Routes (
- IN EFI_IP4_PROTOCOL *This,
- IN BOOLEAN DeleteRoute,
- IN EFI_IPv4_ADDRESS *SubnetAddress,
- IN EFI_IPv4_ADDRESS *SubnetMask,
- IN EFI_IPv4_ADDRESS *GatewayAddress
+ IN EFI_IP4_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv4_ADDRESS *SubnetAddress,
+ IN EFI_IPv4_ADDRESS *SubnetMask,
+ IN EFI_IPv4_ADDRESS *GatewayAddress
)
{
- IP4_PROTOCOL *IpInstance;
- IP4_INTERFACE *IpIf;
- IP4_ADDR Dest;
- IP4_ADDR Netmask;
- IP4_ADDR Nexthop;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ IP4_PROTOCOL *IpInstance;
+ IP4_INTERFACE *IpIf;
+ IP4_ADDR Dest;
+ IP4_ADDR Netmask;
+ IP4_ADDR Nexthop;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
//
// First, validate the parameters
//
if ((This == NULL) || (SubnetAddress == NULL) ||
- (SubnetMask == NULL) || (GatewayAddress == NULL)) {
+ (SubnetMask == NULL) || (GatewayAddress == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -1246,7 +1237,7 @@ EfiIp4Routes (
Netmask = NTOHL (Netmask);
Nexthop = NTOHL (Nexthop);
- IpIf = IpInstance->Interface;
+ IpIf = IpInstance->Interface;
if (!IP4_IS_VALID_NETMASK (Netmask)) {
Status = EFI_INVALID_PARAMETER;
@@ -1257,9 +1248,9 @@ EfiIp4Routes (
// the gateway address must be a unicast on the connected network if not zero.
//
if ((Nexthop != IP4_ALLZERO_ADDRESS) &&
- ((IpIf->SubnetMask != IP4_ALLONE_ADDRESS && !IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask)) ||
- IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf)))) {
-
+ (((IpIf->SubnetMask != IP4_ALLONE_ADDRESS) && !IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask)) ||
+ IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf))))
+ {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
@@ -1275,7 +1266,6 @@ ON_EXIT:
return Status;
}
-
/**
Check whether the user's token or event has already
been enqueued on IP4's list.
@@ -1293,16 +1283,16 @@ ON_EXIT:
EFI_STATUS
EFIAPI
Ip4TokenExist (
- 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_IP4_COMPLETION_TOKEN *Token;
EFI_IP4_COMPLETION_TOKEN *TokenInItem;
- Token = (EFI_IP4_COMPLETION_TOKEN *) Context;
- TokenInItem = (EFI_IP4_COMPLETION_TOKEN *) Item->Key;
+ Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
+ TokenInItem = (EFI_IP4_COMPLETION_TOKEN *)Item->Key;
if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
return EFI_ACCESS_DENIED;
@@ -1325,18 +1315,18 @@ Ip4TokenExist (
**/
EFI_STATUS
Ip4TxTokenValid (
- IN EFI_IP4_COMPLETION_TOKEN *Token,
- IN IP4_INTERFACE *IpIf,
- IN BOOLEAN RawData
+ IN EFI_IP4_COMPLETION_TOKEN *Token,
+ IN IP4_INTERFACE *IpIf,
+ IN BOOLEAN RawData
)
{
- EFI_IP4_TRANSMIT_DATA *TxData;
- EFI_IP4_OVERRIDE_DATA *Override;
- IP4_ADDR Src;
- IP4_ADDR Gateway;
- UINT32 Offset;
- UINT32 Index;
- UINT32 HeadLen;
+ EFI_IP4_TRANSMIT_DATA *TxData;
+ EFI_IP4_OVERRIDE_DATA *Override;
+ IP4_ADDR Src;
+ IP4_ADDR Gateway;
+ UINT32 Offset;
+ UINT32 Index;
+ UINT32 HeadLen;
if ((Token == NULL) || (Token->Event == NULL) || (Token->Packet.TxData == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -1359,8 +1349,8 @@ Ip4TxTokenValid (
for (Index = 0; Index < TxData->FragmentCount; Index++) {
if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) ||
- (TxData->FragmentTable[Index].FragmentLength == 0)) {
-
+ (TxData->FragmentTable[Index].FragmentLength == 0))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -1407,8 +1397,8 @@ Ip4TxTokenValid (
if ((NetGetIpClass (Src) > IP4_ADDR_CLASSC) ||
(Src == IP4_ALLONE_ADDRESS) ||
- IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf))) {
-
+ IP4_IS_BROADCAST (Ip4GetNetCast (Src, IpIf)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -1419,8 +1409,8 @@ Ip4TxTokenValid (
if ((Gateway != IP4_ALLZERO_ADDRESS) &&
((NetGetIpClass (Gateway) > IP4_ADDR_CLASSC) ||
!IP4_NET_EQUAL (Gateway, IpIf->Ip, IpIf->SubnetMask) ||
- IP4_IS_BROADCAST (Ip4GetNetCast (Gateway, IpIf)))) {
-
+ IP4_IS_BROADCAST (Ip4GetNetCast (Gateway, IpIf))))
+ {
return EFI_INVALID_PARAMETER;
}
}
@@ -1431,15 +1421,14 @@ Ip4TxTokenValid (
HeadLen = sizeof (IP4_HEAD) + ((TxData->OptionsLength + 3) &~0x03);
if ((HeadLen > IP4_MAX_HEADLEN) ||
- (TxData->TotalDataLength + HeadLen > IP4_MAX_PACKET_SIZE)) {
-
+ (TxData->TotalDataLength + HeadLen > IP4_MAX_PACKET_SIZE))
+ {
return EFI_BAD_BUFFER_SIZE;
}
return EFI_SUCCESS;
}
-
/**
The callback function for the net buffer which wraps the user's
transmit token. Although it seems this function is pretty simple,
@@ -1464,13 +1453,13 @@ Ip4TxTokenValid (
VOID
EFIAPI
Ip4FreeTxToken (
- IN VOID *Context
+ IN VOID *Context
)
{
- IP4_TXTOKEN_WRAP *Wrap;
- NET_MAP_ITEM *Item;
+ IP4_TXTOKEN_WRAP *Wrap;
+ NET_MAP_ITEM *Item;
- Wrap = (IP4_TXTOKEN_WRAP *) Context;
+ Wrap = (IP4_TXTOKEN_WRAP *)Context;
//
// Signal IpSecRecycleEvent to inform IPsec free the memory
@@ -1501,7 +1490,6 @@ Ip4FreeTxToken (
FreePool (Wrap);
}
-
/**
The callback function to Ip4Output to update the transmit status.
@@ -1514,14 +1502,14 @@ Ip4FreeTxToken (
**/
VOID
Ip4OnPacketSent (
- IP4_PROTOCOL *Ip4Instance,
- NET_BUF *Packet,
- EFI_STATUS IoStatus,
- UINT32 Flag,
- VOID *Context
+ IP4_PROTOCOL *Ip4Instance,
+ NET_BUF *Packet,
+ EFI_STATUS IoStatus,
+ UINT32 Flag,
+ VOID *Context
)
{
- IP4_TXTOKEN_WRAP *Wrap;
+ IP4_TXTOKEN_WRAP *Wrap;
//
// This is the transmission request from upper layer,
@@ -1536,13 +1524,12 @@ Ip4OnPacketSent (
// release when all the fragments are release. Check the comments
// in Ip4FreeTxToken and Ip4Output for information.
//
- Wrap = (IP4_TXTOKEN_WRAP *) Context;
+ Wrap = (IP4_TXTOKEN_WRAP *)Context;
Wrap->Token->Status = IoStatus;
NetbufFree (Wrap->Packet);
}
-
/**
Places outgoing data packets into the transmit queue.
@@ -1575,27 +1562,27 @@ Ip4OnPacketSent (
EFI_STATUS
EFIAPI
EfiIp4Transmit (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_COMPLETION_TOKEN *Token
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token
)
{
- IP4_SERVICE *IpSb;
- IP4_PROTOCOL *IpInstance;
- IP4_INTERFACE *IpIf;
- IP4_TXTOKEN_WRAP *Wrap;
- EFI_IP4_TRANSMIT_DATA *TxData;
- EFI_IP4_CONFIG_DATA *Config;
- EFI_IP4_OVERRIDE_DATA *Override;
- IP4_HEAD Head;
- IP4_ADDR GateWay;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
- BOOLEAN DontFragment;
- UINT32 HeadLen;
- UINT8 RawHdrLen;
- UINT32 OptionsLength;
- UINT8 *OptionsBuffer;
- VOID *FirstFragment;
+ IP4_SERVICE *IpSb;
+ IP4_PROTOCOL *IpInstance;
+ IP4_INTERFACE *IpIf;
+ IP4_TXTOKEN_WRAP *Wrap;
+ EFI_IP4_TRANSMIT_DATA *TxData;
+ EFI_IP4_CONFIG_DATA *Config;
+ EFI_IP4_OVERRIDE_DATA *Override;
+ IP4_HEAD Head;
+ IP4_ADDR GateWay;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+ BOOLEAN DontFragment;
+ UINT32 HeadLen;
+ UINT8 RawHdrLen;
+ UINT32 OptionsLength;
+ UINT8 *OptionsBuffer;
+ VOID *FirstFragment;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -1607,11 +1594,11 @@ EfiIp4Transmit (
return EFI_NOT_STARTED;
}
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- IpSb = IpInstance->Service;
- IpIf = IpInstance->Interface;
- Config = &IpInstance->ConfigData;
+ IpSb = IpInstance->Service;
+ IpIf = IpInstance->Interface;
+ Config = &IpInstance->ConfigData;
if (Config->UseDefaultAddress && IP4_NO_MAPPING (IpInstance)) {
Status = EFI_NO_MAPPING;
@@ -1651,13 +1638,13 @@ EfiIp4Transmit (
FirstFragment = TxData->FragmentTable[0].FragmentBuffer;
CopyMem (&RawHdrLen, FirstFragment, sizeof (UINT8));
- RawHdrLen = (UINT8) (RawHdrLen & 0x0f);
+ RawHdrLen = (UINT8)(RawHdrLen & 0x0f);
if (RawHdrLen < 5) {
Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
- RawHdrLen = (UINT8) (RawHdrLen << 2);
+ RawHdrLen = (UINT8)(RawHdrLen << 2);
CopyMem (&Head, FirstFragment, IP4_MIN_HEADLEN);
@@ -1680,13 +1667,13 @@ EfiIp4Transmit (
OptionsBuffer = NULL;
} else {
OptionsLength = RawHdrLen - IP4_MIN_HEADLEN;
- OptionsBuffer = (UINT8 *) FirstFragment + IP4_MIN_HEADLEN;
+ OptionsBuffer = (UINT8 *)FirstFragment + IP4_MIN_HEADLEN;
}
//
// Trim off IPv4 header and options from first fragment.
//
- TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment + RawHdrLen;
+ TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment + RawHdrLen;
TxData->FragmentTable[0].FragmentLength = TxData->FragmentTable[0].FragmentLength - RawHdrLen;
} else {
CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR));
@@ -1717,7 +1704,7 @@ EfiIp4Transmit (
HeadLen = (TxData->OptionsLength + 3) & (~0x03);
OptionsLength = TxData->OptionsLength;
- OptionsBuffer = (UINT8 *) (TxData->OptionsBuffer);
+ OptionsBuffer = (UINT8 *)(TxData->OptionsBuffer);
}
//
@@ -1738,18 +1725,18 @@ EfiIp4Transmit (
goto ON_EXIT;
}
- Wrap->IpInstance = IpInstance;
- Wrap->Token = Token;
- Wrap->Sent = FALSE;
- Wrap->Life = IP4_US_TO_SEC (Config->TransmitTimeout);
- Wrap->Packet = NetbufFromExt (
- (NET_FRAGMENT *) TxData->FragmentTable,
- TxData->FragmentCount,
- IP4_MAX_HEADLEN,
- 0,
- Ip4FreeTxToken,
- Wrap
- );
+ Wrap->IpInstance = IpInstance;
+ Wrap->Token = Token;
+ Wrap->Sent = FALSE;
+ Wrap->Life = IP4_US_TO_SEC (Config->TransmitTimeout);
+ Wrap->Packet = NetbufFromExt (
+ (NET_FRAGMENT *)TxData->FragmentTable,
+ TxData->FragmentCount,
+ IP4_MAX_HEADLEN,
+ 0,
+ Ip4FreeTxToken,
+ Wrap
+ );
if (Wrap->Packet == NULL) {
FreePool (Wrap);
@@ -1768,7 +1755,7 @@ EfiIp4Transmit (
//
// Restore pointer of first fragment in RawData mode.
//
- TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment;
+ TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
}
NetbufFree (Wrap->Packet);
@@ -1800,7 +1787,7 @@ EfiIp4Transmit (
//
// Restore pointer of first fragment in RawData mode.
//
- TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment;
+ TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
}
NetbufFree (Wrap->Packet);
@@ -1810,7 +1797,7 @@ EfiIp4Transmit (
//
// Restore pointer of first fragment in RawData mode.
//
- TxData->FragmentTable[0].FragmentBuffer = (UINT8 *) FirstFragment;
+ TxData->FragmentTable[0].FragmentBuffer = (UINT8 *)FirstFragment;
}
ON_EXIT:
@@ -1818,7 +1805,6 @@ ON_EXIT:
return Status;
}
-
/**
Places a receiving request into the receiving queue.
@@ -1854,13 +1840,13 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiIp4Receive (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_COMPLETION_TOKEN *Token
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token
)
{
- IP4_PROTOCOL *IpInstance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ IP4_PROTOCOL *IpInstance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
//
// First validate the parameters
@@ -1910,7 +1896,6 @@ ON_EXIT:
return Status;
}
-
/**
Cancel the transmitted but not recycled packet. If a matching
token is found, it will call Ip4CancelPacket to cancel the
@@ -1931,15 +1916,15 @@ ON_EXIT:
EFI_STATUS
EFIAPI
Ip4CancelTxTokens (
- 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_IP4_COMPLETION_TOKEN *Token;
IP4_TXTOKEN_WRAP *Wrap;
- Token = (EFI_IP4_COMPLETION_TOKEN *) Context;
+ Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
//
// Return EFI_SUCCESS to check the next item in the map if
@@ -1949,7 +1934,7 @@ Ip4CancelTxTokens (
return EFI_SUCCESS;
}
- Wrap = (IP4_TXTOKEN_WRAP *) Item->Value;
+ Wrap = (IP4_TXTOKEN_WRAP *)Item->Value;
ASSERT (Wrap != NULL);
//
@@ -1969,7 +1954,6 @@ Ip4CancelTxTokens (
return EFI_SUCCESS;
}
-
/**
Cancel the receive request. This is quiet simple, because
it is only enqueued in our local receive map.
@@ -1987,15 +1971,15 @@ Ip4CancelTxTokens (
EFI_STATUS
EFIAPI
Ip4CancelRxTokens (
- 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_IP4_COMPLETION_TOKEN *Token;
EFI_IP4_COMPLETION_TOKEN *This;
- Token = (EFI_IP4_COMPLETION_TOKEN *) Context;
+ Token = (EFI_IP4_COMPLETION_TOKEN *)Context;
This = Item->Key;
if ((Token != NULL) && (Token != This)) {
@@ -2015,7 +1999,6 @@ Ip4CancelRxTokens (
return EFI_SUCCESS;
}
-
/**
Cancel the user's receive/transmit request.
@@ -2031,11 +2014,11 @@ Ip4CancelRxTokens (
**/
EFI_STATUS
Ip4Cancel (
- IN IP4_PROTOCOL *IpInstance,
- IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
+ IN IP4_PROTOCOL *IpInstance,
+ IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// First check the transmitted packet. Ip4CancelTxTokens returns
@@ -2083,15 +2066,14 @@ Ip4Cancel (
// all of them are cancelled.
//
if (!NetMapIsEmpty (&IpInstance->TxTokens) ||
- !NetMapIsEmpty (&IpInstance->RxTokens)) {
-
+ !NetMapIsEmpty (&IpInstance->RxTokens))
+ {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
-
/**
Abort an asynchronous transmit or receive request.
@@ -2124,13 +2106,13 @@ Ip4Cancel (
EFI_STATUS
EFIAPI
EfiIp4Cancel (
- IN EFI_IP4_PROTOCOL *This,
- IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
)
{
- IP4_PROTOCOL *IpInstance;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ IP4_PROTOCOL *IpInstance;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2157,7 +2139,6 @@ ON_EXIT:
return Status;
}
-
/**
Polls for incoming data packets and processes outgoing data packets.
@@ -2188,7 +2169,7 @@ ON_EXIT:
EFI_STATUS
EFIAPI
EfiIp4Poll (
- IN EFI_IP4_PROTOCOL *This
+ IN EFI_IP4_PROTOCOL *This
)
{
IP4_PROTOCOL *IpInstance;
@@ -2230,14 +2211,14 @@ EfiIp4Poll (
EFI_STATUS
EFIAPI
Ip4SentPacketTicking (
- IN NET_MAP *Map,
- IN NET_MAP_ITEM *Item,
- IN VOID *Context
+ IN NET_MAP *Map,
+ IN NET_MAP_ITEM *Item,
+ IN VOID *Context
)
{
- IP4_TXTOKEN_WRAP *Wrap;
+ IP4_TXTOKEN_WRAP *Wrap;
- Wrap = (IP4_TXTOKEN_WRAP *) Item->Value;
+ Wrap = (IP4_TXTOKEN_WRAP *)Item->Value;
ASSERT (Wrap != NULL);
if ((Wrap->Life > 0) && (--Wrap->Life == 0)) {
@@ -2259,13 +2240,13 @@ Ip4SentPacketTicking (
VOID
EFIAPI
Ip4TimerTicking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- IP4_SERVICE *IpSb;
+ IP4_SERVICE *IpSb;
- IpSb = (IP4_SERVICE *) Context;
+ IpSb = (IP4_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
Ip4PacketTimerTicking (IpSb);
@@ -2287,16 +2268,16 @@ Ip4TimerTicking (
VOID
EFIAPI
Ip4TimerReconfigChecking (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- IP4_SERVICE *IpSb;
- BOOLEAN OldMediaPresent;
- EFI_STATUS Status;
- EFI_SIMPLE_NETWORK_MODE SnpModeData;
+ IP4_SERVICE *IpSb;
+ BOOLEAN OldMediaPresent;
+ EFI_STATUS Status;
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;
- IpSb = (IP4_SERVICE *) Context;
+ IpSb = (IP4_SERVICE *)Context;
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
OldMediaPresent = IpSb->MediaPresent;