TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip6ConfigNv.c
Go to the documentation of this file.
1
10#include "Ip6Impl.h"
11
12CHAR16 mIp6ConfigStorageName[] = L"IP6_CONFIG_IFR_NVDATA";
13
21VOID
22EFIAPI
24 IN EFI_EVENT Event,
25 IN VOID *Context
26 )
27{
28 *((BOOLEAN *)Context) = TRUE;
29}
30
55 IN EFI_IP6_CONFIG_PROTOCOL *Ip6Config,
57 OUT UINTN *DataSize,
58 OUT VOID **Data
59 )
60{
61 UINTN BufferSize;
62 VOID *Buffer;
63 EFI_STATUS Status;
64
65 if ((Ip6Config == NULL) || (Data == NULL) || (DataSize == NULL)) {
66 return EFI_INVALID_PARAMETER;
67 }
68
69 BufferSize = 0;
70 Status = Ip6Config->GetData (
71 Ip6Config,
72 DataType,
73 &BufferSize,
74 NULL
75 );
76 if (Status != EFI_BUFFER_TOO_SMALL) {
77 return Status;
78 }
79
80 Buffer = AllocateZeroPool (BufferSize);
81 if (Buffer == NULL) {
82 return EFI_OUT_OF_RESOURCES;
83 }
84
85 Status = Ip6Config->GetData (
86 Ip6Config,
87 DataType,
88 &BufferSize,
89 Buffer
90 );
91 if (EFI_ERROR (Status)) {
92 FreePool (Buffer);
93 return Status;
94 }
95
96 *DataSize = BufferSize;
97 *Data = Buffer;
98
99 return EFI_SUCCESS;
100}
101
109VOID
111 IN LIST_ENTRY *ListHead
112 )
113{
115 LIST_ENTRY *Entry;
116 LIST_ENTRY *NextEntry;
117
118 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, ListHead) {
119 Node = NET_LIST_USER_STRUCT (Entry, IP6_ADDRESS_INFO_ENTRY, Link);
120 RemoveEntryList (&Node->Link);
121 FreePool (Node);
122 }
123}
124
132VOID
134 IN EFI_IPv6_ADDRESS *Ip6,
135 OUT CHAR16 *Str
136 )
137{
138 UINTN Index;
139 BOOLEAN Short;
140 UINTN Number;
141 CHAR16 FormatString[8];
142
143 Short = FALSE;
144
145 for (Index = 0; Index < 15; Index = Index + 2) {
146 if (!Short &&
147 (Index % 2 == 0) &&
148 (Ip6->Addr[Index] == 0) &&
149 (Ip6->Addr[Index + 1] == 0)
150 )
151 {
152 //
153 // Deal with the case of ::.
154 //
155 if (Index == 0) {
156 *Str = L':';
157 *(Str + 1) = L':';
158 Str = Str + 2;
159 } else {
160 *Str = L':';
161 Str = Str + 1;
162 }
163
164 while ((Index < 15) && (Ip6->Addr[Index] == 0) && (Ip6->Addr[Index + 1] == 0)) {
165 Index = Index + 2;
166 }
167
168 Short = TRUE;
169
170 if (Index == 16) {
171 //
172 // :: is at the end of the address.
173 //
174 *Str = L'\0';
175 break;
176 }
177 }
178
179 ASSERT (Index < 15);
180
181 if (Ip6->Addr[Index] == 0) {
182 Number = UnicodeSPrint (Str, 2 * IP6_STR_MAX_SIZE, L"%x:", (UINTN)Ip6->Addr[Index + 1]);
183 } else {
184 if (Ip6->Addr[Index + 1] < 0x10) {
185 CopyMem (FormatString, L"%x0%x:", StrSize (L"%x0%x:"));
186 } else {
187 CopyMem (FormatString, L"%x%x:", StrSize (L"%x%x:"));
188 }
189
190 Number = UnicodeSPrint (
191 Str,
192 2 * IP6_STR_MAX_SIZE,
193 (CONST CHAR16 *)FormatString,
194 (UINTN)Ip6->Addr[Index],
195 (UINTN)Ip6->Addr[Index + 1]
196 );
197 }
198
199 Str = Str + Number;
200
201 if (Index + 2 == 16) {
202 *Str = L'\0';
203 if (*(Str - 1) == L':') {
204 *(Str - 1) = L'\0';
205 }
206 }
207 }
208}
209
222 OUT CHAR16 *String,
224 )
225{
226 UINT8 Index;
227 UINTN Number;
228
229 if ((String == NULL) || (IfId == NULL)) {
230 return EFI_INVALID_PARAMETER;
231 }
232
233 for (Index = 0; Index < 8; Index++) {
234 Number = UnicodeSPrint (
235 String,
236 2 * INTERFACE_ID_STR_STORAGE,
237 L"%x:",
238 (UINTN)IfId->Id[Index]
239 );
240 String = String + Number;
241 }
242
243 *(String - 1) = '\0';
244
245 return EFI_SUCCESS;
246}
247
260 IN CONST CHAR16 *String,
262 )
263{
264 UINT8 Index;
265 CHAR16 *IfIdStr;
266 CHAR16 *TempStr;
267 UINTN NodeVal;
268
269 if ((String == NULL) || (IfId == NULL)) {
270 return EFI_INVALID_PARAMETER;
271 }
272
273 IfIdStr = (CHAR16 *)String;
274
275 ZeroMem (IfId, sizeof (EFI_IP6_CONFIG_INTERFACE_ID));
276
277 for (Index = 0; Index < 8; Index++) {
278 TempStr = IfIdStr;
279
280 while ((*IfIdStr != L'\0') && (*IfIdStr != L':')) {
281 IfIdStr++;
282 }
283
284 //
285 // The InterfaceId format is X:X:X:X, the number of X should not exceed 8.
286 // If the number of X is less than 8, zero is appended to the InterfaceId.
287 //
288 if ((*IfIdStr == ':') && (Index == 7)) {
289 return EFI_INVALID_PARAMETER;
290 }
291
292 //
293 // Convert the string to interface id. AsciiStrHexToUintn stops at the
294 // first character that is not a valid hex character, ':' or '\0' here.
295 //
296 NodeVal = StrHexToUintn (TempStr);
297 if (NodeVal > 0xFF) {
298 return EFI_INVALID_PARAMETER;
299 }
300
301 IfId->Id[Index] = (UINT8)NodeVal;
302
303 IfIdStr++;
304 }
305
306 return EFI_SUCCESS;
307}
308
327 IN UINT16 StartLabelNumber,
328 OUT VOID **StartOpCodeHandle,
329 OUT EFI_IFR_GUID_LABEL **StartLabel,
330 OUT VOID **EndOpCodeHandle,
331 OUT EFI_IFR_GUID_LABEL **EndLabel
332 )
333{
334 EFI_STATUS Status;
335 EFI_IFR_GUID_LABEL *InternalStartLabel;
336 EFI_IFR_GUID_LABEL *InternalEndLabel;
337
338 if ((StartOpCodeHandle == NULL) || (StartLabel == NULL) || (EndOpCodeHandle == NULL) || (EndLabel == NULL)) {
339 return EFI_INVALID_PARAMETER;
340 }
341
342 *StartOpCodeHandle = NULL;
343 *EndOpCodeHandle = NULL;
344 Status = EFI_OUT_OF_RESOURCES;
345
346 //
347 // Initialize the container for dynamic opcodes.
348 //
349 *StartOpCodeHandle = HiiAllocateOpCodeHandle ();
350 if (*StartOpCodeHandle == NULL) {
351 return Status;
352 }
353
354 *EndOpCodeHandle = HiiAllocateOpCodeHandle ();
355 if (*EndOpCodeHandle == NULL) {
356 goto Exit;
357 }
358
359 //
360 // Create Hii Extend Label OpCode as the start opcode.
361 //
362 InternalStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
363 *StartOpCodeHandle,
364 &gEfiIfrTianoGuid,
365 NULL,
366 sizeof (EFI_IFR_GUID_LABEL)
367 );
368 if (InternalStartLabel == NULL) {
369 goto Exit;
370 }
371
372 InternalStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
373 InternalStartLabel->Number = StartLabelNumber;
374
375 //
376 // Create Hii Extend Label OpCode as the end opcode.
377 //
378 InternalEndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
379 *EndOpCodeHandle,
380 &gEfiIfrTianoGuid,
381 NULL,
382 sizeof (EFI_IFR_GUID_LABEL)
383 );
384 if (InternalEndLabel == NULL) {
385 goto Exit;
386 }
387
388 InternalEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
389 InternalEndLabel->Number = LABEL_END;
390
391 *StartLabel = InternalStartLabel;
392 *EndLabel = InternalEndLabel;
393
394 return EFI_SUCCESS;
395
396Exit:
397
398 if (*StartOpCodeHandle != NULL) {
399 HiiFreeOpCodeHandle (*StartOpCodeHandle);
400 }
401
402 if (*EndOpCodeHandle != NULL) {
403 HiiFreeOpCodeHandle (*EndOpCodeHandle);
404 }
405
406 return Status;
407}
408
433 IN OUT CHAR16 *String,
434 IN EFI_HII_HANDLE HiiHandle,
435 IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType,
436 IN VOID *AddressInfo,
437 IN UINTN AddressCount
438 )
439{
440 UINTN Index;
441 UINTN Number;
442 CHAR16 *TempStr;
443 EFI_STATUS Status;
444 VOID *StartOpCodeHandle;
445 EFI_IFR_GUID_LABEL *StartLabel;
446 VOID *EndOpCodeHandle;
447 EFI_IFR_GUID_LABEL *EndLabel;
448 UINT16 StartLabelNumber;
449 EFI_STRING_ID TextTwo;
450 UINT8 *AddressHead;
451 UINT8 PrefixLength;
452 EFI_IPv6_ADDRESS *Address;
453
454 if ((String == NULL) || (HiiHandle == NULL) || (AddressInfo == NULL)) {
455 return EFI_INVALID_PARAMETER;
456 }
457
458 if (AddressType == Ip6ConfigNvHostAddress) {
459 StartLabelNumber = HOST_ADDRESS_LABEL;
460 } else if (AddressType == Ip6ConfigNvGatewayAddress) {
461 StartLabelNumber = GATEWAY_ADDRESS_LABEL;
462 } else if (AddressType == Ip6ConfigNvDnsAddress) {
463 StartLabelNumber = DNS_ADDRESS_LABEL;
464 } else if (AddressType == Ip6ConfigNvRouteTable) {
465 StartLabelNumber = ROUTE_TABLE_LABEL;
466 } else {
467 ASSERT (FALSE);
468 return EFI_UNSUPPORTED;
469 }
470
471 Status = Ip6CreateOpCode (
472 StartLabelNumber,
473 &StartOpCodeHandle,
474 &StartLabel,
475 &EndOpCodeHandle,
476 &EndLabel
477 );
478 if (EFI_ERROR (Status)) {
479 return Status;
480 }
481
482 AddressHead = (UINT8 *)AddressInfo;
483
484 for (Index = 0; Index < AddressCount; Index++) {
485 if (AddressType == Ip6ConfigNvHostAddress) {
486 AddressInfo = AddressHead + sizeof (EFI_IP6_ADDRESS_INFO) * Index;
487 Address = &((EFI_IP6_ADDRESS_INFO *)AddressInfo)->Address;
488 } else if (AddressType == Ip6ConfigNvRouteTable) {
489 AddressInfo = AddressHead + sizeof (EFI_IP6_ROUTE_TABLE) * Index;
490 Address = &((EFI_IP6_ROUTE_TABLE *)AddressInfo)->Destination;
491 } else {
492 AddressInfo = AddressHead + sizeof (EFI_IPv6_ADDRESS) * Index;
493 Address = AddressInfo;
494 }
495
496 //
497 // Convert the IP address info to string.
498 //
499 Ip6ToStr (Address, String);
500 TempStr = String + StrLen (String);
501
502 if ((AddressType == Ip6ConfigNvHostAddress) || (AddressType == Ip6ConfigNvRouteTable)) {
503 if (AddressType == Ip6ConfigNvHostAddress) {
504 PrefixLength = ((EFI_IP6_ADDRESS_INFO *)AddressInfo)->PrefixLength;
505 } else {
506 PrefixLength = ((EFI_IP6_ROUTE_TABLE *)AddressInfo)->PrefixLength;
507 }
508
509 //
510 // Append the prefix length to the string.
511 //
512 *TempStr = L'/';
513 TempStr++;
514 Number = UnicodeSPrint (TempStr, 6, L"%d", PrefixLength);
515 TempStr = TempStr + Number;
516 }
517
518 if (AddressType == Ip6ConfigNvRouteTable) {
519 //
520 // Append " >> " to the string.
521 //
522 Number = UnicodeSPrint (TempStr, 8, L" >> ");
523 TempStr = TempStr + Number;
524
525 //
526 // Append the gateway address to the string.
527 //
528 Ip6ToStr (&((EFI_IP6_ROUTE_TABLE *)AddressInfo)->Gateway, TempStr);
529 TempStr = TempStr + StrLen (TempStr);
530 }
531
532 //
533 // Generate a text opcode and update the UI.
534 //
535 TextTwo = HiiSetString (HiiHandle, 0, String, NULL);
536 if (TextTwo == 0) {
537 Status = EFI_INVALID_PARAMETER;
538 goto Exit;
539 }
540
541 HiiCreateTextOpCode (StartOpCodeHandle, STR_NULL, STR_NULL, TextTwo);
542
543 String = TempStr;
544 *String = IP6_ADDRESS_DELIMITER;
545 String++;
546 }
547
548 *(String - 1) = '\0';
549
550 Status = HiiUpdateForm (
551 HiiHandle, // HII handle
552 &gIp6ConfigNvDataGuid, // Formset GUID
553 FORMID_MAIN_FORM, // Form ID
554 StartOpCodeHandle, // Label for where to insert opcodes
555 EndOpCodeHandle // Replace data
556 );
557
558Exit:
559 HiiFreeOpCodeHandle (StartOpCodeHandle);
560 HiiFreeOpCodeHandle (EndOpCodeHandle);
561
562 return Status;
563}
564
580 IN CONST CHAR16 *String,
581 OUT LIST_ENTRY *ListHead,
582 OUT UINT32 *AddressCount
583 )
584{
585 EFI_STATUS Status;
586 CHAR16 *LocalString;
587 CHAR16 *Temp;
588 CHAR16 *TempStr;
589 EFI_IP6_ADDRESS_INFO AddressInfo;
591 BOOLEAN Last;
592 UINT32 Count;
593
594 if ((String == NULL) || (ListHead == NULL) || (AddressCount == NULL)) {
595 return EFI_INVALID_PARAMETER;
596 }
597
598 ZeroMem (&AddressInfo, sizeof (EFI_IP6_ADDRESS_INFO));
599 LocalString = (CHAR16 *)AllocateCopyPool (StrSize (String), String);
600 if (LocalString == NULL) {
601 return EFI_OUT_OF_RESOURCES;
602 }
603
604 //
605 // Clean the original address list.
606 //
607 Ip6FreeAddressInfoList (ListHead);
608
609 Temp = LocalString;
610 Last = FALSE;
611 Count = 0;
612
613 while (*LocalString != L'\0') {
614 TempStr = LocalString;
615 while ((*LocalString != L'\0') && (*LocalString != IP6_ADDRESS_DELIMITER)) {
616 LocalString++;
617 }
618
619 if (*LocalString == L'\0') {
620 Last = TRUE;
621 }
622
623 *LocalString = L'\0';
624
625 Status = NetLibStrToIp6andPrefix (TempStr, &AddressInfo.Address, &AddressInfo.PrefixLength);
626 if (EFI_ERROR (Status)) {
627 goto Error;
628 }
629
630 if (AddressInfo.PrefixLength == 0xFF) {
631 AddressInfo.PrefixLength = 0;
632 }
633
634 if (!NetIp6IsValidUnicast (&AddressInfo.Address)) {
635 Status = EFI_INVALID_PARAMETER;
636 goto Error;
637 }
638
639 Node = AllocatePool (sizeof (IP6_ADDRESS_INFO_ENTRY));
640 if (Node == NULL) {
641 Status = EFI_OUT_OF_RESOURCES;
642 goto Error;
643 }
644
645 CopyMem (&Node->AddrInfo, &AddressInfo, sizeof (EFI_IP6_ADDRESS_INFO));
646 InsertTailList (ListHead, &Node->Link);
647 Count++;
648
649 if (Last) {
650 break;
651 }
652
653 LocalString++;
654 }
655
656 FreePool (Temp);
657 *AddressCount = Count;
658 return EFI_SUCCESS;
659
660Error:
661 Ip6FreeAddressInfoList (ListHead);
662 FreePool (Temp);
663 return Status;
664}
665
684 IN EFI_HII_HANDLE HiiHandle,
685 IN OUT IP6_CONFIG_IFR_NVDATA *IfrNvData
686 )
687{
688 UINT32 Index;
689 UINTN Number;
690 CHAR16 *String;
691 CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
692 CHAR16 FormatString[8];
693 EFI_STRING_ID StringId;
694
695 if ((IfInfo == NULL) || (HiiHandle == NULL) || (IfrNvData == NULL)) {
696 return EFI_INVALID_PARAMETER;
697 }
698
699 //
700 // Print the interface name.
701 //
702 StringId = HiiSetString (
703 HiiHandle,
704 STRING_TOKEN (STR_IP6_INTERFACE_NAME_CONTENT),
705 IfInfo->Name,
706 NULL
707 );
708 if (StringId == 0) {
709 return EFI_OUT_OF_RESOURCES;
710 }
711
712 //
713 // Print the interface type.
714 //
715 if (IfInfo->IfType == Ip6InterfaceTypeEthernet) {
716 CopyMem (PortString, IP6_ETHERNET, sizeof (IP6_ETHERNET));
717 } else if (IfInfo->IfType == Ip6InterfaceTypeExperimentalEthernet) {
718 CopyMem (PortString, IP6_EXPERIMENTAL_ETHERNET, sizeof (IP6_EXPERIMENTAL_ETHERNET));
719 } else {
720 //
721 // Refer to RFC1700, chapter Number Hardware Type.
722 //
723 UnicodeSPrint (PortString, 6, L"%d", IfInfo->IfType);
724 }
725
726 StringId = HiiSetString (
727 HiiHandle,
728 STRING_TOKEN (STR_IP6_INTERFACE_TYPE_CONTENT),
729 PortString,
730 NULL
731 );
732 if (StringId == 0) {
733 return EFI_OUT_OF_RESOURCES;
734 }
735
736 //
737 // Convert the hardware address.
738 //
739 String = PortString;
740 ASSERT (IfInfo->HwAddressSize <= 32);
741
742 for (Index = 0; Index < IfInfo->HwAddressSize; Index++) {
743 if (IfInfo->HwAddress.Addr[Index] < 0x10) {
744 CopyMem (FormatString, L"0%x-", sizeof (L"0%x-"));
745 } else {
746 CopyMem (FormatString, L"%x-", sizeof (L"%x-"));
747 }
748
749 Number = UnicodeSPrint (
750 String,
751 8,
752 (CONST CHAR16 *)FormatString,
753 (UINTN)IfInfo->HwAddress.Addr[Index]
754 );
755 String = String + Number;
756 }
757
758 if (Index != 0) {
759 ASSERT (String > PortString);
760 String--;
761 *String = '\0';
762 }
763
764 //
765 // Print the hardware address.
766 //
767 StringId = HiiSetString (
768 HiiHandle,
769 STRING_TOKEN (STR_IP6_MAC_ADDRESS_CONTENT),
770 PortString,
771 NULL
772 );
773 if (StringId == 0) {
774 return EFI_OUT_OF_RESOURCES;
775 }
776
777 return EFI_SUCCESS;
778}
779
795 IN IP6_CONFIG_INSTANCE *Instance,
796 IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType,
797 OUT VOID **AddressInfo,
798 OUT UINTN *AddressSize
799 )
800{
801 IP6_CONFIG_NVDATA *Ip6NvData;
802 LIST_ENTRY *Entry;
803 LIST_ENTRY *ListHead;
805 VOID *AddressList;
806 VOID *TmpStr;
807 UINTN DataSize;
808 EFI_IPv6_ADDRESS *Ip6Address;
809 EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
810
811 if ((Instance == NULL) || (AddressInfo == NULL) || (AddressSize == NULL)) {
812 return EFI_INVALID_PARAMETER;
813 }
814
815 NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
816
817 Ip6NvData = &Instance->Ip6NvData;
818
819 if (AddressType == Ip6ConfigNvHostAddress) {
820 ListHead = &Ip6NvData->ManualAddress;
821 DataSize = sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS) * Ip6NvData->ManualAddressCount;
822 } else if (AddressType == Ip6ConfigNvGatewayAddress) {
823 ListHead = &Ip6NvData->GatewayAddress;
824 DataSize = sizeof (EFI_IPv6_ADDRESS) * Ip6NvData->GatewayAddressCount;
825 } else if (AddressType == Ip6ConfigNvDnsAddress) {
826 ListHead = &Ip6NvData->DnsAddress;
827 DataSize = sizeof (EFI_IPv6_ADDRESS) * Ip6NvData->DnsAddressCount;
828 } else {
829 return EFI_UNSUPPORTED;
830 }
831
832 AddressList = AllocateZeroPool (DataSize);
833 if (AddressList == NULL) {
834 return EFI_OUT_OF_RESOURCES;
835 }
836
837 TmpStr = AddressList;
838
839 NET_LIST_FOR_EACH (Entry, ListHead) {
840 Node = NET_LIST_USER_STRUCT (Entry, IP6_ADDRESS_INFO_ENTRY, Link);
841 if (AddressType == Ip6ConfigNvHostAddress) {
842 ManualAddress = (EFI_IP6_CONFIG_MANUAL_ADDRESS *)AddressList;
843 IP6_COPY_ADDRESS (&ManualAddress->Address, &Node->AddrInfo.Address);
844 ManualAddress->PrefixLength = Node->AddrInfo.PrefixLength;
845 AddressList = (UINT8 *)AddressList + sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS);
846 } else {
847 Ip6Address = (EFI_IPv6_ADDRESS *)AddressList;
848 IP6_COPY_ADDRESS (Ip6Address, &Node->AddrInfo.Address);
849 AddressList = (UINT8 *)AddressList + sizeof (EFI_IPv6_ADDRESS);
850 }
851 }
852
853 *AddressInfo = TmpStr;
854 *AddressSize = DataSize;
855 return EFI_SUCCESS;
856}
857
872 IN OUT IP6_CONFIG_IFR_NVDATA *IfrNvData,
873 IN IP6_CONFIG_INSTANCE *Instance
874 )
875{
876 IP6_CONFIG_NVDATA *Ip6NvData;
877 EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
878 UINTN DataSize;
879 VOID *Data;
880 EFI_STATUS Status;
883 EFI_HII_HANDLE HiiHandle;
884
885 if ((IfrNvData == NULL) || (Instance == NULL)) {
886 return EFI_INVALID_PARAMETER;
887 }
888
889 NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
890
891 Ip6Config = &Instance->Ip6Config;
892 Ip6NvData = &Instance->Ip6NvData;
893 Data = NULL;
894 DataSize = 0;
895 HiiHandle = Instance->CallbackInfo.RegisteredHandle;
896
897 //
898 // Get the current interface info.
899 //
900 Status = Ip6ConfigNvGetData (
901 Ip6Config,
903 &DataSize,
904 (VOID **)&Data
905 );
906 if (EFI_ERROR (Status)) {
907 goto Exit;
908 }
909
910 //
911 // Convert the interface info to string and print.
912 //
915 HiiHandle,
916 IfrNvData
917 );
918 if (EFI_ERROR (Status)) {
919 goto Exit;
920 }
921
922 //
923 // Get the interface id.
924 //
925 DataSize = sizeof (EFI_IP6_CONFIG_INTERFACE_ID);
926 ZeroMem (&Ip6NvData->InterfaceId, DataSize);
927 Status = Ip6Config->GetData (
928 Ip6Config,
930 &DataSize,
931 &Ip6NvData->InterfaceId
932 );
933 if (EFI_ERROR (Status)) {
934 goto Exit;
935 }
936
937 Ip6ConvertInterfaceIdToString (IfrNvData->InterfaceId, &Ip6NvData->InterfaceId);
938
939 //
940 // Get current policy.
941 //
942 DataSize = sizeof (EFI_IP6_CONFIG_POLICY);
943 Status = Ip6Config->GetData (
944 Ip6Config,
946 &DataSize,
947 &Policy
948 );
949
950 if (EFI_ERROR (Status)) {
951 goto Exit;
952 }
953
954 if (Policy == Ip6ConfigPolicyManual) {
955 IfrNvData->Policy = IP6_POLICY_MANUAL;
956 } else if (Policy == Ip6ConfigPolicyAutomatic) {
957 IfrNvData->Policy = IP6_POLICY_AUTO;
958 } else {
959 ASSERT (FALSE);
960 Status = EFI_UNSUPPORTED;
961 goto Exit;
962 }
963
964 //
965 // Get Duplicate Address Detection Transmits count.
966 //
968 Status = Ip6Config->GetData (
969 Ip6Config,
971 &DataSize,
972 &DadXmits
973 );
974
975 if (EFI_ERROR (Status)) {
976 goto Exit;
977 }
978
979 IfrNvData->DadTransmitCount = DadXmits.DupAddrDetectTransmits;
980
981Exit:
982 if (Data != NULL) {
983 FreePool (Data);
984 }
985
986 return Status;
987}
988
1003 IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
1004 IN OUT IP6_CONFIG_INSTANCE *Instance
1005 )
1006{
1007 IP6_CONFIG_NVDATA *Ip6NvData;
1008 EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
1009 EFI_STATUS Status;
1010
1011 if ((IfrNvData == NULL) || (Instance == NULL)) {
1012 return EFI_INVALID_PARAMETER;
1013 }
1014
1015 NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
1016 Ip6NvData = &Instance->Ip6NvData;
1017 Ip6Config = &Instance->Ip6Config;
1018
1019 //
1020 // Update those fields which don't have INTERACTIVE attribute.
1021 //
1022 if (IfrNvData->Policy == IP6_POLICY_AUTO) {
1023 Ip6NvData->Policy = Ip6ConfigPolicyAutomatic;
1024 } else if (IfrNvData->Policy == IP6_POLICY_MANUAL) {
1025 Ip6NvData->Policy = Ip6ConfigPolicyManual;
1026 }
1027
1028 Ip6NvData->DadTransmitCount.DupAddrDetectTransmits = IfrNvData->DadTransmitCount;
1029
1030 //
1031 // Set the configured policy.
1032 //
1033 Status = Ip6Config->SetData (
1034 Ip6Config,
1036 sizeof (EFI_IP6_CONFIG_POLICY),
1037 &Ip6NvData->Policy
1038 );
1039 if (EFI_ERROR (Status)) {
1040 return Status;
1041 }
1042
1043 //
1044 // Set the duplicate address detection transmits count.
1045 //
1046 Status = Ip6Config->SetData (
1047 Ip6Config,
1050 &Ip6NvData->DadTransmitCount
1051 );
1052 if (EFI_ERROR (Status)) {
1053 return Status;
1054 }
1055
1056 //
1057 // Set the alternative interface ID
1058 //
1059 Status = Ip6Config->SetData (
1060 Ip6Config,
1063 &Ip6NvData->InterfaceId
1064 );
1065 if (EFI_ERROR (Status)) {
1066 return Status;
1067 }
1068
1069 return EFI_SUCCESS;
1070}
1071
1086 IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
1087 IN OUT IP6_CONFIG_INSTANCE *Instance
1088 )
1089{
1090 IP6_CONFIG_NVDATA *Ip6NvData;
1091 EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
1092 EFI_STATUS Status;
1093 EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
1094 EFI_IPv6_ADDRESS *Address;
1095 BOOLEAN IsAddressOk;
1096 EFI_EVENT SetAddressEvent;
1097 EFI_EVENT TimeoutEvent;
1098 UINTN DataSize;
1099
1100 if ((IfrNvData == NULL) || (Instance == NULL)) {
1101 return EFI_INVALID_PARAMETER;
1102 }
1103
1104 if (IfrNvData->Policy == IP6_POLICY_AUTO) {
1105 return EFI_SUCCESS;
1106 }
1107
1108 NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
1109 Ip6NvData = &Instance->Ip6NvData;
1110 Ip6Config = &Instance->Ip6Config;
1111
1112 //
1113 // Update those fields which don't have INTERACTIVE attribute.
1114 //
1115 Ip6NvData->Policy = Ip6ConfigPolicyManual;
1116
1117 //
1118 // Set the configured policy.
1119 //
1120 Status = Ip6Config->SetData (
1121 Ip6Config,
1123 sizeof (EFI_IP6_CONFIG_POLICY),
1124 &Ip6NvData->Policy
1125 );
1126 if (EFI_ERROR (Status)) {
1127 return Status;
1128 }
1129
1130 //
1131 // Create events & timers for asynchronous settings.
1132 //
1133 SetAddressEvent = NULL;
1134 TimeoutEvent = NULL;
1135 ManualAddress = NULL;
1136 Address = NULL;
1137
1138 Status = gBS->CreateEvent (
1139 EVT_NOTIFY_SIGNAL,
1140 TPL_NOTIFY,
1142 &IsAddressOk,
1143 &SetAddressEvent
1144 );
1145 if (EFI_ERROR (Status)) {
1146 goto Exit;
1147 }
1148
1149 Status = gBS->CreateEvent (
1150 EVT_TIMER,
1151 TPL_CALLBACK,
1152 NULL,
1153 NULL,
1154 &TimeoutEvent
1155 );
1156 if (EFI_ERROR (Status)) {
1157 goto Exit;
1158 }
1159
1160 //
1161 // Set the manual address list. This is an asynchronous process.
1162 //
1163 if (!IsListEmpty (&Ip6NvData->ManualAddress) && (Ip6NvData->ManualAddressCount != 0)) {
1164 Status = Ip6BuildNvAddressInfo (
1165 Instance,
1166 Ip6ConfigNvHostAddress,
1167 (VOID **)&ManualAddress,
1168 &DataSize
1169 );
1170 if (EFI_ERROR (Status)) {
1171 goto Exit;
1172 }
1173
1174 IsAddressOk = FALSE;
1175
1176 Status = Ip6Config->RegisterDataNotify (
1177 Ip6Config,
1179 SetAddressEvent
1180 );
1181 if (EFI_ERROR (Status)) {
1182 goto Exit;
1183 }
1184
1185 Status = Ip6Config->SetData (
1186 Ip6Config,
1188 DataSize,
1189 (VOID *)ManualAddress
1190 );
1191 if (Status == EFI_NOT_READY) {
1192 gBS->SetTimer (TimeoutEvent, TimerRelative, 50000000);
1193 while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
1194 if (IsAddressOk) {
1195 Status = EFI_SUCCESS;
1196 }
1197
1198 break;
1199 }
1200 }
1201
1202 Status = Ip6Config->UnregisterDataNotify (
1203 Ip6Config,
1205 SetAddressEvent
1206 );
1207 if (EFI_ERROR (Status)) {
1208 goto Exit;
1209 }
1210 }
1211
1212 //
1213 // Set gateway address list.
1214 //
1215 if (!IsListEmpty (&Ip6NvData->GatewayAddress) && (Ip6NvData->GatewayAddressCount != 0)) {
1216 Status = Ip6BuildNvAddressInfo (
1217 Instance,
1218 Ip6ConfigNvGatewayAddress,
1219 (VOID **)&Address,
1220 &DataSize
1221 );
1222 if (EFI_ERROR (Status)) {
1223 goto Exit;
1224 }
1225
1226 Status = Ip6Config->SetData (
1227 Ip6Config,
1229 DataSize,
1230 (VOID *)Address
1231 );
1232 if (EFI_ERROR (Status)) {
1233 goto Exit;
1234 }
1235
1236 FreePool (Address);
1237 Address = NULL;
1238 }
1239
1240 //
1241 // Set DNS server address list.
1242 //
1243 if (!IsListEmpty (&Ip6NvData->DnsAddress) && (Ip6NvData->DnsAddressCount != 0)) {
1244 Status = Ip6BuildNvAddressInfo (
1245 Instance,
1246 Ip6ConfigNvDnsAddress,
1247 (VOID **)&Address,
1248 &DataSize
1249 );
1250 if (EFI_ERROR (Status)) {
1251 goto Exit;
1252 }
1253
1254 Status = Ip6Config->SetData (
1255 Ip6Config,
1257 DataSize,
1258 (VOID *)Address
1259 );
1260 if (EFI_ERROR (Status)) {
1261 goto Exit;
1262 }
1263 }
1264
1265 Status = EFI_SUCCESS;
1266
1267Exit:
1268 if (SetAddressEvent != NULL) {
1269 gBS->CloseEvent (SetAddressEvent);
1270 }
1271
1272 if (TimeoutEvent != NULL) {
1273 gBS->CloseEvent (TimeoutEvent);
1274 }
1275
1276 if (ManualAddress != NULL) {
1277 FreePool (ManualAddress);
1278 }
1279
1280 if (Address != NULL) {
1281 FreePool (Address);
1282 }
1283
1284 return Status;
1285}
1286
1350EFIAPI
1353 IN CONST EFI_STRING Request,
1354 OUT EFI_STRING *Progress,
1355 OUT EFI_STRING *Results
1356 )
1357{
1358 EFI_STATUS Status;
1359 IP6_FORM_CALLBACK_INFO *Private;
1360 IP6_CONFIG_INSTANCE *Ip6ConfigInstance;
1361 IP6_CONFIG_IFR_NVDATA *IfrNvData;
1362 EFI_STRING ConfigRequestHdr;
1363 EFI_STRING ConfigRequest;
1364 BOOLEAN AllocatedRequest;
1365 UINTN Size;
1366 UINTN BufferSize;
1367
1368 if ((This == NULL) || (Progress == NULL) || (Results == NULL)) {
1369 return EFI_INVALID_PARAMETER;
1370 }
1371
1372 *Progress = Request;
1373 if ((Request != NULL) &&
1374 !HiiIsConfigHdrMatch (Request, &gIp6ConfigNvDataGuid, mIp6ConfigStorageName))
1375 {
1376 return EFI_NOT_FOUND;
1377 }
1378
1379 ConfigRequestHdr = NULL;
1380 ConfigRequest = NULL;
1381 AllocatedRequest = FALSE;
1382 Size = 0;
1383
1384 Private = IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
1385 Ip6ConfigInstance = IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private);
1386 BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
1387
1388 IfrNvData = (IP6_CONFIG_IFR_NVDATA *)AllocateZeroPool (BufferSize);
1389 if (IfrNvData == NULL) {
1390 return EFI_OUT_OF_RESOURCES;
1391 }
1392
1393 Status = Ip6ConvertConfigNvDataToIfrNvData (IfrNvData, Ip6ConfigInstance);
1394 if (EFI_ERROR (Status)) {
1395 goto Exit;
1396 }
1397
1398 ConfigRequest = Request;
1399 if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
1400 //
1401 // Request has no request element, construct full request string.
1402 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
1403 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator.
1404 //
1405 ConfigRequestHdr = HiiConstructConfigHdr (
1406 &gIp6ConfigNvDataGuid,
1407 mIp6ConfigStorageName,
1408 Private->ChildHandle
1409 );
1410 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
1411 ConfigRequest = AllocateZeroPool (Size);
1412 ASSERT (ConfigRequest != NULL);
1413 AllocatedRequest = TRUE;
1415 ConfigRequest,
1416 Size,
1417 L"%s&OFFSET=0&WIDTH=%016LX",
1418 ConfigRequestHdr,
1419 (UINT64)BufferSize
1420 );
1421 FreePool (ConfigRequestHdr);
1422 }
1423
1424 //
1425 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
1426 //
1427 Status = gHiiConfigRouting->BlockToConfig (
1429 ConfigRequest,
1430 (UINT8 *)IfrNvData,
1431 BufferSize,
1432 Results,
1433 Progress
1434 );
1435
1436Exit:
1437 FreePool (IfrNvData);
1438 //
1439 // Free the allocated config request string.
1440 //
1441 if (AllocatedRequest) {
1442 FreePool (ConfigRequest);
1443 ConfigRequest = NULL;
1444 }
1445
1446 //
1447 // Set Progress string to the original request string.
1448 //
1449 if (Request == NULL) {
1450 *Progress = NULL;
1451 } else if (StrStr (Request, L"OFFSET") == NULL) {
1452 *Progress = Request + StrLen (Request);
1453 }
1454
1455 return Status;
1456}
1457
1492EFIAPI
1495 IN CONST EFI_STRING Configuration,
1496 OUT EFI_STRING *Progress
1497 )
1498{
1499 if ((This == NULL) || (Configuration == NULL) || (Progress == NULL)) {
1500 return EFI_INVALID_PARAMETER;
1501 }
1502
1503 //
1504 // Check routing data in <ConfigHdr>.
1505 // Note: if only one Storage is used, then this checking could be skipped.
1506 //
1507 if (!HiiIsConfigHdrMatch (Configuration, &gIp6ConfigNvDataGuid, mIp6ConfigStorageName)) {
1508 *Progress = Configuration;
1509 return EFI_NOT_FOUND;
1510 }
1511
1512 *Progress = Configuration + StrLen (Configuration);
1513
1514 return EFI_SUCCESS;
1515}
1516
1529 IN IP6_CONFIG_INSTANCE *Instance
1530 )
1531{
1532 EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
1533 EFI_HII_HANDLE HiiHandle;
1535 UINTN DataSize;
1536 EFI_STATUS Status;
1537 CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
1539
1540 Ip6Config = &Instance->Ip6Config;
1541 HiiHandle = Instance->CallbackInfo.RegisteredHandle;
1542 Data = NULL;
1543
1544 //
1545 // Get current interface info.
1546 //
1547 Status = Ip6ConfigNvGetData (
1548 Ip6Config,
1550 &DataSize,
1551 (VOID **)&Data
1552 );
1553 if (EFI_ERROR (Status)) {
1554 return Status;
1555 }
1556
1557 //
1558 // Generate dynamic text opcode for host address and draw it.
1559 //
1560 IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *)Data;
1562 PortString,
1563 HiiHandle,
1564 Ip6ConfigNvHostAddress,
1565 IfInfo->AddressInfo,
1566 IfInfo->AddressInfoCount
1567 );
1568 if (EFI_ERROR (Status)) {
1569 FreePool (Data);
1570 return Status;
1571 }
1572
1573 //
1574 // Generate the dynamic text opcode for route table and draw it.
1575 //
1577 PortString,
1578 HiiHandle,
1579 Ip6ConfigNvRouteTable,
1580 IfInfo->RouteTable,
1581 IfInfo->RouteCount
1582 );
1583 if (EFI_ERROR (Status)) {
1584 FreePool (Data);
1585 return Status;
1586 }
1587
1588 //
1589 // Get DNS server list.
1590 //
1591 FreePool (Data);
1592 DataSize = 0;
1593 Data = NULL;
1594 Status = Ip6ConfigNvGetData (
1595 Ip6Config,
1597 &DataSize,
1598 (VOID **)&Data
1599 );
1600 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
1601 if (Data != NULL) {
1602 FreePool (Data);
1603 }
1604
1605 return Status;
1606 }
1607
1608 if (DataSize > 0) {
1609 //
1610 // Generate the dynamic text opcode for DNS server and draw it.
1611 //
1613 PortString,
1614 HiiHandle,
1615 Ip6ConfigNvDnsAddress,
1616 Data,
1617 DataSize / sizeof (EFI_IPv6_ADDRESS)
1618 );
1619 if (EFI_ERROR (Status)) {
1620 FreePool (Data);
1621 return Status;
1622 }
1623 }
1624
1625 //
1626 // Get gateway address list.
1627 //
1628 if (Data != NULL) {
1629 FreePool (Data);
1630 }
1631
1632 DataSize = 0;
1633 Data = NULL;
1634 Status = Ip6ConfigNvGetData (
1635 Ip6Config,
1637 &DataSize,
1638 (VOID **)&Data
1639 );
1640 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
1641 if (Data != NULL) {
1642 FreePool (Data);
1643 }
1644
1645 return Status;
1646 }
1647
1648 if (DataSize > 0) {
1649 //
1650 // Generate the dynamic text opcode for gateway and draw it.
1651 //
1653 PortString,
1654 HiiHandle,
1655 Ip6ConfigNvGatewayAddress,
1656 Data,
1657 DataSize / sizeof (EFI_IPv6_ADDRESS)
1658 );
1659 if (EFI_ERROR (Status)) {
1660 FreePool (Data);
1661 return Status;
1662 }
1663 }
1664
1665 if (Data != NULL) {
1666 FreePool (Data);
1667 }
1668
1669 return EFI_SUCCESS;
1670}
1671
1700EFIAPI
1703 IN EFI_BROWSER_ACTION Action,
1704 IN EFI_QUESTION_ID QuestionId,
1705 IN UINT8 Type,
1706 IN EFI_IFR_TYPE_VALUE *Value,
1707 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
1708 )
1709{
1710 IP6_FORM_CALLBACK_INFO *Private;
1711 UINTN BufferSize;
1712 IP6_CONFIG_IFR_NVDATA *IfrNvData;
1713 EFI_STATUS Status;
1714 EFI_INPUT_KEY Key;
1715 IP6_CONFIG_INSTANCE *Instance;
1716 IP6_CONFIG_NVDATA *Ip6NvData;
1717
1718 if (This == NULL) {
1719 return EFI_INVALID_PARAMETER;
1720 }
1721
1722 Private = IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
1723 Instance = IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private);
1724 Ip6NvData = &Instance->Ip6NvData;
1725
1726 if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {
1727 return EFI_SUCCESS;
1728 }
1729
1730 if ((Action != EFI_BROWSER_ACTION_CHANGING) && (Action != EFI_BROWSER_ACTION_CHANGED)) {
1731 return EFI_UNSUPPORTED;
1732 }
1733
1734 if ((Value == NULL) || (ActionRequest == NULL)) {
1735 return EFI_INVALID_PARAMETER;
1736 }
1737
1738 //
1739 // Retrieve uncommitted data from Browser
1740 //
1741
1742 BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
1743 IfrNvData = AllocateZeroPool (BufferSize);
1744 if (IfrNvData == NULL) {
1745 return EFI_OUT_OF_RESOURCES;
1746 }
1747
1748 Status = EFI_SUCCESS;
1749
1750 HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *)IfrNvData);
1751
1752 if (Action == EFI_BROWSER_ACTION_CHANGING) {
1753 switch (QuestionId) {
1754 case KEY_GET_CURRENT_SETTING:
1755 Status = Ip6GetCurrentSetting (Instance);
1756 break;
1757
1758 default:
1759 break;
1760 }
1761 } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
1762 switch (QuestionId) {
1763 case KEY_SAVE_CONFIG_CHANGES:
1764 Status = Ip6ConvertIfrNvDataToConfigNvDataAdvanced (IfrNvData, Instance);
1765 if (EFI_ERROR (Status)) {
1766 break;
1767 }
1768
1769 Status = Ip6GetCurrentSetting (Instance);
1770
1771 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
1772 break;
1773
1774 case KEY_IGNORE_CONFIG_CHANGES:
1777 Ip6FreeAddressInfoList (&Ip6NvData->DnsAddress);
1778
1779 Ip6NvData->ManualAddressCount = 0;
1780 Ip6NvData->GatewayAddressCount = 0;
1781 Ip6NvData->DnsAddressCount = 0;
1782
1783 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
1784 break;
1785
1786 case KEY_SAVE_CHANGES:
1787 Status = Ip6ConvertIfrNvDataToConfigNvDataGeneral (IfrNvData, Instance);
1788 if (EFI_ERROR (Status)) {
1789 break;
1790 }
1791
1792 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
1793 break;
1794
1795 case KEY_INTERFACE_ID:
1796 Status = Ip6ParseInterfaceIdFromString (IfrNvData->InterfaceId, &Ip6NvData->InterfaceId);
1797 if (EFI_ERROR (Status)) {
1798 CreatePopUp (
1799 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1800 &Key,
1801 L"Invalid Interface ID!",
1802 NULL
1803 );
1804 }
1805
1806 break;
1807
1808 case KEY_MANUAL_ADDRESS:
1810 IfrNvData->ManualAddress,
1811 &Ip6NvData->ManualAddress,
1812 &Ip6NvData->ManualAddressCount
1813 );
1814 if (EFI_ERROR (Status)) {
1815 CreatePopUp (
1816 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1817 &Key,
1818 L"Invalid Host Addresses!",
1819 NULL
1820 );
1821 }
1822
1823 break;
1824
1825 case KEY_GATEWAY_ADDRESS:
1827 IfrNvData->GatewayAddress,
1828 &Ip6NvData->GatewayAddress,
1829 &Ip6NvData->GatewayAddressCount
1830 );
1831 if (EFI_ERROR (Status)) {
1832 CreatePopUp (
1833 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1834 &Key,
1835 L"Invalid Gateway Addresses!",
1836 NULL
1837 );
1838 }
1839
1840 break;
1841
1842 case KEY_DNS_ADDRESS:
1844 IfrNvData->DnsAddress,
1845 &Ip6NvData->DnsAddress,
1846 &Ip6NvData->DnsAddressCount
1847 );
1848 if (EFI_ERROR (Status)) {
1849 CreatePopUp (
1850 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
1851 &Key,
1852 L"Invalid DNS Addresses!",
1853 NULL
1854 );
1855 }
1856
1857 break;
1858
1859 default:
1860 break;
1861 }
1862 }
1863
1864 if (!EFI_ERROR (Status)) {
1865 //
1866 // Pass changed uncommitted data back to Form Browser.
1867 //
1868 BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
1869 HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8 *)IfrNvData, NULL);
1870 }
1871
1872 FreePool (IfrNvData);
1873 return Status;
1874}
1875
1888 IN OUT IP6_CONFIG_INSTANCE *Instance
1889 )
1890{
1891 EFI_STATUS Status;
1892 IP6_SERVICE *IpSb;
1893 IP6_FORM_CALLBACK_INFO *CallbackInfo;
1894 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
1895 VENDOR_DEVICE_PATH VendorDeviceNode;
1897 CHAR16 *MacString;
1898 CHAR16 MenuString[128];
1899 CHAR16 PortString[128];
1900 CHAR16 *OldMenuString;
1901 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
1902
1903 IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance);
1904 ASSERT (IpSb != NULL);
1905
1906 Status = gBS->HandleProtocol (
1907 IpSb->Controller,
1908 &gEfiDevicePathProtocolGuid,
1909 (VOID **)&ParentDevicePath
1910 );
1911 if (EFI_ERROR (Status)) {
1912 return Status;
1913 }
1914
1915 CallbackInfo = &Instance->CallbackInfo;
1916 CallbackInfo->Signature = IP6_FORM_CALLBACK_INFO_SIGNATURE;
1917
1918 //
1919 // Construct device path node for EFI HII Config Access protocol,
1920 // which consists of controller physical device path and one hardware
1921 // vendor guid node.
1922 //
1923 ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH));
1924 VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH;
1925 VendorDeviceNode.Header.SubType = HW_VENDOR_DP;
1926
1927 CopyGuid (&VendorDeviceNode.Guid, &gEfiCallerIdGuid);
1928
1929 SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));
1930 CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode (
1931 ParentDevicePath,
1932 (EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
1933 );
1934 if (CallbackInfo->HiiVendorDevicePath == NULL) {
1935 Status = EFI_OUT_OF_RESOURCES;
1936 goto Error;
1937 }
1938
1939 ConfigAccess = &CallbackInfo->HiiConfigAccess;
1940 ConfigAccess->ExtractConfig = Ip6FormExtractConfig;
1941 ConfigAccess->RouteConfig = Ip6FormRouteConfig;
1942 ConfigAccess->Callback = Ip6FormCallback;
1943
1944 //
1945 // Install Device Path Protocol and Config Access protocol on new handle
1946 //
1947 Status = gBS->InstallMultipleProtocolInterfaces (
1948 &CallbackInfo->ChildHandle,
1949 &gEfiDevicePathProtocolGuid,
1950 CallbackInfo->HiiVendorDevicePath,
1951 &gEfiHiiConfigAccessProtocolGuid,
1952 ConfigAccess,
1953 NULL
1954 );
1955 if (!EFI_ERROR (Status)) {
1956 //
1957 // Open the Parent Handle for the child
1958 //
1959 Status = gBS->OpenProtocol (
1960 IpSb->Controller,
1961 &gEfiManagedNetworkServiceBindingProtocolGuid,
1962 (VOID **)&MnpSb,
1963 IpSb->Image,
1964 CallbackInfo->ChildHandle,
1965 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1966 );
1967 }
1968
1969 if (EFI_ERROR (Status)) {
1970 goto Error;
1971 }
1972
1973 //
1974 // Publish our HII data
1975 //
1976 CallbackInfo->RegisteredHandle = HiiAddPackages (
1977 &gIp6ConfigNvDataGuid,
1978 CallbackInfo->ChildHandle,
1979 Ip6DxeStrings,
1980 Ip6ConfigBin,
1981 NULL
1982 );
1983 if (CallbackInfo->RegisteredHandle == NULL) {
1984 Status = EFI_OUT_OF_RESOURCES;
1985 goto Error;
1986 }
1987
1988 //
1989 // Append MAC string in the menu help string and tile help string
1990 //
1991 Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &MacString);
1992 if (!EFI_ERROR (Status)) {
1993 OldMenuString = HiiGetString (
1994 CallbackInfo->RegisteredHandle,
1995 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP),
1996 NULL
1997 )
1998 ;
1999 UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
2000 HiiSetString (
2001 CallbackInfo->RegisteredHandle,
2002 STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP),
2003 MenuString,
2004 NULL
2005 );
2006 UnicodeSPrint (PortString, 128, L"MAC:%s", MacString);
2007 HiiSetString (
2008 CallbackInfo->RegisteredHandle,
2009 STRING_TOKEN (STR_IP6_DEVICE_FORM_HELP),
2010 PortString,
2011 NULL
2012 );
2013
2014 FreePool (MacString);
2015 FreePool (OldMenuString);
2016
2017 InitializeListHead (&Instance->Ip6NvData.ManualAddress);
2018 InitializeListHead (&Instance->Ip6NvData.GatewayAddress);
2019 InitializeListHead (&Instance->Ip6NvData.DnsAddress);
2020
2021 return EFI_SUCCESS;
2022 }
2023
2024Error:
2025 Ip6ConfigFormUnload (Instance);
2026 return Status;
2027}
2028
2035VOID
2037 IN OUT IP6_CONFIG_INSTANCE *Instance
2038 )
2039{
2040 IP6_SERVICE *IpSb;
2041 IP6_FORM_CALLBACK_INFO *CallbackInfo;
2042 IP6_CONFIG_NVDATA *Ip6NvData;
2043
2044 IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance);
2045 ASSERT (IpSb != NULL);
2046
2047 CallbackInfo = &Instance->CallbackInfo;
2048
2049 if (CallbackInfo->ChildHandle != NULL) {
2050 //
2051 // Close the child handle
2052 //
2053 gBS->CloseProtocol (
2054 IpSb->Controller,
2055 &gEfiManagedNetworkServiceBindingProtocolGuid,
2056 IpSb->Image,
2057 CallbackInfo->ChildHandle
2058 );
2059 //
2060 // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
2061 //
2062 gBS->UninstallMultipleProtocolInterfaces (
2063 CallbackInfo->ChildHandle,
2064 &gEfiDevicePathProtocolGuid,
2065 CallbackInfo->HiiVendorDevicePath,
2066 &gEfiHiiConfigAccessProtocolGuid,
2067 &CallbackInfo->HiiConfigAccess,
2068 NULL
2069 );
2070 }
2071
2072 if (CallbackInfo->HiiVendorDevicePath != NULL) {
2073 FreePool (CallbackInfo->HiiVendorDevicePath);
2074 }
2075
2076 if (CallbackInfo->RegisteredHandle != NULL) {
2077 //
2078 // Remove HII package list
2079 //
2080 HiiRemovePackages (CallbackInfo->RegisteredHandle);
2081 }
2082
2083 Ip6NvData = &Instance->Ip6NvData;
2084
2087 Ip6FreeAddressInfoList (&Ip6NvData->DnsAddress);
2088
2089 Ip6NvData->ManualAddressCount = 0;
2090 Ip6NvData->GatewayAddressCount = 0;
2091 Ip6NvData->DnsAddressCount = 0;
2092}
UINT64 UINTN
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
UINTN EFIAPI StrHexToUintn(IN CONST CHAR16 *String)
Definition: String.c:508
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
Definition: String.c:30
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
Definition: String.c:224
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STRING EFIAPI HiiConstructConfigHdr(IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL, IN EFI_HANDLE DriverHandle)
Definition: HiiLib.c:723
BOOLEAN EFIAPI HiiGetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, OUT UINT8 *Buffer)
Definition: HiiLib.c:2872
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
Definition: HiiLib.c:3051
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
Definition: HiiLib.c:3085
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
Definition: HiiLib.c:141
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
Definition: HiiLib.c:3411
BOOLEAN EFIAPI HiiSetBrowserData(IN CONST EFI_GUID *VariableGuid OPTIONAL, IN CONST CHAR16 *VariableName OPTIONAL, IN UINTN BufferSize, IN CONST UINT8 *Buffer, IN CONST CHAR16 *RequestElement OPTIONAL)
Definition: HiiLib.c:2954
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
Definition: HiiString.c:211
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
Definition: HiiLib.c:4410
BOOLEAN EFIAPI HiiIsConfigHdrMatch(IN CONST EFI_STRING ConfigHdr, IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL)
Definition: HiiLib.c:2813
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
Definition: HiiString.c:52
UINT8 *EFIAPI HiiCreateTextOpCode(IN VOID *OpCodeHandle, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN EFI_STRING_ID TextTwo)
Definition: HiiLib.c:4037
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLib.c:253
EFI_IP6_CONFIG_DATA_TYPE
Definition: Ip6Config.h:25
@ Ip6ConfigDataTypeDupAddrDetectTransmits
Definition: Ip6Config.h:59
@ Ip6ConfigDataTypeGateway
Definition: Ip6Config.h:79
@ Ip6ConfigDataTypeAltInterfaceId
Definition: Ip6Config.h:42
@ Ip6ConfigDataTypeManualAddress
Definition: Ip6Config.h:68
@ Ip6ConfigDataTypeInterfaceInfo
Definition: Ip6Config.h:32
@ Ip6ConfigDataTypePolicy
Definition: Ip6Config.h:50
@ Ip6ConfigDataTypeDnsServer
Definition: Ip6Config.h:90
EFI_IP6_CONFIG_POLICY
Definition: Ip6Config.h:154
@ Ip6ConfigPolicyManual
Definition: Ip6Config.h:163
@ Ip6ConfigPolicyAutomatic
Definition: Ip6Config.h:175
EFI_STATUS Ip6ConvertInterfaceInfoToString(IN EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo, IN EFI_HII_HANDLE HiiHandle, IN OUT IP6_CONFIG_IFR_NVDATA *IfrNvData)
Definition: Ip6ConfigNv.c:682
EFI_STATUS Ip6ConfigFormInit(IN OUT IP6_CONFIG_INSTANCE *Instance)
Definition: Ip6ConfigNv.c:1887
EFI_STATUS Ip6BuildNvAddressInfo(IN IP6_CONFIG_INSTANCE *Instance, IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType, OUT VOID **AddressInfo, OUT UINTN *AddressSize)
Definition: Ip6ConfigNv.c:794
VOID Ip6ToStr(IN EFI_IPv6_ADDRESS *Ip6, OUT CHAR16 *Str)
Definition: Ip6ConfigNv.c:133
EFI_STATUS Ip6ConvertInterfaceIdToString(OUT CHAR16 *String, IN EFI_IP6_CONFIG_INTERFACE_ID *IfId)
Definition: Ip6ConfigNv.c:221
EFI_STATUS Ip6ConvertIfrNvDataToConfigNvDataAdvanced(IN IP6_CONFIG_IFR_NVDATA *IfrNvData, IN OUT IP6_CONFIG_INSTANCE *Instance)
Definition: Ip6ConfigNv.c:1085
EFI_STATUS Ip6GetCurrentSetting(IN IP6_CONFIG_INSTANCE *Instance)
Definition: Ip6ConfigNv.c:1528
EFI_STATUS EFIAPI Ip6FormCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
Definition: Ip6ConfigNv.c:1701
EFI_STATUS EFIAPI Ip6FormExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
Definition: Ip6ConfigNv.c:1351
EFI_STATUS Ip6ConvertIfrNvDataToConfigNvDataGeneral(IN IP6_CONFIG_IFR_NVDATA *IfrNvData, IN OUT IP6_CONFIG_INSTANCE *Instance)
Definition: Ip6ConfigNv.c:1002
EFI_STATUS Ip6ParseInterfaceIdFromString(IN CONST CHAR16 *String, OUT EFI_IP6_CONFIG_INTERFACE_ID *IfId)
Definition: Ip6ConfigNv.c:259
EFI_STATUS Ip6CreateOpCode(IN UINT16 StartLabelNumber, OUT VOID **StartOpCodeHandle, OUT EFI_IFR_GUID_LABEL **StartLabel, OUT VOID **EndOpCodeHandle, OUT EFI_IFR_GUID_LABEL **EndLabel)
Definition: Ip6ConfigNv.c:326
EFI_STATUS Ip6ConvertConfigNvDataToIfrNvData(IN OUT IP6_CONFIG_IFR_NVDATA *IfrNvData, IN IP6_CONFIG_INSTANCE *Instance)
Definition: Ip6ConfigNv.c:871
VOID EFIAPI Ip6ConfigManualAddressNotify(IN EFI_EVENT Event, IN VOID *Context)
Definition: Ip6ConfigNv.c:23
VOID Ip6ConfigFormUnload(IN OUT IP6_CONFIG_INSTANCE *Instance)
Definition: Ip6ConfigNv.c:2036
EFI_STATUS Ip6ConvertAddressListToString(IN OUT CHAR16 *String, IN EFI_HII_HANDLE HiiHandle, IN IP6_CONFIG_NV_ADDRESS_TYPE AddressType, IN VOID *AddressInfo, IN UINTN AddressCount)
Definition: Ip6ConfigNv.c:432
EFI_STATUS Ip6ParseAddressListFromString(IN CONST CHAR16 *String, OUT LIST_ENTRY *ListHead, OUT UINT32 *AddressCount)
Definition: Ip6ConfigNv.c:579
EFI_STATUS Ip6ConfigNvGetData(IN EFI_IP6_CONFIG_PROTOCOL *Ip6Config, IN EFI_IP6_CONFIG_DATA_TYPE DataType, OUT UINTN *DataSize, OUT VOID **Data)
Definition: Ip6ConfigNv.c:54
EFI_STATUS EFIAPI Ip6FormRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
Definition: Ip6ConfigNv.c:1493
VOID Ip6FreeAddressInfoList(IN LIST_ENTRY *ListHead)
Definition: Ip6ConfigNv.c:110
#define EFI_IFR_EXTEND_OP_LABEL
Definition: MdeModuleHii.h:33
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
Definition: PrintLib.c:408
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS EFIAPI NetLibGetMacString(IN EFI_HANDLE ServiceHandle, IN EFI_HANDLE ImageHandle OPTIONAL, OUT CHAR16 **MacString)
Definition: DxeNetLib.c:2363
BOOLEAN EFIAPI NetIp6IsValidUnicast(IN EFI_IPv6_ADDRESS *Ip6)
Definition: DxeNetLib.c:725
EFI_STATUS EFIAPI NetLibStrToIp6andPrefix(IN CONST CHAR16 *String, OUT EFI_IPv6_ADDRESS *Ip6Address, OUT UINT8 *PrefixLength)
Definition: DxeNetLib.c:3185
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI Exit(IN EFI_STATUS Status)
IPv6_ADDRESS EFI_IPv6_ADDRESS
Definition: UefiBaseType.h:90
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_HII_CONFIG_ROUTING_PROTOCOL * gHiiConfigRouting
#define STRING_TOKEN(t)
VOID * EFI_HII_HANDLE
VOID EFIAPI CreatePopUp(IN UINTN Attribute, OUT EFI_INPUT_KEY *Key OPTIONAL,...)
Definition: Console.c:393
@ TimerRelative
Definition: UefiSpec.h:539
UINT8 PrefixLength
The length of the prefix associated with the Address.
Definition: Ip6.h:222
EFI_IPv6_ADDRESS Address
The IPv6 address.
Definition: Ip6.h:221
UINT32 DupAddrDetectTransmits
The number of consecutive Neighbor Solicitation messages sent.
Definition: Ip6Config.h:185
EFI_IP6_ROUTE_TABLE * RouteTable
Definition: Ip6Config.h:138
EFI_IP6_ADDRESS_INFO * AddressInfo
Definition: Ip6Config.h:129
UINT8 PrefixLength
The length, in bits, of the prefix associated with this Address.
Definition: Ip6Config.h:196
EFI_IPv6_ADDRESS Address
The IPv6 unicast address.
Definition: Ip6Config.h:194
CHAR16 DnsAddress[ADDRESS_STR_MAX_SIZE]
DNS server address.
Definition: Ip6NvData.h:58
CHAR16 GatewayAddress[ADDRESS_STR_MAX_SIZE]
Gateway address.
Definition: Ip6NvData.h:57
CHAR16 InterfaceId[INTERFACE_ID_STR_STORAGE]
alternative interface id
Definition: Ip6NvData.h:55
CHAR16 ManualAddress[ADDRESS_STR_MAX_SIZE]
IP addresses.
Definition: Ip6NvData.h:56
EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadTransmitCount
dad transmits count
UINT32 ManualAddressCount
IP addresses count.
LIST_ENTRY DnsAddress
DNS server address.
UINT32 GatewayAddressCount
Gateway address count.
LIST_ENTRY GatewayAddress
Gateway address.
EFI_IP6_CONFIG_INTERFACE_ID InterfaceId
alternative interface id
LIST_ENTRY ManualAddress
IP addresses.
EFI_IP6_CONFIG_POLICY Policy
manual or automatic
UINT32 DnsAddressCount
DNS server address count.