2 Helper functions for configuring or obtaining the parameters relating to IP6.
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 EFI_GUID mIp6HiiVendorDevicePathGuid
= IP6_HII_VENDOR_DEVICE_PATH_GUID
;
19 EFI_GUID mIp6ConfigNvDataGuid
= IP6_CONFIG_NVDATA_GUID
;
20 CHAR16 mIp6ConfigStorageName
[] = L
"IP6_CONFIG_IFR_NVDATA";
23 The notify function of create event when performing a manual configuration.
25 @param[in] Event The pointer of Event.
26 @param[in] Context The pointer of Context.
31 Ip6ConfigManualAddressNotify (
36 *((BOOLEAN
*) Context
) = TRUE
;
40 Get the configuration data for the EFI IPv6 network stack running on the
41 communication. It is a help function to the call EfiIp6ConfigGetData().
43 @param[in] Ip6Config The pointer to the EFI_IP6_CONFIG_PROTOCOL instance.
44 @param[in] DataType The type of data to get.
45 @param[out] DataSize The size of buffer required in bytes.
46 @param[out] Data The data buffer in which the configuration data is returned. The
47 type of the data buffer associated with the DataType.
48 It is the caller's responsibility to free the resource.
50 @retval EFI_SUCCESS The specified configuration data was obtained successfully.
51 @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:
52 - Ip6Config is NULL or invalid.
55 @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resources.
56 @retval EFI_NOT_READY The specified configuration data is not ready due to an
57 asynchronous configuration process already in progress.
58 @retval EFI_NOT_FOUND The specified configuration data was not found.
63 IN EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
,
64 IN EFI_IP6_CONFIG_DATA_TYPE DataType
,
73 if ((Ip6Config
== NULL
) || (Data
== NULL
) || (DataSize
== NULL
)) {
74 return EFI_INVALID_PARAMETER
;
78 Status
= Ip6Config
->GetData (
84 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
88 Buffer
= AllocateZeroPool (BufferSize
);
90 return EFI_OUT_OF_RESOURCES
;
93 Status
= Ip6Config
->GetData (
99 if (EFI_ERROR (Status
)) {
104 *DataSize
= BufferSize
;
111 Free all nodes in IP6_ADDRESS_INFO_ENTRY in the list array specified
114 @param[in] ListHead The head of the list array in IP6_ADDRESS_INFO_ENTRY.
118 Ip6FreeAddressInfoList (
119 IN LIST_ENTRY
*ListHead
122 IP6_ADDRESS_INFO_ENTRY
*Node
;
124 LIST_ENTRY
*NextEntry
;
126 NET_LIST_FOR_EACH_SAFE (Entry
, NextEntry
, ListHead
) {
127 Node
= NET_LIST_USER_STRUCT (Entry
, IP6_ADDRESS_INFO_ENTRY
, Link
);
128 RemoveEntryList (&Node
->Link
);
134 Convert the IPv6 address into a formatted string.
136 @param[in] Ip6 The IPv6 address.
137 @param[out] Str The formatted IP string.
142 IN EFI_IPv6_ADDRESS
*Ip6
,
149 CHAR16 FormatString
[8];
153 for (Index
= 0; Index
< 15; Index
= Index
+ 2) {
156 Ip6
->Addr
[Index
] == 0 &&
157 Ip6
->Addr
[Index
+ 1] == 0
160 // Deal with the case of ::.
171 while ((Index
< 15) && (Ip6
->Addr
[Index
] == 0) && (Ip6
->Addr
[Index
+ 1] == 0)) {
179 // :: is at the end of the address.
188 if (Ip6
->Addr
[Index
] == 0) {
189 Number
= UnicodeSPrint (Str
, 2 * IP6_STR_MAX_SIZE
, L
"%x:", (UINTN
) Ip6
->Addr
[Index
+ 1]);
191 if (Ip6
->Addr
[Index
+ 1] < 0x10) {
192 CopyMem (FormatString
, L
"%x0%x:", StrSize (L
"%x0%x:"));
194 CopyMem (FormatString
, L
"%x%x:", StrSize (L
"%x%x:"));
197 Number
= UnicodeSPrint (
199 2 * IP6_STR_MAX_SIZE
,
200 (CONST CHAR16
*) FormatString
,
201 (UINTN
) Ip6
->Addr
[Index
],
202 (UINTN
) Ip6
->Addr
[Index
+ 1]
208 if (Index
+ 2 == 16) {
210 if (*(Str
- 1) == L
':') {
218 Convert EFI_IP6_CONFIG_INTERFACE_ID to string format.
220 @param[out] String The buffer to store the converted string.
221 @param[in] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
223 @retval EFI_SUCCESS The string converted successfully.
224 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
228 Ip6ConvertInterfaceIdToString (
230 IN EFI_IP6_CONFIG_INTERFACE_ID
*IfId
236 if ((String
== NULL
) || (IfId
== NULL
)) {
237 return EFI_INVALID_PARAMETER
;
240 for (Index
= 0; Index
< 8; Index
++) {
241 Number
= UnicodeSPrint (
243 2 * INTERFACE_ID_STR_STORAGE
,
245 (UINTN
) IfId
->Id
[Index
]
247 String
= String
+ Number
;
250 *(String
- 1) = '\0';
256 Parse InterfaceId in string format and convert it to EFI_IP6_CONFIG_INTERFACE_ID.
258 @param[in] String The buffer of the string to be parsed.
259 @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
261 @retval EFI_SUCCESS The operation finished successfully.
262 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
266 Ip6ParseInterfaceIdFromString (
267 IN CONST CHAR16
*String
,
268 OUT EFI_IP6_CONFIG_INTERFACE_ID
*IfId
276 if ((String
== NULL
) || (IfId
== NULL
)) {
277 return EFI_INVALID_PARAMETER
;
280 IfIdStr
= (CHAR16
*) String
;
282 ZeroMem (IfId
, sizeof (EFI_IP6_CONFIG_INTERFACE_ID
));
284 for (Index
= 0; Index
< 8; Index
++) {
287 while ((*IfIdStr
!= L
'\0') && (*IfIdStr
!= L
':')) {
292 // The InterfaceId format is X:X:X:X, the number of X should not exceed 8.
293 // If the number of X is less than 8, zero is appended to the InterfaceId.
295 if ((*IfIdStr
== ':') && (Index
== 7)) {
296 return EFI_INVALID_PARAMETER
;
300 // Convert the string to interface id. AsciiStrHexToUintn stops at the
301 // first character that is not a valid hex character, ':' or '\0' here.
303 NodeVal
= StrHexToUintn (TempStr
);
304 if (NodeVal
> 0xFF) {
305 return EFI_INVALID_PARAMETER
;
308 IfId
->Id
[Index
] = (UINT8
) NodeVal
;
317 Create Hii Extend Label OpCode as the start opcode and end opcode. It is
320 @param[in] StartLabelNumber The number of start label.
321 @param[out] StartOpCodeHandle Points to the start opcode handle.
322 @param[out] StartLabel Points to the created start opcode.
323 @param[out] EndOpCodeHandle Points to the end opcode handle.
324 @param[out] EndLabel Points to the created end opcode.
326 @retval EFI_OUT_OF_RESOURCES Does not have sufficient resources to finish this
328 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
329 @retval EFI_SUCCESS The operation completed successfully.
334 IN UINT16 StartLabelNumber
,
335 OUT VOID
**StartOpCodeHandle
,
336 OUT EFI_IFR_GUID_LABEL
**StartLabel
,
337 OUT VOID
**EndOpCodeHandle
,
338 OUT EFI_IFR_GUID_LABEL
**EndLabel
342 EFI_IFR_GUID_LABEL
*InternalStartLabel
;
343 EFI_IFR_GUID_LABEL
*InternalEndLabel
;
345 if (StartOpCodeHandle
== NULL
|| StartLabel
== NULL
|| EndOpCodeHandle
== NULL
|| EndLabel
== NULL
) {
346 return EFI_INVALID_PARAMETER
;
349 *StartOpCodeHandle
= NULL
;
350 *EndOpCodeHandle
= NULL
;
351 Status
= EFI_OUT_OF_RESOURCES
;
354 // Initialize the container for dynamic opcodes.
356 *StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
357 if (*StartOpCodeHandle
== NULL
) {
361 *EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
362 if (*EndOpCodeHandle
== NULL
) {
367 // Create Hii Extend Label OpCode as the start opcode.
369 InternalStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
373 sizeof (EFI_IFR_GUID_LABEL
)
375 if (InternalStartLabel
== NULL
) {
379 InternalStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
380 InternalStartLabel
->Number
= StartLabelNumber
;
383 // Create Hii Extend Label OpCode as the end opcode.
385 InternalEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
389 sizeof (EFI_IFR_GUID_LABEL
)
391 if (InternalEndLabel
== NULL
) {
395 InternalEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
396 InternalEndLabel
->Number
= LABEL_END
;
398 *StartLabel
= InternalStartLabel
;
399 *EndLabel
= InternalEndLabel
;
405 if (*StartOpCodeHandle
!= NULL
) {
406 HiiFreeOpCodeHandle (*StartOpCodeHandle
);
409 if (*EndOpCodeHandle
!= NULL
) {
410 HiiFreeOpCodeHandle (*EndOpCodeHandle
);
417 This function converts the different format of address list to string format and
418 then generates the corresponding text opcode to illustarate the address info in
419 IP6 configuration page. Currently, the following formats are supported:
420 EFI_IP6_ADDRESS_INFO AddressType: Ip6ConfigNvHostAddress;
421 EFI_IPv6_ADDRESS AddressType: Ip6ConfigNvGatewayAddress and Ip6ConfigNvDnsAddress;
422 EFI_IP6_ROUTE_TABLE AddressType: Ip6ConfigNvRouteTable.
424 @param[in, out] String The pointer to the buffer to store the converted
426 @param[in] HiiHandle A handle that was previously registered in the
428 @param[in] AddressType The address type.
429 @param[in] AddressInfo Pointer to the address list.
430 @param[in] AddressCount The address count of the address list.
432 @retval EFI_SUCCESS The operation finished successfully.
433 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
434 @retval EFI_UNSUPPORTED The AddressType is not supported.
439 Ip6ConvertAddressListToString (
440 IN OUT CHAR16
*String
,
441 IN EFI_HII_HANDLE HiiHandle
,
442 IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType
,
443 IN VOID
*AddressInfo
,
444 IN UINTN AddressCount
451 VOID
*StartOpCodeHandle
;
452 EFI_IFR_GUID_LABEL
*StartLabel
;
453 VOID
*EndOpCodeHandle
;
454 EFI_IFR_GUID_LABEL
*EndLabel
;
455 UINT16 StartLabelNumber
;
456 EFI_STRING_ID TextTwo
;
459 EFI_IPv6_ADDRESS
*Address
;
461 if ((String
== NULL
) || (HiiHandle
== NULL
) || (AddressInfo
== NULL
)) {
462 return EFI_INVALID_PARAMETER
;
465 if (AddressType
== Ip6ConfigNvHostAddress
) {
466 StartLabelNumber
= HOST_ADDRESS_LABEL
;
467 } else if (AddressType
== Ip6ConfigNvGatewayAddress
) {
468 StartLabelNumber
= GATEWAY_ADDRESS_LABEL
;
469 } else if (AddressType
== Ip6ConfigNvDnsAddress
) {
470 StartLabelNumber
= DNS_ADDRESS_LABEL
;
471 } else if (AddressType
== Ip6ConfigNvRouteTable
) {
472 StartLabelNumber
= ROUTE_TABLE_LABEL
;
475 return EFI_UNSUPPORTED
;
478 Status
= Ip6CreateOpCode (
485 if (EFI_ERROR (Status
)) {
489 AddressHead
= (UINT8
*) AddressInfo
;
491 for (Index
= 0; Index
< AddressCount
; Index
++) {
492 if (AddressType
== Ip6ConfigNvHostAddress
) {
493 AddressInfo
= AddressHead
+ sizeof (EFI_IP6_ADDRESS_INFO
) * Index
;
494 Address
= &((EFI_IP6_ADDRESS_INFO
*) AddressInfo
)->Address
;
495 } else if (AddressType
== Ip6ConfigNvRouteTable
) {
496 AddressInfo
= AddressHead
+ sizeof (EFI_IP6_ROUTE_TABLE
) * Index
;
497 Address
= &((EFI_IP6_ROUTE_TABLE
*) AddressInfo
)->Destination
;
499 AddressInfo
= AddressHead
+ sizeof (EFI_IPv6_ADDRESS
) * Index
;
500 Address
= AddressInfo
;
504 // Convert the IP address info to string.
506 Ip6ToStr (Address
, String
);
507 TempStr
= String
+ StrLen (String
);
509 if ((AddressType
== Ip6ConfigNvHostAddress
) || (AddressType
== Ip6ConfigNvRouteTable
)) {
510 if (AddressType
== Ip6ConfigNvHostAddress
) {
511 PrefixLength
= ((EFI_IP6_ADDRESS_INFO
*) AddressInfo
)->PrefixLength
;
513 PrefixLength
= ((EFI_IP6_ROUTE_TABLE
*) AddressInfo
)->PrefixLength
;
517 // Append the prefix length to the string.
521 Number
= UnicodeSPrint (TempStr
, 6, L
"%d", PrefixLength
);
522 TempStr
= TempStr
+ Number
;
525 if (AddressType
== Ip6ConfigNvRouteTable
) {
527 // Append " >> " to the string.
529 Number
= UnicodeSPrint (TempStr
, 8, L
" >> ");
530 TempStr
= TempStr
+ Number
;
533 // Append the gateway address to the string.
535 Ip6ToStr (&((EFI_IP6_ROUTE_TABLE
*) AddressInfo
)->Gateway
, TempStr
);
536 TempStr
= TempStr
+ StrLen (TempStr
);
540 // Generate a text opcode and update the UI.
542 TextTwo
= HiiSetString (HiiHandle
, 0, String
, NULL
);
544 Status
= EFI_INVALID_PARAMETER
;
548 HiiCreateTextOpCode (StartOpCodeHandle
, STR_NULL
, STR_NULL
, TextTwo
);
551 *String
= IP6_ADDRESS_DELIMITER
;
555 *(String
- 1) = '\0';
557 Status
= HiiUpdateForm (
558 HiiHandle
, // HII handle
559 &mIp6ConfigNvDataGuid
, // Formset GUID
560 FORMID_MAIN_FORM
, // Form ID
561 StartOpCodeHandle
, // Label for where to insert opcodes
562 EndOpCodeHandle
// Replace data
566 HiiFreeOpCodeHandle (StartOpCodeHandle
);
567 HiiFreeOpCodeHandle (EndOpCodeHandle
);
573 Parse address list in string format and convert it to a list array of node in
574 IP6_ADDRESS_INFO_ENTRY.
576 @param[in] String The buffer to string to be parsed.
577 @param[out] ListHead The list head of array.
578 @param[out] AddressCount The number of list nodes in the array.
580 @retval EFI_SUCCESS The operation finished successfully.
581 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
582 @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to lack of resource.
586 Ip6ParseAddressListFromString (
587 IN CONST CHAR16
*String
,
588 OUT LIST_ENTRY
*ListHead
,
589 OUT UINT32
*AddressCount
596 EFI_IP6_ADDRESS_INFO AddressInfo
;
597 IP6_ADDRESS_INFO_ENTRY
*Node
;
601 if ((String
== NULL
) || (ListHead
== NULL
) || (AddressCount
== NULL
)) {
602 return EFI_INVALID_PARAMETER
;
605 LocalString
= (CHAR16
*) AllocateCopyPool (StrSize (String
), String
);
606 if (LocalString
== NULL
) {
607 return EFI_OUT_OF_RESOURCES
;
611 // Clean the original address list.
613 Ip6FreeAddressInfoList (ListHead
);
619 while (*LocalString
!= L
'\0') {
620 TempStr
= LocalString
;
621 while ((*LocalString
!= L
'\0') && (*LocalString
!= IP6_ADDRESS_DELIMITER
)) {
625 if (*LocalString
== L
'\0') {
629 *LocalString
= L
'\0';
631 Status
= NetLibStrToIp6andPrefix (TempStr
, &AddressInfo
.Address
, &AddressInfo
.PrefixLength
);
632 if (EFI_ERROR (Status
)) {
636 if (AddressInfo
.PrefixLength
== 0xFF) {
637 AddressInfo
.PrefixLength
= 0;
640 if (!NetIp6IsValidUnicast (&AddressInfo
.Address
)) {
641 Status
= EFI_INVALID_PARAMETER
;
645 Node
= AllocatePool (sizeof (IP6_ADDRESS_INFO_ENTRY
));
647 Status
= EFI_OUT_OF_RESOURCES
;
651 CopyMem (&Node
->AddrInfo
, &AddressInfo
, sizeof (EFI_IP6_ADDRESS_INFO
));
652 InsertTailList (ListHead
, &Node
->Link
);
663 *AddressCount
= Count
;
667 Ip6FreeAddressInfoList (ListHead
);
673 This function converts the interface info to string and draws it to the IP6 UI.
674 The interface information includes interface name, interface type, hardware address,
675 address info, and route table information. The address information is also used as the
676 content of manual addresses in IP6 UI.
678 @param[in] IfInfo The pointer of EFI_IP6_CONFIG_INTERFACE_INFO.
679 @param[in] HiiHandle The handle that was previously registered in the
681 @param[in, out] IfrNvData Points to IP6_CONFIG_IFR_NVDATA.
683 @retval EFI_SUCCESS The operation finished successfully.
684 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
685 @retval EFI_OUT_OF_RESOURCES The operation failed due to lack of resources.
689 Ip6ConvertInterfaceInfoToString (
690 IN EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
,
691 IN EFI_HII_HANDLE HiiHandle
,
692 IN OUT IP6_CONFIG_IFR_NVDATA
*IfrNvData
698 CHAR16
*LinkLocalStr
;
699 CHAR16 PortString
[ADDRESS_STR_MAX_SIZE
];
700 CHAR16 FormatString
[8];
701 EFI_STRING_ID StringId
;
704 if ((IfInfo
== NULL
) || (HiiHandle
== NULL
) || (IfrNvData
== NULL
)) {
705 return EFI_INVALID_PARAMETER
;
709 // Print the interface name.
711 StringId
= HiiSetString (
713 STRING_TOKEN (STR_IP6_INTERFACE_NAME_CONTENT
),
718 return EFI_OUT_OF_RESOURCES
;
722 // Print the interface type.
724 if (IfInfo
->IfType
== Ip6InterfaceTypeEthernet
) {
725 StrCpy (PortString
, IP6_ETHERNET
);
726 } else if (IfInfo
->IfType
== Ip6InterfaceTypeExperimentalEthernet
) {
727 StrCpy (PortString
, IP6_EXPERIMENTAL_ETHERNET
);
730 // Refer to RFC1700, chapter Number Hardware Type.
732 UnicodeSPrint (PortString
, 6, L
"%d", IfInfo
->IfType
);
735 StringId
= HiiSetString (
737 STRING_TOKEN (STR_IP6_INTERFACE_TYPE_CONTENT
),
742 return EFI_OUT_OF_RESOURCES
;
746 // Convert the hardware address.
749 ASSERT (IfInfo
->HwAddressSize
<= 32);
751 for (Index
= 0; Index
< IfInfo
->HwAddressSize
; Index
++) {
753 if (IfInfo
->HwAddress
.Addr
[Index
] < 0x10) {
754 StrCpy (FormatString
, L
"0%x-");
756 StrCpy (FormatString
, L
"%x-");
759 Number
= UnicodeSPrint (
762 (CONST CHAR16
*) FormatString
,
763 (UINTN
) IfInfo
->HwAddress
.Addr
[Index
]
765 String
= String
+ Number
;
769 ASSERT (String
> PortString
);
775 // Print the hardware address.
777 StringId
= HiiSetString (
779 STRING_TOKEN (STR_IP6_MAC_ADDRESS_CONTENT
),
784 return EFI_OUT_OF_RESOURCES
;
788 // Print the host address Information.
790 Status
= Ip6ConvertAddressListToString (
793 Ip6ConfigNvHostAddress
,
795 IfInfo
->AddressInfoCount
797 if (EFI_ERROR (Status
)) {
802 // Copy the Host Address Info to manual address field.
803 // Do not copy the link local address.
805 LinkLocalStr
= StrStr (PortString
, IP6_LINK_LOCAL_PREFIX
);
806 if (LinkLocalStr
!= NULL
) {
807 Number
= LinkLocalStr
- PortString
;
809 CopyMem (IfrNvData
->ManualAddress
, PortString
, Number
* sizeof (CHAR16
));
812 while ((*LinkLocalStr
!= L
' ') && (*LinkLocalStr
!= L
'\0')) {
816 if (*LinkLocalStr
!= L
'\0') {
818 StrCat (IfrNvData
->ManualAddress
, LinkLocalStr
);
821 StrCpy (IfrNvData
->ManualAddress
, PortString
);
825 // Print the route table information.
827 Status
= Ip6ConvertAddressListToString (
830 Ip6ConfigNvRouteTable
,
838 Build the address info list from list array of node in IP6_ADDRESS_INFO_ENTRY.
840 @param[in] Instance Points to IP6 config instance data.
841 @param[in] AddressType The address type.
842 @param[out] AddressInfo The pointer to the buffer to store the address list.
843 @param[out] AddressSize The address size of the address list.
845 @retval EFI_SUCCESS The operation finished successfully.
846 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
847 @retval EFI_UNSUPPORTED The AddressType is not supported.
851 Ip6BuildNvAddressInfo (
852 IN IP6_CONFIG_INSTANCE
*Instance
,
853 IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType
,
854 OUT VOID
**AddressInfo
,
855 OUT UINTN
*AddressSize
858 IP6_CONFIG_NVDATA
*Ip6NvData
;
860 LIST_ENTRY
*ListHead
;
861 IP6_ADDRESS_INFO_ENTRY
*Node
;
865 EFI_IPv6_ADDRESS
*Ip6Address
;
866 EFI_IP6_CONFIG_MANUAL_ADDRESS
*ManualAddress
;
868 if ((Instance
== NULL
) || (AddressInfo
== NULL
) || (AddressSize
== NULL
)) {
869 return EFI_INVALID_PARAMETER
;
872 NET_CHECK_SIGNATURE (Instance
, IP6_CONFIG_INSTANCE_SIGNATURE
);
874 Ip6NvData
= &Instance
->Ip6NvData
;
876 if (AddressType
== Ip6ConfigNvHostAddress
) {
877 ListHead
= &Ip6NvData
->ManualAddress
;
878 DataSize
= sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
) * Ip6NvData
->ManualAddressCount
;
879 } else if (AddressType
== Ip6ConfigNvGatewayAddress
) {
880 ListHead
= &Ip6NvData
->GatewayAddress
;
881 DataSize
= sizeof (EFI_IPv6_ADDRESS
) * Ip6NvData
->GatewayAddressCount
;
882 } else if (AddressType
== Ip6ConfigNvDnsAddress
) {
883 ListHead
= &Ip6NvData
->DnsAddress
;
884 DataSize
= sizeof (EFI_IPv6_ADDRESS
) * Ip6NvData
->DnsAddressCount
;
886 return EFI_UNSUPPORTED
;
889 AddressList
= AllocateZeroPool (DataSize
);
890 if (AddressList
== NULL
) {
891 return EFI_OUT_OF_RESOURCES
;
894 TmpStr
= AddressList
;
896 NET_LIST_FOR_EACH (Entry
, ListHead
) {
897 Node
= NET_LIST_USER_STRUCT (Entry
, IP6_ADDRESS_INFO_ENTRY
, Link
);
898 if (AddressType
== Ip6ConfigNvHostAddress
) {
899 ManualAddress
= (EFI_IP6_CONFIG_MANUAL_ADDRESS
*) AddressList
;
900 IP6_COPY_ADDRESS (&ManualAddress
->Address
, &Node
->AddrInfo
.Address
);
901 ManualAddress
->PrefixLength
= Node
->AddrInfo
.PrefixLength
;
902 AddressList
= (UINT8
*) AddressList
+ sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
);
904 Ip6Address
= (EFI_IPv6_ADDRESS
*) AddressList
;
905 IP6_COPY_ADDRESS (Ip6Address
, &Node
->AddrInfo
.Address
);
906 AddressList
= (UINT8
*) AddressList
+ sizeof (EFI_IPv6_ADDRESS
);
910 *AddressInfo
= TmpStr
;
911 *AddressSize
= DataSize
;
916 Convert the IP6 configuration data into the IFR data.
918 @param[in, out] IfrNvData The IFR NV data.
919 @param[in] Instance The IP6 config instance data.
921 @retval EFI_SUCCESS The operation finished successfully.
922 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
923 @retval EFI_UNSUPPORTED The policy is not supported in the current implementation.
924 @retval Others Other errors as indicated.
928 Ip6ConvertConfigNvDataToIfrNvData (
929 IN OUT IP6_CONFIG_IFR_NVDATA
*IfrNvData
,
930 IN IP6_CONFIG_INSTANCE
*Instance
933 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
937 EFI_IP6_CONFIG_INTERFACE_ID InterfaceId
;
938 EFI_IP6_CONFIG_POLICY Policy
;
939 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits
;
940 EFI_HII_HANDLE HiiHandle
;
942 if ((IfrNvData
== NULL
) || (Instance
== NULL
)) {
943 return EFI_INVALID_PARAMETER
;
946 NET_CHECK_SIGNATURE (Instance
, IP6_CONFIG_INSTANCE_SIGNATURE
);
948 Ip6Config
= &Instance
->Ip6Config
;
951 HiiHandle
= Instance
->CallbackInfo
.RegisteredHandle
;
954 // Get the current interface info.
956 Status
= Ip6ConfigNvGetData (
958 Ip6ConfigDataTypeInterfaceInfo
,
962 if (EFI_ERROR (Status
)) {
967 // Convert the interface info to string and print.
969 Status
= Ip6ConvertInterfaceInfoToString (
970 (EFI_IP6_CONFIG_INTERFACE_INFO
*) Data
,
974 if (EFI_ERROR (Status
)) {
979 // Get the interface id.
981 DataSize
= sizeof (EFI_IP6_CONFIG_INTERFACE_ID
);
982 ZeroMem (&InterfaceId
, DataSize
);
983 Status
= Ip6Config
->GetData (
985 Ip6ConfigDataTypeAltInterfaceId
,
989 if (EFI_ERROR (Status
)) {
993 Ip6ConvertInterfaceIdToString (IfrNvData
->InterfaceId
, &InterfaceId
);
996 // Get current policy.
998 DataSize
= sizeof (EFI_IP6_CONFIG_POLICY
);
999 Status
= Ip6Config
->GetData (
1001 Ip6ConfigDataTypePolicy
,
1006 if (EFI_ERROR (Status
)) {
1010 if (Policy
== Ip6ConfigPolicyManual
) {
1011 IfrNvData
->Policy
= IP6_POLICY_MANUAL
;
1012 } else if (Policy
== Ip6ConfigPolicyAutomatic
) {
1013 IfrNvData
->Policy
= IP6_POLICY_AUTO
;
1016 Status
= EFI_UNSUPPORTED
;
1021 // Get Duplicate Address Detection Transmits count.
1023 DataSize
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
1024 Status
= Ip6Config
->GetData (
1026 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1031 if (EFI_ERROR (Status
)) {
1035 IfrNvData
->DadTransmitCount
= DadXmits
.DupAddrDetectTransmits
;
1038 // Get DNS server list.
1043 Status
= Ip6ConfigNvGetData (
1045 Ip6ConfigDataTypeDnsServer
,
1050 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1056 // Convert the DNS server address to string and draw it to UI.
1058 Status
= Ip6ConvertAddressListToString (
1059 IfrNvData
->DnsAddress
,
1061 Ip6ConfigNvDnsAddress
,
1063 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1065 if (EFI_ERROR (Status
)) {
1074 // Get gateway adderss list.
1077 Status
= Ip6ConfigNvGetData (
1079 Ip6ConfigDataTypeGateway
,
1084 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1090 // Convert the gateway address to string and draw it to UI.
1092 Status
= Ip6ConvertAddressListToString (
1093 IfrNvData
->GatewayAddress
,
1095 Ip6ConfigNvGatewayAddress
,
1097 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1099 if (EFI_ERROR (Status
)) {
1104 Status
= EFI_SUCCESS
;
1115 Convert IFR data into IP6 configuration data. The policy, alternative interface
1116 ID, and DAD transmit counts, and will be saved. If under manual policy, the configured
1117 manual address, gateway address, and DNS server address will be saved.
1119 @param[in] IfrNvData The IFR NV data.
1120 @param[in, out] Instance The IP6 config instance data.
1122 @retval EFI_SUCCESS The operation finished successfully.
1123 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
1124 @retval Others Other errors as indicated.
1128 Ip6ConvertIfrNvDataToConfigNvData (
1129 IN IP6_CONFIG_IFR_NVDATA
*IfrNvData
,
1130 IN OUT IP6_CONFIG_INSTANCE
*Instance
1133 IP6_CONFIG_NVDATA
*Ip6NvData
;
1134 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
1136 EFI_IP6_CONFIG_MANUAL_ADDRESS
*ManualAddress
;
1137 EFI_IPv6_ADDRESS
*Address
;
1138 BOOLEAN IsAddressOk
;
1139 EFI_EVENT SetAddressEvent
;
1140 EFI_EVENT TimeoutEvent
;
1143 if ((IfrNvData
== NULL
) || (Instance
== NULL
)) {
1144 return EFI_INVALID_PARAMETER
;
1147 NET_CHECK_SIGNATURE (Instance
, IP6_CONFIG_INSTANCE_SIGNATURE
);
1148 Ip6NvData
= &Instance
->Ip6NvData
;
1149 Ip6Config
= &Instance
->Ip6Config
;
1152 // Update those fields which don't have INTERACTIVE attribute.
1154 if (IfrNvData
->Policy
== IP6_POLICY_AUTO
) {
1155 Ip6NvData
->Policy
= Ip6ConfigPolicyAutomatic
;
1156 } else if (IfrNvData
->Policy
== IP6_POLICY_MANUAL
) {
1157 Ip6NvData
->Policy
= Ip6ConfigPolicyManual
;
1160 Ip6NvData
->DadTransmitCount
.DupAddrDetectTransmits
= IfrNvData
->DadTransmitCount
;
1163 // Set the configured policy.
1165 Status
= Ip6Config
->SetData (
1167 Ip6ConfigDataTypePolicy
,
1168 sizeof (EFI_IP6_CONFIG_POLICY
),
1171 if (EFI_ERROR (Status
)) {
1176 // Set the duplicate address detection transmits count.
1178 Status
= Ip6Config
->SetData (
1180 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1181 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
),
1182 &Ip6NvData
->DadTransmitCount
1184 if (EFI_ERROR (Status
)) {
1189 // Set the alternative interface ID
1191 Status
= Ip6Config
->SetData (
1193 Ip6ConfigDataTypeAltInterfaceId
,
1194 sizeof (EFI_IP6_CONFIG_INTERFACE_ID
),
1195 &Ip6NvData
->InterfaceId
1197 if (EFI_ERROR (Status
)) {
1202 if (Ip6NvData
->Policy
== Ip6ConfigPolicyAutomatic
) {
1207 // Create events & timers for asynchronous settings.
1209 SetAddressEvent
= NULL
;
1210 TimeoutEvent
= NULL
;
1211 ManualAddress
= NULL
;
1214 Status
= gBS
->CreateEvent (
1217 Ip6ConfigManualAddressNotify
,
1221 if (EFI_ERROR (Status
)) {
1225 Status
= gBS
->CreateEvent (
1232 if (EFI_ERROR (Status
)) {
1237 // Set the manual address list. This is an asynchronous process.
1239 if (!IsListEmpty (&Ip6NvData
->ManualAddress
) && (Ip6NvData
->ManualAddressCount
!= 0)) {
1240 Status
= Ip6BuildNvAddressInfo (
1242 Ip6ConfigNvHostAddress
,
1243 (VOID
**) &ManualAddress
,
1246 if (EFI_ERROR (Status
)) {
1250 IsAddressOk
= FALSE
;
1252 Status
= Ip6Config
->RegisterDataNotify (
1254 Ip6ConfigDataTypeManualAddress
,
1257 if (EFI_ERROR (Status
)) {
1261 Status
= Ip6Config
->SetData (
1263 Ip6ConfigDataTypeManualAddress
,
1265 (VOID
*) ManualAddress
1267 if (Status
== EFI_NOT_READY
) {
1268 gBS
->SetTimer (TimeoutEvent
, TimerRelative
, 50000000);
1269 while (EFI_ERROR (gBS
->CheckEvent (TimeoutEvent
))) {
1271 Status
= EFI_SUCCESS
;
1277 Status
= Ip6Config
->UnregisterDataNotify (
1279 Ip6ConfigDataTypeManualAddress
,
1282 if (EFI_ERROR (Status
)) {
1288 // Set gateway address list.
1290 if (!IsListEmpty (&Ip6NvData
->GatewayAddress
) && (Ip6NvData
->GatewayAddressCount
!= 0)) {
1291 Status
= Ip6BuildNvAddressInfo (
1293 Ip6ConfigNvGatewayAddress
,
1297 if (EFI_ERROR (Status
)) {
1301 Status
= Ip6Config
->SetData (
1303 Ip6ConfigDataTypeGateway
,
1307 if (EFI_ERROR (Status
)) {
1316 // Set DNS server address list.
1318 if (!IsListEmpty (&Ip6NvData
->DnsAddress
) && (Ip6NvData
->DnsAddressCount
!= 0)) {
1319 Status
= Ip6BuildNvAddressInfo (
1321 Ip6ConfigNvDnsAddress
,
1325 if (EFI_ERROR (Status
)) {
1329 Status
= Ip6Config
->SetData (
1331 Ip6ConfigDataTypeDnsServer
,
1335 if (EFI_ERROR (Status
)) {
1340 Status
= EFI_SUCCESS
;
1343 if (SetAddressEvent
!= NULL
) {
1344 gBS
->CloseEvent (SetAddressEvent
);
1347 if (TimeoutEvent
!= NULL
) {
1348 gBS
->CloseEvent (TimeoutEvent
);
1351 if (ManualAddress
!= NULL
) {
1352 FreePool (ManualAddress
);
1355 if (Address
!= NULL
) {
1363 This function allows the caller to request the current
1364 configuration for one or more named elements. The resulting
1365 string is in <ConfigAltResp> format. Any and all alternative
1366 configuration strings shall also be appended to the end of the
1367 current configuration string. If they are, they must appear
1368 after the current configuration. They must contain the same
1369 routing (GUID, NAME, PATH) as the current configuration string.
1370 They must have an additional description indicating the type of
1371 alternative configuration the string represents,
1372 "ALTCFG=<StringToken>". That <StringToken> (when
1373 converted from Hex UNICODE to binary) is a reference to a
1374 string in the associated string pack.
1376 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1377 @param[in] Request A null-terminated Unicode string in
1378 <ConfigRequest> format. Note that this
1379 includes the routing information as well as
1380 the configurable name / value pairs. It is
1381 invalid for this string to be in
1382 <MultiConfigRequest> format.
1383 @param[out] Progress On return, points to a character in the
1384 Request string. Points to the string's null
1385 terminator if request was successful. Points
1386 to the most recent "&" before the first
1387 failing name / value pair (or the beginning
1388 of the string if the failure is in the first
1389 name / value pair) if the request was not
1391 @param[out] Results A null-terminated Unicode string in
1392 <ConfigAltResp> format which has all values
1393 filled in for the names in the Request string.
1394 String to be allocated by the called function.
1396 @retval EFI_SUCCESS The Results string is filled with the
1397 values corresponding to all requested
1399 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1400 parts of the results that must be
1401 stored awaiting possible future
1403 @retval EFI_INVALID_PARAMETER For example, passing in a NULL
1404 for the Request parameter
1405 would result in this type of
1406 error. In this case, the
1407 Progress parameter would be
1409 @retval EFI_NOT_FOUND Routing data doesn't match any
1410 known driver. Progress set to the
1411 first character in the routing header.
1412 Note: There is no requirement that the
1413 driver validate the routing data. It
1414 must skip the <ConfigHdr> in order to
1416 @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set
1417 to most recent & before the
1418 error or the beginning of the
1420 @retval EFI_INVALID_PARAMETER Unknown name. Progress points
1421 to the & before the name in
1422 question. Currently not implemented.
1426 Ip6FormExtractConfig (
1427 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1428 IN CONST EFI_STRING Request
,
1429 OUT EFI_STRING
*Progress
,
1430 OUT EFI_STRING
*Results
1435 IP6_FORM_CALLBACK_INFO
*Private
;
1436 IP6_CONFIG_INSTANCE
*Ip6ConfigInstance
;
1437 IP6_CONFIG_IFR_NVDATA
*IfrNvData
;
1438 EFI_STRING ConfigRequestHdr
;
1439 EFI_STRING ConfigRequest
;
1440 BOOLEAN AllocatedRequest
;
1444 if (This
== NULL
|| Progress
== NULL
|| Results
== NULL
) {
1445 return EFI_INVALID_PARAMETER
;
1448 *Progress
= Request
;
1449 if ((Request
!= NULL
) &&
1450 !HiiIsConfigHdrMatch (Request
, &mIp6ConfigNvDataGuid
, mIp6ConfigStorageName
)) {
1451 return EFI_NOT_FOUND
;
1454 ConfigRequestHdr
= NULL
;
1455 ConfigRequest
= NULL
;
1456 AllocatedRequest
= FALSE
;
1459 Private
= IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This
);
1460 Ip6ConfigInstance
= IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private
);
1461 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1463 IfrNvData
= (IP6_CONFIG_IFR_NVDATA
*) AllocateZeroPool (BufferSize
);
1464 if (IfrNvData
== NULL
) {
1465 return EFI_OUT_OF_RESOURCES
;
1468 Status
= Ip6ConvertConfigNvDataToIfrNvData (IfrNvData
, Ip6ConfigInstance
);
1469 if (EFI_ERROR (Status
)) {
1473 ConfigRequest
= Request
;
1474 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
1476 // Request has no request element, construct full request string.
1477 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
1478 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator.
1480 ConfigRequestHdr
= HiiConstructConfigHdr (
1481 &mIp6ConfigNvDataGuid
,
1482 mIp6ConfigStorageName
,
1483 Private
->ChildHandle
1485 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
1486 ConfigRequest
= AllocateZeroPool (Size
);
1487 ASSERT (ConfigRequest
!= NULL
);
1488 AllocatedRequest
= TRUE
;
1492 L
"%s&OFFSET=0&WIDTH=%016LX",
1496 FreePool (ConfigRequestHdr
);
1500 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
1502 Status
= gHiiConfigRouting
->BlockToConfig (
1505 (UINT8
*) IfrNvData
,
1512 FreePool (IfrNvData
);
1514 // Free the allocated config request string.
1516 if (AllocatedRequest
) {
1517 FreePool (ConfigRequest
);
1518 ConfigRequest
= NULL
;
1521 // Set Progress string to the original request string.
1523 if (Request
== NULL
) {
1525 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
1526 *Progress
= Request
+ StrLen (Request
);
1533 This function applies changes in a driver's configuration.
1534 Input is a Configuration, which has the routing data for this
1535 driver followed by name / value configuration pairs. The driver
1536 must apply those pairs to its configurable storage. If the
1537 driver's configuration is stored in a linear block of data
1538 and the driver's name / value pairs are in <BlockConfig>
1539 format, it may use the ConfigToBlock helper function (above) to
1540 simplify the job. Currently not implemented.
1542 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1543 @param[in] Configuration A null-terminated Unicode string in
1544 <ConfigString> format.
1545 @param[out] Progress A pointer to a string filled in with the
1546 offset of the most recent '&' before the
1547 first failing name / value pair (or the
1548 beginn ing of the string if the failure
1549 is in the first name / value pair) or
1550 the terminating NULL if all was
1553 @retval EFI_SUCCESS The results have been distributed or are
1554 awaiting distribution.
1555 @retval EFI_OUT_OF_MEMORY Not enough memory to store the
1556 parts of the results that must be
1557 stored awaiting possible future
1559 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1560 Results parameter would result
1561 in this type of error.
1562 @retval EFI_NOT_FOUND Target for the specified routing data
1567 Ip6FormRouteConfig (
1568 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1569 IN CONST EFI_STRING Configuration
,
1570 OUT EFI_STRING
*Progress
1573 if (This
== NULL
|| Configuration
== NULL
|| Progress
== NULL
) {
1574 return EFI_INVALID_PARAMETER
;
1578 // Check routing data in <ConfigHdr>.
1579 // Note: if only one Storage is used, then this checking could be skipped.
1581 if (!HiiIsConfigHdrMatch (Configuration
, &mIp6ConfigNvDataGuid
, mIp6ConfigStorageName
)) {
1582 *Progress
= Configuration
;
1583 return EFI_NOT_FOUND
;
1586 *Progress
= Configuration
+ StrLen (Configuration
);
1592 This function is called to provide results data to the driver.
1593 This data consists of a unique key that is used to identify
1594 which data is either being passed back or being asked for.
1596 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1597 @param[in] Action Specifies the type of action taken by the browser.
1598 @param[in] QuestionId A unique value which is sent to the original
1599 exporting driver so that it can identify the type
1600 of data to expect. The format of the data tends to
1601 vary based on the opcode that generated the callback.
1602 @param[in] Type The type of value for the question.
1603 @param[in] Value A pointer to the data being sent to the original
1605 @param[out] ActionRequest On return, points to the action requested by the
1608 @retval EFI_SUCCESS The callback successfully handled the action.
1609 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
1610 variable and its data.
1611 @retval EFI_DEVICE_ERROR The variable could not be saved.
1612 @retval EFI_UNSUPPORTED The specified Action is not supported by the
1613 callback. Currently not implemented.
1614 @retval EFI_INVALID_PARAMETER Passed in the wrong parameter.
1615 @retval Others Other errors as indicated.
1621 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1622 IN EFI_BROWSER_ACTION Action
,
1623 IN EFI_QUESTION_ID QuestionId
,
1625 IN EFI_IFR_TYPE_VALUE
*Value
,
1626 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1629 IP6_FORM_CALLBACK_INFO
*Private
;
1631 IP6_CONFIG_IFR_NVDATA
*IfrNvData
;
1632 IP6_CONFIG_IFR_NVDATA OldIfrNvData
;
1635 IP6_CONFIG_INSTANCE
*Instance
;
1636 IP6_CONFIG_NVDATA
*Ip6NvData
;
1637 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
1638 EFI_IP6_CONFIG_INTERFACE_INFO
*Data
;
1640 CHAR16 PortString
[ADDRESS_STR_MAX_SIZE
];
1641 EFI_HII_HANDLE HiiHandle
;
1642 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
1645 return EFI_INVALID_PARAMETER
;
1648 Private
= IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This
);
1649 Instance
= IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private
);
1650 Ip6NvData
= &Instance
->Ip6NvData
;
1652 if (Action
== EFI_BROWSER_ACTION_FORM_OPEN
) {
1654 // Update main Form when main Form is opened.
1655 // This will be done only in FORM_OPEN CallBack of question with KEY_INTERFACE_ID from main Form.
1657 if (QuestionId
!= KEY_INTERFACE_ID
) {
1661 Ip6Config
= &Instance
->Ip6Config
;
1662 HiiHandle
= Instance
->CallbackInfo
.RegisteredHandle
;
1665 // Get the current interface info.
1667 Status
= Ip6ConfigNvGetData (
1669 Ip6ConfigDataTypeInterfaceInfo
,
1673 if (EFI_ERROR (Status
)) {
1678 // Generate the dynamic text opcode for host address and draw it.
1680 IfInfo
= (EFI_IP6_CONFIG_INTERFACE_INFO
*) Data
;
1681 Status
= Ip6ConvertAddressListToString (
1684 Ip6ConfigNvHostAddress
,
1685 IfInfo
->AddressInfo
,
1686 IfInfo
->AddressInfoCount
1688 if (EFI_ERROR (Status
)) {
1693 // Generate the dynamic text opcode for route table and draw it.
1695 Status
= Ip6ConvertAddressListToString (
1698 Ip6ConfigNvRouteTable
,
1702 if (EFI_ERROR (Status
)) {
1707 // Get DNS server list.
1710 Status
= Ip6ConfigNvGetData (
1712 Ip6ConfigDataTypeDnsServer
,
1716 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1722 // Generate the dynamic text opcode for DNS server and draw it.
1724 Status
= Ip6ConvertAddressListToString (
1727 Ip6ConfigNvDnsAddress
,
1729 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1731 if (EFI_ERROR (Status
)) {
1737 // Get gateway adderss list.
1740 Status
= Ip6ConfigNvGetData (
1742 Ip6ConfigDataTypeGateway
,
1746 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1752 // Generate the dynamic text opcode for gateway and draw it.
1754 Status
= Ip6ConvertAddressListToString (
1757 Ip6ConfigNvGatewayAddress
,
1759 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1761 if (EFI_ERROR (Status
)) {
1771 if (Action
== EFI_BROWSER_ACTION_FORM_CLOSE
) {
1773 // Do nothing for UEFI FORM_CLOSE action
1778 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
1779 return EFI_INVALID_PARAMETER
;
1783 // Retrieve uncommitted data from Browser
1786 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1787 IfrNvData
= AllocateZeroPool (BufferSize
);
1788 if (IfrNvData
== NULL
) {
1789 return EFI_OUT_OF_RESOURCES
;
1792 Status
= EFI_SUCCESS
;
1794 ZeroMem (&OldIfrNvData
, BufferSize
);
1796 HiiGetBrowserData (NULL
, NULL
, BufferSize
, (UINT8
*) IfrNvData
);
1798 CopyMem (&OldIfrNvData
, IfrNvData
, BufferSize
);
1800 switch (QuestionId
) {
1801 case KEY_INTERFACE_ID
:
1802 Status
= Ip6ParseInterfaceIdFromString (IfrNvData
->InterfaceId
, &Ip6NvData
->InterfaceId
);
1803 if (EFI_ERROR (Status
)) {
1805 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1807 L
"Invalid Interface ID!",
1814 case KEY_MANUAL_ADDRESS
:
1815 Status
= Ip6ParseAddressListFromString (
1816 IfrNvData
->ManualAddress
,
1817 &Ip6NvData
->ManualAddress
,
1818 &Ip6NvData
->ManualAddressCount
1820 if (EFI_ERROR (Status
)) {
1822 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1824 L
"Invalid Host Addresses!",
1831 case KEY_GATEWAY_ADDRESS
:
1832 Status
= Ip6ParseAddressListFromString (
1833 IfrNvData
->GatewayAddress
,
1834 &Ip6NvData
->GatewayAddress
,
1835 &Ip6NvData
->GatewayAddressCount
1837 if (EFI_ERROR (Status
)) {
1839 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1841 L
"Invalid Gateway Addresses!",
1848 case KEY_DNS_ADDRESS
:
1849 Status
= Ip6ParseAddressListFromString (
1850 IfrNvData
->DnsAddress
,
1851 &Ip6NvData
->DnsAddress
,
1852 &Ip6NvData
->DnsAddressCount
1854 if (EFI_ERROR (Status
)) {
1856 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1858 L
"Invalid DNS Addresses!",
1865 case KEY_SAVE_CONFIG_CHANGES
:
1866 CopyMem (&OldIfrNvData
, IfrNvData
, sizeof (IP6_CONFIG_IFR_NVDATA
));
1867 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
1870 case KEY_IGNORE_CONFIG_CHANGES
:
1871 CopyMem (IfrNvData
, &OldIfrNvData
, sizeof (IP6_CONFIG_IFR_NVDATA
));
1872 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
1875 case KEY_SAVE_CHANGES
:
1876 Status
= Ip6ConvertIfrNvDataToConfigNvData (IfrNvData
, Instance
);
1877 if (EFI_ERROR (Status
)) {
1881 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
1888 if (!EFI_ERROR (Status
)) {
1890 // Pass changed uncommitted data back to Form Browser.
1892 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1893 HiiSetBrowserData (NULL
, NULL
, BufferSize
, (UINT8
*) IfrNvData
, NULL
);
1896 FreePool (IfrNvData
);
1901 Install HII Config Access protocol for network device and allocate resources.
1903 @param[in, out] Instance The IP6_CONFIG_INSTANCE to create a form.
1905 @retval EFI_SUCCESS The HII Config Access protocol is installed.
1906 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
1907 @retval Others Other errors as indicated.
1912 IN OUT IP6_CONFIG_INSTANCE
*Instance
1917 IP6_FORM_CALLBACK_INFO
*CallbackInfo
;
1918 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
1919 VENDOR_DEVICE_PATH VendorDeviceNode
;
1920 EFI_SERVICE_BINDING_PROTOCOL
*MnpSb
;
1922 CHAR16 MenuString
[128];
1923 CHAR16 PortString
[128];
1924 CHAR16
*OldMenuString
;
1925 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
1927 IpSb
= IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance
);
1928 ASSERT (IpSb
!= NULL
);
1930 Status
= gBS
->HandleProtocol (
1932 &gEfiDevicePathProtocolGuid
,
1933 (VOID
**) &ParentDevicePath
1935 if (EFI_ERROR (Status
)) {
1939 CallbackInfo
= &Instance
->CallbackInfo
;
1940 CallbackInfo
->Signature
= IP6_FORM_CALLBACK_INFO_SIGNATURE
;
1943 // Construct device path node for EFI HII Config Access protocol,
1944 // which consists of controller physical device path and one hardware
1945 // vendor guid node.
1947 ZeroMem (&VendorDeviceNode
, sizeof (VENDOR_DEVICE_PATH
));
1948 VendorDeviceNode
.Header
.Type
= HARDWARE_DEVICE_PATH
;
1949 VendorDeviceNode
.Header
.SubType
= HW_VENDOR_DP
;
1951 CopyGuid (&VendorDeviceNode
.Guid
, &mIp6HiiVendorDevicePathGuid
);
1953 SetDevicePathNodeLength (&VendorDeviceNode
.Header
, sizeof (VENDOR_DEVICE_PATH
));
1954 CallbackInfo
->HiiVendorDevicePath
= AppendDevicePathNode (
1956 (EFI_DEVICE_PATH_PROTOCOL
*) &VendorDeviceNode
1958 if (CallbackInfo
->HiiVendorDevicePath
== NULL
) {
1959 Status
= EFI_OUT_OF_RESOURCES
;
1963 ConfigAccess
= &CallbackInfo
->HiiConfigAccess
;
1964 ConfigAccess
->ExtractConfig
= Ip6FormExtractConfig
;
1965 ConfigAccess
->RouteConfig
= Ip6FormRouteConfig
;
1966 ConfigAccess
->Callback
= Ip6FormCallback
;
1969 // Install Device Path Protocol and Config Access protocol on new handle
1971 Status
= gBS
->InstallMultipleProtocolInterfaces (
1972 &CallbackInfo
->ChildHandle
,
1973 &gEfiDevicePathProtocolGuid
,
1974 CallbackInfo
->HiiVendorDevicePath
,
1975 &gEfiHiiConfigAccessProtocolGuid
,
1979 if (!EFI_ERROR (Status
)) {
1981 // Open the Parent Handle for the child
1983 Status
= gBS
->OpenProtocol (
1985 &gEfiManagedNetworkServiceBindingProtocolGuid
,
1988 CallbackInfo
->ChildHandle
,
1989 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1993 if (EFI_ERROR (Status
)) {
1998 // Publish our HII data
2000 CallbackInfo
->RegisteredHandle
= HiiAddPackages (
2001 &mIp6ConfigNvDataGuid
,
2002 CallbackInfo
->ChildHandle
,
2007 if (CallbackInfo
->RegisteredHandle
== NULL
) {
2008 Status
= EFI_OUT_OF_RESOURCES
;
2013 // Append MAC string in the menu help string and tile help string
2015 Status
= NetLibGetMacString (IpSb
->Controller
, IpSb
->Image
, &MacString
);
2016 if (!EFI_ERROR (Status
)) {
2017 OldMenuString
= HiiGetString (
2018 CallbackInfo
->RegisteredHandle
,
2019 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP
),
2022 UnicodeSPrint (MenuString
, 128, L
"%s (MAC:%s)", OldMenuString
, MacString
);
2024 CallbackInfo
->RegisteredHandle
,
2025 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP
),
2029 UnicodeSPrint (PortString
, 128, L
"MAC:%s", MacString
);
2031 CallbackInfo
->RegisteredHandle
,
2032 STRING_TOKEN (STR_IP6_DEVICE_FORM_HELP
),
2037 FreePool (MacString
);
2038 FreePool (OldMenuString
);
2040 InitializeListHead (&Instance
->Ip6NvData
.ManualAddress
);
2041 InitializeListHead (&Instance
->Ip6NvData
.GatewayAddress
);
2042 InitializeListHead (&Instance
->Ip6NvData
.DnsAddress
);
2048 Ip6ConfigFormUnload (Instance
);
2053 Uninstall the HII Config Access protocol for network devices and free up the resources.
2055 @param[in, out] Instance The IP6_CONFIG_INSTANCE to unload a form.
2059 Ip6ConfigFormUnload (
2060 IN OUT IP6_CONFIG_INSTANCE
*Instance
2064 IP6_FORM_CALLBACK_INFO
*CallbackInfo
;
2065 IP6_CONFIG_NVDATA
*Ip6NvData
;
2067 IpSb
= IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance
);
2068 ASSERT (IpSb
!= NULL
);
2070 CallbackInfo
= &Instance
->CallbackInfo
;
2072 if (CallbackInfo
->ChildHandle
!= NULL
) {
2075 // Close the child handle
2077 gBS
->CloseProtocol (
2079 &gEfiManagedNetworkServiceBindingProtocolGuid
,
2081 CallbackInfo
->ChildHandle
2084 // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
2086 gBS
->UninstallMultipleProtocolInterfaces (
2087 CallbackInfo
->ChildHandle
,
2088 &gEfiDevicePathProtocolGuid
,
2089 CallbackInfo
->HiiVendorDevicePath
,
2090 &gEfiHiiConfigAccessProtocolGuid
,
2091 &CallbackInfo
->HiiConfigAccess
,
2096 if (CallbackInfo
->HiiVendorDevicePath
!= NULL
) {
2097 FreePool (CallbackInfo
->HiiVendorDevicePath
);
2100 if (CallbackInfo
->RegisteredHandle
!= NULL
) {
2102 // Remove HII package list
2104 HiiRemovePackages (CallbackInfo
->RegisteredHandle
);
2107 Ip6NvData
= &Instance
->Ip6NvData
;
2109 Ip6FreeAddressInfoList (&Ip6NvData
->ManualAddress
);
2110 Ip6FreeAddressInfoList (&Ip6NvData
->GatewayAddress
);
2111 Ip6FreeAddressInfoList (&Ip6NvData
->DnsAddress
);
2113 Ip6NvData
->ManualAddressCount
= 0;
2114 Ip6NvData
->GatewayAddressCount
= 0;
2115 Ip6NvData
->DnsAddressCount
= 0;