11CHAR16 mIp4Config2StorageName[] = L
"IP4_CONFIG2_IFR_NVDATA";
33 ReverseMask =
SwapBytes32 (*(UINT32 *)&SubnetMask[0]);
38 ReverseMask = ~ReverseMask;
40 if ((ReverseMask & (ReverseMask + 1)) != 0) {
46 while (ReverseMask != 0) {
47 ReverseMask = ReverseMask >> 1;
51 return (UINT8)(32 - Len);
75 while (*Str != L
'\0') {
77 return EFI_INVALID_PARAMETER;
81 while ((*Str >= L
'0') && (*Str <= L
'9')) {
82 Number = Number * 10 + (*Str - L
'0');
87 return EFI_INVALID_PARAMETER;
90 Ip->Addr[Index] = (UINT8)Number;
92 if ((*Str != L
'\0') && (*Str != L
'.')) {
97 return EFI_INVALID_PARAMETER;
111 return EFI_INVALID_PARAMETER;
144 EndIndex = BeginIndex;
160 while (*(Str + Index) != L
'\0') {
161 if (*(Str + Index) == L
' ') {
181 if (*PtrIpList ==
NULL) {
182 return EFI_OUT_OF_RESOURCES;
189 while (*(Str + Index) != L
'\0') {
190 if (*(Str + Index) == L
' ') {
193 if (StrTemp ==
NULL) {
197 return EFI_OUT_OF_RESOURCES;
200 CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) *
sizeof (CHAR16));
201 *(StrTemp + (EndIndex - BeginIndex)) = L
'\0';
208 return EFI_INVALID_PARAMETER;
211 BeginIndex = EndIndex;
227 if (*(Str + Index) == L
'\0') {
230 if (StrTemp ==
NULL) {
234 return EFI_OUT_OF_RESOURCES;
237 CopyMem (StrTemp, Str + BeginIndex, (EndIndex - BeginIndex) *
sizeof (CHAR16));
238 *(StrTemp + (EndIndex - BeginIndex)) = L
'\0';
245 return EFI_INVALID_PARAMETER;
271 2 * IP4_STR_MAX_SIZE,
312 for (Index = 0; Index < IpCount; Index++) {
314 if (TempStr ==
NULL) {
316 if (TempStr ==
NULL) {
317 return EFI_OUT_OF_RESOURCES;
323 2 * IP4_STR_MAX_SIZE,
331 for (TemIndex = 0; TemIndex < IP4_STR_MAX_SIZE; TemIndex++) {
332 if (*(TempStr + TemIndex) == L
'\0') {
333 if (Index == IpCount - 1) {
334 Str[StrIndex++] = L
'\0';
336 Str[StrIndex++] = L
' ';
341 Str[StrIndex++] = *(TempStr + TemIndex);
346 if (TempStr !=
NULL) {
367 *((BOOLEAN *)Context) =
TRUE;
401 Ip4Config2 = &Instance->Ip4Config2;
406 if ((IfrNvData ==
NULL) || (Instance ==
NULL)) {
407 return EFI_INVALID_PARAMETER;
410 NET_CHECK_SIGNATURE (Instance, IP4_CONFIG2_INSTANCE_SIGNATURE);
412 IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
414 if (IpSb->DefaultInterface->Configured) {
415 IfrNvData->Configure = 1;
417 IfrNvData->Configure = 0;
425 Status = Ip4Config2->GetData (
431 if (EFI_ERROR (Status)) {
436 IfrNvData->DhcpEnable =
FALSE;
438 IfrNvData->DhcpEnable =
TRUE;
446 Status = Ip4Config2->GetData (
452 if (Status != EFI_BUFFER_TOO_SMALL) {
457 if (Ip4Info ==
NULL) {
458 Status = EFI_OUT_OF_RESOURCES;
462 Status = Ip4Config2->GetData (
468 if (EFI_ERROR (Status)) {
475 Status = Ip4Config2->GetData (
481 if (EFI_ERROR (Status)) {
489 Status = Ip4Config2->GetData (
495 if ((Status != EFI_BUFFER_TOO_SMALL) && (Status != EFI_NOT_FOUND)) {
503 if (DnsAddress ==
NULL) {
504 Status = EFI_OUT_OF_RESOURCES;
508 Status = Ip4Config2->GetData (
514 if (EFI_ERROR (Status)) {
526 if (DnsAddress !=
NULL) {
530 if (Ip4Info !=
NULL) {
575 Ip4Cfg2 = &Instance->Ip4Config2;
576 Ip4NvData = &Instance->Ip4NvData;
582 SetAddressEvent =
NULL;
584 if ((Instance ==
NULL) || (IfrFormNvData ==
NULL)) {
585 return EFI_INVALID_PARAMETER;
588 if (IfrFormNvData->Configure !=
TRUE) {
608 Status = Ip4Cfg2->SetData (
617 if (IfrFormNvData->DhcpEnable ==
TRUE) {
620 Status = Ip4Cfg2->SetData (
626 if (EFI_ERROR (Status)) {
637 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Subnet Mask!",
NULL);
638 return EFI_INVALID_PARAMETER;
642 if (EFI_ERROR (Status) ||
643 ((SubnetMask.Addr[0] != 0) && !
NetIp4IsUnicast (NTOHL (StationAddress.Addr[0]), NTOHL (SubnetMask.Addr[0]))) ||
646 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid IP address!",
NULL);
647 return EFI_INVALID_PARAMETER;
651 if (EFI_ERROR (Status) ||
652 ((Gateway.Addr[0] != 0) && (SubnetMask.Addr[0] != 0) && !
NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (SubnetMask.Addr[0]))))
654 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Gateway!",
NULL);
655 return EFI_INVALID_PARAMETER;
659 if (!EFI_ERROR (Status) && (DnsCount > 0)) {
660 for (Index = 0; Index < DnsCount; Index++) {
661 CopyMem (&Ip, &DnsAddress[Index],
sizeof (IP4_ADDR));
662 if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
663 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Dns Server!",
NULL);
665 return EFI_INVALID_PARAMETER;
669 if (EFI_ERROR (Status)) {
670 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Dns Server!",
NULL);
681 if (DnsAddress !=
NULL) {
685 return EFI_OUT_OF_RESOURCES;
698 if (DnsAddress !=
NULL) {
702 return EFI_OUT_OF_RESOURCES;
717 Status = Ip4Cfg2->SetData (
723 if (EFI_ERROR (Status)) {
730 Status =
gBS->CreateEvent (
737 if (EFI_ERROR (Status)) {
738 return EFI_OUT_OF_RESOURCES;
741 Status =
gBS->CreateEvent (
748 if (EFI_ERROR (Status)) {
754 Status = Ip4Cfg2->RegisterDataNotify (
759 if (EFI_ERROR (Status)) {
767 Status = Ip4Cfg2->SetData (
774 if (Status == EFI_NOT_READY) {
776 while (EFI_ERROR (
gBS->CheckEvent (TimeoutEvent))) {
784 Ip4Cfg2->UnregisterDataNotify (
789 if (EFI_ERROR (Status)) {
797 Status = Ip4Cfg2->SetData (
803 if (EFI_ERROR (Status)) {
812 Status = Ip4Cfg2->SetData (
819 if (EFI_ERROR (Status)) {
826 if (SetAddressEvent !=
NULL) {
827 gBS->CloseEvent (SetAddressEvent);
830 if (TimeoutEvent !=
NULL) {
831 gBS->CloseEvent (TimeoutEvent);
898 OUT EFI_STRING *Progress,
899 OUT EFI_STRING *Results
906 EFI_STRING ConfigRequestHdr;
907 EFI_STRING ConfigRequest;
908 BOOLEAN AllocatedRequest;
909 EFI_STRING FormResult;
913 if ((Progress ==
NULL) || (Results ==
NULL)) {
914 return EFI_INVALID_PARAMETER;
918 IfrFormNvData =
NULL;
919 ConfigRequest =
NULL;
922 AllocatedRequest =
FALSE;
923 ConfigRequest = Request;
924 Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
925 Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
934 if (IfrFormNvData ==
NULL) {
935 return EFI_OUT_OF_RESOURCES;
946 ConfigRequestHdr =
HiiConstructConfigHdr (&gIp4Config2NvDataGuid, mIp4Config2StorageName, Private->ChildHandle);
947 Size = (
StrLen (ConfigRequestHdr) + 32 + 1) *
sizeof (CHAR16);
949 if (ConfigRequest ==
NULL) {
950 Status = EFI_OUT_OF_RESOURCES;
954 AllocatedRequest =
TRUE;
956 UnicodeSPrint (ConfigRequest, Size, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
966 (UINT8 *)IfrFormNvData,
977 if (AllocatedRequest) {
979 ConfigRequest =
NULL;
982 if (EFI_ERROR (Status)) {
988 *Results = FormResult;
990 return EFI_NOT_FOUND;
997 if (Request ==
NULL) {
999 }
else if (
StrStr (Request, L
"OFFSET") ==
NULL) {
1000 *Progress = Request +
StrLen (Request);
1043 IN CONST EFI_STRING Configuration,
1044 OUT EFI_STRING *Progress
1054 IfrFormNvData =
NULL;
1056 if ((Configuration ==
NULL) || (Progress ==
NULL)) {
1057 return EFI_INVALID_PARAMETER;
1060 *Progress = Configuration;
1062 Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
1063 Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
1068 if (
HiiIsConfigHdrMatch (Configuration, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) {
1073 if (IfrFormNvData ==
NULL) {
1074 return EFI_OUT_OF_RESOURCES;
1082 (UINT8 *)IfrFormNvData,
1086 if (Status != EFI_BUFFER_TOO_SMALL) {
1093 (UINT8 *)IfrFormNvData,
1097 if (!EFI_ERROR (Status)) {
1103 return EFI_NOT_FOUND;
1140 IN EFI_BROWSER_ACTION Action,
1141 IN EFI_QUESTION_ID QuestionId,
1144 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
1161 IfrFormNvData =
NULL;
1165 if (Action == EFI_BROWSER_ACTION_CHANGED) {
1166 Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
1167 Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK (Private);
1170 if (IfrFormNvData ==
NULL) {
1171 return EFI_OUT_OF_RESOURCES;
1179 return EFI_NOT_FOUND;
1184 switch (QuestionId) {
1187 if (EFI_ERROR (Status) || IP4_IS_UNSPECIFIED (NTOHL (StationAddress.Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (StationAddress.Addr[0]))) {
1188 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid IP address!",
NULL);
1189 Status = EFI_INVALID_PARAMETER;
1194 case KEY_SUBNET_MASK:
1197 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Subnet Mask!",
NULL);
1198 Status = EFI_INVALID_PARAMETER;
1205 if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST (NTOHL (Gateway.Addr[0]))) {
1206 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Gateway!",
NULL);
1207 Status = EFI_INVALID_PARAMETER;
1214 if (!EFI_ERROR (Status) && (DnsCount > 0)) {
1215 for (Index = 0; Index < DnsCount; Index++) {
1216 CopyMem (&Ip, &DnsAddress[Index],
sizeof (IP4_ADDR));
1217 if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
1218 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Dns Server!",
NULL);
1219 Status = EFI_INVALID_PARAMETER;
1224 if (EFI_ERROR (Status)) {
1225 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L
"Invalid Dns Server!",
NULL);
1229 if (DnsAddress !=
NULL) {
1235 case KEY_SAVE_CHANGES:
1237 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
1252 return EFI_UNSUPPORTED;
1277 CHAR16 MenuString[128];
1278 CHAR16 PortString[128];
1279 CHAR16 *OldMenuString;
1282 IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
1283 ASSERT (IpSb !=
NULL);
1285 CallbackInfo = &Instance->CallbackInfo;
1287 CallbackInfo->Signature = IP4_FORM_CALLBACK_INFO_SIGNATURE;
1289 Status =
gBS->HandleProtocol (
1291 &gEfiDevicePathProtocolGuid,
1292 (VOID **)&ParentDevicePath
1294 if (EFI_ERROR (Status)) {
1314 if (CallbackInfo->HiiVendorDevicePath ==
NULL) {
1315 Status = EFI_OUT_OF_RESOURCES;
1319 ConfigAccess = &CallbackInfo->HiiConfigAccessProtocol;
1327 Status =
gBS->InstallMultipleProtocolInterfaces (
1328 &CallbackInfo->ChildHandle,
1329 &gEfiDevicePathProtocolGuid,
1330 CallbackInfo->HiiVendorDevicePath,
1331 &gEfiHiiConfigAccessProtocolGuid,
1336 if (!EFI_ERROR (Status)) {
1340 Status =
gBS->OpenProtocol (
1342 &gEfiManagedNetworkServiceBindingProtocolGuid,
1345 CallbackInfo->ChildHandle,
1346 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1350 if (EFI_ERROR (Status)) {
1358 &gIp4Config2NvDataGuid,
1359 CallbackInfo->ChildHandle,
1364 if (CallbackInfo->RegisteredHandle ==
NULL) {
1365 Status = EFI_OUT_OF_RESOURCES;
1373 if (!EFI_ERROR (Status)) {
1375 CallbackInfo->RegisteredHandle,
1379 UnicodeSPrint (MenuString, 128, L
"%s (MAC:%s)", OldMenuString, MacString);
1381 CallbackInfo->RegisteredHandle,
1389 CallbackInfo->RegisteredHandle,
1421 IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
1422 ASSERT (IpSb !=
NULL);
1424 CallbackInfo = &Instance->CallbackInfo;
1426 if (CallbackInfo->ChildHandle !=
NULL) {
1430 gBS->CloseProtocol (
1432 &gEfiManagedNetworkServiceBindingProtocolGuid,
1434 CallbackInfo->ChildHandle
1440 gBS->UninstallMultipleProtocolInterfaces (
1441 CallbackInfo->ChildHandle,
1442 &gEfiDevicePathProtocolGuid,
1443 CallbackInfo->HiiVendorDevicePath,
1444 &gEfiHiiConfigAccessProtocolGuid,
1445 &CallbackInfo->HiiConfigAccessProtocol,
1450 if (CallbackInfo->HiiVendorDevicePath !=
NULL) {
1451 FreePool (CallbackInfo->HiiVendorDevicePath);
1454 if (CallbackInfo->RegisteredHandle !=
NULL) {
1461 Ip4NvData = &Instance->Ip4NvData;
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define HARDWARE_DEVICE_PATH
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING EFIAPI HiiConstructConfigHdr(IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL, IN EFI_HANDLE DriverHandle)
BOOLEAN EFIAPI HiiGetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, OUT UINT8 *Buffer)
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
BOOLEAN EFIAPI HiiIsConfigHdrMatch(IN CONST EFI_STRING ConfigHdr, IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL)
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
BOOLEAN Ip4StationAddressValid(IN IP4_ADDR Ip, IN IP4_ADDR Netmask)
@ Ip4Config2DataTypeManualAddress
@ Ip4Config2DataTypeGateway
@ Ip4Config2DataTypePolicy
@ Ip4Config2DataTypeInterfaceInfo
@ Ip4Config2DataTypeDnsServer
EFI_STATUS EFIAPI Ip4FormRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
EFI_STATUS Ip4Config2ConvertConfigNvDataToIfrNvData(IN IP4_CONFIG2_INSTANCE *Instance, IN OUT IP4_CONFIG2_IFR_NVDATA *IfrNvData)
EFI_STATUS Ip4Config2StrToIpList(IN CHAR16 *Str, OUT EFI_IPv4_ADDRESS **PtrIpList, OUT UINTN *IpCount)
EFI_STATUS Ip4Config2FormInit(IN OUT IP4_CONFIG2_INSTANCE *Instance)
EFI_STATUS EFIAPI Ip4FormExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
VOID EFIAPI Ip4Config2ManualAddressNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI Ip4FormCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
VOID Ip4Config2FormUnload(IN OUT IP4_CONFIG2_INSTANCE *Instance)
EFI_STATUS Ip4Config2ConvertIfrNvDataToConfigNvData(IN IP4_CONFIG2_IFR_NVDATA *IfrFormNvData, IN OUT IP4_CONFIG2_INSTANCE *Instance)
VOID Ip4Config2IpToStr(IN EFI_IPv4_ADDRESS *Ip, OUT CHAR16 *Str)
UINT8 GetSubnetMaskPrefixLength(IN EFI_IPv4_ADDRESS *SubnetMask)
EFI_STATUS Ip4Config2StrToIp(IN CHAR16 *Str, OUT EFI_IPv4_ADDRESS *Ip)
EFI_STATUS Ip4Config2IpListToStr(IN EFI_IPv4_ADDRESS *Ip, IN UINTN IpCount, OUT CHAR16 *Str)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_STATUS EFIAPI NetLibGetMacString(IN EFI_HANDLE ServiceHandle, IN EFI_HANDLE ImageHandle OPTIONAL, OUT CHAR16 **MacString)
BOOLEAN EFIAPI NetIp4IsUnicast(IN IP4_ADDR Ip, IN IP4_ADDR NetMask)
VOID EFIAPI Exit(IN EFI_STATUS Status)
IPv4_ADDRESS EFI_IPv4_ADDRESS
EFI_HII_CONFIG_ROUTING_PROTOCOL * gHiiConfigRouting
VOID EFIAPI CreatePopUp(IN UINTN Attribute, OUT EFI_INPUT_KEY *Key OPTIONAL,...)
EFI_IPv4_ADDRESS SubnetMask
EFI_IPv4_ADDRESS StationAddress
EFI_IPv4_ADDRESS SubnetMask
EFI_IP4_CONFIG2_MANUAL_ADDRESS * ManualAddress
IP addresses.
EFI_IPv4_ADDRESS * DnsAddress
DNS server address.
UINT32 ManualAddressCount
IP addresses count.
UINT32 DnsAddressCount
DNS server address count.
EFI_IP4_CONFIG2_POLICY Policy
manual or automatic
EFI_IPv4_ADDRESS * GatewayAddress
Gateway address.
UINT32 GatewayAddressCount
Gateway address count.