2 Helper functions for configuring or obtaining the parameters relating to IP6.
4 Copyright (c) 2010 - 2012, 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 CHAR16 mIp6ConfigStorageName
[] = L
"IP6_CONFIG_IFR_NVDATA";
21 The notify function of create event when performing a manual configuration.
23 @param[in] Event The pointer of Event.
24 @param[in] Context The pointer of Context.
29 Ip6ConfigManualAddressNotify (
34 *((BOOLEAN
*) Context
) = TRUE
;
38 Get the configuration data for the EFI IPv6 network stack running on the
39 communication. It is a help function to the call EfiIp6ConfigGetData().
41 @param[in] Ip6Config The pointer to the EFI_IP6_CONFIG_PROTOCOL instance.
42 @param[in] DataType The type of data to get.
43 @param[out] DataSize The size of buffer required in bytes.
44 @param[out] Data The data buffer in which the configuration data is returned. The
45 type of the data buffer associated with the DataType.
46 It is the caller's responsibility to free the resource.
48 @retval EFI_SUCCESS The specified configuration data was obtained successfully.
49 @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE:
50 - Ip6Config is NULL or invalid.
53 @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resources.
54 @retval EFI_NOT_READY The specified configuration data is not ready due to an
55 asynchronous configuration process already in progress.
56 @retval EFI_NOT_FOUND The specified configuration data was not found.
61 IN EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
,
62 IN EFI_IP6_CONFIG_DATA_TYPE DataType
,
71 if ((Ip6Config
== NULL
) || (Data
== NULL
) || (DataSize
== NULL
)) {
72 return EFI_INVALID_PARAMETER
;
76 Status
= Ip6Config
->GetData (
82 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
86 Buffer
= AllocateZeroPool (BufferSize
);
88 return EFI_OUT_OF_RESOURCES
;
91 Status
= Ip6Config
->GetData (
97 if (EFI_ERROR (Status
)) {
102 *DataSize
= BufferSize
;
109 Free all nodes in IP6_ADDRESS_INFO_ENTRY in the list array specified
112 @param[in] ListHead The head of the list array in IP6_ADDRESS_INFO_ENTRY.
116 Ip6FreeAddressInfoList (
117 IN LIST_ENTRY
*ListHead
120 IP6_ADDRESS_INFO_ENTRY
*Node
;
122 LIST_ENTRY
*NextEntry
;
124 NET_LIST_FOR_EACH_SAFE (Entry
, NextEntry
, ListHead
) {
125 Node
= NET_LIST_USER_STRUCT (Entry
, IP6_ADDRESS_INFO_ENTRY
, Link
);
126 RemoveEntryList (&Node
->Link
);
132 Convert the IPv6 address into a formatted string.
134 @param[in] Ip6 The IPv6 address.
135 @param[out] Str The formatted IP string.
140 IN EFI_IPv6_ADDRESS
*Ip6
,
147 CHAR16 FormatString
[8];
151 for (Index
= 0; Index
< 15; Index
= Index
+ 2) {
154 Ip6
->Addr
[Index
] == 0 &&
155 Ip6
->Addr
[Index
+ 1] == 0
158 // Deal with the case of ::.
169 while ((Index
< 15) && (Ip6
->Addr
[Index
] == 0) && (Ip6
->Addr
[Index
+ 1] == 0)) {
177 // :: is at the end of the address.
186 if (Ip6
->Addr
[Index
] == 0) {
187 Number
= UnicodeSPrint (Str
, 2 * IP6_STR_MAX_SIZE
, L
"%x:", (UINTN
) Ip6
->Addr
[Index
+ 1]);
189 if (Ip6
->Addr
[Index
+ 1] < 0x10) {
190 CopyMem (FormatString
, L
"%x0%x:", StrSize (L
"%x0%x:"));
192 CopyMem (FormatString
, L
"%x%x:", StrSize (L
"%x%x:"));
195 Number
= UnicodeSPrint (
197 2 * IP6_STR_MAX_SIZE
,
198 (CONST CHAR16
*) FormatString
,
199 (UINTN
) Ip6
->Addr
[Index
],
200 (UINTN
) Ip6
->Addr
[Index
+ 1]
206 if (Index
+ 2 == 16) {
208 if (*(Str
- 1) == L
':') {
216 Convert EFI_IP6_CONFIG_INTERFACE_ID to string format.
218 @param[out] String The buffer to store the converted string.
219 @param[in] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
221 @retval EFI_SUCCESS The string converted successfully.
222 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
226 Ip6ConvertInterfaceIdToString (
228 IN EFI_IP6_CONFIG_INTERFACE_ID
*IfId
234 if ((String
== NULL
) || (IfId
== NULL
)) {
235 return EFI_INVALID_PARAMETER
;
238 for (Index
= 0; Index
< 8; Index
++) {
239 Number
= UnicodeSPrint (
241 2 * INTERFACE_ID_STR_STORAGE
,
243 (UINTN
) IfId
->Id
[Index
]
245 String
= String
+ Number
;
248 *(String
- 1) = '\0';
254 Parse InterfaceId in string format and convert it to EFI_IP6_CONFIG_INTERFACE_ID.
256 @param[in] String The buffer of the string to be parsed.
257 @param[out] IfId The pointer of EFI_IP6_CONFIG_INTERFACE_ID.
259 @retval EFI_SUCCESS The operation finished successfully.
260 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
264 Ip6ParseInterfaceIdFromString (
265 IN CONST CHAR16
*String
,
266 OUT EFI_IP6_CONFIG_INTERFACE_ID
*IfId
274 if ((String
== NULL
) || (IfId
== NULL
)) {
275 return EFI_INVALID_PARAMETER
;
278 IfIdStr
= (CHAR16
*) String
;
280 ZeroMem (IfId
, sizeof (EFI_IP6_CONFIG_INTERFACE_ID
));
282 for (Index
= 0; Index
< 8; Index
++) {
285 while ((*IfIdStr
!= L
'\0') && (*IfIdStr
!= L
':')) {
290 // The InterfaceId format is X:X:X:X, the number of X should not exceed 8.
291 // If the number of X is less than 8, zero is appended to the InterfaceId.
293 if ((*IfIdStr
== ':') && (Index
== 7)) {
294 return EFI_INVALID_PARAMETER
;
298 // Convert the string to interface id. AsciiStrHexToUintn stops at the
299 // first character that is not a valid hex character, ':' or '\0' here.
301 NodeVal
= StrHexToUintn (TempStr
);
302 if (NodeVal
> 0xFF) {
303 return EFI_INVALID_PARAMETER
;
306 IfId
->Id
[Index
] = (UINT8
) NodeVal
;
315 Create Hii Extend Label OpCode as the start opcode and end opcode. It is
318 @param[in] StartLabelNumber The number of start label.
319 @param[out] StartOpCodeHandle Points to the start opcode handle.
320 @param[out] StartLabel Points to the created start opcode.
321 @param[out] EndOpCodeHandle Points to the end opcode handle.
322 @param[out] EndLabel Points to the created end opcode.
324 @retval EFI_OUT_OF_RESOURCES Does not have sufficient resources to finish this
326 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
327 @retval EFI_SUCCESS The operation completed successfully.
332 IN UINT16 StartLabelNumber
,
333 OUT VOID
**StartOpCodeHandle
,
334 OUT EFI_IFR_GUID_LABEL
**StartLabel
,
335 OUT VOID
**EndOpCodeHandle
,
336 OUT EFI_IFR_GUID_LABEL
**EndLabel
340 EFI_IFR_GUID_LABEL
*InternalStartLabel
;
341 EFI_IFR_GUID_LABEL
*InternalEndLabel
;
343 if (StartOpCodeHandle
== NULL
|| StartLabel
== NULL
|| EndOpCodeHandle
== NULL
|| EndLabel
== NULL
) {
344 return EFI_INVALID_PARAMETER
;
347 *StartOpCodeHandle
= NULL
;
348 *EndOpCodeHandle
= NULL
;
349 Status
= EFI_OUT_OF_RESOURCES
;
352 // Initialize the container for dynamic opcodes.
354 *StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
355 if (*StartOpCodeHandle
== NULL
) {
359 *EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
360 if (*EndOpCodeHandle
== NULL
) {
365 // Create Hii Extend Label OpCode as the start opcode.
367 InternalStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
371 sizeof (EFI_IFR_GUID_LABEL
)
373 if (InternalStartLabel
== NULL
) {
377 InternalStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
378 InternalStartLabel
->Number
= StartLabelNumber
;
381 // Create Hii Extend Label OpCode as the end opcode.
383 InternalEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
387 sizeof (EFI_IFR_GUID_LABEL
)
389 if (InternalEndLabel
== NULL
) {
393 InternalEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
394 InternalEndLabel
->Number
= LABEL_END
;
396 *StartLabel
= InternalStartLabel
;
397 *EndLabel
= InternalEndLabel
;
403 if (*StartOpCodeHandle
!= NULL
) {
404 HiiFreeOpCodeHandle (*StartOpCodeHandle
);
407 if (*EndOpCodeHandle
!= NULL
) {
408 HiiFreeOpCodeHandle (*EndOpCodeHandle
);
415 This function converts the different format of address list to string format and
416 then generates the corresponding text opcode to illustarate the address info in
417 IP6 configuration page. Currently, the following formats are supported:
418 EFI_IP6_ADDRESS_INFO AddressType: Ip6ConfigNvHostAddress;
419 EFI_IPv6_ADDRESS AddressType: Ip6ConfigNvGatewayAddress and Ip6ConfigNvDnsAddress;
420 EFI_IP6_ROUTE_TABLE AddressType: Ip6ConfigNvRouteTable.
422 @param[in, out] String The pointer to the buffer to store the converted
424 @param[in] HiiHandle A handle that was previously registered in the
426 @param[in] AddressType The address type.
427 @param[in] AddressInfo Pointer to the address list.
428 @param[in] AddressCount The address count of the address list.
430 @retval EFI_SUCCESS The operation finished successfully.
431 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
432 @retval EFI_UNSUPPORTED The AddressType is not supported.
437 Ip6ConvertAddressListToString (
438 IN OUT CHAR16
*String
,
439 IN EFI_HII_HANDLE HiiHandle
,
440 IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType
,
441 IN VOID
*AddressInfo
,
442 IN UINTN AddressCount
449 VOID
*StartOpCodeHandle
;
450 EFI_IFR_GUID_LABEL
*StartLabel
;
451 VOID
*EndOpCodeHandle
;
452 EFI_IFR_GUID_LABEL
*EndLabel
;
453 UINT16 StartLabelNumber
;
454 EFI_STRING_ID TextTwo
;
457 EFI_IPv6_ADDRESS
*Address
;
459 if ((String
== NULL
) || (HiiHandle
== NULL
) || (AddressInfo
== NULL
)) {
460 return EFI_INVALID_PARAMETER
;
463 if (AddressType
== Ip6ConfigNvHostAddress
) {
464 StartLabelNumber
= HOST_ADDRESS_LABEL
;
465 } else if (AddressType
== Ip6ConfigNvGatewayAddress
) {
466 StartLabelNumber
= GATEWAY_ADDRESS_LABEL
;
467 } else if (AddressType
== Ip6ConfigNvDnsAddress
) {
468 StartLabelNumber
= DNS_ADDRESS_LABEL
;
469 } else if (AddressType
== Ip6ConfigNvRouteTable
) {
470 StartLabelNumber
= ROUTE_TABLE_LABEL
;
473 return EFI_UNSUPPORTED
;
476 Status
= Ip6CreateOpCode (
483 if (EFI_ERROR (Status
)) {
487 AddressHead
= (UINT8
*) AddressInfo
;
489 for (Index
= 0; Index
< AddressCount
; Index
++) {
490 if (AddressType
== Ip6ConfigNvHostAddress
) {
491 AddressInfo
= AddressHead
+ sizeof (EFI_IP6_ADDRESS_INFO
) * Index
;
492 Address
= &((EFI_IP6_ADDRESS_INFO
*) AddressInfo
)->Address
;
493 } else if (AddressType
== Ip6ConfigNvRouteTable
) {
494 AddressInfo
= AddressHead
+ sizeof (EFI_IP6_ROUTE_TABLE
) * Index
;
495 Address
= &((EFI_IP6_ROUTE_TABLE
*) AddressInfo
)->Destination
;
497 AddressInfo
= AddressHead
+ sizeof (EFI_IPv6_ADDRESS
) * Index
;
498 Address
= AddressInfo
;
502 // Convert the IP address info to string.
504 Ip6ToStr (Address
, String
);
505 TempStr
= String
+ StrLen (String
);
507 if ((AddressType
== Ip6ConfigNvHostAddress
) || (AddressType
== Ip6ConfigNvRouteTable
)) {
508 if (AddressType
== Ip6ConfigNvHostAddress
) {
509 PrefixLength
= ((EFI_IP6_ADDRESS_INFO
*) AddressInfo
)->PrefixLength
;
511 PrefixLength
= ((EFI_IP6_ROUTE_TABLE
*) AddressInfo
)->PrefixLength
;
515 // Append the prefix length to the string.
519 Number
= UnicodeSPrint (TempStr
, 6, L
"%d", PrefixLength
);
520 TempStr
= TempStr
+ Number
;
523 if (AddressType
== Ip6ConfigNvRouteTable
) {
525 // Append " >> " to the string.
527 Number
= UnicodeSPrint (TempStr
, 8, L
" >> ");
528 TempStr
= TempStr
+ Number
;
531 // Append the gateway address to the string.
533 Ip6ToStr (&((EFI_IP6_ROUTE_TABLE
*) AddressInfo
)->Gateway
, TempStr
);
534 TempStr
= TempStr
+ StrLen (TempStr
);
538 // Generate a text opcode and update the UI.
540 TextTwo
= HiiSetString (HiiHandle
, 0, String
, NULL
);
542 Status
= EFI_INVALID_PARAMETER
;
546 HiiCreateTextOpCode (StartOpCodeHandle
, STR_NULL
, STR_NULL
, TextTwo
);
549 *String
= IP6_ADDRESS_DELIMITER
;
553 *(String
- 1) = '\0';
555 Status
= HiiUpdateForm (
556 HiiHandle
, // HII handle
557 &gIp6ConfigNvDataGuid
, // Formset GUID
558 FORMID_MAIN_FORM
, // Form ID
559 StartOpCodeHandle
, // Label for where to insert opcodes
560 EndOpCodeHandle
// Replace data
564 HiiFreeOpCodeHandle (StartOpCodeHandle
);
565 HiiFreeOpCodeHandle (EndOpCodeHandle
);
571 Parse address list in string format and convert it to a list array of node in
572 IP6_ADDRESS_INFO_ENTRY.
574 @param[in] String The buffer to string to be parsed.
575 @param[out] ListHead The list head of array.
576 @param[out] AddressCount The number of list nodes in the array.
578 @retval EFI_SUCCESS The operation finished successfully.
579 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
580 @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to lack of resource.
584 Ip6ParseAddressListFromString (
585 IN CONST CHAR16
*String
,
586 OUT LIST_ENTRY
*ListHead
,
587 OUT UINT32
*AddressCount
594 EFI_IP6_ADDRESS_INFO AddressInfo
;
595 IP6_ADDRESS_INFO_ENTRY
*Node
;
599 if ((String
== NULL
) || (ListHead
== NULL
) || (AddressCount
== NULL
)) {
600 return EFI_INVALID_PARAMETER
;
603 LocalString
= (CHAR16
*) AllocateCopyPool (StrSize (String
), String
);
604 if (LocalString
== NULL
) {
605 return EFI_OUT_OF_RESOURCES
;
609 // Clean the original address list.
611 Ip6FreeAddressInfoList (ListHead
);
617 while (*LocalString
!= L
'\0') {
618 TempStr
= LocalString
;
619 while ((*LocalString
!= L
'\0') && (*LocalString
!= IP6_ADDRESS_DELIMITER
)) {
623 if (*LocalString
== L
'\0') {
627 *LocalString
= L
'\0';
629 Status
= NetLibStrToIp6andPrefix (TempStr
, &AddressInfo
.Address
, &AddressInfo
.PrefixLength
);
630 if (EFI_ERROR (Status
)) {
634 if (AddressInfo
.PrefixLength
== 0xFF) {
635 AddressInfo
.PrefixLength
= 0;
638 if (!NetIp6IsValidUnicast (&AddressInfo
.Address
)) {
639 Status
= EFI_INVALID_PARAMETER
;
643 Node
= AllocatePool (sizeof (IP6_ADDRESS_INFO_ENTRY
));
645 Status
= EFI_OUT_OF_RESOURCES
;
649 CopyMem (&Node
->AddrInfo
, &AddressInfo
, sizeof (EFI_IP6_ADDRESS_INFO
));
650 InsertTailList (ListHead
, &Node
->Link
);
661 *AddressCount
= Count
;
665 Ip6FreeAddressInfoList (ListHead
);
671 This function converts the interface info to string and draws it to the IP6 UI.
672 The interface information includes interface name, interface type, hardware address,
673 address info, and route table information. The address information is also used as the
674 content of manual addresses in IP6 UI.
676 @param[in] IfInfo The pointer of EFI_IP6_CONFIG_INTERFACE_INFO.
677 @param[in] HiiHandle The handle that was previously registered in the
679 @param[in, out] IfrNvData Points to IP6_CONFIG_IFR_NVDATA.
681 @retval EFI_SUCCESS The operation finished successfully.
682 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
683 @retval EFI_OUT_OF_RESOURCES The operation failed due to lack of resources.
687 Ip6ConvertInterfaceInfoToString (
688 IN EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
,
689 IN EFI_HII_HANDLE HiiHandle
,
690 IN OUT IP6_CONFIG_IFR_NVDATA
*IfrNvData
696 CHAR16
*LinkLocalStr
;
697 CHAR16 PortString
[ADDRESS_STR_MAX_SIZE
];
698 CHAR16 FormatString
[8];
699 EFI_STRING_ID StringId
;
702 if ((IfInfo
== NULL
) || (HiiHandle
== NULL
) || (IfrNvData
== NULL
)) {
703 return EFI_INVALID_PARAMETER
;
707 // Print the interface name.
709 StringId
= HiiSetString (
711 STRING_TOKEN (STR_IP6_INTERFACE_NAME_CONTENT
),
716 return EFI_OUT_OF_RESOURCES
;
720 // Print the interface type.
722 if (IfInfo
->IfType
== Ip6InterfaceTypeEthernet
) {
723 StrCpy (PortString
, IP6_ETHERNET
);
724 } else if (IfInfo
->IfType
== Ip6InterfaceTypeExperimentalEthernet
) {
725 StrCpy (PortString
, IP6_EXPERIMENTAL_ETHERNET
);
728 // Refer to RFC1700, chapter Number Hardware Type.
730 UnicodeSPrint (PortString
, 6, L
"%d", IfInfo
->IfType
);
733 StringId
= HiiSetString (
735 STRING_TOKEN (STR_IP6_INTERFACE_TYPE_CONTENT
),
740 return EFI_OUT_OF_RESOURCES
;
744 // Convert the hardware address.
747 ASSERT (IfInfo
->HwAddressSize
<= 32);
749 for (Index
= 0; Index
< IfInfo
->HwAddressSize
; Index
++) {
751 if (IfInfo
->HwAddress
.Addr
[Index
] < 0x10) {
752 StrCpy (FormatString
, L
"0%x-");
754 StrCpy (FormatString
, L
"%x-");
757 Number
= UnicodeSPrint (
760 (CONST CHAR16
*) FormatString
,
761 (UINTN
) IfInfo
->HwAddress
.Addr
[Index
]
763 String
= String
+ Number
;
767 ASSERT (String
> PortString
);
773 // Print the hardware address.
775 StringId
= HiiSetString (
777 STRING_TOKEN (STR_IP6_MAC_ADDRESS_CONTENT
),
782 return EFI_OUT_OF_RESOURCES
;
786 // Print the host address Information.
788 Status
= Ip6ConvertAddressListToString (
791 Ip6ConfigNvHostAddress
,
793 IfInfo
->AddressInfoCount
795 if (EFI_ERROR (Status
)) {
800 // Copy the Host Address Info to manual address field.
801 // Do not copy the link local address.
803 LinkLocalStr
= StrStr (PortString
, IP6_LINK_LOCAL_PREFIX
);
804 if (LinkLocalStr
!= NULL
) {
805 Number
= LinkLocalStr
- PortString
;
807 CopyMem (IfrNvData
->ManualAddress
, PortString
, Number
* sizeof (CHAR16
));
810 while ((*LinkLocalStr
!= L
' ') && (*LinkLocalStr
!= L
'\0')) {
814 if (*LinkLocalStr
!= L
'\0') {
816 StrCat (IfrNvData
->ManualAddress
, LinkLocalStr
);
819 StrCpy (IfrNvData
->ManualAddress
, PortString
);
823 // Print the route table information.
825 Status
= Ip6ConvertAddressListToString (
828 Ip6ConfigNvRouteTable
,
836 Build the address info list from list array of node in IP6_ADDRESS_INFO_ENTRY.
838 @param[in] Instance Points to IP6 config instance data.
839 @param[in] AddressType The address type.
840 @param[out] AddressInfo The pointer to the buffer to store the address list.
841 @param[out] AddressSize The address size of the address list.
843 @retval EFI_SUCCESS The operation finished successfully.
844 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
845 @retval EFI_UNSUPPORTED The AddressType is not supported.
849 Ip6BuildNvAddressInfo (
850 IN IP6_CONFIG_INSTANCE
*Instance
,
851 IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType
,
852 OUT VOID
**AddressInfo
,
853 OUT UINTN
*AddressSize
856 IP6_CONFIG_NVDATA
*Ip6NvData
;
858 LIST_ENTRY
*ListHead
;
859 IP6_ADDRESS_INFO_ENTRY
*Node
;
863 EFI_IPv6_ADDRESS
*Ip6Address
;
864 EFI_IP6_CONFIG_MANUAL_ADDRESS
*ManualAddress
;
866 if ((Instance
== NULL
) || (AddressInfo
== NULL
) || (AddressSize
== NULL
)) {
867 return EFI_INVALID_PARAMETER
;
870 NET_CHECK_SIGNATURE (Instance
, IP6_CONFIG_INSTANCE_SIGNATURE
);
872 Ip6NvData
= &Instance
->Ip6NvData
;
874 if (AddressType
== Ip6ConfigNvHostAddress
) {
875 ListHead
= &Ip6NvData
->ManualAddress
;
876 DataSize
= sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
) * Ip6NvData
->ManualAddressCount
;
877 } else if (AddressType
== Ip6ConfigNvGatewayAddress
) {
878 ListHead
= &Ip6NvData
->GatewayAddress
;
879 DataSize
= sizeof (EFI_IPv6_ADDRESS
) * Ip6NvData
->GatewayAddressCount
;
880 } else if (AddressType
== Ip6ConfigNvDnsAddress
) {
881 ListHead
= &Ip6NvData
->DnsAddress
;
882 DataSize
= sizeof (EFI_IPv6_ADDRESS
) * Ip6NvData
->DnsAddressCount
;
884 return EFI_UNSUPPORTED
;
887 AddressList
= AllocateZeroPool (DataSize
);
888 if (AddressList
== NULL
) {
889 return EFI_OUT_OF_RESOURCES
;
892 TmpStr
= AddressList
;
894 NET_LIST_FOR_EACH (Entry
, ListHead
) {
895 Node
= NET_LIST_USER_STRUCT (Entry
, IP6_ADDRESS_INFO_ENTRY
, Link
);
896 if (AddressType
== Ip6ConfigNvHostAddress
) {
897 ManualAddress
= (EFI_IP6_CONFIG_MANUAL_ADDRESS
*) AddressList
;
898 IP6_COPY_ADDRESS (&ManualAddress
->Address
, &Node
->AddrInfo
.Address
);
899 ManualAddress
->PrefixLength
= Node
->AddrInfo
.PrefixLength
;
900 AddressList
= (UINT8
*) AddressList
+ sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS
);
902 Ip6Address
= (EFI_IPv6_ADDRESS
*) AddressList
;
903 IP6_COPY_ADDRESS (Ip6Address
, &Node
->AddrInfo
.Address
);
904 AddressList
= (UINT8
*) AddressList
+ sizeof (EFI_IPv6_ADDRESS
);
908 *AddressInfo
= TmpStr
;
909 *AddressSize
= DataSize
;
914 Convert the IP6 configuration data into the IFR data.
916 @param[in, out] IfrNvData The IFR NV data.
917 @param[in] Instance The IP6 config instance data.
919 @retval EFI_SUCCESS The operation finished successfully.
920 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
921 @retval EFI_UNSUPPORTED The policy is not supported in the current implementation.
922 @retval Others Other errors as indicated.
926 Ip6ConvertConfigNvDataToIfrNvData (
927 IN OUT IP6_CONFIG_IFR_NVDATA
*IfrNvData
,
928 IN IP6_CONFIG_INSTANCE
*Instance
931 IP6_CONFIG_NVDATA
*Ip6NvData
;
932 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
936 EFI_IP6_CONFIG_POLICY Policy
;
937 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits
;
938 EFI_HII_HANDLE HiiHandle
;
940 if ((IfrNvData
== NULL
) || (Instance
== NULL
)) {
941 return EFI_INVALID_PARAMETER
;
944 NET_CHECK_SIGNATURE (Instance
, IP6_CONFIG_INSTANCE_SIGNATURE
);
946 Ip6Config
= &Instance
->Ip6Config
;
947 Ip6NvData
= &Instance
->Ip6NvData
;
950 HiiHandle
= Instance
->CallbackInfo
.RegisteredHandle
;
953 // Get the current interface info.
955 Status
= Ip6ConfigNvGetData (
957 Ip6ConfigDataTypeInterfaceInfo
,
961 if (EFI_ERROR (Status
)) {
966 // Convert the interface info to string and print.
968 Status
= Ip6ConvertInterfaceInfoToString (
969 (EFI_IP6_CONFIG_INTERFACE_INFO
*) Data
,
973 if (EFI_ERROR (Status
)) {
978 // Get the interface id.
980 DataSize
= sizeof (EFI_IP6_CONFIG_INTERFACE_ID
);
981 ZeroMem (&Ip6NvData
->InterfaceId
, DataSize
);
982 Status
= Ip6Config
->GetData (
984 Ip6ConfigDataTypeAltInterfaceId
,
986 &Ip6NvData
->InterfaceId
988 if (EFI_ERROR (Status
)) {
992 Ip6ConvertInterfaceIdToString (IfrNvData
->InterfaceId
, &Ip6NvData
->InterfaceId
);
995 // Get current policy.
997 DataSize
= sizeof (EFI_IP6_CONFIG_POLICY
);
998 Status
= Ip6Config
->GetData (
1000 Ip6ConfigDataTypePolicy
,
1005 if (EFI_ERROR (Status
)) {
1009 if (Policy
== Ip6ConfigPolicyManual
) {
1010 IfrNvData
->Policy
= IP6_POLICY_MANUAL
;
1011 } else if (Policy
== Ip6ConfigPolicyAutomatic
) {
1012 IfrNvData
->Policy
= IP6_POLICY_AUTO
;
1015 Status
= EFI_UNSUPPORTED
;
1020 // Get Duplicate Address Detection Transmits count.
1022 DataSize
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
1023 Status
= Ip6Config
->GetData (
1025 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1030 if (EFI_ERROR (Status
)) {
1034 IfrNvData
->DadTransmitCount
= DadXmits
.DupAddrDetectTransmits
;
1037 // Get DNS server list.
1042 Status
= Ip6ConfigNvGetData (
1044 Ip6ConfigDataTypeDnsServer
,
1049 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1055 // Convert the DNS server address to string and draw it to UI.
1057 Status
= Ip6ConvertAddressListToString (
1058 IfrNvData
->DnsAddress
,
1060 Ip6ConfigNvDnsAddress
,
1062 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1064 if (EFI_ERROR (Status
)) {
1073 // Get gateway adderss list.
1076 Status
= Ip6ConfigNvGetData (
1078 Ip6ConfigDataTypeGateway
,
1083 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1089 // Convert the gateway address to string and draw it to UI.
1091 Status
= Ip6ConvertAddressListToString (
1092 IfrNvData
->GatewayAddress
,
1094 Ip6ConfigNvGatewayAddress
,
1096 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1098 if (EFI_ERROR (Status
)) {
1103 Status
= EFI_SUCCESS
;
1114 Convert IFR data into IP6 configuration data. The policy, alternative interface
1115 ID, and DAD transmit counts, and will be saved. If under manual policy, the configured
1116 manual address, gateway address, and DNS server address will be saved.
1118 @param[in] IfrNvData The IFR NV data.
1119 @param[in, out] Instance The IP6 config instance data.
1121 @retval EFI_SUCCESS The operation finished successfully.
1122 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
1123 @retval Others Other errors as indicated.
1127 Ip6ConvertIfrNvDataToConfigNvData (
1128 IN IP6_CONFIG_IFR_NVDATA
*IfrNvData
,
1129 IN OUT IP6_CONFIG_INSTANCE
*Instance
1132 IP6_CONFIG_NVDATA
*Ip6NvData
;
1133 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
1135 EFI_IP6_CONFIG_MANUAL_ADDRESS
*ManualAddress
;
1136 EFI_IPv6_ADDRESS
*Address
;
1137 BOOLEAN IsAddressOk
;
1138 EFI_EVENT SetAddressEvent
;
1139 EFI_EVENT TimeoutEvent
;
1142 if ((IfrNvData
== NULL
) || (Instance
== NULL
)) {
1143 return EFI_INVALID_PARAMETER
;
1146 NET_CHECK_SIGNATURE (Instance
, IP6_CONFIG_INSTANCE_SIGNATURE
);
1147 Ip6NvData
= &Instance
->Ip6NvData
;
1148 Ip6Config
= &Instance
->Ip6Config
;
1151 // Update those fields which don't have INTERACTIVE attribute.
1153 if (IfrNvData
->Policy
== IP6_POLICY_AUTO
) {
1154 Ip6NvData
->Policy
= Ip6ConfigPolicyAutomatic
;
1155 } else if (IfrNvData
->Policy
== IP6_POLICY_MANUAL
) {
1156 Ip6NvData
->Policy
= Ip6ConfigPolicyManual
;
1159 Ip6NvData
->DadTransmitCount
.DupAddrDetectTransmits
= IfrNvData
->DadTransmitCount
;
1162 // Set the configured policy.
1164 Status
= Ip6Config
->SetData (
1166 Ip6ConfigDataTypePolicy
,
1167 sizeof (EFI_IP6_CONFIG_POLICY
),
1170 if (EFI_ERROR (Status
)) {
1175 // Set the duplicate address detection transmits count.
1177 Status
= Ip6Config
->SetData (
1179 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1180 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
),
1181 &Ip6NvData
->DadTransmitCount
1183 if (EFI_ERROR (Status
)) {
1188 // Set the alternative interface ID
1190 Status
= Ip6Config
->SetData (
1192 Ip6ConfigDataTypeAltInterfaceId
,
1193 sizeof (EFI_IP6_CONFIG_INTERFACE_ID
),
1194 &Ip6NvData
->InterfaceId
1196 if (EFI_ERROR (Status
)) {
1201 if (Ip6NvData
->Policy
== Ip6ConfigPolicyAutomatic
) {
1206 // Create events & timers for asynchronous settings.
1208 SetAddressEvent
= NULL
;
1209 TimeoutEvent
= NULL
;
1210 ManualAddress
= NULL
;
1213 Status
= gBS
->CreateEvent (
1216 Ip6ConfigManualAddressNotify
,
1220 if (EFI_ERROR (Status
)) {
1224 Status
= gBS
->CreateEvent (
1231 if (EFI_ERROR (Status
)) {
1236 // Set the manual address list. This is an asynchronous process.
1238 if (!IsListEmpty (&Ip6NvData
->ManualAddress
) && (Ip6NvData
->ManualAddressCount
!= 0)) {
1239 Status
= Ip6BuildNvAddressInfo (
1241 Ip6ConfigNvHostAddress
,
1242 (VOID
**) &ManualAddress
,
1245 if (EFI_ERROR (Status
)) {
1249 IsAddressOk
= FALSE
;
1251 Status
= Ip6Config
->RegisterDataNotify (
1253 Ip6ConfigDataTypeManualAddress
,
1256 if (EFI_ERROR (Status
)) {
1260 Status
= Ip6Config
->SetData (
1262 Ip6ConfigDataTypeManualAddress
,
1264 (VOID
*) ManualAddress
1266 if (Status
== EFI_NOT_READY
) {
1267 gBS
->SetTimer (TimeoutEvent
, TimerRelative
, 50000000);
1268 while (EFI_ERROR (gBS
->CheckEvent (TimeoutEvent
))) {
1270 Status
= EFI_SUCCESS
;
1276 Status
= Ip6Config
->UnregisterDataNotify (
1278 Ip6ConfigDataTypeManualAddress
,
1281 if (EFI_ERROR (Status
)) {
1287 // Set gateway address list.
1289 if (!IsListEmpty (&Ip6NvData
->GatewayAddress
) && (Ip6NvData
->GatewayAddressCount
!= 0)) {
1290 Status
= Ip6BuildNvAddressInfo (
1292 Ip6ConfigNvGatewayAddress
,
1296 if (EFI_ERROR (Status
)) {
1300 Status
= Ip6Config
->SetData (
1302 Ip6ConfigDataTypeGateway
,
1306 if (EFI_ERROR (Status
)) {
1315 // Set DNS server address list.
1317 if (!IsListEmpty (&Ip6NvData
->DnsAddress
) && (Ip6NvData
->DnsAddressCount
!= 0)) {
1318 Status
= Ip6BuildNvAddressInfo (
1320 Ip6ConfigNvDnsAddress
,
1324 if (EFI_ERROR (Status
)) {
1328 Status
= Ip6Config
->SetData (
1330 Ip6ConfigDataTypeDnsServer
,
1334 if (EFI_ERROR (Status
)) {
1339 Status
= EFI_SUCCESS
;
1342 if (SetAddressEvent
!= NULL
) {
1343 gBS
->CloseEvent (SetAddressEvent
);
1346 if (TimeoutEvent
!= NULL
) {
1347 gBS
->CloseEvent (TimeoutEvent
);
1350 if (ManualAddress
!= NULL
) {
1351 FreePool (ManualAddress
);
1354 if (Address
!= NULL
) {
1362 This function allows the caller to request the current
1363 configuration for one or more named elements. The resulting
1364 string is in <ConfigAltResp> format. Any and all alternative
1365 configuration strings shall also be appended to the end of the
1366 current configuration string. If they are, they must appear
1367 after the current configuration. They must contain the same
1368 routing (GUID, NAME, PATH) as the current configuration string.
1369 They must have an additional description indicating the type of
1370 alternative configuration the string represents,
1371 "ALTCFG=<StringToken>". That <StringToken> (when
1372 converted from Hex UNICODE to binary) is a reference to a
1373 string in the associated string pack.
1375 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1376 @param[in] Request A null-terminated Unicode string in
1377 <ConfigRequest> format. Note that this
1378 includes the routing information as well as
1379 the configurable name / value pairs. It is
1380 invalid for this string to be in
1381 <MultiConfigRequest> format.
1382 @param[out] Progress On return, points to a character in the
1383 Request string. Points to the string's null
1384 terminator if request was successful. Points
1385 to the most recent "&" before the first
1386 failing name / value pair (or the beginning
1387 of the string if the failure is in the first
1388 name / value pair) if the request was not
1390 @param[out] Results A null-terminated Unicode string in
1391 <ConfigAltResp> format which has all values
1392 filled in for the names in the Request string.
1393 String to be allocated by the called function.
1395 @retval EFI_SUCCESS The Results string is filled with the
1396 values corresponding to all requested
1398 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1399 parts of the results that must be
1400 stored awaiting possible future
1402 @retval EFI_INVALID_PARAMETER For example, passing in a NULL
1403 for the Request parameter
1404 would result in this type of
1405 error. In this case, the
1406 Progress parameter would be
1408 @retval EFI_NOT_FOUND Routing data doesn't match any
1409 known driver. Progress set to the
1410 first character in the routing header.
1411 Note: There is no requirement that the
1412 driver validate the routing data. It
1413 must skip the <ConfigHdr> in order to
1415 @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set
1416 to most recent & before the
1417 error or the beginning of the
1419 @retval EFI_INVALID_PARAMETER Unknown name. Progress points
1420 to the & before the name in
1421 question. Currently not implemented.
1425 Ip6FormExtractConfig (
1426 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1427 IN CONST EFI_STRING Request
,
1428 OUT EFI_STRING
*Progress
,
1429 OUT EFI_STRING
*Results
1434 IP6_FORM_CALLBACK_INFO
*Private
;
1435 IP6_CONFIG_INSTANCE
*Ip6ConfigInstance
;
1436 IP6_CONFIG_IFR_NVDATA
*IfrNvData
;
1437 EFI_STRING ConfigRequestHdr
;
1438 EFI_STRING ConfigRequest
;
1439 BOOLEAN AllocatedRequest
;
1443 if (This
== NULL
|| Progress
== NULL
|| Results
== NULL
) {
1444 return EFI_INVALID_PARAMETER
;
1447 *Progress
= Request
;
1448 if ((Request
!= NULL
) &&
1449 !HiiIsConfigHdrMatch (Request
, &gIp6ConfigNvDataGuid
, mIp6ConfigStorageName
)) {
1450 return EFI_NOT_FOUND
;
1453 ConfigRequestHdr
= NULL
;
1454 ConfigRequest
= NULL
;
1455 AllocatedRequest
= FALSE
;
1458 Private
= IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This
);
1459 Ip6ConfigInstance
= IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private
);
1460 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1462 IfrNvData
= (IP6_CONFIG_IFR_NVDATA
*) AllocateZeroPool (BufferSize
);
1463 if (IfrNvData
== NULL
) {
1464 return EFI_OUT_OF_RESOURCES
;
1467 Status
= Ip6ConvertConfigNvDataToIfrNvData (IfrNvData
, Ip6ConfigInstance
);
1468 if (EFI_ERROR (Status
)) {
1472 ConfigRequest
= Request
;
1473 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
1475 // Request has no request element, construct full request string.
1476 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
1477 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator.
1479 ConfigRequestHdr
= HiiConstructConfigHdr (
1480 &gIp6ConfigNvDataGuid
,
1481 mIp6ConfigStorageName
,
1482 Private
->ChildHandle
1484 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
1485 ConfigRequest
= AllocateZeroPool (Size
);
1486 ASSERT (ConfigRequest
!= NULL
);
1487 AllocatedRequest
= TRUE
;
1491 L
"%s&OFFSET=0&WIDTH=%016LX",
1495 FreePool (ConfigRequestHdr
);
1499 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
1501 Status
= gHiiConfigRouting
->BlockToConfig (
1504 (UINT8
*) IfrNvData
,
1511 FreePool (IfrNvData
);
1513 // Free the allocated config request string.
1515 if (AllocatedRequest
) {
1516 FreePool (ConfigRequest
);
1517 ConfigRequest
= NULL
;
1520 // Set Progress string to the original request string.
1522 if (Request
== NULL
) {
1524 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
1525 *Progress
= Request
+ StrLen (Request
);
1532 This function applies changes in a driver's configuration.
1533 Input is a Configuration, which has the routing data for this
1534 driver followed by name / value configuration pairs. The driver
1535 must apply those pairs to its configurable storage. If the
1536 driver's configuration is stored in a linear block of data
1537 and the driver's name / value pairs are in <BlockConfig>
1538 format, it may use the ConfigToBlock helper function (above) to
1539 simplify the job. Currently not implemented.
1541 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1542 @param[in] Configuration A null-terminated Unicode string in
1543 <ConfigString> format.
1544 @param[out] Progress A pointer to a string filled in with the
1545 offset of the most recent '&' before the
1546 first failing name / value pair (or the
1547 beginn ing of the string if the failure
1548 is in the first name / value pair) or
1549 the terminating NULL if all was
1552 @retval EFI_SUCCESS The results have been distributed or are
1553 awaiting distribution.
1554 @retval EFI_OUT_OF_MEMORY Not enough memory to store the
1555 parts of the results that must be
1556 stored awaiting possible future
1558 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1559 Results parameter would result
1560 in this type of error.
1561 @retval EFI_NOT_FOUND Target for the specified routing data
1566 Ip6FormRouteConfig (
1567 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1568 IN CONST EFI_STRING Configuration
,
1569 OUT EFI_STRING
*Progress
1572 if (This
== NULL
|| Configuration
== NULL
|| Progress
== NULL
) {
1573 return EFI_INVALID_PARAMETER
;
1577 // Check routing data in <ConfigHdr>.
1578 // Note: if only one Storage is used, then this checking could be skipped.
1580 if (!HiiIsConfigHdrMatch (Configuration
, &gIp6ConfigNvDataGuid
, mIp6ConfigStorageName
)) {
1581 *Progress
= Configuration
;
1582 return EFI_NOT_FOUND
;
1585 *Progress
= Configuration
+ StrLen (Configuration
);
1591 This function is called to provide results data to the driver.
1592 This data consists of a unique key that is used to identify
1593 which data is either being passed back or being asked for.
1595 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1596 @param[in] Action Specifies the type of action taken by the browser.
1597 @param[in] QuestionId A unique value which is sent to the original
1598 exporting driver so that it can identify the type
1599 of data to expect. The format of the data tends to
1600 vary based on the opcode that generated the callback.
1601 @param[in] Type The type of value for the question.
1602 @param[in] Value A pointer to the data being sent to the original
1604 @param[out] ActionRequest On return, points to the action requested by the
1607 @retval EFI_SUCCESS The callback successfully handled the action.
1608 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
1609 variable and its data.
1610 @retval EFI_DEVICE_ERROR The variable could not be saved.
1611 @retval EFI_UNSUPPORTED The specified Action is not supported by the
1612 callback. Currently not implemented.
1613 @retval EFI_INVALID_PARAMETER Passed in the wrong parameter.
1614 @retval Others Other errors as indicated.
1620 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1621 IN EFI_BROWSER_ACTION Action
,
1622 IN EFI_QUESTION_ID QuestionId
,
1624 IN EFI_IFR_TYPE_VALUE
*Value
,
1625 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1628 IP6_FORM_CALLBACK_INFO
*Private
;
1630 IP6_CONFIG_IFR_NVDATA
*IfrNvData
;
1633 IP6_CONFIG_INSTANCE
*Instance
;
1634 IP6_CONFIG_NVDATA
*Ip6NvData
;
1635 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
1636 EFI_IP6_CONFIG_INTERFACE_INFO
*Data
;
1638 CHAR16 PortString
[ADDRESS_STR_MAX_SIZE
];
1639 EFI_HII_HANDLE HiiHandle
;
1640 EFI_IP6_CONFIG_INTERFACE_INFO
*IfInfo
;
1643 return EFI_INVALID_PARAMETER
;
1646 Private
= IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This
);
1647 Instance
= IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private
);
1648 Ip6NvData
= &Instance
->Ip6NvData
;
1650 if ((Action
== EFI_BROWSER_ACTION_FORM_OPEN
) || (Action
== EFI_BROWSER_ACTION_FORM_CLOSE
)){
1654 if (Action
!= EFI_BROWSER_ACTION_CHANGING
&& Action
!= EFI_BROWSER_ACTION_CHANGED
) {
1655 return EFI_UNSUPPORTED
;
1658 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
1659 return EFI_INVALID_PARAMETER
;
1663 // Retrieve uncommitted data from Browser
1666 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1667 IfrNvData
= AllocateZeroPool (BufferSize
);
1668 if (IfrNvData
== NULL
) {
1669 return EFI_OUT_OF_RESOURCES
;
1672 Status
= EFI_SUCCESS
;
1674 HiiGetBrowserData (NULL
, NULL
, BufferSize
, (UINT8
*) IfrNvData
);
1676 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
1677 switch (QuestionId
) {
1678 case KEY_GET_CURRENT_SETTING
:
1679 Ip6Config
= &Instance
->Ip6Config
;
1680 HiiHandle
= Instance
->CallbackInfo
.RegisteredHandle
;
1684 // Get current interface info.
1686 Status
= Ip6ConfigNvGetData (
1688 Ip6ConfigDataTypeInterfaceInfo
,
1692 if (EFI_ERROR (Status
)) {
1697 // Generate dynamic text opcode for host address and draw it.
1699 IfInfo
= (EFI_IP6_CONFIG_INTERFACE_INFO
*) Data
;
1700 Status
= Ip6ConvertAddressListToString (
1703 Ip6ConfigNvHostAddress
,
1704 IfInfo
->AddressInfo
,
1705 IfInfo
->AddressInfoCount
1707 if (EFI_ERROR (Status
)) {
1713 // Generate the dynamic text opcode for route table and draw it.
1715 Status
= Ip6ConvertAddressListToString (
1718 Ip6ConfigNvRouteTable
,
1722 if (EFI_ERROR (Status
)) {
1728 // Get DNS server list.
1733 Status
= Ip6ConfigNvGetData (
1735 Ip6ConfigDataTypeDnsServer
,
1739 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1748 // Generate the dynamic text opcode for DNS server and draw it.
1750 Status
= Ip6ConvertAddressListToString (
1753 Ip6ConfigNvDnsAddress
,
1755 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1757 if (EFI_ERROR (Status
)) {
1764 // Get gateway adderss list.
1772 Status
= Ip6ConfigNvGetData (
1774 Ip6ConfigDataTypeGateway
,
1778 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1787 // Generate the dynamic text opcode for gateway and draw it.
1789 Status
= Ip6ConvertAddressListToString (
1792 Ip6ConfigNvGatewayAddress
,
1794 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1796 if (EFI_ERROR (Status
)) {
1806 Status
= EFI_SUCCESS
;
1813 } else if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
1814 switch (QuestionId
) {
1815 case KEY_SAVE_CONFIG_CHANGES
:
1816 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
;
1819 case KEY_IGNORE_CONFIG_CHANGES
:
1820 Ip6FreeAddressInfoList (&Ip6NvData
->ManualAddress
);
1821 Ip6FreeAddressInfoList (&Ip6NvData
->GatewayAddress
);
1822 Ip6FreeAddressInfoList (&Ip6NvData
->DnsAddress
);
1824 Ip6NvData
->ManualAddressCount
= 0;
1825 Ip6NvData
->GatewayAddressCount
= 0;
1826 Ip6NvData
->DnsAddressCount
= 0;
1828 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
;
1831 case KEY_SAVE_CHANGES
:
1832 Status
= Ip6ConvertIfrNvDataToConfigNvData (IfrNvData
, Instance
);
1833 if (EFI_ERROR (Status
)) {
1836 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
1839 case KEY_INTERFACE_ID
:
1840 Status
= Ip6ParseInterfaceIdFromString (IfrNvData
->InterfaceId
, &Ip6NvData
->InterfaceId
);
1841 if (EFI_ERROR (Status
)) {
1843 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1845 L
"Invalid Interface ID!",
1852 case KEY_MANUAL_ADDRESS
:
1853 Status
= Ip6ParseAddressListFromString (
1854 IfrNvData
->ManualAddress
,
1855 &Ip6NvData
->ManualAddress
,
1856 &Ip6NvData
->ManualAddressCount
1858 if (EFI_ERROR (Status
)) {
1860 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1862 L
"Invalid Host Addresses!",
1869 case KEY_GATEWAY_ADDRESS
:
1870 Status
= Ip6ParseAddressListFromString (
1871 IfrNvData
->GatewayAddress
,
1872 &Ip6NvData
->GatewayAddress
,
1873 &Ip6NvData
->GatewayAddressCount
1875 if (EFI_ERROR (Status
)) {
1877 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1879 L
"Invalid Gateway Addresses!",
1886 case KEY_DNS_ADDRESS
:
1887 Status
= Ip6ParseAddressListFromString (
1888 IfrNvData
->DnsAddress
,
1889 &Ip6NvData
->DnsAddress
,
1890 &Ip6NvData
->DnsAddressCount
1892 if (EFI_ERROR (Status
)) {
1894 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1896 L
"Invalid DNS Addresses!",
1908 if (!EFI_ERROR (Status
)) {
1910 // Pass changed uncommitted data back to Form Browser.
1912 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1913 HiiSetBrowserData (NULL
, NULL
, BufferSize
, (UINT8
*) IfrNvData
, NULL
);
1916 FreePool (IfrNvData
);
1921 Install HII Config Access protocol for network device and allocate resources.
1923 @param[in, out] Instance The IP6_CONFIG_INSTANCE to create a form.
1925 @retval EFI_SUCCESS The HII Config Access protocol is installed.
1926 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
1927 @retval Others Other errors as indicated.
1932 IN OUT IP6_CONFIG_INSTANCE
*Instance
1937 IP6_FORM_CALLBACK_INFO
*CallbackInfo
;
1938 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
1939 VENDOR_DEVICE_PATH VendorDeviceNode
;
1940 EFI_SERVICE_BINDING_PROTOCOL
*MnpSb
;
1942 CHAR16 MenuString
[128];
1943 CHAR16 PortString
[128];
1944 CHAR16
*OldMenuString
;
1945 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
1947 IpSb
= IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance
);
1948 ASSERT (IpSb
!= NULL
);
1950 Status
= gBS
->HandleProtocol (
1952 &gEfiDevicePathProtocolGuid
,
1953 (VOID
**) &ParentDevicePath
1955 if (EFI_ERROR (Status
)) {
1959 CallbackInfo
= &Instance
->CallbackInfo
;
1960 CallbackInfo
->Signature
= IP6_FORM_CALLBACK_INFO_SIGNATURE
;
1963 // Construct device path node for EFI HII Config Access protocol,
1964 // which consists of controller physical device path and one hardware
1965 // vendor guid node.
1967 ZeroMem (&VendorDeviceNode
, sizeof (VENDOR_DEVICE_PATH
));
1968 VendorDeviceNode
.Header
.Type
= HARDWARE_DEVICE_PATH
;
1969 VendorDeviceNode
.Header
.SubType
= HW_VENDOR_DP
;
1971 CopyGuid (&VendorDeviceNode
.Guid
, &gEfiCallerIdGuid
);
1973 SetDevicePathNodeLength (&VendorDeviceNode
.Header
, sizeof (VENDOR_DEVICE_PATH
));
1974 CallbackInfo
->HiiVendorDevicePath
= AppendDevicePathNode (
1976 (EFI_DEVICE_PATH_PROTOCOL
*) &VendorDeviceNode
1978 if (CallbackInfo
->HiiVendorDevicePath
== NULL
) {
1979 Status
= EFI_OUT_OF_RESOURCES
;
1983 ConfigAccess
= &CallbackInfo
->HiiConfigAccess
;
1984 ConfigAccess
->ExtractConfig
= Ip6FormExtractConfig
;
1985 ConfigAccess
->RouteConfig
= Ip6FormRouteConfig
;
1986 ConfigAccess
->Callback
= Ip6FormCallback
;
1989 // Install Device Path Protocol and Config Access protocol on new handle
1991 Status
= gBS
->InstallMultipleProtocolInterfaces (
1992 &CallbackInfo
->ChildHandle
,
1993 &gEfiDevicePathProtocolGuid
,
1994 CallbackInfo
->HiiVendorDevicePath
,
1995 &gEfiHiiConfigAccessProtocolGuid
,
1999 if (!EFI_ERROR (Status
)) {
2001 // Open the Parent Handle for the child
2003 Status
= gBS
->OpenProtocol (
2005 &gEfiManagedNetworkServiceBindingProtocolGuid
,
2008 CallbackInfo
->ChildHandle
,
2009 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
2013 if (EFI_ERROR (Status
)) {
2018 // Publish our HII data
2020 CallbackInfo
->RegisteredHandle
= HiiAddPackages (
2021 &gIp6ConfigNvDataGuid
,
2022 CallbackInfo
->ChildHandle
,
2027 if (CallbackInfo
->RegisteredHandle
== NULL
) {
2028 Status
= EFI_OUT_OF_RESOURCES
;
2033 // Append MAC string in the menu help string and tile help string
2035 Status
= NetLibGetMacString (IpSb
->Controller
, IpSb
->Image
, &MacString
);
2036 if (!EFI_ERROR (Status
)) {
2037 OldMenuString
= HiiGetString (
2038 CallbackInfo
->RegisteredHandle
,
2039 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP
),
2042 UnicodeSPrint (MenuString
, 128, L
"%s (MAC:%s)", OldMenuString
, MacString
);
2044 CallbackInfo
->RegisteredHandle
,
2045 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP
),
2049 UnicodeSPrint (PortString
, 128, L
"MAC:%s", MacString
);
2051 CallbackInfo
->RegisteredHandle
,
2052 STRING_TOKEN (STR_IP6_DEVICE_FORM_HELP
),
2057 FreePool (MacString
);
2058 FreePool (OldMenuString
);
2060 InitializeListHead (&Instance
->Ip6NvData
.ManualAddress
);
2061 InitializeListHead (&Instance
->Ip6NvData
.GatewayAddress
);
2062 InitializeListHead (&Instance
->Ip6NvData
.DnsAddress
);
2068 Ip6ConfigFormUnload (Instance
);
2073 Uninstall the HII Config Access protocol for network devices and free up the resources.
2075 @param[in, out] Instance The IP6_CONFIG_INSTANCE to unload a form.
2079 Ip6ConfigFormUnload (
2080 IN OUT IP6_CONFIG_INSTANCE
*Instance
2084 IP6_FORM_CALLBACK_INFO
*CallbackInfo
;
2085 IP6_CONFIG_NVDATA
*Ip6NvData
;
2087 IpSb
= IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance
);
2088 ASSERT (IpSb
!= NULL
);
2090 CallbackInfo
= &Instance
->CallbackInfo
;
2092 if (CallbackInfo
->ChildHandle
!= NULL
) {
2095 // Close the child handle
2097 gBS
->CloseProtocol (
2099 &gEfiManagedNetworkServiceBindingProtocolGuid
,
2101 CallbackInfo
->ChildHandle
2104 // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
2106 gBS
->UninstallMultipleProtocolInterfaces (
2107 CallbackInfo
->ChildHandle
,
2108 &gEfiDevicePathProtocolGuid
,
2109 CallbackInfo
->HiiVendorDevicePath
,
2110 &gEfiHiiConfigAccessProtocolGuid
,
2111 &CallbackInfo
->HiiConfigAccess
,
2116 if (CallbackInfo
->HiiVendorDevicePath
!= NULL
) {
2117 FreePool (CallbackInfo
->HiiVendorDevicePath
);
2120 if (CallbackInfo
->RegisteredHandle
!= NULL
) {
2122 // Remove HII package list
2124 HiiRemovePackages (CallbackInfo
->RegisteredHandle
);
2127 Ip6NvData
= &Instance
->Ip6NvData
;
2129 Ip6FreeAddressInfoList (&Ip6NvData
->ManualAddress
);
2130 Ip6FreeAddressInfoList (&Ip6NvData
->GatewayAddress
);
2131 Ip6FreeAddressInfoList (&Ip6NvData
->DnsAddress
);
2133 Ip6NvData
->ManualAddressCount
= 0;
2134 Ip6NvData
->GatewayAddressCount
= 0;
2135 Ip6NvData
->DnsAddressCount
= 0;