/** @file\r
The implementation of EFI IPv4 Configuration II Protocol.\r
\r
- Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
\r
This program and the accompanying materials\r
\r
IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
\r
+ //\r
+ // Check whether the StationAddress/SubnetMask pair is valid.\r
+ //\r
+ if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
{\r
UINTN OldIndex;\r
UINTN NewIndex;\r
- UINTN Index1;\r
EFI_IPv4_ADDRESS *OldDns;\r
EFI_IPv4_ADDRESS *NewDns;\r
UINTN OldDnsCount;\r
\r
for (NewIndex = 0; NewIndex < NewDnsCount; NewIndex++) {\r
CopyMem (&DnsAddress, NewDns + NewIndex, sizeof (IP4_ADDR));\r
-\r
- if (!NetIp4IsUnicast (NTOHL (DnsAddress), 0)) {\r
+ if (IP4_IS_UNSPECIFIED (NTOHL (DnsAddress)) || IP4_IS_LOCAL_BROADCAST (NTOHL (DnsAddress))) {\r
//\r
// The dns server address must be unicast.\r
//\r
- FreePool (Tmp);\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- for (Index1 = NewIndex + 1; Index1 < NewDnsCount; Index1++) {\r
- if (EFI_IP4_EQUAL (NewDns + NewIndex, NewDns + Index1)) {\r
+ if (Tmp != NULL) {\r
FreePool (Tmp);\r
- return EFI_INVALID_PARAMETER;\r
}\r
+ return EFI_INVALID_PARAMETER;\r
}\r
\r
if (OneAdded) {\r
\r
@param[in] Instance The IP4 config2 instance to configure\r
\r
- @retval EFI_SUCCESS The auto configuration is successfull started\r
+ @retval EFI_SUCCESS The auto configuration is successfully started\r
@retval Others Failed to start auto configuration.\r
\r
**/\r
\r
NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data);\r
\r
+ StationAddress = EFI_NTOHL (NewAddress.Address);\r
+ SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);\r
+\r
+ //\r
+ // Check whether the StationAddress/SubnetMask pair is valid.\r
+ //\r
+ if (!Ip4StationAddressValid (StationAddress, SubnetMask)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
//\r
// Store the new data, and init the DataItem status to EFI_NOT_READY because\r
// we may have an asynchronous configuration process.\r
DataItem->DataSize = DataSize;\r
DataItem->Status = EFI_NOT_READY;\r
\r
- StationAddress = EFI_NTOHL (NewAddress.Address);\r
- SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);\r
-\r
IpSb->Reconfig = TRUE;\r
Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);\r
- if (EFI_ERROR (Status)) {\r
- goto ON_EXIT;\r
- } \r
\r
- DataItem->Status = EFI_SUCCESS; \r
+ DataItem->Status = Status; \r
\r
-ON_EXIT:\r
- if (EFI_ERROR (DataItem->Status)) {\r
+ if (EFI_ERROR (DataItem->Status) && DataItem->Status != EFI_NOT_READY) {\r
if (Ptr != NULL) {\r
FreePool (Ptr);\r
}\r
DataItem->Data.Ptr = NULL; \r
}\r
\r
- return EFI_SUCCESS;\r
+ return Status;\r
}\r
\r
/**\r
return EFI_WRITE_PROTECTED;\r
}\r
\r
+ IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
\r
NewGateway = (EFI_IPv4_ADDRESS *) Data;\r
NewGatewayCount = DataSize / sizeof (EFI_IPv4_ADDRESS);\r
for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {\r
CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR));\r
- \r
- if (!NetIp4IsUnicast (NTOHL (Gateway), 0)) {\r
\r
+ if ((IpSb->DefaultInterface->SubnetMask != 0) && \r
+ !NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetMask)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
}\r
}\r
\r
- IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
DataItem = &Instance->DataItem[Ip4Config2DataTypeGateway];\r
OldGateway = DataItem->Data.Gateway;\r
OldGatewayCount = DataItem->DataSize / sizeof (EFI_IPv4_ADDRESS);\r
OUT EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo\r
)\r
{\r
- IfInfo->Name[0] = L'e';\r
- IfInfo->Name[1] = L't';\r
- IfInfo->Name[2] = L'h';\r
- IfInfo->Name[3] = (CHAR16) (L'0' + IpSb->Ip4Config2Instance.IfIndex);\r
- IfInfo->Name[4] = 0;\r
+ UnicodeSPrint (\r
+ IfInfo->Name,\r
+ EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE,\r
+ L"eth%d",\r
+ IpSb->Ip4Config2Instance.IfIndex\r
+ );\r
\r
IfInfo->IfType = IpSb->SnpMode.IfType;\r
IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;\r