Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
/vendor/edk2/current 103735-103757
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c
r48674 r58459 2 2 Helper functions for configuring or obtaining the parameters relating to IP6. 3 3 4 Copyright (c) 2010 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 601 601 } 602 602 603 ZeroMem (&AddressInfo, sizeof (EFI_IP6_ADDRESS_INFO)); 603 604 LocalString = (CHAR16 *) AllocateCopyPool (StrSize (String), String); 604 605 if (LocalString == NULL) { … … 670 671 /** 671 672 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. 673 The interface information includes interface name, interface type, hardware 674 address and route table information. 675 675 676 676 @param[in] IfInfo The pointer of EFI_IP6_CONFIG_INTERFACE_INFO. … … 694 694 UINTN Number; 695 695 CHAR16 *String; 696 CHAR16 *LinkLocalStr;697 696 CHAR16 PortString[ADDRESS_STR_MAX_SIZE]; 698 697 CHAR16 FormatString[8]; 699 698 EFI_STRING_ID StringId; 700 EFI_STATUS Status;701 699 702 700 if ((IfInfo == NULL) || (HiiHandle == NULL) || (IfrNvData == NULL)) { … … 721 719 // 722 720 if (IfInfo->IfType == Ip6InterfaceTypeEthernet) { 723 StrCpy (PortString, IP6_ETHERNET);721 CopyMem (PortString, IP6_ETHERNET, sizeof (IP6_ETHERNET)); 724 722 } else if (IfInfo->IfType == Ip6InterfaceTypeExperimentalEthernet) { 725 StrCpy (PortString, IP6_EXPERIMENTAL_ETHERNET);723 CopyMem (PortString, IP6_EXPERIMENTAL_ETHERNET, sizeof (IP6_EXPERIMENTAL_ETHERNET)); 726 724 } else { 727 725 // … … 750 748 751 749 if (IfInfo->HwAddress.Addr[Index] < 0x10) { 752 StrCpy (FormatString, L"0%x-");750 CopyMem (FormatString, L"0%x-", sizeof (L"0%x-")); 753 751 } else { 754 StrCpy (FormatString, L"%x-");752 CopyMem (FormatString, L"%x-", sizeof (L"%x-")); 755 753 } 756 754 … … 783 781 } 784 782 785 // 786 // Print the host address Information. 787 // 788 Status = Ip6ConvertAddressListToString ( 789 PortString, 790 HiiHandle, 791 Ip6ConfigNvHostAddress, 792 IfInfo->AddressInfo, 793 IfInfo->AddressInfoCount 794 ); 795 if (EFI_ERROR (Status)) { 796 return Status; 797 } 798 799 // 800 // Copy the Host Address Info to manual address field. 801 // Do not copy the link local address. 802 // 803 LinkLocalStr = StrStr (PortString, IP6_LINK_LOCAL_PREFIX); 804 if (LinkLocalStr != NULL) { 805 Number = LinkLocalStr - PortString; 806 if (Number > 0) { 807 CopyMem (IfrNvData->ManualAddress, PortString, Number * sizeof (CHAR16)); 808 } 809 810 while ((*LinkLocalStr != L' ') && (*LinkLocalStr != L'\0')) { 811 LinkLocalStr++; 812 } 813 814 if (*LinkLocalStr != L'\0') { 815 LinkLocalStr++; 816 StrCat (IfrNvData->ManualAddress, LinkLocalStr); 817 } 818 } else { 819 StrCpy (IfrNvData->ManualAddress, PortString); 820 } 821 822 // 823 // Print the route table information. 824 // 825 Status = Ip6ConvertAddressListToString ( 826 PortString, 827 HiiHandle, 828 Ip6ConfigNvRouteTable, 829 IfInfo->RouteTable, 830 IfInfo->RouteCount 831 ); 832 return Status; 783 return EFI_SUCCESS; 833 784 } 834 785 … … 1034 985 IfrNvData->DadTransmitCount = DadXmits.DupAddrDetectTransmits; 1035 986 1036 //1037 // Get DNS server list.1038 //1039 FreePool (Data);1040 Data = NULL;1041 DataSize = 0;1042 Status = Ip6ConfigNvGetData (1043 Ip6Config,1044 Ip6ConfigDataTypeDnsServer,1045 &DataSize,1046 (VOID **) &Data1047 );1048 1049 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {1050 goto Exit;1051 }1052 1053 if (DataSize > 0) {1054 //1055 // Convert the DNS server address to string and draw it to UI.1056 //1057 Status = Ip6ConvertAddressListToString (1058 IfrNvData->DnsAddress,1059 HiiHandle,1060 Ip6ConfigNvDnsAddress,1061 Data,1062 DataSize / sizeof (EFI_IPv6_ADDRESS)1063 );1064 if (EFI_ERROR (Status)) {1065 goto Exit;1066 }1067 1068 FreePool (Data);1069 Data = NULL;1070 }1071 1072 //1073 // Get gateway adderss list.1074 //1075 DataSize = 0;1076 Status = Ip6ConfigNvGetData (1077 Ip6Config,1078 Ip6ConfigDataTypeGateway,1079 &DataSize,1080 (VOID **) &Data1081 );1082 1083 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {1084 goto Exit;1085 }1086 1087 if (DataSize > 0) {1088 //1089 // Convert the gateway address to string and draw it to UI.1090 //1091 Status = Ip6ConvertAddressListToString (1092 IfrNvData->GatewayAddress,1093 HiiHandle,1094 Ip6ConfigNvGatewayAddress,1095 Data,1096 DataSize / sizeof (EFI_IPv6_ADDRESS)1097 );1098 if (EFI_ERROR (Status)) {1099 goto Exit;1100 }1101 }1102 1103 Status = EFI_SUCCESS;1104 1105 987 Exit: 1106 988 if (Data != NULL) { … … 1113 995 /** 1114 996 Convert IFR data into IP6 configuration data. The policy, alternative interface 1115 ID, and DAD transmit counts, and will be saved. If under manual policy, the configured 1116 manual address, gateway address, and DNS server address will be saved. 997 ID, and DAD transmit counts, and will be saved. 1117 998 1118 999 @param[in] IfrNvData The IFR NV data. … … 1125 1006 **/ 1126 1007 EFI_STATUS 1127 Ip6ConvertIfrNvDataToConfigNvData ( 1008 Ip6ConvertIfrNvDataToConfigNvDataGeneral ( 1009 IN IP6_CONFIG_IFR_NVDATA *IfrNvData, 1010 IN OUT IP6_CONFIG_INSTANCE *Instance 1011 ) 1012 { 1013 IP6_CONFIG_NVDATA *Ip6NvData; 1014 EFI_IP6_CONFIG_PROTOCOL *Ip6Config; 1015 EFI_STATUS Status; 1016 1017 if ((IfrNvData == NULL) || (Instance == NULL)) { 1018 return EFI_INVALID_PARAMETER; 1019 } 1020 1021 NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE); 1022 Ip6NvData = &Instance->Ip6NvData; 1023 Ip6Config = &Instance->Ip6Config; 1024 1025 // 1026 // Update those fields which don't have INTERACTIVE attribute. 1027 // 1028 if (IfrNvData->Policy == IP6_POLICY_AUTO) { 1029 Ip6NvData->Policy = Ip6ConfigPolicyAutomatic; 1030 } else if (IfrNvData->Policy == IP6_POLICY_MANUAL) { 1031 Ip6NvData->Policy = Ip6ConfigPolicyManual; 1032 } 1033 1034 Ip6NvData->DadTransmitCount.DupAddrDetectTransmits = IfrNvData->DadTransmitCount; 1035 1036 // 1037 // Set the configured policy. 1038 // 1039 Status = Ip6Config->SetData ( 1040 Ip6Config, 1041 Ip6ConfigDataTypePolicy, 1042 sizeof (EFI_IP6_CONFIG_POLICY), 1043 &Ip6NvData->Policy 1044 ); 1045 if (EFI_ERROR (Status)) { 1046 return Status; 1047 } 1048 1049 // 1050 // Set the duplicate address detection transmits count. 1051 // 1052 Status = Ip6Config->SetData ( 1053 Ip6Config, 1054 Ip6ConfigDataTypeDupAddrDetectTransmits, 1055 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS), 1056 &Ip6NvData->DadTransmitCount 1057 ); 1058 if (EFI_ERROR (Status)) { 1059 return Status; 1060 } 1061 1062 // 1063 // Set the alternative interface ID 1064 // 1065 Status = Ip6Config->SetData ( 1066 Ip6Config, 1067 Ip6ConfigDataTypeAltInterfaceId, 1068 sizeof (EFI_IP6_CONFIG_INTERFACE_ID), 1069 &Ip6NvData->InterfaceId 1070 ); 1071 if (EFI_ERROR (Status)) { 1072 return Status; 1073 } 1074 1075 return EFI_SUCCESS; 1076 } 1077 1078 /** 1079 Convert IFR data into IP6 configuration data. The policy, configured 1080 manual address, gateway address, and DNS server address will be saved. 1081 1082 @param[in] IfrNvData The IFR NV data. 1083 @param[in, out] Instance The IP6 config instance data. 1084 1085 @retval EFI_SUCCESS The operation finished successfully. 1086 @retval EFI_INVALID_PARAMETER Any input parameter is invalid. 1087 @retval Others Other errors as indicated. 1088 1089 **/ 1090 EFI_STATUS 1091 Ip6ConvertIfrNvDataToConfigNvDataAdvanced ( 1128 1092 IN IP6_CONFIG_IFR_NVDATA *IfrNvData, 1129 1093 IN OUT IP6_CONFIG_INSTANCE *Instance … … 1144 1108 } 1145 1109 1110 if (IfrNvData->Policy == IP6_POLICY_AUTO) { 1111 return EFI_SUCCESS; 1112 } 1113 1146 1114 NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE); 1147 1115 Ip6NvData = &Instance->Ip6NvData; … … 1151 1119 // Update those fields which don't have INTERACTIVE attribute. 1152 1120 // 1153 if (IfrNvData->Policy == IP6_POLICY_AUTO) { 1154 Ip6NvData->Policy = Ip6ConfigPolicyAutomatic; 1155 } else if (IfrNvData->Policy == IP6_POLICY_MANUAL) { 1156 Ip6NvData->Policy = Ip6ConfigPolicyManual; 1157 } 1158 1159 Ip6NvData->DadTransmitCount.DupAddrDetectTransmits = IfrNvData->DadTransmitCount; 1121 Ip6NvData->Policy = Ip6ConfigPolicyManual; 1160 1122 1161 1123 // … … 1170 1132 if (EFI_ERROR (Status)) { 1171 1133 return Status; 1172 }1173 1174 //1175 // Set the duplicate address detection transmits count.1176 //1177 Status = Ip6Config->SetData (1178 Ip6Config,1179 Ip6ConfigDataTypeDupAddrDetectTransmits,1180 sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS),1181 &Ip6NvData->DadTransmitCount1182 );1183 if (EFI_ERROR (Status)) {1184 return Status;1185 }1186 1187 //1188 // Set the alternative interface ID1189 //1190 Status = Ip6Config->SetData (1191 Ip6Config,1192 Ip6ConfigDataTypeAltInterfaceId,1193 sizeof (EFI_IP6_CONFIG_INTERFACE_ID),1194 &Ip6NvData->InterfaceId1195 );1196 if (EFI_ERROR (Status)) {1197 return Status;1198 }1199 1200 1201 if (Ip6NvData->Policy == Ip6ConfigPolicyAutomatic) {1202 return EFI_SUCCESS;1203 1134 } 1204 1135 … … 1358 1289 return Status; 1359 1290 } 1291 1360 1292 1361 1293 /** … … 1589 1521 1590 1522 /** 1523 Display host addresses, route table, DNS addresses and gateway addresses in 1524 "IPv6 Current Setting" page. 1525 1526 @param[in] Instance The IP6 config instance data. 1527 1528 @retval EFI_SUCCESS The operation finished successfully. 1529 @retval Others Other errors as indicated. 1530 1531 **/ 1532 EFI_STATUS 1533 Ip6GetCurrentSetting ( 1534 IN IP6_CONFIG_INSTANCE *Instance 1535 ) 1536 { 1537 EFI_IP6_CONFIG_PROTOCOL *Ip6Config; 1538 EFI_HII_HANDLE HiiHandle; 1539 EFI_IP6_CONFIG_INTERFACE_INFO *Data; 1540 UINTN DataSize; 1541 EFI_STATUS Status; 1542 CHAR16 PortString[ADDRESS_STR_MAX_SIZE]; 1543 EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; 1544 1545 1546 Ip6Config = &Instance->Ip6Config; 1547 HiiHandle = Instance->CallbackInfo.RegisteredHandle; 1548 Data = NULL; 1549 1550 // 1551 // Get current interface info. 1552 // 1553 Status = Ip6ConfigNvGetData ( 1554 Ip6Config, 1555 Ip6ConfigDataTypeInterfaceInfo, 1556 &DataSize, 1557 (VOID **) &Data 1558 ); 1559 if (EFI_ERROR (Status)) { 1560 return Status; 1561 } 1562 1563 // 1564 // Generate dynamic text opcode for host address and draw it. 1565 // 1566 IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data; 1567 Status = Ip6ConvertAddressListToString ( 1568 PortString, 1569 HiiHandle, 1570 Ip6ConfigNvHostAddress, 1571 IfInfo->AddressInfo, 1572 IfInfo->AddressInfoCount 1573 ); 1574 if (EFI_ERROR (Status)) { 1575 FreePool (Data); 1576 return Status; 1577 } 1578 1579 // 1580 // Generate the dynamic text opcode for route table and draw it. 1581 // 1582 Status = Ip6ConvertAddressListToString ( 1583 PortString, 1584 HiiHandle, 1585 Ip6ConfigNvRouteTable, 1586 IfInfo->RouteTable, 1587 IfInfo->RouteCount 1588 ); 1589 if (EFI_ERROR (Status)) { 1590 FreePool (Data); 1591 return Status; 1592 } 1593 1594 // 1595 // Get DNS server list. 1596 // 1597 FreePool (Data); 1598 DataSize = 0; 1599 Data = NULL; 1600 Status = Ip6ConfigNvGetData ( 1601 Ip6Config, 1602 Ip6ConfigDataTypeDnsServer, 1603 &DataSize, 1604 (VOID **) &Data 1605 ); 1606 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { 1607 if (Data != NULL) { 1608 FreePool (Data); 1609 } 1610 return Status; 1611 } 1612 1613 if (DataSize > 0) { 1614 // 1615 // Generate the dynamic text opcode for DNS server and draw it. 1616 // 1617 Status = Ip6ConvertAddressListToString ( 1618 PortString, 1619 HiiHandle, 1620 Ip6ConfigNvDnsAddress, 1621 Data, 1622 DataSize / sizeof (EFI_IPv6_ADDRESS) 1623 ); 1624 if (EFI_ERROR (Status)) { 1625 FreePool (Data); 1626 return Status; 1627 } 1628 } 1629 1630 // 1631 // Get gateway adderss list. 1632 // 1633 if (Data != NULL) { 1634 FreePool (Data); 1635 } 1636 1637 DataSize = 0; 1638 Data = NULL; 1639 Status = Ip6ConfigNvGetData ( 1640 Ip6Config, 1641 Ip6ConfigDataTypeGateway, 1642 &DataSize, 1643 (VOID **) &Data 1644 ); 1645 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { 1646 if (Data != NULL) { 1647 FreePool (Data); 1648 } 1649 return Status; 1650 } 1651 1652 if (DataSize > 0) { 1653 // 1654 // Generate the dynamic text opcode for gateway and draw it. 1655 // 1656 Status = Ip6ConvertAddressListToString ( 1657 PortString, 1658 HiiHandle, 1659 Ip6ConfigNvGatewayAddress, 1660 Data, 1661 DataSize / sizeof (EFI_IPv6_ADDRESS) 1662 ); 1663 if (EFI_ERROR (Status)) { 1664 FreePool (Data); 1665 return Status; 1666 } 1667 } 1668 1669 if (Data != NULL) { 1670 FreePool (Data); 1671 } 1672 1673 return EFI_SUCCESS; 1674 } 1675 1676 /** 1591 1677 This function is called to provide results data to the driver. 1592 1678 This data consists of a unique key that is used to identify … … 1633 1719 IP6_CONFIG_INSTANCE *Instance; 1634 1720 IP6_CONFIG_NVDATA *Ip6NvData; 1635 EFI_IP6_CONFIG_PROTOCOL *Ip6Config;1636 EFI_IP6_CONFIG_INTERFACE_INFO *Data;1637 UINTN DataSize;1638 CHAR16 PortString[ADDRESS_STR_MAX_SIZE];1639 EFI_HII_HANDLE HiiHandle;1640 EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;1641 1721 1642 1722 if (This == NULL) { … … 1677 1757 switch (QuestionId) { 1678 1758 case KEY_GET_CURRENT_SETTING: 1679 Ip6Config = &Instance->Ip6Config; 1680 HiiHandle = Instance->CallbackInfo.RegisteredHandle; 1681 Data = NULL; 1682 1683 // 1684 // Get current interface info. 1685 // 1686 Status = Ip6ConfigNvGetData ( 1687 Ip6Config, 1688 Ip6ConfigDataTypeInterfaceInfo, 1689 &DataSize, 1690 (VOID **) &Data 1691 ); 1692 if (EFI_ERROR (Status)) { 1693 return Status; 1694 } 1695 1696 // 1697 // Generate dynamic text opcode for host address and draw it. 1698 // 1699 IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data; 1700 Status = Ip6ConvertAddressListToString ( 1701 PortString, 1702 HiiHandle, 1703 Ip6ConfigNvHostAddress, 1704 IfInfo->AddressInfo, 1705 IfInfo->AddressInfoCount 1706 ); 1707 if (EFI_ERROR (Status)) { 1708 FreePool (Data); 1709 return Status; 1710 } 1711 1712 // 1713 // Generate the dynamic text opcode for route table and draw it. 1714 // 1715 Status = Ip6ConvertAddressListToString ( 1716 PortString, 1717 HiiHandle, 1718 Ip6ConfigNvRouteTable, 1719 IfInfo->RouteTable, 1720 IfInfo->RouteCount 1721 ); 1722 if (EFI_ERROR (Status)) { 1723 FreePool (Data); 1724 return Status; 1725 } 1726 1727 // 1728 // Get DNS server list. 1729 // 1730 FreePool (Data); 1731 DataSize = 0; 1732 Data = NULL; 1733 Status = Ip6ConfigNvGetData ( 1734 Ip6Config, 1735 Ip6ConfigDataTypeDnsServer, 1736 &DataSize, 1737 (VOID **) &Data 1738 ); 1739 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { 1740 if (Data != NULL) { 1741 FreePool (Data); 1742 } 1743 return Status; 1744 } 1745 1746 if (DataSize > 0) { 1747 // 1748 // Generate the dynamic text opcode for DNS server and draw it. 1749 // 1750 Status = Ip6ConvertAddressListToString ( 1751 PortString, 1752 HiiHandle, 1753 Ip6ConfigNvDnsAddress, 1754 Data, 1755 DataSize / sizeof (EFI_IPv6_ADDRESS) 1756 ); 1757 if (EFI_ERROR (Status)) { 1758 FreePool (Data); 1759 return Status; 1760 } 1761 } 1762 1763 // 1764 // Get gateway adderss list. 1765 // 1766 if (Data != NULL) { 1767 FreePool (Data); 1768 } 1769 1770 DataSize = 0; 1771 Data = NULL; 1772 Status = Ip6ConfigNvGetData ( 1773 Ip6Config, 1774 Ip6ConfigDataTypeGateway, 1775 &DataSize, 1776 (VOID **) &Data 1777 ); 1778 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { 1779 if (Data != NULL) { 1780 FreePool (Data); 1781 } 1782 return Status; 1783 } 1784 1785 if (DataSize > 0) { 1786 // 1787 // Generate the dynamic text opcode for gateway and draw it. 1788 // 1789 Status = Ip6ConvertAddressListToString ( 1790 PortString, 1791 HiiHandle, 1792 Ip6ConfigNvGatewayAddress, 1793 Data, 1794 DataSize / sizeof (EFI_IPv6_ADDRESS) 1795 ); 1796 if (EFI_ERROR (Status)) { 1797 FreePool (Data); 1798 return Status; 1799 } 1800 } 1801 1802 if (Data != NULL) { 1803 FreePool (Data); 1804 } 1805 1806 Status = EFI_SUCCESS; 1807 1759 Status = Ip6GetCurrentSetting (Instance); 1808 1760 break; 1809 1761 … … 1814 1766 switch (QuestionId) { 1815 1767 case KEY_SAVE_CONFIG_CHANGES: 1768 Status = Ip6ConvertIfrNvDataToConfigNvDataAdvanced (IfrNvData, Instance); 1769 if (EFI_ERROR (Status)) { 1770 break; 1771 } 1772 1773 Status = Ip6GetCurrentSetting (Instance); 1774 1816 1775 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; 1817 1776 break; … … 1830 1789 1831 1790 case KEY_SAVE_CHANGES: 1832 Status = Ip6ConvertIfrNvDataToConfigNvData (IfrNvData, Instance);1791 Status = Ip6ConvertIfrNvDataToConfigNvDataGeneral (IfrNvData, Instance); 1833 1792 if (EFI_ERROR (Status)) { 1834 1793 break;
Note:
See TracChangeset
for help on using the changeset viewer.