2 Helper functions for configuring or obtaining the parameters relating to IP6.
4 Copyright (c) 2010 - 2011, 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 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
935 EFI_IP6_CONFIG_INTERFACE_ID InterfaceId
;
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
;
949 HiiHandle
= Instance
->CallbackInfo
.RegisteredHandle
;
952 // Get the current interface info.
954 Status
= Ip6ConfigNvGetData (
956 Ip6ConfigDataTypeInterfaceInfo
,
960 if (EFI_ERROR (Status
)) {
965 // Convert the interface info to string and print.
967 Status
= Ip6ConvertInterfaceInfoToString (
968 (EFI_IP6_CONFIG_INTERFACE_INFO
*) Data
,
972 if (EFI_ERROR (Status
)) {
977 // Get the interface id.
979 DataSize
= sizeof (EFI_IP6_CONFIG_INTERFACE_ID
);
980 ZeroMem (&InterfaceId
, DataSize
);
981 Status
= Ip6Config
->GetData (
983 Ip6ConfigDataTypeAltInterfaceId
,
987 if (EFI_ERROR (Status
)) {
991 Ip6ConvertInterfaceIdToString (IfrNvData
->InterfaceId
, &InterfaceId
);
994 // Get current policy.
996 DataSize
= sizeof (EFI_IP6_CONFIG_POLICY
);
997 Status
= Ip6Config
->GetData (
999 Ip6ConfigDataTypePolicy
,
1004 if (EFI_ERROR (Status
)) {
1008 if (Policy
== Ip6ConfigPolicyManual
) {
1009 IfrNvData
->Policy
= IP6_POLICY_MANUAL
;
1010 } else if (Policy
== Ip6ConfigPolicyAutomatic
) {
1011 IfrNvData
->Policy
= IP6_POLICY_AUTO
;
1014 Status
= EFI_UNSUPPORTED
;
1019 // Get Duplicate Address Detection Transmits count.
1021 DataSize
= sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
);
1022 Status
= Ip6Config
->GetData (
1024 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1029 if (EFI_ERROR (Status
)) {
1033 IfrNvData
->DadTransmitCount
= DadXmits
.DupAddrDetectTransmits
;
1036 // Get DNS server list.
1041 Status
= Ip6ConfigNvGetData (
1043 Ip6ConfigDataTypeDnsServer
,
1048 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1054 // Convert the DNS server address to string and draw it to UI.
1056 Status
= Ip6ConvertAddressListToString (
1057 IfrNvData
->DnsAddress
,
1059 Ip6ConfigNvDnsAddress
,
1061 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1063 if (EFI_ERROR (Status
)) {
1072 // Get gateway adderss list.
1075 Status
= Ip6ConfigNvGetData (
1077 Ip6ConfigDataTypeGateway
,
1082 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1088 // Convert the gateway address to string and draw it to UI.
1090 Status
= Ip6ConvertAddressListToString (
1091 IfrNvData
->GatewayAddress
,
1093 Ip6ConfigNvGatewayAddress
,
1095 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1097 if (EFI_ERROR (Status
)) {
1102 Status
= EFI_SUCCESS
;
1113 Convert IFR data into IP6 configuration data. The policy, alternative interface
1114 ID, and DAD transmit counts, and will be saved. If under manual policy, the configured
1115 manual address, gateway address, and DNS server address will be saved.
1117 @param[in] IfrNvData The IFR NV data.
1118 @param[in, out] Instance The IP6 config instance data.
1120 @retval EFI_SUCCESS The operation finished successfully.
1121 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
1122 @retval Others Other errors as indicated.
1126 Ip6ConvertIfrNvDataToConfigNvData (
1127 IN IP6_CONFIG_IFR_NVDATA
*IfrNvData
,
1128 IN OUT IP6_CONFIG_INSTANCE
*Instance
1131 IP6_CONFIG_NVDATA
*Ip6NvData
;
1132 EFI_IP6_CONFIG_PROTOCOL
*Ip6Config
;
1134 EFI_IP6_CONFIG_MANUAL_ADDRESS
*ManualAddress
;
1135 EFI_IPv6_ADDRESS
*Address
;
1136 BOOLEAN IsAddressOk
;
1137 EFI_EVENT SetAddressEvent
;
1138 EFI_EVENT TimeoutEvent
;
1141 if ((IfrNvData
== NULL
) || (Instance
== NULL
)) {
1142 return EFI_INVALID_PARAMETER
;
1145 NET_CHECK_SIGNATURE (Instance
, IP6_CONFIG_INSTANCE_SIGNATURE
);
1146 Ip6NvData
= &Instance
->Ip6NvData
;
1147 Ip6Config
= &Instance
->Ip6Config
;
1150 // Update those fields which don't have INTERACTIVE attribute.
1152 if (IfrNvData
->Policy
== IP6_POLICY_AUTO
) {
1153 Ip6NvData
->Policy
= Ip6ConfigPolicyAutomatic
;
1154 } else if (IfrNvData
->Policy
== IP6_POLICY_MANUAL
) {
1155 Ip6NvData
->Policy
= Ip6ConfigPolicyManual
;
1158 Ip6NvData
->DadTransmitCount
.DupAddrDetectTransmits
= IfrNvData
->DadTransmitCount
;
1161 // Set the configured policy.
1163 Status
= Ip6Config
->SetData (
1165 Ip6ConfigDataTypePolicy
,
1166 sizeof (EFI_IP6_CONFIG_POLICY
),
1169 if (EFI_ERROR (Status
)) {
1174 // Set the duplicate address detection transmits count.
1176 Status
= Ip6Config
->SetData (
1178 Ip6ConfigDataTypeDupAddrDetectTransmits
,
1179 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS
),
1180 &Ip6NvData
->DadTransmitCount
1182 if (EFI_ERROR (Status
)) {
1187 // Set the alternative interface ID
1189 Status
= Ip6Config
->SetData (
1191 Ip6ConfigDataTypeAltInterfaceId
,
1192 sizeof (EFI_IP6_CONFIG_INTERFACE_ID
),
1193 &Ip6NvData
->InterfaceId
1195 if (EFI_ERROR (Status
)) {
1200 if (Ip6NvData
->Policy
== Ip6ConfigPolicyAutomatic
) {
1205 // Create events & timers for asynchronous settings.
1207 SetAddressEvent
= NULL
;
1208 TimeoutEvent
= NULL
;
1209 ManualAddress
= NULL
;
1212 Status
= gBS
->CreateEvent (
1215 Ip6ConfigManualAddressNotify
,
1219 if (EFI_ERROR (Status
)) {
1223 Status
= gBS
->CreateEvent (
1230 if (EFI_ERROR (Status
)) {
1235 // Set the manual address list. This is an asynchronous process.
1237 if (!IsListEmpty (&Ip6NvData
->ManualAddress
) && (Ip6NvData
->ManualAddressCount
!= 0)) {
1238 Status
= Ip6BuildNvAddressInfo (
1240 Ip6ConfigNvHostAddress
,
1241 (VOID
**) &ManualAddress
,
1244 if (EFI_ERROR (Status
)) {
1248 IsAddressOk
= FALSE
;
1250 Status
= Ip6Config
->RegisterDataNotify (
1252 Ip6ConfigDataTypeManualAddress
,
1255 if (EFI_ERROR (Status
)) {
1259 Status
= Ip6Config
->SetData (
1261 Ip6ConfigDataTypeManualAddress
,
1263 (VOID
*) ManualAddress
1265 if (Status
== EFI_NOT_READY
) {
1266 gBS
->SetTimer (TimeoutEvent
, TimerRelative
, 50000000);
1267 while (EFI_ERROR (gBS
->CheckEvent (TimeoutEvent
))) {
1269 Status
= EFI_SUCCESS
;
1275 Status
= Ip6Config
->UnregisterDataNotify (
1277 Ip6ConfigDataTypeManualAddress
,
1280 if (EFI_ERROR (Status
)) {
1286 // Set gateway address list.
1288 if (!IsListEmpty (&Ip6NvData
->GatewayAddress
) && (Ip6NvData
->GatewayAddressCount
!= 0)) {
1289 Status
= Ip6BuildNvAddressInfo (
1291 Ip6ConfigNvGatewayAddress
,
1295 if (EFI_ERROR (Status
)) {
1299 Status
= Ip6Config
->SetData (
1301 Ip6ConfigDataTypeGateway
,
1305 if (EFI_ERROR (Status
)) {
1314 // Set DNS server address list.
1316 if (!IsListEmpty (&Ip6NvData
->DnsAddress
) && (Ip6NvData
->DnsAddressCount
!= 0)) {
1317 Status
= Ip6BuildNvAddressInfo (
1319 Ip6ConfigNvDnsAddress
,
1323 if (EFI_ERROR (Status
)) {
1327 Status
= Ip6Config
->SetData (
1329 Ip6ConfigDataTypeDnsServer
,
1333 if (EFI_ERROR (Status
)) {
1338 Status
= EFI_SUCCESS
;
1341 if (SetAddressEvent
!= NULL
) {
1342 gBS
->CloseEvent (SetAddressEvent
);
1345 if (TimeoutEvent
!= NULL
) {
1346 gBS
->CloseEvent (TimeoutEvent
);
1349 if (ManualAddress
!= NULL
) {
1350 FreePool (ManualAddress
);
1353 if (Address
!= NULL
) {
1361 This function allows the caller to request the current
1362 configuration for one or more named elements. The resulting
1363 string is in <ConfigAltResp> format. Any and all alternative
1364 configuration strings shall also be appended to the end of the
1365 current configuration string. If they are, they must appear
1366 after the current configuration. They must contain the same
1367 routing (GUID, NAME, PATH) as the current configuration string.
1368 They must have an additional description indicating the type of
1369 alternative configuration the string represents,
1370 "ALTCFG=<StringToken>". That <StringToken> (when
1371 converted from Hex UNICODE to binary) is a reference to a
1372 string in the associated string pack.
1374 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1375 @param[in] Request A null-terminated Unicode string in
1376 <ConfigRequest> format. Note that this
1377 includes the routing information as well as
1378 the configurable name / value pairs. It is
1379 invalid for this string to be in
1380 <MultiConfigRequest> format.
1381 @param[out] Progress On return, points to a character in the
1382 Request string. Points to the string's null
1383 terminator if request was successful. Points
1384 to the most recent "&" before the first
1385 failing name / value pair (or the beginning
1386 of the string if the failure is in the first
1387 name / value pair) if the request was not
1389 @param[out] Results A null-terminated Unicode string in
1390 <ConfigAltResp> format which has all values
1391 filled in for the names in the Request string.
1392 String to be allocated by the called function.
1394 @retval EFI_SUCCESS The Results string is filled with the
1395 values corresponding to all requested
1397 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1398 parts of the results that must be
1399 stored awaiting possible future
1401 @retval EFI_INVALID_PARAMETER For example, passing in a NULL
1402 for the Request parameter
1403 would result in this type of
1404 error. In this case, the
1405 Progress parameter would be
1407 @retval EFI_NOT_FOUND Routing data doesn't match any
1408 known driver. Progress set to the
1409 first character in the routing header.
1410 Note: There is no requirement that the
1411 driver validate the routing data. It
1412 must skip the <ConfigHdr> in order to
1414 @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set
1415 to most recent & before the
1416 error or the beginning of the
1418 @retval EFI_INVALID_PARAMETER Unknown name. Progress points
1419 to the & before the name in
1420 question. Currently not implemented.
1424 Ip6FormExtractConfig (
1425 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1426 IN CONST EFI_STRING Request
,
1427 OUT EFI_STRING
*Progress
,
1428 OUT EFI_STRING
*Results
1433 IP6_FORM_CALLBACK_INFO
*Private
;
1434 IP6_CONFIG_INSTANCE
*Ip6ConfigInstance
;
1435 IP6_CONFIG_IFR_NVDATA
*IfrNvData
;
1436 EFI_STRING ConfigRequestHdr
;
1437 EFI_STRING ConfigRequest
;
1438 BOOLEAN AllocatedRequest
;
1442 if (This
== NULL
|| Progress
== NULL
|| Results
== NULL
) {
1443 return EFI_INVALID_PARAMETER
;
1446 *Progress
= Request
;
1447 if ((Request
!= NULL
) &&
1448 !HiiIsConfigHdrMatch (Request
, &gIp6ConfigNvDataGuid
, mIp6ConfigStorageName
)) {
1449 return EFI_NOT_FOUND
;
1452 ConfigRequestHdr
= NULL
;
1453 ConfigRequest
= NULL
;
1454 AllocatedRequest
= FALSE
;
1457 Private
= IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This
);
1458 Ip6ConfigInstance
= IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private
);
1459 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1461 IfrNvData
= (IP6_CONFIG_IFR_NVDATA
*) AllocateZeroPool (BufferSize
);
1462 if (IfrNvData
== NULL
) {
1463 return EFI_OUT_OF_RESOURCES
;
1466 Status
= Ip6ConvertConfigNvDataToIfrNvData (IfrNvData
, Ip6ConfigInstance
);
1467 if (EFI_ERROR (Status
)) {
1471 ConfigRequest
= Request
;
1472 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
1474 // Request has no request element, construct full request string.
1475 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
1476 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator.
1478 ConfigRequestHdr
= HiiConstructConfigHdr (
1479 &gIp6ConfigNvDataGuid
,
1480 mIp6ConfigStorageName
,
1481 Private
->ChildHandle
1483 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
1484 ConfigRequest
= AllocateZeroPool (Size
);
1485 ASSERT (ConfigRequest
!= NULL
);
1486 AllocatedRequest
= TRUE
;
1490 L
"%s&OFFSET=0&WIDTH=%016LX",
1494 FreePool (ConfigRequestHdr
);
1498 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
1500 Status
= gHiiConfigRouting
->BlockToConfig (
1503 (UINT8
*) IfrNvData
,
1510 FreePool (IfrNvData
);
1512 // Free the allocated config request string.
1514 if (AllocatedRequest
) {
1515 FreePool (ConfigRequest
);
1516 ConfigRequest
= NULL
;
1519 // Set Progress string to the original request string.
1521 if (Request
== NULL
) {
1523 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
1524 *Progress
= Request
+ StrLen (Request
);
1531 This function applies changes in a driver's configuration.
1532 Input is a Configuration, which has the routing data for this
1533 driver followed by name / value configuration pairs. The driver
1534 must apply those pairs to its configurable storage. If the
1535 driver's configuration is stored in a linear block of data
1536 and the driver's name / value pairs are in <BlockConfig>
1537 format, it may use the ConfigToBlock helper function (above) to
1538 simplify the job. Currently not implemented.
1540 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1541 @param[in] Configuration A null-terminated Unicode string in
1542 <ConfigString> format.
1543 @param[out] Progress A pointer to a string filled in with the
1544 offset of the most recent '&' before the
1545 first failing name / value pair (or the
1546 beginn ing of the string if the failure
1547 is in the first name / value pair) or
1548 the terminating NULL if all was
1551 @retval EFI_SUCCESS The results have been distributed or are
1552 awaiting distribution.
1553 @retval EFI_OUT_OF_MEMORY Not enough memory to store the
1554 parts of the results that must be
1555 stored awaiting possible future
1557 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1558 Results parameter would result
1559 in this type of error.
1560 @retval EFI_NOT_FOUND Target for the specified routing data
1565 Ip6FormRouteConfig (
1566 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1567 IN CONST EFI_STRING Configuration
,
1568 OUT EFI_STRING
*Progress
1571 if (This
== NULL
|| Configuration
== NULL
|| Progress
== NULL
) {
1572 return EFI_INVALID_PARAMETER
;
1576 // Check routing data in <ConfigHdr>.
1577 // Note: if only one Storage is used, then this checking could be skipped.
1579 if (!HiiIsConfigHdrMatch (Configuration
, &gIp6ConfigNvDataGuid
, mIp6ConfigStorageName
)) {
1580 *Progress
= Configuration
;
1581 return EFI_NOT_FOUND
;
1584 *Progress
= Configuration
+ StrLen (Configuration
);
1590 This function is called to provide results data to the driver.
1591 This data consists of a unique key that is used to identify
1592 which data is either being passed back or being asked for.
1594 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1595 @param[in] Action Specifies the type of action taken by the browser.
1596 @param[in] QuestionId A unique value which is sent to the original
1597 exporting driver so that it can identify the type
1598 of data to expect. The format of the data tends to
1599 vary based on the opcode that generated the callback.
1600 @param[in] Type The type of value for the question.
1601 @param[in] Value A pointer to the data being sent to the original
1603 @param[out] ActionRequest On return, points to the action requested by the
1606 @retval EFI_SUCCESS The callback successfully handled the action.
1607 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
1608 variable and its data.
1609 @retval EFI_DEVICE_ERROR The variable could not be saved.
1610 @retval EFI_UNSUPPORTED The specified Action is not supported by the
1611 callback. Currently not implemented.
1612 @retval EFI_INVALID_PARAMETER Passed in the wrong parameter.
1613 @retval Others Other errors as indicated.
1619 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1620 IN EFI_BROWSER_ACTION Action
,
1621 IN EFI_QUESTION_ID QuestionId
,
1623 IN EFI_IFR_TYPE_VALUE
*Value
,
1624 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1627 IP6_FORM_CALLBACK_INFO
*Private
;
1629 IP6_CONFIG_IFR_NVDATA
*IfrNvData
;
1630 IP6_CONFIG_IFR_NVDATA OldIfrNvData
;
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 ZeroMem (&OldIfrNvData
, BufferSize
);
1676 HiiGetBrowserData (NULL
, NULL
, BufferSize
, (UINT8
*) IfrNvData
);
1678 CopyMem (&OldIfrNvData
, IfrNvData
, BufferSize
);
1680 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
1681 switch (QuestionId
) {
1682 case KEY_GET_CURRENT_SETTING
:
1683 Ip6Config
= &Instance
->Ip6Config
;
1684 HiiHandle
= Instance
->CallbackInfo
.RegisteredHandle
;
1688 // Get current interface info.
1690 Status
= Ip6ConfigNvGetData (
1692 Ip6ConfigDataTypeInterfaceInfo
,
1696 if (EFI_ERROR (Status
)) {
1701 // Generate dynamic text opcode for host address and draw it.
1703 IfInfo
= (EFI_IP6_CONFIG_INTERFACE_INFO
*) Data
;
1704 Status
= Ip6ConvertAddressListToString (
1707 Ip6ConfigNvHostAddress
,
1708 IfInfo
->AddressInfo
,
1709 IfInfo
->AddressInfoCount
1711 if (EFI_ERROR (Status
)) {
1717 // Generate the dynamic text opcode for route table and draw it.
1719 Status
= Ip6ConvertAddressListToString (
1722 Ip6ConfigNvRouteTable
,
1726 if (EFI_ERROR (Status
)) {
1732 // Get DNS server list.
1737 Status
= Ip6ConfigNvGetData (
1739 Ip6ConfigDataTypeDnsServer
,
1743 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1752 // Generate the dynamic text opcode for DNS server and draw it.
1754 Status
= Ip6ConvertAddressListToString (
1757 Ip6ConfigNvDnsAddress
,
1759 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1761 if (EFI_ERROR (Status
)) {
1768 // Get gateway adderss list.
1776 Status
= Ip6ConfigNvGetData (
1778 Ip6ConfigDataTypeGateway
,
1782 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_FOUND
)) {
1791 // Generate the dynamic text opcode for gateway and draw it.
1793 Status
= Ip6ConvertAddressListToString (
1796 Ip6ConfigNvGatewayAddress
,
1798 DataSize
/ sizeof (EFI_IPv6_ADDRESS
)
1800 if (EFI_ERROR (Status
)) {
1810 Status
= EFI_SUCCESS
;
1817 } else if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
1818 switch (QuestionId
) {
1819 case KEY_SAVE_CONFIG_CHANGES
:
1820 CopyMem (&OldIfrNvData
, IfrNvData
, sizeof (IP6_CONFIG_IFR_NVDATA
));
1821 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
;
1824 case KEY_IGNORE_CONFIG_CHANGES
:
1825 CopyMem (IfrNvData
, &OldIfrNvData
, sizeof (IP6_CONFIG_IFR_NVDATA
));
1826 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
;
1829 case KEY_SAVE_CHANGES
:
1830 Status
= Ip6ConvertIfrNvDataToConfigNvData (IfrNvData
, Instance
);
1831 if (EFI_ERROR (Status
)) {
1834 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
1837 case KEY_INTERFACE_ID
:
1838 Status
= Ip6ParseInterfaceIdFromString (IfrNvData
->InterfaceId
, &Ip6NvData
->InterfaceId
);
1839 if (EFI_ERROR (Status
)) {
1841 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1843 L
"Invalid Interface ID!",
1850 case KEY_MANUAL_ADDRESS
:
1851 Status
= Ip6ParseAddressListFromString (
1852 IfrNvData
->ManualAddress
,
1853 &Ip6NvData
->ManualAddress
,
1854 &Ip6NvData
->ManualAddressCount
1856 if (EFI_ERROR (Status
)) {
1858 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1860 L
"Invalid Host Addresses!",
1867 case KEY_GATEWAY_ADDRESS
:
1868 Status
= Ip6ParseAddressListFromString (
1869 IfrNvData
->GatewayAddress
,
1870 &Ip6NvData
->GatewayAddress
,
1871 &Ip6NvData
->GatewayAddressCount
1873 if (EFI_ERROR (Status
)) {
1875 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1877 L
"Invalid Gateway Addresses!",
1884 case KEY_DNS_ADDRESS
:
1885 Status
= Ip6ParseAddressListFromString (
1886 IfrNvData
->DnsAddress
,
1887 &Ip6NvData
->DnsAddress
,
1888 &Ip6NvData
->DnsAddressCount
1890 if (EFI_ERROR (Status
)) {
1892 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1894 L
"Invalid DNS Addresses!",
1906 if (!EFI_ERROR (Status
)) {
1908 // Pass changed uncommitted data back to Form Browser.
1910 BufferSize
= sizeof (IP6_CONFIG_IFR_NVDATA
);
1911 HiiSetBrowserData (NULL
, NULL
, BufferSize
, (UINT8
*) IfrNvData
, NULL
);
1914 FreePool (IfrNvData
);
1919 Install HII Config Access protocol for network device and allocate resources.
1921 @param[in, out] Instance The IP6_CONFIG_INSTANCE to create a form.
1923 @retval EFI_SUCCESS The HII Config Access protocol is installed.
1924 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
1925 @retval Others Other errors as indicated.
1930 IN OUT IP6_CONFIG_INSTANCE
*Instance
1935 IP6_FORM_CALLBACK_INFO
*CallbackInfo
;
1936 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
1937 VENDOR_DEVICE_PATH VendorDeviceNode
;
1938 EFI_SERVICE_BINDING_PROTOCOL
*MnpSb
;
1940 CHAR16 MenuString
[128];
1941 CHAR16 PortString
[128];
1942 CHAR16
*OldMenuString
;
1943 EFI_DEVICE_PATH_PROTOCOL
*ParentDevicePath
;
1945 IpSb
= IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance
);
1946 ASSERT (IpSb
!= NULL
);
1948 Status
= gBS
->HandleProtocol (
1950 &gEfiDevicePathProtocolGuid
,
1951 (VOID
**) &ParentDevicePath
1953 if (EFI_ERROR (Status
)) {
1957 CallbackInfo
= &Instance
->CallbackInfo
;
1958 CallbackInfo
->Signature
= IP6_FORM_CALLBACK_INFO_SIGNATURE
;
1961 // Construct device path node for EFI HII Config Access protocol,
1962 // which consists of controller physical device path and one hardware
1963 // vendor guid node.
1965 ZeroMem (&VendorDeviceNode
, sizeof (VENDOR_DEVICE_PATH
));
1966 VendorDeviceNode
.Header
.Type
= HARDWARE_DEVICE_PATH
;
1967 VendorDeviceNode
.Header
.SubType
= HW_VENDOR_DP
;
1969 CopyGuid (&VendorDeviceNode
.Guid
, &gEfiCallerIdGuid
);
1971 SetDevicePathNodeLength (&VendorDeviceNode
.Header
, sizeof (VENDOR_DEVICE_PATH
));
1972 CallbackInfo
->HiiVendorDevicePath
= AppendDevicePathNode (
1974 (EFI_DEVICE_PATH_PROTOCOL
*) &VendorDeviceNode
1976 if (CallbackInfo
->HiiVendorDevicePath
== NULL
) {
1977 Status
= EFI_OUT_OF_RESOURCES
;
1981 ConfigAccess
= &CallbackInfo
->HiiConfigAccess
;
1982 ConfigAccess
->ExtractConfig
= Ip6FormExtractConfig
;
1983 ConfigAccess
->RouteConfig
= Ip6FormRouteConfig
;
1984 ConfigAccess
->Callback
= Ip6FormCallback
;
1987 // Install Device Path Protocol and Config Access protocol on new handle
1989 Status
= gBS
->InstallMultipleProtocolInterfaces (
1990 &CallbackInfo
->ChildHandle
,
1991 &gEfiDevicePathProtocolGuid
,
1992 CallbackInfo
->HiiVendorDevicePath
,
1993 &gEfiHiiConfigAccessProtocolGuid
,
1997 if (!EFI_ERROR (Status
)) {
1999 // Open the Parent Handle for the child
2001 Status
= gBS
->OpenProtocol (
2003 &gEfiManagedNetworkServiceBindingProtocolGuid
,
2006 CallbackInfo
->ChildHandle
,
2007 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
2011 if (EFI_ERROR (Status
)) {
2016 // Publish our HII data
2018 CallbackInfo
->RegisteredHandle
= HiiAddPackages (
2019 &gIp6ConfigNvDataGuid
,
2020 CallbackInfo
->ChildHandle
,
2025 if (CallbackInfo
->RegisteredHandle
== NULL
) {
2026 Status
= EFI_OUT_OF_RESOURCES
;
2031 // Append MAC string in the menu help string and tile help string
2033 Status
= NetLibGetMacString (IpSb
->Controller
, IpSb
->Image
, &MacString
);
2034 if (!EFI_ERROR (Status
)) {
2035 OldMenuString
= HiiGetString (
2036 CallbackInfo
->RegisteredHandle
,
2037 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP
),
2040 UnicodeSPrint (MenuString
, 128, L
"%s (MAC:%s)", OldMenuString
, MacString
);
2042 CallbackInfo
->RegisteredHandle
,
2043 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP
),
2047 UnicodeSPrint (PortString
, 128, L
"MAC:%s", MacString
);
2049 CallbackInfo
->RegisteredHandle
,
2050 STRING_TOKEN (STR_IP6_DEVICE_FORM_HELP
),
2055 FreePool (MacString
);
2056 FreePool (OldMenuString
);
2058 InitializeListHead (&Instance
->Ip6NvData
.ManualAddress
);
2059 InitializeListHead (&Instance
->Ip6NvData
.GatewayAddress
);
2060 InitializeListHead (&Instance
->Ip6NvData
.DnsAddress
);
2066 Ip6ConfigFormUnload (Instance
);
2071 Uninstall the HII Config Access protocol for network devices and free up the resources.
2073 @param[in, out] Instance The IP6_CONFIG_INSTANCE to unload a form.
2077 Ip6ConfigFormUnload (
2078 IN OUT IP6_CONFIG_INSTANCE
*Instance
2082 IP6_FORM_CALLBACK_INFO
*CallbackInfo
;
2083 IP6_CONFIG_NVDATA
*Ip6NvData
;
2085 IpSb
= IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance
);
2086 ASSERT (IpSb
!= NULL
);
2088 CallbackInfo
= &Instance
->CallbackInfo
;
2090 if (CallbackInfo
->ChildHandle
!= NULL
) {
2093 // Close the child handle
2095 gBS
->CloseProtocol (
2097 &gEfiManagedNetworkServiceBindingProtocolGuid
,
2099 CallbackInfo
->ChildHandle
2102 // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
2104 gBS
->UninstallMultipleProtocolInterfaces (
2105 CallbackInfo
->ChildHandle
,
2106 &gEfiDevicePathProtocolGuid
,
2107 CallbackInfo
->HiiVendorDevicePath
,
2108 &gEfiHiiConfigAccessProtocolGuid
,
2109 &CallbackInfo
->HiiConfigAccess
,
2114 if (CallbackInfo
->HiiVendorDevicePath
!= NULL
) {
2115 FreePool (CallbackInfo
->HiiVendorDevicePath
);
2118 if (CallbackInfo
->RegisteredHandle
!= NULL
) {
2120 // Remove HII package list
2122 HiiRemovePackages (CallbackInfo
->RegisteredHandle
);
2125 Ip6NvData
= &Instance
->Ip6NvData
;
2127 Ip6FreeAddressInfoList (&Ip6NvData
->ManualAddress
);
2128 Ip6FreeAddressInfoList (&Ip6NvData
->GatewayAddress
);
2129 Ip6FreeAddressInfoList (&Ip6NvData
->DnsAddress
);
2131 Ip6NvData
->ManualAddressCount
= 0;
2132 Ip6NvData
->GatewayAddressCount
= 0;
2133 Ip6NvData
->DnsAddressCount
= 0;