Changeset 77662 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg
- Timestamp:
- Mar 12, 2019 12:40:12 PM (6 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 83 added
- 4 deleted
- 133 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776 /vendor/edk2/current 103735-103757,103769-103776,129194-129237
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/Indexer.c
r58459 r77662 2 2 The implementation of construct ENTRY_INDEXER in IpSecConfig application. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 45 45 ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e"); 46 46 } else { 47 ASSERT (FALSE); 48 } 49 50 ASSERT (ValueStr != NULL); 47 return EFI_INVALID_PARAMETER; 48 } 49 50 if (ValueStr == NULL) { 51 return EFI_INVALID_PARAMETER; 52 } 51 53 52 54 Value64 = StrToUInteger (ValueStr, &Status); 53 55 if (!EFI_ERROR (Status)) { 54 56 Indexer->Index = (UINTN) Value64; 55 Indexer->Name = NULL;56 } else { 57 UnicodeStrToAsciiStr (ValueStr, (CHAR8 *) Indexer->Name);57 ZeroMem (Indexer->Name, MAX_PEERID_LEN); 58 } else { 59 UnicodeStrToAsciiStrS (ValueStr, (CHAR8 *) Indexer->Name, MAX_PEERID_LEN); 58 60 } 59 61 … … 90 92 ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e"); 91 93 } else { 92 ASSERT (FALSE); 93 } 94 95 ASSERT (ValueStr != NULL); 94 return EFI_INVALID_PARAMETER; 95 } 96 97 if (ValueStr == NULL) { 98 return EFI_INVALID_PARAMETER; 99 } 96 100 97 101 Value64 = StrToUInteger (ValueStr, &Status); … … 188 192 ValueStr = ShellCommandLineGetValue (ParamPackage, L"-e"); 189 193 } else { 190 ASSERT (FALSE); 191 } 192 193 ASSERT (ValueStr != NULL); 194 return EFI_INVALID_PARAMETER; 195 } 196 197 if (ValueStr == NULL) { 198 return EFI_INVALID_PARAMETER; 199 } 194 200 195 201 Value64 = StrToUInteger (ValueStr, &Status); … … 236 242 Indexer->PadId.PeerIdValid = TRUE; 237 243 ZeroMem (Indexer->PadId.Id.PeerId, MAX_PEERID_LEN); 238 StrnCpy ((CHAR16 *) Indexer->PadId.Id.PeerId, ValueStr, ARRAY_SIZE (Indexer->PadId.Id.PeerId) - 1);244 StrnCpyS ((CHAR16 *) Indexer->PadId.Id.PeerId, MAX_PEERID_LEN / sizeof (CHAR16), ValueStr, MAX_PEERID_LEN / sizeof (CHAR16) - 1); 239 245 } 240 246 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/Indexer.h
r48674 r77662 3 3 IpSecConfig application. 4 4 5 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 19 19 20 20 typedef struct { 21 UINT8 *Name;22 UINTN Index; // Used only if Name is NULL.21 UINT8 Name[MAX_PEERID_LEN]; 22 UINTN Index; // Used only if Name buffer is filled with zero. 23 23 } SPD_ENTRY_INDEXER; 24 24 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/IpSecConfig.c
r48674 r77662 2 2 The main process for IpSecConfig application. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 25 25 #include "Delete.h" 26 26 #include "Helper.h" 27 28 // 29 // String token ID of IpSecConfig command help message text. 30 // 31 GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringIpSecHelpTokenId = STRING_TOKEN (STR_IPSEC_CONFIG_HELP); 27 32 28 33 // … … 41 46 { L"-disable", TypeFlag }, 42 47 { L"-status", TypeFlag }, 43 { L"-?", TypeFlag },44 48 45 49 // … … 623 627 CHAR16 *ProblemParam; 624 628 UINTN NonOptionCount; 625 626 // 627 // Register our string package with HII and return the handle to it. 628 // 629 mHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, IpSecConfigStrings, NULL); 629 EFI_HII_PACKAGE_LIST_HEADER *PackageList; 630 631 // 632 // Retrieve HII package list from ImageHandle 633 // 634 Status = gBS->OpenProtocol ( 635 ImageHandle, 636 &gEfiHiiPackageListProtocolGuid, 637 (VOID **) &PackageList, 638 ImageHandle, 639 NULL, 640 EFI_OPEN_PROTOCOL_GET_PROTOCOL 641 ); 642 if (EFI_ERROR (Status)) { 643 return Status; 644 } 645 646 // 647 // Publish HII package list to HII Database. 648 // 649 Status = gHiiDatabase->NewPackageList ( 650 gHiiDatabase, 651 PackageList, 652 NULL, 653 &mHiiHandle 654 ); 655 if (EFI_ERROR (Status)) { 656 return Status; 657 } 658 630 659 ASSERT (mHiiHandle != NULL); 631 660 … … 729 758 } 730 759 731 if (ShellCommandLineGetFlag (ParamPackage, L"-?")) {732 if (DataType == -1) {733 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_HELP), mHiiHandle);734 goto Done;735 }736 737 switch (DataType) {738 case IPsecConfigDataTypeSpd:739 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_SPD_HELP), mHiiHandle);740 break;741 742 case IPsecConfigDataTypeSad:743 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_SAD_HELP), mHiiHandle);744 break;745 746 case IPsecConfigDataTypePad:747 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_PAD_HELP), mHiiHandle);748 break;749 750 default:751 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IPSEC_CONFIG_INCORRECT_DB), mHiiHandle);752 break;753 }754 755 goto Done;756 }757 758 760 NonOptionCount = ShellCommandLineGetCount (ParamPackage); 759 761 if ((NonOptionCount - 1) > 0) { -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/IpSecConfig.h
r48674 r77662 2 2 The internal structure and function declaration in IpSecConfig application. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 23 23 #include <Library/MemoryAllocationLib.h> 24 24 #include <Library/UefiBootServicesTableLib.h> 25 #include <Library/UefiHiiServicesLib.h> 25 26 #include <Library/NetLib.h> 26 27 27 28 #include <Protocol/IpSecConfig.h> 28 29 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))30 29 31 30 #define IPSECCONFIG_STATUS_NAME L"IpSecStatus" -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
r58466 r77662 25 25 ENTRY_POINT = InitializeIpSecConfig 26 26 MODULE_UNI_FILE = IpSecConfig.uni 27 28 # 29 # 30 # This flag specifies whether HII resource section is generated into PE image. 31 # 32 UEFI_HII_RESOURCE_SECTION = TRUE 27 33 28 34 [Sources] … … 53 59 UefiBootServicesTableLib 54 60 UefiApplicationEntryPoint 61 UefiHiiServicesLib 55 62 BaseMemoryLib 56 63 ShellLib … … 64 71 gEfiIpSec2ProtocolGuid ##CONSUMES 65 72 gEfiIpSecConfigProtocolGuid ##CONSUMES 73 gEfiHiiPackageListProtocolGuid ##CONSUMES 66 74 67 75 [UserExtensions.TianoCore."ExtraFiles"] -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/IpSecConfig.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Shell application IpSecConfig. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/IpSecConfigExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // IpSecConfig Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/IpSecConfigStrings.uni
r58466 r77662 1 /** @file1 /** @file 2 2 String definitions for the Shell IpSecConfig application. 3 3 … … 50 50 #string STR_IPSEC_CONFIG_INSERT_UNSUPPORT #language en-US "%s: Policy entry insertion not supported!\n" 51 51 52 #string STR_IPSEC_CONFIG_LINE_HELP #language en-US "Displays or modifies the IPsec configuration"53 54 #string STR_IPSEC_CONFIG_HELP #language en-US "Displays or modifies the current IPsec configuration.\n"55 "%HUsage: IpSecConfig [-p {SPD|SAD|PAD}] [command] [options[parameters]]%N\n"56 "\n"57 "%H-p (SPD|SAD|PAD)%N required.point to certain policy database.\n"58 "%Hcommand%N:\n"59 " -a [options[parameters]] Add new policy entry.\n"60 " -i entryid [options[parameters]] Insert new policy entry before the one\n"61 " matched by the entryid.\n"62 " It's only supported on SPD policy database.\n"63 " -d entryid Delete the policy entry matched by the \n"64 " entryid.\n"65 " -e entryid [options[parameters]] Edit the policy entry matched by the\n"66 " entryid.\n"67 " -f Flush the entire policy database.\n"68 " -l List all entries for specified database.\n"69 " -enable Enable IPsec.\n"70 " -disable Disable IPsec.\n"71 " -status Show IPsec current status.\n"72 "%H[options[parametes]]%N depend on the type of policy database.Type\n "73 " 'IpSecConfig -p'followed by the database \n"74 " name, and then type ' -?'.\n"75 " e.g.: 'IpSecConfig -p SPD -?'\n"76 77 #string STR_IPSEC_CONFIG_SPD_HELP #language en-US "Explain the %H[options[parametes]%N for %HSPD%N\n"78 "\n"79 "%H[options[parameters]]%N:\n"80 " --local localaddress optional local address\n"81 " --remote remoteaddress required remote address\n"82 " --proto (TCP|UDP|ICMP|...) required IP protocol\n"83 " --local-port port optional local port for tcp/udp protocol\n"84 " --remote-port port optional remote port for tcp/udp protocol\n"85 " --name name optional SPD name\n"86 " --action (Bypass|Discard|Protect) required \n"87 " required IPsec action\n"88 " --mode (Transport|Tunnel) optional IPsec mode, transport by default\n"89 " --ipsec-proto (AH|ESP) optional IPsec protocol, ESP by default\n"90 " --auth-algo (NONE|SHA1HMAC) optional authentication algorithm\n"91 " --encrypt-algo(NONE|DESCBC|3DESCBC)optional encryption algorithm\n"92 " --tunnel-local tunnellocaladdr optional tunnel local address(only for tunnel mode)\n"93 " --tunnel-remote tunnelremoteaddr optional tunnel remote address(only for tunnel mode)\n"94 "\n"95 96 #string STR_IPSEC_CONFIG_SAD_HELP #language en-US "Explain the %H[options[parameters]]%N for %HSAD%N\n"97 "\n"98 "%H[options[parameters]]%N:\n"99 " --spi spi required SPI value\n"100 " --ipsec-proto (AH|ESP) required IPsec protocol\n"101 " --local localaddress optional local address\n"102 " --remote remoteaddress required destination address\n"103 " --auth-algo (NONE|SHA1HMAC) required for AH. authentication algorithm\n"104 " --auth-key key required for AH. key for authentication\n"105 " --encrypt-algo (NONE|DESCBC|3DESCBC) required for ESP. encryption algorithm\n"106 " --encrypt-key key required for ESP. key for encryption\n"107 " --mode (Transport|Tunnel) optional IPsec mode, transport by default\n"108 " --tunnel-dest tunneldestaddr optional tunnel destination address(only for tunnel mode)\n"109 " --tunnel-source tunnelsourceaddr optional tunnel source address(only for tunnel mode)\n"110 "\n"111 112 #string STR_IPSEC_CONFIG_PAD_HELP #language en-US "Explain the %H[options[parameters]]%N for %HPAD%N\n"113 "\n"114 "%H[options[parameters]]%N:\n"115 " --peer-address address required peer address\n"116 " --auth-proto (IKEv1|IKEv2) optional IKE protocol, IKEv1 by\n"117 " default\n"118 " --auth-method (PreSharedSecret|Certificates) required authentication method\n"119 " --auth-data authdata required data for authentication\n"120 "\n"121 122 52 #string STR_IPSEC_MISTAKEN_OPTIONS #language en-US "Mistaken Input. Please refer to %H"IpSecConfig -?"%N for more help information.\n" 123 53 … … 140 70 #string STR_IPSEC_CONFIG_DISABLE_FAILED #language en-US "Error: Disable IPsec failed !\n" 141 71 72 #string STR_IPSEC_CONFIG_HELP #language en-US "" 73 ".TH IpSecConfig 0 "Displays or modifies the current IPsec configuration."\r\n" 74 ".SH NAME\r\n" 75 "Displays or modifies the current IPsec configuration.\r\n" 76 ".SH SYNOPSIS\r\n" 77 " \r\n" 78 "%HIpSecConfig [-p {SPD|SAD|PAD}] [command] [options[parameters]]\r\n" 79 ".SH OPTIONS\r\n" 80 " \r\n" 81 "%H-p (SPD|SAD|PAD)%N required.point to certain policy database.\r\n" 82 " \r\n" 83 "%Hcommand%N:\r\n" 84 " -a [options[parameters]] Add new policy entry.\r\n" 85 " -i entryid [options[parameters]] Insert new policy entry before the one\r\n" 86 " matched by the entryid.\r\n" 87 " It's only supported on SPD policy database.\r\n" 88 " -d entryid Delete the policy entry matched by the \r\n" 89 " entryid.\r\n" 90 " -e entryid [options[parameters]] Edit the policy entry matched by the\r\n" 91 " entryid.\r\n" 92 " -f Flush the entire policy database.\r\n" 93 " -l List all entries for specified database.\r\n" 94 " -enable Enable IPsec.\r\n" 95 " -disable Disable IPsec.\r\n" 96 " -status Show IPsec current status.\r\n" 97 " \r\n" 98 "%H[options[parameters]]%N for %HSPD%N:\r\n" 99 " --local localaddress optional local address\r\n" 100 " --remote remoteaddress required remote address\r\n" 101 " --proto (TCP|UDP|ICMP|...) required IP protocol\r\n" 102 " --local-port port optional local port for tcp/udp protocol\r\n" 103 " --remote-port port optional remote port for tcp/udp protocol\r\n" 104 " --name name optional SPD name\r\n" 105 " --action (Bypass|Discard|Protect) required \r\n" 106 " required IPsec action\r\n" 107 " --mode (Transport|Tunnel) optional IPsec mode, transport by default\r\n" 108 " --ipsec-proto (AH|ESP) optional IPsec protocol, ESP by default\r\n" 109 " --auth-algo (NONE|SHA1HMAC) optional authentication algorithm\r\n" 110 " --encrypt-algo(NONE|DESCBC|3DESCBC)optional encryption algorithm\r\n" 111 " --tunnel-local tunnellocaladdr optional tunnel local address(only for tunnel mode)\r\n" 112 " --tunnel-remote tunnelremoteaddr optional tunnel remote address(only for tunnel mode)\r\n" 113 " \r\n" 114 "%H[options[parameters]]%N for %HSAD%N:\r\n" 115 " --spi spi required SPI value\r\n" 116 " --ipsec-proto (AH|ESP) required IPsec protocol\r\n" 117 " --local localaddress optional local address\r\n" 118 " --remote remoteaddress required destination address\r\n" 119 " --auth-algo (NONE|SHA1HMAC) required for AH. authentication algorithm\n" 120 " --auth-key key required for AH. key for authentication\r\n" 121 " --encrypt-algo (NONE|DESCBC|3DESCBC) required for ESP. encryption algorithm\r\n" 122 " --encrypt-key key required for ESP. key for encryption\r\n" 123 " --mode (Transport|Tunnel) optional IPsec mode, transport by default\r\n" 124 " --tunnel-dest tunneldestaddr optional tunnel destination address(only for tunnel mode)\r\n" 125 " --tunnel-source tunnelsourceaddr optional tunnel source address(only for tunnel mode)\r\n" 126 " \r\n" 127 "%H[options[parameters]]%N for %HPAD%N:\r\n" 128 " --peer-address address required peer address\r\n" 129 " --auth-proto (IKEv1|IKEv2) optional IKE protocol, IKEv1 by\r\n" 130 " default\r\n" 131 " --auth-method (PreSharedSecret|Certificates) required authentication method\r\n" 132 " --auth-data authdata required data for authentication\r\n" 133 " \r\n" -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/Match.c
r48674 r77662 2 2 The implementation of match policy entry function in IpSecConfig application. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 64 64 65 65 Match = FALSE; 66 if ( Indexer->Name != NULL) {66 if (!IsMemoryZero (Indexer->Name, MAX_PEERID_LEN)) { 67 67 if ((Data->Name != NULL) && (AsciiStrCmp ((CHAR8 *) Indexer->Name, (CHAR8 *) Data->Name) == 0)) { 68 68 Match = TRUE; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/IpsecConfig/PolicyEntryOperation.c
r48674 r77662 2 2 The implementation of policy entry operation function in IpSecConfig application. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 272 272 ValueStr = ShellCommandLineGetValue (ParamPackage, L"--name"); 273 273 if (ValueStr != NULL) { 274 UnicodeStrToAsciiStr (ValueStr, (CHAR8 *) (*Data)->Name);274 UnicodeStrToAsciiStrS (ValueStr, (CHAR8 *) (*Data)->Name, sizeof ((*Data)->Name)); 275 275 *Mask |= NAME; 276 276 } … … 786 786 AsciiStr = AllocateZeroPool (EncKeyLength + 1); 787 787 ASSERT (AsciiStr != NULL); 788 UnicodeStrToAsciiStr (ValueStr, AsciiStr);788 UnicodeStrToAsciiStrS (ValueStr, AsciiStr, EncKeyLength + 1); 789 789 CopyMem ((*Data)->AlgoInfo.EspAlgoInfo.EncKey, AsciiStr, EncKeyLength); 790 790 FreePool (AsciiStr); … … 816 816 AsciiStr = AllocateZeroPool (AuthKeyLength + 1); 817 817 ASSERT (AsciiStr != NULL); 818 UnicodeStrToAsciiStr (ValueStr, AsciiStr);818 UnicodeStrToAsciiStrS (ValueStr, AsciiStr, AuthKeyLength + 1); 819 819 CopyMem ((*Data)->AlgoInfo.EspAlgoInfo.AuthKey, AsciiStr, AuthKeyLength); 820 820 FreePool (AsciiStr); … … 1105 1105 if (ValueStr != NULL) { 1106 1106 (*PadId)->PeerIdValid = TRUE; 1107 StrnCpy ((CHAR16 *) (*PadId)->Id.PeerId, ValueStr, ARRAY_SIZE ((*PadId)->Id.PeerId) - 1);1107 StrnCpyS ((CHAR16 *) (*PadId)->Id.PeerId, MAX_PEERID_LEN / sizeof (CHAR16), ValueStr, MAX_PEERID_LEN / sizeof (CHAR16) - 1); 1108 1108 *Mask |= PEER_ID; 1109 1109 } … … 1399 1399 // Process Data 1400 1400 // 1401 OldData->SaIdCount = 0; 1402 1401 1403 if ((Mask & NAME) != 0) { 1402 AsciiStrCpy ((CHAR8 *) OldData->Name, (CHAR8 *) NewData->Name);1404 AsciiStrCpyS ((CHAR8 *) OldData->Name, MAX_PEERID_LEN, (CHAR8 *) NewData->Name); 1403 1405 } 1404 1406 … … 1863 1865 ); 1864 1866 if (!EFI_ERROR (Status)) { 1867 // 1868 // If the Selector already existed, this Entry will be updated by set data. 1869 // 1870 Status = mIpSecConfig->SetData ( 1871 mIpSecConfig, 1872 Context->DataType, 1873 Context->Selector, /// New created selector. 1874 Data, /// Old date which has been modified, need to be set data. 1875 Selector 1876 ); 1877 ASSERT_EFI_ERROR (Status); 1878 1865 1879 if (CreateNew) { 1866 1880 // 1867 // Insert new entry before old entry1881 // Edit the entry to a new one. So, we need delete the old entry. 1868 1882 // 1869 1883 Status = mIpSecConfig->SetData ( 1870 1884 mIpSecConfig, 1871 1885 Context->DataType, 1872 Context->Selector, 1873 Data, 1874 Selector 1875 ); 1876 ASSERT_EFI_ERROR (Status); 1877 // 1878 // Delete old entry 1879 // 1880 Status = mIpSecConfig->SetData ( 1881 mIpSecConfig, 1882 Context->DataType, 1883 Selector, 1884 NULL, 1886 Selector, /// Old selector. 1887 NULL, /// NULL means to delete this Entry specified by Selector. 1885 1888 NULL 1886 1889 ); 1887 1890 ASSERT_EFI_ERROR (Status); 1888 } else {1889 Status = mIpSecConfig->SetData (1890 mIpSecConfig,1891 Context->DataType,1892 Context->Selector,1893 Data,1894 NULL1895 );1896 1891 } 1897 1892 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/VConfig/VConfig.c
r58459 r77662 2 2 Shell application for VLAN configuration. 3 3 4 Copyright (c) 2009 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 24 24 #include <Library/HiiLib.h> 25 25 #include <Library/UefiBootServicesTableLib.h> 26 #include <Library/UefiHiiServicesLib.h> 26 27 #include <Library/NetLib.h> 28 29 // 30 // String token ID of VConfig command help message text. 31 // 32 GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringVConfigHelpTokenId = STRING_TOKEN (STR_VCONFIG_HELP); 27 33 28 34 #define INVALID_NIC_INDEX 0xffff … … 609 615 LIST_ENTRY *List; 610 616 CONST CHAR16 *Str; 617 EFI_HII_PACKAGE_LIST_HEADER *PackageList; 618 EFI_STATUS Status; 611 619 612 620 mImageHandle = ImageHandle; 613 621 614 622 // 615 // Register our string package to HII database. 616 // 617 mHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, VConfigStrings, NULL); 623 // Retrieve HII package list from ImageHandle 624 // 625 Status = gBS->OpenProtocol ( 626 ImageHandle, 627 &gEfiHiiPackageListProtocolGuid, 628 (VOID **) &PackageList, 629 ImageHandle, 630 NULL, 631 EFI_OPEN_PROTOCOL_GET_PROTOCOL 632 ); 633 if (EFI_ERROR (Status)) { 634 return Status; 635 } 636 637 // 638 // Publish HII package list to HII Database. 639 // 640 Status = gHiiDatabase->NewPackageList ( 641 gHiiDatabase, 642 PackageList, 643 NULL, 644 &mHiiHandle 645 ); 646 if (EFI_ERROR (Status)) { 647 return Status; 648 } 649 618 650 if (mHiiHandle == NULL) { 619 651 return EFI_SUCCESS; … … 627 659 } 628 660 629 if (ShellCommandLineGetFlag (List, L"-?")) {630 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_HELP), mHiiHandle);631 goto Exit;632 }633 634 661 if (ShellCommandLineGetFlag (List, L"-l")) { 635 662 Str = ShellCommandLineGetValue (List, L"-l"); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/VConfig/VConfig.inf
r58459 r77662 4 4 # It is shell application which is used to get and set VLAN configuration. 5 5 # 6 # Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>6 # Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 7 7 # 8 8 # This program and the accompanying materials … … 26 26 27 27 # 28 # 29 # This flag specifies whether HII resource section is generated into PE image. 30 # 31 UEFI_HII_RESOURCE_SECTION = TRUE 32 33 # 28 34 # VALID_ARCHITECTURES = IA32 X64 IPF 29 35 # … … 41 47 UefiApplicationEntryPoint 42 48 UefiBootServicesTableLib 49 UefiHiiServicesLib 43 50 UefiLib 44 51 ShellLib … … 48 55 49 56 [Protocols] 50 gEfiVlanConfigProtocolGuid ## CONSUMES 57 gEfiVlanConfigProtocolGuid ## CONSUMES 58 gEfiHiiPackageListProtocolGuid ## CONSUMES 51 59 52 60 [UserExtensions.TianoCore."ExtraFiles"] -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/VConfig/VConfig.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Shell application VLAN configuration. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/VConfig/VConfigExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // VConfig Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Application/VConfig/VConfigStrings.uni
r58466 r77662 1 /** @file1 /** @file 2 2 String definitions for VLAN configuration Shell application. 3 3 4 Copyright (c) 2009 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 33 33 #string STR_VCONFIG_REMOVE_SUCCESS #language en-US "VLAN device removed.\n" 34 34 #string STR_VCONFIG_NO_ARG #language en-US "Invalid argument, try "-?" for help.\n" 35 #string STR_VCONFIG_HELP #language en-US "Display or modify VLAN configuration for network interface.\n\n" 36 "VCONFIG [-?] [-l [IfName]] [-a IfName VlanId [Priority]] [-d IfName.VlanId]\n" 37 "\n" 38 " -l Display VLAN configuration for all or specified interface.\n" 39 " -a Add a VLAN device for the network interface.\n" 40 " -d Delete a VLAN device.\n" 41 " IfName Name of network interface, e.g. eth0, eth1.\n" 42 " VlanId Unique VLAN identifier (0~4094).\n" 43 " Priority 802.1Q priority level (0~7), default 0.\n" 44 "\n" 45 "Examples:\n" 46 " * To display VLAN configuration:\n" 47 " fs0:\> vconfig -l\n" 48 " fs0:\> vconfig -l eth0\n" 49 "\n" 50 " * To add VLAN device:\n" 51 " fs0:\> vconfig -a eth0 1000\n" 52 " fs0:\> vconfig -a eth0 2000 7\n" 53 "\n" 54 " * To delete VLAN device:\n" 55 " fs0:\> vconfig -d eth0.1000\n" 35 36 #string STR_VCONFIG_HELP #language en-US "" 37 ".TH VConfig 0 "Display or modify VLAN configuration for network interface."\r\n" 38 ".SH NAME\r\n" 39 "Display or modify VLAN configuration for network interface.\r\n" 40 ".SH SYNOPSIS\r\n" 41 " \r\n" 42 "VCONFIG [-?] [-l [IfName]] [-a IfName VlanId [Priority]] [-d IfName.VlanId]\r\n" 43 ".SH OPTIONS\r\n" 44 " \r\n" 45 " -l Display VLAN configuration for all or specified interface.\r\n" 46 " -a Add a VLAN device for the network interface.\r\n" 47 " -d Delete a VLAN device.\r\n" 48 " IfName Name of network interface, e.g. eth0, eth1.\r\n" 49 " VlanId Unique VLAN identifier (0~4094).\r\n" 50 " Priority 802.1Q priority level (0~7), default 0.\r\n" 51 ".SH EXAMPLES\r\n" 52 " \r\n" 53 "Examples:\r\n" 54 " * To display VLAN configuration:\r\n" 55 " fs0:\> vconfig -l\r\n" 56 " fs0:\> vconfig -l eth0\r\n" 57 "\r\n" 58 " * To add VLAN device:\r\n" 59 " fs0:\> vconfig -a eth0 1000\r\n" 60 " fs0:\> vconfig -a eth0 2000 7\r\n" 61 "\r\n" 62 " * To delete VLAN device:\r\n" 63 " fs0:\> vconfig -d eth0.1000\r\n" -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/ComponentName.c
r58466 r77662 2 2 UEFI Component Name(2) protocol implementation for Dhcp6 driver. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 288 288 } 289 289 290 if (Dhcp6ModeData.Ia != NULL) { 291 FreePool (Dhcp6ModeData.Ia); 292 } 293 if (Dhcp6ModeData.ClientId != NULL) { 294 FreePool (Dhcp6ModeData.ClientId); 295 } 296 290 297 Status = AddUnicodeString2 ( 291 298 "eng", -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.h
r58459 r77662 3 3 declaration for Dhcp6 Driver. 4 4 5 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 117 117 @retval EFI_SUCCES The protocol was added to ChildHandle. 118 118 @retval EFI_INVALID_PARAMETER ChildHandle is NULL. 119 @retval EFI_OUT_OF_RESOURCES There are not enough resources availab e to create119 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create 120 120 the child. 121 121 @retval other The child handle was not created. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf
r58466 r77662 5 5 # and other configuration parameters from DHCPv6 servers. 6 6 # 7 # Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 7 # (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 8 # Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 8 9 # 9 10 # This program and the accompanying materials … … 52 53 MdePkg/MdePkg.dec 53 54 MdeModulePkg/MdeModulePkg.dec 54 55 NetworkPkg/NetworkPkg.dec 55 56 56 57 [LibraryClasses] … … 74 75 gEfiIp6ConfigProtocolGuid ## TO_START 75 76 77 [Guids] 78 gZeroGuid ## SOMETIMES_CONSUMES ## GUID 79 80 [Pcd] 81 gEfiNetworkPkgTokenSpaceGuid.PcdDhcp6UidType ## SOMETIMES_CONSUMES 82 76 83 [UserExtensions.TianoCore."ExtraFiles"] 77 84 Dhcp6DxeExtra.uni -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Client-side DHCPv6 services. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6DxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Dhcp6Dxe Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c
r58466 r77662 2 2 This EFI_DHCP6_PROTOCOL interface implementation. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 77 77 DHCP6_INSTANCE *Instance; 78 78 DHCP6_SERVICE *Service; 79 EFI_STATUS MediaStatus; 79 80 80 81 if (This == NULL) { … … 102 103 103 104 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 105 106 // 107 // Check Media Satus. 108 // 109 MediaStatus = EFI_SUCCESS; 110 NetLibDetectMediaWaitTimeout (Service->Controller, DHCP_CHECK_MEDIA_WAITING_TIME, &MediaStatus); 111 if (MediaStatus != EFI_SUCCESS) { 112 Status = EFI_NO_MEDIA; 113 goto ON_ERROR; 114 } 115 104 116 Instance->UdpSts = EFI_ALREADY_STARTED; 105 117 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
r58466 r77662 2 2 Dhcp6 internal data structure and definition declaration. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 19 19 20 20 #include <Uefi.h> 21 22 #include <IndustryStandard/Dhcp.h> 21 23 22 24 #include <Protocol/Dhcp6.h> … … 36 38 #include <Library/NetLib.h> 37 39 #include <Library/PrintLib.h> 40 #include <Guid/ZeroGuid.h> 38 41 39 42 … … 51 54 #define DHCP6_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'I') 52 55 53 //54 // Transmit parameters of solicit message, refers to section-5.5 of rfc-3315.55 //56 #define DHCP6_SOL_MAX_DELAY 157 #define DHCP6_SOL_IRT 158 #define DHCP6_SOL_MRC 059 #define DHCP6_SOL_MRT 12060 #define DHCP6_SOL_MRD 061 //62 // Transmit parameters of request message, refers to section-5.5 of rfc-3315.63 //64 #define DHCP6_REQ_IRT 165 #define DHCP6_REQ_MRC 1066 #define DHCP6_REQ_MRT 3067 #define DHCP6_REQ_MRD 068 //69 // Transmit parameters of confirm message, refers to section-5.5 of rfc-3315.70 //71 #define DHCP6_CNF_MAX_DELAY 172 #define DHCP6_CNF_IRT 173 #define DHCP6_CNF_MRC 074 #define DHCP6_CNF_MRT 475 #define DHCP6_CNF_MRD 1076 //77 // Transmit parameters of renew message, refers to section-5.5 of rfc-3315.78 //79 #define DHCP6_REN_IRT 1080 #define DHCP6_REN_MRC 081 #define DHCP6_REN_MRT 60082 #define DHCP6_REN_MRD 083 //84 // Transmit parameters of rebind message, refers to section-5.5 of rfc-3315.85 //86 #define DHCP6_REB_IRT 1087 #define DHCP6_REB_MRC 088 #define DHCP6_REB_MRT 60089 #define DHCP6_REB_MRD 090 //91 // Transmit parameters of information request message, refers to section-5.5 of rfc-3315.92 //93 #define DHCP6_INF_MAX_DELAY 194 #define DHCP6_INF_IRT 195 #define DHCP6_INF_MRC 096 #define DHCP6_INF_MRT 12097 #define DHCP6_INF_MRD 098 //99 // Transmit parameters of release message, refers to section-5.5 of rfc-3315.100 //101 #define DHCP6_REL_IRT 1102 #define DHCP6_REL_MRC 5103 #define DHCP6_REL_MRT 0104 #define DHCP6_REL_MRD 0105 //106 // Transmit parameters of decline message, refers to section-5.5 of rfc-3315.107 //108 #define DHCP6_DEC_IRT 1109 #define DHCP6_DEC_MRC 5110 #define DHCP6_DEC_MRT 0111 #define DHCP6_DEC_MRD 0112 113 56 #define DHCP6_PACKET_ALL 0 114 57 #define DHCP6_PACKET_STATEFUL 1 … … 120 63 #define DHCP6_PORT_SERVER 547 121 64 65 #define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) 66 122 67 #define DHCP6_INSTANCE_FROM_THIS(Instance) CR ((Instance), DHCP6_INSTANCE, Dhcp6, DHCP6_INSTANCE_SIGNATURE) 123 68 #define DHCP6_SERVICE_FROM_THIS(Service) CR ((Service), DHCP6_SERVICE, ServiceBinding, DHCP6_SERVICE_SIGNATURE) … … 126 71 extern EFI_IPv6_ADDRESS mAllDhcpServersAddress; 127 72 extern EFI_DHCP6_PROTOCOL gDhcp6ProtocolTemplate; 128 129 //130 // Enumeration of Dhcp6 message type, refers to section-5.3 of rfc-3315.131 //132 typedef enum {133 Dhcp6MsgSolicit = 1,134 Dhcp6MsgAdvertise = 2,135 Dhcp6MsgRequest = 3,136 Dhcp6MsgConfirm = 4,137 Dhcp6MsgRenew = 5,138 Dhcp6MsgRebind = 6,139 Dhcp6MsgReply = 7,140 Dhcp6MsgRelease = 8,141 Dhcp6MsgDecline = 9,142 Dhcp6MsgReconfigure = 10,143 Dhcp6MsgInfoRequest = 11144 } DHCP6_MSG_TYPE;145 146 //147 // Enumeration of option code in Dhcp6 packet, refers to section-24.3 of rfc-3315.148 //149 typedef enum {150 Dhcp6OptClientId = 1,151 Dhcp6OptServerId = 2,152 Dhcp6OptIana = 3,153 Dhcp6OptIata = 4,154 Dhcp6OptIaAddr = 5,155 Dhcp6OptRequestOption = 6,156 Dhcp6OptPreference = 7,157 Dhcp6OptElapsedTime = 8,158 Dhcp6OptReplayMessage = 9,159 Dhcp6OptAuthentication = 11,160 Dhcp6OptServerUnicast = 12,161 Dhcp6OptStatusCode = 13,162 Dhcp6OptRapidCommit = 14,163 Dhcp6OptUserClass = 15,164 Dhcp6OptVendorClass = 16,165 Dhcp6OptVendorInfo = 17,166 Dhcp6OptInterfaceId = 18,167 Dhcp6OptReconfigMessage = 19,168 Dhcp6OptReconfigureAccept = 20169 } DHCP6_OPT_CODE;170 171 //172 // Enumeration of status code recorded by IANA, refers to section-24.4 of rfc-3315.173 //174 typedef enum {175 Dhcp6StsSuccess = 0,176 Dhcp6StsUnspecFail = 1,177 Dhcp6StsNoAddrsAvail = 2,178 Dhcp6StsNoBinding = 3,179 Dhcp6StsNotOnLink = 4,180 Dhcp6StsUseMulticast = 5181 } DHCP6_STS_CODE;182 183 //184 // Enumeration of Duid type recorded by IANA, refers to section-24.5 of rfc-3315.185 //186 typedef enum {187 Dhcp6DuidTypeLlt = 1,188 Dhcp6DuidTypeEn = 2,189 Dhcp6DuidTypeLl = 3,190 Dhcp6DuidTypeUuid = 4191 } DHCP6_DUID_TYPE;192 73 193 74 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
r58466 r77662 2 2 Dhcp6 internal functions implementation. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 545 546 { 546 547 EFI_STATUS Status; 547 EFI_DHCP6_STATE State;548 548 UINT8 *Option; 549 549 UINT8 *IaInnerOpt; … … 566 566 // See details in the section-18.1.8 of rfc-3315. 567 567 // 568 State = Dhcp6Init;569 568 Option = Dhcp6SeekIaOption ( 570 569 Packet->Dhcp6.Option, … … 2429 2428 EFI_STATUS Status; 2430 2429 UINT8 *Option; 2431 UINT16 StsCode;2432 2430 BOOLEAN Timeout; 2433 2431 … … 2436 2434 2437 2435 Timeout = FALSE; 2438 StsCode = Dhcp6StsSuccess;2439 2436 2440 2437 // … … 2816 2813 LIST_ENTRY *Entry2; 2817 2814 LIST_ENTRY *Next2; 2815 EFI_STATUS Status; 2818 2816 2819 2817 ASSERT (Udp6Wrap != NULL); … … 2828 2826 if (EFI_ERROR (IoStatus)) { 2829 2827 return ; 2828 } 2829 2830 if (Udp6Wrap->TotalSize < sizeof (EFI_DHCP6_HEADER)) { 2831 goto ON_CONTINUE; 2830 2832 } 2831 2833 … … 2894 2896 2895 2897 ON_CONTINUE: 2898 2899 if (!IsDispatched) { 2900 Status = UdpIoRecvDatagram ( 2901 Service->UdpIo, 2902 Dhcp6ReceivePacket, 2903 Service, 2904 0 2905 ); 2906 if (EFI_ERROR (Status)) { 2907 NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) { 2908 Instance = NET_LIST_USER_STRUCT (Entry1, DHCP6_INSTANCE, Link); 2909 Dhcp6CleanupRetry (Instance, DHCP6_PACKET_ALL); 2910 } 2911 } 2912 } 2896 2913 2897 2914 NetbufFree (Udp6Wrap); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
r58466 r77662 2 2 Dhcp6 support functions implementation. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 64 65 // If System UUID is found from SMBIOS Table, use DUID-UUID type. 65 66 // 66 if ( !EFI_ERROR (NetLibGetSystemGuid (&Uuid))) {67 if ((PcdGet8 (PcdDhcp6UidType) == Dhcp6DuidTypeUuid) && !EFI_ERROR (NetLibGetSystemGuid (&Uuid)) && !CompareGuid (&Uuid, &gZeroGuid)) { 67 68 // 68 69 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiCHAP.c
r58466 r77662 2 2 This file is for Challenge-Handshake Authentication Protocol (CHAP) Configuration. 3 3 4 Copyright (c) 2004 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 16 16 17 17 /** 18 Initator ca culates its own expected hash value.18 Initator calculates its own expected hash value. 19 19 20 20 @param[in] ChapIdentifier iSCSI CHAP identifier sent by authenticator. … … 25 25 @param[out] ChapResponse The calculation of the expected hash value. 26 26 27 @retval EFI_SUCCESS The expected hash value was ca culatedly successfully.27 @retval EFI_SUCCESS The expected hash value was calculatedly successfully. 28 28 @retval EFI_PROTOCOL_ERROR The length of the secret should be at least the 29 29 length of the hash value for the hashing algorithm chosen. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiConfig.c
r58466 r77662 2 2 Helper functions for configuring or getting the parameters relating to iSCSI. 3 3 4 Copyright (c) 2004 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 165 165 { 166 166 if (IpMode == IP_MODE_IP4) { 167 return NetIp4IsUnicast (NTOHL (Ip->Addr[0]), 0); 167 if (IP4_IS_UNSPECIFIED (NTOHL (Ip->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip->Addr[0]))) { 168 return FALSE; 169 } 170 return TRUE; 168 171 } else if (IpMode == IP_MODE_IP6) { 169 172 return NetIp6IsValidUnicast (&Ip->v6); … … 203 206 IsIdStr = (CHAR16 *) String; 204 207 205 if (StrLen (IsIdStr) != 6 ) {208 if (StrLen (IsIdStr) != 6 && StrLen (IsIdStr) != 12) { 206 209 UnicodeSPrint ( 207 210 PortString, 208 211 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 209 L"Error! Input is incorrect, please input 6 hex numbers!\n"212 L"Error! Only last 3 bytes are configurable, please input 6 hex numbers for last 3 bytes only or 12 hex numbers for full SSID!\n" 210 213 ); 211 214 … … 218 221 219 222 return EFI_INVALID_PARAMETER; 223 } 224 225 if (StrLen (IsIdStr) == 12) { 226 IsIdStr += 6; 220 227 } 221 228 … … 288 295 289 296 /** 297 Get the Offset value specified by the input String. 298 299 @param[in] Configuration A null-terminated Unicode string in 300 <ConfigString> format. 301 @param[in] String The string is "&OFFSET=". 302 @param[out] Value The Offset value. 303 304 @retval EFI_OUT_OF_RESOURCES Insufficient resources to store neccessary 305 structures. 306 @retval EFI_SUCCESS Value of <Number> is outputted in Number 307 successfully. 308 309 **/ 310 EFI_STATUS 311 IScsiGetValue ( 312 IN CONST EFI_STRING Configuration, 313 IN CHAR16 *String, 314 OUT UINTN *Value 315 ) 316 { 317 CHAR16 *StringPtr; 318 CHAR16 *TmpPtr; 319 CHAR16 *Str; 320 CHAR16 TmpStr[2]; 321 UINTN Length; 322 UINTN Len; 323 UINTN Index; 324 UINT8 *Buf; 325 UINT8 DigitUint8; 326 EFI_STATUS Status; 327 328 // 329 // Get Value. 330 // 331 Buf = NULL; 332 StringPtr = StrStr (Configuration, String); 333 ASSERT(StringPtr != NULL); 334 StringPtr += StrLen (String); 335 TmpPtr = StringPtr; 336 337 while (*StringPtr != L'\0' && *StringPtr != L'&') { 338 StringPtr ++; 339 } 340 Length = StringPtr - TmpPtr; 341 Len = Length + 1; 342 343 Str = AllocateZeroPool (Len * sizeof (CHAR16)); 344 if (Str == NULL) { 345 Status = EFI_OUT_OF_RESOURCES; 346 goto Exit; 347 } 348 349 CopyMem (Str, TmpPtr, Len * sizeof (CHAR16)); 350 *(Str + Length) = L'\0'; 351 352 Len = (Len + 1) / 2; 353 Buf = (UINT8 *) AllocateZeroPool (Len); 354 if (Buf == NULL) { 355 Status = EFI_OUT_OF_RESOURCES; 356 goto Exit; 357 } 358 359 ZeroMem (TmpStr, sizeof (TmpStr)); 360 for (Index = 0; Index < Length; Index ++) { 361 TmpStr[0] = Str[Length - Index - 1]; 362 DigitUint8 = (UINT8) StrHexToUint64 (TmpStr); 363 if ((Index & 1) == 0) { 364 Buf [Index/2] = DigitUint8; 365 } else { 366 Buf [Index/2] = (UINT8) ((DigitUint8 << 4) + Buf [Index/2]); 367 } 368 } 369 370 *Value = 0; 371 CopyMem ( 372 Value, 373 Buf, 374 (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN) 375 ); 376 377 FreePool (Buf); 378 Status = EFI_SUCCESS; 379 380 Exit: 381 if (Str != NULL) { 382 FreePool (Str); 383 } 384 385 return Status; 386 } 387 388 /** 290 389 Get the attempt config data from global structure by the ConfigIndex. 291 390 … … 347 446 } 348 447 448 /** 449 Extract the Index of the attempt list. 450 451 @param[in] AttemptNameList The Name list of the Attempts. 452 @param[out] AttemptIndexList The Index list of the Attempts. 453 @param[in] IsAddAttempts If TRUE, Indicates add one or more attempts. 454 If FALSE, Indicates delete attempts or change attempt order. 455 456 @retval EFI_SUCCESS The Attempt list is valid. 457 @retval EFI_INVALID_PARAMETERS The Attempt List is invalid. 458 459 **/ 460 EFI_STATUS 461 IScsiGetAttemptIndexList ( 462 IN CHAR16 *AttemptNameList, 463 OUT UINT8 *AttemptIndexList, 464 IN BOOLEAN IsAddAttempts 465 ) 466 { 467 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 468 CHAR16 *AttemptStr; 469 UINT8 AttemptIndex; 470 UINTN Len; 471 UINTN Index; 472 473 Index = 0; 474 475 if ((AttemptNameList == NULL) || (*AttemptNameList == L'\0')) { 476 return EFI_INVALID_PARAMETER; 477 } 478 479 AttemptStr = AttemptNameList; 480 Len = StrLen (L"attempt:"); 481 482 while (*AttemptStr != L'\0') { 483 AttemptStr = StrStr (AttemptStr, L"attempt:"); 484 if (AttemptStr == NULL) { 485 return EFI_INVALID_PARAMETER; 486 } 487 AttemptStr += Len; 488 AttemptIndex = (UINT8)(*AttemptStr - L'0'); 489 AttemptConfigData = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 490 if (IsAddAttempts) { 491 if ((AttemptConfigData != NULL) || ((AttemptIndex) > PcdGet8 (PcdMaxIScsiAttemptNumber))) { 492 return EFI_INVALID_PARAMETER; 493 } 494 } else { 495 if (AttemptConfigData == NULL) { 496 return EFI_INVALID_PARAMETER; 497 } 498 } 499 500 AttemptIndexList[Index] = AttemptIndex; 501 Index ++; 502 AttemptStr += 2; 503 } 504 return EFI_SUCCESS; 505 } 349 506 350 507 /** … … 364 521 ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData; 365 522 EFI_IP_ADDRESS Ip; 523 BOOLEAN DnsMode; 366 524 367 525 // … … 371 529 IfrNvData->Enabled = SessionConfigData->Enabled; 372 530 IfrNvData->IpMode = SessionConfigData->IpMode; 531 DnsMode = SessionConfigData->DnsMode; 373 532 374 533 IfrNvData->InitiatorInfoFromDhcp = SessionConfigData->InitiatorInfoFromDhcp; … … 383 542 CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof (EFI_IPv4_ADDRESS)); 384 543 IScsiIpToStr (&Ip, FALSE, IfrNvData->Gateway); 385 CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS)); 386 IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp); 544 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); 545 if (SessionConfigData->TargetIp.v4.Addr[0] != '\0') { 546 CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS)); 547 IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp); 548 } 549 387 550 } else if (IfrNvData->IpMode == IP_MODE_IP6) { 388 551 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); 389 IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp); 390 IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp); 391 } 392 393 AsciiStrToUnicodeStr (SessionConfigData->TargetName, IfrNvData->TargetName); 552 if (SessionConfigData->TargetIp.v6.Addr[0] != '\0') { 553 IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp); 554 IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp); 555 } 556 } 557 558 AsciiStrToUnicodeStrS ( 559 SessionConfigData->TargetName, 560 IfrNvData->TargetName, 561 sizeof (IfrNvData->TargetName) / sizeof (IfrNvData->TargetName[0]) 562 ); 563 564 if (DnsMode) { 565 AsciiStrToUnicodeStrS ( 566 SessionConfigData->TargetUrl, 567 IfrNvData->TargetIp, 568 sizeof (IfrNvData->TargetIp) / sizeof (IfrNvData->TargetIp[0]) 569 ); 570 } 571 394 572 IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun); 395 573 IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId); … … 406 584 AuthConfigData = &Attempt->AuthConfigData.CHAP; 407 585 IfrNvData->CHAPType = AuthConfigData->CHAPType; 408 AsciiStrToUnicodeStr (AuthConfigData->CHAPName, IfrNvData->CHAPName); 409 AsciiStrToUnicodeStr (AuthConfigData->CHAPSecret, IfrNvData->CHAPSecret); 410 AsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPName, IfrNvData->ReverseCHAPName); 411 AsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPSecret, IfrNvData->ReverseCHAPSecret); 586 AsciiStrToUnicodeStrS ( 587 AuthConfigData->CHAPName, 588 IfrNvData->CHAPName, 589 sizeof (IfrNvData->CHAPName) / sizeof (IfrNvData->CHAPName[0]) 590 ); 591 AsciiStrToUnicodeStrS ( 592 AuthConfigData->CHAPSecret, 593 IfrNvData->CHAPSecret, 594 sizeof (IfrNvData->CHAPSecret) / sizeof (IfrNvData->CHAPSecret[0]) 595 ); 596 AsciiStrToUnicodeStrS ( 597 AuthConfigData->ReverseCHAPName, 598 IfrNvData->ReverseCHAPName, 599 sizeof (IfrNvData->ReverseCHAPName) / sizeof (IfrNvData->ReverseCHAPName[0]) 600 ); 601 AsciiStrToUnicodeStrS ( 602 AuthConfigData->ReverseCHAPSecret, 603 IfrNvData->ReverseCHAPSecret, 604 sizeof (IfrNvData->ReverseCHAPSecret) / sizeof (IfrNvData->ReverseCHAPSecret[0]) 605 ); 412 606 } 413 607 … … 415 609 // Other parameters. 416 610 // 417 AsciiStrToUnicodeStr (Attempt->AttemptName, IfrNvData->AttemptName); 611 AsciiStrToUnicodeStrS ( 612 Attempt->AttemptName, 613 IfrNvData->AttemptName, 614 sizeof (IfrNvData->AttemptName) / sizeof (IfrNvData->AttemptName[0]) 615 ); 616 } 617 618 /** 619 Convert the iSCSI configuration data into the IFR data Which will be used 620 to extract the iSCSI Keyword configuration in <ConfigAltResp> format. 621 622 @param[in, out] IfrNvData The IFR nv data. 623 624 **/ 625 VOID 626 EFIAPI 627 IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( 628 IN OUT ISCSI_CONFIG_IFR_NVDATA *IfrNvData 629 ) 630 { 631 LIST_ENTRY *Entry; 632 ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt; 633 ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData; 634 ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData; 635 CHAR16 AttemptNameList[ATTEMPT_NAME_LIST_SIZE]; 636 ISCSI_NIC_INFO *NicInfo; 637 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; 638 EFI_IP_ADDRESS Ip; 639 UINTN Index; 640 UINTN StringLen; 641 642 NicInfo = NULL; 643 ZeroMem (AttemptNameList, sizeof (AttemptNameList)); 644 645 if ((mPrivate != NULL) && (mPrivate->AttemptCount != 0)) { 646 NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) { 647 Attempt = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link); 648 // 649 // Normal session configuration parameters. 650 // 651 SessionConfigData = &Attempt->SessionConfigData; 652 653 ASSERT ((Attempt->AttemptConfigIndex > 0) && (Attempt->AttemptConfigIndex <= FixedPcdGet8 (PcdMaxIScsiAttemptNumber))); 654 Index = Attempt->AttemptConfigIndex - 1; 655 656 // 657 // Save the attempt to AttemptNameList as Attempt:1 Attempt:2 658 // 659 AsciiStrToUnicodeStrS ( 660 Attempt->AttemptName, 661 AttemptNameList + StrLen (AttemptNameList), 662 ATTEMPT_NAME_LIST_SIZE - StrLen (AttemptNameList) 663 ); 664 665 StringLen = StrLen (AttemptNameList); 666 ASSERT (StringLen > 2); 667 *(AttemptNameList + StringLen - 2) = L':'; 668 *(AttemptNameList + StringLen) = L' '; 669 670 AsciiStrToUnicodeStrS ( 671 Attempt->AttemptName, 672 IfrNvData->ISCSIAttemptName + ATTEMPT_NAME_SIZE * Index, 673 ATTEMPT_NAME_LIST_SIZE - ATTEMPT_NAME_SIZE * Index 674 ); 675 676 IfrNvData->ISCSIBootEnableList[Index] = SessionConfigData->Enabled; 677 IfrNvData->ISCSIIpAddressTypeList[Index] = SessionConfigData->IpMode; 678 679 IfrNvData->ISCSIInitiatorInfoViaDHCP[Index] = SessionConfigData->InitiatorInfoFromDhcp; 680 IfrNvData->ISCSITargetInfoViaDHCP[Index] = SessionConfigData->TargetInfoFromDhcp; 681 IfrNvData->ISCSIConnectRetry[Index] = SessionConfigData->ConnectRetryCount; 682 IfrNvData->ISCSIConnectTimeout[Index] = SessionConfigData->ConnectTimeout; 683 IfrNvData->ISCSITargetTcpPort[Index] = SessionConfigData->TargetPort; 684 685 if (SessionConfigData->IpMode == IP_MODE_IP4) { 686 CopyMem (&Ip.v4, &SessionConfigData->LocalIp, sizeof (EFI_IPv4_ADDRESS)); 687 IScsiIpToStr (&Ip, FALSE, IfrNvData->Keyword[Index].ISCSIInitiatorIpAddress); 688 CopyMem (&Ip.v4, &SessionConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS)); 689 IScsiIpToStr (&Ip, FALSE, IfrNvData->Keyword[Index].ISCSIInitiatorNetmask); 690 CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof (EFI_IPv4_ADDRESS)); 691 IScsiIpToStr (&Ip, FALSE, IfrNvData->Keyword[Index].ISCSIInitiatorGateway); 692 if (SessionConfigData->TargetIp.v4.Addr[0] != '\0') { 693 CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof (EFI_IPv4_ADDRESS)); 694 IScsiIpToStr (&Ip, FALSE, IfrNvData->Keyword[Index].ISCSITargetIpAddress); 695 } 696 } else if (SessionConfigData->IpMode == IP_MODE_IP6) { 697 ZeroMem (IfrNvData->Keyword[Index].ISCSITargetIpAddress, sizeof (IfrNvData->TargetIp)); 698 if (SessionConfigData->TargetIp.v6.Addr[0] != '\0') { 699 IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp); 700 IScsiIpToStr (&Ip, TRUE, IfrNvData->Keyword[Index].ISCSITargetIpAddress); 701 } 702 } 703 704 AsciiStrToUnicodeStrS ( 705 SessionConfigData->TargetName, 706 IfrNvData->Keyword[Index].ISCSITargetName, 707 ISCSI_NAME_MAX_SIZE 708 ); 709 710 if (SessionConfigData->DnsMode) { 711 AsciiStrToUnicodeStrS ( 712 SessionConfigData->TargetUrl, 713 IfrNvData->Keyword[Index].ISCSITargetIpAddress, 714 sizeof (IfrNvData->Keyword[Index].ISCSITargetIpAddress) / sizeof (IfrNvData->Keyword[Index].ISCSITargetIpAddress[0]) 715 ); 716 } 717 718 IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->Keyword[Index].ISCSILun); 719 IScsiConvertIsIdToString (IfrNvData->Keyword[Index].ISCSIIsId, SessionConfigData->IsId); 720 721 IfrNvData->ISCSIAuthenticationMethod[Index] = Attempt->AuthenticationType; 722 723 if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) { 724 AuthConfigData = &Attempt->AuthConfigData.CHAP; 725 IfrNvData->ISCSIChapType[Index] = AuthConfigData->CHAPType; 726 AsciiStrToUnicodeStrS ( 727 AuthConfigData->CHAPName, 728 IfrNvData->Keyword[Index].ISCSIChapUsername, 729 ISCSI_CHAP_NAME_STORAGE 730 ); 731 732 AsciiStrToUnicodeStrS ( 733 AuthConfigData->CHAPSecret, 734 IfrNvData->Keyword[Index].ISCSIChapSecret, 735 ISCSI_CHAP_SECRET_STORAGE 736 ); 737 738 AsciiStrToUnicodeStrS ( 739 AuthConfigData->ReverseCHAPName, 740 IfrNvData->Keyword[Index].ISCSIReverseChapUsername, 741 ISCSI_CHAP_NAME_STORAGE 742 ); 743 744 AsciiStrToUnicodeStrS ( 745 AuthConfigData->ReverseCHAPSecret, 746 IfrNvData->Keyword[Index].ISCSIReverseChapSecret, 747 ISCSI_CHAP_SECRET_STORAGE 748 ); 749 } 750 } 751 CopyMem(IfrNvData->ISCSIDisplayAttemptList, AttemptNameList, ATTEMPT_NAME_LIST_SIZE); 752 753 ZeroMem (IfrNvData->ISCSIMacAddr, sizeof (IfrNvData->ISCSIMacAddr)); 754 NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) { 755 NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); 756 IScsiMacAddrToStr ( 757 &NicInfo->PermanentAddress, 758 NicInfo->HwAddressSize, 759 NicInfo->VlanId, 760 MacString 761 ); 762 CopyMem ( 763 IfrNvData->ISCSIMacAddr + StrLen (IfrNvData->ISCSIMacAddr), 764 MacString, 765 StrLen (MacString) * sizeof (CHAR16) 766 ); 767 768 *(IfrNvData->ISCSIMacAddr + StrLen (IfrNvData->ISCSIMacAddr)) = L'/'; 769 } 770 771 StringLen = StrLen (IfrNvData->ISCSIMacAddr); 772 if (StringLen > 0) { 773 *(IfrNvData->ISCSIMacAddr + StringLen - 1) = L'\0'; 774 } 775 } 418 776 } 419 777 … … 533 891 // 534 892 if (!Attempt->SessionConfigData.TargetInfoFromDhcp && Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) { 535 if (!IpIsUnicast (&Attempt->SessionConfigData.TargetIp, IfrNvData->IpMode)) { 893 if (!Attempt->SessionConfigData.DnsMode) { 894 if (!IpIsUnicast (&Attempt->SessionConfigData.TargetIp, IfrNvData->IpMode)) { 895 CreatePopUp ( 896 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 897 &Key, 898 L"Target IP is invalid!", 899 NULL 900 ); 901 return EFI_INVALID_PARAMETER; 902 } 903 } else { 904 if (Attempt->SessionConfigData.TargetUrl[0] == '\0') { 905 CreatePopUp ( 906 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 907 &Key, 908 L"iSCSI target Url should not be NULL!", 909 NULL 910 ); 911 return EFI_INVALID_PARAMETER; 912 } 913 } 914 915 // 916 // Validate iSCSI target name configuration again: 917 // The format of iSCSI target name is already verified in IScsiFormCallback() when 918 // user input the name; here we only check the case user does not input the name. 919 // 920 if (Attempt->SessionConfigData.TargetName[0] == '\0') { 536 921 CreatePopUp ( 537 922 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 538 923 &Key, 539 L" Target IP is invalid!",924 L"iSCSI target name is NULL!", 540 925 NULL 541 926 ); … … 543 928 } 544 929 } 930 545 931 // 546 932 // Validate the authentication info. … … 576 962 SameNicAttempt = IScsiConfigGetAttemptByNic (Attempt, IfrNvData->Enabled); 577 963 if (SameNicAttempt != NULL) { 578 AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_ MAX_SIZE * sizeof (CHAR16));964 AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16)); 579 965 if (AttemptName1 == NULL) { 580 966 return EFI_OUT_OF_RESOURCES; 581 967 } 582 968 583 AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_ MAX_SIZE * sizeof (CHAR16));969 AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16)); 584 970 if (AttemptName2 == NULL) { 585 971 FreePool (AttemptName1); … … 587 973 } 588 974 589 AsciiStrToUnicodeStr (Attempt->AttemptName, AttemptName1); 590 if (StrLen (AttemptName1) > ATTEMPT_NAME_SIZE) { 591 CopyMem (&AttemptName1[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16)); 592 } 593 594 AsciiStrToUnicodeStr (SameNicAttempt->AttemptName, AttemptName2); 595 if (StrLen (AttemptName2) > ATTEMPT_NAME_SIZE) { 596 CopyMem (&AttemptName2[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16)); 597 } 975 AsciiStrToUnicodeStrS (Attempt->AttemptName, AttemptName1, ATTEMPT_NAME_SIZE); 976 AsciiStrToUnicodeStrS (SameNicAttempt->AttemptName, AttemptName2, ATTEMPT_NAME_SIZE); 598 977 599 978 UnicodeSPrint ( … … 620 999 // Update the iSCSI Mode data and record it in attempt help info. 621 1000 // 622 Attempt->SessionConfigData.Enabled = IfrNvData->Enabled;623 1001 if (IfrNvData->Enabled == ISCSI_DISABLED) { 624 1002 UnicodeSPrint (IScsiMode, 64, L"Disabled"); … … 647 1025 } 648 1026 649 AsciiStrToUnicodeStr (Attempt->MacString, MacString);1027 AsciiStrToUnicodeStrS (Attempt->MacString, MacString, ISCSI_MAX_MAC_STRING_LEN); 650 1028 651 1029 UnicodeSPrint ( … … 744 1122 // 745 1123 // When a new attempt is created, pointer of the attempt is saved to 746 // mPrivate->NewAttempt, and also saved to mCallbackInfo->Current in 747 // IScsiConfigProcessDefault. If input Attempt does not match any existing 748 // attempt, it should be a new created attempt. Save it to system now. 749 // 750 ASSERT (Attempt == mPrivate->NewAttempt); 1124 // mCallbackInfo->Current in IScsiConfigProcessDefault. If input Attempt 1125 // does not match any existing attempt, it should be a new created attempt. 1126 // Save it to system now. 1127 // 751 1128 752 1129 // … … 799 1176 InsertTailList (&mPrivate->AttemptConfigs, &Attempt->Link); 800 1177 mPrivate->AttemptCount++; 801 //802 // Reset mPrivate->NewAttempt to NULL, which indicates none attempt is created803 // but not saved now.804 //805 mPrivate->NewAttempt = NULL;806 1178 807 1179 if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) { … … 817 1189 IScsiConfigUpdateAttempt (); 818 1190 } 1191 Attempt->SessionConfigData.Enabled = IfrNvData->Enabled; 819 1192 820 1193 // 821 1194 // Record the user configuration information in NVR. 822 1195 // 823 UnicodeSPrint ( 824 mPrivate->PortString, 825 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 826 L"%s%d", 827 MacString, 828 (UINTN) Attempt->AttemptConfigIndex 829 ); 1196 UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex); 830 1197 831 1198 FreePool (MacString); … … 838 1205 Attempt 839 1206 ); 1207 } 1208 1209 /** 1210 Convert the IFR data configured by keyword to iSCSI configuration data. 1211 1212 @param[in] IfrNvData Point to ISCSI_CONFIG_IFR_NVDATA. 1213 @param[in] OffSet The offset of the variable to the configuration structure. 1214 1215 @retval EFI_INVALID_PARAMETER Any input or configured parameter is invalid. 1216 @retval EFI_SUCCESS The operation is completed successfully. 1217 1218 **/ 1219 EFI_STATUS 1220 IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( 1221 IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData, 1222 IN UINTN OffSet 1223 ) 1224 { 1225 ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt; 1226 UINT8 AttemptIndex; 1227 UINT8 Index; 1228 UINT8 ChapSecretLen; 1229 UINT8 ReverseChapSecretLen; 1230 CHAR16 *AttemptName1; 1231 CHAR16 *AttemptName2; 1232 ISCSI_ATTEMPT_CONFIG_NVDATA *SameNicAttempt; 1233 CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN]; 1234 CHAR8 IScsiName[ISCSI_NAME_MAX_SIZE]; 1235 CHAR8 IpString[IP_STR_MAX_SIZE]; 1236 EFI_IP_ADDRESS HostIp; 1237 EFI_IP_ADDRESS SubnetMask; 1238 EFI_IP_ADDRESS Gateway; 1239 EFI_INPUT_KEY Key; 1240 UINT64 Lun; 1241 EFI_STATUS Status; 1242 1243 Attempt = NULL; 1244 ZeroMem (IScsiName, sizeof (IScsiName)); 1245 1246 if (OffSet < ATTEMPT_BOOTENABLE_VAR_OFFSET) { 1247 return EFI_SUCCESS; 1248 1249 } else if ((OffSet >= ATTEMPT_BOOTENABLE_VAR_OFFSET) && (OffSet < ATTEMPT_ADDRESS_TYPE_VAR_OFFSET)) { 1250 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_BOOTENABLE_VAR_OFFSET) + 1); 1251 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1252 if (Attempt == NULL) { 1253 return EFI_INVALID_PARAMETER; 1254 } 1255 IfrNvData->Enabled = IfrNvData->ISCSIBootEnableList[AttemptIndex - 1]; 1256 // 1257 // Validate the configuration of attempt. 1258 // 1259 if (IfrNvData->Enabled != ISCSI_DISABLED) { 1260 // 1261 // Check whether this attempt uses NIC which is already used by existing attempt. 1262 // 1263 SameNicAttempt = IScsiConfigGetAttemptByNic (Attempt, IfrNvData->Enabled); 1264 if (SameNicAttempt != NULL) { 1265 AttemptName1 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16)); 1266 if (AttemptName1 == NULL) { 1267 return EFI_OUT_OF_RESOURCES; 1268 } 1269 1270 AttemptName2 = (CHAR16 *) AllocateZeroPool (ATTEMPT_NAME_SIZE * sizeof (CHAR16)); 1271 if (AttemptName2 == NULL) { 1272 FreePool (AttemptName1); 1273 return EFI_OUT_OF_RESOURCES; 1274 } 1275 1276 AsciiStrToUnicodeStrS (Attempt->AttemptName, AttemptName1, ATTEMPT_NAME_SIZE); 1277 AsciiStrToUnicodeStrS (SameNicAttempt->AttemptName, AttemptName2, ATTEMPT_NAME_SIZE); 1278 1279 UnicodeSPrint ( 1280 mPrivate->PortString, 1281 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 1282 L"Warning! \"%s\" uses same NIC as Attempt \"%s\".", 1283 AttemptName1, 1284 AttemptName2 1285 ); 1286 1287 CreatePopUp ( 1288 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1289 &Key, 1290 mPrivate->PortString, 1291 NULL 1292 ); 1293 1294 FreePool (AttemptName1); 1295 FreePool (AttemptName2); 1296 } 1297 } 1298 1299 if (IfrNvData->Enabled == ISCSI_DISABLED && 1300 Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { 1301 1302 // 1303 // User updates the Attempt from "Enabled"/"Enabled for MPIO" to "Disabled". 1304 // 1305 if (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) { 1306 if (mPrivate->MpioCount < 1) { 1307 return EFI_ABORTED; 1308 } 1309 1310 if (--mPrivate->MpioCount == 0) { 1311 mPrivate->EnableMpio = FALSE; 1312 } 1313 } else if (Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) { 1314 if (mPrivate->SinglePathCount < 1) { 1315 return EFI_ABORTED; 1316 } 1317 mPrivate->SinglePathCount--; 1318 } 1319 1320 } else if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO && 1321 Attempt->SessionConfigData.Enabled == ISCSI_ENABLED) { 1322 // 1323 // User updates the Attempt from "Enabled" to "Enabled for MPIO". 1324 // 1325 if (mPrivate->SinglePathCount < 1) { 1326 return EFI_ABORTED; 1327 } 1328 1329 mPrivate->EnableMpio = TRUE; 1330 mPrivate->MpioCount++; 1331 mPrivate->SinglePathCount--; 1332 1333 } else if (IfrNvData->Enabled == ISCSI_ENABLED && 1334 Attempt->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) { 1335 // 1336 // User updates the Attempt from "Enabled for MPIO" to "Enabled". 1337 // 1338 if (mPrivate->MpioCount < 1) { 1339 return EFI_ABORTED; 1340 } 1341 1342 if (--mPrivate->MpioCount == 0) { 1343 mPrivate->EnableMpio = FALSE; 1344 } 1345 mPrivate->SinglePathCount++; 1346 1347 } else if (IfrNvData->Enabled != ISCSI_DISABLED && 1348 Attempt->SessionConfigData.Enabled == ISCSI_DISABLED) { 1349 // 1350 // User updates the Attempt from "Disabled" to "Enabled"/"Enabled for MPIO". 1351 // 1352 if (IfrNvData->Enabled == ISCSI_ENABLED_FOR_MPIO) { 1353 mPrivate->EnableMpio = TRUE; 1354 mPrivate->MpioCount++; 1355 1356 } else if (IfrNvData->Enabled == ISCSI_ENABLED) { 1357 mPrivate->SinglePathCount++; 1358 } 1359 } 1360 Attempt->SessionConfigData.Enabled = IfrNvData->Enabled; 1361 1362 } else if ((OffSet >= ATTEMPT_ADDRESS_TYPE_VAR_OFFSET) && (OffSet < ATTEMPT_CONNECT_RETRY_VAR_OFFSET)) { 1363 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_ADDRESS_TYPE_VAR_OFFSET) + 1); 1364 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1365 if (Attempt == NULL) { 1366 return EFI_INVALID_PARAMETER; 1367 } 1368 Attempt->SessionConfigData.IpMode = IfrNvData->ISCSIIpAddressTypeList[AttemptIndex - 1]; 1369 if (Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) { 1370 Attempt->AutoConfigureMode = 0; 1371 } 1372 1373 } else if ((OffSet >= ATTEMPT_CONNECT_RETRY_VAR_OFFSET) && (OffSet < ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET)) { 1374 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CONNECT_RETRY_VAR_OFFSET) + 1); 1375 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1376 if (Attempt == NULL) { 1377 return EFI_INVALID_PARAMETER; 1378 } 1379 1380 if (IfrNvData->ISCSIConnectRetry[AttemptIndex - 1] > CONNECT_MAX_RETRY) { 1381 CreatePopUp ( 1382 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1383 &Key, 1384 L"The minimum value is 0 and the maximum is 16. 0 means no retry.", 1385 NULL 1386 ); 1387 return EFI_INVALID_PARAMETER; 1388 } 1389 Attempt->SessionConfigData.ConnectRetryCount = IfrNvData->ISCSIConnectRetry[AttemptIndex - 1]; 1390 1391 } else if ((OffSet >= ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET)) { 1392 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) / 2 + 1); 1393 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1394 if (Attempt == NULL) { 1395 return EFI_INVALID_PARAMETER; 1396 } 1397 1398 if ((IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] < CONNECT_MIN_TIMEOUT) || 1399 (IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] > CONNECT_MAX_TIMEOUT)) { 1400 CreatePopUp ( 1401 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1402 &Key, 1403 L"The minimum value is 100 milliseconds and the maximum is 20 seconds.", 1404 NULL 1405 ); 1406 return EFI_INVALID_PARAMETER; 1407 } 1408 1409 Attempt->SessionConfigData.ConnectTimeout = IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1]; 1410 if (Attempt->SessionConfigData.ConnectTimeout == 0) { 1411 Attempt->SessionConfigData.ConnectTimeout = CONNECT_DEFAULT_TIMEOUT; 1412 } 1413 1414 } else if ((OffSet >= ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET)) { 1415 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) + 1); 1416 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1417 if (Attempt == NULL) { 1418 return EFI_INVALID_PARAMETER; 1419 } 1420 Attempt->SessionConfigData.InitiatorInfoFromDhcp = IfrNvData->ISCSIInitiatorInfoViaDHCP[AttemptIndex - 1]; 1421 1422 } else if ((OffSet >= ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET)) { 1423 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET) + 1); 1424 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1425 if (Attempt == NULL) { 1426 return EFI_INVALID_PARAMETER; 1427 } 1428 1429 if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (Attempt->SessionConfigData.InitiatorInfoFromDhcp)) { 1430 Attempt->SessionConfigData.TargetInfoFromDhcp = IfrNvData->ISCSITargetInfoViaDHCP[AttemptIndex - 1]; 1431 } else { 1432 CreatePopUp ( 1433 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1434 &Key, 1435 L"Invalid Configuration, Check value of IpMode or Enable DHCP!", 1436 NULL 1437 ); 1438 return EFI_INVALID_PARAMETER; 1439 } 1440 1441 } else if ((OffSet >= ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) && (OffSet < ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET)) { 1442 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET) / 2 + 1); 1443 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1444 if (Attempt == NULL) { 1445 return EFI_INVALID_PARAMETER; 1446 } 1447 if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) { 1448 Attempt->SessionConfigData.TargetPort = IfrNvData->ISCSITargetTcpPort[AttemptIndex - 1]; 1449 if (Attempt->SessionConfigData.TargetPort == 0) { 1450 Attempt->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT; 1451 } 1452 } else { 1453 CreatePopUp ( 1454 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1455 &Key, 1456 L"Invalid Configuration, Check value of IpMode or Target Via DHCP!", 1457 NULL 1458 ); 1459 return EFI_INVALID_PARAMETER; 1460 } 1461 1462 } else if ((OffSet >= ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET) && (OffSet < ATTEMPT_CHARTYPE_VAR_OFFSET)) { 1463 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET) + 1); 1464 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1465 if (Attempt == NULL) { 1466 return EFI_INVALID_PARAMETER; 1467 } 1468 1469 Attempt->AuthenticationType = IfrNvData->ISCSIAuthenticationMethod[AttemptIndex - 1]; 1470 1471 } else if ((OffSet >= ATTEMPT_CHARTYPE_VAR_OFFSET) && (OffSet < ATTEMPT_ISID_VAR_OFFSET)) { 1472 AttemptIndex = (UINT8) ((OffSet - ATTEMPT_CHARTYPE_VAR_OFFSET) + 1); 1473 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1474 if (Attempt == NULL) { 1475 return EFI_INVALID_PARAMETER; 1476 } 1477 if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) { 1478 Attempt->AuthConfigData.CHAP.CHAPType = IfrNvData->ISCSIChapType[AttemptIndex - 1]; 1479 } 1480 1481 } else if (OffSet >= ATTEMPT_ISID_VAR_OFFSET) { 1482 Index = (UINT8) ((OffSet - ATTEMPT_ISID_VAR_OFFSET) / sizeof (KEYWORD_STR)); 1483 AttemptIndex = Index + 1; 1484 Attempt = IScsiConfigGetAttemptByConfigIndex (AttemptIndex); 1485 if (Attempt == NULL) { 1486 return EFI_INVALID_PARAMETER; 1487 } 1488 1489 OffSet = OffSet - Index * sizeof (KEYWORD_STR); 1490 1491 if ((OffSet >= ATTEMPT_ISID_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET)) { 1492 IScsiParseIsIdFromString (IfrNvData->Keyword[Index].ISCSIIsId, Attempt->SessionConfigData.IsId); 1493 1494 } else if ((OffSet >= ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET)) { 1495 if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) { 1496 // 1497 // Config Local ip 1498 // 1499 Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorIpAddress, &HostIp.v4); 1500 if (EFI_ERROR (Status) || ((Attempt->SessionConfigData.SubnetMask.Addr[0] != 0) && 1501 !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Attempt->SessionConfigData.SubnetMask.Addr)))) { 1502 CreatePopUp ( 1503 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1504 &Key, 1505 L"Invalid IP address!", 1506 NULL 1507 ); 1508 return EFI_INVALID_PARAMETER; 1509 } else { 1510 CopyMem (&Attempt->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4)); 1511 } 1512 } else { 1513 CreatePopUp ( 1514 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1515 &Key, 1516 L"Invalid Configuration, Check value of IpMode or Enable DHCP!", 1517 NULL 1518 ); 1519 return EFI_INVALID_PARAMETER; 1520 } 1521 1522 } else if ((OffSet >= ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET) && (OffSet < ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET)) { 1523 if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) { 1524 Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorNetmask, &SubnetMask.v4); 1525 if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (IScsiGetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) { 1526 CreatePopUp ( 1527 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1528 &Key, 1529 L"Invalid Subnet Mask!", 1530 NULL 1531 ); 1532 return EFI_INVALID_PARAMETER; 1533 } else { 1534 CopyMem (&Attempt->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4)); 1535 } 1536 } else { 1537 CreatePopUp ( 1538 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1539 &Key, 1540 L"Invalid Configuration, Check value of IpMode or Enable DHCP!", 1541 NULL 1542 ); 1543 return EFI_INVALID_PARAMETER; 1544 } 1545 1546 } else if ((OffSet >= ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_NAME_VAR_OFFSET)) { 1547 if ((Attempt->SessionConfigData.IpMode == IP_MODE_IP4) && (!Attempt->SessionConfigData.InitiatorInfoFromDhcp)) { 1548 Status = NetLibStrToIp4 (IfrNvData->Keyword[Index].ISCSIInitiatorGateway, &Gateway.v4); 1549 if (EFI_ERROR (Status) || 1550 ((Gateway.Addr[0] != 0) && (Attempt->SessionConfigData.SubnetMask.Addr[0] != 0) && 1551 !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Attempt->SessionConfigData.SubnetMask.Addr)))) { 1552 CreatePopUp ( 1553 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1554 &Key, 1555 L"Invalid Gateway!", 1556 NULL 1557 ); 1558 return EFI_INVALID_PARAMETER; 1559 } else { 1560 CopyMem (&Attempt->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4)); 1561 } 1562 } else { 1563 CreatePopUp ( 1564 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1565 &Key, 1566 L"Invalid Configuration, Check value of IpMode or Enable DHCP!", 1567 NULL 1568 ); 1569 return EFI_INVALID_PARAMETER; 1570 } 1571 1572 } else if ((OffSet >= ATTEMPT_TARGET_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET)) { 1573 if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) { 1574 UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSITargetName, IScsiName, ISCSI_NAME_MAX_SIZE); 1575 Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName)); 1576 if (EFI_ERROR (Status)) { 1577 CreatePopUp ( 1578 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1579 &Key, 1580 L"Invalid iSCSI Name!", 1581 NULL 1582 ); 1583 } else { 1584 AsciiStrCpyS (Attempt->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName); 1585 } 1586 if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { 1587 if (Attempt->SessionConfigData.TargetName[0] == L'\0') { 1588 CreatePopUp ( 1589 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1590 &Key, 1591 L"iSCSI target name is NULL!", 1592 NULL 1593 ); 1594 return EFI_INVALID_PARAMETER; 1595 } 1596 } 1597 } else { 1598 CreatePopUp ( 1599 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1600 &Key, 1601 L"Invalid Configuration, Check value of IpMode or Target Via DHCP!", 1602 NULL 1603 ); 1604 return EFI_INVALID_PARAMETER; 1605 } 1606 1607 } else if ((OffSet >= ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET) && (OffSet < ATTEMPT_LUN_VAR_OFFSET)) { 1608 if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (!Attempt->SessionConfigData.TargetInfoFromDhcp)) { 1609 UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSITargetIpAddress, IpString, sizeof (IpString)); 1610 Status = IScsiAsciiStrToIp (IpString, Attempt->SessionConfigData.IpMode, &HostIp); 1611 if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, Attempt->SessionConfigData.IpMode)) { 1612 Attempt->SessionConfigData.DnsMode = TRUE; 1613 ZeroMem (&Attempt->SessionConfigData.TargetIp, sizeof (Attempt->SessionConfigData.TargetIp)); 1614 UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSITargetIpAddress, Attempt->SessionConfigData.TargetUrl, ISCSI_NAME_MAX_SIZE); 1615 } else { 1616 Attempt->SessionConfigData.DnsMode = FALSE; 1617 CopyMem (&Attempt->SessionConfigData.TargetIp, &HostIp, sizeof (HostIp)); 1618 } 1619 } else { 1620 CreatePopUp ( 1621 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1622 &Key, 1623 L"Invalid Configuration, Check value of IpMode or Target Via DHCP!", 1624 NULL 1625 ); 1626 return EFI_INVALID_PARAMETER; 1627 } 1628 1629 } else if ((OffSet >= ATTEMPT_LUN_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_USER_NAME_VAR_OFFSET)) { 1630 if ((Attempt->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) && (Attempt->SessionConfigData.TargetInfoFromDhcp == 0)) { 1631 // 1632 // Config LUN. 1633 // 1634 UnicodeStrToAsciiStrS (IfrNvData->Keyword[Index].ISCSILun, LunString, ISCSI_LUN_STR_MAX_LEN); 1635 Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun); 1636 if (EFI_ERROR (Status)) { 1637 CreatePopUp ( 1638 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1639 &Key, 1640 L"Invalid LUN string, Examples are: 4752-3A4F-6b7e-2F99, 6734-9-156f-127, 4186-9!", 1641 NULL 1642 ); 1643 } else { 1644 CopyMem (&Attempt->SessionConfigData.BootLun, &Lun, sizeof (Lun)); 1645 } 1646 } else { 1647 CreatePopUp ( 1648 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1649 &Key, 1650 L"Invalid Configuration, Check value of IpMode or Target Via DHCP!", 1651 NULL 1652 ); 1653 return EFI_INVALID_PARAMETER; 1654 } 1655 1656 } else if ((OffSet >= ATTEMPT_CHAR_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_SECRET_VAR_OFFSET)) { 1657 if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) { 1658 UnicodeStrToAsciiStrS ( 1659 IfrNvData->Keyword[Index].ISCSIChapUsername, 1660 Attempt->AuthConfigData.CHAP.CHAPName, 1661 ISCSI_CHAP_NAME_STORAGE 1662 ); 1663 1664 if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { 1665 if (IfrNvData->Keyword[Index].ISCSIChapUsername[0] == L'\0') { 1666 CreatePopUp ( 1667 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1668 &Key, 1669 L"CHAP Name is invalid!", 1670 NULL 1671 ); 1672 return EFI_INVALID_PARAMETER; 1673 } 1674 } 1675 } else { 1676 CreatePopUp ( 1677 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1678 &Key, 1679 L"Invalid Configuration, Check value of AuthenticationType!", 1680 NULL 1681 ); 1682 return EFI_INVALID_PARAMETER; 1683 } 1684 1685 } else if ((OffSet >= ATTEMPT_CHAR_SECRET_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET)) { 1686 if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) { 1687 ChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIChapSecret); 1688 UnicodeStrToAsciiStrS ( 1689 IfrNvData->Keyword[Index].ISCSIChapSecret, 1690 Attempt->AuthConfigData.CHAP.CHAPSecret, 1691 ISCSI_CHAP_SECRET_STORAGE 1692 ); 1693 1694 if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { 1695 if ((ChapSecretLen < ISCSI_CHAP_SECRET_MIN_LEN) || (ChapSecretLen > ISCSI_CHAP_SECRET_MAX_LEN)) { 1696 CreatePopUp ( 1697 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1698 &Key, 1699 L"The Chap Secret minimum length is 12 bytes and the maximum length is 16 bytes.", 1700 NULL 1701 ); 1702 return EFI_INVALID_PARAMETER; 1703 } 1704 } 1705 } else { 1706 CreatePopUp ( 1707 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1708 &Key, 1709 L"Invalid Configuration, Check value of AuthenticationType!", 1710 NULL 1711 ); 1712 return EFI_INVALID_PARAMETER; 1713 } 1714 1715 } else if ((OffSet >= ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET) && (OffSet < ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET)) { 1716 if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) { 1717 UnicodeStrToAsciiStrS ( 1718 IfrNvData->Keyword[Index].ISCSIReverseChapUsername, 1719 Attempt->AuthConfigData.CHAP.ReverseCHAPName, 1720 ISCSI_CHAP_NAME_STORAGE 1721 ); 1722 if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { 1723 if (IfrNvData->Keyword[Index].ISCSIReverseChapUsername[0] == L'\0') { 1724 CreatePopUp ( 1725 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1726 &Key, 1727 L"Reverse CHAP Name is invalid!", 1728 NULL 1729 ); 1730 return EFI_INVALID_PARAMETER; 1731 } 1732 } 1733 } else { 1734 CreatePopUp ( 1735 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1736 &Key, 1737 L"Invalid Configuration, Check value of AuthenticationType or Chap Type!", 1738 NULL 1739 ); 1740 return EFI_INVALID_PARAMETER; 1741 } 1742 1743 } else if (OffSet >= ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET) { 1744 if (Attempt->AuthConfigData.CHAP.CHAPType == ISCSI_CHAP_MUTUAL) { 1745 ReverseChapSecretLen = (UINT8)StrLen (IfrNvData->Keyword[Index].ISCSIReverseChapSecret); 1746 UnicodeStrToAsciiStrS ( 1747 IfrNvData->Keyword[Index].ISCSIReverseChapSecret, 1748 Attempt->AuthConfigData.CHAP.ReverseCHAPSecret, 1749 ISCSI_CHAP_SECRET_STORAGE 1750 ); 1751 1752 if (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED) { 1753 if ((ReverseChapSecretLen < ISCSI_CHAP_SECRET_MIN_LEN) || (ReverseChapSecretLen > ISCSI_CHAP_SECRET_MAX_LEN)) { 1754 CreatePopUp ( 1755 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1756 &Key, 1757 L"The Reverse CHAP Secret minimum length is 12 bytes and the maximum length is 16 bytes.", 1758 NULL 1759 ); 1760 return EFI_INVALID_PARAMETER; 1761 } 1762 } 1763 } else { 1764 CreatePopUp ( 1765 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 1766 &Key, 1767 L"Invalid Configuration, Check value of AuthenticationType or Chap Type!", 1768 NULL 1769 ); 1770 return EFI_INVALID_PARAMETER; 1771 } 1772 } 1773 } 1774 1775 1776 1777 // 1778 // Record the user configuration information in NVR. 1779 // 1780 ASSERT (Attempt != NULL); 1781 UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", Attempt->AttemptConfigIndex); 1782 return gRT->SetVariable ( 1783 mPrivate->PortString, 1784 &gEfiIScsiInitiatorNameProtocolGuid, 1785 ISCSI_CONFIG_VAR_ATTR, 1786 sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA), 1787 Attempt 1788 ); 1789 840 1790 } 841 1791 … … 936 1886 HiiFreeOpCodeHandle (*EndOpCodeHandle); 937 1887 } 938 939 1888 return Status; 1889 } 1890 1891 /** 1892 Update the MAIN form to display the configured attempts. 1893 1894 **/ 1895 VOID 1896 IScsiConfigUpdateAttempt ( 1897 VOID 1898 ) 1899 { 1900 LIST_ENTRY *Entry; 1901 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 1902 VOID *StartOpCodeHandle; 1903 EFI_IFR_GUID_LABEL *StartLabel; 1904 VOID *EndOpCodeHandle; 1905 EFI_IFR_GUID_LABEL *EndLabel; 1906 EFI_STATUS Status; 1907 1908 Status = IScsiCreateOpCode ( 1909 ATTEMPT_ENTRY_LABEL, 1910 &StartOpCodeHandle, 1911 &StartLabel, 1912 &EndOpCodeHandle, 1913 &EndLabel 1914 ); 1915 if (EFI_ERROR (Status)) { 1916 return ; 1917 } 1918 1919 NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) { 1920 AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link); 1921 if (AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) { 1922 // 1923 // Update Attempt Help Info. 1924 // 1925 UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", (UINTN) AttemptConfigData->AttemptConfigIndex); 1926 AttemptConfigData->AttemptTitleToken = HiiSetString ( 1927 mCallbackInfo->RegisteredHandle, 1928 0, 1929 mPrivate->PortString, 1930 NULL 1931 ); 1932 if (AttemptConfigData->AttemptTitleToken == 0) { 1933 return ; 1934 } 1935 1936 HiiCreateGotoOpCode ( 1937 StartOpCodeHandle, // Container for dynamic created opcodes 1938 FORMID_ATTEMPT_FORM, // Form ID 1939 AttemptConfigData->AttemptTitleToken, // Prompt text 1940 AttemptConfigData->AttemptTitleHelpToken, // Help text 1941 EFI_IFR_FLAG_CALLBACK, // Question flag 1942 (UINT16) (KEY_ATTEMPT_ENTRY_BASE + AttemptConfigData->AttemptConfigIndex) // Question ID 1943 ); 1944 } 1945 } 1946 1947 HiiUpdateForm ( 1948 mCallbackInfo->RegisteredHandle, // HII handle 1949 &gIScsiConfigGuid, // Formset GUID 1950 FORMID_MAIN_FORM, // Form ID 1951 StartOpCodeHandle, // Label for where to insert opcodes 1952 EndOpCodeHandle // Replace data 1953 ); 1954 1955 HiiFreeOpCodeHandle (StartOpCodeHandle); 1956 HiiFreeOpCodeHandle (EndOpCodeHandle); 940 1957 } 941 1958 … … 1038 2055 } 1039 2056 1040 1041 2057 /** 1042 Update the MAIN form to display the configured attempts. 2058 Add the attempts by keyword 'iSCSIAddAttempts', you can use this keyword with 2059 value 'attempt:1 attempt:2' etc to add one or more attempts once. This is different 2060 with IScsiConfigAddAttempt function which is used to add attempt by UI configuration. 2061 2062 @param[in] AttemptList The new attempt List will be added. 2063 2064 @retval EFI_SUCCESS The operation to add attempt list successfully. 2065 @retval EFI_INVALID_PARAMETER Any parameter is invalid. 2066 @retval EFI_NOT_FOUND Cannot find the corresponding variable. 2067 @retval EFI_OUT_OF_RESOURCES Fail to finish the operation due to lack of 2068 resources. 1043 2069 1044 2070 **/ 1045 VOID 1046 IScsiConfig UpdateAttempt(1047 VOID2071 EFI_STATUS 2072 IScsiConfigAddAttemptsByKeywords ( 2073 IN UINT8 *AttemptList 1048 2074 ) 1049 2075 { 1050 CHAR16 AttemptName[ATTEMPT_NAME_MAX_SIZE]; 1051 LIST_ENTRY *Entry; 1052 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 1053 VOID *StartOpCodeHandle; 1054 EFI_IFR_GUID_LABEL *StartLabel; 1055 VOID *EndOpCodeHandle; 1056 EFI_IFR_GUID_LABEL *EndLabel; 1057 EFI_STATUS Status; 1058 1059 Status = IScsiCreateOpCode ( 1060 ATTEMPT_ENTRY_LABEL, 1061 &StartOpCodeHandle, 1062 &StartLabel, 1063 &EndOpCodeHandle, 1064 &EndLabel 1065 ); 1066 if (EFI_ERROR (Status)) { 1067 return ; 1068 } 1069 1070 NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) { 1071 AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link); 1072 1073 AsciiStrToUnicodeStr (AttemptConfigData->AttemptName, AttemptName); 1074 UnicodeSPrint (mPrivate->PortString, (UINTN) 128, L"Attempt %s", AttemptName); 1075 AttemptConfigData->AttemptTitleToken = HiiSetString ( 1076 mCallbackInfo->RegisteredHandle, 1077 0, 1078 mPrivate->PortString, 1079 NULL 1080 ); 1081 if (AttemptConfigData->AttemptTitleToken == 0) { 1082 return ; 1083 } 1084 1085 HiiCreateGotoOpCode ( 1086 StartOpCodeHandle, // Container for dynamic created opcodes 1087 FORMID_ATTEMPT_FORM, // Form ID 1088 AttemptConfigData->AttemptTitleToken, // Prompt text 1089 AttemptConfigData->AttemptTitleHelpToken, // Help text 1090 EFI_IFR_FLAG_CALLBACK, // Question flag 1091 (UINT16) (KEY_ATTEMPT_ENTRY_BASE + AttemptConfigData->AttemptConfigIndex) // Question ID 2076 UINT8 Index; 2077 UINT8 Number; 2078 UINTN TotalNumber; 2079 UINT8 Nic; 2080 UINT8 *AttemptConfigOrder; 2081 UINTN AttemptConfigOrderSize; 2082 UINT8 *AttemptConfigOrderTmp; 2083 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 2084 ISCSI_NIC_INFO *NicInfo; 2085 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; 2086 CHAR16 IScsiMode[64]; 2087 CHAR16 IpMode[64]; 2088 EFI_STATUS Status; 2089 2090 Nic = mPrivate->CurrentNic; 2091 NicInfo = IScsiGetNicInfoByIndex (Nic); 2092 if (NicInfo == NULL) { 2093 return EFI_NOT_FOUND; 2094 } 2095 2096 // 2097 // The MAC info will be recorded in Config Data. 2098 // 2099 IScsiMacAddrToStr ( 2100 &NicInfo->PermanentAddress, 2101 NicInfo->HwAddressSize, 2102 NicInfo->VlanId, 2103 MacString 2104 ); 2105 2106 for (Index = 0; Index < PcdGet8 (PcdMaxIScsiAttemptNumber); Index++) { 2107 if (AttemptList[Index] == 0) { 2108 continue; 2109 } 2110 2111 // 2112 // Add the attempt. 2113 // 2114 Number = AttemptList[Index]; 2115 2116 UnicodeSPrint ( 2117 mPrivate->PortString, 2118 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 2119 L"Attempt %d", 2120 Number 1092 2121 ); 1093 } 1094 1095 HiiUpdateForm ( 1096 mCallbackInfo->RegisteredHandle, // HII handle 1097 &gIScsiConfigGuid, // Formset GUID 1098 FORMID_MAIN_FORM, // Form ID 1099 StartOpCodeHandle, // Label for where to insert opcodes 1100 EndOpCodeHandle // Replace data 1101 ); 1102 1103 HiiFreeOpCodeHandle (StartOpCodeHandle); 1104 HiiFreeOpCodeHandle (EndOpCodeHandle); 2122 2123 GetVariable2 ( 2124 mPrivate->PortString, 2125 &gEfiIScsiInitiatorNameProtocolGuid, 2126 (VOID**)&AttemptConfigData, 2127 NULL 2128 ); 2129 if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) { 2130 return EFI_INVALID_PARAMETER; 2131 } 2132 2133 AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED; 2134 AttemptConfigData->NicIndex = NicInfo->NicIndex; 2135 UnicodeStrToAsciiStrS (MacString, AttemptConfigData->MacString, ISCSI_MAX_MAC_STRING_LEN); 2136 2137 // 2138 // Generate OUI-format ISID based on MAC address. 2139 // 2140 CopyMem (AttemptConfigData->SessionConfigData.IsId, &NicInfo->PermanentAddress, 6); 2141 AttemptConfigData->SessionConfigData.IsId[0] = 2142 (UINT8) (AttemptConfigData->SessionConfigData.IsId[0] & 0x3F); 2143 2144 // 2145 // Configure the iSCSI Mode and IpMode to default. 2146 // Add Attempt Help Info. 2147 // 2148 UnicodeSPrint (IScsiMode, 64, L"Disabled"); 2149 UnicodeSPrint (IpMode, 64, L"IP4"); 2150 UnicodeSPrint ( 2151 mPrivate->PortString, 2152 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 2153 L"MAC: %s, PFA: Bus %d | Dev %d | Func %d, iSCSI mode: %s, IP version: %s", 2154 MacString, 2155 NicInfo->BusNumber, 2156 NicInfo->DeviceNumber, 2157 NicInfo->FunctionNumber, 2158 IScsiMode, 2159 IpMode 2160 ); 2161 2162 AttemptConfigData->AttemptTitleHelpToken = HiiSetString ( 2163 mCallbackInfo->RegisteredHandle, 2164 0, 2165 mPrivate->PortString, 2166 NULL 2167 ); 2168 if (AttemptConfigData->AttemptTitleHelpToken == 0) { 2169 return EFI_OUT_OF_RESOURCES; 2170 } 2171 2172 // 2173 // Get current Attempt order and number. 2174 // 2175 AttemptConfigOrder = IScsiGetVariableAndSize ( 2176 L"AttemptOrder", 2177 &gIScsiConfigGuid, 2178 &AttemptConfigOrderSize 2179 ); 2180 TotalNumber = AttemptConfigOrderSize / sizeof (UINT8); 2181 TotalNumber++; 2182 2183 // 2184 // Append the new created attempt order to the end. 2185 // 2186 AttemptConfigOrderTmp = AllocateZeroPool (TotalNumber * sizeof (UINT8)); 2187 if (AttemptConfigOrderTmp == NULL) { 2188 if (AttemptConfigOrder != NULL) { 2189 FreePool (AttemptConfigOrder); 2190 } 2191 return EFI_OUT_OF_RESOURCES; 2192 } 2193 if (AttemptConfigOrder != NULL) { 2194 CopyMem (AttemptConfigOrderTmp, AttemptConfigOrder, AttemptConfigOrderSize); 2195 FreePool (AttemptConfigOrder); 2196 } 2197 2198 AttemptConfigOrderTmp[TotalNumber - 1] = Number; 2199 AttemptConfigOrder = AttemptConfigOrderTmp; 2200 AttemptConfigOrderSize = TotalNumber * sizeof (UINT8); 2201 2202 Status = gRT->SetVariable ( 2203 L"AttemptOrder", 2204 &gIScsiConfigGuid, 2205 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, 2206 AttemptConfigOrderSize, 2207 AttemptConfigOrder 2208 ); 2209 FreePool (AttemptConfigOrder); 2210 if (EFI_ERROR (Status)) { 2211 return Status; 2212 } 2213 2214 // 2215 // Record the attempt in global link list. 2216 // 2217 InsertTailList (&mPrivate->AttemptConfigs, &AttemptConfigData->Link); 2218 mPrivate->AttemptCount++; 2219 UnicodeSPrint (mPrivate->PortString, (UINTN) ISCSI_NAME_IFR_MAX_SIZE, L"Attempt %d", AttemptConfigData->AttemptConfigIndex); 2220 gRT->SetVariable ( 2221 mPrivate->PortString, 2222 &gEfiIScsiInitiatorNameProtocolGuid, 2223 ISCSI_CONFIG_VAR_ATTR, 2224 sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA), 2225 AttemptConfigData 2226 ); 2227 2228 } 2229 2230 return EFI_SUCCESS; 1105 2231 } 1106 2232 1107 1108 2233 /** 1109 Callback function when user presses "Commit Changes and Exit" in Delete Attempts .2234 Callback function when user presses "Commit Changes and Exit" in Delete Attempts or Delete Attempts by Keyword. 1110 2235 1111 2236 @param[in] IfrNvData The IFR NV data. … … 1124 2249 ) 1125 2250 { 1126 EFI_STATUS Status; 1127 UINTN Index; 1128 UINTN NewIndex; 1129 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 1130 UINT8 *AttemptConfigOrder; 1131 UINTN AttemptConfigOrderSize; 1132 UINT8 *AttemptNewOrder; 1133 UINT32 Attribute; 1134 UINTN Total; 1135 UINTN NewTotal; 1136 LIST_ENTRY *Entry; 1137 LIST_ENTRY *NextEntry; 1138 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; 2251 EFI_STATUS Status; 2252 UINTN Index; 2253 UINTN NewIndex; 2254 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 2255 UINT8 *AttemptConfigOrder; 2256 UINTN AttemptConfigOrderSize; 2257 UINT8 *AttemptNewOrder; 2258 UINT8 AttemptConfigIndex; 2259 UINT32 Attribute; 2260 UINTN Total; 2261 UINTN NewTotal; 2262 LIST_ENTRY *Entry; 2263 LIST_ENTRY *NextEntry; 2264 ISCSI_SESSION_CONFIG_NVDATA *ConfigData; 2265 2266 Index = 0; 1139 2267 1140 2268 AttemptConfigOrder = IScsiGetVariableAndSize ( … … 1155 2283 Total = AttemptConfigOrderSize / sizeof (UINT8); 1156 2284 NewTotal = Total; 1157 Index = 0;1158 2285 1159 2286 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mPrivate->AttemptConfigs) { … … 1200 2327 } 1201 2328 1202 AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString); 1203 2329 AttemptConfigIndex = AttemptConfigData->AttemptConfigIndex; 2330 FreePool (AttemptConfigData); 2331 2332 // 2333 // Create a new Attempt 2334 // 2335 AttemptConfigData = AllocateZeroPool (sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA)); 2336 if (AttemptConfigData == NULL) { 2337 return EFI_OUT_OF_RESOURCES; 2338 } 2339 ConfigData = &AttemptConfigData->SessionConfigData; 2340 ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT; 2341 ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT; 2342 ConfigData->ConnectRetryCount = CONNECT_MIN_RETRY; 2343 2344 AttemptConfigData->AuthenticationType = ISCSI_AUTH_TYPE_CHAP; 2345 AttemptConfigData->AuthConfigData.CHAP.CHAPType = ISCSI_CHAP_UNI; 2346 // 2347 // Configure the Attempt index and set variable. 2348 // 2349 AttemptConfigData->AttemptConfigIndex = AttemptConfigIndex; 2350 2351 // 2352 // Set the attempt name to default. 2353 // 1204 2354 UnicodeSPrint ( 1205 2355 mPrivate->PortString, 1206 (UINTN) 128, 1207 L"%s%d", 1208 MacString, 2356 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 2357 L"Attempt %d", 1209 2358 (UINTN) AttemptConfigData->AttemptConfigIndex 1210 2359 ); 1211 2360 UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE); 1212 2361 gRT->SetVariable ( 1213 2362 mPrivate->PortString, 1214 2363 &gEfiIScsiInitiatorNameProtocolGuid, 1215 0,1216 0,1217 NULL2364 ISCSI_CONFIG_VAR_ATTR, 2365 sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA), 2366 AttemptConfigData 1218 2367 ); 1219 2368 … … 1229 2378 1230 2379 NewTotal--; 2380 if (mCallbackInfo->Current == AttemptConfigData) { 2381 mCallbackInfo->Current = NULL; 2382 } 1231 2383 FreePool (AttemptConfigData); 1232 2384 … … 1467 2619 } 1468 2620 1469 1470 2621 /** 1471 Callback function when user presses "Commit Changes and Exit" in Change Attempt Order .2622 Callback function when user presses "Commit Changes and Exit" in Change Attempt Order or Change Attempt Order by Keyword. 1472 2623 1473 2624 @param[in] IfrNvData The IFR nv data. … … 1585 2736 operation. 1586 2737 @retval EFI_NOT_FOUND Cannot find the corresponding variable. 2738 @retval EFI_UNSUPPORTED Can not create more attempts. 1587 2739 @retval EFI_SUCCESS The operation is completed successfully. 1588 2740 … … 1596 2748 BOOLEAN NewAttempt; 1597 2749 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 1598 ISCSI_SESSION_CONFIG_NVDATA *ConfigData;1599 2750 UINT8 CurrentAttemptConfigIndex; 1600 2751 ISCSI_NIC_INFO *NicInfo; … … 1603 2754 UINT8 *AttemptConfigOrder; 1604 2755 UINTN AttemptConfigOrderSize; 1605 UINTN TotalNumber;1606 2756 UINTN Index; 1607 2757 EFI_INPUT_KEY Key; 2758 2759 AttemptConfigData = NULL; 1608 2760 // 1609 2761 // Is User creating a new attempt? … … 1629 2781 // 1630 2782 return EFI_SUCCESS; 1631 }1632 1633 //1634 // Free any attempt that is previously created but not saved to system.1635 //1636 if (mPrivate->NewAttempt != NULL) {1637 FreePool (mPrivate->NewAttempt);1638 mPrivate->NewAttempt = NULL;1639 2783 } 1640 2784 … … 1650 2794 1651 2795 // 1652 // Create new attempt. 1653 // 1654 1655 AttemptConfigData = AllocateZeroPool (sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA)); 1656 if (AttemptConfigData == NULL) { 1657 return EFI_OUT_OF_RESOURCES; 1658 } 1659 1660 ConfigData = &AttemptConfigData->SessionConfigData; 1661 ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT; 1662 ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT; 1663 ConfigData->ConnectRetryCount = CONNECT_MIN_RETRY; 1664 1665 AttemptConfigData->AuthenticationType = ISCSI_AUTH_TYPE_CHAP; 1666 AttemptConfigData->AuthConfigData.CHAP.CHAPType = ISCSI_CHAP_UNI; 1667 1668 // 1669 // Get current order number for this attempt. 2796 // Create an attempt following the initialized attempt order. 1670 2797 // 1671 2798 AttemptConfigOrder = IScsiGetVariableAndSize ( 1672 L" AttemptOrder",2799 L"InitialAttemptOrder", 1673 2800 &gIScsiConfigGuid, 1674 2801 &AttemptConfigOrderSize 1675 2802 ); 1676 2803 1677 TotalNumber = AttemptConfigOrderSize / sizeof (UINT8);1678 1679 2804 if (AttemptConfigOrder == NULL) { 1680 CurrentAttemptConfigIndex = 1; 1681 } else { 1682 // 1683 // Get the max attempt config index. 1684 // 1685 CurrentAttemptConfigIndex = AttemptConfigOrder[0]; 1686 for (Index = 1; Index < TotalNumber; Index++) { 1687 if (CurrentAttemptConfigIndex < AttemptConfigOrder[Index]) { 1688 CurrentAttemptConfigIndex = AttemptConfigOrder[Index]; 1689 } 1690 } 1691 1692 CurrentAttemptConfigIndex++; 1693 } 1694 1695 TotalNumber++; 1696 1697 // 1698 // Record the mapping between attempt order and attempt's configdata. 1699 // 1700 AttemptConfigData->AttemptConfigIndex = CurrentAttemptConfigIndex; 2805 return EFI_NOT_FOUND; 2806 } 2807 2808 for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { 2809 UnicodeSPrint ( 2810 mPrivate->PortString, 2811 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 2812 L"Attempt %d", 2813 (UINTN) AttemptConfigOrder[Index] 2814 ); 2815 GetVariable2 ( 2816 mPrivate->PortString, 2817 &gEfiIScsiInitiatorNameProtocolGuid, 2818 (VOID**)&AttemptConfigData, 2819 NULL 2820 ); 2821 if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_ENABLED) { 2822 continue; 2823 } 2824 2825 break; 2826 } 2827 2828 if (Index > PcdGet8 (PcdMaxIScsiAttemptNumber)) { 2829 CreatePopUp ( 2830 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 2831 &Key, 2832 L"Can not create more attempts, Please configure the PcdMaxIScsiAttemptNumber if needed!", 2833 NULL 2834 ); 2835 return EFI_UNSUPPORTED; 2836 } 1701 2837 1702 2838 if (AttemptConfigOrder != NULL) { … … 1714 2850 ); 1715 2851 1716 UnicodeStrToAsciiStr (MacString, AttemptConfigData->MacString); 2852 ASSERT (AttemptConfigData != NULL); 2853 UnicodeStrToAsciiStrS (MacString, AttemptConfigData->MacString, sizeof (AttemptConfigData->MacString)); 1717 2854 AttemptConfigData->NicIndex = NicIndex; 2855 AttemptConfigData->Actived = ISCSI_ACTIVE_ENABLED; 1718 2856 1719 2857 // … … 1745 2883 if (AttemptConfigData->AttemptTitleHelpToken == 0) { 1746 2884 FreePool (AttemptConfigData); 1747 return EFI_INVALID_PARAMETER; 1748 } 1749 1750 // 1751 // Set the attempt name to default. 1752 // 1753 UnicodeSPrint ( 1754 mPrivate->PortString, 1755 (UINTN) 128, 1756 L"%d", 1757 (UINTN) AttemptConfigData->AttemptConfigIndex 1758 ); 1759 UnicodeStrToAsciiStr (mPrivate->PortString, AttemptConfigData->AttemptName); 1760 1761 // 1762 // Save the created Attempt temporarily. If user does not save the attempt 1763 // by press 'KEY_SAVE_ATTEMPT_CONFIG' later, iSCSI driver would know that 1764 // and free resources. 1765 // 1766 mPrivate->NewAttempt = (VOID *) AttemptConfigData; 2885 return EFI_OUT_OF_RESOURCES; 2886 } 1767 2887 1768 2888 } else { … … 1911 3031 } 1912 3032 1913 if (Private->Current != NULL) { 3033 3034 if (Private->Current!= NULL) { 1914 3035 IScsiConvertAttemptConfigDataToIfrNvData (Private->Current, IfrNvData); 1915 3036 } 3037 3038 // 3039 // Extract all AttemptConfigData to Keyword stroage of IfrNvData. 3040 // 3041 IScsiConvertAttemptConfigDataToIfrNvDataByKeyword (IfrNvData); 1916 3042 1917 3043 BufferSize = ISCSI_NAME_MAX_SIZE; … … 1926 3052 IfrNvData->InitiatorName[0] = L'\0'; 1927 3053 } else { 1928 AsciiStrToUnicodeStr (InitiatorName, IfrNvData->InitiatorName); 3054 AsciiStrToUnicodeStrS ( 3055 InitiatorName, 3056 IfrNvData->InitiatorName, 3057 sizeof (IfrNvData->InitiatorName) / sizeof (IfrNvData->InitiatorName[0]) 3058 ); 1929 3059 } 1930 3060 … … 1943 3073 Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); 1944 3074 ConfigRequest = AllocateZeroPool (Size); 1945 ASSERT (ConfigRequest != NULL); 3075 if (ConfigRequest == NULL) { 3076 FreePool (IfrNvData); 3077 FreePool (InitiatorName); 3078 return EFI_OUT_OF_RESOURCES; 3079 } 1946 3080 AllocatedRequest = TRUE; 1947 3081 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); … … 2028 3162 ) 2029 3163 { 3164 EFI_STATUS Status; 3165 ISCSI_CONFIG_IFR_NVDATA *IfrNvData; 3166 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 3167 LIST_ENTRY *Entry; 3168 LIST_ENTRY *NextEntry; 3169 ISCSI_NIC_INFO *NicInfo; 3170 EFI_INPUT_KEY Key; 3171 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; 3172 CHAR8 *InitiatorName; 3173 UINT8 *AttemptList; 3174 UINTN BufferSize; 3175 UINTN OffSet; 3176 UINTN Index; 3177 UINTN Index2; 3178 3179 Index = 0; 3180 Index2 = 0; 3181 NicInfo = NULL; 3182 AttemptList = NULL; 3183 Status = EFI_SUCCESS; 3184 2030 3185 if (This == NULL || Configuration == NULL || Progress == NULL) { 2031 3186 return EFI_INVALID_PARAMETER; … … 2041 3196 } 2042 3197 2043 *Progress = Configuration + StrLen (Configuration); 2044 return EFI_SUCCESS; 3198 IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA)); 3199 if (IfrNvData == NULL) { 3200 return EFI_OUT_OF_RESOURCES; 3201 } 3202 3203 BufferSize = ISCSI_NAME_MAX_SIZE; 3204 InitiatorName = (CHAR8 *) AllocateZeroPool (BufferSize); 3205 if (InitiatorName == NULL) { 3206 Status = EFI_OUT_OF_RESOURCES; 3207 goto Exit; 3208 } 3209 3210 // 3211 // Convert <ConfigResp> to buffer data by helper function ConfigToBlock(). 3212 // 3213 BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA); 3214 Status = gHiiConfigRouting->ConfigToBlock ( 3215 gHiiConfigRouting, 3216 Configuration, 3217 (UINT8 *) IfrNvData, 3218 &BufferSize, 3219 Progress 3220 ); 3221 if (EFI_ERROR (Status)) { 3222 goto Exit; 3223 } 3224 3225 if (IfrNvData->InitiatorName[0] != L'\0') { 3226 UnicodeStrToAsciiStrS (IfrNvData->InitiatorName, InitiatorName, ISCSI_NAME_MAX_SIZE); 3227 BufferSize = AsciiStrSize (InitiatorName); 3228 3229 Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, InitiatorName); 3230 if (EFI_ERROR (Status)) { 3231 CreatePopUp ( 3232 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 3233 &Key, 3234 L"Invalid iSCSI Name!", 3235 NULL 3236 ); 3237 goto Exit; 3238 } 3239 } else { 3240 Status = IScsiGetValue (Configuration, L"&OFFSET=", &OffSet); 3241 if (EFI_ERROR (Status)) { 3242 goto Exit; 3243 } 3244 3245 if (OffSet >= ATTEMPT_MAC_ADDR_VAR_OFFSET) { 3246 Status = gIScsiInitiatorName.Get (&gIScsiInitiatorName, &BufferSize, InitiatorName); 3247 if (EFI_ERROR (Status)) { 3248 CreatePopUp ( 3249 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 3250 &Key, 3251 L"Error: please configure iSCSI initiator name first!", 3252 NULL 3253 ); 3254 goto Exit; 3255 } 3256 } else { 3257 goto Exit; 3258 } 3259 3260 if (IfrNvData->ISCSIAddAttemptList[0] != L'\0') { 3261 Status =IScsiGetAttemptIndexList (IfrNvData->ISCSIAddAttemptList, IfrNvData->AddAttemptList, TRUE); 3262 if (EFI_ERROR (Status)) { 3263 CreatePopUp ( 3264 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 3265 &Key, 3266 L"Error: The add attempt list is invalid", 3267 NULL 3268 ); 3269 goto Exit; 3270 } 3271 3272 Status = IScsiConfigAddAttemptsByKeywords (IfrNvData->AddAttemptList); 3273 if (EFI_ERROR (Status)) { 3274 goto Exit; 3275 } 3276 3277 } else if (IfrNvData->ISCSIDeleteAttemptList[0] != L'\0') { 3278 AttemptList =(UINT8 *) AllocateZeroPool ((ISCSI_MAX_ATTEMPTS_NUM + 1) * sizeof (UINT8)); 3279 if (AttemptList == NULL) { 3280 Status = EFI_OUT_OF_RESOURCES; 3281 goto Exit; 3282 } 3283 Status = IScsiGetAttemptIndexList (IfrNvData->ISCSIDeleteAttemptList, AttemptList, FALSE); 3284 if (EFI_ERROR (Status)) { 3285 CreatePopUp ( 3286 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 3287 &Key, 3288 L"Error: The delete attempt list is invalid", 3289 NULL 3290 ); 3291 goto Exit; 3292 } 3293 3294 // 3295 // Mark the attempt which will be delete in the global list. 3296 // 3297 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mPrivate->AttemptConfigs) { 3298 AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link); 3299 while (AttemptList[Index] != 0) { 3300 if (AttemptConfigData->AttemptConfigIndex == AttemptList[Index]) { 3301 IfrNvData->DeleteAttemptList[Index2] = 1; 3302 break; 3303 } 3304 Index ++; 3305 } 3306 Index2 ++; 3307 Index = 0; 3308 } 3309 3310 Status = IScsiConfigDeleteAttempts (IfrNvData); 3311 if (EFI_ERROR (Status)) { 3312 goto Exit; 3313 } 3314 3315 FreePool (AttemptList); 3316 3317 } else if (IfrNvData->ISCSIAttemptOrder[0] != L'\0') { 3318 Status = IScsiGetAttemptIndexList (IfrNvData->ISCSIAttemptOrder, IfrNvData->DynamicOrderedList, FALSE); 3319 if (EFI_ERROR (Status)) { 3320 CreatePopUp ( 3321 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 3322 &Key, 3323 L"Error: The new attempt order list is invalid", 3324 NULL 3325 ); 3326 goto Exit; 3327 } 3328 3329 Status = IScsiConfigOrderAttempts (IfrNvData); 3330 if (EFI_ERROR (Status)) { 3331 goto Exit; 3332 } 3333 3334 } else if (IfrNvData->ISCSIMacAddr[0] != L'\0') { 3335 NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) { 3336 NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); 3337 IScsiMacAddrToStr ( 3338 &NicInfo->PermanentAddress, 3339 NicInfo->HwAddressSize, 3340 NicInfo->VlanId, 3341 MacString 3342 ); 3343 if (!StrCmp(MacString, IfrNvData->ISCSIMacAddr)) { 3344 mPrivate->CurrentNic = NicInfo->NicIndex; 3345 break; 3346 } 3347 } 3348 3349 if ((NicInfo == NULL) || (NicInfo->NicIndex == 0)) { 3350 Status = EFI_NOT_FOUND; 3351 goto Exit; 3352 } 3353 3354 } else { 3355 Status = IScsiConvertlfrNvDataToAttemptConfigDataByKeyword (IfrNvData, OffSet); 3356 if (EFI_ERROR (Status)) { 3357 goto Exit; 3358 } 3359 } 3360 } 3361 3362 IScsiConfigUpdateAttempt (); 3363 3364 Exit: 3365 if (InitiatorName != NULL) { 3366 FreePool (InitiatorName); 3367 } 3368 3369 if (IfrNvData != NULL) { 3370 FreePool (IfrNvData); 3371 } 3372 3373 return Status; 2045 3374 } 2046 2047 3375 2048 3376 /** … … 2085 3413 UINTN BufferSize; 2086 3414 CHAR8 *IScsiName; 2087 CHAR8 IpString[I P_STR_MAX_SIZE];3415 CHAR8 IpString[ISCSI_NAME_MAX_SIZE]; 2088 3416 CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN]; 2089 3417 UINT64 Lun; … … 2094 3422 ISCSI_CONFIG_IFR_NVDATA OldIfrNvData; 2095 3423 EFI_STATUS Status; 2096 CHAR16 AttemptName[ATTEMPT_NAME_SIZE + 4];2097 3424 EFI_INPUT_KEY Key; 3425 ISCSI_NIC_INFO *NicInfo; 3426 3427 NicInfo = NULL; 2098 3428 2099 3429 if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) { … … 2144 3474 switch (QuestionId) { 2145 3475 case KEY_ADD_ATTEMPT: 3476 // 3477 // Check whether iSCSI initiator name is configured already. 3478 // 3479 mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE; 3480 Status = gIScsiInitiatorName.Get ( 3481 &gIScsiInitiatorName, 3482 &mPrivate->InitiatorNameLength, 3483 mPrivate->InitiatorName 3484 ); 3485 if (EFI_ERROR (Status)) { 3486 CreatePopUp ( 3487 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 3488 &Key, 3489 L"Error: please configure iSCSI initiator name first!", 3490 NULL 3491 ); 3492 break; 3493 } 3494 2146 3495 Status = IScsiConfigAddAttempt (); 2147 3496 break; … … 2175 3524 switch (QuestionId) { 2176 3525 case KEY_INITIATOR_NAME: 2177 UnicodeStrToAsciiStr (IfrNvData->InitiatorName, IScsiName);3526 UnicodeStrToAsciiStrS (IfrNvData->InitiatorName, IScsiName, ISCSI_NAME_MAX_SIZE); 2178 3527 BufferSize = AsciiStrSize (IScsiName); 2179 3528 … … 2190 3539 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; 2191 3540 break; 2192 case KEY_ATTEMPT_NAME:2193 if (StrLen (IfrNvData->AttemptName) > ATTEMPT_NAME_SIZE) {2194 CopyMem (AttemptName, IfrNvData->AttemptName, ATTEMPT_NAME_SIZE * sizeof (CHAR16));2195 CopyMem (&AttemptName[ATTEMPT_NAME_SIZE], L"...", 4 * sizeof (CHAR16));2196 } else {2197 CopyMem (2198 AttemptName,2199 IfrNvData->AttemptName,2200 (StrLen (IfrNvData->AttemptName) + 1) * sizeof (CHAR16)2201 );2202 }2203 2204 UnicodeStrToAsciiStr (IfrNvData->AttemptName, Private->Current->AttemptName);2205 2206 IScsiConfigUpdateAttempt ();2207 2208 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;2209 break;2210 3541 2211 3542 case KEY_SAVE_ATTEMPT_CONFIG: … … 2215 3546 } 2216 3547 2217 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_ APPLY;3548 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; 2218 3549 break; 2219 3550 … … 2265 3596 switch (Value->u8) { 2266 3597 case IP_MODE_IP6: 3598 NicInfo = IScsiGetNicInfoByIndex (Private->Current->NicIndex); 3599 if(NicInfo == NULL) { 3600 break; 3601 } 3602 3603 if(!NicInfo->Ipv6Available) { 3604 // 3605 // Current NIC doesn't Support IPv6, hence use IPv4. 3606 // 3607 IfrNvData->IpMode = IP_MODE_IP4; 3608 3609 CreatePopUp ( 3610 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 3611 &Key, 3612 L"Current NIC doesn't Support IPv6!", 3613 NULL 3614 ); 3615 } 3616 3617 case IP_MODE_IP4: 3618 ZeroMem (IfrNvData->LocalIp, sizeof (IfrNvData->LocalIp)); 3619 ZeroMem (IfrNvData->SubnetMask, sizeof (IfrNvData->SubnetMask)); 3620 ZeroMem (IfrNvData->Gateway, sizeof (IfrNvData->Gateway)); 2267 3621 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); 2268 IScsiIpToStr (&Private->Current->SessionConfigData.TargetIp, TRUE, IfrNvData->TargetIp);2269 3622 Private->Current->AutoConfigureMode = 0; 2270 break; 2271 2272 case IP_MODE_IP4: 2273 ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); 2274 IScsiIpToStr (&Private->Current->SessionConfigData.TargetIp, FALSE, IfrNvData->TargetIp); 2275 Private->Current->AutoConfigureMode = 0; 3623 ZeroMem (&Private->Current->SessionConfigData.LocalIp, sizeof (EFI_IP_ADDRESS)); 3624 ZeroMem (&Private->Current->SessionConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); 3625 ZeroMem (&Private->Current->SessionConfigData.Gateway, sizeof (EFI_IP_ADDRESS)); 3626 ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof (EFI_IP_ADDRESS)); 2276 3627 2277 3628 break; … … 2282 3633 case KEY_LOCAL_IP: 2283 3634 Status = NetLibStrToIp4 (IfrNvData->LocalIp, &HostIp.v4); 2284 if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { 3635 if (EFI_ERROR (Status) || 3636 ((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && 3637 !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) { 2285 3638 CreatePopUp ( 2286 3639 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, … … 2316 3669 case KEY_GATE_WAY: 2317 3670 Status = NetLibStrToIp4 (IfrNvData->Gateway, &Gateway.v4); 2318 if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) { 3671 if (EFI_ERROR (Status) || 3672 ((Gateway.Addr[0] != 0) && 3673 (Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) && 3674 !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) { 2319 3675 CreatePopUp ( 2320 3676 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, … … 2331 3687 2332 3688 case KEY_TARGET_IP: 2333 UnicodeStrToAsciiStr (IfrNvData->TargetIp, IpString);3689 UnicodeStrToAsciiStrS (IfrNvData->TargetIp, IpString, sizeof (IpString)); 2334 3690 Status = IScsiAsciiStrToIp (IpString, IfrNvData->IpMode, &HostIp); 2335 3691 if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, IfrNvData->IpMode)) { 2336 CreatePopUp ( 2337 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 2338 &Key, 2339 L"Invalid IP address!", 2340 NULL 2341 ); 2342 Status = EFI_INVALID_PARAMETER; 3692 // 3693 // The target is expressed in URL format or an invalid Ip address, just save. 3694 // 3695 Private->Current->SessionConfigData.DnsMode = TRUE; 3696 ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof (Private->Current->SessionConfigData.TargetIp)); 3697 UnicodeStrToAsciiStrS (IfrNvData->TargetIp, Private->Current->SessionConfigData.TargetUrl, ISCSI_NAME_MAX_SIZE); 2343 3698 } else { 3699 Private->Current->SessionConfigData.DnsMode = FALSE; 2344 3700 CopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp, sizeof (HostIp)); 2345 3701 } … … 2348 3704 2349 3705 case KEY_TARGET_NAME: 2350 UnicodeStrToAsciiStr (IfrNvData->TargetName, IScsiName);3706 UnicodeStrToAsciiStrS (IfrNvData->TargetName, IScsiName, ISCSI_NAME_MAX_SIZE); 2351 3707 Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName)); 2352 3708 if (EFI_ERROR (Status)) { … … 2358 3714 ); 2359 3715 } else { 2360 AsciiStrCpy (Private->Current->SessionConfigData.TargetName, IScsiName);3716 AsciiStrCpyS (Private->Current->SessionConfigData.TargetName, ISCSI_NAME_MAX_SIZE, IScsiName); 2361 3717 } 2362 3718 … … 2371 3727 2372 3728 case KEY_BOOT_LUN: 2373 UnicodeStrToAsciiStr (IfrNvData->BootLun, LunString);3729 UnicodeStrToAsciiStrS (IfrNvData->BootLun, LunString, sizeof (LunString)); 2374 3730 Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun); 2375 3731 if (EFI_ERROR (Status)) { … … 2398 3754 2399 3755 case KEY_CHAP_NAME: 2400 UnicodeStrToAsciiStr (3756 UnicodeStrToAsciiStrS ( 2401 3757 IfrNvData->CHAPName, 2402 Private->Current->AuthConfigData.CHAP.CHAPName 3758 Private->Current->AuthConfigData.CHAP.CHAPName, 3759 sizeof (Private->Current->AuthConfigData.CHAP.CHAPName) 2403 3760 ); 2404 3761 break; 2405 3762 2406 3763 case KEY_CHAP_SECRET: 2407 UnicodeStrToAsciiStr (3764 UnicodeStrToAsciiStrS ( 2408 3765 IfrNvData->CHAPSecret, 2409 Private->Current->AuthConfigData.CHAP.CHAPSecret 3766 Private->Current->AuthConfigData.CHAP.CHAPSecret, 3767 sizeof (Private->Current->AuthConfigData.CHAP.CHAPSecret) 2410 3768 ); 2411 3769 break; 2412 3770 2413 3771 case KEY_REVERSE_CHAP_NAME: 2414 UnicodeStrToAsciiStr (3772 UnicodeStrToAsciiStrS ( 2415 3773 IfrNvData->ReverseCHAPName, 2416 Private->Current->AuthConfigData.CHAP.ReverseCHAPName 3774 Private->Current->AuthConfigData.CHAP.ReverseCHAPName, 3775 sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPName) 2417 3776 ); 2418 3777 break; 2419 3778 2420 3779 case KEY_REVERSE_CHAP_SECRET: 2421 UnicodeStrToAsciiStr (3780 UnicodeStrToAsciiStrS ( 2422 3781 IfrNvData->ReverseCHAPSecret, 2423 Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret 3782 Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret, 3783 sizeof (Private->Current->AuthConfigData.CHAP.ReverseCHAPSecret) 2424 3784 ); 2425 3785 break; … … 2561 3921 ASSERT (mPrivate->NicCount == 0); 2562 3922 2563 //2564 // Free attempt is created but not saved to system.2565 //2566 if (mPrivate->NewAttempt != NULL) {2567 FreePool (mPrivate->NewAttempt);2568 }2569 2570 3923 FreePool (mPrivate); 2571 3924 mPrivate = NULL; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiConfig.h
r48674 r77662 3 3 relating to iSCSI. 4 4 5 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 6 6 This program and the accompanying materials 7 7 are licensed and made available under the terms and conditions of the BSD License … … 31 31 #define QUESTION_ID(Field) \ 32 32 ((UINT16) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)) 33 34 33 35 34 #define DYNAMIC_ONE_OF_VAR_OFFSET VAR_OFFSET (Enabled) … … 38 37 #define ATTEMPT_DEL_QUESTION_ID QUESTION_ID (DeleteAttemptList) 39 38 #define ATTEMPT_DEL_VAR_OFFSET VAR_OFFSET (DeleteAttemptList) 39 #define ATTEMPT_ADD_QUESTION_ID QUESTION_ID (AddAttemptList) 40 #define ATTEMPT_ADD_VAR_OFFSET VAR_OFFSET (AddAttemptList) 40 41 41 42 // 42 // sizeof (EFI_MAC_ADDRESS) * 343 // Define QuestionId and OffSet for Keywords. 43 44 // 44 #define ISCSI_MAX_MAC_STRING_LEN 96 45 #define ATTEMPT_MAC_ADDR_VAR_OFFSET VAR_OFFSET (ISCSIMacAddr) 46 #define ATTEMPT_ATTEMPT_NAME_QUESTION_ID QUESTION_ID (ISCSIAttemptName) 47 #define ATTEMPT_ATTEMPT_NAME_VAR_OFFSET VAR_OFFSET (ISCSIAttemptName) 48 #define ATTEMPT_BOOTENABLE_QUESTION_ID QUESTION_ID (ISCSIBootEnableList) 49 #define ATTEMPT_BOOTENABLE_VAR_OFFSET VAR_OFFSET (ISCSIBootEnableList) 50 #define ATTEMPT_ADDRESS_TYPE_QUESTION_ID QUESTION_ID (ISCSIIpAddressTypeList) 51 #define ATTEMPT_ADDRESS_TYPE_VAR_OFFSET VAR_OFFSET (ISCSIIpAddressTypeList) 52 #define ATTEMPT_CONNECT_RETRY_QUESTION_ID QUESTION_ID (ISCSIConnectRetry) 53 #define ATTEMPT_CONNECT_RETRY_VAR_OFFSET VAR_OFFSET (ISCSIConnectRetry) 54 #define ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID QUESTION_ID (ISCSIConnectTimeout) 55 #define ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET VAR_OFFSET (ISCSIConnectTimeout) 56 #define ATTEMPT_ISID_QUESTION_ID QUESTION_ID (Keyword->ISCSIIsId) 57 #define ATTEMPT_ISID_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIIsId) 58 #define ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID QUESTION_ID (ISCSIInitiatorInfoViaDHCP) 59 #define ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET VAR_OFFSET (ISCSIInitiatorInfoViaDHCP) 60 #define ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID QUESTION_ID (Keyword->ISCSIInitiatorIpAddress) 61 #define ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIInitiatorIpAddress) 62 #define ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID QUESTION_ID (Keyword->ISCSIInitiatorNetmask) 63 #define ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIInitiatorNetmask) 64 #define ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID QUESTION_ID (Keyword->ISCSIInitiatorGateway) 65 #define ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIInitiatorGateway) 66 #define ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID QUESTION_ID (ISCSITargetInfoViaDHCP) 67 #define ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET VAR_OFFSET (ISCSITargetInfoViaDHCP) 68 #define ATTEMPT_TARGET_NAME_QUESTION_ID QUESTION_ID (Keyword->ISCSITargetName) 69 #define ATTEMPT_TARGET_NAME_VAR_OFFSET VAR_OFFSET (Keyword->ISCSITargetName) 70 #define ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID QUESTION_ID (Keyword->ISCSITargetIpAddress) 71 #define ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET VAR_OFFSET (Keyword->ISCSITargetIpAddress) 72 #define ATTEMPT_TARGET_TCP_PORT_QUESTION_ID QUESTION_ID (ISCSITargetTcpPort) 73 #define ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET VAR_OFFSET (ISCSITargetTcpPort) 74 #define ATTEMPT_LUN_QUESTION_ID QUESTION_ID (Keyword->ISCSILun) 75 #define ATTEMPT_LUN_VAR_OFFSET VAR_OFFSET (Keyword->ISCSILun) 76 #define ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID QUESTION_ID (ISCSIAuthenticationMethod) 77 #define ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET VAR_OFFSET (ISCSIAuthenticationMethod) 78 #define ATTEMPT_CHARTYPE_QUESTION_ID QUESTION_ID (ISCSIChapType) 79 #define ATTEMPT_CHARTYPE_VAR_OFFSET VAR_OFFSET (ISCSIChapType) 80 #define ATTEMPT_CHAR_USER_NAME_QUESTION_ID QUESTION_ID (Keyword->ISCSIChapUsername) 81 #define ATTEMPT_CHAR_USER_NAME_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIChapUsername) 82 #define ATTEMPT_CHAR_SECRET_QUESTION_ID QUESTION_ID (Keyword->ISCSIChapSecret) 83 #define ATTEMPT_CHAR_SECRET_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIChapSecret) 84 #define ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID QUESTION_ID (Keyword->ISCSIReverseChapUsername) 85 #define ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIReverseChapUsername) 86 #define ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID QUESTION_ID (Keyword->ISCSIReverseChapSecret) 87 #define ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET VAR_OFFSET (Keyword->ISCSIReverseChapSecret) 88 45 89 46 90 #define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME" … … 69 113 EFI_STRING_ID AttemptTitleToken; 70 114 EFI_STRING_ID AttemptTitleHelpToken; 71 CHAR8 AttemptName[ATTEMPT_NAME_ MAX_SIZE];115 CHAR8 AttemptName[ATTEMPT_NAME_SIZE]; 72 116 CHAR8 MacString[ISCSI_MAX_MAC_STRING_LEN]; 73 117 EFI_IP_ADDRESS PrimaryDns; … … 79 123 ISCSI_CHAP_AUTH_CONFIG_NVDATA CHAP; 80 124 } AuthConfigData; 81 125 BOOLEAN AutoConfigureSuccess; 126 UINT8 Actived; 82 127 }; 83 128 … … 103 148 104 149 /** 150 Create Hii Extend Label OpCode as the start opcode and end opcode. It is 151 a help function. 152 153 @param[in] StartLabelNumber The number of start label. 154 @param[out] StartOpCodeHandle Points to the start opcode handle. 155 @param[out] StartLabel Points to the created start opcode. 156 @param[out] EndOpCodeHandle Points to the end opcode handle. 157 @param[out] EndLabel Points to the created end opcode. 158 159 @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this 160 operation. 161 @retval EFI_INVALID_PARAMETER Any input parameter is invalid. 162 @retval EFI_SUCCESS The operation is completed successfully. 163 164 **/ 165 EFI_STATUS 166 IScsiCreateOpCode ( 167 IN UINT16 StartLabelNumber, 168 OUT VOID **StartOpCodeHandle, 169 OUT EFI_IFR_GUID_LABEL **StartLabel, 170 OUT VOID **EndOpCodeHandle, 171 OUT EFI_IFR_GUID_LABEL **EndLabel 172 ); 173 174 /** 105 175 Initialize the iSCSI configuration form. 106 176 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h
r58459 r77662 2 2 Define NVData structures used by the iSCSI configuration component. 3 3 4 Copyright (c) 2004 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 27 27 #define FORMID_DELETE_FORM 5 28 28 29 #define ISCSI_MAX_ATTEMPTS_NUM FixedPcdGet8 (PcdMaxIScsiAttemptNumber) 30 29 31 #define ISCSI_NAME_IFR_MIN_SIZE 4 30 32 #define ISCSI_NAME_IFR_MAX_SIZE 223 31 33 #define ISCSI_NAME_MAX_SIZE 224 32 34 33 #define ATTEMPT_NAME_ MAX_SIZE9634 #define ATTEMPT_NAME_SIZE 1 035 #define ATTEMPT_NAME_LIST_SIZE 96 36 #define ATTEMPT_NAME_SIZE 12 35 37 36 38 #define CONNECT_MIN_RETRY 0 … … 41 43 #define CONNECT_DEFAULT_TIMEOUT 1000 42 44 43 #define ISCSI_MAX_ATTEMPTS_NUM 255 45 #define ISCSI_ACTIVE_DISABLED 0 46 #define ISCSI_ACTIVE_ENABLED 1 44 47 45 48 #define ISCSI_DISABLED 0 … … 68 71 #define LUN_MIN_SIZE 1 69 72 #define LUN_MAX_SIZE 20 73 #define ISCSI_LUN_STR_MAX_LEN 21 70 74 71 75 #define ISCSI_CHAP_UNI 0 … … 113 117 #define ORDER_ENTRY_LABEL 0x4000 114 118 #define DELETE_ENTRY_LABEL 0x5000 119 #define KEYWORD_ENTRY_LABEL 0x6000 115 120 #define CONFIG_OPTION_OFFSET 0x9000 116 121 117 #define ISCSI_LUN_STR_MAX_LEN 21118 122 #define ISCSI_CHAP_SECRET_MIN_LEN 12 119 123 #define ISCSI_CHAP_SECRET_MAX_LEN 16 … … 121 125 // ISCSI_CHAP_SECRET_STORAGE = ISCSI_CHAP_SECRET_MAX_LEN + sizeof (NULL-Terminator) 122 126 // 123 #define ISCSI_CHAP_SECRET_STORAGE 17 124 #define ISCSI_CHAP_NAME_MAX_LEN 126 125 #define ISCSI_CHAP_NAME_STORAGE 127 127 #define ISCSI_CHAP_SECRET_STORAGE 17 128 129 #define ISCSI_CHAP_NAME_MAX_LEN 126 130 #define ISCSI_CHAP_NAME_STORAGE 127 126 131 127 132 #define KERBEROS_SECRET_MIN_LEN 12 … … 136 141 #define ISID_CONFIGURABLE_STORAGE 13 137 142 143 // 144 // sizeof (EFI_MAC_ADDRESS) * 3 145 // 146 #define ISCSI_MAX_MAC_STRING_LEN 96 147 148 /// 149 /// Macro used for target Url. 150 /// 151 #define ISCSI_TARGET_URI_MIN_SIZE 0 152 #define ISCSI_TARGET_URI_MAX_SIZE 255 153 138 154 #pragma pack(1) 155 156 // 157 // Used by keyword. 158 // 159 typedef struct { 160 CHAR16 ISCSIIsId[ISID_CONFIGURABLE_STORAGE]; 161 CHAR16 ISCSIInitiatorIpAddress[IP4_STR_MAX_SIZE]; 162 CHAR16 ISCSIInitiatorNetmask[IP4_STR_MAX_SIZE]; 163 CHAR16 ISCSIInitiatorGateway[IP4_STR_MAX_SIZE]; 164 CHAR16 ISCSITargetName[ISCSI_NAME_MAX_SIZE]; 165 CHAR16 ISCSITargetIpAddress[ISCSI_TARGET_URI_MAX_SIZE]; 166 CHAR16 ISCSILun[ISCSI_LUN_STR_MAX_LEN]; 167 CHAR16 ISCSIChapUsername[ISCSI_CHAP_NAME_STORAGE]; 168 CHAR16 ISCSIChapSecret[ISCSI_CHAP_SECRET_STORAGE]; 169 CHAR16 ISCSIReverseChapUsername[ISCSI_CHAP_NAME_STORAGE]; 170 CHAR16 ISCSIReverseChapSecret[ISCSI_CHAP_SECRET_STORAGE]; 171 } KEYWORD_STR; 172 139 173 typedef struct _ISCSI_CONFIG_IFR_NVDATA { 140 174 CHAR16 InitiatorName[ISCSI_NAME_MAX_SIZE]; 141 CHAR16 AttemptName[ATTEMPT_NAME_MAX_SIZE]; 142 175 CHAR16 AttemptName[ATTEMPT_NAME_SIZE]; 143 176 UINT8 Enabled; 144 177 UINT8 IpMode; … … 155 188 156 189 CHAR16 TargetName[ISCSI_NAME_MAX_SIZE]; 157 CHAR16 TargetIp[I P_STR_MAX_SIZE];190 CHAR16 TargetIp[ISCSI_TARGET_URI_MAX_SIZE]; 158 191 UINT16 TargetPort; 159 192 CHAR16 BootLun[ISCSI_LUN_STR_MAX_LEN]; … … 178 211 UINT8 DynamicOrderedList[ISCSI_MAX_ATTEMPTS_NUM]; 179 212 UINT8 DeleteAttemptList[ISCSI_MAX_ATTEMPTS_NUM]; 180 213 UINT8 AddAttemptList[ISCSI_MAX_ATTEMPTS_NUM]; 181 214 CHAR16 IsId[ISID_CONFIGURABLE_STORAGE]; 215 216 // 217 // This will be used by keywords. 218 // 219 CHAR16 ISCSIMacAddr[ISCSI_MAX_MAC_STRING_LEN]; 220 CHAR16 ISCSIAttemptOrder[ATTEMPT_NAME_LIST_SIZE]; 221 CHAR16 ISCSIAddAttemptList[ATTEMPT_NAME_LIST_SIZE]; 222 CHAR16 ISCSIDeleteAttemptList[ATTEMPT_NAME_LIST_SIZE]; 223 CHAR16 ISCSIDisplayAttemptList[ATTEMPT_NAME_LIST_SIZE]; 224 CHAR16 ISCSIAttemptName[ATTEMPT_NAME_LIST_SIZE]; 225 UINT8 ISCSIBootEnableList[ISCSI_MAX_ATTEMPTS_NUM]; 226 UINT8 ISCSIIpAddressTypeList[ISCSI_MAX_ATTEMPTS_NUM]; 227 UINT8 ISCSIConnectRetry[ISCSI_MAX_ATTEMPTS_NUM]; 228 UINT16 ISCSIConnectTimeout[ISCSI_MAX_ATTEMPTS_NUM]; 229 UINT8 ISCSIInitiatorInfoViaDHCP[ISCSI_MAX_ATTEMPTS_NUM]; 230 UINT8 ISCSITargetInfoViaDHCP[ISCSI_MAX_ATTEMPTS_NUM]; 231 UINT16 ISCSITargetTcpPort[ISCSI_MAX_ATTEMPTS_NUM]; 232 UINT8 ISCSIAuthenticationMethod[ISCSI_MAX_ATTEMPTS_NUM]; 233 UINT8 ISCSIChapType[ISCSI_MAX_ATTEMPTS_NUM]; 234 KEYWORD_STR Keyword[ISCSI_MAX_ATTEMPTS_NUM]; 182 235 } ISCSI_CONFIG_IFR_NVDATA; 183 236 #pragma pack() -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni
r58466 r77662 1 // *++1 // *++ 2 2 // 3 // Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>3 // Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 4 4 // This program and the accompanying materials 5 5 // are licensed and made available under the terms and conditions of the BSD License … … 13 13 // 14 14 // IScsiConfigStrings.uni 15 // 15 // 16 16 // Abstract: 17 // 17 // 18 18 // String definitions for iSCSI configuration. 19 // 19 // 20 20 // Revision History: 21 // 21 // 22 22 // --*/ 23 23 … … 25 25 26 26 #langdef en-US "English" 27 #langdef x-UEFI-ns "UefiNameSpace" 27 28 28 29 #string STR_ISCSI_CONFIG_FORM_TITLE #language en-US "iSCSI Configuration" … … 31 32 #string STR_ISCSI_MAC_FORM_TITLE #language en-US "MAC Selection" 32 33 #string STR_ISCSI_CONFIG_INIT_NAME #language en-US "iSCSI Initiator Name" 34 #language x-UEFI-ns "iSCSIInitiatorName" 33 35 #string STR_ISCSI_CONFIG_INIT_NAME_HELP #language en-US "The worldwide unique name of iSCSI Initiator. Only IQN format is accepted." 34 36 #string STR_ISCSI_ATTEMPT_NAME #language en-US "iSCSI Attempt Name" … … 64 66 #string STR_ISCSI_TARGET_NAME #language en-US " Target Name" 65 67 #string STR_ISCSI_TARGET_NAME_HELP #language en-US "The worldwide unique name of the target. Only iqn. format is accepted." 66 #string STR_ISCSI_TARGET_IP_ADDRESS #language en-US " Target IP Address" 68 #string STR_ISCSI_TARGET_ADDRESS #language en-US " Target Address" 69 #string STR_ISCSI_TARGET_ADDRESS_HELP #language en-US "Enter Target address in IPv4,IPv6 or URL format.You need to configure DNS server address in advance if input a URL string." 67 70 #string STR_ISCSI_TARGET_PORT #language en-US " Target Port" 68 71 #string STR_ISCSI_BOOT_LUN #language en-US " Boot LUN" 69 72 #string STR_ISCSI_BOOT_LUN_HELP #language en-US "Hexadecimal representation of the LU number. Examples are: 4752-3A4F-6b7e-2F99, 6734-9-156f-127, 4186-9" 70 #string STR_ISCSI_ENABLE_DHCP #language en-US "Enable DHCP" 73 #string STR_ISCSI_ENABLE_DHCP #language en-US "Enable DHCP" 71 74 #string STR_ISCSI_ENABLE_DHCP_ON_TARGET #language en-US "Get target info via DHCP" 72 75 #string STR_CHAP_TYPE_PROMPT #language en-US " CHAP Type" … … 83 86 #string STR_SAVE_CHANGES_HELP #language en-US "Must reboot system manually for changes to take place." 84 87 #string STR_NULL #language en-US "" 85 #string STR_SAVE_AND_EXIT #language en-US "Commit Changes and Exit" 86 #string STR_NO_SAVE_AND_EXIT #language en-US "Discard Changes and Exit" 88 #string STR_SAVE_AND_EXIT #language en-US "Commit Changes and Exit" 89 #string STR_NO_SAVE_AND_EXIT #language en-US "Discard Changes and Exit" 87 90 #string STR_ISCSI_CONFIG_ISID #language en-US "ISID" 88 91 #string STR_ISCSI_CONFIG_ISID_HELP #language en-US "OUI-format ISID in 6 bytes, default value are derived from MAC address. Only last 3 bytes are configurable. Example: update 0ABBCCDDEEFF to 0ABBCCF07901 by input F07901." 89 90 92 #string STR_ISCSI_MAC_PROMPT #language en-US "Configure the mac address for the attempt" 93 #language x-UEFI-ns "iSCSIMacAddr" 94 #string STR_ISCSI_ADD_ATTEMPTS #language en-US "Add Attempts" 95 #language x-UEFI-ns "iSCSIAddAttempts" 96 #string STR_ISCSI_DELETE_ATTEMPTS #language en-US "Delete Attempts" 97 #language x-UEFI-ns "iSCSIDeleteAttempts" 98 #string STR_ISCSI_DISPLAY_ATTEMPTS #language en-US "Display Attempts" 99 #language x-UEFI-ns "iSCSIDisplayAttemptList" 100 #string STR_ISCSI_ATTEMPT_ORDER #language en-US "New Attempt Order" 101 #language x-UEFI-ns "iSCSIAttemptOrder" 102 #string STR_ISCSI_ISID_HELP #language en-US "The iSCSI ISID. Default value are derived from MAC address. Only last 3 bytes are configurable." -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr
r58466 r77662 2 2 VFR file used by the iSCSI configuration component. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 21 21 title = STRING_TOKEN(STR_ISCSI_CONFIG_FORM_TITLE), 22 22 help = STRING_TOKEN(STR_ISCSI_CONFIG_FORM_HELP), 23 class = EFI_NETWORK_DEVICE_CLASS,24 subclass = 0x03,25 23 26 24 varstore ISCSI_CONFIG_IFR_NVDATA, … … 124 122 prompt = STRING_TOKEN(STR_ISCSI_ATTEMPT_NAME), 125 123 help = STRING_TOKEN(STR_ISCSI_ATTEMPT_NAME_HELP), 126 flags = INTERACTIVE,124 flags = READ_ONLY, 127 125 key = KEY_ATTEMPT_NAME, 128 126 minsize = 0, 129 maxsize = ATTEMPT_NAME_ MAX_SIZE,127 maxsize = ATTEMPT_NAME_SIZE, 130 128 endstring; 131 129 … … 194 192 endif; 195 193 196 suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01 OR 197 ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 194 suppressif ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_IP6 OR 198 195 ideqval ISCSI_CONFIG_IFR_NVDATA.IpMode == IP_MODE_AUTOCONFIG; 196 197 grayoutif ideqval ISCSI_CONFIG_IFR_NVDATA.InitiatorInfoFromDhcp == 0x01; 199 198 string varid = ISCSI_CONFIG_IFR_NVDATA.LocalIp, 200 199 prompt = STRING_TOKEN(STR_ISCSI_LOCAL_IP_ADDRESS), … … 223 222 maxsize = IP4_MAX_SIZE, 224 223 endstring; 224 endif; 225 225 226 226 endif; … … 252 252 253 253 string varid = ISCSI_CONFIG_IFR_NVDATA.TargetIp, 254 prompt = STRING_TOKEN(STR_ISCSI_TARGET_ IP_ADDRESS),255 help = STRING_TOKEN(STR_ISCSI_ IP_ADDRESS_HELP),254 prompt = STRING_TOKEN(STR_ISCSI_TARGET_ADDRESS), 255 help = STRING_TOKEN(STR_ISCSI_TARGET_ADDRESS_HELP), 256 256 flags = INTERACTIVE, 257 257 key = KEY_TARGET_IP, 258 minsize = I P_MIN_SIZE,259 maxsize = I P_MAX_SIZE,258 minsize = ISCSI_TARGET_URI_MIN_SIZE, 259 maxsize = ISCSI_TARGET_URI_MAX_SIZE, 260 260 endstring; 261 261 … … 345 345 endif; 346 346 347 suppressif TRUE; 348 349 string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIMacAddr, 350 prompt = STRING_TOKEN(STR_ISCSI_MAC_PROMPT), 351 help = STRING_TOKEN(STR_ISCSI_MAC_PROMPT), 352 minsize = 0, 353 maxsize = ISCSI_MAX_MAC_STRING_LEN, 354 endstring; 355 356 string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIAttemptOrder, 357 prompt = STRING_TOKEN(STR_ISCSI_ATTEMPT_ORDER), 358 help = STRING_TOKEN(STR_ISCSI_ATTEMPT_ORDER), 359 minsize = 0, 360 maxsize = ATTEMPT_NAME_LIST_SIZE, 361 endstring; 362 363 string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIAddAttemptList, 364 prompt = STRING_TOKEN(STR_ISCSI_ADD_ATTEMPTS), 365 help = STRING_TOKEN(STR_ISCSI_ADD_ATTEMPTS), 366 minsize = 0, 367 maxsize = ATTEMPT_NAME_LIST_SIZE, 368 endstring; 369 370 string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIDeleteAttemptList, 371 prompt = STRING_TOKEN(STR_ISCSI_DELETE_ATTEMPTS), 372 help = STRING_TOKEN(STR_ISCSI_DELETE_ATTEMPTS), 373 minsize = 0, 374 maxsize = ATTEMPT_NAME_LIST_SIZE, 375 endstring; 376 377 string varid = ISCSI_CONFIG_IFR_NVDATA.ISCSIDisplayAttemptList, 378 prompt = STRING_TOKEN(STR_ISCSI_DISPLAY_ATTEMPTS), 379 help = STRING_TOKEN(STR_ISCSI_DISPLAY_ATTEMPTS), 380 flags = READ_ONLY, 381 minsize = 0, 382 maxsize = ATTEMPT_NAME_LIST_SIZE, 383 endstring; 384 385 label KEYWORD_ENTRY_LABEL; 386 label LABEL_END; 387 endif; 388 347 389 subtitle text = STRING_TOKEN(STR_NULL); 348 390 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDhcp.c
r58466 r77662 2 2 iSCSI DHCP4 related configuration routines. 3 3 4 Copyright (c) 2004 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 124 124 } 125 125 126 Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); 127 CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); 128 129 if (EFI_ERROR (Status)) { 130 goto ON_EXIT; 126 // 127 // Server name is expressed as domain name, just save it. 128 // 129 if ((!NET_IS_DIGIT (*(Field->Str))) && (*(Field->Str) != '[')) { 130 ConfigNvData->DnsMode = TRUE; 131 if (Field->Len > sizeof (ConfigNvData->TargetUrl)) { 132 return EFI_INVALID_PARAMETER; 133 } 134 CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len); 135 ConfigNvData->TargetUrl[Field->Len + 1] = '\0'; 136 } else { 137 ConfigNvData->DnsMode = FALSE; 138 ZeroMem(ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl)); 139 Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); 140 CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); 141 142 if (EFI_ERROR (Status)) { 143 goto ON_EXIT; 144 } 131 145 } 132 146 // … … 176 190 } 177 191 178 AsciiStrCpy (ConfigNvData->TargetName, Field->Str);192 AsciiStrCpyS (ConfigNvData->TargetName, ISCSI_NAME_MAX_SIZE, Field->Str); 179 193 180 194 ON_EXIT: … … 241 255 242 256 for (Index = 0; Index < OptionCount; Index++) { 243 if (OptionList[Index]->OpCode != DHCP4_TAG_ROOT _PATH) {257 if (OptionList[Index]->OpCode != DHCP4_TAG_ROOTPATH) { 244 258 continue; 245 259 } … … 254 268 } 255 269 256 if ( (Index == OptionCount)) {270 if (Index == OptionCount) { 257 271 Status = EFI_NOT_READY; 258 272 } … … 327 341 // Get DNS server addresses and DHCP server address from this offer. 328 342 // 329 if (OptionList[Index]->OpCode == DHCP4_TAG_DNS ) {343 if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) { 330 344 331 345 if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) { … … 359 373 } 360 374 375 /** 376 This function will switch the IP4 configuration policy to Static. 377 378 @param[in] Ip4Config2 Pointer to the IP4 configuration protocol. 379 380 @retval EFI_SUCCESS The policy is already configured to static. 381 @retval Others Other error as indicated. 382 383 **/ 384 EFI_STATUS 385 IScsiSetIp4Policy ( 386 IN EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2 387 ) 388 { 389 EFI_IP4_CONFIG2_POLICY Policy; 390 EFI_STATUS Status; 391 UINTN DataSize; 392 393 DataSize = sizeof (EFI_IP4_CONFIG2_POLICY); 394 Status = Ip4Config2->GetData ( 395 Ip4Config2, 396 Ip4Config2DataTypePolicy, 397 &DataSize, 398 &Policy 399 ); 400 if (EFI_ERROR (Status)) { 401 return Status; 402 } 403 404 if (Policy != Ip4Config2PolicyStatic) { 405 Policy = Ip4Config2PolicyStatic; 406 Status= Ip4Config2->SetData ( 407 Ip4Config2, 408 Ip4Config2DataTypePolicy, 409 sizeof (EFI_IP4_CONFIG2_POLICY), 410 &Policy 411 ); 412 if (EFI_ERROR (Status)) { 413 return Status; 414 } 415 } 416 417 return EFI_SUCCESS; 418 } 361 419 362 420 /** … … 381 439 { 382 440 EFI_HANDLE Dhcp4Handle; 441 EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; 383 442 EFI_DHCP4_PROTOCOL *Dhcp4; 384 443 EFI_STATUS Status; … … 386 445 EFI_DHCP4_CONFIG_DATA Dhcp4ConfigData; 387 446 ISCSI_SESSION_CONFIG_NVDATA *NvData; 388 BOOLEAN MediaPresent;447 EFI_STATUS MediaStatus; 389 448 390 449 Dhcp4Handle = NULL; 450 Ip4Config2 = NULL; 391 451 Dhcp4 = NULL; 392 452 ParaList = NULL; … … 395 455 // Check media status before doing DHCP. 396 456 // 397 MediaPresent = TRUE; 398 NetLibDetectMedia (Controller, &MediaPresent); 399 if (!MediaPresent) { 457 MediaStatus = EFI_SUCCESS; 458 NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME, &MediaStatus); 459 if (MediaStatus!= EFI_SUCCESS) { 460 AsciiPrint ("\n Error: Could not detect network connection.\n"); 400 461 return EFI_NO_MEDIA; 462 } 463 464 // 465 // DHCP4 service allows only one of its children to be configured in 466 // the active state, If the DHCP4 D.O.R.A started by IP4 auto 467 // configuration and has not been completed, the Dhcp4 state machine 468 // will not be in the right state for the iSCSI to start a new round D.O.R.A. 469 // So, we need to switch it's policy to static. 470 // 471 Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); 472 if (!EFI_ERROR (Status)) { 473 Status = IScsiSetIp4Policy (Ip4Config2); 474 if (EFI_ERROR (Status)) { 475 return Status; 476 } 401 477 } 402 478 … … 441 517 ParaList->Data[0] = DHCP4_TAG_NETMASK; 442 518 ParaList->Data[1] = DHCP4_TAG_ROUTER; 443 ParaList->Data[2] = DHCP4_TAG_DNS ;444 ParaList->Data[3] = DHCP4_TAG_ROOT _PATH;519 ParaList->Data[2] = DHCP4_TAG_DNS_SERVER; 520 ParaList->Data[3] = DHCP4_TAG_ROOTPATH; 445 521 446 522 ZeroMem (&Dhcp4ConfigData, sizeof (EFI_DHCP4_CONFIG_DATA)); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDhcp.h
r48674 r77662 2 2 The head file of iSCSI DHCP4 related configuration routines. 3 3 4 Copyright (c) 2004 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 16 16 #define _ISCSI_DHCP_H_ 17 17 18 19 #define DHCP4_TAG_PARA_LIST 5520 #define DHCP4_TAG_NETMASK 121 #define DHCP4_TAG_ROUTER 322 #define DHCP4_TAG_DNS 623 #define DHCP4_TAG_SERVER_ID 5424 #define DHCP4_TAG_ROOT_PATH 1725 18 #define ISCSI_ROOT_PATH_ID "iscsi:" 26 19 #define ISCSI_ROOT_PATH_FIELD_DELIMITER ':' -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDhcp6.c
r58466 r77662 2 2 iSCSI DHCP6 related configuration routines. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 51 51 52 52 ConfigNvData = &ConfigData->SessionConfigData; 53 53 ConfigNvData->DnsMode = FALSE; 54 54 // 55 55 // "iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname> … … 83 83 // 84 84 if (TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_START_DELIMITER) { 85 Status = EFI_INVALID_PARAMETER; 86 goto ON_EXIT; 85 // 86 // The servername is expressed as domain name. 87 // 88 ConfigNvData->DnsMode = TRUE; 87 89 } else { 88 90 Index++; … … 91 93 Fields[RP_FIELD_IDX_SERVERNAME].Str = &TmpStr[Index]; 92 94 93 while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER) && (Index < Length)) { 94 Index++; 95 } 96 97 // 98 // Skip ']' and ':'. 99 // 100 TmpStr[Index] = '\0'; 101 Index += 2; 95 if (!ConfigNvData->DnsMode) { 96 while ((TmpStr[Index] != ISCSI_ROOT_PATH_ADDR_END_DELIMITER)&& (Index < Length)) { 97 Index++; 98 } 99 100 // 101 // Skip ']' and ':'. 102 // 103 TmpStr[Index] = '\0'; 104 Index += 2; 105 } else { 106 while ((TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) && (Index < Length)) { 107 Index++; 108 } 109 // 110 // Skip ':'. 111 // 112 TmpStr[Index] = '\0'; 113 Index += 1; 114 } 102 115 103 116 Fields[RP_FIELD_IDX_SERVERNAME].Len = (UINT8) AsciiStrLen (Fields[RP_FIELD_IDX_SERVERNAME].Str); … … 151 164 } 152 165 153 Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); 154 CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); 155 156 157 if (EFI_ERROR (Status)) { 158 goto ON_EXIT; 159 } 166 // 167 // Server name is expressed as domain name, just save it. 168 // 169 if (ConfigNvData->DnsMode) { 170 if (Field->Len > sizeof (ConfigNvData->TargetUrl)) { 171 return EFI_INVALID_PARAMETER; 172 } 173 CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len); 174 ConfigNvData->TargetUrl[Field->Len + 1] = '\0'; 175 } else { 176 ZeroMem(&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl)); 177 Status = IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); 178 CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); 179 180 if (EFI_ERROR (Status)) { 181 goto ON_EXIT; 182 } 183 } 184 160 185 // 161 186 // Check the protocol type. … … 204 229 } 205 230 206 AsciiStrCpy (ConfigNvData->TargetName, Field->Str);231 AsciiStrCpyS (ConfigNvData->TargetName, ISCSI_NAME_MAX_SIZE, Field->Str); 207 232 208 233 ON_EXIT: … … 304 329 // 305 330 BootFileOpt = OptionList[Index]; 306 } else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_PARA ) {331 } else if (OptionList[Index]->OpCode == DHCP6_OPT_BOOT_FILE_PARAM) { 307 332 // 308 333 // The server sends this option to inform the client about DHCP6 server address. … … 377 402 EFI_DHCP6_RETRANSMISSION InfoReqReXmit; 378 403 EFI_EVENT Timer; 379 BOOLEAN MediaPresent;404 EFI_STATUS MediaStatus; 380 405 381 406 // 382 407 // Check media status before doing DHCP. 383 408 // 384 MediaPresent = TRUE; 385 NetLibDetectMedia (Controller, &MediaPresent); 386 if (!MediaPresent) { 409 MediaStatus = EFI_SUCCESS; 410 NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME, &MediaStatus); 411 if (MediaStatus != EFI_SUCCESS) { 412 AsciiPrint ("\n Error: Could not detect network connection.\n"); 387 413 return EFI_NO_MEDIA; 388 414 } … … 435 461 // All members in EFI_DHCP6_PACKET_OPTION are in network order. 436 462 // 437 Oro->OpCode = HTONS (DHCP6_OPT_ REQUEST_OPTION);463 Oro->OpCode = HTONS (DHCP6_OPT_ORO); 438 464 Oro->OpLen = HTONS (2 * 3); 439 465 Oro->Data[1] = DHCP6_OPT_DNS_SERVERS; 440 466 Oro->Data[3] = DHCP6_OPT_BOOT_FILE_URL; 441 Oro->Data[5] = DHCP6_OPT_BOOT_FILE_PARA ;467 Oro->Data[5] = DHCP6_OPT_BOOT_FILE_PARAM; 442 468 443 469 InfoReqReXmit.Irt = 4; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDhcp6.h
r58459 r77662 2 2 The header file of iSCSI DHCP6 related configuration routines. 3 3 4 Copyright (c) 2004 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 15 15 #ifndef _ISCSI_DHCP6_H_ 16 16 #define _ISCSI_DHCP6_H_ 17 18 #define DHCP6_OPT_REQUEST_OPTION 619 #define DHCP6_OPT_VENDOR_INFO 1720 #define DHCP6_OPT_DNS_SERVERS 2321 ///22 /// Assigned by IANA, RFC 597023 ///24 #define DHCP6_OPT_BOOT_FILE_URL 5925 #define DHCP6_OPT_BOOT_FILE_PARA 6026 17 27 18 #define ISCSI_ROOT_PATH_ID "iscsi:" -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDriver.c
r58466 r77662 2 2 The entry point of IScsi driver. 3 3 4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR> 6 5 7 This program and the accompanying materials 6 8 are licensed and made available under the terms and conditions of the BSD License … … 75 77 } 76 78 79 /** 80 Check whether an iSCSI HBA adapter already installs an AIP instance with 81 network boot policy matching the value specified in PcdIScsiAIPNetworkBootPolicy. 82 If yes, return EFI_SUCCESS. 83 84 @retval EFI_SUCCESS Found an AIP with matching network boot policy. 85 @retval EFI_NOT_FOUND AIP is unavailable or the network boot policy 86 not matched. 87 **/ 88 EFI_STATUS 89 IScsiCheckAip ( 90 VOID 91 ) 92 { 93 UINTN AipHandleCount; 94 EFI_HANDLE *AipHandleBuffer; 95 UINTN AipIndex; 96 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; 97 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru; 98 EFI_GUID *InfoTypesBuffer; 99 UINTN InfoTypeBufferCount; 100 UINTN TypeIndex; 101 VOID *InfoBlock; 102 UINTN InfoBlockSize; 103 BOOLEAN Supported; 104 EFI_ADAPTER_INFO_NETWORK_BOOT *NetworkBoot; 105 EFI_STATUS Status; 106 UINT8 NetworkBootPolicy; 107 108 // 109 // Check any AIP instances exist in system. 110 // 111 AipHandleCount = 0; 112 AipHandleBuffer = NULL; 113 Status = gBS->LocateHandleBuffer ( 114 ByProtocol, 115 &gEfiAdapterInformationProtocolGuid, 116 NULL, 117 &AipHandleCount, 118 &AipHandleBuffer 119 ); 120 if (EFI_ERROR (Status) || AipHandleCount == 0) { 121 return EFI_NOT_FOUND; 122 } 123 124 ASSERT (AipHandleBuffer != NULL); 125 126 InfoBlock = NULL; 127 128 for (AipIndex = 0; AipIndex < AipHandleCount; AipIndex++) { 129 Status = gBS->HandleProtocol ( 130 AipHandleBuffer[AipIndex], 131 &gEfiAdapterInformationProtocolGuid, 132 (VOID *) &Aip 133 ); 134 ASSERT_EFI_ERROR (Status); 135 ASSERT (Aip != NULL); 136 137 Status = gBS->HandleProtocol ( 138 AipHandleBuffer[AipIndex], 139 &gEfiExtScsiPassThruProtocolGuid, 140 (VOID *) &ExtScsiPassThru 141 ); 142 if (EFI_ERROR (Status) || ExtScsiPassThru == NULL) { 143 continue; 144 } 145 146 InfoTypesBuffer = NULL; 147 InfoTypeBufferCount = 0; 148 Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); 149 if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) { 150 continue; 151 } 152 // 153 // Check whether the AIP instance has Network boot information block. 154 // 155 Supported = FALSE; 156 for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) { 157 if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoNetworkBootGuid)) { 158 Supported = TRUE; 159 break; 160 } 161 } 162 163 FreePool (InfoTypesBuffer); 164 if (!Supported) { 165 continue; 166 } 167 168 // 169 // We now have network boot information block. 170 // 171 InfoBlock = NULL; 172 InfoBlockSize = 0; 173 Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize); 174 if (EFI_ERROR (Status) || InfoBlock == NULL) { 175 continue; 176 } 177 178 // 179 // Check whether the network boot policy matches. 180 // 181 NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *) InfoBlock; 182 NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy); 183 184 if (NetworkBootPolicy == STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP) { 185 Status = EFI_SUCCESS; 186 goto Exit; 187 } 188 if (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0 && 189 !NetworkBoot->iScsiIpv4BootCapablity) || 190 ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0 && 191 !NetworkBoot->iScsiIpv6BootCapablity) || 192 ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0 && 193 !NetworkBoot->OffloadCapability) || 194 ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0 && 195 !NetworkBoot->iScsiMpioCapability) || 196 ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0 && 197 !NetworkBoot->iScsiIpv4Boot) || 198 ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0 && 199 !NetworkBoot->iScsiIpv6Boot)) { 200 FreePool (InfoBlock); 201 continue; 202 } 203 204 Status = EFI_SUCCESS; 205 goto Exit; 206 } 207 208 Status = EFI_NOT_FOUND; 209 210 Exit: 211 if (InfoBlock != NULL) { 212 FreePool (InfoBlock); 213 } 214 if (AipHandleBuffer != NULL) { 215 FreePool (AipHandleBuffer); 216 } 217 return Status; 218 } 77 219 78 220 /** … … 114 256 EFI_GUID *TcpServiceBindingGuid; 115 257 EFI_GUID *DhcpServiceBindingGuid; 258 EFI_GUID *DnsServiceBindingGuid; 116 259 117 260 if (IpVersion == IP_VERSION_4) { … … 119 262 TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid; 120 263 DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid; 264 DnsServiceBindingGuid = &gEfiDns4ServiceBindingProtocolGuid; 265 121 266 } else { 122 267 IScsiServiceBindingGuid = &gIScsiV6PrivateGuid; 123 268 TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid; 124 269 DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid; 270 DnsServiceBindingGuid = &gEfiDns6ServiceBindingProtocolGuid; 125 271 } 126 272 … … 168 314 } 169 315 316 if (IScsiDnsIsConfigured (ControllerHandle)) { 317 Status = gBS->OpenProtocol ( 318 ControllerHandle, 319 DnsServiceBindingGuid, 320 NULL, 321 This->DriverBindingHandle, 322 ControllerHandle, 323 EFI_OPEN_PROTOCOL_TEST_PROTOCOL 324 ); 325 if (EFI_ERROR (Status)) { 326 return EFI_UNSUPPORTED; 327 } 328 } 329 170 330 return EFI_SUCCESS; 171 331 } … … 185 345 @retval EFI_NOT_FOUND There is no sufficient information to establish 186 346 the iScsi session. 347 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 187 348 @retval EFI_DEVICE_ERROR Failed to get TCP connection device path. 349 @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle 350 because its interfaces are being used. 188 351 189 352 **/ … … 212 375 EFI_GUID *IScsiPrivateGuid; 213 376 EFI_GUID *TcpServiceBindingGuid; 214 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];215 377 BOOLEAN NeedUpdate; 216 378 VOID *Interface; 217 379 EFI_GUID *ProtocolGuid; 380 UINT8 NetworkBootPolicy; 381 ISCSI_SESSION_CONFIG_NVDATA *NvData; 218 382 219 383 // … … 257 421 } 258 422 423 NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy); 424 if (NetworkBootPolicy == ALWAYS_USE_ISCSI_HBA_AND_IGNORE_UEFI_ISCSI) { 425 return EFI_ABORTED; 426 } 427 428 if (NetworkBootPolicy != ALWAYS_USE_UEFI_ISCSI_AND_IGNORE_ISCSI_HBA) { 429 // 430 // Check existing iSCSI AIP. 431 // 432 Status = IScsiCheckAip (); 433 if (!EFI_ERROR (Status)) { 434 // 435 // Find iSCSI AIP with specified network boot policy. return EFI_ABORTED. 436 // 437 return EFI_ABORTED; 438 } 439 } 440 259 441 // 260 442 // Record the incoming NIC info. 261 443 // 262 Status = IScsiAddNic (ControllerHandle );444 Status = IScsiAddNic (ControllerHandle, Image); 263 445 if (EFI_ERROR (Status)) { 264 446 return Status; … … 478 660 // 479 661 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG && 480 AttemptConfigData->AutoConfigure Mode == IP_MODE_AUTOCONFIG_SUCCESS) {662 AttemptConfigData->AutoConfigureSuccess) { 481 663 continue; 482 664 } … … 516 698 Session->AuthType = AttemptConfigData->AuthenticationType; 517 699 518 AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString);519 700 UnicodeSPrint ( 520 701 mPrivate->PortString, 521 702 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 522 L"%s%d", 523 MacString, 703 L"Attempt %d", 524 704 (UINTN) AttemptConfigData->AttemptConfigIndex 525 705 ); … … 545 725 } 546 726 727 // 728 // Restore the origial user setting which specifies the proxy/virtual iSCSI target to NV region. 729 // 730 NvData = &AttemptConfigData->SessionConfigData; 731 if (NvData->RedirectFlag) { 732 NvData->TargetPort = NvData->OriginalTargetPort; 733 CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_IP_ADDRESS)); 734 NvData->RedirectFlag = FALSE; 735 736 gRT->SetVariable ( 737 mPrivate->PortString, 738 &gEfiIScsiInitiatorNameProtocolGuid, 739 ISCSI_CONFIG_VAR_ATTR, 740 sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA), 741 AttemptConfigData 742 ); 743 } 744 547 745 if (EFI_ERROR (Status)) { 548 746 // … … 577 775 // 578 776 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) { 579 AttemptConfigData->AutoConfigure Mode = IP_MODE_AUTOCONFIG_SUCCESS;777 AttemptConfigData->AutoConfigureSuccess = TRUE; 580 778 } 581 779 … … 710 908 } 711 909 712 IScsiCleanDriverData (ExistPrivate); 910 if (ExistPrivate->DevicePath != NULL) { 911 Status = gBS->UninstallProtocolInterface ( 912 ExistPrivate->ExtScsiPassThruHandle, 913 &gEfiDevicePathProtocolGuid, 914 ExistPrivate->DevicePath 915 ); 916 if (EFI_ERROR (Status)) { 917 goto ON_ERROR; 918 } 919 920 FreePool (ExistPrivate->DevicePath); 921 } 922 923 gBS->CloseEvent (ExistPrivate->ExitBootServiceEvent); 924 FreePool (ExistPrivate); 925 713 926 } 714 927 } else { … … 810 1023 @retval EFI_SUCCESS The device was stopped. 811 1024 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. 1025 @retval EFI_INVALID_PARAMETER Child handle is NULL. 1026 @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle 1027 because its interfaces are being used. 812 1028 813 1029 **/ … … 952 1168 } 953 1169 954 IScsiCleanDriverData (Private); 1170 Status = IScsiCleanDriverData (Private); 1171 1172 if (EFI_ERROR (Status)) { 1173 return Status; 1174 } 955 1175 956 1176 return EFI_SUCCESS; … … 1583 1803 1584 1804 // 1805 // Create the Maximum Attempts. 1806 // 1807 Status = IScsiCreateAttempts (PcdGet8 (PcdMaxIScsiAttemptNumber)); 1808 if (EFI_ERROR (Status)) { 1809 goto Error5; 1810 } 1811 1812 // 1813 // Create Keywords for all the Attempts. 1814 // 1815 Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber)); 1816 if (EFI_ERROR (Status)) { 1817 goto Error6; 1818 } 1819 1820 // 1585 1821 // There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If already exists, 1586 1822 // do not produce the protocol instance. … … 1599 1835 ); 1600 1836 if (EFI_ERROR (Status)) { 1601 goto Error 5;1837 goto Error6; 1602 1838 } 1603 1839 } 1604 1840 1605 1841 return EFI_SUCCESS; 1842 1843 Error6: 1844 IScsiCleanAttemptVariable (); 1606 1845 1607 1846 Error5: … … 1609 1848 1610 1849 Error4: 1611 FreePool (mPrivate); 1850 if (mPrivate != NULL) { 1851 FreePool (mPrivate); 1852 mPrivate = NULL; 1853 } 1612 1854 1613 1855 Error3: -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDriver.h
r58466 r77662 2 2 The header file of IScsiDriver.c. 3 3 4 Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR> 6 5 7 This program and the accompanying materials 6 8 are licensed and made available under the terms and conditions of the BSD License … … 30 32 #define IP_MODE_AUTOCONFIG_IP4 3 31 33 #define IP_MODE_AUTOCONFIG_IP6 4 32 #define IP_MODE_AUTOCONFIG_SUCCESS 5 34 #define ALWAYS_USE_UEFI_ISCSI_AND_IGNORE_ISCSI_HBA 0x00 35 #define STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP 0x01 36 #define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4 0x02 37 #define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6 0x04 38 #define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD 0x08 39 #define STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO 0x10 40 #define STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4 0x20 41 #define STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6 0x40 42 #define ALWAYS_USE_ISCSI_HBA_AND_IGNORE_UEFI_ISCSI 0xFF 33 43 34 44 extern EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2; … … 59 69 CHAR8 InitiatorName[ISCSI_NAME_MAX_SIZE]; 60 70 UINTN InitiatorNameLength; 61 VOID *NewAttempt; // Attempt is created but not saved.62 71 } ISCSI_PRIVATE_DATA; 63 72 … … 73 82 UINTN DeviceNumber; 74 83 UINTN FunctionNumber; 84 BOOLEAN Ipv6Available; 75 85 } ISCSI_NIC_INFO; 76 86 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDxe.inf
r58466 r77662 5 5 # booting over iSCSI. 6 6 # 7 # Copyright (c) 2004 - 201 4, Intel Corporation. All rights reserved.<BR>7 # Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 8 8 # This program and the accompanying materials 9 9 # are licensed and made available under the terms and conditions of the BSD License … … 51 51 IScsiDhcp6.c 52 52 IScsiDhcp6.h 53 IScsiDns.c 54 IScsiDns.h 53 55 IScsiDriver.c 54 56 IScsiDriver.h … … 90 92 gEfiDriverBindingProtocolGuid ## SOMETIMES_PRODUCES 91 93 gEfiPciIoProtocolGuid ## SOMETIMES_CONSUMES 92 gEfiDhcp4ProtocolGuid ## TO_START 93 gEfiDhcp6ProtocolGuid ## TO_START 94 gEfiDhcp4ServiceBindingProtocolGuid ## TO_START 95 gEfiDhcp6ServiceBindingProtocolGuid ## TO_START 94 gEfiDhcp4ProtocolGuid ## SOMETIMES_CONSUMES 95 gEfiDhcp6ProtocolGuid ## SOMETIMES_CONSUMES 96 gEfiDhcp4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES 97 gEfiDhcp6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES 98 gEfiDns4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES 99 gEfiDns4ProtocolGuid ## SOMETIMES_CONSUMES 100 gEfiDns6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES 101 gEfiDns6ProtocolGuid ## SOMETIMES_CONSUMES 102 gEfiIp4Config2ProtocolGuid ## SOMETIMES_CONSUMES 103 gEfiIp6ConfigProtocolGuid ## SOMETIMES_CONSUMES 96 104 gEfiTcp4ProtocolGuid ## TO_START 97 105 gEfiTcp6ProtocolGuid ## TO_START … … 108 116 ## PRODUCES 109 117 gEfiAuthenticationInfoProtocolGuid 118 ## SOMETIMES_CONSUMES 119 gEfiAdapterInformationProtocolGuid 120 gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## SOMETIMES_CONSUMES 110 121 111 122 [Guids] … … 115 126 gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES ## SystemTable 116 127 gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES ## SystemTable 128 gEfiAdapterInfoNetworkBootGuid ## SOMETIMES_CONSUMES ## UNDEFINED 129 gEfiAdapterInfoUndiIpv6SupportGuid ## SOMETIMES_CONSUMES ## GUID 117 130 118 131 ## SOMETIMES_PRODUCES ## Variable:L"AttemptOrder" 119 132 ## SOMETIMES_CONSUMES ## Variable:L"AttemptOrder" 133 ## SOMETIMES_PRODUCES ## Variable:L"InitialAttemptOrder" 134 ## SOMETIMES_CONSUMES ## Variable:L"InitialAttemptOrder" 120 135 ## SOMETIMES_CONSUMES ## UNDEFINED # HiiIsConfigHdrMatch mVendorStorageName 121 136 ## SOMETIMES_PRODUCES ## UNDEFINED # HiiConstructConfigHdr mVendorStorageName … … 125 140 gIScsiConfigGuid 126 141 142 [Pcd] 143 gEfiNetworkPkgTokenSpaceGuid.PcdIScsiAIPNetworkBootPolicy ## CONSUMES 144 gEfiNetworkPkgTokenSpaceGuid.PcdMaxIScsiAttemptNumber ## CONSUMES 145 127 146 [UserExtensions.TianoCore."ExtraFiles"] 128 147 IScsiDxeExtra.uni -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Client-side iSCSI service. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiDxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // IScsiDxe Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiExtScsiPassThru.c
r58466 r77662 2 2 The implementation of EFI_EXT_SCSI_PASS_THRU_PROTOCOL. 3 3 4 Copyright (c) 2004 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 220 220 UINTN DevPathNodeLen; 221 221 222 if ( (DevicePath == NULL)) {222 if (DevicePath == NULL) { 223 223 return EFI_INVALID_PARAMETER; 224 224 } … … 274 274 CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64)); 275 275 Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag; 276 AsciiStrCpy ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), ConfigNvData->TargetName);276 AsciiStrCpyS ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), AsciiStrLen (ConfigNvData->TargetName) + 1, ConfigNvData->TargetName); 277 277 278 278 *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiIbft.c
r58466 r77662 457 457 EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; 458 458 EFI_ACPI_DESCRIPTION_HEADER *Rsdt; 459 EFI_ACPI_DESCRIPTION_HEADER *Xsdt; 459 460 UINT8 *Heap; 460 461 UINT8 Checksum; 461 UINTN Index; 462 462 463 Rsdt = NULL; 464 Xsdt = NULL; 463 465 464 466 Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); … … 470 472 // Find ACPI table RSD_PTR from the system table. 471 473 // 472 for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) { 473 if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi20TableGuid) || 474 CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi10TableGuid) || 475 CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpiTableGuid) 476 ) { 477 // 478 // A match was found. 479 // 480 Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) gST->ConfigurationTable[Index].VendorTable; 481 break; 482 } 483 } 484 485 if (Rsdp == NULL) { 474 Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp); 475 if (EFI_ERROR (Status)) { 476 Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp); 477 } 478 479 if (EFI_ERROR (Status) || (Rsdp == NULL)) { 486 480 return ; 487 } else { 481 } else if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) { 482 Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; 483 } else if (Rsdp->RsdtAddress != 0) { 488 484 Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; 485 } 486 487 if ((Xsdt == NULL) && (Rsdt == NULL)) { 488 return ; 489 489 } 490 490 … … 521 521 // Fill in the various section of the iSCSI Boot Firmware Table. 522 522 // 523 IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId); 523 if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 524 IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId); 525 } else { 526 IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId); 527 } 528 524 529 IScsiInitControlSection (Table); 525 530 IScsiFillInitiatorSection (Table, &Heap); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiImpl.h
r58466 r77662 2 2 The shared head file for iSCSI driver. 3 3 4 Copyright (c) 2004 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 17 17 18 18 #include <Uefi.h> 19 20 #include <IndustryStandard/Dhcp.h> 19 21 20 22 #include <Protocol/ComponentName.h> … … 27 29 #include <Protocol/Dhcp4.h> 28 30 #include <Protocol/Dhcp6.h> 31 #include <Protocol/Dns4.h> 32 #include <Protocol/Dns6.h> 29 33 #include <Protocol/Tcp4.h> 30 34 #include <Protocol/Tcp6.h> 35 #include <Protocol/Ip4Config2.h> 36 #include <Protocol/Ip6Config.h> 31 37 32 38 #include <Protocol/AuthenticationInfo.h> 33 39 #include <Protocol/IScsiInitiatorName.h> 34 40 #include <Protocol/ScsiPassThruExt.h> 41 #include <Protocol/AdapterInformation.h> 42 #include <Protocol/NetworkInterfaceIdentifier.h> 35 43 36 44 #include <Library/HiiLib.h> … … 60 68 #include "IScsiDhcp.h" 61 69 #include "IScsiDhcp6.h" 70 62 71 #include "IScsiIbft.h" 63 72 #include "IScsiMisc.h" 73 #include "IScsiDns.h" 64 74 #include "IScsiConfig.h" 65 75 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiMisc.c
r58466 r77662 2 2 Miscellaneous routines for iSCSI driver. 3 3 4 Copyright (c) 2004 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 467 467 468 468 /** 469 Check whether UNDI protocol supports IPv6. 470 471 @param[in] ControllerHandle Controller handle. 472 @param[in] Image Handle of the image. 473 @param[out] Ipv6Support TRUE if UNDI supports IPv6. 474 475 @retval EFI_SUCCESS Get the result whether UNDI supports IPv6 by NII or AIP protocol successfully. 476 @retval EFI_NOT_FOUND Don't know whether UNDI supports IPv6 since NII or AIP is not available. 477 478 **/ 479 EFI_STATUS 480 IScsiCheckIpv6Support ( 481 IN EFI_HANDLE ControllerHandle, 482 IN EFI_HANDLE Image, 483 OUT BOOLEAN *Ipv6Support 484 ) 485 { 486 EFI_HANDLE Handle; 487 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; 488 EFI_STATUS Status; 489 EFI_GUID *InfoTypesBuffer; 490 UINTN InfoTypeBufferCount; 491 UINTN TypeIndex; 492 BOOLEAN Supported; 493 VOID *InfoBlock; 494 UINTN InfoBlockSize; 495 496 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii; 497 498 ASSERT (Ipv6Support != NULL); 499 500 // 501 // Check whether the UNDI supports IPv6 by NII protocol. 502 // 503 Status = gBS->OpenProtocol ( 504 ControllerHandle, 505 &gEfiNetworkInterfaceIdentifierProtocolGuid_31, 506 (VOID **) &Nii, 507 Image, 508 ControllerHandle, 509 EFI_OPEN_PROTOCOL_GET_PROTOCOL 510 ); 511 if (Status == EFI_SUCCESS) { 512 *Ipv6Support = Nii->Ipv6Supported; 513 return EFI_SUCCESS; 514 } 515 516 // 517 // Get the NIC handle by SNP protocol. 518 // 519 Handle = NetLibGetSnpHandle (ControllerHandle, NULL); 520 if (Handle == NULL) { 521 return EFI_NOT_FOUND; 522 } 523 524 Aip = NULL; 525 Status = gBS->HandleProtocol ( 526 Handle, 527 &gEfiAdapterInformationProtocolGuid, 528 (VOID *) &Aip 529 ); 530 if (EFI_ERROR (Status) || Aip == NULL) { 531 return EFI_NOT_FOUND; 532 } 533 534 InfoTypesBuffer = NULL; 535 InfoTypeBufferCount = 0; 536 Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); 537 if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) { 538 FreePool (InfoTypesBuffer); 539 return EFI_NOT_FOUND; 540 } 541 542 Supported = FALSE; 543 for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) { 544 if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoUndiIpv6SupportGuid)) { 545 Supported = TRUE; 546 break; 547 } 548 } 549 550 FreePool (InfoTypesBuffer); 551 if (!Supported) { 552 return EFI_NOT_FOUND; 553 } 554 555 // 556 // We now have adapter information block. 557 // 558 InfoBlock = NULL; 559 InfoBlockSize = 0; 560 Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize); 561 if (EFI_ERROR (Status) || InfoBlock == NULL) { 562 FreePool (InfoBlock); 563 return EFI_NOT_FOUND; 564 } 565 566 *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support; 567 FreePool (InfoBlock); 568 569 return EFI_SUCCESS; 570 } 571 572 /** 469 573 Record the NIC info in global structure. 470 574 471 575 @param[in] Controller The handle of the controller. 576 @param[in] Image Handle of the image. 472 577 473 578 @retval EFI_SUCCESS The operation is completed. … … 478 583 EFI_STATUS 479 584 IScsiAddNic ( 480 IN EFI_HANDLE Controller 585 IN EFI_HANDLE Controller, 586 IN EFI_HANDLE Image 481 587 ) 482 588 { … … 510 616 NicInfo->VlanId == VlanId) { 511 617 mPrivate->CurrentNic = NicInfo->NicIndex; 618 619 // 620 // Set IPv6 available flag. 621 // 622 Status = IScsiCheckIpv6Support (Controller, Image, &NicInfo->Ipv6Available); 623 if (EFI_ERROR (Status)) { 624 // 625 // Fail to get the data whether UNDI supports IPv6. 626 // Set default value to TRUE. 627 // 628 NicInfo->Ipv6Available = TRUE; 629 } 630 512 631 return EFI_SUCCESS; 513 632 } … … 531 650 NicInfo->NicIndex = (UINT8) (mPrivate->MaxNic + 1); 532 651 mPrivate->MaxNic = NicInfo->NicIndex; 652 653 // 654 // Set IPv6 available flag. 655 // 656 Status = IScsiCheckIpv6Support (Controller, Image, &NicInfo->Ipv6Available); 657 if (EFI_ERROR (Status)) { 658 // 659 // Fail to get the data whether UNDI supports IPv6. 660 // Set default value to TRUE. 661 // 662 NicInfo->Ipv6Available = TRUE; 663 } 533 664 534 665 // … … 644 775 } 645 776 646 //647 // Free attempt is created but not saved to system.648 //649 if (mPrivate->NewAttempt != NULL) {650 FreePool (mPrivate->NewAttempt);651 mPrivate->NewAttempt = NULL;652 }653 654 777 return EFI_SUCCESS; 655 778 } 656 779 780 /** 781 Create and initialize the Attempts. 782 783 @param[in] AttemptNum The number of Attempts will be created. 784 785 @retval EFI_SUCCESS The Attempts have been created successfully. 786 @retval Others Failed to create the Attempt. 787 788 **/ 789 EFI_STATUS 790 IScsiCreateAttempts ( 791 IN UINTN AttemptNum 792 ) 793 { 794 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 795 ISCSI_SESSION_CONFIG_NVDATA *ConfigData; 796 UINT8 *AttemptConfigOrder; 797 UINTN AttemptConfigOrderSize; 798 UINT8 *AttemptOrderTmp; 799 UINTN TotalNumber; 800 UINT8 Index; 801 EFI_STATUS Status; 802 803 for (Index = 1; Index <= AttemptNum; Index ++) { 804 // 805 // Get the initialized attempt order. This is used to essure creating attempts by order. 806 // 807 AttemptConfigOrder = IScsiGetVariableAndSize ( 808 L"InitialAttemptOrder", 809 &gIScsiConfigGuid, 810 &AttemptConfigOrderSize 811 ); 812 TotalNumber = AttemptConfigOrderSize / sizeof (UINT8); 813 if (TotalNumber == AttemptNum) { 814 Status = EFI_SUCCESS; 815 break; 816 } 817 TotalNumber++; 818 819 // 820 // Append the new created attempt to the end. 821 // 822 AttemptOrderTmp = AllocateZeroPool (TotalNumber * sizeof (UINT8)); 823 if (AttemptOrderTmp == NULL) { 824 if (AttemptConfigOrder != NULL) { 825 FreePool (AttemptConfigOrder); 826 } 827 return EFI_OUT_OF_RESOURCES; 828 } 829 830 if (AttemptConfigOrder != NULL) { 831 CopyMem (AttemptOrderTmp, AttemptConfigOrder, AttemptConfigOrderSize); 832 FreePool (AttemptConfigOrder); 833 } 834 835 AttemptOrderTmp[TotalNumber - 1] = Index; 836 AttemptConfigOrder = AttemptOrderTmp; 837 AttemptConfigOrderSize = TotalNumber * sizeof (UINT8); 838 839 Status = gRT->SetVariable ( 840 L"InitialAttemptOrder", 841 &gIScsiConfigGuid, 842 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, 843 AttemptConfigOrderSize, 844 AttemptConfigOrder 845 ); 846 FreePool (AttemptConfigOrder); 847 if (EFI_ERROR (Status)) { 848 return Status; 849 } 850 851 // 852 // Create new Attempt 853 // 854 AttemptConfigData = AllocateZeroPool (sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA)); 855 if (AttemptConfigData == NULL) { 856 return EFI_OUT_OF_RESOURCES; 857 } 858 ConfigData = &AttemptConfigData->SessionConfigData; 859 ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT; 860 ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT; 861 ConfigData->ConnectRetryCount = CONNECT_MIN_RETRY; 862 863 AttemptConfigData->AuthenticationType = ISCSI_AUTH_TYPE_CHAP; 864 AttemptConfigData->AuthConfigData.CHAP.CHAPType = ISCSI_CHAP_UNI; 865 // 866 // Configure the Attempt index and set variable. 867 // 868 AttemptConfigData->AttemptConfigIndex = Index; 869 870 // 871 // Set the attempt name according to the order. 872 // 873 UnicodeSPrint ( 874 mPrivate->PortString, 875 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 876 L"Attempt %d", 877 (UINTN) AttemptConfigData->AttemptConfigIndex 878 ); 879 UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE); 880 881 Status = gRT->SetVariable ( 882 mPrivate->PortString, 883 &gEfiIScsiInitiatorNameProtocolGuid, 884 ISCSI_CONFIG_VAR_ATTR, 885 sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA), 886 AttemptConfigData 887 ); 888 FreePool (AttemptConfigData); 889 if (EFI_ERROR (Status)) { 890 return Status; 891 } 892 } 893 894 return EFI_SUCCESS; 895 } 896 897 /** 898 Create the iSCSI configuration Keywords for each attempt. You can find the keywords 899 defined in the "x-UEFI-ns" namespace (http://www.uefi.org/confignamespace). 900 901 @param[in] KeywordNum The number Sets of Keywords will be created. 902 903 @retval EFI_SUCCESS The operation is completed. 904 @retval Others Failed to create the Keywords. 905 906 **/ 907 EFI_STATUS 908 IScsiCreateKeywords ( 909 IN UINTN KeywordNum 910 ) 911 { 912 VOID *StartOpCodeHandle; 913 EFI_IFR_GUID_LABEL *StartLabel; 914 VOID *EndOpCodeHandle; 915 EFI_IFR_GUID_LABEL *EndLabel; 916 UINTN Index; 917 EFI_STRING_ID StringToken; 918 CHAR16 StringId[64]; 919 CHAR16 KeywordId[32]; 920 EFI_STATUS Status; 921 922 Status = IScsiCreateOpCode ( 923 KEYWORD_ENTRY_LABEL, 924 &StartOpCodeHandle, 925 &StartLabel, 926 &EndOpCodeHandle, 927 &EndLabel 928 ); 929 if (EFI_ERROR (Status)) { 930 return EFI_OUT_OF_RESOURCES; 931 } 932 933 for (Index = 1; Index <= KeywordNum; Index ++) { 934 // 935 // Create iSCSIAttemptName Keyword. 936 // 937 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_ATTEMPTT_NAME_PROMPT%d", Index); 938 StringToken = HiiSetString ( 939 mCallbackInfo->RegisteredHandle, 940 0, 941 StringId, 942 NULL 943 ); 944 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIAttemptName:%d", Index); 945 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 946 HiiCreateStringOpCode ( 947 StartOpCodeHandle, 948 (EFI_QUESTION_ID) (ATTEMPT_ATTEMPT_NAME_QUESTION_ID + (Index - 1)), 949 CONFIGURATION_VARSTORE_ID, 950 (UINT16) (ATTEMPT_ATTEMPT_NAME_VAR_OFFSET + ATTEMPT_NAME_SIZE * (Index - 1) * sizeof (CHAR16)), 951 StringToken, 952 StringToken, 953 EFI_IFR_FLAG_READ_ONLY, 954 0, 955 0, 956 ATTEMPT_NAME_SIZE, 957 NULL 958 ); 959 960 // 961 // Create iSCSIBootEnable Keyword. 962 // 963 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_MODE_PROMPT%d", Index); 964 StringToken = HiiSetString ( 965 mCallbackInfo->RegisteredHandle, 966 0, 967 StringId, 968 NULL 969 ); 970 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIBootEnable:%d", Index); 971 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 972 HiiCreateNumericOpCode ( 973 StartOpCodeHandle, 974 (EFI_QUESTION_ID) (ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)), 975 CONFIGURATION_VARSTORE_ID, 976 (UINT16) (ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)), 977 StringToken, 978 StringToken, 979 0, 980 EFI_IFR_NUMERIC_SIZE_1, 981 0, 982 2, 983 0, 984 NULL 985 ); 986 987 // 988 // Create iSCSIIpAddressType Keyword. 989 // 990 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_IP_MODE_PROMPT%d", Index); 991 StringToken = HiiSetString ( 992 mCallbackInfo->RegisteredHandle, 993 0, 994 StringId, 995 NULL 996 ); 997 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIIpAddressType:%d", Index); 998 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 999 HiiCreateNumericOpCode ( 1000 StartOpCodeHandle, 1001 (EFI_QUESTION_ID) (ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)), 1002 CONFIGURATION_VARSTORE_ID, 1003 (UINT16) (ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)), 1004 StringToken, 1005 StringToken, 1006 0, 1007 EFI_IFR_NUMERIC_SIZE_1, 1008 0, 1009 2, 1010 0, 1011 NULL 1012 ); 1013 1014 // 1015 // Create iSCSIConnectRetry Keyword. 1016 // 1017 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CONNECT_RETRY_PROMPT%d", Index); 1018 StringToken = HiiSetString ( 1019 mCallbackInfo->RegisteredHandle, 1020 0, 1021 StringId, 1022 NULL 1023 ); 1024 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIConnectRetry:%d", Index); 1025 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1026 HiiCreateNumericOpCode ( 1027 StartOpCodeHandle, 1028 (EFI_QUESTION_ID) (ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)), 1029 CONFIGURATION_VARSTORE_ID, 1030 (UINT16) (ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)), 1031 StringToken, 1032 StringToken, 1033 0, 1034 EFI_IFR_NUMERIC_SIZE_1, 1035 0, 1036 16, 1037 0, 1038 NULL 1039 ); 1040 1041 // 1042 // Create iSCSIConnectTimeout Keyword. 1043 // 1044 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CONNECT_TIMEOUT_PROMPT%d", Index); 1045 StringToken = HiiSetString ( 1046 mCallbackInfo->RegisteredHandle, 1047 0, 1048 StringId, 1049 NULL 1050 ); 1051 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIConnectTimeout:%d", Index); 1052 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1053 HiiCreateNumericOpCode ( 1054 StartOpCodeHandle, 1055 (EFI_QUESTION_ID) (ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)), 1056 CONFIGURATION_VARSTORE_ID, 1057 (UINT16) (ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)), 1058 StringToken, 1059 StringToken, 1060 0, 1061 EFI_IFR_NUMERIC_SIZE_2, 1062 CONNECT_MIN_TIMEOUT, 1063 CONNECT_MAX_TIMEOUT, 1064 0, 1065 NULL 1066 ); 1067 1068 // 1069 // Create ISID Keyword. 1070 // 1071 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_ISID_PROMPT%d", Index); 1072 StringToken = HiiSetString ( 1073 mCallbackInfo->RegisteredHandle, 1074 0, 1075 StringId, 1076 NULL 1077 ); 1078 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIISID:%d", Index); 1079 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1080 HiiCreateStringOpCode ( 1081 StartOpCodeHandle, 1082 (EFI_QUESTION_ID) (ATTEMPT_ISID_QUESTION_ID + (Index - 1)), 1083 CONFIGURATION_VARSTORE_ID, 1084 (UINT16) (ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1085 StringToken, 1086 STRING_TOKEN (STR_ISCSI_ISID_HELP), 1087 0, 1088 0, 1089 ISID_CONFIGURABLE_MIN_LEN, 1090 ISID_CONFIGURABLE_STORAGE, 1091 NULL 1092 ); 1093 1094 // 1095 // Create iSCSIInitiatorInfoViaDHCP Keyword. 1096 // 1097 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_VIA_DHCP_PROMPT%d", Index); 1098 StringToken = HiiSetString ( 1099 mCallbackInfo->RegisteredHandle, 1100 0, 1101 StringId, 1102 NULL 1103 ); 1104 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorInfoViaDHCP:%d", Index); 1105 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1106 HiiCreateNumericOpCode ( 1107 StartOpCodeHandle, 1108 (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID + (Index - 1)), 1109 CONFIGURATION_VARSTORE_ID, 1110 (UINT16) (ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET + (Index - 1)), 1111 StringToken, 1112 StringToken, 1113 0, 1114 0, 1115 0, 1116 1, 1117 0, 1118 NULL 1119 ); 1120 1121 // 1122 // Create iSCSIInitiatorIpAddress Keyword. 1123 // 1124 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_IP_ADDRESS_PROMPT%d", Index); 1125 StringToken = HiiSetString ( 1126 mCallbackInfo->RegisteredHandle, 1127 0, 1128 StringId, 1129 NULL 1130 ); 1131 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorIpAddress:%d", Index); 1132 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1133 HiiCreateStringOpCode ( 1134 StartOpCodeHandle, 1135 (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID + (Index - 1)), 1136 CONFIGURATION_VARSTORE_ID, 1137 (UINT16) (ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1138 StringToken, 1139 StringToken, 1140 0, 1141 0, 1142 IP4_MIN_SIZE, 1143 IP4_STR_MAX_SIZE, 1144 NULL 1145 ); 1146 1147 // 1148 // Create iSCSIInitiatorNetmask Keyword. 1149 // 1150 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_NET_MASK_PROMPT%d", Index); 1151 StringToken = HiiSetString ( 1152 mCallbackInfo->RegisteredHandle, 1153 0, 1154 StringId, 1155 NULL 1156 ); 1157 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorNetmask:%d", Index); 1158 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1159 HiiCreateStringOpCode ( 1160 StartOpCodeHandle, 1161 (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID + (Index - 1)), 1162 CONFIGURATION_VARSTORE_ID, 1163 (UINT16) (ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1164 StringToken, 1165 StringToken, 1166 0, 1167 0, 1168 IP4_MIN_SIZE, 1169 IP4_STR_MAX_SIZE, 1170 NULL 1171 ); 1172 1173 // 1174 // Create iSCSIInitiatorGateway Keyword. 1175 // 1176 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_INITIATOR_GATE_PROMPT%d", Index); 1177 StringToken = HiiSetString ( 1178 mCallbackInfo->RegisteredHandle, 1179 0, 1180 StringId, 1181 NULL 1182 ); 1183 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorGateway:%d", Index); 1184 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1185 HiiCreateStringOpCode ( 1186 StartOpCodeHandle, 1187 (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID + (Index - 1)), 1188 CONFIGURATION_VARSTORE_ID, 1189 (UINT16) (ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1190 StringToken, 1191 StringToken, 1192 0, 1193 0, 1194 IP4_MIN_SIZE, 1195 IP4_STR_MAX_SIZE, 1196 NULL 1197 ); 1198 1199 // 1200 // Create iSCSITargetInfoViaDHCP Keyword. 1201 // 1202 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_VIA_DHCP_PROMPT%d", Index); 1203 StringToken = HiiSetString ( 1204 mCallbackInfo->RegisteredHandle, 1205 0, 1206 StringId, 1207 NULL 1208 ); 1209 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetInfoViaDHCP:%d", Index); 1210 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1211 HiiCreateNumericOpCode ( 1212 StartOpCodeHandle, 1213 (EFI_QUESTION_ID) (ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID + (Index - 1)), 1214 CONFIGURATION_VARSTORE_ID, 1215 (UINT16) (ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET + (Index - 1)), 1216 StringToken, 1217 StringToken, 1218 0, 1219 0, 1220 0, 1221 1, 1222 0, 1223 NULL 1224 ); 1225 1226 // 1227 // Create iSCSITargetTcpPort Keyword. 1228 // 1229 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_TCP_PORT_PROMPT%d", Index); 1230 StringToken = HiiSetString ( 1231 mCallbackInfo->RegisteredHandle, 1232 0, 1233 StringId, 1234 NULL 1235 ); 1236 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetTcpPort:%d", Index); 1237 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1238 HiiCreateNumericOpCode ( 1239 StartOpCodeHandle, 1240 (EFI_QUESTION_ID) (ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)), 1241 CONFIGURATION_VARSTORE_ID, 1242 (UINT16) (ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)), 1243 StringToken, 1244 StringToken, 1245 0, 1246 EFI_IFR_NUMERIC_SIZE_2, 1247 TARGET_PORT_MIN_NUM, 1248 TARGET_PORT_MAX_NUM, 1249 0, 1250 NULL 1251 ); 1252 1253 // 1254 // Create iSCSITargetName Keyword. 1255 // 1256 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_NAME_PROMPT%d", Index); 1257 StringToken = HiiSetString ( 1258 mCallbackInfo->RegisteredHandle, 1259 0, 1260 StringId, 1261 NULL 1262 ); 1263 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetName:%d", Index); 1264 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1265 HiiCreateStringOpCode ( 1266 StartOpCodeHandle, 1267 (EFI_QUESTION_ID) (ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)), 1268 CONFIGURATION_VARSTORE_ID, 1269 (UINT16) (ATTEMPT_TARGET_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1270 StringToken, 1271 StringToken, 1272 0, 1273 0, 1274 ISCSI_NAME_IFR_MIN_SIZE, 1275 ISCSI_NAME_IFR_MAX_SIZE, 1276 NULL 1277 ); 1278 1279 // 1280 // Create iSCSITargetIpAddress Keyword. 1281 // 1282 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_TARGET_IP_ADDRESS_PROMPT%d", Index); 1283 StringToken = HiiSetString ( 1284 mCallbackInfo->RegisteredHandle, 1285 0, 1286 StringId, 1287 NULL 1288 ); 1289 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetIpAddress:%d", Index); 1290 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1291 HiiCreateStringOpCode ( 1292 StartOpCodeHandle, 1293 (EFI_QUESTION_ID) (ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID + (Index - 1)), 1294 CONFIGURATION_VARSTORE_ID, 1295 (UINT16) (ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1296 StringToken, 1297 StringToken, 1298 0, 1299 0, 1300 IP_MIN_SIZE, 1301 IP_STR_MAX_SIZE, 1302 NULL 1303 ); 1304 1305 // 1306 // Create iSCSILUN Keyword. 1307 // 1308 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_LUN_PROMPT%d", Index); 1309 StringToken = HiiSetString ( 1310 mCallbackInfo->RegisteredHandle, 1311 0, 1312 StringId, 1313 NULL 1314 ); 1315 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSILUN:%d", Index); 1316 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1317 HiiCreateStringOpCode ( 1318 StartOpCodeHandle, 1319 (EFI_QUESTION_ID) (ATTEMPT_LUN_QUESTION_ID + (Index - 1)), 1320 CONFIGURATION_VARSTORE_ID, 1321 (UINT16) (ATTEMPT_LUN_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1322 StringToken, 1323 StringToken, 1324 0, 1325 0, 1326 LUN_MIN_SIZE, 1327 LUN_MAX_SIZE, 1328 NULL 1329 ); 1330 1331 // 1332 // Create iSCSIAuthenticationMethod Keyword. 1333 // 1334 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_AUTHENTICATION_METHOD_PROMPT%d", Index); 1335 StringToken = HiiSetString ( 1336 mCallbackInfo->RegisteredHandle, 1337 0, 1338 StringId, 1339 NULL 1340 ); 1341 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIAuthenticationMethod:%d", Index); 1342 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1343 HiiCreateNumericOpCode ( 1344 StartOpCodeHandle, 1345 (EFI_QUESTION_ID) (ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID + (Index - 1)), 1346 CONFIGURATION_VARSTORE_ID, 1347 (UINT16) (ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET + (Index - 1)), 1348 StringToken, 1349 StringToken, 1350 0, 1351 0, 1352 0, 1353 1, 1354 0, 1355 NULL 1356 ); 1357 1358 // 1359 // Create iSCSIChapType Keyword. 1360 // 1361 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHARTYPE_PROMPT%d", Index); 1362 StringToken = HiiSetString ( 1363 mCallbackInfo->RegisteredHandle, 1364 0, 1365 StringId, 1366 NULL 1367 ); 1368 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapType:%d", Index); 1369 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1370 HiiCreateNumericOpCode ( 1371 StartOpCodeHandle, 1372 (EFI_QUESTION_ID) (ATTEMPT_CHARTYPE_QUESTION_ID + (Index - 1)), 1373 CONFIGURATION_VARSTORE_ID, 1374 (UINT16) (ATTEMPT_CHARTYPE_VAR_OFFSET + (Index - 1)), 1375 StringToken, 1376 StringToken, 1377 0, 1378 0, 1379 0, 1380 1, 1381 0, 1382 NULL 1383 ); 1384 1385 // 1386 // Create iSCSIChapUsername Keyword. 1387 // 1388 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_USER_NAME_PROMPT%d", Index); 1389 StringToken = HiiSetString ( 1390 mCallbackInfo->RegisteredHandle, 1391 0, 1392 StringId, 1393 NULL 1394 ); 1395 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapUsername:%d", Index); 1396 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1397 HiiCreateStringOpCode ( 1398 StartOpCodeHandle, 1399 (EFI_QUESTION_ID) (ATTEMPT_CHAR_USER_NAME_QUESTION_ID + (Index - 1)), 1400 CONFIGURATION_VARSTORE_ID, 1401 (UINT16) (ATTEMPT_CHAR_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1402 StringToken, 1403 StringToken, 1404 0, 1405 0, 1406 0, 1407 ISCSI_CHAP_NAME_MAX_LEN, 1408 NULL 1409 ); 1410 1411 // 1412 // Create iSCSIChapSecret Keyword. 1413 // 1414 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_SECRET_PROMPT%d", Index); 1415 StringToken = HiiSetString ( 1416 mCallbackInfo->RegisteredHandle, 1417 0, 1418 StringId, 1419 NULL 1420 ); 1421 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapSecret:%d", Index); 1422 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1423 HiiCreateStringOpCode ( 1424 StartOpCodeHandle, 1425 (EFI_QUESTION_ID) (ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)), 1426 CONFIGURATION_VARSTORE_ID, 1427 (UINT16) (ATTEMPT_CHAR_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1428 StringToken, 1429 StringToken, 1430 0, 1431 0, 1432 ISCSI_CHAP_SECRET_MIN_LEN, 1433 ISCSI_CHAP_SECRET_MAX_LEN, 1434 NULL 1435 ); 1436 1437 // 1438 // Create iSCSIReverseChapUsername Keyword. 1439 // 1440 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_REVERSE_USER_NAME_PROMPT%d", Index); 1441 StringToken = HiiSetString ( 1442 mCallbackInfo->RegisteredHandle, 1443 0, 1444 StringId, 1445 NULL 1446 ); 1447 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIReverseChapUsername:%d", Index); 1448 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1449 HiiCreateStringOpCode ( 1450 StartOpCodeHandle, 1451 (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID + (Index - 1)), 1452 CONFIGURATION_VARSTORE_ID, 1453 (UINT16) (ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1454 StringToken, 1455 StringToken, 1456 0, 1457 0, 1458 0, 1459 ISCSI_CHAP_NAME_MAX_LEN, 1460 NULL 1461 ); 1462 1463 // 1464 // Create iSCSIReverseChapSecret Keyword. 1465 // 1466 UnicodeSPrint (StringId, sizeof (StringId), L"STR_ISCSI_CHAR_REVERSE_SECRET_PROMPT%d", Index); 1467 StringToken = HiiSetString ( 1468 mCallbackInfo->RegisteredHandle, 1469 0, 1470 StringId, 1471 NULL 1472 ); 1473 UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIReverseChapSecret:%d", Index); 1474 HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); 1475 HiiCreateStringOpCode ( 1476 StartOpCodeHandle, 1477 (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID + (Index - 1)), 1478 CONFIGURATION_VARSTORE_ID, 1479 (UINT16) (ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), 1480 StringToken, 1481 StringToken, 1482 0, 1483 0, 1484 ISCSI_CHAP_SECRET_MIN_LEN, 1485 ISCSI_CHAP_SECRET_MAX_LEN, 1486 NULL 1487 ); 1488 } 1489 1490 Status = HiiUpdateForm ( 1491 mCallbackInfo->RegisteredHandle, // HII handle 1492 &gIScsiConfigGuid, // Formset GUID 1493 FORMID_ATTEMPT_FORM, // Form ID 1494 StartOpCodeHandle, // Label for where to insert opcodes 1495 EndOpCodeHandle // Replace data 1496 ); 1497 1498 HiiFreeOpCodeHandle (StartOpCodeHandle); 1499 HiiFreeOpCodeHandle (EndOpCodeHandle); 1500 1501 return Status; 1502 } 1503 1504 /** 1505 1506 Free the attempt configure data variable. 1507 1508 **/ 1509 VOID 1510 IScsiCleanAttemptVariable ( 1511 IN VOID 1512 ) 1513 { 1514 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; 1515 UINT8 *AttemptConfigOrder; 1516 UINTN AttemptConfigOrderSize; 1517 UINTN Index; 1518 1519 // 1520 // Get the initialized attempt order. 1521 // 1522 AttemptConfigOrder = IScsiGetVariableAndSize ( 1523 L"InitialAttemptOrder", 1524 &gIScsiConfigGuid, 1525 &AttemptConfigOrderSize 1526 ); 1527 if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) { 1528 return; 1529 } 1530 1531 for (Index = 1; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { 1532 UnicodeSPrint ( 1533 mPrivate->PortString, 1534 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 1535 L"Attempt %d", 1536 Index 1537 ); 1538 1539 GetVariable2 ( 1540 mPrivate->PortString, 1541 &gEfiIScsiInitiatorNameProtocolGuid, 1542 (VOID**)&AttemptConfigData, 1543 NULL 1544 ); 1545 1546 if (AttemptConfigData != NULL) { 1547 gRT->SetVariable ( 1548 mPrivate->PortString, 1549 &gEfiIScsiInitiatorNameProtocolGuid, 1550 0, 1551 0, 1552 NULL 1553 ); 1554 } 1555 } 1556 return; 1557 } 657 1558 658 1559 /** … … 684 1585 685 1586 /** 686 Get the NIC's PCI location and return it acc roding to the composited1587 Get the NIC's PCI location and return it according to the composited 687 1588 format defined in iSCSI Boot Firmware Table. 688 1589 … … 858 1759 Clean the iSCSI driver data. 859 1760 860 @param[in] Private The iSCSI driver data. 861 862 **/ 863 VOID 1761 @param[in] Private The iSCSI driver data. 1762 1763 @retval EFI_SUCCESS The clean operation is successful. 1764 @retval Others Other errors as indicated. 1765 1766 **/ 1767 EFI_STATUS 864 1768 IScsiCleanDriverData ( 865 1769 IN ISCSI_DRIVER_DATA *Private … … 868 1772 EFI_STATUS Status; 869 1773 1774 Status = EFI_SUCCESS; 1775 870 1776 if (Private->DevicePath != NULL) { 871 gBS->UninstallProtocolInterface ( 872 Private->ExtScsiPassThruHandle, 873 &gEfiDevicePathProtocolGuid, 874 Private->DevicePath 875 ); 1777 Status = gBS->UninstallProtocolInterface ( 1778 Private->ExtScsiPassThruHandle, 1779 &gEfiDevicePathProtocolGuid, 1780 Private->DevicePath 1781 ); 1782 if (EFI_ERROR (Status)) { 1783 goto EXIT; 1784 } 876 1785 877 1786 FreePool (Private->DevicePath); … … 889 1798 } 890 1799 891 gBS->CloseEvent (Private->ExitBootServiceEvent); 1800 EXIT: 1801 if (Private->ExitBootServiceEvent != NULL) { 1802 gBS->CloseEvent (Private->ExitBootServiceEvent); 1803 } 1804 1805 mCallbackInfo->Current = NULL; 892 1806 893 1807 FreePool (Private); 1808 return Status; 894 1809 } 895 1810 … … 919 1834 UINT16 VlanId; 920 1835 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; 1836 CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; 921 1837 CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; 922 1838 … … 947 1863 AttemptName, 948 1864 (UINTN) 128, 949 L"%s%d", 950 MacString, 1865 L"Attempt %d", 951 1866 (UINTN) AttemptConfigOrder[Index] 952 1867 ); … … 974 1889 } 975 1890 1891 AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0])); 1892 1893 if (AttemptTmp->Actived == ISCSI_ACTIVE_DISABLED || StrCmp (MacString, AttemptMacString)) { 1894 continue; 1895 } 1896 976 1897 if(AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG || 977 1898 AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE || … … 990 1911 991 1912 /** 1913 Check whether the Controller handle is configured to use DNS protocol. 1914 1915 @param[in] Controller The handle of the controller. 1916 1917 @retval TRUE The handle of the controller need the Dns protocol. 1918 @retval FALSE The handle of the controller does not need the Dns protocol. 1919 1920 **/ 1921 BOOLEAN 1922 IScsiDnsIsConfigured ( 1923 IN EFI_HANDLE Controller 1924 ) 1925 { 1926 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp; 1927 UINT8 *AttemptConfigOrder; 1928 UINTN AttemptConfigOrderSize; 1929 UINTN Index; 1930 EFI_STATUS Status; 1931 EFI_MAC_ADDRESS MacAddr; 1932 UINTN HwAddressSize; 1933 UINT16 VlanId; 1934 CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; 1935 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; 1936 CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; 1937 1938 AttemptConfigOrder = IScsiGetVariableAndSize ( 1939 L"AttemptOrder", 1940 &gIScsiConfigGuid, 1941 &AttemptConfigOrderSize 1942 ); 1943 if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) { 1944 return FALSE; 1945 } 1946 1947 // 1948 // Get MAC address of this network device. 1949 // 1950 Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize); 1951 if(EFI_ERROR (Status)) { 1952 return FALSE; 1953 } 1954 // 1955 // Get VLAN ID of this network device. 1956 // 1957 VlanId = NetLibGetVlanId (Controller); 1958 IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString); 1959 1960 for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { 1961 UnicodeSPrint ( 1962 AttemptName, 1963 (UINTN) 128, 1964 L"Attempt %d", 1965 (UINTN) AttemptConfigOrder[Index] 1966 ); 1967 1968 Status = GetVariable2 ( 1969 AttemptName, 1970 &gEfiIScsiInitiatorNameProtocolGuid, 1971 (VOID**)&AttemptTmp, 1972 NULL 1973 ); 1974 if(AttemptTmp == NULL || EFI_ERROR (Status)) { 1975 continue; 1976 } 1977 1978 ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex); 1979 1980 AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0])); 1981 1982 if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED || StrCmp (MacString, AttemptMacString)) { 1983 FreePool (AttemptTmp); 1984 continue; 1985 } 1986 1987 if (AttemptTmp->SessionConfigData.DnsMode || AttemptTmp->SessionConfigData.TargetInfoFromDhcp) { 1988 FreePool (AttemptTmp); 1989 FreePool (AttemptConfigOrder); 1990 return TRUE; 1991 } else { 1992 FreePool (AttemptTmp); 1993 continue; 1994 } 1995 1996 } 1997 1998 FreePool (AttemptConfigOrder); 1999 return FALSE; 2000 2001 } 2002 2003 /** 992 2004 Get the various configuration data. 993 2005 … … 996 2008 @retval EFI_SUCCESS The configuration data is retrieved. 997 2009 @retval EFI_NOT_FOUND This iSCSI driver is not configured yet. 2010 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 998 2011 999 2012 **/ … … 1005 2018 EFI_STATUS Status; 1006 2019 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; 2020 CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; 1007 2021 UINTN Index; 1008 2022 ISCSI_NIC_INFO *NicInfo; … … 1055 2069 // 1056 2070 if (AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG && 1057 AttemptTmp->AutoConfigureMode != IP_MODE_AUTOCONFIG_SUCCESS) {2071 !AttemptTmp->AutoConfigureSuccess) { 1058 2072 if (mPrivate->Ipv6Flag && 1059 2073 AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) { … … 1096 2110 // Refresh the state of this attempt to NVR. 1097 2111 // 1098 AsciiStrToUnicodeStr (AttemptTmp->MacString, MacString);1099 2112 UnicodeSPrint ( 1100 2113 mPrivate->PortString, 1101 2114 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 1102 L"%s%d", 1103 MacString, 2115 L"Attempt %d", 1104 2116 (UINTN) AttemptTmp->AttemptConfigIndex 1105 2117 ); … … 1115 2127 continue; 1116 2128 } 1117 } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && !AttemptTmp->ValidPath) { 2129 } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && 2130 !AttemptTmp->ValidPath && 2131 AttemptTmp->NicIndex == mPrivate->CurrentNic) { 1118 2132 // 1119 // Get DHCP information for already added, but failed, attempt. 2133 // If the attempt associates with the current NIC, we can 2134 // get DHCP information for already added, but failed, attempt. 1120 2135 // 1121 2136 AttemptTmp->DhcpSuccess = FALSE; … … 1135 2150 // Refresh the state of this attempt to NVR. 1136 2151 // 1137 AsciiStrToUnicodeStr (AttemptTmp->MacString, MacString);1138 2152 UnicodeSPrint ( 1139 2153 mPrivate->PortString, 1140 2154 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 1141 L"%s%d", 1142 MacString, 2155 L"Attempt %d", 1143 2156 (UINTN) AttemptTmp->AttemptConfigIndex 1144 2157 ); … … 1168 2181 UnicodeSPrint ( 1169 2182 mPrivate->PortString, 1170 (UINTN) 128, 1171 L"%s%d", 1172 MacString, 2183 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 2184 L"Attempt %d", 1173 2185 (UINTN) AttemptConfigOrder[Index] 1174 2186 ); 1175 2187 1176 2188 GetVariable2 ( 1177 mPrivate->PortString, 1178 &gEfiIScsiInitiatorNameProtocolGuid, 1179 (VOID**)&AttemptConfigData, 1180 NULL 1181 ); 1182 1183 if (AttemptConfigData == NULL) { 2189 mPrivate->PortString, 2190 &gEfiIScsiInitiatorNameProtocolGuid, 2191 (VOID**)&AttemptConfigData, 2192 NULL 2193 ); 2194 AsciiStrToUnicodeStrS (AttemptConfigData->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0])); 2195 2196 if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED || 2197 StrCmp (MacString, AttemptMacString)) { 1184 2198 continue; 1185 2199 } … … 1198 2212 AttemptConfigData->AutoConfigureMode = 1199 2213 (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4); 2214 AttemptConfigData->AutoConfigureSuccess = FALSE; 1200 2215 } 1201 2216 … … 1225 2240 // Refresh the state of this attempt to NVR. 1226 2241 // 1227 AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString);1228 2242 UnicodeSPrint ( 1229 2243 mPrivate->PortString, 1230 2244 (UINTN) ISCSI_NAME_IFR_MAX_SIZE, 1231 L"%s%d", 1232 MacString, 2245 L"Attempt %d", 1233 2246 (UINTN) AttemptConfigData->AttemptConfigIndex 1234 2247 ); … … 1281 2294 NULL 1282 2295 ); 1283 ASSERT (AttemptConfigData->AttemptTitleHelpToken != 0); 2296 if (AttemptConfigData->AttemptTitleHelpToken == 0) { 2297 return EFI_OUT_OF_RESOURCES; 2298 } 1284 2299 1285 2300 // … … 1353 2368 EFI_STATUS Status; 1354 2369 EFI_DEV_PATH *DPathNode; 2370 UINTN PathLen; 1355 2371 1356 2372 if (Session->State != SESSION_STATE_LOGGED_IN) { … … 1391 2407 (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp); 1392 2408 1393 IP4_COPY_ADDRESS ( 1394 &DPathNode->Ipv4.GatewayIpAddress, 1395 &Session->ConfigData->SessionConfigData.Gateway 1396 ); 1397 1398 IP4_COPY_ADDRESS ( 1399 &DPathNode->Ipv4.SubnetMask, 1400 &Session->ConfigData->SessionConfigData.SubnetMask 1401 ); 2409 // 2410 // Add a judgement here to support previous versions of IPv4_DEVICE_PATH. 2411 // In previous versions of IPv4_DEVICE_PATH, GatewayIpAddress and SubnetMask 2412 // do not exist. 2413 // In new version of IPv4_DEVICE_PATH, structcure length is 27. 2414 // 2415 2416 PathLen = DevicePathNodeLength (&DPathNode->Ipv4); 2417 2418 if (PathLen == IP4_NODE_LEN_NEW_VERSIONS) { 2419 2420 IP4_COPY_ADDRESS ( 2421 &DPathNode->Ipv4.GatewayIpAddress, 2422 &Session->ConfigData->SessionConfigData.Gateway 2423 ); 2424 2425 IP4_COPY_ADDRESS ( 2426 &DPathNode->Ipv4.SubnetMask, 2427 &Session->ConfigData->SessionConfigData.SubnetMask 2428 ); 2429 } 2430 1402 2431 break; 1403 2432 } else if (Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP) { 1404 2433 DPathNode->Ipv6.LocalPort = 0; 1405 DPathNode->Ipv6.IpAddressOrigin = 0; 1406 DPathNode->Ipv6.PrefixLength = IP6_PREFIX_LENGTH; 1407 ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS)); 2434 2435 // 2436 // Add a judgement here to support previous versions of IPv6_DEVICE_PATH. 2437 // In previous versions of IPv6_DEVICE_PATH, IpAddressOrigin, PrefixLength 2438 // and GatewayIpAddress do not exist. 2439 // In new version of IPv6_DEVICE_PATH, structure length is 60, while in 2440 // old versions, the length is 43. 2441 // 2442 2443 PathLen = DevicePathNodeLength (&DPathNode->Ipv6); 2444 2445 if (PathLen == IP6_NODE_LEN_NEW_VERSIONS ) { 2446 2447 DPathNode->Ipv6.IpAddressOrigin = 0; 2448 DPathNode->Ipv6.PrefixLength = IP6_PREFIX_LENGTH; 2449 ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS)); 2450 } 2451 else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) { 2452 2453 // 2454 // StaticIPAddress is a field in old versions of IPv6_DEVICE_PATH, while ignored in new 2455 // version. Set StaticIPAddress through its' offset in old IPv6_DEVICE_PATH. 2456 // 2457 *((UINT8 *)(&DPathNode->Ipv6) + IP6_OLD_IPADDRESS_OFFSET) = 2458 (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp); 2459 } 2460 1408 2461 break; 1409 2462 } … … 1434 2487 1435 2488 Private = (ISCSI_DRIVER_DATA *) Context; 2489 1436 2490 gBS->CloseEvent (Private->ExitBootServiceEvent); 2491 Private->ExitBootServiceEvent = NULL; 1437 2492 1438 2493 if (Private->Session != NULL) { -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiMisc.h
r58466 r77662 2 2 Miscellaneous definitions for iSCSI driver. 3 3 4 Copyright (c) 2004 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 17 17 18 18 typedef struct _ISCSI_DRIVER_DATA ISCSI_DRIVER_DATA; 19 20 /// 21 /// IPv4 Device Path Node Length 22 /// 23 #define IP4_NODE_LEN_NEW_VERSIONS 27 24 25 /// 26 /// IPv6 Device Path Node Length 27 /// 28 #define IP6_NODE_LEN_OLD_VERSIONS 43 29 #define IP6_NODE_LEN_NEW_VERSIONS 60 30 31 /// 32 /// The ignored field StaticIpAddress's offset in old IPv6 Device Path 33 /// 34 #define IP6_OLD_IPADDRESS_OFFSET 42 35 19 36 20 37 #pragma pack(1) … … 30 47 BOOLEAN InitiatorInfoFromDhcp; 31 48 BOOLEAN TargetInfoFromDhcp; 49 32 50 CHAR8 TargetName[ISCSI_NAME_MAX_SIZE]; 33 51 EFI_IP_ADDRESS TargetIp; … … 35 53 UINT8 BootLun[8]; 36 54 37 UINT16 ConnectTimeout; ///< timout value in milliseconds 55 UINT16 ConnectTimeout; ///< timout value in milliseconds. 38 56 UINT8 ConnectRetryCount; 39 57 UINT8 IsId[6]; 58 59 BOOLEAN RedirectFlag; 60 UINT16 OriginalTargetPort; // The port of proxy/virtual target. 61 EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virtual target. 62 63 BOOLEAN DnsMode; // Flag indicate whether the Target address is expressed as URL format. 64 CHAR8 TargetUrl[ISCSI_TARGET_URI_MAX_SIZE]; 65 40 66 } ISCSI_SESSION_CONFIG_NVDATA; 41 67 #pragma pack() … … 192 218 193 219 @param[in] Controller The handle of the controller. 220 @param[in] Image Handle of the image. 194 221 195 222 @retval EFI_SUCCESS The operation is completed. … … 200 227 EFI_STATUS 201 228 IScsiAddNic ( 202 IN EFI_HANDLE Controller 229 IN EFI_HANDLE Controller, 230 IN EFI_HANDLE Image 203 231 ); 204 232 … … 216 244 IScsiRemoveNic ( 217 245 IN EFI_HANDLE Controller 246 ); 247 248 /** 249 Create and initialize the Attempts. 250 251 @param[in] AttemptNum The number of Attempts will be created. 252 253 @retval EFI_SUCCESS The Attempts have been created successfully. 254 @retval Others Failed to create the Attempt. 255 256 **/ 257 EFI_STATUS 258 IScsiCreateAttempts ( 259 IN UINTN AttemptNum 260 ); 261 262 /** 263 Create the iSCSI configuration Keywords for each attempt. 264 265 @param[in] KeywordNum The number Sets of Keywords will be created. 266 267 @retval EFI_SUCCESS The operation is completed. 268 @retval Others Failed to create the Keywords. 269 270 **/ 271 EFI_STATUS 272 IScsiCreateKeywords ( 273 IN UINTN KeywordNum 274 ); 275 276 /** 277 278 Free the attempt configure data variable. 279 280 **/ 281 VOID 282 IScsiCleanAttemptVariable ( 283 IN VOID 218 284 ); 219 285 … … 233 299 234 300 /** 235 Get the NIC's PCI location and return it acc roding to the composited301 Get the NIC's PCI location and return it according to the composited 236 302 format defined in iSCSI Boot Firmware Table. 237 303 … … 291 357 Clean the iSCSI driver data. 292 358 293 @param[in] Private The iSCSI driver data. 294 295 **/ 296 VOID 359 @param[in] Private The iSCSI driver data. 360 361 @retval EFI_SUCCES The clean operation is successful. 362 @retval Others Other errors as indicated. 363 364 **/ 365 EFI_STATUS 297 366 IScsiCleanDriverData ( 298 367 IN ISCSI_DRIVER_DATA *Private … … 313 382 IN EFI_HANDLE Controller, 314 383 IN UINT8 IpVersion 384 ); 385 386 /** 387 Check wheather the Controller handle is configured to use DNS protocol. 388 389 @param[in] Controller The handle of the controller. 390 391 @retval TRUE The handle of the controller need the DNS protocol. 392 @retval FALSE The handle of the controller does not need the DNS protocol. 393 394 **/ 395 BOOLEAN 396 IScsiDnsIsConfigured ( 397 IN EFI_HANDLE Controller 315 398 ); 316 399 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiProto.c
r58466 r77662 2 2 The implementation of iSCSI protocol based on RFC3720. 3 3 4 Copyright (c) 2004 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 139 139 // Start the timer, and wait Timeout seconds to establish the TCP connection. 140 140 // 141 Status = gBS->SetTimer (Conn->TimeoutEvent, TimerRelative, Timeout * TICKS_PER_MS); 141 Status = gBS->SetTimer ( 142 Conn->TimeoutEvent, 143 TimerRelative, 144 MultU64x32 (Timeout, TICKS_PER_MS) 145 ); 142 146 if (EFI_ERROR (Status)) { 143 147 return Status; … … 252 256 Conn->DataDigest = IScsiDigestNone; 253 257 258 if (NvData->DnsMode) { 259 // 260 // perform dns process if target address expressed by domain name. 261 // 262 if (!Conn->Ipv6Flag) { 263 Status = IScsiDns4 (Private->Image, Private->Controller, NvData); 264 } else { 265 Status = IScsiDns6 (Private->Image, Private->Controller, NvData); 266 } 267 268 if (EFI_ERROR(Status)) { 269 DEBUG ((EFI_D_ERROR, "The configuration of Target address or DNS server address is invalid!\n")); 270 FreePool (Conn); 271 return NULL; 272 } 273 } 274 254 275 if (!Conn->Ipv6Flag) { 255 276 Tcp4IoConfig = &TcpIoConfig.Tcp4IoConfigData; … … 424 445 EFI_GUID *ProtocolGuid; 425 446 UINT8 RetryCount; 426 BOOLEAN MediaPresent;447 EFI_STATUS MediaStatus; 427 448 428 449 // 429 450 // Check media status before session login. 430 451 // 431 Media Present = TRUE;432 NetLibDetectMedia (Session->Private->Controller, &MediaPresent);433 if ( !MediaPresent) {452 MediaStatus = EFI_SUCCESS; 453 NetLibDetectMediaWaitTimeout (Session->Private->Controller, ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME, &MediaStatus); 454 if (MediaStatus != EFI_SUCCESS) { 434 455 return EFI_NO_MEDIA; 435 456 } … … 732 753 733 754 LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufAllocSpace (Nbuf, sizeof (ISCSI_LOGIN_REQUEST), NET_BUF_TAIL); 734 ASSERT (LoginReq != NULL); 755 if (LoginReq == NULL) { 756 NetbufFree (Nbuf); 757 return NULL; 758 } 735 759 ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST)); 736 760 … … 780 804 case ISCSI_LOGIN_OPERATIONAL_NEGOTIATION: 781 805 // 782 // Only negotiate the param ter once.806 // Only negotiate the parameter once. 783 807 // 784 808 if (!Conn->ParamNegotiated) { … … 1063 1087 ) 1064 1088 { 1065 LIST_ENTRY *KeyValueList; 1066 CHAR8 *TargetAddress; 1067 CHAR8 *IpStr; 1068 EFI_STATUS Status; 1069 UINTN Number; 1070 UINT8 IpMode; 1089 LIST_ENTRY *KeyValueList; 1090 CHAR8 *TargetAddress; 1091 CHAR8 *IpStr; 1092 EFI_STATUS Status; 1093 UINTN Number; 1094 UINT8 IpMode; 1095 ISCSI_SESSION_CONFIG_NVDATA *NvData; 1071 1096 1072 1097 KeyValueList = IScsiBuildKeyValueList (Data, Len); … … 1076 1101 1077 1102 Status = EFI_NOT_FOUND; 1103 NvData = &Session->ConfigData->SessionConfigData; 1078 1104 1079 1105 while (TRUE) { … … 1083 1109 } 1084 1110 1085 if (!NET_IS_DIGIT (TargetAddress[0])) { 1111 // 1112 // RFC 3720 defines format of the TargetAddress=domainname[:port][,portal-group-tag] 1113 // The domainname can be specified as either a DNS host name, adotted-decimal IPv4 address, 1114 // or a bracketed IPv6 address as specified in [RFC2732]. 1115 // 1116 if (NET_IS_DIGIT (TargetAddress[0])) { 1086 1117 // 1087 // The domainname of the target may be presented in three formats: a DNS host name, 1088 // a dotted-decimal IPv4 address, or a bracketed IPv6 address. Only accept dotted 1089 // IPv4 address. 1118 // The domainname of the target is presented in a dotted-decimal IPv4 address format. 1090 1119 // 1091 continue; 1092 } 1093 1094 IpStr = TargetAddress; 1095 1096 while ((*TargetAddress != 0) && (*TargetAddress != ':') && (*TargetAddress != ',')) { 1120 IpStr = TargetAddress; 1121 1122 while ((*TargetAddress != '\0') && (*TargetAddress != ':') && (*TargetAddress != ',')) { 1123 // 1124 // NULL, ':', or ',' ends the IPv4 string. 1125 // 1126 TargetAddress++; 1127 } 1128 } else if (*TargetAddress == ISCSI_REDIRECT_ADDR_START_DELIMITER){ 1097 1129 // 1098 // NULL, ':', or ',' ends the IPv4 string.1130 // The domainname of the target is presented in a bracketed IPv6 address format. 1099 1131 // 1100 TargetAddress++; 1101 } 1132 TargetAddress ++; 1133 IpStr = TargetAddress; 1134 while ((*TargetAddress != '\0') && (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER)) { 1135 // 1136 // ']' ends the IPv6 string. 1137 // 1138 TargetAddress++; 1139 } 1140 1141 if (*TargetAddress != ISCSI_REDIRECT_ADDR_END_DELIMITER) { 1142 continue; 1143 } 1144 1145 *TargetAddress = '\0'; 1146 TargetAddress ++; 1147 1148 } else { 1149 // 1150 // The domainname of the target is presented in the format of a DNS host name. 1151 // 1152 IpStr = TargetAddress; 1153 1154 while ((*TargetAddress != '\0') && (*TargetAddress != ':') && (*TargetAddress != ',')) { 1155 TargetAddress++; 1156 } 1157 NvData->DnsMode = TRUE; 1158 } 1159 1160 // 1161 // Save the origial user setting which specifies the proxy/virtual iSCSI target. 1162 // 1163 NvData->OriginalTargetPort = NvData->TargetPort; 1102 1164 1103 1165 if (*TargetAddress == ',') { … … 1116 1178 continue; 1117 1179 } else { 1118 Session->ConfigData->SessionConfigData.TargetPort = (UINT16) Number;1180 NvData->TargetPort = (UINT16) Number; 1119 1181 } 1120 1182 } else { 1121 1183 // 1122 // The string only contains the IPv4address. Use the well-known port.1184 // The string only contains the Target address. Use the well-known port. 1123 1185 // 1124 Session->ConfigData->SessionConfigData.TargetPort = ISCSI_WELL_KNOWN_PORT; 1125 } 1186 NvData->TargetPort = ISCSI_WELL_KNOWN_PORT; 1187 } 1188 1189 // 1190 // Save the origial user setting which specifies the proxy/virtual iSCSI target. 1191 // 1192 CopyMem (&NvData->OriginalTargetIp, &NvData->TargetIp, sizeof (EFI_IP_ADDRESS)); 1193 1126 1194 // 1127 1195 // Update the target IP address. 1128 1196 // 1129 if ( Session->ConfigData->SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) {1130 IpMode = Session->ConfigData->SessionConfigData.IpMode;1197 if (NvData->IpMode < IP_MODE_AUTOCONFIG) { 1198 IpMode = NvData->IpMode; 1131 1199 } else { 1132 1200 IpMode = Session->ConfigData->AutoConfigureMode; 1133 1201 } 1134 1202 1135 Status = IScsiAsciiStrToIp ( 1136 IpStr, 1137 IpMode, 1138 &Session->ConfigData->SessionConfigData.TargetIp 1139 ); 1140 1141 if (EFI_ERROR (Status)) { 1142 continue; 1203 if (NvData->DnsMode) { 1204 // 1205 // Target address is expressed as URL format, just save it and 1206 // do DNS resolution when creating a TCP connection. 1207 // 1208 if (AsciiStrSize (IpStr) > sizeof (Session->ConfigData->SessionConfigData.TargetUrl)){ 1209 return EFI_INVALID_PARAMETER; 1210 } 1211 CopyMem (&Session->ConfigData->SessionConfigData.TargetUrl, IpStr, AsciiStrSize (IpStr)); 1143 1212 } else { 1144 break; 1213 Status = IScsiAsciiStrToIp ( 1214 IpStr, 1215 IpMode, 1216 &Session->ConfigData->SessionConfigData.TargetIp 1217 ); 1218 1219 if (EFI_ERROR (Status)) { 1220 continue; 1221 } else { 1222 NvData->RedirectFlag = TRUE; 1223 break; 1224 } 1145 1225 } 1146 1226 } … … 1246 1326 1247 1327 Header = NetbufAllocSpace (PduHdr, Len, NET_BUF_TAIL); 1248 ASSERT (Header != NULL); 1328 if (Header == NULL) { 1329 Status = EFI_OUT_OF_RESOURCES; 1330 goto ON_EXIT; 1331 } 1249 1332 InsertTailList (NbufList, &PduHdr->List); 1250 1333 … … 2094 2177 @param[in] Packet The EXT SCSI PASS THRU request packet containing the SCSI command. 2095 2178 @param[in] Lun The LUN. 2096 @param[in] Tcb The tcb assoc ated with this SCSI command.2179 @param[in] Tcb The tcb associated with this SCSI command. 2097 2180 2098 2181 @return The created iSCSI SCSI command PDU. … … 2317 2400 2318 2401 DataOutHdr = (ISCSI_SCSI_DATA_OUT *) NetbufAllocSpace (PduHdr, sizeof (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL); 2319 ASSERT (DataOutHdr != NULL); 2402 if (DataOutHdr == NULL) { 2403 IScsiFreeNbufList (NbufList); 2404 return NULL; 2405 } 2320 2406 XferContext = &Tcb->XferContext; 2321 2407 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IScsiDxe/IScsiProto.h
r58466 r77662 2 2 The header file of iSCSI Protocol that defines many specific data structures. 3 3 4 Copyright (c) 2004 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 40 40 #define ISCSI_VERSION_MAX 0x00 41 41 #define ISCSI_VERSION_MIN 0x00 42 43 #define ISCSI_CHECK_MEDIA_LOGIN_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) 44 #define ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) 45 46 #define ISCSI_REDIRECT_ADDR_START_DELIMITER '[' 47 #define ISCSI_REDIRECT_ADDR_END_DELIMITER ']' 42 48 43 49 #define ISCSI_KEY_AUTH_METHOD "AuthMethod" -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/ComponentName.c
r58466 r77662 3 3 EFI_COMPONENT_NAME2_PROTOCOL protocol. 4 4 5 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 264 264 Offset = 0; 265 265 Status = Ip6->GetModeData (Ip6, &Ip6ModeData, NULL, NULL); 266 if (!EFI_ERROR (Status)) { 267 if (Ip6ModeData.AddressList != NULL) { 268 FreePool (Ip6ModeData.AddressList); 269 } 270 271 if (Ip6ModeData.GroupTable != NULL) { 272 FreePool (Ip6ModeData.GroupTable); 273 } 274 275 if (Ip6ModeData.RouteTable != NULL) { 276 FreePool (Ip6ModeData.RouteTable); 277 } 278 279 if (Ip6ModeData.NeighborCache != NULL) { 280 FreePool (Ip6ModeData.NeighborCache); 281 } 282 283 if (Ip6ModeData.PrefixTable != NULL) { 284 FreePool (Ip6ModeData.PrefixTable); 285 } 286 287 if (Ip6ModeData.IcmpTypeList != NULL) { 288 FreePool (Ip6ModeData.IcmpTypeList); 289 } 290 } 291 266 292 if (!EFI_ERROR (Status) && Ip6ModeData.IsStarted) { 267 293 Status = NetLibIp6ToStr (&Ip6ModeData.ConfigData.StationAddress, Address, sizeof(Address)); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Common.c
r58466 r77662 2 2 The implementation of common functions shared by IP6 driver. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 429 429 EFI_IPv6_ADDRESS SnMCastAddr; 430 430 431 if (IsListEmpty (AddressList) || *AddressCount < 1 || PrefixLength > IP6_PREFIX_ NUM) {431 if (IsListEmpty (AddressList) || *AddressCount < 1 || PrefixLength > IP6_PREFIX_MAX) { 432 432 return EFI_INVALID_PARAMETER; 433 433 } … … 607 607 608 608 ASSERT (Dest != NULL && Src != NULL); 609 ASSERT (PrefixLength < IP6_PREFIX_NUM);609 ASSERT (PrefixLength <= IP6_PREFIX_MAX); 610 610 611 611 Byte = (UINT8) (PrefixLength / 8); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Config.vfr
r58466 r77662 22 22 title = STRING_TOKEN(STR_IP6_CONFIG_FORM_TITLE), 23 23 help = STRING_TOKEN(STR_IP6_CONFIG_FORM_HELP), 24 class = EFI_NETWORK_DEVICE_CLASS,25 subclass = 0x03,26 24 27 25 varstore IP6_CONFIG_IFR_NVDATA, -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c
r58459 r77662 2 2 The implementation of EFI IPv6 Configuration Protocol. 3 3 4 Copyright (c) 2009 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 48 48 ) 49 49 { 50 LIST_ENTRY *Entry; 51 LIST_ENTRY *Entry2; 52 LIST_ENTRY *Next; 53 IP6_INTERFACE *IpIf; 54 IP6_DAD_ENTRY *DadEntry; 50 LIST_ENTRY *Entry; 51 LIST_ENTRY *Entry2; 52 LIST_ENTRY *Next; 53 IP6_INTERFACE *IpIf; 54 IP6_DAD_ENTRY *DadEntry; 55 IP6_DELAY_JOIN_LIST *DelayNode; 56 IP6_ADDRESS_INFO *AddrInfo; 57 IP6_PROTOCOL *Instance; 58 BOOLEAN Recovery; 59 60 Recovery = FALSE; 55 61 56 62 // … … 80 86 } 81 87 82 // 83 // All IPv6 children that use global unicast address as it's source address 84 // should be destryoed now. The survivers are those use the link-local address 85 // or the unspecified address as the source address. 86 // TODO: Conduct a check here. 87 Ip6RemoveAddr ( 88 IpSb, 89 &IpSb->DefaultInterface->AddressList, 90 &IpSb->DefaultInterface->AddressCount, 91 NULL, 92 0 93 ); 88 if (!IsListEmpty (&IpSb->DefaultInterface->AddressList) && IpSb->DefaultInterface->AddressCount > 0) { 89 // 90 // If any IPv6 children (Instance) in configured state and use global unicast address, it will be 91 // destroyed in Ip6RemoveAddr() function later. Then, the upper layer driver's Stop() function will be 92 // called, which may break the upper layer network stacks. So, the driver should take the responsibility 93 // for the recovery by using ConnectController() after Ip6RemoveAddr(). 94 // Here, just check whether need to recover the upper layer network stacks later. 95 // 96 NET_LIST_FOR_EACH (Entry, &IpSb->DefaultInterface->AddressList) { 97 AddrInfo = NET_LIST_USER_STRUCT_S (Entry, IP6_ADDRESS_INFO, Link, IP6_ADDR_INFO_SIGNATURE); 98 if (!IsListEmpty (&IpSb->Children)) { 99 NET_LIST_FOR_EACH (Entry2, &IpSb->Children) { 100 Instance = NET_LIST_USER_STRUCT_S (Entry2, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE); 101 if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, &AddrInfo->Address)) { 102 Recovery = TRUE; 103 break; 104 } 105 } 106 } 107 } 108 109 // 110 // All IPv6 children that use global unicast address as it's source address 111 // should be destroyed now. The survivers are those use the link-local address 112 // or the unspecified address as the source address. 113 // TODO: Conduct a check here. 114 Ip6RemoveAddr ( 115 IpSb, 116 &IpSb->DefaultInterface->AddressList, 117 &IpSb->DefaultInterface->AddressCount, 118 NULL, 119 0 120 ); 121 122 if (IpSb->Controller != NULL && Recovery) { 123 // 124 // ConnectController() to recover the upper layer network stacks. 125 // 126 gBS->ConnectController (IpSb->Controller, NULL, NULL, TRUE); 127 } 128 } 129 94 130 95 131 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { 96 132 // 97 // remove all pending DAD entries for the global addresses.133 // remove all pending delay node and DAD entries for the global addresses. 98 134 // 99 135 IpIf = NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INTERFACE_SIGNATURE); 136 137 NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DelayJoinList) { 138 DelayNode = NET_LIST_USER_STRUCT (Entry2, IP6_DELAY_JOIN_LIST, Link); 139 if (!NetIp6IsLinkLocalAddr (&DelayNode->AddressInfo->Address)) { 140 RemoveEntryList (&DelayNode->Link); 141 FreePool (DelayNode); 142 } 143 } 100 144 101 145 NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DupAddrDetectList) { … … 113 157 if (NewPolicy == Ip6ConfigPolicyAutomatic) { 114 158 // 115 // Set param ters to trigger router solicitation sending in timer handler.159 // Set parameters to trigger router solicitation sending in timer handler. 116 160 // 117 161 IpSb->RouterAdvertiseReceived = FALSE; … … 122 166 IpSb->Ticks = (UINT32) IP6_GET_TICKS (IP6_ONE_SECOND_IN_MS); 123 167 } 124 125 168 } 126 169 … … 211 254 // 212 255 Oro = (EFI_DHCP6_PACKET_OPTION *) OptBuf; 213 Oro->OpCode = HTONS ( IP6_CONFIG_DHCP6_OPTION_ORO);256 Oro->OpCode = HTONS (DHCP6_OPT_ORO); 214 257 Oro->OpLen = HTONS (2); 215 *((UINT16 *) &Oro->Data[0]) = HTONS ( IP6_CONFIG_DHCP6_OPTION_DNS_SERVERS);258 *((UINT16 *) &Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS); 216 259 OptList[0] = Oro; 217 260 … … 657 700 return EFI_ABORTED; 658 701 } else { 659 660 if (NewPolicy == Ip6ConfigPolicyAutomatic) { 661 // 662 // Clean the ManualAddress, Gateway and DnsServers, shrink the variable 663 // data size, and fire up all the related events. 664 // 665 DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress]; 666 if (DataItem->Data.Ptr != NULL) { 667 FreePool (DataItem->Data.Ptr); 668 } 669 DataItem->Data.Ptr = NULL; 670 DataItem->DataSize = 0; 671 DataItem->Status = EFI_NOT_FOUND; 672 NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL); 673 674 DataItem = &Instance->DataItem[Ip6ConfigDataTypeGateway]; 675 if (DataItem->Data.Ptr != NULL) { 676 FreePool (DataItem->Data.Ptr); 677 } 678 DataItem->Data.Ptr = NULL; 679 DataItem->DataSize = 0; 680 DataItem->Status = EFI_NOT_FOUND; 681 NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL); 682 683 DataItem = &Instance->DataItem[Ip6ConfigDataTypeDnsServer]; 684 DataItem->Data.Ptr = NULL; 685 DataItem->DataSize = 0; 686 DataItem->Status = EFI_NOT_FOUND; 687 NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL); 688 } else { 702 // 703 // Clean the ManualAddress, Gateway and DnsServers, shrink the variable 704 // data size, and fire up all the related events. 705 // 706 DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress]; 707 if (DataItem->Data.Ptr != NULL) { 708 FreePool (DataItem->Data.Ptr); 709 } 710 DataItem->Data.Ptr = NULL; 711 DataItem->DataSize = 0; 712 DataItem->Status = EFI_NOT_FOUND; 713 NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL); 714 715 DataItem = &Instance->DataItem[Ip6ConfigDataTypeGateway]; 716 if (DataItem->Data.Ptr != NULL) { 717 FreePool (DataItem->Data.Ptr); 718 } 719 DataItem->Data.Ptr = NULL; 720 DataItem->DataSize = 0; 721 DataItem->Status = EFI_NOT_FOUND; 722 NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL); 723 724 DataItem = &Instance->DataItem[Ip6ConfigDataTypeDnsServer]; 725 DataItem->Data.Ptr = NULL; 726 DataItem->DataSize = 0; 727 DataItem->Status = EFI_NOT_FOUND; 728 NetMapIterate (&DataItem->EventMap, Ip6ConfigSignalEvent, NULL); 729 730 if (NewPolicy == Ip6ConfigPolicyManual) { 689 731 // 690 732 // The policy is changed from automatic to manual. Stop the DHCPv6 process … … 749 791 The callback function for Ip6SetAddr. The prototype is defined 750 792 as IP6_DAD_CALLBACK. It is called after Duplicate Address Detection is performed 751 for the manual address set by Ip6ConfigSetMa unualAddress.793 for the manual address set by Ip6ConfigSetManualAddress. 752 794 753 795 @param[in] IsDadPassed If TRUE, Duplicate Address Detection passed. … … 777 819 ManualAddr = NULL; 778 820 821 if (Item->DataSize == 0) { 822 return; 823 } 824 779 825 for (Index = 0; Index < Item->DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS); Index++) { 780 826 // … … 885 931 **/ 886 932 EFI_STATUS 887 Ip6ConfigSetMa unualAddress (933 Ip6ConfigSetManualAddress ( 888 934 IN IP6_CONFIG_INSTANCE *Instance, 889 935 IN UINTN DataSize, … … 908 954 EFI_STATUS Status; 909 955 BOOLEAN IsUpdated; 956 LIST_ENTRY *Next; 957 IP6_DAD_ENTRY *DadEntry; 958 IP6_DELAY_JOIN_LIST *DelayNode; 959 960 NewAddress = NULL; 961 TmpAddress = NULL; 962 CurrentAddrInfo = NULL; 963 Copy = NULL; 964 Entry = NULL; 965 Entry2 = NULL; 966 IpIf = NULL; 967 PrefixEntry = NULL; 968 Next = NULL; 969 DadEntry = NULL; 970 DelayNode = NULL; 971 Status = EFI_SUCCESS; 910 972 911 973 ASSERT (Instance->DataItem[Ip6ConfigDataTypeManualAddress].Status != EFI_NOT_READY); 912 974 913 if (( (DataSize % sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)) != 0) || (DataSize == 0)) {975 if ((DataSize != 0) && ((DataSize % sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)) != 0)) { 914 976 return EFI_BAD_BUFFER_SIZE; 915 977 } … … 919 981 } 920 982 921 NewAddressCount = DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS); 922 NewAddress = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) Data; 923 924 for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) { 925 926 if (NetIp6IsLinkLocalAddr (&NewAddress->Address) || 927 !NetIp6IsValidUnicast (&NewAddress->Address) || 928 (NewAddress->PrefixLength > 128) 929 ) { 930 // 931 // make sure the IPv6 address is unicast and not link-local address && 932 // the prefix length is valid. 933 // 934 return EFI_INVALID_PARAMETER; 935 } 936 937 TmpAddress = NewAddress + 1; 938 for (Index2 = Index1 + 1; Index2 < NewAddressCount; Index2++, TmpAddress++) { 939 // 940 // Any two addresses in the array can't be equal. 941 // 942 if (EFI_IP6_EQUAL (&TmpAddress->Address, &NewAddress->Address)) { 943 983 IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance); 984 985 DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress]; 986 987 if (Data != NULL && DataSize != 0) { 988 NewAddressCount = DataSize / sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS); 989 NewAddress = (EFI_IP6_CONFIG_MANUAL_ADDRESS *) Data; 990 991 for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) { 992 993 if (NetIp6IsLinkLocalAddr (&NewAddress->Address) || 994 !NetIp6IsValidUnicast (&NewAddress->Address) || 995 (NewAddress->PrefixLength > 128) 996 ) { 997 // 998 // make sure the IPv6 address is unicast and not link-local address && 999 // the prefix length is valid. 1000 // 944 1001 return EFI_INVALID_PARAMETER; 945 1002 } 946 } 947 } 948 949 IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance); 950 951 // 952 // Build the current source address list. 953 // 954 InitializeListHead (&CurrentSourceList); 955 CurrentSourceCount = 0; 956 957 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { 958 IpIf = NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INTERFACE_SIGNATURE); 959 960 NET_LIST_FOR_EACH (Entry2, &IpIf->AddressList) { 961 CurrentAddrInfo = NET_LIST_USER_STRUCT_S (Entry2, IP6_ADDRESS_INFO, Link, IP6_ADDR_INFO_SIGNATURE); 962 963 Copy = AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), CurrentAddrInfo); 964 if (Copy == NULL) { 965 break; 966 } 967 968 InsertTailList (&CurrentSourceList, &Copy->Link); 969 CurrentSourceCount++; 970 } 971 } 972 973 // 974 // Update the value... a long journey starts 975 // 976 NewAddress = AllocateCopyPool (DataSize, Data); 977 if (NewAddress == NULL) { 978 Ip6RemoveAddr (NULL, &CurrentSourceList, &CurrentSourceCount, NULL, 0); 979 980 return EFI_OUT_OF_RESOURCES; 981 } 982 983 // 984 // Store the new data, and init the DataItem status to EFI_NOT_READY because 985 // we may have an asynchronous configuration process. 986 // 987 DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress]; 988 if (DataItem->Data.Ptr != NULL) { 989 FreePool (DataItem->Data.Ptr); 990 } 991 DataItem->Data.Ptr = NewAddress; 992 DataItem->DataSize = DataSize; 993 DataItem->Status = EFI_NOT_READY; 994 995 // 996 // Trigger DAD, it's an asynchronous process. 997 // 998 IsUpdated = FALSE; 999 1000 for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) { 1001 if (Ip6IsOneOfSetAddress (IpSb, &NewAddress->Address, NULL, &CurrentAddrInfo)) { 1002 ASSERT (CurrentAddrInfo != NULL); 1003 // 1004 // Remove this already existing source address from the CurrentSourceList 1005 // built before. 1003 1004 TmpAddress = NewAddress + 1; 1005 for (Index2 = Index1 + 1; Index2 < NewAddressCount; Index2++, TmpAddress++) { 1006 // 1007 // Any two addresses in the array can't be equal. 1008 // 1009 if (EFI_IP6_EQUAL (&TmpAddress->Address, &NewAddress->Address)) { 1010 1011 return EFI_INVALID_PARAMETER; 1012 } 1013 } 1014 } 1015 1016 // 1017 // Build the current source address list. 1018 // 1019 InitializeListHead (&CurrentSourceList); 1020 CurrentSourceCount = 0; 1021 1022 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { 1023 IpIf = NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INTERFACE_SIGNATURE); 1024 1025 NET_LIST_FOR_EACH (Entry2, &IpIf->AddressList) { 1026 CurrentAddrInfo = NET_LIST_USER_STRUCT_S (Entry2, IP6_ADDRESS_INFO, Link, IP6_ADDR_INFO_SIGNATURE); 1027 1028 Copy = AllocateCopyPool (sizeof (IP6_ADDRESS_INFO), CurrentAddrInfo); 1029 if (Copy == NULL) { 1030 break; 1031 } 1032 1033 InsertTailList (&CurrentSourceList, &Copy->Link); 1034 CurrentSourceCount++; 1035 } 1036 } 1037 1038 // 1039 // Update the value... a long journey starts 1040 // 1041 NewAddress = AllocateCopyPool (DataSize, Data); 1042 if (NewAddress == NULL) { 1043 Ip6RemoveAddr (NULL, &CurrentSourceList, &CurrentSourceCount, NULL, 0); 1044 1045 return EFI_OUT_OF_RESOURCES; 1046 } 1047 1048 // 1049 // Store the new data, and init the DataItem status to EFI_NOT_READY because 1050 // we may have an asynchronous configuration process. 1051 // 1052 if (DataItem->Data.Ptr != NULL) { 1053 FreePool (DataItem->Data.Ptr); 1054 } 1055 DataItem->Data.Ptr = NewAddress; 1056 DataItem->DataSize = DataSize; 1057 DataItem->Status = EFI_NOT_READY; 1058 1059 // 1060 // Trigger DAD, it's an asynchronous process. 1061 // 1062 IsUpdated = FALSE; 1063 1064 for (Index1 = 0; Index1 < NewAddressCount; Index1++, NewAddress++) { 1065 if (Ip6IsOneOfSetAddress (IpSb, &NewAddress->Address, NULL, &CurrentAddrInfo)) { 1066 ASSERT (CurrentAddrInfo != NULL); 1067 // 1068 // Remove this already existing source address from the CurrentSourceList 1069 // built before. 1070 // 1071 Ip6RemoveAddr ( 1072 NULL, 1073 &CurrentSourceList, 1074 &CurrentSourceCount, 1075 &CurrentAddrInfo->Address, 1076 128 1077 ); 1078 1079 // 1080 // If the new address's prefix length is not specified, just use the previous configured 1081 // prefix length for this address. 1082 // 1083 if (NewAddress->PrefixLength == 0) { 1084 NewAddress->PrefixLength = CurrentAddrInfo->PrefixLength; 1085 } 1086 1087 // 1088 // This manual address is already in use, see whether prefix length is changed. 1089 // 1090 if (NewAddress->PrefixLength != CurrentAddrInfo->PrefixLength) { 1091 // 1092 // Remove the on-link prefix table, the route entry will be removed 1093 // implicitly. 1094 // 1095 PrefixEntry = Ip6FindPrefixListEntry ( 1096 IpSb, 1097 TRUE, 1098 CurrentAddrInfo->PrefixLength, 1099 &CurrentAddrInfo->Address 1100 ); 1101 if (PrefixEntry != NULL) { 1102 Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); 1103 } 1104 1105 // 1106 // Save the prefix length. 1107 // 1108 CurrentAddrInfo->PrefixLength = NewAddress->PrefixLength; 1109 IsUpdated = TRUE; 1110 } 1111 1112 // 1113 // create a new on-link prefix entry. 1114 // 1115 PrefixEntry = Ip6FindPrefixListEntry ( 1116 IpSb, 1117 TRUE, 1118 NewAddress->PrefixLength, 1119 &NewAddress->Address 1120 ); 1121 if (PrefixEntry == NULL) { 1122 Ip6CreatePrefixListEntry ( 1123 IpSb, 1124 TRUE, 1125 (UINT32) IP6_INFINIT_LIFETIME, 1126 (UINT32) IP6_INFINIT_LIFETIME, 1127 NewAddress->PrefixLength, 1128 &NewAddress->Address 1129 ); 1130 } 1131 1132 CurrentAddrInfo->IsAnycast = NewAddress->IsAnycast; 1133 // 1134 // Artificially mark this address passed DAD be'coz it is already in use. 1135 // 1136 Ip6ManualAddrDadCallback (TRUE, &NewAddress->Address, Instance); 1137 } else { 1138 // 1139 // A new address. 1140 // 1141 IsUpdated = TRUE; 1142 1143 // 1144 // Set the new address, this will trigger DAD and activate the address if 1145 // DAD succeeds. 1146 // 1147 Ip6SetAddress ( 1148 IpSb->DefaultInterface, 1149 &NewAddress->Address, 1150 NewAddress->IsAnycast, 1151 NewAddress->PrefixLength, 1152 (UINT32) IP6_INFINIT_LIFETIME, 1153 (UINT32) IP6_INFINIT_LIFETIME, 1154 Ip6ManualAddrDadCallback, 1155 Instance 1156 ); 1157 } 1158 } 1159 1160 // 1161 // Check the CurrentSourceList, it now contains those addresses currently in 1162 // use and will be removed. 1163 // 1164 IpIf = IpSb->DefaultInterface; 1165 1166 while (!IsListEmpty (&CurrentSourceList)) { 1167 IsUpdated = TRUE; 1168 1169 CurrentAddrInfo = NET_LIST_HEAD (&CurrentSourceList, IP6_ADDRESS_INFO, Link); 1170 1171 // 1172 // This local address is going to be removed, the IP instances that are 1173 // currently using it will be destroyed. 1006 1174 // 1007 1175 Ip6RemoveAddr ( 1008 NULL,1009 & CurrentSourceList,1010 & CurrentSourceCount,1176 IpSb, 1177 &IpIf->AddressList, 1178 &IpIf->AddressCount, 1011 1179 &CurrentAddrInfo->Address, 1012 1180 128 … … 1014 1182 1015 1183 // 1016 // This manual address is already in use, see whether prefix length is changed. 1017 // 1018 if (NewAddress->PrefixLength != CurrentAddrInfo->PrefixLength) { 1019 // 1020 // Remove the on-link prefix table, the route entry will be removed 1021 // implicitly. 1022 // 1023 PrefixEntry = Ip6FindPrefixListEntry ( 1024 IpSb, 1025 TRUE, 1026 CurrentAddrInfo->PrefixLength, 1027 &CurrentAddrInfo->Address 1028 ); 1029 if (PrefixEntry != NULL) { 1030 Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); 1031 } 1032 1033 // 1034 // Save the prefix length. 1035 // 1036 CurrentAddrInfo->PrefixLength = NewAddress->PrefixLength; 1037 IsUpdated = TRUE; 1038 } 1039 1040 // 1041 // create a new on-link prefix entry. 1184 // Remove the on-link prefix table, the route entry will be removed 1185 // implicitly. 1042 1186 // 1043 1187 PrefixEntry = Ip6FindPrefixListEntry ( 1044 1188 IpSb, 1045 1189 TRUE, 1046 NewAddress->PrefixLength,1047 & NewAddress->Address1190 CurrentAddrInfo->PrefixLength, 1191 &CurrentAddrInfo->Address 1048 1192 ); 1049 if (PrefixEntry == NULL) { 1050 Ip6CreatePrefixListEntry ( 1051 IpSb, 1052 TRUE, 1053 (UINT32) IP6_INFINIT_LIFETIME, 1054 (UINT32) IP6_INFINIT_LIFETIME, 1055 NewAddress->PrefixLength, 1056 &NewAddress->Address 1057 ); 1058 } 1059 1060 CurrentAddrInfo->IsAnycast = NewAddress->IsAnycast; 1061 // 1062 // Artificially mark this address passed DAD be'coz it is already in use. 1063 // 1064 Ip6ManualAddrDadCallback (TRUE, &NewAddress->Address, Instance); 1193 if (PrefixEntry != NULL) { 1194 Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); 1195 } 1196 1197 RemoveEntryList (&CurrentAddrInfo->Link); 1198 FreePool (CurrentAddrInfo); 1199 } 1200 1201 if (IsUpdated) { 1202 if (DataItem->Status == EFI_NOT_READY) { 1203 // 1204 // If DAD is disabled on this interface, the configuration process is 1205 // actually synchronous, and the data item's status will be changed to 1206 // the final status before we reach here, just check it. 1207 // 1208 Status = EFI_NOT_READY; 1209 } else { 1210 Status = EFI_SUCCESS; 1211 } 1065 1212 } else { 1066 1213 // 1067 // A new address. 1068 // 1069 IsUpdated = TRUE; 1070 1071 // 1072 // Set the new address, this will trigger DAD and activate the address if 1073 // DAD succeeds. 1074 // 1075 Ip6SetAddress ( 1076 IpSb->DefaultInterface, 1077 &NewAddress->Address, 1078 NewAddress->IsAnycast, 1079 NewAddress->PrefixLength, 1214 // No update is taken, reset the status to success and return EFI_ABORTED. 1215 // 1216 DataItem->Status = EFI_SUCCESS; 1217 Status = EFI_ABORTED; 1218 } 1219 } else { 1220 // 1221 // DataSize is 0 and Data is NULL, clean up the manual address. 1222 // 1223 if (DataItem->Data.Ptr != NULL) { 1224 FreePool (DataItem->Data.Ptr); 1225 } 1226 DataItem->Data.Ptr = NULL; 1227 DataItem->DataSize = 0; 1228 DataItem->Status = EFI_NOT_FOUND; 1229 1230 Ip6CleanDefaultRouterList (IpSb); 1231 Ip6CleanPrefixListTable (IpSb, &IpSb->OnlinkPrefix); 1232 Ip6CleanPrefixListTable (IpSb, &IpSb->AutonomousPrefix); 1233 Ip6CleanAssembleTable (&IpSb->Assemble); 1234 1235 if (IpSb->LinkLocalOk) { 1236 Ip6CreatePrefixListEntry ( 1237 IpSb, 1238 TRUE, 1080 1239 (UINT32) IP6_INFINIT_LIFETIME, 1081 1240 (UINT32) IP6_INFINIT_LIFETIME, 1082 I p6ManualAddrDadCallback,1083 Instance1241 IP6_LINK_LOCAL_PREFIX_LENGTH, 1242 &IpSb->LinkLocalAddr 1084 1243 ); 1085 1244 } 1086 } 1087 1088 // 1089 // Check the CurrentSourceList, it now contains those addresses currently in 1090 // use and will be removed. 1091 // 1092 IpIf = IpSb->DefaultInterface; 1093 1094 while (!IsListEmpty (&CurrentSourceList)) { 1095 IsUpdated = TRUE; 1096 1097 CurrentAddrInfo = NET_LIST_HEAD (&CurrentSourceList, IP6_ADDRESS_INFO, Link); 1098 1099 // 1100 // This local address is going to be removed, the IP instances that are 1101 // currently using it will be destroyed. 1102 // 1245 1103 1246 Ip6RemoveAddr ( 1104 1247 IpSb, 1105 &Ip If->AddressList,1106 &Ip If->AddressCount,1107 &CurrentAddrInfo->Address,1108 1281248 &IpSb->DefaultInterface->AddressList, 1249 &IpSb->DefaultInterface->AddressCount, 1250 NULL, 1251 0 1109 1252 ); 1110 1253 1111 // 1112 // Remove the on-link prefix table, the route entry will be removed 1113 // implicitly. 1114 // 1115 PrefixEntry = Ip6FindPrefixListEntry ( 1116 IpSb, 1117 TRUE, 1118 CurrentAddrInfo->PrefixLength, 1119 &CurrentAddrInfo->Address 1120 ); 1121 if (PrefixEntry != NULL) { 1122 Ip6DestroyPrefixListEntry (IpSb, PrefixEntry, TRUE, FALSE); 1123 } 1124 1125 RemoveEntryList (&CurrentAddrInfo->Link); 1126 FreePool (CurrentAddrInfo); 1127 } 1128 1129 if (IsUpdated) { 1130 if (DataItem->Status == EFI_NOT_READY) { 1131 // 1132 // If DAD is disabled on this interface, the configuration process is 1133 // actually synchronous, and the data item's status will be changed to 1134 // the final status before we reach here, just check it. 1135 // 1136 Status = EFI_NOT_READY; 1137 } else { 1138 Status = EFI_SUCCESS; 1139 } 1140 } else { 1141 // 1142 // No update is taken, reset the status to success and return EFI_ABORTED. 1143 // 1144 DataItem->Status = EFI_SUCCESS; 1145 Status = EFI_ABORTED; 1254 NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { 1255 // 1256 // Remove all pending delay node and DAD entries for the global addresses. 1257 // 1258 IpIf = NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INTERFACE_SIGNATURE); 1259 1260 NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DelayJoinList) { 1261 DelayNode = NET_LIST_USER_STRUCT (Entry2, IP6_DELAY_JOIN_LIST, Link); 1262 if (!NetIp6IsLinkLocalAddr (&DelayNode->AddressInfo->Address)) { 1263 RemoveEntryList (&DelayNode->Link); 1264 FreePool (DelayNode); 1265 } 1266 } 1267 1268 NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DupAddrDetectList) { 1269 DadEntry = NET_LIST_USER_STRUCT_S (Entry2, IP6_DAD_ENTRY, Link, IP6_DAD_ENTRY_SIGNATURE); 1270 1271 if (!NetIp6IsLinkLocalAddr (&DadEntry->AddressInfo->Address)) { 1272 // 1273 // Fail this DAD entry if the address is not link-local. 1274 // 1275 Ip6OnDADFinished (FALSE, IpIf, DadEntry); 1276 } 1277 } 1278 } 1146 1279 } 1147 1280 … … 1191 1324 VOID *Tmp; 1192 1325 1193 if ((DataSize % sizeof (EFI_IPv6_ADDRESS) != 0) || (DataSize == 0)) { 1326 OldGateway = NULL; 1327 NewGateway = NULL; 1328 Item = NULL; 1329 DefaultRouter = NULL; 1330 Tmp = NULL; 1331 OneRemoved = FALSE; 1332 OneAdded = FALSE; 1333 1334 if ((DataSize != 0) && (DataSize % sizeof (EFI_IPv6_ADDRESS) != 0)) { 1194 1335 return EFI_BAD_BUFFER_SIZE; 1195 1336 } … … 1197 1338 if (Instance->Policy != Ip6ConfigPolicyManual) { 1198 1339 return EFI_WRITE_PROTECTED; 1199 }1200 1201 NewGateway = (EFI_IPv6_ADDRESS *) Data;1202 NewGatewayCount = DataSize / sizeof (EFI_IPv6_ADDRESS);1203 for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {1204 1205 if (!NetIp6IsValidUnicast (NewGateway + Index1)) {1206 1207 return EFI_INVALID_PARAMETER;1208 }1209 1210 for (Index2 = Index1 + 1; Index2 < NewGatewayCount; Index2++) {1211 if (EFI_IP6_EQUAL (NewGateway + Index1, NewGateway + Index2)) {1212 return EFI_INVALID_PARAMETER;1213 }1214 }1215 1340 } 1216 1341 … … 1219 1344 OldGateway = Item->Data.Gateway; 1220 1345 OldGatewayCount = Item->DataSize / sizeof (EFI_IPv6_ADDRESS); 1221 OneRemoved = FALSE; 1222 OneAdded = FALSE; 1223 1224 if (NewGatewayCount != OldGatewayCount) { 1225 Tmp = AllocatePool (DataSize); 1226 if (Tmp == NULL) { 1227 return EFI_OUT_OF_RESOURCES; 1346 1347 for (Index1 = 0; Index1 < OldGatewayCount; Index1++) { 1348 // 1349 // Remove this default router. 1350 // 1351 DefaultRouter = Ip6FindDefaultRouter (IpSb, OldGateway + Index1); 1352 if (DefaultRouter != NULL) { 1353 Ip6DestroyDefaultRouter (IpSb, DefaultRouter); 1354 OneRemoved = TRUE; 1355 } 1356 } 1357 1358 if (Data != NULL && DataSize != 0) { 1359 NewGateway = (EFI_IPv6_ADDRESS *) Data; 1360 NewGatewayCount = DataSize / sizeof (EFI_IPv6_ADDRESS); 1361 for (Index1 = 0; Index1 < NewGatewayCount; Index1++) { 1362 1363 if (!NetIp6IsValidUnicast (NewGateway + Index1)) { 1364 1365 return EFI_INVALID_PARAMETER; 1366 } 1367 1368 for (Index2 = Index1 + 1; Index2 < NewGatewayCount; Index2++) { 1369 if (EFI_IP6_EQUAL (NewGateway + Index1, NewGateway + Index2)) { 1370 return EFI_INVALID_PARAMETER; 1371 } 1372 } 1373 } 1374 1375 if (NewGatewayCount != OldGatewayCount) { 1376 Tmp = AllocatePool (DataSize); 1377 if (Tmp == NULL) { 1378 return EFI_OUT_OF_RESOURCES; 1379 } 1380 } else { 1381 Tmp = NULL; 1382 } 1383 1384 for (Index1 = 0; Index1 < NewGatewayCount; Index1++) { 1385 1386 DefaultRouter = Ip6FindDefaultRouter (IpSb, NewGateway + Index1); 1387 if (DefaultRouter == NULL) { 1388 Ip6CreateDefaultRouter (IpSb, NewGateway + Index1, IP6_INF_ROUTER_LIFETIME); 1389 OneAdded = TRUE; 1390 } 1391 } 1392 1393 if (!OneRemoved && !OneAdded) { 1394 Item->Status = EFI_SUCCESS; 1395 return EFI_ABORTED; 1396 } else { 1397 1398 if (Tmp != NULL) { 1399 if (Item->Data.Ptr != NULL) { 1400 FreePool (Item->Data.Ptr); 1401 } 1402 Item->Data.Ptr = Tmp; 1403 } 1404 1405 CopyMem (Item->Data.Ptr, Data, DataSize); 1406 Item->DataSize = DataSize; 1407 Item->Status = EFI_SUCCESS; 1408 return EFI_SUCCESS; 1228 1409 } 1229 1410 } else { 1230 Tmp = NULL; 1231 } 1232 1233 for (Index1 = 0; Index1 < OldGatewayCount; Index1++) { 1234 // 1235 // Find the gateways that are no long in the new setting and remove them. 1236 // 1237 for (Index2 = 0; Index2 < NewGatewayCount; Index2++) { 1238 if (EFI_IP6_EQUAL (OldGateway + Index1, NewGateway + Index2)) { 1239 OneRemoved = TRUE; 1240 break; 1241 } 1242 } 1243 1244 if (Index2 == NewGatewayCount) { 1245 // 1246 // Remove this default router. 1247 // 1248 DefaultRouter = Ip6FindDefaultRouter (IpSb, OldGateway + Index1); 1249 if (DefaultRouter != NULL) { 1250 Ip6DestroyDefaultRouter (IpSb, DefaultRouter); 1251 } 1252 } 1253 } 1254 1255 for (Index1 = 0; Index1 < NewGatewayCount; Index1++) { 1256 1257 DefaultRouter = Ip6FindDefaultRouter (IpSb, NewGateway + Index1); 1258 if (DefaultRouter == NULL) { 1259 Ip6CreateDefaultRouter (IpSb, NewGateway + Index1, IP6_INF_ROUTER_LIFETIME); 1260 OneAdded = TRUE; 1261 } 1262 } 1263 1264 if (!OneRemoved && !OneAdded) { 1265 Item->Status = EFI_SUCCESS; 1266 return EFI_ABORTED; 1267 } else { 1268 1269 if (Tmp != NULL) { 1270 if (Item->Data.Ptr != NULL) { 1271 FreePool (Item->Data.Ptr); 1272 } 1273 Item->Data.Ptr = Tmp; 1274 } 1275 1276 CopyMem (Item->Data.Ptr, Data, DataSize); 1277 Item->DataSize = DataSize; 1278 Item->Status = EFI_SUCCESS; 1279 return EFI_SUCCESS; 1280 } 1411 // 1412 // DataSize is 0 and Data is NULL, clean up the Gateway address. 1413 // 1414 if (Item->Data.Ptr != NULL) { 1415 FreePool (Item->Data.Ptr); 1416 } 1417 Item->Data.Ptr = NULL; 1418 Item->DataSize = 0; 1419 Item->Status = EFI_NOT_FOUND; 1420 } 1421 1422 return EFI_SUCCESS; 1281 1423 } 1282 1424 … … 1312 1454 UINTN OldIndex; 1313 1455 UINTN NewIndex; 1314 UINTN Index1;1315 1456 EFI_IPv6_ADDRESS *OldDns; 1316 1457 EFI_IPv6_ADDRESS *NewDns; … … 1321 1462 VOID *Tmp; 1322 1463 1323 if ((DataSize % sizeof (EFI_IPv6_ADDRESS) != 0) || (DataSize == 0)) { 1464 OldDns = NULL; 1465 NewDns = NULL; 1466 Item = NULL; 1467 Tmp = NULL; 1468 1469 if ((DataSize != 0) && (DataSize % sizeof (EFI_IPv6_ADDRESS) != 0)) { 1324 1470 return EFI_BAD_BUFFER_SIZE; 1325 1471 } … … 1329 1475 } 1330 1476 1331 Item = &Instance->DataItem[Ip6ConfigDataTypeDnsServer]; 1332 NewDns = (EFI_IPv6_ADDRESS *) Data; 1333 OldDns = Item->Data.DnsServers; 1334 NewDnsCount = DataSize / sizeof (EFI_IPv6_ADDRESS); 1335 OldDnsCount = Item->DataSize / sizeof (EFI_IPv6_ADDRESS); 1336 OneAdded = FALSE; 1337 1338 if (NewDnsCount != OldDnsCount) { 1339 Tmp = AllocatePool (DataSize); 1340 if (Tmp == NULL) { 1341 return EFI_OUT_OF_RESOURCES; 1342 } 1343 } else { 1344 Tmp = NULL; 1345 } 1346 1347 for (NewIndex = 0; NewIndex < NewDnsCount; NewIndex++) { 1348 1349 if (!NetIp6IsValidUnicast (NewDns + NewIndex)) { 1350 // 1351 // The dns server address must be unicast. 1352 // 1353 FreePool (Tmp); 1354 return EFI_INVALID_PARAMETER; 1355 } 1356 1357 for (Index1 = NewIndex + 1; Index1 < NewDnsCount; Index1++) { 1358 if (EFI_IP6_EQUAL (NewDns + NewIndex, NewDns + Index1)) { 1359 FreePool (Tmp); 1477 Item = &Instance->DataItem[Ip6ConfigDataTypeDnsServer]; 1478 1479 if (Data != NULL && DataSize != 0) { 1480 NewDns = (EFI_IPv6_ADDRESS *) Data; 1481 OldDns = Item->Data.DnsServers; 1482 NewDnsCount = DataSize / sizeof (EFI_IPv6_ADDRESS); 1483 OldDnsCount = Item->DataSize / sizeof (EFI_IPv6_ADDRESS); 1484 OneAdded = FALSE; 1485 1486 if (NewDnsCount != OldDnsCount) { 1487 Tmp = AllocatePool (DataSize); 1488 if (Tmp == NULL) { 1489 return EFI_OUT_OF_RESOURCES; 1490 } 1491 } else { 1492 Tmp = NULL; 1493 } 1494 1495 for (NewIndex = 0; NewIndex < NewDnsCount; NewIndex++) { 1496 1497 if (!NetIp6IsValidUnicast (NewDns + NewIndex)) { 1498 // 1499 // The dns server address must be unicast. 1500 // 1501 if (Tmp != NULL) { 1502 FreePool (Tmp); 1503 } 1360 1504 return EFI_INVALID_PARAMETER; 1361 1505 } 1362 } 1363 1364 if (OneAdded) { 1365 // 1366 // If any address in the new setting is not in the old settings, skip the 1367 // comparision below. 1368 // 1369 continue; 1370 } 1371 1372 for (OldIndex = 0; OldIndex < OldDnsCount; OldIndex++) { 1373 if (EFI_IP6_EQUAL (NewDns + NewIndex, OldDns + OldIndex)) { 1374 // 1375 // If found break out. 1376 // 1377 break; 1378 } 1379 } 1380 1381 if (OldIndex == OldDnsCount) { 1382 OneAdded = TRUE; 1383 } 1384 } 1385 1386 if (!OneAdded && (DataSize == Item->DataSize)) { 1387 // 1388 // No new item is added and the size is the same. 1389 // 1390 Item->Status = EFI_SUCCESS; 1391 return EFI_ABORTED; 1392 } else { 1393 if (Tmp != NULL) { 1394 if (Item->Data.Ptr != NULL) { 1395 FreePool (Item->Data.Ptr); 1396 } 1397 Item->Data.Ptr = Tmp; 1398 } 1399 1400 CopyMem (Item->Data.Ptr, Data, DataSize); 1401 Item->DataSize = DataSize; 1402 Item->Status = EFI_SUCCESS; 1403 return EFI_SUCCESS; 1404 } 1506 1507 if (OneAdded) { 1508 // 1509 // If any address in the new setting is not in the old settings, skip the 1510 // comparision below. 1511 // 1512 continue; 1513 } 1514 1515 for (OldIndex = 0; OldIndex < OldDnsCount; OldIndex++) { 1516 if (EFI_IP6_EQUAL (NewDns + NewIndex, OldDns + OldIndex)) { 1517 // 1518 // If found break out. 1519 // 1520 break; 1521 } 1522 } 1523 1524 if (OldIndex == OldDnsCount) { 1525 OneAdded = TRUE; 1526 } 1527 } 1528 1529 if (!OneAdded && (DataSize == Item->DataSize)) { 1530 // 1531 // No new item is added and the size is the same. 1532 // 1533 Item->Status = EFI_SUCCESS; 1534 return EFI_ABORTED; 1535 } else { 1536 if (Tmp != NULL) { 1537 if (Item->Data.Ptr != NULL) { 1538 FreePool (Item->Data.Ptr); 1539 } 1540 Item->Data.Ptr = Tmp; 1541 } 1542 1543 CopyMem (Item->Data.Ptr, Data, DataSize); 1544 Item->DataSize = DataSize; 1545 Item->Status = EFI_SUCCESS; 1546 } 1547 } else { 1548 // 1549 // DataSize is 0 and Data is NULL, clean up the DnsServer address. 1550 // 1551 if (Item->Data.Ptr != NULL) { 1552 FreePool (Item->Data.Ptr); 1553 } 1554 Item->Data.Ptr = NULL; 1555 Item->DataSize = 0; 1556 Item->Status = EFI_NOT_FOUND; 1557 } 1558 1559 return EFI_SUCCESS; 1405 1560 } 1406 1561 … … 1419 1574 ) 1420 1575 { 1421 IfInfo->Name[0] = L'e'; 1422 IfInfo->Name[1] = L't'; 1423 IfInfo->Name[2] = L'h'; 1424 IfInfo->Name[3] = (CHAR16) (L'0' + IpSb->Ip6ConfigInstance.IfIndex); 1425 IfInfo->Name[4] = 0; 1576 UnicodeSPrint ( 1577 IfInfo->Name, 1578 sizeof (IfInfo->Name), 1579 L"eth%d", 1580 IpSb->Ip6ConfigInstance.IfIndex 1581 ); 1426 1582 1427 1583 IfInfo->IfType = IpSb->SnpMode.IfType; … … 1492 1648 OpCode = NTOHS (OpCode); 1493 1649 1494 if (OpCode == IP6_CONFIG_DHCP6_OPTION_DNS_SERVERS) {1650 if (OpCode == DHCP6_OPT_DNS_SERVERS) { 1495 1651 CopyMem (&Length, &OptList[Index]->OpLen, sizeof (Length)); 1496 1652 Length = NTOHS (Length); … … 1595 1751 // Decline those duplicates. 1596 1752 // 1597 Instance->Dhcp6->Decline ( 1598 Instance->Dhcp6, 1599 Instance->DeclineAddressCount, 1600 Instance->DeclineAddress 1601 ); 1753 if (Instance->Dhcp6 != NULL) { 1754 Instance->Dhcp6->Decline ( 1755 Instance->Dhcp6, 1756 Instance->DeclineAddressCount, 1757 Instance->DeclineAddress 1758 ); 1759 } 1602 1760 } 1603 1761 … … 1808 1966 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: 1809 1967 - This is NULL. 1810 - Data is NULL. 1811 - One or more fields in Data do not match the requirement of the 1812 data type indicated by DataType. 1968 - One or more fields in Data and DataSizedo not match the 1969 requirement of the data type indicated by DataType. 1813 1970 @retval EFI_WRITE_PROTECTED The specified configuration data is read-only or the specified 1814 1971 configuration data cannot be set under the current policy. … … 1838 1995 IP6_SERVICE *IpSb; 1839 1996 1840 if ((This == NULL) || (Data == NULL )) {1997 if ((This == NULL) || (Data == NULL && DataSize != 0) || (Data != NULL && DataSize == 0)) { 1841 1998 return EFI_INVALID_PARAMETER; 1842 1999 } … … 2191 2348 DataItem->Data.Ptr = &Instance->Policy; 2192 2349 DataItem->DataSize = sizeof (Instance->Policy); 2193 Instance->Policy = Ip6ConfigPolicy Automatic;2350 Instance->Policy = Ip6ConfigPolicyManual; 2194 2351 SET_DATA_ATTRIB (DataItem->Attribute, DATA_ATTRIB_SIZE_FIXED); 2195 2352 … … 2202 2359 2203 2360 DataItem = &Instance->DataItem[Ip6ConfigDataTypeManualAddress]; 2204 DataItem->SetData = Ip6ConfigSetMa unualAddress;2361 DataItem->SetData = Ip6ConfigSetManualAddress; 2205 2362 DataItem->Status = EFI_NOT_FOUND; 2206 2363 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.h
r58466 r77662 2 2 Definitions for EFI IPv6 Configuartion Protocol implementation. 3 3 4 Copyright (c) 2009 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 22 22 23 23 #define IP6_CONFIG_DEFAULT_DAD_XMITS 1 24 #define IP6_CONFIG_DHCP6_OPTION_ORO 625 #define IP6_CONFIG_DHCP6_OPTION_DNS_SERVERS 2326 24 27 25 #define DATA_ATTRIB_SIZE_FIXED 0x1 … … 217 215 218 216 /** 217 Read the configuration data from variable storage according to the VarName and 218 gEfiIp6ConfigProtocolGuid. It checks the integrity of variable data. If the 219 data is corrupted, it clears the variable data to ZERO. Othewise, it outputs the 220 configuration data to IP6_CONFIG_INSTANCE. 221 222 @param[in] VarName The pointer to the variable name 223 @param[in, out] Instance The pointer to the IP6 config instance data. 224 225 @retval EFI_NOT_FOUND The variable can not be found or already corrupted. 226 @retval EFI_OUT_OF_RESOURCES Fail to allocate resource to complete the operation. 227 @retval EFI_SUCCESS The configuration data was retrieved successfully. 228 229 **/ 230 EFI_STATUS 231 Ip6ConfigReadConfigData ( 232 IN CHAR16 *VarName, 233 IN OUT IP6_CONFIG_INSTANCE *Instance 234 ); 235 236 /** 219 237 The event process routine when the DHCPv6 server is answered with a reply packet 220 238 for an information request. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Driver.c
r58466 r77662 2 2 The driver binding and service binding protocol for IP6 driver. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 6 6 7 This program and the accompanying materials … … 25 26 }; 26 27 28 BOOLEAN mIpSec2Installed = FALSE; 29 30 /** 31 Callback function for IpSec2 Protocol install. 32 33 @param[in] Event Event whose notification function is being invoked 34 @param[in] Context Pointer to the notification function's context 35 36 **/ 37 VOID 38 EFIAPI 39 IpSec2InstalledCallback ( 40 IN EFI_EVENT Event, 41 IN VOID *Context 42 ) 43 { 44 EFI_STATUS Status; 45 // 46 // Test if protocol was even found. 47 // Notification function will be called at least once. 48 // 49 Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec); 50 if (Status == EFI_SUCCESS && mIpSec != NULL) { 51 // 52 // Close the event so it does not get called again. 53 // 54 gBS->CloseEvent (Event); 55 56 mIpSec2Installed = TRUE; 57 } 58 } 59 27 60 /** 28 61 This is the declaration of an EFI image entry point. This entry point is … … 47 80 ) 48 81 { 82 VOID *Registration; 83 84 EfiCreateProtocolNotifyEvent ( 85 &gEfiIpSec2ProtocolGuid, 86 TPL_CALLBACK, 87 IpSec2InstalledCallback, 88 NULL, 89 &Registration 90 ); 91 49 92 return EfiLibInstallDriverBindingComponentName2 ( 50 93 ImageHandle, … … 112 155 EFI_IPv6_ADDRESS AllNodes; 113 156 IP6_NEIGHBOR_ENTRY *NeighborCache; 157 158 IpSb->State = IP6_SERVICE_DESTROY; 159 160 if (IpSb->Timer != NULL) { 161 gBS->SetTimer (IpSb->Timer, TimerCancel, 0); 162 gBS->CloseEvent (IpSb->Timer); 163 164 IpSb->Timer = NULL; 165 } 166 167 if (IpSb->FasterTimer != NULL) { 168 gBS->SetTimer (IpSb->FasterTimer, TimerCancel, 0); 169 gBS->CloseEvent (IpSb->FasterTimer); 170 171 IpSb->FasterTimer = NULL; 172 } 114 173 115 174 Ip6ConfigCleanInstance (&IpSb->Ip6ConfigInstance); … … 178 237 } 179 238 180 if (IpSb->Timer != NULL) {181 gBS->SetTimer (IpSb->Timer, TimerCancel, 0);182 gBS->CloseEvent (IpSb->Timer);183 184 IpSb->Timer = NULL;185 }186 187 if (IpSb->FasterTimer != NULL) {188 gBS->SetTimer (IpSb->FasterTimer, TimerCancel, 0);189 gBS->CloseEvent (IpSb->FasterTimer);190 191 IpSb->FasterTimer = NULL;192 }193 239 // 194 240 // Free the Neighbor Discovery resources … … 226 272 EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken; 227 273 EFI_MANAGED_NETWORK_CONFIG_DATA *Config; 228 IP6_CONFIG_DATA_ITEM *DataItem;229 274 230 275 ASSERT (Service != NULL); … … 440 485 } 441 486 442 //443 // If there is any manual address, set it.444 //445 DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeManualAddress];446 if (DataItem->Data.Ptr != NULL) {447 DataItem->SetData (448 &IpSb->Ip6ConfigInstance,449 DataItem->DataSize,450 DataItem->Data.Ptr451 );452 }453 454 //455 // If there is any gateway address, set it.456 //457 DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeGateway];458 if (DataItem->Data.Ptr != NULL) {459 DataItem->SetData (460 &IpSb->Ip6ConfigInstance,461 DataItem->DataSize,462 DataItem->Data.Ptr463 );464 }465 466 487 InsertHeadList (&IpSb->Interfaces, &IpSb->DefaultInterface->Link); 467 488 … … 499 520 IP6_SERVICE *IpSb; 500 521 EFI_STATUS Status; 522 EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; 523 IP6_CONFIG_DATA_ITEM *DataItem; 524 525 IpSb = NULL; 526 Ip6Cfg = NULL; 527 DataItem = NULL; 501 528 502 529 // … … 524 551 ASSERT (IpSb != NULL); 525 552 553 Ip6Cfg = &IpSb->Ip6ConfigInstance.Ip6Config; 554 526 555 // 527 556 // Install the Ip6ServiceBinding Protocol onto ControlerHandle … … 532 561 &IpSb->ServiceBinding, 533 562 &gEfiIp6ConfigProtocolGuid, 534 &IpSb->Ip6ConfigInstance.Ip6Config,563 Ip6Cfg, 535 564 NULL 536 565 ); 537 538 if (!EFI_ERROR (Status)) { 539 // 540 // ready to go: start the receiving and timer 541 // 542 Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb); 543 if (EFI_ERROR (Status)) { 566 if (EFI_ERROR (Status)) { 567 goto ON_ERROR; 568 } 569 570 // 571 // Read the config data from NV variable again. 572 // The default data can be changed by other drivers. 573 // 574 Status = Ip6ConfigReadConfigData (IpSb->MacString, &IpSb->Ip6ConfigInstance); 575 if (EFI_ERROR (Status)) { 576 goto ON_ERROR; 577 } 578 579 // 580 // If there is any default manual address, set it. 581 // 582 DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeManualAddress]; 583 if (DataItem->Data.Ptr != NULL) { 584 Status = Ip6Cfg->SetData ( 585 Ip6Cfg, 586 Ip6ConfigDataTypeManualAddress, 587 DataItem->DataSize, 588 DataItem->Data.Ptr 589 ); 590 if (EFI_ERROR(Status) && Status != EFI_NOT_READY) { 544 591 goto ON_ERROR; 545 592 } 546 547 // 548 // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds. 549 // 550 Status = gBS->SetTimer ( 551 IpSb->FasterTimer, 552 TimerPeriodic, 553 TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS 554 ); 555 if (EFI_ERROR (Status)) { 593 } 594 595 // 596 // If there is any default gateway address, set it. 597 // 598 DataItem = &IpSb->Ip6ConfigInstance.DataItem[Ip6ConfigDataTypeGateway]; 599 if (DataItem->Data.Ptr != NULL) { 600 Status = Ip6Cfg->SetData ( 601 Ip6Cfg, 602 Ip6ConfigDataTypeGateway, 603 DataItem->DataSize, 604 DataItem->Data.Ptr 605 ); 606 if (EFI_ERROR(Status)) { 556 607 goto ON_ERROR; 557 608 } 558 559 // 560 // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds. 561 // 562 Status = gBS->SetTimer ( 563 IpSb->Timer, 564 TimerPeriodic, 565 TICKS_PER_MS * IP6_ONE_SECOND_IN_MS 566 ); 567 if (EFI_ERROR (Status)) { 568 goto ON_ERROR; 569 } 570 571 // 572 // Initialize the IP6 ID 573 // 574 mIp6Id = NET_RANDOM (NetRandomInitSeed ()); 575 576 return EFI_SUCCESS; 577 } 609 } 610 611 // 612 // ready to go: start the receiving and timer 613 // 614 Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb); 615 if (EFI_ERROR (Status)) { 616 goto ON_ERROR; 617 } 618 619 // 620 // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds. 621 // 622 Status = gBS->SetTimer ( 623 IpSb->FasterTimer, 624 TimerPeriodic, 625 TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS 626 ); 627 if (EFI_ERROR (Status)) { 628 goto ON_ERROR; 629 } 630 631 // 632 // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds. 633 // 634 Status = gBS->SetTimer ( 635 IpSb->Timer, 636 TimerPeriodic, 637 TICKS_PER_MS * IP6_ONE_SECOND_IN_MS 638 ); 639 if (EFI_ERROR (Status)) { 640 goto ON_ERROR; 641 } 642 643 // 644 // Initialize the IP6 ID 645 // 646 mIp6Id = NET_RANDOM (NetRandomInitSeed ()); 647 648 return EFI_SUCCESS; 578 649 579 650 ON_ERROR: … … 698 769 } else if (IsListEmpty (&IpSb->Children)) { 699 770 State = IpSb->State; 700 IpSb->State = IP6_SERVICE_DESTROY;701 702 771 Status = Ip6CleanService (IpSb); 703 772 if (EFI_ERROR (Status)) { … … 734 803 735 804 @retval EFI_SUCCES The child handle was created with the I/O services. 736 @retval EFI_OUT_OF_RESOURCES There are not enough resources availab e to create805 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create 737 806 the child. 738 807 @retval other The child handle was not created. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Driver.h
r58459 r77662 2 2 The driver binding and service binding protocol for IP6 driver. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 142 142 143 143 // 144 // Function p tototypes for the ServiceBinding Prococol144 // Function prototypes for the ServiceBinding Protocol 145 145 // 146 146 … … 155 155 156 156 @retval EFI_SUCCES The child handle was created with the I/O services. 157 @retval EFI_OUT_OF_RESOURCES There are not enough resources availab e to create157 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create 158 158 the child. 159 159 @retval other The child handle was not created. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Dxe.inf
r58466 r77662 8 8 # the EFI IPv6 network stack. 9 9 # 10 # Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>10 # Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 11 11 # 12 12 # This program and the accompanying materials -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Dxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Basic IPv6 packet I/O Service. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6DxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Ip6Dxe Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6DxeStrings.uni
r58466 r77662 1 /** @file1 /** @file 2 2 String definitions for IP6 configuration. 3 3 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Icmp.c
r48674 r77662 2 2 The ICMPv6 handle routines to process the ICMPv6 control messages. 3 3 4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> 5 6 6 7 This program and the accompanying materials … … 473 474 UINT8 Value; 474 475 475 ASSERT ((Prefix != NULL) && (PrefixLength < IP6_PREFIX_ NUM));476 ASSERT ((Prefix != NULL) && (PrefixLength < IP6_PREFIX_MAX)); 476 477 477 478 if (PrefixLength == 0) { … … 480 481 } 481 482 482 if (PrefixLength == IP6_PREFIX_NUM - 1) {483 if (PrefixLength >= IP6_PREFIX_MAX) { 483 484 return ; 484 485 } … … 488 489 Value = Prefix->Addr[Byte]; 489 490 490 if ( (Byte > 0) && (Byte < 16)) {491 if (Byte > 0) { 491 492 ZeroMem (Prefix->Addr + Byte, 16 - Byte); 492 493 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Impl.c
r58459 r77662 2 2 Implementation of EFI_IP6_PROTOCOL protocol interfaces. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 842 843 IP6_SERVICE *IpSb; 843 844 844 if ((This == NULL) || (PrefixLength > = IP6_PREFIX_NUM)) {845 if ((This == NULL) || (PrefixLength > IP6_PREFIX_MAX)) { 845 846 return EFI_INVALID_PARAMETER; 846 847 } … … 1762 1763 { 1763 1764 IP6_PROTOCOL *IpInstance; 1764 IP6_SERVICE *IpSb;1765 1765 EFI_STATUS Status; 1766 1766 EFI_TPL OldTpl; … … 1771 1771 1772 1772 IpInstance = IP6_INSTANCE_FROM_PROTOCOL (This); 1773 IpSb = IpInstance->Service;1774 1773 1775 1774 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Impl.h
r58459 r77662 2 2 Implementation of EFI_IP6_PROTOCOL protocol interfaces and type definitions. 3 3 4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 6 6 7 This program and the accompanying materials … … 18 19 19 20 #include <Uefi.h> 21 22 #include <IndustryStandard/Dhcp.h> 20 23 21 24 #include <Protocol/ServiceBinding.h> … … 90 93 91 94 extern EFI_IPSEC2_PROTOCOL *mIpSec; 95 extern BOOLEAN mIpSec2Installed; 92 96 93 97 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Input.c
r58466 r77662 2 2 IP6 internal functions to process the incoming packets. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 6 6 7 This program and the accompanying materials … … 526 527 527 528 Status = EFI_SUCCESS; 529 530 if (!mIpSec2Installed) { 531 goto ON_EXIT; 532 } 533 ASSERT (mIpSec != NULL); 534 528 535 Packet = *Netbuf; 529 536 RecycleEvent = NULL; … … 535 542 FragmentCount = Packet->BlockOpNum; 536 543 ZeroMem (&ZeroHead, sizeof (EFI_IP6_HEADER)); 537 538 if (mIpSec == NULL) {539 gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **) &mIpSec);540 541 //542 // Check whether the ipsec protocol is available.543 //544 if (mIpSec == NULL) {545 goto ON_EXIT;546 }547 }548 544 549 545 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Nd.c
r58466 r77662 2 2 Implementation of Neighbor Discovery support routines. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 199 199 IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry; 200 200 201 if (Prefix == NULL || PreferredLifetime > ValidLifetime || PrefixLength > = IP6_PREFIX_NUM) {201 if (Prefix == NULL || PreferredLifetime > ValidLifetime || PrefixLength > IP6_PREFIX_MAX) { 202 202 return NULL; 203 203 } … … 854 854 // 855 855 Oro = (EFI_DHCP6_PACKET_OPTION *) OptBuf; 856 Oro->OpCode = HTONS ( IP6_CONFIG_DHCP6_OPTION_ORO);856 Oro->OpCode = HTONS (DHCP6_OPT_ORO); 857 857 Oro->OpLen = HTONS (2); 858 *((UINT16 *) &Oro->Data[0]) = HTONS ( IP6_CONFIG_DHCP6_OPTION_DNS_SERVERS);858 *((UINT16 *) &Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS); 859 859 860 860 InfoReqReXmit.Irt = 4; … … 982 982 NET_CHECK_SIGNATURE (IpIf, IP6_INTERFACE_SIGNATURE); 983 983 ASSERT (AddressInfo != NULL); 984 985 // 986 // Do nothing if we have already started DAD on the address. 987 // 988 if (Ip6FindDADEntry (IpIf->Service, &AddressInfo->Address, NULL) != NULL) { 989 return EFI_SUCCESS; 990 } 984 991 985 992 Status = EFI_SUCCESS; … … 1578 1585 DupAddrDetect = Ip6FindDADEntry (IpSb, &Target, &IpIf); 1579 1586 if (DupAddrDetect != NULL) { 1580 if (DupAddrDetect->Transmit == 0) {1581 //1582 // The NS is from another node to performing DAD on the same address since1583 // we haven't send out any NS yet. Fail DAD for the tentative address.1584 //1585 Ip6OnDADFinished (FALSE, IpIf, DupAddrDetect);1586 Status = EFI_ICMP_ERROR;1587 goto Exit;1588 }1589 1590 1587 // 1591 1588 // Check the MAC address of the incoming packet. … … 2864 2861 Flag = FALSE; 2865 2862 if ((DupAddrDetect->Receive == 0) || 2866 (DupAddrDetect->Transmit == DupAddrDetect->Receive)) {2863 (DupAddrDetect->Transmit <= DupAddrDetect->Receive)) { 2867 2864 Flag = TRUE; 2868 2865 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Option.c
r48674 r77662 19 19 Validate the IP6 option format for both the packets we received 20 20 and that we will transmit. It will compute the ICMPv6 error message fields 21 if the option is malformat ed.21 if the option is malformatted. 22 22 23 23 @param[in] IpSb The IP6 service data. … … 30 30 31 31 @retval TRUE The option is properly formatted. 32 @retval FALSE The option is malformat ed.32 @retval FALSE The option is malformatted. 33 33 34 34 **/ … … 127 127 128 128 @retval TRUE The option is properly formatted. 129 @retval FALSE The option is malformat ed.129 @retval FALSE The option is malformatted. 130 130 131 131 **/ … … 232 232 Validate the IP6 extension header format for both the packets we received 233 233 and that we will transmit. It will compute the ICMPv6 error message fields 234 if the option is mal-format ed.234 if the option is mal-formatted. 235 235 236 236 @param[in] IpSb The IP6 service instance. This is an optional parameter. … … 253 253 This is an optional parameter that may be NULL. 254 254 255 @retval TRUE The option is properly format ed.256 @retval FALSE The option is malformat ed.255 @retval TRUE The option is properly formatted. 256 @retval FALSE The option is malformatted. 257 257 258 258 **/ … … 437 437 // 438 438 // RFC2460, ICMP Parameter Problem message with code 0 should be sent 439 // if the length of a fragment is not a multiple of 8 octe cts and the M439 // if the length of a fragment is not a multiple of 8 octets and the M 440 440 // flag of that fragment is 1, pointing to the Payload length field of the 441 441 // fragment packet. … … 607 607 @param[in] FragmentOffset The fragment offset of the data following the header. 608 608 @param[out] UpdatedExtHdrs The updated ExtHdrs with Fragment header inserted. 609 It's caller's responsib lity to free this buffer.609 It's caller's responsibility to free this buffer. 610 610 611 611 @retval EFI_OUT_OF_RESOURCES Failed to finish the operation due to lake of -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Option.h
r48674 r77662 52 52 Validate the IP6 extension header format for both the packets we received 53 53 and that we will transmit. It will compute the ICMPv6 error message fields 54 if the option is mal-format ed.54 if the option is mal-formatted. 55 55 56 56 @param[in] IpSb The IP6 service instance. This is an optional parameter. … … 73 73 This is an optional parameter that may be NULL. 74 74 75 @retval TRUE The option is properly format ed.76 @retval FALSE The option is malformat ed.75 @retval TRUE The option is properly formatted. 76 @retval FALSE The option is malformatted. 77 77 78 78 **/ … … 123 123 @param[in] FragmentOffset The fragment offset of the data following the header. 124 124 @param[out] UpdatedExtHdrs The updated ExtHdrs with Fragment header inserted. 125 It's caller's responsib lity to free this buffer.125 It's caller's responsibility to free this buffer. 126 126 127 127 @retval EFI_OUT_OF_RESOURCES Failed to finish the operation due to lake of … … 180 180 181 181 @retval TRUE The option is properly formatted. 182 @retval FALSE The option is malformat ed.182 @retval FALSE The option is malformatted. 183 183 184 184 **/ -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Output.c
r58459 r77662 2 2 The internal functions and routines to transmit the IP6 packet. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 24 24 @param[in] IpSb Points to an IP6 service binding instance. 25 25 @param[out] SourceList The list entry head of all source addresses. 26 It is the caller's responsib lity to free the26 It is the caller's responsibility to free the 27 27 resources. 28 28 @param[out] SourceCount The number of source addresses. … … 92 92 93 93 /** 94 Ca culate how many bits are the same between two IPv6 addresses.94 Calculate how many bits are the same between two IPv6 addresses. 95 95 96 96 @param[in] AddressA Points to an IPv6 address. … … 365 365 @param[in] HeadLen The length of the unfragmented part of the IP6 header. 366 366 367 @retval EFI_BAD_BUFFER_SIZE There is no enough troom in the head space of367 @retval EFI_BAD_BUFFER_SIZE There is no enough room in the head space of 368 368 Packet. 369 369 @retval EFI_SUCCESS The operation performed successfully. … … 727 727 728 728 // 729 // Send out multicast neighbor solicitation for address resolution immediat ly.729 // Send out multicast neighbor solicitation for address resolution immediately. 730 730 // 731 731 Ip6CreateSNMulticastAddr (&NeighborCache->Neighbor, &Destination); … … 810 810 // OK, selected the source and route, fragment the packet then send 811 811 // them. Tag each fragment other than the first one as spawn from it. 812 // Each extension header is an integ ar multiple of 8 octets long, in812 // Each extension header is an integer multiple of 8 octets long, in 813 813 // order to retain 8-octet alignment for subsequent headers. 814 814 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Ip6Dxe/Ip6Route.c
r48674 r77662 2 2 The functions and routines to handle the route caches and route table. 3 3 4 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 136 136 RtEntry = NULL; 137 137 138 for (Index = IP6_PREFIX_ NUM - 1; Index >= 0; Index--) {138 for (Index = IP6_PREFIX_MAX; Index >= 0; Index--) { 139 139 NET_LIST_FOR_EACH (Entry, &RtTable->RouteArea[Index]) { 140 140 RtEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link); … … 301 301 Count = 0; 302 302 303 for (Index = IP6_PREFIX_ NUM - 1; Index >= 0; Index--) {303 for (Index = IP6_PREFIX_MAX; Index >= 0; Index--) { 304 304 305 305 NET_LIST_FOR_EACH (Entry, &(RouteTable->RouteArea[Index])) { … … 347 347 RtTable->TotalNum = 0; 348 348 349 for (Index = 0; Index < IP6_PREFIX_NUM; Index++) {349 for (Index = 0; Index <= IP6_PREFIX_MAX; Index++) { 350 350 InitializeListHead (&RtTable->RouteArea[Index]); 351 351 } … … 386 386 // Free all the route table entry and its route cache. 387 387 // 388 for (Index = 0; Index < IP6_PREFIX_NUM; Index++) {388 for (Index = 0; Index <= IP6_PREFIX_MAX; Index++) { 389 389 NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtTable->RouteArea[Index]) { 390 390 RtEntry = NET_LIST_USER_STRUCT (Entry, IP6_ROUTE_ENTRY, Link); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IkeCommon.c
r58466 r77662 2 2 Common operation of the IKE 3 3 4 Copyright (c) 2010 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 19 19 #include "IpSecDebug.h" 20 20 21 // 22 // Initial the SPI 23 // 24 UINT32 mNextSpi = IKE_SPI_BASE; 25 EFI_GUID mZeroGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } }; 21 /** 22 Check whether the new generated Spi has existed. 23 24 @param[in] IkeSaSession Pointer to the Child SA Session. 25 @param[in] SpiValue SPI Value. 26 27 @retval TRUE This SpiValue has existed in the Child SA Session 28 @retval FALSE This SpiValue doesn't exist in the Child SA Session. 29 30 **/ 31 BOOLEAN 32 IkeSpiValueExisted ( 33 IN IKEV2_SA_SESSION *IkeSaSession, 34 IN UINT32 SpiValue 35 ) 36 { 37 LIST_ENTRY *Entry; 38 LIST_ENTRY *Next; 39 IKEV2_CHILD_SA_SESSION *SaSession; 40 41 Entry = NULL; 42 Next = NULL; 43 SaSession = NULL; 44 45 // 46 // Check whether the SPI value has existed in ChildSaEstablishSessionList. 47 // 48 NET_LIST_FOR_EACH_SAFE (Entry, Next, &IkeSaSession->ChildSaEstablishSessionList) { 49 SaSession= IKEV2_CHILD_SA_SESSION_BY_IKE_SA (Entry); 50 if (SaSession->LocalPeerSpi == SpiValue) { 51 return TRUE; 52 } 53 } 54 55 // 56 // Check whether the SPI value has existed in ChildSaSessionList. 57 // 58 NET_LIST_FOR_EACH_SAFE (Entry, Next, &IkeSaSession->ChildSaSessionList) { 59 SaSession= IKEV2_CHILD_SA_SESSION_BY_IKE_SA (Entry); 60 if (SaSession->LocalPeerSpi == SpiValue) { 61 return TRUE; 62 } 63 } 64 65 return FALSE; 66 } 26 67 27 68 /** … … 161 202 Generate an new SPI. 162 203 163 @return a SPI in 4 bytes. 164 165 **/ 166 UINT32 204 @param[in] IkeSaSession Pointer to IKEV2_SA_SESSION related to this Child SA 205 Session. 206 @param[in, out] SpiValue Pointer to the new generated SPI value. 207 208 @retval EFI_SUCCESS The operation performs successfully. 209 @retval Otherwise The operation is failed. 210 211 **/ 212 EFI_STATUS 167 213 IkeGenerateSpi ( 168 VOID 169 ) 170 { 171 // 172 // TODO: should generate SPI randomly to avoid security issue 173 // 174 return mNextSpi++; 214 IN IKEV2_SA_SESSION *IkeSaSession, 215 IN OUT UINT32 *SpiValue 216 ) 217 { 218 EFI_STATUS Status; 219 220 Status = EFI_SUCCESS; 221 222 while (TRUE) { 223 // 224 // Generate SPI randomly 225 // 226 Status = IpSecCryptoIoGenerateRandomBytes ((UINT8 *)SpiValue, sizeof (UINT32)); 227 if (EFI_ERROR (Status)) { 228 break; 229 } 230 231 // 232 // The set of SPI values in the range 1 through 255 are reserved by the 233 // Internet Assigned Numbers Authority (IANA) for future use; a reserved 234 // SPI value will not normally be assigned by IANA unless the use of the 235 // assigned SPI value is specified in an RFC. 236 // 237 if (*SpiValue < IKE_SPI_BASE) { 238 *SpiValue += IKE_SPI_BASE; 239 } 240 241 // 242 // Check whether the new generated SPI has existed. 243 // 244 if (!IkeSpiValueExisted (IkeSaSession, *SpiValue)) { 245 break; 246 } 247 } 248 249 return Status; 175 250 } 176 251 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IkeCommon.h
r58466 r77662 2 2 Common operation of the IKE. 3 3 4 Copyright (c) 2010 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 19 19 #include <Protocol/Udp4.h> 20 20 #include <Protocol/Udp6.h> 21 #include <Protocol/Ip4Config .h>21 #include <Protocol/Ip4Config2.h> 22 22 23 23 #include <Library/BaseLib.h> … … 40 40 #define IKE_NONCE_SIZE 16 41 41 #define IKE_MAX_RETRY 4 42 #define IKE_SPI_BASE 0x100 0042 #define IKE_SPI_BASE 0x100 43 43 #define IKE_PAYLOAD_SIGNATURE SIGNATURE_32('I','K','E','P') 44 44 #define IKE_PAYLOAD_BY_PACKET(a) CR(a,IKE_PAYLOAD,ByPacket,IKE_PAYLOAD_SIGNATURE) … … 131 131 132 132 /** 133 Generate an unused SPI133 Generate an new SPI. 134 134 135 @return a SPI in 4 bytes. 135 @param[in] IkeSaSession Pointer to IKEV2_SA_SESSION related to this Child SA 136 Session. 137 @param[in, out] SpiValue Pointer to the new generated SPI value. 138 139 @retval EFI_SUCCESS The operation performs successfully. 140 @retval Otherwise The operation is failed. 136 141 137 142 **/ 138 UINT32 143 EFI_STATUS 139 144 IkeGenerateSpi ( 140 VOID 145 IN IKEV2_SA_SESSION *IkeSaSession, 146 IN OUT UINT32 *SpiValue 141 147 ); 142 148 … … 182 188 ); 183 189 184 extern EFI_GUID mZeroGuid;185 190 extern MODP_GROUP OakleyModpGroup[]; 186 191 extern IKE_ALG_GUID_INFO mIPsecEncrAlgInfo[]; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IkePacket.c
r58466 r77662 2 2 IKE Packet related operation. 3 3 4 Copyright (c) 2010 , Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 196 196 LIST_ENTRY *Entry; 197 197 IKE_PAYLOAD *IkePayload; 198 EFI_STATUS RetStatus; 199 200 RetStatus = EFI_SUCCESS; 198 201 199 202 if (!IkePacket->IsEncoded) { … … 204 207 // 205 208 if (((IKEV2_SESSION_COMMON *) SessionCommon)->IkeVer == 2) { 206 Ikev2EncodePacket ((IKEV2_SESSION_COMMON *) SessionCommon, IkePacket, IkeType); 209 RetStatus = Ikev2EncodePacket ((IKEV2_SESSION_COMMON *) SessionCommon, IkePacket, IkeType); 210 if (EFI_ERROR (RetStatus)) { 211 return NULL; 212 } 213 207 214 } else { 208 215 // 209 // If IKEv1 support, check it here.216 // If IKEv1 support, check it here. 210 217 // 211 218 return NULL; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IkeService.c
r58459 r77662 2 2 Provide IPsec Key Exchange (IKE) service general interfaces. 3 3 4 Copyright (c) 2010 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 16 16 #include "IkeService.h" 17 17 #include "IpSecConfigImpl.h" 18 #include "Ikev2/Utility.h"19 18 20 19 IKE_EXCHANGE_INTERFACE *mIkeExchange[] = { … … 213 212 ) 214 213 { 215 EFI_STATUS Status;216 EFI_IP4_CONFIG _PROTOCOL *Ip4Cfg;217 EFI_IP4_ IPCONFIG_DATA *Ip4CfgData;218 UINTN BufSize;219 EFI_IP6_MODE_DATA Ip6ModeData;220 EFI_UDP6_PROTOCOL *Udp6;214 EFI_STATUS Status; 215 EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2; 216 EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo; 217 UINTN BufSize; 218 EFI_IP6_MODE_DATA Ip6ModeData; 219 EFI_UDP6_PROTOCOL *Udp6; 221 220 222 221 Status = EFI_SUCCESS; 223 I p4CfgData= NULL;222 IfInfo = NULL; 224 223 BufSize = 0; 225 224 … … 237 236 Status = gBS->HandleProtocol ( 238 237 UdpService->NicHandle, 239 &gEfiIp4Config ProtocolGuid,240 (VOID **) &Ip4Cfg 238 &gEfiIp4Config2ProtocolGuid, 239 (VOID **) &Ip4Cfg2 241 240 ); 242 241 … … 245 244 } 246 245 247 Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, NULL); 246 // 247 // Get the interface information size. 248 // 249 Status = Ip4Cfg2->GetData ( 250 Ip4Cfg2, 251 Ip4Config2DataTypeInterfaceInfo, 252 &BufSize, 253 NULL 254 ); 248 255 249 256 if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { … … 251 258 } 252 259 253 I p4CfgData= AllocateZeroPool (BufSize);254 255 if (I p4CfgData== NULL) {260 IfInfo = AllocateZeroPool (BufSize); 261 262 if (IfInfo == NULL) { 256 263 Status = EFI_OUT_OF_RESOURCES; 257 264 goto ON_EXIT; 258 265 } 259 266 260 Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, Ip4CfgData); 267 // 268 // Get the interface info. 269 // 270 Status = Ip4Cfg2->GetData ( 271 Ip4Cfg2, 272 Ip4Config2DataTypeInterfaceInfo, 273 &BufSize, 274 IfInfo 275 ); 276 261 277 if (EFI_ERROR (Status)) { 262 278 goto ON_EXIT; … … 265 281 CopyMem ( 266 282 &UdpService->DefaultAddress.v4, 267 &I p4CfgData->StationAddress,283 &IfInfo->StationAddress, 268 284 sizeof (EFI_IPv4_ADDRESS) 269 285 ); … … 313 329 goto ON_EXIT; 314 330 } 331 332 if (Ip6ModeData.AddressList != NULL) { 333 FreePool (Ip6ModeData.AddressList); 334 } 335 336 if (Ip6ModeData.GroupTable != NULL) { 337 FreePool (Ip6ModeData.GroupTable); 338 } 339 340 if (Ip6ModeData.RouteTable != NULL) { 341 FreePool (Ip6ModeData.RouteTable); 342 } 343 344 if (Ip6ModeData.NeighborCache != NULL) { 345 FreePool (Ip6ModeData.NeighborCache); 346 } 347 348 if (Ip6ModeData.PrefixTable != NULL) { 349 FreePool (Ip6ModeData.PrefixTable); 350 } 351 352 if (Ip6ModeData.IcmpTypeList != NULL) { 353 FreePool (Ip6ModeData.IcmpTypeList); 354 } 355 315 356 // 316 357 // Reconfigure udp6 io without remote address. … … 332 373 333 374 ON_EXIT: 334 if (I p4CfgData!= NULL) {335 FreePool (I p4CfgData);375 if (IfInfo != NULL) { 376 FreePool (IfInfo); 336 377 } 337 378 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IkeService.h
r58459 r77662 2 2 Prototypes definitions of IKE service. 3 3 4 Copyright (c) 2010 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 20 20 #include "IpSecImpl.h" 21 21 #include "IkeCommon.h" 22 #include "Ikev2/Utility.h" 22 23 23 24 #define IPSEC_CRYPTO_LIB_MEMORY 128 * 1024 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/ChildSa.c
r58466 r77662 2 2 The operations for Child SA. 3 3 4 Copyright (c) 2010 , Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 41 41 UINT32 *MessageId; 42 42 43 ChildSaSession = (IKEV2_CHILD_SA_SESSION *) SaSession; 44 IkePacket = IkePacketAlloc(); 43 NotifyPayload = NULL; 45 44 MessageId = NULL; 46 45 46 ChildSaSession = (IKEV2_CHILD_SA_SESSION *) SaSession; 47 if (ChildSaSession == NULL) { 48 return NULL; 49 } 50 51 IkePacket = IkePacketAlloc(); 47 52 if (IkePacket == NULL) { 48 53 return NULL; 49 54 } 50 if (ChildSaSession == NULL) { 51 return NULL; 52 } 55 53 56 54 57 if (Context != NULL) { … … 74 77 75 78 if (ChildSaSession->SessionCommon.IsInitiator) { 76 IkePacket->Header->Flags = IKE_HEADER_FLAGS_CHILD_INIT; 77 } else { 78 IkePacket->Header->Flags = IKE_HEADER_FLAGS_RESPOND; 79 IkePacket->Header->Flags = IKE_HEADER_FLAGS_INIT; 79 80 } 80 81 … … 94 95 95 96 if (IkeSaSession->SessionCommon.IsInitiator) { 96 IkePacket->Header->Flags = IKE_HEADER_FLAGS_CHILD_INIT; 97 } else { 98 IkePacket->Header->Flags = IKE_HEADER_FLAGS_RESPOND; 97 IkePacket->Header->Flags = IKE_HEADER_FLAGS_INIT; 99 98 } 99 } 100 101 if (MessageId != NULL) { 102 IkePacket->Header->Flags |= IKE_HEADER_FLAGS_RESPOND; 100 103 } 101 104 … … 114 117 0 115 118 ); 119 if (NotifyPayload == NULL) { 120 IkePacketFree (IkePacket); 121 return NULL; 122 } 116 123 117 124 IKE_PACKET_APPEND_PAYLOAD (IkePacket, NotifyPayload); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/Exchange.c
r58459 r77662 2 2 The general interfaces of the IKEv2. 3 3 4 Copyright (c) 2010 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 331 331 // Send out the Packet 332 332 // 333 if (UdpService != NULL ) {333 if (UdpService != NULL && UdpService->Output != NULL) { 334 334 Status = Ikev2SendIkePacket (UdpService, (UINT8 *) SaCommon, IkePacket, 0); 335 335 … … 358 358 // Send out the Packet 359 359 // 360 if (UdpService != NULL ) {360 if (UdpService != NULL && UdpService->Output != NULL) { 361 361 Status = Ikev2SendIkePacket (UdpService, (UINT8 *) &ChildSaSession->SessionCommon, IkePacket, 0); 362 362 … … 496 496 497 497 ChildSaSession = Ikev2ChildSaSessionCreate (IkeSaSession, UdpService); 498 if (ChildSaSession == NULL) { 499 goto ON_ERROR; 500 } 501 498 502 ChildSaCommon = &ChildSaSession->SessionCommon; 499 503 } … … 520 524 521 525 ChildSaSession = Ikev2ChildSaSessionCreate (IkeSaSession, UdpService); 526 if (ChildSaSession == NULL) { 527 goto ON_ERROR; 528 } 529 522 530 ChildSaCommon = &ChildSaSession->SessionCommon; 523 531 … … 698 706 // Generate the reply packet if needed and send it out. 699 707 // 700 if ( IkePacket->Header->Flags != IKE_HEADER_FLAGS_RESPOND) {708 if (!(IkePacket->Header->Flags & IKE_HEADER_FLAGS_RESPOND)) { 701 709 Reply = mIkev2CreateChild.Generator ((UINT8 *) IkeSaSession, &IkePacket->Header->MessageId); 702 710 if (Reply != NULL) { -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/Info.c
r58466 r77662 2 2 The Implementations for Information Exchange. 3 3 4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 47 48 IkeSaSession = (IKEV2_SA_SESSION *) SaSession; 48 49 IkePacket = IkePacketAlloc (); 49 ASSERT (IkePacket != NULL); 50 if (IkePacket == NULL) { 51 return NULL; 52 } 50 53 51 54 // … … 127 130 goto ERROR_EXIT; 128 131 } 132 133 if (IkeSaSession->SessionCommon.IsInitiator) { 134 IkePacket->Header->Flags = IKE_HEADER_FLAGS_INIT ; 135 } 129 136 } else { 130 137 // … … 178 185 // 179 186 ChildSaSession->SessionCommon.IsOnDeleting = TRUE; 180 } 181 182 if (InfoContext == NULL) { 183 IkePacket->Header->Flags = IKE_HEADER_FLAGS_INIT; 184 } else { 185 IkePacket->Header->Flags = IKE_HEADER_FLAGS_RESPOND; 186 } 187 188 if (ChildSaSession->SessionCommon.IsInitiator) { 189 IkePacket->Header->Flags = IKE_HEADER_FLAGS_INIT ; 190 } 191 } 192 193 if (InfoContext != NULL) { 194 IkePacket->Header->Flags |= IKE_HEADER_FLAGS_RESPOND; 195 } 196 187 197 return IkePacket; 188 198 … … 212 222 IKEV2_CHILD_SA_SESSION *ChildSaSession; 213 223 IKEV2_SA_SESSION *IkeSaSession; 214 IKE_PAYLOAD *NotifyPayload;215 224 IKE_PAYLOAD *DeletePayload; 216 225 IKE_PAYLOAD *IkePayload; … … 230 239 IkeSaSession = (IKEV2_SA_SESSION *) SaSession; 231 240 232 NotifyPayload = NULL;233 241 DeletePayload = NULL; 234 242 Private = NULL; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/Payload.c
r58459 r77662 2 2 The implementation of Payloads Creation. 3 3 4 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 52 53 53 54 SaPayload = IkePayloadAlloc (); 54 ASSERT (SaPayload != NULL); 55 if (SaPayload == NULL) { 56 return NULL; 57 } 58 55 59 // 56 60 // TODO: Get the Proposal Number and Transform Number from IPsec Config, … … 70 74 71 75 SaData = AllocateZeroPool (SaDataSize); 72 ASSERT (SaData != NULL); 76 if (SaData == NULL) { 77 IkePayloadFree (SaPayload); 78 return NULL; 79 } 73 80 74 81 CopyMem (SaData, SessionSaData, SaDataSize); … … 118 125 119 126 Nonce = AllocateZeroPool (Size); 120 ASSERT (Nonce != NULL); 127 if (Nonce == NULL) { 128 return NULL; 129 } 130 121 131 CopyMem (Nonce + 1, NonceBlock, Size - sizeof (IKEV2_NONCE)); 122 132 … … 124 134 Nonce->Header.PayloadLength = (UINT16) Size; 125 135 NoncePayload = IkePayloadAlloc (); 126 127 ASSERT (NoncePayload != NULL); 136 if (NoncePayload == NULL) { 137 FreePool (Nonce); 138 return NULL; 139 } 140 128 141 NoncePayload->PayloadType = IKEV2_PAYLOAD_TYPE_NONCE; 129 142 NoncePayload->PayloadBuf = (UINT8 *) Nonce; … … 180 193 // 181 194 Ke = AllocateZeroPool (KeSize); 182 ASSERT (Ke != NULL); 195 if (Ke == NULL) { 196 return NULL; 197 } 183 198 184 199 Ke->Header.NextPayload = NextPayload; … … 192 207 // 193 208 KePayload = IkePayloadAlloc (); 194 ASSERT (KePayload != NULL); 209 if (KePayload == NULL) { 210 FreePool (Ke); 211 return NULL; 212 } 195 213 196 214 KePayload->PayloadType = IKEV2_PAYLOAD_TYPE_KE; … … 241 259 242 260 Id = (IKEV2_ID *) AllocateZeroPool (IdSize); 243 ASSERT (Id != NULL); 261 if (Id == NULL) { 262 return NULL; 263 } 244 264 245 265 IdPayload = IkePayloadAlloc (); 246 ASSERT (IdPayload != NULL); 266 if (IdPayload == NULL) { 267 FreePool (Id); 268 return NULL; 269 } 247 270 248 271 IdPayload->PayloadType = (UINT8) ((CommonSession->IsInitiator) ? IKEV2_PAYLOAD_TYPE_ID_INIT : IKEV2_PAYLOAD_TYPE_ID_RSP); … … 285 308 IKEV2_ID *Id; 286 309 UINTN IdSize; 287 UINT8 IpVersion;288 310 UINTN SubjectSize; 289 311 UINT8 *CertSubject; … … 305 327 SubjectSize = 0; 306 328 CertSubject = NULL; 307 IpVersion = CommonSession->UdpService->IpVersion;308 329 IpSecCryptoIoGetSubjectFromCert ( 309 330 InCert, … … 319 340 320 341 Id = (IKEV2_ID *) AllocateZeroPool (IdSize); 321 ASSERT (Id != NULL); 342 if (Id == NULL) { 343 return NULL; 344 } 322 345 323 346 IdPayload = IkePayloadAlloc (); 324 ASSERT (IdPayload != NULL); 347 if (IdPayload == NULL) { 348 FreePool (Id); 349 return NULL; 350 } 325 351 326 352 IdPayload->PayloadType = (UINT8) ((CommonSession->IsInitiator) ? IKEV2_PAYLOAD_TYPE_ID_INIT : IKEV2_PAYLOAD_TYPE_ID_RSP); … … 400 426 DigestSize = IpSecGetHmacDigestLength ((UINT8)IkeSaSession->SessionCommon.SaParams->Prf); 401 427 Digest = AllocateZeroPool (DigestSize); 402 403 428 if (Digest == NULL) { 404 429 return NULL; 405 430 } 431 406 432 if (IdPayload == NULL) { 407 433 return NULL; 408 434 } 435 409 436 // 410 437 // Calcualte Prf(Seceret, "Key Pad for IKEv2"); … … 430 457 // 431 458 KeyBuf = AllocateZeroPool (DigestSize); 432 ASSERT (KeyBuf != NULL); 459 if (KeyBuf == NULL) { 460 Status = EFI_OUT_OF_RESOURCES; 461 goto EXIT; 462 } 463 433 464 CopyMem (KeyBuf, Digest, DigestSize); 434 465 KeySize = DigestSize; … … 488 519 // 489 520 Fragments[2].Data = AllocateZeroPool (DigestSize); 521 if (Fragments[2].Data == NULL) { 522 Status = EFI_OUT_OF_RESOURCES; 523 goto EXIT; 524 } 525 490 526 Fragments[2].DataSize = DigestSize; 491 527 CopyMem (Fragments[2].Data, Digest, DigestSize); … … 511 547 // 512 548 AuthPayload = IkePayloadAlloc (); 513 ASSERT (AuthPayload != NULL); 549 if (AuthPayload == NULL) { 550 Status = EFI_OUT_OF_RESOURCES; 551 goto EXIT; 552 } 514 553 515 554 AuthPayload->PayloadSize = sizeof (IKEV2_AUTH) + DigestSize; 516 555 PayloadBuf = (IKEV2_AUTH *) AllocateZeroPool (AuthPayload->PayloadSize); 517 ASSERT (PayloadBuf != NULL); 556 if (PayloadBuf == NULL) { 557 Status = EFI_OUT_OF_RESOURCES; 558 goto EXIT; 559 } 560 518 561 // 519 562 // Fill in Auth payload. … … 615 658 UINTN DigestSize; 616 659 PRF_DATA_FRAGMENT Fragments[3]; 617 UINT8 *KeyBuf;618 UINTN KeySize;619 660 IKE_PAYLOAD *AuthPayload; 620 661 IKEV2_AUTH *PayloadBuf; … … 641 682 // Initial point 642 683 // 643 KeyBuf = NULL;644 684 AuthPayload = NULL; 645 685 Digest = NULL; … … 652 692 DigestSize = IpSecGetHmacDigestLength ((UINT8)IkeSaSession->SessionCommon.SaParams->Prf); 653 693 Digest = AllocateZeroPool (DigestSize); 654 655 694 if (Digest == NULL) { 656 695 return NULL; 657 696 } 658 659 //660 // Store the AuthKey into KeyBuf661 //662 KeyBuf = AllocateZeroPool (DigestSize);663 ASSERT (KeyBuf != NULL);664 665 CopyMem (KeyBuf, Digest, DigestSize);666 KeySize = DigestSize;667 697 668 698 // … … 728 758 // 729 759 Fragments[2].Data = AllocateZeroPool (DigestSize); 760 if (Fragments[2].Data == NULL) { 761 Status = EFI_OUT_OF_RESOURCES; 762 goto EXIT; 763 } 764 730 765 Fragments[2].DataSize = DigestSize; 731 766 CopyMem (Fragments[2].Data, Digest, DigestSize); … … 770 805 // 771 806 AuthPayload = IkePayloadAlloc (); 772 ASSERT (AuthPayload != NULL); 807 if (AuthPayload == NULL) { 808 Status = EFI_OUT_OF_RESOURCES; 809 goto EXIT; 810 } 773 811 774 812 if (!IsVerify) { … … 779 817 780 818 PayloadBuf = (IKEV2_AUTH *) AllocateZeroPool (AuthPayload->PayloadSize); 781 ASSERT (PayloadBuf != NULL); 819 if (PayloadBuf == NULL) { 820 Status = EFI_OUT_OF_RESOURCES; 821 goto EXIT; 822 } 823 782 824 // 783 825 // Fill in Auth payload. … … 809 851 810 852 EXIT: 811 if (KeyBuf != NULL) {812 FreePool (KeyBuf);813 }814 853 if (Digest != NULL) { 815 854 FreePool (Digest); … … 883 922 884 923 TsPayload = IkePayloadAlloc(); 885 ASSERT (TsPayload != NULL); 924 if (TsPayload == NULL) { 925 return NULL; 926 } 886 927 887 928 IpVersion = ChildSa->SessionCommon.UdpService->IpVersion; … … 894 935 TsPayloadSize = sizeof (IKEV2_TS) + SelectorSize; 895 936 TsPayloadBuf = AllocateZeroPool (TsPayloadSize); 896 ASSERT (TsPayloadBuf != NULL); 937 if (TsPayloadBuf == NULL) { 938 goto ON_ERROR; 939 } 897 940 898 941 TsPayload->PayloadBuf = (UINT8 *) TsPayloadBuf; … … 1150 1193 NotifyPayloadLen = (UINT16) (sizeof (IKEV2_NOTIFY) + NotifyDataSize + SpiSize); 1151 1194 Notify = (IKEV2_NOTIFY *) AllocateZeroPool (NotifyPayloadLen); 1152 ASSERT (Notify != NULL); 1195 if (Notify == NULL) { 1196 return NULL; 1197 } 1153 1198 1154 1199 // … … 1181 1226 // 1182 1227 NotifyPayload = IkePayloadAlloc (); 1183 ASSERT (NotifyPayload != NULL); 1228 if (NotifyPayload == NULL) { 1229 FreePool (Notify); 1230 return NULL; 1231 } 1232 1184 1233 NotifyPayload->PayloadType = IKEV2_PAYLOAD_TYPE_NOTIFY; 1185 1234 NotifyPayload->PayloadBuf = (UINT8 *) Notify; … … 1242 1291 1243 1292 Del = AllocateZeroPool (DelPayloadLen); 1244 ASSERT (Del != NULL); 1293 if (Del == NULL) { 1294 return NULL; 1295 } 1245 1296 1246 1297 // … … 1266 1317 CopyMem (Del + 1, SpiBuf, SpiBufSize); 1267 1318 DelPayload = IkePayloadAlloc (); 1268 ASSERT (DelPayload != NULL); 1319 if (DelPayload == NULL) { 1320 FreePool (Del); 1321 return NULL; 1322 } 1323 1269 1324 DelPayload->PayloadType = IKEV2_PAYLOAD_TYPE_DELETE; 1270 1325 DelPayload->PayloadBuf = (UINT8 *) Del; … … 1422 1477 @param[in] IsRequest To indicate create Certificate Payload or Certificate 1423 1478 Request Payload. If it is TURE, create Certificate 1424 Payload. Otherwise, create Certificate RequestPayload.1479 Request Payload. Otherwise, create Certificate Payload. 1425 1480 1426 1481 @retval a Pointer to IKE Payload whose payload buffer containing the Certificate … … 1615 1670 TotalTransforms = 0; 1616 1671 // 1617 // Ca culate the Proposal numbers and Transform numbers.1672 // Calculate the Proposal numbers and Transform numbers. 1618 1673 // 1619 1674 for (ProposalIndex = 0; ProposalIndex < SaData->NumProposals; ProposalIndex++) { … … 1630 1685 // 1631 1686 Sa = AllocateZeroPool (SaSize); 1632 ASSERT (Sa != NULL); 1687 if (Sa == NULL) { 1688 return NULL; 1689 } 1690 1633 1691 CopyMem (Sa, SaData, sizeof (IKEV2_SA)); 1634 1692 Sa->Header.PayloadLength = (UINT16) sizeof (IKEV2_SA); … … 1691 1749 Transform->Header.PayloadLength = HTONS ((UINT16)TransformSize); 1692 1750 1693 if (TransformIndex == ( UINTN)(ProposalData->NumTransforms - 1)) {1751 if (TransformIndex == ((UINT32)ProposalData->NumTransforms - 1)) { 1694 1752 Transform->Header.NextPayload = IKE_TRANSFORM_NEXT_PAYLOAD_NONE; 1695 1753 } … … 1778 1836 1779 1837 // 1780 // Ca culate the number of Proposal payload and the total numbers of1838 // Calculate the number of Proposal payload and the total numbers of 1781 1839 // Transforms payload (the transforms in all proposal payload). 1782 1840 // … … 1823 1881 TotalTransforms * sizeof (IKEV2_TRANSFORM_DATA) 1824 1882 ); 1825 ASSERT (SaData != NULL); 1883 if (SaData == NULL) { 1884 Status = EFI_OUT_OF_RESOURCES; 1885 goto Exit; 1886 } 1887 1826 1888 CopyMem (SaData, Sa, sizeof (IKEV2_SA)); 1827 1889 SaData->NumProposals = TotalProposals; … … 1856 1918 // 1857 1919 Spi = AllocateZeroPool (Proposal->SpiSize); 1858 ASSERT (Spi != NULL); 1920 if (Spi == NULL) { 1921 Status = EFI_OUT_OF_RESOURCES; 1922 goto Exit; 1923 } 1924 1859 1925 CopyMem (Spi, (UINT32 *) (Proposal + 1), Proposal->SpiSize); 1860 1926 *((UINT32*) Spi) = NTOHL (*((UINT32*) Spi)); … … 2288 2354 if (IkePacket->Header->ExchangeType == IKEV2_EXCHANGE_TYPE_INIT) { 2289 2355 IkeHeader = AllocateZeroPool (sizeof (IKE_HEADER)); 2290 ASSERT (IkeHeader != NULL); 2356 if (IkeHeader == NULL) { 2357 Status = EFI_OUT_OF_RESOURCES; 2358 goto Exit; 2359 } 2360 2291 2361 CopyMem (IkeHeader, IkePacket->Header, sizeof (IKE_HEADER)); 2292 2362 … … 2362 2432 // 2363 2433 IkePayload = IkePayloadAlloc (); 2364 ASSERT (IkePayload != NULL); 2434 if (IkePayload == NULL) { 2435 Status = EFI_OUT_OF_RESOURCES; 2436 goto Exit; 2437 } 2365 2438 2366 2439 IkePayload->PayloadType = PayloadType; … … 2470 2543 // 2471 2544 Status = Ikev2EncryptPacket (SessionCommon, IkePacket); 2545 if (EFI_ERROR (Status)) { 2546 return Status; 2547 } 2472 2548 } else { 2473 2549 // … … 2487 2563 IkeSaSession->InitPacketSize = IkePacket->PayloadTotalSize + sizeof (IKE_HEADER); 2488 2564 IkeSaSession->InitPacket = AllocateZeroPool (IkeSaSession->InitPacketSize); 2489 ASSERT (IkeSaSession->InitPacket != NULL); 2565 if (IkeSaSession->InitPacket == NULL) { 2566 return EFI_OUT_OF_RESOURCES; 2567 } 2568 2490 2569 CopyMem (IkeSaSession->InitPacket, IkePacket->Header, sizeof (IKE_HEADER)); 2491 2570 PayloadTotalSize = 0; … … 2503 2582 IkeSaSession->RespPacketSize = IkePacket->PayloadTotalSize + sizeof(IKE_HEADER); 2504 2583 IkeSaSession->RespPacket = AllocateZeroPool (IkeSaSession->RespPacketSize); 2505 ASSERT (IkeSaSession->RespPacket != NULL); 2584 if (IkeSaSession->RespPacket == NULL) { 2585 return EFI_OUT_OF_RESOURCES; 2586 } 2587 2506 2588 CopyMem (IkeSaSession->RespPacket, IkePacket->Header, sizeof (IKE_HEADER)); 2507 2589 PayloadTotalSize = 0; … … 2559 2641 EFI_STATUS Status; 2560 2642 UINT8 PadLen; 2561 UINTN CryptKeyLength;2562 2643 HASH_DATA_FRAGMENT Fragments[1]; 2563 2644 … … 2566 2647 CryptBlockSize = 0; 2567 2648 CheckSumSize = 0; 2568 CryptKeyLength = 0;2569 2649 2570 2650 // … … 2584 2664 2585 2665 CryptBlockSize = (UINT8) IpSecGetEncryptBlockSize ((UINT8) SessionCommon->SaParams->EncAlgId); 2586 CryptKeyLength = IpSecGetEncryptKeyLength ((UINT8) SessionCommon->SaParams->EncAlgId); 2666 2587 2667 CheckSumSize = (UINT8) IpSecGetIcvLength ((UINT8) SessionCommon->SaParams->IntegAlgId); 2588 2668 IkeSaSession = IKEV2_SA_SESSION_FROM_COMMON (SessionCommon); … … 2593 2673 IkeSaSession = ChildSaSession->IkeSaSession; 2594 2674 CryptBlockSize = (UINT8) IpSecGetEncryptBlockSize ((UINT8) IkeSaSession->SessionCommon.SaParams->EncAlgId); 2595 CryptKeyLength = IpSecGetEncryptKeyLength ((UINT8) IkeSaSession->SessionCommon.SaParams->EncAlgId);2596 2675 CheckSumSize = (UINT8) IpSecGetIcvLength ((UINT8) IkeSaSession->SessionCommon.SaParams->IntegAlgId); 2597 2676 } else { … … 2603 2682 2604 2683 CheckSumData = AllocateZeroPool (CheckSumSize); 2605 ASSERT (CheckSumData != NULL); 2684 if (CheckSumData == NULL) { 2685 Status = EFI_OUT_OF_RESOURCES; 2686 goto ON_EXIT; 2687 } 2606 2688 2607 2689 // … … 2610 2692 IntegritySize = IkePacket->PayloadTotalSize + sizeof (IKE_HEADER); 2611 2693 IntegrityBuffer = AllocateZeroPool (IntegritySize); 2612 ASSERT (IntegrityBuffer != NULL); 2694 if (IntegrityBuffer == NULL) { 2695 Status = EFI_OUT_OF_RESOURCES; 2696 goto ON_EXIT; 2697 } 2698 2613 2699 CopyMem (IntegrityBuffer, IkePacket->Header, sizeof(IKE_HEADER)); 2614 2700 CopyMem (IntegrityBuffer + sizeof (IKE_HEADER), IkePacket->PayloadsBuf, IkePacket->PayloadTotalSize); … … 2671 2757 DecryptedSize = IkePacket->PayloadTotalSize - sizeof (IKEV2_COMMON_PAYLOAD_HEADER) - IvSize - CheckSumSize; 2672 2758 DecryptedBuf = AllocateZeroPool (DecryptedSize); 2673 ASSERT (DecryptedBuf != NULL); 2759 if (DecryptedBuf == NULL) { 2760 Status = EFI_OUT_OF_RESOURCES; 2761 goto ON_EXIT; 2762 } 2674 2763 2675 2764 CopyMem ( … … 2769 2858 UINTN EncryptPayloadSize; // Total size of the Encrypted payload 2770 2859 UINT8 *IntegrityBuf; // Buffer to be intergity 2771 UINT32 IntegrityBufSize; // Buffer size of IntegrityBuf2772 2860 UINT8 *IvBuffer; // Initialization Vector 2773 2861 UINT8 IvSize; // Iv Size … … 2781 2869 LIST_ENTRY *Entry; 2782 2870 IKE_PAYLOAD *IkePayload; 2783 UINTN CryptKeyLength;2784 2871 HASH_DATA_FRAGMENT Fragments[1]; 2785 2872 … … 2796 2883 CryptBlockSize = 0; 2797 2884 CheckSumSize = 0; 2798 CryptKeyLength = 0;2799 2885 IntegrityBuf = NULL; 2800 2886 // … … 2804 2890 2805 2891 CryptBlockSize = (UINT8) IpSecGetEncryptBlockSize ((UINT8) SessionCommon->SaParams->EncAlgId); 2806 CryptKeyLength = IpSecGetEncryptKeyLength ((UINT8) SessionCommon->SaParams->EncAlgId);2807 2892 CheckSumSize = (UINT8) IpSecGetIcvLength ((UINT8) SessionCommon->SaParams->IntegAlgId); 2808 2893 IkeSaSession = IKEV2_SA_SESSION_FROM_COMMON (SessionCommon); … … 2813 2898 IkeSaSession = ChildSaSession->IkeSaSession; 2814 2899 CryptBlockSize = (UINT8) IpSecGetEncryptBlockSize ((UINT8) IkeSaSession->SessionCommon.SaParams->EncAlgId); 2815 CryptKeyLength = IpSecGetEncryptKeyLength ((UINT8) IkeSaSession->SessionCommon.SaParams->EncAlgId);2816 2900 CheckSumSize = (UINT8) IpSecGetIcvLength ((UINT8) IkeSaSession->SessionCommon.SaParams->IntegAlgId); 2817 2901 } … … 2823 2907 EncryptedSize = (IkePacket->PayloadTotalSize + sizeof (IKEV2_PAD_LEN) + CryptBlockSizeMask) & ~CryptBlockSizeMask; 2824 2908 EncryptedBuf = (UINT8 *) AllocateZeroPool (EncryptedSize); 2825 ASSERT (EncryptedBuf != NULL); 2909 if (EncryptedBuf == NULL) { 2910 Status = EFI_OUT_OF_RESOURCES; 2911 goto ON_EXIT; 2912 } 2826 2913 2827 2914 // … … 2890 2977 EncryptPayloadSize = sizeof(IKEV2_ENCRYPTED) + IvSize + EncryptedSize + CheckSumSize; 2891 2978 EncryptPayloadBuf = AllocateZeroPool (EncryptPayloadSize); 2892 ASSERT (EncryptPayloadBuf != NULL); 2979 if (EncryptPayloadBuf == NULL) { 2980 Status = EFI_OUT_OF_RESOURCES; 2981 goto ON_EXIT; 2982 } 2893 2983 2894 2984 // … … 2920 3010 goto ON_EXIT; 2921 3011 } 2922 IntegrityBufSize = IkePacket->Header->Length;2923 3012 IkeHdrHostToNet (IkePacket->Header); 2924 3013 … … 2978 3067 // 2979 3068 EncryptPayload = IkePayloadAlloc (); 2980 ASSERT (EncryptPayload != NULL); 3069 if (EncryptPayload == NULL) { 3070 Status = EFI_OUT_OF_RESOURCES; 3071 goto ON_EXIT; 3072 } 2981 3073 2982 3074 // … … 3224 3316 // 3225 3317 IkePacketNetbuf = IkeNetbufFromPacket ((UINT8 *) SessionCommon, IkePacket, IkeType); 3226 ASSERT (IkePacketNetbuf != NULL); 3318 if (IkePacketNetbuf == NULL) { 3319 return EFI_OUT_OF_RESOURCES; 3320 } 3227 3321 3228 3322 ZeroMem (&EndPoint, sizeof (UDP_END_POINT)); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/Payload.h
r58466 r77662 2 2 The Definitions related to IKEv2 payload. 3 3 4 Copyright (c) 2010 , Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 38 38 39 39 // 40 // IKE header Flag for IKEv2 40 // IKE header Flag (1 octet) for IKEv2, defined in RFC 4306 section 3.1 41 // 42 // I(nitiator) (bit 3 of Flags, 0x08) - This bit MUST be set in messages sent by the 43 // original initiator of the IKE_SA 44 // 45 // R(esponse) (bit 5 of Flags, 0x20) - This bit indicates that this message is a response to 46 // a message containing the same message ID. 41 47 // 42 48 #define IKE_HEADER_FLAGS_INIT 0x08 43 49 #define IKE_HEADER_FLAGS_RESPOND 0x20 44 #define IKE_HEADER_FLAGS_CHILD_INIT 045 50 46 51 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/Sa.c
r58466 r77662 2 2 The operations for IKEv2 SA. 3 3 4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 102 103 // 103 104 IkePacket = IkePacketAlloc (); 104 ASSERT (IkePacket != NULL); 105 if (IkePacket == NULL) { 106 goto CheckError; 107 } 105 108 106 109 // … … 176 179 IkeSaSession->NiBlkSize = IKE_NONCE_SIZE; 177 180 IkeSaSession->NiBlock = IkeGenerateNonce (IKE_NONCE_SIZE); 178 ASSERT (IkeSaSession->NiBlock != NULL); 181 if (IkeSaSession->NiBlock == NULL) { 182 goto CheckError; 183 } 179 184 } 180 185 … … 283 288 // 284 289 if (IkeSaSession->SessionCommon.IsInitiator) { 285 if (NotifyPayload != NULL) { 286 Status = Ikev2ParserNotifyCookiePayload (NotifyPayload, IkeSaSession); 287 return Status; 290 if (NotifyPayload != NULL && !EFI_ERROR(Ikev2ParserNotifyCookiePayload (NotifyPayload, IkeSaSession))) { 291 return EFI_SUCCESS; 288 292 } 289 293 } … … 298 302 NonceSize = NoncePayload->PayloadSize - sizeof (IKEV2_COMMON_PAYLOAD_HEADER); 299 303 NonceBuffer = (UINT8 *) AllocatePool (NonceSize); 300 ASSERT (NonceBuffer != NULL); 304 if (NonceBuffer == NULL) { 305 Status = EFI_OUT_OF_RESOURCES; 306 goto CheckError; 307 } 308 301 309 CopyMem ( 302 310 NonceBuffer, … … 376 384 // 377 385 IkeSaSession->NrBlock = IkeGenerateNonce (IKE_NONCE_SIZE); 378 ASSERT _EFI_ERROR(IkeSaSession->NrBlock != NULL);386 ASSERT (IkeSaSession->NrBlock != NULL); 379 387 IkeSaSession->NrBlkSize = IKE_NONCE_SIZE; 380 388 … … 437 445 ChildSaSession = IKEV2_CHILD_SA_SESSION_BY_IKE_SA (GetFirstNode (&IkeSaSession->ChildSaSessionList)); 438 446 447 IkePacket = NULL; 448 IdPayload = NULL; 449 AuthPayload = NULL; 450 SaPayload = NULL; 451 TsiPayload = NULL; 452 TsrPayload = NULL; 453 NotifyPayload = NULL; 439 454 CpPayload = NULL; 440 455 NotifyPayload = NULL; … … 444 459 // 445 460 IkePacket= IkePacketAlloc (); 446 ASSERT (IkePacket != NULL); 461 if (IkePacket == NULL) { 462 return NULL; 463 } 447 464 448 465 // … … 478 495 IKEV2_PAYLOAD_TYPE_AUTH 479 496 ); 497 if (IdPayload == NULL) { 498 goto CheckError; 499 } 480 500 481 501 // … … 512 532 ); 513 533 } 534 535 if (CpPayload == NULL) { 536 goto CheckError; 537 } 538 } 539 540 if (AuthPayload == NULL) { 541 goto CheckError; 514 542 } 515 543 … … 522 550 IkeSessionTypeChildSa 523 551 ); 552 if (SaPayload == NULL) { 553 goto CheckError; 554 } 524 555 525 556 if (IkeSaSession->Spd->Data->ProcessingPolicy->Mode == EfiIPsecTransport) { … … 552 583 0 553 584 ); 585 if (NotifyPayload == NULL) { 586 goto CheckError; 587 } 554 588 } else { 555 589 // … … 568 602 } 569 603 604 if (TsiPayload == NULL || TsrPayload == NULL) { 605 goto CheckError; 606 } 607 570 608 IKE_PACKET_APPEND_PAYLOAD (IkePacket, IdPayload); 571 609 IKE_PACKET_APPEND_PAYLOAD (IkePacket, AuthPayload); … … 581 619 582 620 return IkePacket; 621 622 CheckError: 623 if (IkePacket != NULL) { 624 IkePacketFree (IkePacket); 625 } 626 627 if (IdPayload != NULL) { 628 IkePayloadFree (IdPayload); 629 } 630 631 if (AuthPayload != NULL) { 632 IkePayloadFree (AuthPayload); 633 } 634 635 if (CpPayload != NULL) { 636 IkePayloadFree (CpPayload); 637 } 638 639 if (SaPayload != NULL) { 640 IkePayloadFree (SaPayload); 641 } 642 643 if (TsiPayload != NULL) { 644 IkePayloadFree (TsiPayload); 645 } 646 647 if (TsrPayload != NULL) { 648 IkePayloadFree (TsrPayload); 649 } 650 651 if (NotifyPayload != NULL) { 652 IkePayloadFree (NotifyPayload); 653 } 654 655 return NULL; 583 656 } 584 657 … … 745 818 if (ChildSaSession->IkeSaSession->Spd == NULL) { 746 819 ChildSaSession->IkeSaSession->Spd = ChildSaSession->Spd; 747 Ikev2ChildSaSessionSpdSelectorCreate (ChildSaSession); 820 Status = Ikev2ChildSaSessionSpdSelectorCreate (ChildSaSession); 821 if (EFI_ERROR (Status)) { 822 return Status; 823 } 748 824 } 749 825 } else { … … 787 863 // 5. Generate keymats for IPsec protocol. 788 864 // 789 Ikev2GenerateChildSaKeys (ChildSaSession, NULL); 865 Status = Ikev2GenerateChildSaKeys (ChildSaSession, NULL); 866 if (EFI_ERROR (Status)) { 867 return Status; 868 } 869 790 870 if (IkeSaSession->SessionCommon.IsInitiator) { 791 871 // … … 921 1001 ChildSaSession = IKEV2_CHILD_SA_SESSION_BY_IKE_SA (GetFirstNode (&IkeSaSession->ChildSaSessionList)); 922 1002 1003 IkePacket = NULL; 1004 IdPayload = NULL; 1005 AuthPayload = NULL; 923 1006 CpPayload = NULL; 1007 SaPayload = NULL; 1008 TsiPayload = NULL; 1009 TsrPayload = NULL; 924 1010 NotifyPayload = NULL; 925 1011 CertPayload = NULL; … … 930 1016 // 931 1017 IkePacket= IkePacketAlloc (); 932 ASSERT (IkePacket != NULL); 1018 if (IkePacket == NULL) { 1019 return NULL; 1020 } 933 1021 934 1022 // … … 966 1054 PcdGet32 (PcdIpsecUefiCertificateSize) 967 1055 ); 1056 if (IdPayload == NULL) { 1057 goto CheckError; 1058 } 968 1059 969 1060 // … … 978 1069 FALSE 979 1070 ); 1071 if (CertPayload == NULL) { 1072 goto CheckError; 1073 } 1074 980 1075 if (IkeSaSession->SessionCommon.IsInitiator) { 981 1076 CertReqPayload = Ikev2GenerateCertificatePayload ( … … 987 1082 TRUE 988 1083 ); 1084 if (CertReqPayload == NULL) { 1085 goto CheckError; 1086 } 989 1087 } 990 1088 … … 1029 1127 ); 1030 1128 } 1129 1130 if (CpPayload == NULL) { 1131 goto CheckError; 1132 } 1133 } 1134 1135 if (AuthPayload == NULL) { 1136 goto CheckError; 1031 1137 } 1032 1138 … … 1039 1145 IkeSessionTypeChildSa 1040 1146 ); 1147 if (SaPayload == NULL) { 1148 goto CheckError; 1149 } 1041 1150 1042 1151 if (IkeSaSession->Spd->Data->ProcessingPolicy->Mode == EfiIPsecTransport) { … … 1069 1178 0 1070 1179 ); 1180 if (NotifyPayload == NULL) { 1181 goto CheckError; 1182 } 1071 1183 } else { 1072 1184 // … … 1085 1197 } 1086 1198 1199 if (TsiPayload == NULL || TsrPayload == NULL) { 1200 goto CheckError; 1201 } 1202 1087 1203 IKE_PACKET_APPEND_PAYLOAD (IkePacket, IdPayload); 1088 1204 IKE_PACKET_APPEND_PAYLOAD (IkePacket, CertPayload); … … 1102 1218 1103 1219 return IkePacket; 1220 1221 CheckError: 1222 if (IkePacket != NULL) { 1223 IkePacketFree (IkePacket); 1224 } 1225 1226 if (IdPayload != NULL) { 1227 IkePayloadFree (IdPayload); 1228 } 1229 1230 if (CertPayload != NULL) { 1231 IkePayloadFree (CertPayload); 1232 } 1233 1234 if (CertReqPayload != NULL) { 1235 IkePayloadFree (CertReqPayload); 1236 } 1237 1238 if (AuthPayload != NULL) { 1239 IkePayloadFree (AuthPayload); 1240 } 1241 1242 if (CpPayload != NULL) { 1243 IkePayloadFree (CpPayload); 1244 } 1245 1246 if (SaPayload != NULL) { 1247 IkePayloadFree (SaPayload); 1248 } 1249 1250 if (TsiPayload != NULL) { 1251 IkePayloadFree (TsiPayload); 1252 } 1253 1254 if (TsrPayload != NULL) { 1255 IkePayloadFree (TsrPayload); 1256 } 1257 1258 if (NotifyPayload != NULL) { 1259 IkePayloadFree (NotifyPayload); 1260 } 1261 1262 return NULL; 1104 1263 } 1105 1264 … … 1133 1292 IKE_PAYLOAD *TsrPayload; 1134 1293 IKE_PAYLOAD *CertPayload; 1135 IKE_PAYLOAD *CertReqPayload;1136 1294 IKE_PAYLOAD *VerifiedAuthPayload; 1137 1295 LIST_ENTRY *Entry; … … 1152 1310 TsrPayload = NULL; 1153 1311 CertPayload = NULL; 1154 CertReqPayload = NULL;1155 1312 VerifiedAuthPayload = NULL; 1156 1313 Status = EFI_INVALID_PARAMETER; … … 1183 1340 if (IkePayload->PayloadType == IKEV2_PAYLOAD_TYPE_CERT) { 1184 1341 CertPayload = IkePayload; 1185 }1186 if (IkePayload->PayloadType == IKEV2_PAYLOAD_TYPE_CERTREQ) {1187 CertReqPayload = IkePayload;1188 1342 } 1189 1343 } … … 1285 1439 if (ChildSaSession->IkeSaSession->Spd == NULL) { 1286 1440 ChildSaSession->IkeSaSession->Spd = ChildSaSession->Spd; 1287 Ikev2ChildSaSessionSpdSelectorCreate (ChildSaSession); 1441 Status = Ikev2ChildSaSessionSpdSelectorCreate (ChildSaSession); 1442 if (EFI_ERROR (Status)) { 1443 goto Exit; 1444 } 1288 1445 } 1289 1446 } else { … … 1327 1484 // 5. Generat keymats for IPsec protocol. 1328 1485 // 1329 Ikev2GenerateChildSaKeys (ChildSaSession, NULL); 1486 Status = Ikev2GenerateChildSaKeys (ChildSaSession, NULL); 1487 if (EFI_ERROR (Status)) { 1488 goto Exit; 1489 } 1490 1330 1491 if (IkeSaSession->SessionCommon.IsInitiator) { 1331 1492 // … … 1365 1526 1366 1527 IkeSaSession->IkeKeys = AllocateZeroPool (sizeof (IKEV2_SESSION_KEYS)); 1367 ASSERT (IkeSaSession->IkeKeys != NULL); 1528 if (IkeSaSession->IkeKeys == NULL) { 1529 return EFI_OUT_OF_RESOURCES; 1530 } 1531 1368 1532 IkeKeys = IkeSaSession->IkeKeys; 1369 1533 IkeKeys->DhBuffer = AllocateZeroPool (sizeof (IKEV2_DH_BUFFER)); 1370 ASSERT (IkeKeys->DhBuffer != NULL); 1534 if (IkeKeys->DhBuffer == NULL) { 1535 FreePool (IkeSaSession->IkeKeys); 1536 return EFI_OUT_OF_RESOURCES; 1537 } 1371 1538 1372 1539 // … … 1375 1542 IkeKeys->DhBuffer->GxSize = OakleyModpGroup[(UINT8)IkeSaSession->SessionCommon.PreferDhGroup].Size >> 3; 1376 1543 IkeKeys->DhBuffer->GxBuffer = AllocateZeroPool (IkeKeys->DhBuffer->GxSize); 1377 ASSERT (IkeKeys->DhBuffer->GxBuffer != NULL); 1544 if (IkeKeys->DhBuffer->GxBuffer == NULL) { 1545 FreePool (IkeKeys->DhBuffer); 1546 FreePool (IkeSaSession->IkeKeys); 1547 return EFI_OUT_OF_RESOURCES; 1548 } 1378 1549 1379 1550 // … … 1390 1561 if (EFI_ERROR (Status)) { 1391 1562 DEBUG ((DEBUG_ERROR, "Error CPLKeyManGetKeyParam X public key error Status = %r\n", Status)); 1563 1564 FreePool (IkeKeys->DhBuffer->GxBuffer); 1565 1566 FreePool (IkeKeys->DhBuffer); 1567 1568 FreePool (IkeSaSession->IkeKeys); 1569 1392 1570 return Status; 1393 1571 } … … 1427 1605 DhBuffer->GxySize = DhBuffer->GxSize; 1428 1606 DhBuffer->GxyBuffer = AllocateZeroPool (DhBuffer->GxySize); 1429 ASSERT (DhBuffer->GxyBuffer != NULL); 1607 if (DhBuffer->GxyBuffer == NULL) { 1608 return EFI_OUT_OF_RESOURCES; 1609 } 1430 1610 1431 1611 // … … 1441 1621 if (EFI_ERROR (Status)) { 1442 1622 DEBUG ((DEBUG_ERROR, "Error CPLKeyManGetKeyParam Y session key error Status = %r\n", Status)); 1623 1624 FreePool (DhBuffer->GxyBuffer); 1625 1443 1626 return Status; 1444 1627 } … … 1449 1632 DhBuffer->GySize = PubKeySize; 1450 1633 DhBuffer->GyBuffer = AllocateZeroPool (DhBuffer->GySize); 1451 ASSERT (DhBuffer->GyBuffer != NULL); 1634 if (DhBuffer->GyBuffer == NULL) { 1635 FreePool (DhBuffer->GxyBuffer); 1636 1637 return Status; 1638 } 1639 1452 1640 CopyMem (DhBuffer->GyBuffer, PubKey, DhBuffer->GySize); 1453 1641 … … 1479 1667 EFI_STATUS Status; 1480 1668 IKEV2_SA_PARAMS *SaParams; 1481 IPSEC_PAD_ENTRY *Pad;1482 1669 PRF_DATA_FRAGMENT Fragments[4]; 1483 1670 UINT64 InitiatorCookieNet; … … 1502 1689 // Generate Gxy 1503 1690 // 1504 Ikev2GenerateSaDhComputeKey (IkeSaSession->IkeKeys->DhBuffer, KePayload); 1505 1506 Pad = IkeSaSession->Pad; 1691 Status = Ikev2GenerateSaDhComputeKey (IkeSaSession->IkeKeys->DhBuffer, KePayload); 1692 if (EFI_ERROR (Status)) { 1693 goto Exit; 1694 } 1507 1695 1508 1696 // … … 1532 1720 KeyBufferSize = IkeSaSession->NiBlkSize + IkeSaSession->NrBlkSize; 1533 1721 KeyBuffer = AllocateZeroPool (KeyBufferSize); 1534 ASSERT (KeyBuffer != NULL); 1722 if (KeyBuffer == NULL) { 1723 Status = EFI_OUT_OF_RESOURCES; 1724 goto Exit; 1725 } 1535 1726 1536 1727 CopyMem (KeyBuffer, IkeSaSession->NiBlock, IkeSaSession->NiBlkSize); … … 1803 1994 // Generate Gxy 1804 1995 // 1805 Ikev2GenerateSaDhComputeKey (ChildSaSession->DhBuffer, KePayload); 1996 Status = Ikev2GenerateSaDhComputeKey (ChildSaSession->DhBuffer, KePayload); 1997 if (EFI_ERROR (Status)) { 1998 goto Exit; 1999 } 2000 1806 2001 Fragments[0].Data = ChildSaSession->DhBuffer->GxyBuffer; 1807 2002 Fragments[0].DataSize = ChildSaSession->DhBuffer->GxySize; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/Utility.c
r58466 r77662 2 2 The Common operations used by IKE Exchange Process. 3 3 4 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 57 58 58 59 IkeSaSession = AllocateZeroPool (sizeof (IKEV2_SA_SESSION)); 59 ASSERT (IkeSaSession != NULL); 60 if (IkeSaSession == NULL) { 61 return NULL; 62 } 60 63 61 64 // … … 523 526 ChildSaSession->IkeSaSession = IkeSaSession; 524 527 ChildSaSession->MessageId = IkeSaSession->MessageId; 525 ChildSaSession->LocalPeerSpi = IkeGenerateSpi (); 528 529 // 530 // Generate an new SPI. 531 // 532 Status = IkeGenerateSpi (IkeSaSession, &(ChildSaSession->LocalPeerSpi)); 533 if (EFI_ERROR (Status)) { 534 FreePool (ChildSaSession); 535 return NULL; 536 } 537 526 538 ChildSaCommon = &ChildSaSession->SessionCommon; 527 539 ChildSaCommon->UdpService = UdpService; … … 572 584 IKEV2_CHILD_SA_SESSION *OldChildSaSession; 573 585 IKEV2_SA_SESSION *IkeSaSession; 574 IKEV2_SA_PARAMS *SaParams;575 586 EFI_STATUS Status; 576 587 UINT64 Lifetime; … … 625 636 // Start to count the lifetime of the IKE SA. 626 637 // 627 SaParams = SessionCommon->SaParams;628 638 if (ChildSaSession->Spd->Data->ProcessingPolicy->SaLifetime.HardLifetime != 0){ 629 639 Lifetime = ChildSaSession->Spd->Data->ProcessingPolicy->SaLifetime.HardLifetime; … … 879 889 EFI_IPSEC_CONFIG_SELECTOR *LocalSelector; 880 890 EFI_IPSEC_CONFIG_SELECTOR *RemoteSelector; 881 IKE_UDP_SERVICE *UdpService;882 891 IPSEC_PRIVATE_DATA *Private; 883 892 … … 891 900 LocalSelector = NULL; 892 901 RemoteSelector = NULL; 893 UdpService = IkeSaSession->SessionCommon.UdpService; 894 895 Private = (UdpService->IpVersion == IP_VERSION_4) ? 896 IPSEC_PRIVATE_DATA_FROM_UDP4LIST(UdpService->ListHead) : 897 IPSEC_PRIVATE_DATA_FROM_UDP6LIST(UdpService->ListHead); 902 903 Private = IkeSaSession->SessionCommon.Private; 898 904 899 905 // … … 914 920 SelectorSize = sizeof (EFI_IPSEC_CONFIG_SELECTOR); 915 921 Selector = AllocateZeroPool (SelectorSize); 916 ASSERT (Selector != NULL);917 918 922 if (Selector == NULL) { 923 return EFI_OUT_OF_RESOURCES; 924 } 919 925 920 926 while (1) { … … 929 935 930 936 Selector = AllocateZeroPool (SelectorSize); 931 ASSERT (Selector != NULL); 937 if (Selector == NULL) { 938 Status = EFI_OUT_OF_RESOURCES; 939 break; 940 } 941 932 942 Status = EfiIpSecConfigGetNextSelector ( 933 943 &Private->IpSecConfig, … … 949 959 IsRemoteFound = TRUE; 950 960 RemoteSelector = AllocateZeroPool (SelectorSize); 951 ASSERT (RemoteSelector != NULL); 961 if (RemoteSelector == NULL) { 962 Status = EFI_OUT_OF_RESOURCES; 963 break; 964 } 965 952 966 CopyMem (RemoteSelector, Selector, SelectorSize); 953 967 } … … 960 974 IsLocalFound = TRUE; 961 975 LocalSelector = AllocateZeroPool (SelectorSize); 962 ASSERT (LocalSelector != NULL); 976 if (LocalSelector == NULL) { 977 Status = EFI_OUT_OF_RESOURCES; 978 break; 979 } 980 963 981 CopyMem (LocalSelector, Selector, SelectorSize); 964 982 } … … 1276 1294 ProposalData->ProtocolId = IPSEC_PROTO_IPSEC_ESP; 1277 1295 ProposalData->Spi = AllocateZeroPool (sizeof (ChildSaSession->LocalPeerSpi)); 1278 ASSERT (ProposalData->Spi != NULL); 1296 if (ProposalData->Spi == NULL) { 1297 FreePool (SaData); 1298 return NULL; 1299 } 1300 1279 1301 CopyMem ( 1280 1302 ProposalData->Spi, … … 1344 1366 ProposalData->NumTransforms = 3; 1345 1367 ProposalData->Spi = AllocateZeroPool (sizeof (ChildSaSession->LocalPeerSpi)); 1346 ASSERT (ProposalData->Spi != NULL); 1368 if (ProposalData->Spi == NULL) { 1369 FreePool (((IKEV2_PROPOSAL_DATA *) (SaData + 1))->Spi); 1370 FreePool (SaData); 1371 return NULL; 1372 } 1373 1347 1374 CopyMem ( 1348 1375 ProposalData->Spi, … … 1738 1765 @param[in, out] ChildSaSession Pointer to IKEV2_CHILD_SA_SESSION related to. 1739 1766 1740 **/ 1741 VOID 1767 @retval EFI_SUCCESS The operation complete successfully. 1768 @retval EFI_OUT_OF_RESOURCES If the required resource can't be allocated. 1769 1770 **/ 1771 EFI_STATUS 1742 1772 Ikev2ChildSaSessionSpdSelectorCreate ( 1743 1773 IN OUT IKEV2_CHILD_SA_SESSION *ChildSaSession 1744 1774 ) 1745 1775 { 1776 EFI_STATUS Status; 1777 1778 Status = EFI_SUCCESS; 1779 1746 1780 if (ChildSaSession->Spd != NULL && ChildSaSession->Spd->Selector != NULL) { 1747 1781 if (ChildSaSession->SpdSelector == NULL) { 1748 1782 ChildSaSession->SpdSelector = AllocateZeroPool (sizeof (EFI_IPSEC_SPD_SELECTOR)); 1749 ASSERT (ChildSaSession->SpdSelector != NULL); 1783 if (ChildSaSession->SpdSelector == NULL) { 1784 Status = EFI_OUT_OF_RESOURCES; 1785 return Status; 1786 } 1750 1787 } 1751 1788 CopyMem ( … … 1759 1796 ChildSaSession->Spd->Selector->RemoteAddress 1760 1797 ); 1798 if (ChildSaSession->SpdSelector->RemoteAddress == NULL) { 1799 Status = EFI_OUT_OF_RESOURCES; 1800 1801 FreePool (ChildSaSession->SpdSelector); 1802 1803 return Status; 1804 } 1805 1761 1806 ChildSaSession->SpdSelector->LocalAddress = AllocateCopyPool ( 1762 1807 ChildSaSession->Spd->Selector->LocalAddressCount * … … 1764 1809 ChildSaSession->Spd->Selector->LocalAddress 1765 1810 ); 1766 1767 ASSERT (ChildSaSession->SpdSelector->LocalAddress != NULL); 1768 ASSERT (ChildSaSession->SpdSelector->RemoteAddress != NULL); 1811 if (ChildSaSession->SpdSelector->LocalAddress == NULL) { 1812 Status = EFI_OUT_OF_RESOURCES; 1813 1814 FreePool (ChildSaSession->SpdSelector->RemoteAddress); 1815 1816 FreePool (ChildSaSession->SpdSelector); 1817 1818 return Status; 1819 } 1769 1820 1770 1821 ChildSaSession->SpdSelector->RemoteAddressCount = ChildSaSession->Spd->Selector->RemoteAddressCount; 1771 1822 ChildSaSession->SpdSelector->LocalAddressCount = ChildSaSession->Spd->Selector->LocalAddressCount; 1772 1823 } 1824 1825 return Status; 1773 1826 } 1774 1827 … … 1795 1848 // 1796 1849 ChildSaSession = Ikev2ChildSaSessionAlloc (UdpService, IkeSaSession); 1797 ASSERT (ChildSaSession != NULL); 1850 if (ChildSaSession == NULL) { 1851 return NULL; 1852 } 1798 1853 1799 1854 // … … 1816 1871 // negoniation and it will be copied into the SAData after ChildSA established. 1817 1872 // 1818 Ikev2ChildSaSessionSpdSelectorCreate (ChildSaSession); 1873 if (EFI_ERROR (Ikev2ChildSaSessionSpdSelectorCreate (ChildSaSession))) { 1874 Ikev2ChildSaSessionFree (ChildSaSession); 1875 return NULL; 1876 } 1819 1877 1820 1878 // … … 1822 1880 // 1823 1881 ChildSaSession->NiBlock = AllocateZeroPool (IkeSaSession->NiBlkSize); 1824 ASSERT (ChildSaSession->NiBlock != NULL); 1882 if (ChildSaSession->NiBlock == NULL) { 1883 Ikev2ChildSaSessionFree (ChildSaSession); 1884 return NULL; 1885 } 1886 1825 1887 ChildSaSession->NiBlkSize = IkeSaSession->NiBlkSize; 1826 1888 CopyMem (ChildSaSession->NiBlock, IkeSaSession->NiBlock, IkeSaSession->NiBlkSize); 1827 1889 1828 1890 ChildSaSession->NrBlock = AllocateZeroPool (IkeSaSession->NrBlkSize); 1829 ASSERT (ChildSaSession->NrBlock != NULL); 1891 if (ChildSaSession->NrBlock == NULL) { 1892 Ikev2ChildSaSessionFree (ChildSaSession); 1893 return NULL; 1894 } 1895 1830 1896 ChildSaSession->NrBlkSize = IkeSaSession->NrBlkSize; 1831 1897 CopyMem (ChildSaSession->NrBlock, IkeSaSession->NrBlock, IkeSaSession->NrBlkSize); … … 2200 2266 // 2201 2267 IkeSaSession->SessionCommon.SaParams = AllocateZeroPool (sizeof (IKEV2_SA_PARAMS)); 2202 ASSERT (IkeSaSession->SessionCommon.SaParams != NULL); 2268 if (IkeSaSession->SessionCommon.SaParams == NULL) { 2269 return FALSE; 2270 } 2271 2203 2272 IkeSaSession->SessionCommon.SaParams->EncAlgId = PreferEncryptAlgorithm; 2204 2273 IkeSaSession->SessionCommon.SaParams->EnckeyLen = PreferEncryptKeylength; … … 2215 2284 sizeof (IKEV2_TRANSFORM_DATA) * 4; 2216 2285 IkeSaSession->SaData = AllocateZeroPool (SaDataSize); 2217 ASSERT (IkeSaSession->SaData != NULL); 2286 if (IkeSaSession->SaData == NULL) { 2287 FreePool (IkeSaSession->SessionCommon.SaParams); 2288 return FALSE; 2289 } 2218 2290 2219 2291 IkeSaSession->SaData->NumProposals = 1; … … 2231 2303 2232 2304 ((IKEV2_PROPOSAL_DATA *) (IkeSaSession->SaData + 1))->ProposalIndex = 1; 2305 2233 2306 return TRUE; 2234 2307 } else { … … 2306 2379 if (IsMatch) { 2307 2380 IkeSaSession->SessionCommon.SaParams = AllocateZeroPool (sizeof (IKEV2_SA_PARAMS)); 2308 ASSERT (IkeSaSession->SessionCommon.SaParams != NULL); 2381 if (IkeSaSession->SessionCommon.SaParams == NULL) { 2382 return FALSE; 2383 } 2384 2309 2385 IkeSaSession->SessionCommon.SaParams->EncAlgId = PreferEncryptAlgorithm; 2310 2386 IkeSaSession->SessionCommon.SaParams->EnckeyLen = PreferEncryptKeylength; … … 2317 2393 } 2318 2394 } 2395 2319 2396 return FALSE; 2320 2397 } … … 2397 2474 // 2398 2475 ChildSaSession->SessionCommon.SaParams = AllocateZeroPool (sizeof (IKEV2_SA_PARAMS)); 2399 ASSERT (ChildSaSession->SessionCommon.SaParams != NULL); 2476 if (ChildSaSession->SessionCommon.SaParams == NULL) { 2477 return FALSE; 2478 } 2479 2400 2480 ChildSaSession->SessionCommon.SaParams->EncAlgId = PreferEncryptAlgorithm; 2401 2481 ChildSaSession->SessionCommon.SaParams->EnckeyLen = PreferEncryptKeylength; … … 2411 2491 2412 2492 ChildSaSession->SaData = AllocateZeroPool (SaDataSize); 2413 ASSERT (ChildSaSession->SaData != NULL); 2493 if (ChildSaSession->SaData == NULL) { 2494 FreePool (ChildSaSession->SessionCommon.SaParams); 2495 return FALSE; 2496 } 2414 2497 2415 2498 ChildSaSession->SaData->NumProposals = 1; … … 2432 2515 &ChildSaSession->LocalPeerSpi 2433 2516 ); 2434 ASSERT (((IKEV2_PROPOSAL_DATA *) (ChildSaSession->SaData + 1))->Spi != NULL); 2517 if (((IKEV2_PROPOSAL_DATA *) (ChildSaSession->SaData + 1))->Spi == NULL) { 2518 FreePool (ChildSaSession->SessionCommon.SaParams); 2519 2520 FreePool (ChildSaSession->SaData ); 2521 2522 return FALSE; 2523 } 2524 2435 2525 return TRUE; 2436 2526 … … 2502 2592 if (IsMatch) { 2503 2593 ChildSaSession->SessionCommon.SaParams = AllocateZeroPool (sizeof (IKEV2_SA_PARAMS)); 2504 ASSERT (ChildSaSession->SessionCommon.SaParams != NULL); 2594 if (ChildSaSession->SessionCommon.SaParams == NULL) { 2595 return FALSE; 2596 } 2597 2505 2598 ChildSaSession->SessionCommon.SaParams->EncAlgId = PreferEncryptAlgorithm; 2506 2599 ChildSaSession->SessionCommon.SaParams->EnckeyLen = PreferEncryptKeylength; … … 2535 2628 @retval EFI_SUCCESS The operation complete successfully. 2536 2629 @retval EFI_INVALID_PARAMETER If NumFragments is zero. 2630 If the authentication algorithm given by HashAlgId 2631 cannot be found. 2537 2632 @retval EFI_OUT_OF_RESOURCES If the required resource can't be allocated. 2538 2633 @retval Others The operation is failed. … … 2571 2666 2572 2667 AuthKeyLength = IpSecGetHmacDigestLength (HashAlgId); 2668 if (AuthKeyLength == 0) { 2669 return EFI_INVALID_PARAMETER; 2670 } 2671 2573 2672 DigestSize = AuthKeyLength; 2574 2673 Digest = AllocateZeroPool (AuthKeyLength); … … 2611 2710 2612 2711 LocalFragments[1].Data = AllocateZeroPool (FragmentsSize); 2613 ASSERT (LocalFragments[1].Data != NULL); 2712 if (LocalFragments[1].Data == NULL) { 2713 Status = EFI_OUT_OF_RESOURCES; 2714 goto Exit; 2715 } 2716 2614 2717 LocalFragments[1].DataSize = FragmentsSize; 2615 2718 … … 2637 2740 // 2638 2741 LocalFragments[0].Data = AllocateZeroPool (AuthKeyLength); 2639 ASSERT (LocalFragments[0].Data != NULL); 2742 if (LocalFragments[0].Data == NULL) { 2743 Status = EFI_OUT_OF_RESOURCES; 2744 goto Exit; 2745 } 2746 2640 2747 LocalFragments[0].DataSize = AuthKeyLength; 2641 2748 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/Ikev2/Utility.h
r58466 r77662 3 3 used by IKE Exchange Process. 4 4 5 Copyright (c) 2010 , Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 1121 1121 @param[in, out] ChildSaSession Pointer to IKEV2_CHILD_SA_SESSION related to. 1122 1122 1123 **/ 1124 VOID 1123 @retval EFI_SUCCESS The operation complete successfully. 1124 @retval EFI_OUT_OF_RESOURCES If the required resource can't be allocated. 1125 1126 **/ 1127 EFI_STATUS 1125 1128 Ikev2ChildSaSessionSpdSelectorCreate ( 1126 1129 IN OUT IKEV2_CHILD_SA_SESSION *ChildSaSession -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecConfigImpl.c
r58466 r77662 2 2 The implementation of IPSEC_CONFIG_PROTOCOL. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 212 212 213 213 // 214 // Compare the all LocalAddress fields in the two Spdselectors.214 // Compare the all LocalAddress and RemoteAddress fields in the two Spdselectors. 215 215 // First, SpdSel1->LocalAddress to SpdSel2->LocalAddress && Compare 216 216 // SpdSel1->RemoteAddress to SpdSel2->RemoteAddress. If all match, return … … 373 373 374 374 // 375 // Compare the all LocalAddress fields in the two Spdselectors.375 // Compare the all LocalAddress and RemoteAddress fields in the two Spdselectors. 376 376 // First, SpdSel1->LocalAddress to SpdSel2->LocalAddress && Compare 377 377 // SpdSel1->RemoteAddress to SpdSel2->RemoteAddress. If all match, return … … 430 430 431 431 // 432 // Compare the all LocalAddress fields in the two Spdselectors.433 // First, SpdSel1->LocalAddress to SpdSel2-> LocalAddress && Compare434 // SpdSel1->RemoteAddress to SpdSel2-> RemoteAddress. If all match, return432 // Compare the all LocalAddress and RemoteAddress fields in the two Spdselectors. 433 // First, SpdSel1->LocalAddress to SpdSel2->RemoteAddress && Compare 434 // SpdSel1->RemoteAddress to SpdSel2->LocalAddress. If all match, return 435 435 // TRUE. 436 436 // … … 1019 1019 - The Action of Data is protected and its policy 1020 1020 mode is not Tunnel and it tunnel option is not NULL. 1021 - SadEntry requied to be set into new SpdEntry's Sas has 1022 been found but it is invalid. 1021 1023 @retval EFI_OUT_OF_RESOURCED The required system resource could not be allocated. 1022 1024 @retval EFI_SUCCESS The specified configuration data was obtained successfully. … … 1040 1042 LIST_ENTRY *Entry2; 1041 1043 LIST_ENTRY *NextEntry; 1044 LIST_ENTRY *NextEntry2; 1042 1045 IPSEC_SPD_ENTRY *SpdEntry; 1043 1046 IPSEC_SAD_ENTRY *SadEntry; … … 1098 1101 1099 1102 // 1100 // TODO: Deleted the related SAs. 1101 // 1102 NET_LIST_FOR_EACH (Entry2, SpdSas) { 1103 SadEntry = IPSEC_SAD_ENTRY_FROM_SPD (Entry2); 1104 SadEntry->Data->SpdEntry = NULL; 1103 // Remove the related SAs from Sas(SadEntry->BySpd). If the SA entry is established by 1104 // IKE, remove from mConfigData list(SadEntry->List) and then free it directly since its 1105 // SpdEntry will be freed later. 1106 // 1107 NET_LIST_FOR_EACH_SAFE (Entry2, NextEntry2, SpdSas) { 1108 SadEntry = IPSEC_SAD_ENTRY_FROM_SPD (Entry2); 1109 1110 if (SadEntry->Data->SpdEntry != NULL) { 1111 RemoveEntryList (&SadEntry->BySpd); 1112 SadEntry->Data->SpdEntry = NULL; 1113 } 1114 1115 if (!(SadEntry->Data->ManualSet)) { 1116 RemoveEntryList (&SadEntry->List); 1117 FreePool (SadEntry); 1118 } 1105 1119 } 1106 1120 … … 1139 1153 // 1140 1154 SpdEntrySize = ALIGN_VARIABLE (sizeof (IPSEC_SPD_ENTRY)); 1141 SpdEntrySize = ALIGN_VARIABLE (SpdEntrySize + (UINTN)SIZE_OF_SPD_SELECTOR (SpdSel));1155 SpdEntrySize = ALIGN_VARIABLE (SpdEntrySize + SIZE_OF_SPD_SELECTOR (SpdSel)); 1142 1156 SpdEntrySize += IpSecGetSizeOfEfiSpdData (SpdData); 1143 1157 … … 1168 1182 sizeof (SpdData->Name) 1169 1183 ); 1170 SpdEntry->Data->PackageFlag = SpdData->PackageFlag; 1171 SpdEntry->Data->Action = SpdData->Action; 1184 SpdEntry->Data->PackageFlag = SpdData->PackageFlag; 1185 SpdEntry->Data->TrafficDirection = SpdData->TrafficDirection; 1186 SpdEntry->Data->Action = SpdData->Action; 1172 1187 1173 1188 // … … 1194 1209 SadEntry = IPSEC_SAD_ENTRY_FROM_LIST (Entry); 1195 1210 1196 for (Index = 0; Index < SpdData->SaIdCount; Index++) { 1197 1198 if (CompareSaId ( 1199 (EFI_IPSEC_CONFIG_SELECTOR *) &SpdData->SaId[Index], 1200 (EFI_IPSEC_CONFIG_SELECTOR *) SadEntry->Id 1201 )) { 1202 InsertTailList (&SpdEntry->Data->Sas, &SadEntry->BySpd); 1203 SadEntry->Data->SpdEntry = SpdEntry; 1204 DuplicateSpdSelector ( 1205 (EFI_IPSEC_CONFIG_SELECTOR *)SadEntry->Data->SpdSelector, 1206 (EFI_IPSEC_CONFIG_SELECTOR *)SpdEntry->Selector, 1207 NULL 1208 ); 1209 } 1210 } 1211 } 1211 for (Index = 0; Index < SpdData->SaIdCount; Index++) { 1212 if (CompareSaId ( 1213 (EFI_IPSEC_CONFIG_SELECTOR *) &SpdData->SaId[Index], 1214 (EFI_IPSEC_CONFIG_SELECTOR *) SadEntry->Id 1215 )) { 1216 // 1217 // Check whether the found SadEntry is vaild. 1218 // 1219 if (IsSubSpdSelector ( 1220 (EFI_IPSEC_CONFIG_SELECTOR *) SadEntry->Data->SpdSelector, 1221 (EFI_IPSEC_CONFIG_SELECTOR *) SpdEntry->Selector 1222 )) { 1223 if (SadEntry->Data->SpdEntry != NULL) { 1224 RemoveEntryList (&SadEntry->BySpd); 1225 } 1226 InsertTailList (&SpdEntry->Data->Sas, &SadEntry->BySpd); 1227 SadEntry->Data->SpdEntry = SpdEntry; 1228 } else { 1229 return EFI_INVALID_PARAMETER; 1230 } 1231 } 1232 } 1233 } 1234 1212 1235 // 1213 1236 // Insert the new SPD entry. … … 1335 1358 1336 1359 if (SaData->SpdSelector != NULL) { 1337 SadEntrySize += SadEntrySize + (UINTN)SIZE_OF_SPD_SELECTOR (SaData->SpdSelector);1360 SadEntrySize += SadEntrySize + SIZE_OF_SPD_SELECTOR (SaData->SpdSelector); 1338 1361 } 1339 1362 SadEntry = AllocateZeroPool (SadEntrySize); … … 1436 1459 SadEntry->Data->SpdSelector = (EFI_IPSEC_SPD_SELECTOR *)((UINT8 *)SadEntry + 1437 1460 SadEntrySize - 1438 (UINTN)SIZE_OF_SPD_SELECTOR (SaData->SpdSelector)1461 SIZE_OF_SPD_SELECTOR (SaData->SpdSelector) 1439 1462 ); 1440 1463 DuplicateSpdSelector ( … … 1688 1711 CopyMem (SpdData->Name, SpdEntry->Data->Name, sizeof (SpdData->Name)); 1689 1712 1690 SpdData->PackageFlag = SpdEntry->Data->PackageFlag; 1691 SpdData->Action = SpdEntry->Data->Action; 1713 SpdData->PackageFlag = SpdEntry->Data->PackageFlag; 1714 SpdData->TrafficDirection = SpdEntry->Data->TrafficDirection; 1715 SpdData->Action = SpdEntry->Data->Action; 1692 1716 1693 1717 if (SpdData->Action != EfiIPsecActionProtect) { … … 2152 2176 VariableNameISize = (VariableNameLength + 5) * sizeof (CHAR16); 2153 2177 VariableNameI = AllocateZeroPool (VariableNameISize); 2154 ASSERT (VariableNameI != NULL); 2178 if (VariableNameI == NULL) { 2179 Status = EFI_OUT_OF_RESOURCES; 2180 goto ON_EXIT; 2181 } 2155 2182 2156 2183 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecConfigImpl.h
r58466 r77662 2 2 Definitions related to IPSEC_CONFIG_PROTOCOL implementations. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 39 39 #define IPSECCONFIG_STATUS_NAME L"IpSecStatus" 40 40 41 #define SIZE_OF_SPD_SELECTOR(x) ( UINTN) (sizeof (EFI_IPSEC_SPD_SELECTOR) \41 #define SIZE_OF_SPD_SELECTOR(x) (sizeof (EFI_IPSEC_SPD_SELECTOR) \ 42 42 + sizeof (EFI_IP_ADDRESS_INFO) * ((x)->LocalAddressCount + (x)->RemoteAddressCount)) 43 43 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecCryptIo.c
r58466 r77662 2 2 Common interfaces to call Security library. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 46 46 47 47 /** 48 Get the block size of specified encryption al ogrithm.48 Get the block size of specified encryption algorithm. 49 49 50 50 @param[in] AlgorithmId The encryption algorithm ID. … … 70 70 71 71 /** 72 Get the key length of the specified encryption al ogrithm.72 Get the key length of the specified encryption algorithm. 73 73 74 74 @param[in] AlgorithmId The encryption algorithm ID. … … 94 94 95 95 /** 96 Get the IV size of the specified encryption al ogrithm.96 Get the IV size of the specified encryption algorithm. 97 97 98 98 @param[in] AlgorithmId The encryption algorithm ID. … … 145 145 146 146 /** 147 Get the ICV size of the specified Authenticaion al ogrithm.147 Get the ICV size of the specified Authenticaion algorithm. 148 148 149 149 @param[in] AlgorithmId The Authentication algorithm ID. … … 192 192 193 193 /** 194 Get index of the specified encryption al ogrithm from the mIpsecEncryptAlgorithemList.194 Get index of the specified encryption algorithm from the mIpsecEncryptAlgorithmList. 195 195 196 196 @param[in] AlgorithmId The encryption algorithm ID. … … 216 216 217 217 /** 218 Get index of the specified encryption al ogrithm from the mIpsecAuthAlgorithemList.218 Get index of the specified encryption algorithm from the mIpsecAuthAlgorithmList. 219 219 220 220 @param[in] AlgorithmId The encryption algorithm ID. … … 246 246 247 247 This function calls relevant encryption interface from CryptoLib according to 248 the input al ogrithm ID. The InData should be multiple of block size. This function248 the input algorithm ID. The InData should be multiple of block size. This function 249 249 doesn't perform the padding. If it has the Ivec data, the length of it should be 250 250 same with the block size. The block size is different from the different algorithm. 251 251 252 @param[in] AlgorithmId The Al ogrithem identification defined in RFC.252 @param[in] AlgorithmId The Algorithm identification defined in RFC. 253 253 @param[in] Key Pointer to the buffer containing encrypting key. 254 254 @param[in] KeyBits The length of the key in bits. 255 @param[in] Ivec Point to the buffer contain ning the Initializeion255 @param[in] Ivec Point to the buffer containing the Initialization 256 256 Vector (IV) data. 257 257 @param[in] InData Point to the buffer containing the data to be … … 332 332 333 333 This function calls relevant Decryption interface from CryptoLib according to 334 the input al ogrithm ID. The InData should be multiple of block size. This function334 the input algorithm ID. The InData should be multiple of block size. This function 335 335 doesn't perform the padding. If it has the Ivec data, the length of it should be 336 336 same with the block size. The block size is different from the different algorithm. 337 337 338 @param[in] AlgorithmId The Al ogrithem identification defined in RFC.338 @param[in] AlgorithmId The Algorithm identification defined in RFC. 339 339 @param[in] Key Pointer to the buffer containing encrypting key. 340 340 @param[in] KeyBits The length of the key in bits. 341 @param[in] Ivec Point to the buffer contain ning the Initializeion341 @param[in] Ivec Point to the buffer containing the Initialization 342 342 Vector (IV) data. 343 343 @param[in] InData Point to the buffer containing the data to be … … 418 418 419 419 This function calls relevant Hmac interface from CryptoLib according to 420 the input al ogrithm ID. It computes all datas from InDataFragment and output420 the input algorithm ID. It computes all datas from InDataFragment and output 421 421 the result into the OutData buffer. If the OutDataSize is larger than the related 422 HMAC al ogrithm output size, return EFI_INVALID_PARAMETER.422 HMAC algorithm output size, return EFI_INVALID_PARAMETER. 423 423 424 424 @param[in] AlgorithmId The authentication Identification. … … 541 541 542 542 This function calls relevant Hash interface from CryptoLib according to 543 the input al ogrithm ID. It computes all datas from InDataFragment and output543 the input algorithm ID. It computes all datas from InDataFragment and output 544 544 the result into the OutData buffer. If the OutDataSize is larger than the related 545 Hash al ogrithm output size, return EFI_INVALID_PARAMETER.545 Hash algorithm output size, return EFI_INVALID_PARAMETER. 546 546 547 547 @param[in] AlgorithmId The authentication Identification. … … 658 658 659 659 This function first initiate a DHContext, then call the DhSetParameter() to set 660 the prime and primeleng ht, at end call the DhGenerateKey() to generates random660 the prime and primelength, at end call the DhGenerateKey() to generates random 661 661 secret exponent, and computes the public key. The output returned via parameter 662 662 PublicKey and PublicKeySize. DH context is updated accordingly. If the PublicKey … … 665 665 666 666 @param[in, out] DhContext Pointer to the DH context. 667 @param[in] Generator V laue of generator.667 @param[in] Generator Value of generator. 668 668 @param[in] PrimeLength Length in bits of prime to be generated. 669 669 @param[in] Prime Pointer to the buffer to receive the generated … … 674 674 buffer in bytes. 675 675 676 @retval EFI_SUCCESS The operation perfo ms successfully.676 @retval EFI_SUCCESS The operation performs successfully. 677 677 @retval Otherwise The operation is failed. 678 678 … … 726 726 buffer in bytes. 727 727 728 @retval EFI_SUCCESS The operation perfo ms successfully.728 @retval EFI_SUCCESS The operation performs successfully. 729 729 @retval Otherwise The operation is failed. 730 730 … … 751 751 @param[in, out] DhContext Pointer to the DH context to be freed. 752 752 753 @retval EFI_SUCCESS The operation perfo ms successfully.753 @retval EFI_SUCCESS The operation performs successfully. 754 754 @retval EFI_INVALID_PARAMETER The DhContext is NULL. 755 755 … … 774 774 775 775 @param[out] OutBuffer Pointer to buffer to receive random value. 776 @param[in] Bytes Size of random ebytes to generate.777 778 @retval EFI_SUCCESS The operation perfo ms successfully.776 @param[in] Bytes Size of random bytes to generate. 777 778 @retval EFI_SUCCESS The operation performs successfully. 779 779 @retval Otherwise The operation is failed. 780 780 … … 870 870 @param[in] InCa Pointer to the CA certificate 871 871 @param[in] CaLen The size of CA certificate in bytes. 872 @param[in] InData Pointer to octe ct message hash to be checked.872 @param[in] InData Pointer to octet message hash to be checked. 873 873 @param[in] InDataSize Size of the message hash in bytes. 874 @param[in] Singnature The pointer to the RSA PKCS1-V1_5 signature to be verif ed.874 @param[in] Singnature The pointer to the RSA PKCS1-V1_5 signature to be verified. 875 875 @param[in] SigSize Size of signature in bytes. 876 876 … … 969 969 970 970 *PublicKey = AllocateZeroPool (*PublicKeyLen); 971 ASSERT (*PublicKey != NULL); 971 if (*PublicKey == NULL) { 972 Status = EFI_OUT_OF_RESOURCES; 973 goto EXIT; 974 } 972 975 973 976 if (!RsaGetKey (RsaContext, RsaKeyN, *PublicKey, PublicKeyLen)) { -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecCryptIo.h
r58466 r77662 105 105 106 106 /** 107 Prototype of HMAC final lization.107 Prototype of HMAC finalization. 108 108 Terminate a HMAC message digest operation and output the message digest. 109 109 … … 140 140 /** 141 141 Prototype of Block Cipher initiation. 142 In tializes the user-supplied key as the specifed context (key materials) for both142 Initializes the user-supplied key as the specified context (key materials) for both 143 143 encryption and decryption operations. 144 144 … … 166 166 167 167 If Context is NULL, then ASSERT(). 168 if InData is NULL, then ASSERT().168 If InData is NULL, then ASSERT(). 169 169 If Size of input data is not multiple of Cipher algorithm related block size, 170 170 then ASSERT(). … … 194 194 195 195 If Context is NULL, then ASSERT(). 196 if InData is NULL, then ASSERT().196 If InData is NULL, then ASSERT(). 197 197 If Size of input data is not a multiple of a certaion block size , then ASSERT(). 198 198 … … 257 257 This function performs digest on a data buffer of the specified size. 258 258 It can be called multiple times to compute the digest of long or discontinuous data streams. 259 Context should be already correctly in tialized by HashInit(), and should not be finalized259 Context should be already correctly initialized by HashInit(), and should not be finalized 260 260 by HashFinal(). Behavior with invalid context is undefined. 261 261 … … 286 286 the specified memory. After this function has been called, the context cannot 287 287 be used again. 288 context should be already correctly in tialized by HashInit(), and should not be288 context should be already correctly initialized by HashInit(), and should not be 289 289 finalized by HashFinal(). Behavior with invalid context is undefined. 290 290 … … 340 340 CRYPTO_CIPHER_ENCRYPT CipherEncrypt; 341 341 // 342 // The Function pointer of Cipher Decr ption.342 // The Function pointer of Cipher Decryption. 343 343 // 344 344 CRYPTO_CIPHER_DECRYPT CipherDecrypt; … … 346 346 347 347 // 348 // The struct used to store the information and operation of Aut ahentication algorithm.348 // The struct used to store the information and operation of Authentication algorithm. 349 349 // 350 350 typedef struct _AUTH_ALGORITHM { … … 384 384 385 385 // 386 // The struct used to store the informati noand operation of Hash algorithm.386 // The struct used to store the information and operation of Hash algorithm. 387 387 // 388 388 typedef struct _HASH_ALGORITHM { … … 422 422 423 423 /** 424 Get the IV size of specified encryption al ogrithm.424 Get the IV size of specified encryption algorithm. 425 425 426 426 @param[in] AlgorithmId The encryption algorithm ID. … … 435 435 436 436 /** 437 Get the block size of specified encryption al ogrithm.437 Get the block size of specified encryption algorithm. 438 438 439 439 @param[in] AlgorithmId The encryption algorithm ID. … … 448 448 449 449 /** 450 Get the required key length of the specified encryption al ogrithm.450 Get the required key length of the specified encryption algorithm. 451 451 452 452 @param[in] AlgorithmId The encryption algorithm ID. … … 461 461 462 462 /** 463 Get the ICV size of the specified Authentica ion alogrithm.463 Get the ICV size of the specified Authentication algorithm. 464 464 465 465 @param[in] AlgorithmId The Authentication algorithm ID. … … 476 476 Get the HMAC digest length by the specified Algorithm ID. 477 477 478 @param[in] AlgorithmId The specified Al ogrithm ID.478 @param[in] AlgorithmId The specified Algorithm ID. 479 479 480 480 @return The digest length of the specified Authentication Algorithm ID. … … 506 506 507 507 This function calls relevant encryption interface from CryptoLib according to 508 the input al ogrithm ID. The InData should be multiple of block size. This function508 the input algorithm ID. The InData should be multiple of block size. This function 509 509 doesn't perform the padding. If it has the Ivec data, the length of it should be 510 510 same with the block size. The block size is different from the different algorithm. 511 511 512 @param[in] AlgorithmId The Al ogrithem identification defined in RFC.512 @param[in] AlgorithmId The Algorithm identification defined in RFC. 513 513 @param[in] Key Pointer to the buffer containing encrypting key. 514 514 @param[in] KeyBits The length of the key in bits. 515 @param[in] Ivec Point to the buffer contain ning the Initializeion515 @param[in] Ivec Point to the buffer containing the Initialization 516 516 Vector (IV) data. 517 517 @param[in] InData Point to the buffer containing the data to be … … 541 541 542 542 This function calls relevant Decryption interface from CryptoLib according to 543 the input al ogrithm ID. The InData should be multiple of block size. This function543 the input algorithm ID. The InData should be multiple of block size. This function 544 544 doesn't perform the padding. If it has the Ivec data, the length of it should be 545 545 same with the block size. The block size is different from the different algorithm. 546 546 547 @param[in] AlgorithmId The Al ogrithem identification defined in RFC.547 @param[in] AlgorithmId The Algorithm identification defined in RFC. 548 548 @param[in] Key Pointer to the buffer containing encrypting key. 549 549 @param[in] KeyBits The length of the key in bits. 550 @param[in] Ivec Point to the buffer contain ning the Initializeion550 @param[in] Ivec Point to the buffer containing the Initialization 551 551 Vector (IV) data. 552 552 @param[in] InData Point to the buffer containing the data to be … … 576 576 577 577 This function calls relevant Hmac interface from CryptoLib according to 578 the input al ogrithm ID. It computes all datas from InDataFragment and output578 the input algorithm ID. It computes all datas from InDataFragment and output 579 579 the result into the OutData buffer. If the OutDataSize is larger than the related 580 HMAC al ogrithm output size, return EFI_INVALID_PARAMETER.580 HMAC algorithm output size, return EFI_INVALID_PARAMETER. 581 581 582 582 @param[in] AlgorithmId The authentication Identification. … … 610 610 611 611 This function calls relevant Hash interface from CryptoLib according to 612 the input al ogrithm ID. It computes all datas from InDataFragment and output612 the input algorithm ID. It computes all datas from InDataFragment and output 613 613 the result into the OutData buffer. If the OutDataSize is larger than the related 614 Hash al ogrithm output size, return EFI_INVALID_PARAMETER.614 Hash algorithm output size, return EFI_INVALID_PARAMETER. 615 615 616 616 @param[in] AlgorithmId The authentication Identification. … … 641 641 642 642 This function first initiate a DHContext, then call the DhSetParameter() to set 643 the prime and primeleng ht, at end call the DhGenerateKey() to generates random643 the prime and primelength, at end call the DhGenerateKey() to generates random 644 644 secret exponent, and computes the public key. The output returned via parameter 645 645 PublicKey and PublicKeySize. DH context is updated accordingly. If the PublicKey … … 648 648 649 649 @param[in, out] DhContext Pointer to the DH context. 650 @param[in] Generator V laue of generator.650 @param[in] Generator Value of generator. 651 651 @param[in] PrimeLength Length in bits of prime to be generated. 652 652 @param[in] Prime Pointer to the buffer to receive the generated … … 657 657 buffer in bytes. 658 658 659 @retval EFI_SUCCESS The operation perfo ms successfully.659 @retval EFI_SUCCESS The operation performs successfully. 660 660 @retval Otherwise The operation is failed. 661 661 … … 685 685 buffer in bytes. 686 686 687 @retval EFI_SUCCESS The operation perfo ms successfully.687 @retval EFI_SUCCESS The operation performs successfully. 688 688 @retval Otherwise The operation is failed. 689 689 … … 703 703 @param[in, out] DhContext Pointer to the DH context to be freed. 704 704 705 @retval EFI_SUCCESS The operation perfo ms successfully.705 @retval EFI_SUCCESS The operation performs successfully. 706 706 @retval EFI_INVALID_PARAMETER The DhContext is NULL. 707 707 … … 718 718 719 719 @param[out] OutBuffer Pointer to buffer to receive random value. 720 @param[in] Bytes Size of random ebytes to generate.721 722 @retval EFI_SUCCESS The operation perfo ms successfully.720 @param[in] Bytes Size of random bytes to generate. 721 722 @retval EFI_SUCCESS The operation performs successfully. 723 723 @retval Otherwise The operation is failed. 724 724 … … 763 763 @param[in] InCa Pointer to the CA certificate 764 764 @param[in] CaLen The size of CA certificate in bytes. 765 @param[in] InData Pointer to octe ct message hash to be checked.765 @param[in] InData Pointer to octet message hash to be checked. 766 766 @param[in] InDataSize Size of the message hash in bytes. 767 @param[in] Singnature The pointer to the RSA PKCS1-V1_5 signature to be verif ed.767 @param[in] Singnature The pointer to the RSA PKCS1-V1_5 signature to be verified. 768 768 @param[in] SigSize Size of signature in bytes. 769 769 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecDriver.c
r58466 r77662 2 2 Driver Binding Protocol for IPsec Driver. 3 3 4 Copyright (c) 2009 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 179 179 LIST_ENTRY *Entry; 180 180 LIST_ENTRY *Next; 181 IKEV2_SA_SESSION *Ikev2SaSession; 181 182 182 183 // … … 197 198 if ((IpVersion == IP_VERSION_4 && Private->Udp6Num ==0) || 198 199 (IpVersion == IP_VERSION_6 && Private->Udp4Num ==0)) { 199 IkeDeleteAllSas (Private, FALSE); 200 // 201 // If IKEv2 SAs are under establishing, delete it directly. 202 // 203 if (!IsListEmpty (&Private->Ikev2SessionList)) { 204 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Ikev2SessionList) { 205 Ikev2SaSession = IKEV2_SA_SESSION_BY_SESSION (Entry); 206 RemoveEntryList (&Ikev2SaSession->BySessionTable); 207 Ikev2SaSessionFree (Ikev2SaSession); 208 } 209 } 210 211 // 212 // Delete established IKEv2 SAs. 213 // 214 if (!IsListEmpty (&Private->Ikev2EstablishedList)) { 215 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Ikev2EstablishedList) { 216 Ikev2SaSession = IKEV2_SA_SESSION_BY_SESSION (Entry); 217 RemoveEntryList (&Ikev2SaSession->BySessionTable); 218 Ikev2SaSessionFree (Ikev2SaSession); 219 } 220 } 200 221 } 201 222 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecDxe.inf
r58466 r77662 7 7 # ESP and it supports IKEv2 for key negotiation. 8 8 # 9 # Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>9 # Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR> 10 10 # 11 11 # This program and the accompanying materials … … 90 90 91 91 [Protocols] 92 gEfiIp4Config ProtocolGuid## SOMETIMES_CONSUMES92 gEfiIp4Config2ProtocolGuid ## SOMETIMES_CONSUMES 93 93 gEfiUdp4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES 94 94 gEfiUdp4ProtocolGuid ## SOMETIMES_CONSUMES -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecDxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Packet-level security for IP datagram. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecDxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // IpSecDxe Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecImpl.c
r48674 r77662 2 2 The implementation of IPsec. 3 3 4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 899 900 UINT8 *Option; 900 901 UINT8 OptionLen; 901 BOOLEAN Flag;902 902 UINT8 CountD; 903 903 UINT8 CountF; … … 919 919 920 920 Pointer = 0; 921 Flag = FALSE;922 921 CountD = 0; 923 922 CountF = 0; … … 931 930 return FALSE; 932 931 } 933 934 Flag = TRUE;935 932 936 933 // … … 1193 1190 on return. 1194 1191 @param[in] FragmentCount The number of fragments. 1195 1196 @retval EFI_SUCCESS The operation was successful.1197 @retval EFI_OUT_OF_RESOURCES The required system resources can't be allocated.1198 1192 1199 1193 **/ … … 1224 1218 if (IpVersion == IP_VERSION_4) { 1225 1219 InnerHead = AllocateZeroPool (sizeof (IP4_HEAD) + *OptionsLength); 1226 ASSERT (InnerHead != NULL); 1220 if (InnerHead == NULL) { 1221 return NULL; 1222 } 1223 1227 1224 CopyMem ( 1228 1225 InnerHead, … … 1237 1234 } else { 1238 1235 InnerHead = AllocateZeroPool (sizeof (EFI_IP6_HEADER) + *OptionsLength); 1239 ASSERT (InnerHead != NULL); 1236 if (InnerHead == NULL) { 1237 return NULL; 1238 } 1239 1240 1240 CopyMem ( 1241 1241 InnerHead, … … 1268 1268 NULL 1269 1269 ); 1270 ASSERT (Packet != NULL); 1270 if (Packet == NULL) { 1271 FreePool (InnerHead); 1272 return NULL; 1273 } 1274 1271 1275 // 1272 1276 // 3. Check the Last Header, if it is TCP, UDP or ICMP recalcualate its pesudo … … 1621 1625 // Update the total length field in ip header since processed by esp. 1622 1626 // 1623 if ( !SadData->Mode == EfiIPsecTunnel) {1627 if (SadData->Mode != EfiIPsecTunnel) { 1624 1628 if (IpVersion == IP_VERSION_4) { 1625 1629 ((IP4_HEAD *) IpHead)->TotalLen = HTONS ((UINT16) ((((IP4_HEAD *) IpHead)->HeadLen << 2) + PlainPayloadSize)); … … 1775 1779 1776 1780 // 1777 // Calculate the plain payload size acc roding to the fragment table.1781 // Calculate the plain payload size according to the fragment table. 1778 1782 // 1779 1783 PlainPayloadSize = 0; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/IpSecDxe/IpSecImpl.h
r58466 r77662 77 77 CHAR16 Name[100]; 78 78 UINT32 PackageFlag; 79 EFI_IPSEC_TRAFFIC_DIR TrafficDirection; 79 80 EFI_IPSEC_ACTION Action; 80 81 EFI_IPSEC_PROCESS_POLICY *ProcessingPolicy; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Client-side Mtftp6 service. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Mtftp6Dxe/Mtftp6DxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Mtftp6Dxe Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c
r58459 r77662 2 2 Mtftp6 support functions implementation. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 224 224 225 225 if (Range->Round > 0) { 226 *TotalBlock += Range->Bound + MultU64x32 ( (UINT64) (Range->Round -1), (UINT32)(Range->Bound + 1)) + 1;226 *TotalBlock += Range->Bound + MultU64x32 (Range->Round - 1, (UINT32)(Range->Bound + 1)) + 1; 227 227 } 228 228 … … 320 320 321 321 if (!EFI_ERROR (Status)) { 322 if (Ip6Mode.AddressList != NULL) { 323 FreePool (Ip6Mode.AddressList); 324 } 325 326 if (Ip6Mode.GroupTable != NULL) { 327 FreePool (Ip6Mode.GroupTable); 328 } 329 330 if (Ip6Mode.RouteTable != NULL) { 331 FreePool (Ip6Mode.RouteTable); 332 } 333 334 if (Ip6Mode.NeighborCache != NULL) { 335 FreePool (Ip6Mode.NeighborCache); 336 } 337 338 if (Ip6Mode.PrefixTable != NULL) { 339 FreePool (Ip6Mode.PrefixTable); 340 } 341 342 if (Ip6Mode.IcmpTypeList != NULL) { 343 FreePool (Ip6Mode.IcmpTypeList); 344 } 322 345 323 346 if (Ip6Mode.IsConfigured) { … … 453 476 EFI_MTFTP6_OPTION *Options; 454 477 EFI_MTFTP6_TOKEN *Token; 478 RETURN_STATUS Status; 455 479 NET_BUF *Nbuf; 456 480 UINT8 *Mode; 457 481 UINT8 *Cur; 458 UINT32 Len1;459 UINT32 Len2;460 UINT32 Len;461 482 UINTN Index; 483 UINT32 BufferLength; 484 UINTN FileNameLength; 485 UINTN ModeLength; 486 UINTN OptionStrLength; 487 UINTN ValueStrLength; 462 488 463 489 Token = Instance->Token; … … 488 514 // Compute the size of new Mtftp6 packet. 489 515 // 490 Len1 = (UINT32)AsciiStrLen ((CHAR8 *) Token->Filename);491 Len2 = (UINT32)AsciiStrLen ((CHAR8 *) Mode);492 Len = Len1 + Len2+ 4;516 FileNameLength = AsciiStrLen ((CHAR8 *) Token->Filename); 517 ModeLength = AsciiStrLen ((CHAR8 *) Mode); 518 BufferLength = (UINT32) FileNameLength + (UINT32) ModeLength + 4; 493 519 494 520 for (Index = 0; Index < Token->OptionCount; Index++) { 495 Len1 = (UINT32)AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);496 Len2 = (UINT32)AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);497 Len += Len1 + Len2+ 2;521 OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr); 522 ValueStrLength = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr); 523 BufferLength += (UINT32) OptionStrLength + (UINT32) ValueStrLength + 2; 498 524 } 499 525 … … 501 527 // Allocate a packet then copy the data. 502 528 // 503 if ((Nbuf = NetbufAlloc ( Len)) == NULL) {529 if ((Nbuf = NetbufAlloc (BufferLength)) == NULL) { 504 530 return EFI_OUT_OF_RESOURCES; 505 531 } … … 508 534 // Copy the opcode, filename and mode into packet. 509 535 // 510 Packet = (EFI_MTFTP6_PACKET *) NetbufAllocSpace (Nbuf, Len, FALSE);536 Packet = (EFI_MTFTP6_PACKET *) NetbufAllocSpace (Nbuf, BufferLength, FALSE); 511 537 ASSERT (Packet != NULL); 512 538 513 539 Packet->OpCode = HTONS (Operation); 540 BufferLength -= sizeof (Packet->OpCode); 541 514 542 Cur = Packet->Rrq.Filename; 515 Cur = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Token->Filename); 516 Cur += AsciiStrLen ((CHAR8 *) Token->Filename) + 1; 517 Cur = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Mode); 518 Cur += AsciiStrLen ((CHAR8 *) Mode) + 1; 543 Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Token->Filename); 544 ASSERT_EFI_ERROR (Status); 545 BufferLength -= (UINT32) (FileNameLength + 1); 546 Cur += FileNameLength + 1; 547 Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Mode); 548 ASSERT_EFI_ERROR (Status); 549 BufferLength -= (UINT32) (ModeLength + 1); 550 Cur += ModeLength + 1; 519 551 520 552 // … … 522 554 // 523 555 for (Index = 0; Index < Token->OptionCount; ++Index) { 524 Cur = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].OptionStr); 525 Cur += AsciiStrLen ((CHAR8 *) Options[Index].OptionStr) + 1; 526 Cur = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].ValueStr); 527 Cur += AsciiStrLen ((CHAR8 *) (CHAR8 *) Options[Index].ValueStr) + 1; 556 OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr); 557 ValueStrLength = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr); 558 559 Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].OptionStr); 560 ASSERT_EFI_ERROR (Status); 561 BufferLength -= (UINT32) (OptionStrLength + 1); 562 Cur += OptionStrLength + 1; 563 564 Status = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].ValueStr); 565 ASSERT_EFI_ERROR (Status); 566 BufferLength -= (UINT32) (ValueStrLength + 1); 567 Cur += ValueStrLength + 1; 568 528 569 } 529 570 … … 585 626 TftpError->Error.ErrorCode = HTONS (ErrCode); 586 627 587 AsciiStrCpy ((CHAR8 *) TftpError->Error.ErrorMessage, (CHAR8 *) ErrInfo);628 AsciiStrCpyS ((CHAR8 *) TftpError->Error.ErrorMessage, AsciiStrLen ((CHAR8 *) ErrInfo) + 1 , (CHAR8 *) ErrInfo); 588 629 589 630 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/NetworkPkg.dec
r58466 r77662 4 4 # This package provides network modules that conform to UEFI 2.4 specification. 5 5 # 6 # Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR> 6 # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> 7 # (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP<BR> 7 8 # 8 9 # This program and the accompanying materials are licensed and made available under … … 20 21 PACKAGE_NAME = NetworkPkg 21 22 PACKAGE_GUID = 947988BE-8D5C-471a-893D-AD181C46BEBB 22 PACKAGE_VERSION = 0.9 523 PACKAGE_VERSION = 0.98 23 24 PACKAGE_UNI_FILE = NetworkPkg.uni 24 25 … … 36 37 # Include/Guid/IscsiConfigHii.h 37 38 gIScsiConfigGuid = { 0x4b47d616, 0xa8d6, 0x4552, { 0x9d, 0x44, 0xcc, 0xad, 0x2e, 0xf, 0x4c, 0xf9}} 39 40 # Include/Guid/HttpBootConfigHii.h 41 gHttpBootConfigGuid = { 0x4d20583a, 0x7765, 0x4e7a, { 0x8a, 0x67, 0xdc, 0xde, 0x74, 0xee, 0x3e, 0xc5 }} 42 43 # Include/Guid/TlsAuthConfigHii.h 44 gTlsAuthConfigGuid = { 0xb0eae4f8, 0x9a04, 0x4c6d, { 0xa7, 0x48, 0x79, 0x3d, 0xaa, 0xf, 0x65, 0xdf }} 45 46 # Include/Guid/TlsAuthentication.h 47 gEfiTlsCaCertificateGuid = { 0xfd2340D0, 0x3dab, 0x4349, { 0xa6, 0xc7, 0x3b, 0x4f, 0x12, 0xb4, 0x8e, 0xae }} 48 49 [PcdsFixedAtBuild] 50 ## The max attempt number will be created by iSCSI driver. 51 # @Prompt Max attempt number. 52 gEfiNetworkPkgTokenSpaceGuid.PcdMaxIScsiAttemptNumber|0x08|UINT8|0x0000000D 38 53 39 54 [PcdsFeatureFlag] … … 69 84 gEfiNetworkPkgTokenSpaceGuid.PcdIpsecUefiCertificateKeySize|0x3d5|UINT32|0x00000006 70 85 86 ## Indicates whether HTTP connections (i.e., unsecured) are permitted or not. 87 # TRUE - HTTP connections are allowed. Both the "https://" and "http://" URI schemes are permitted. 88 # FALSE - HTTP connections are denied. Only the "https://" URI scheme is permitted. 89 # @Prompt Indicates whether HTTP connections are permitted or not. 90 gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|FALSE|BOOLEAN|0x00000008 91 92 [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] 93 ## IPv6 DHCP Unique Identifier (DUID) Type configuration (From RFCs 3315 and 6355). 94 # 01 = DUID Based on Link-layer Address Plus Time [DUID-LLT] 95 # 04 = UUID-Based DHCPv6 Unique Identifier (DUID-UUID) 96 # 02 = DUID Assigned by Vendor Based on Enterprise Number [DUID-EN] (not supported) 97 # 03 = DUID Based on Link-layer Address [DUID-LL] (not supported) 98 # @Prompt Type Value of Dhcp6 Unique Identifier (DUID). 99 gEfiNetworkPkgTokenSpaceGuid.PcdDhcp6UidType|4|UINT8|0x10000001 100 101 ## Network boot policy to stop UEFI iSCSI if applicable. 102 # 0x00 = Always use UEFI iSCSI and ignore iSCSI HBA. 103 # 0x01 = Stop UEFI iSCSI if iSCSI HBA adapter produces AIP protocol with Network Boot. 104 # 0x02 = Stop UEFI iSCSI if iSCSI HBA adapter supports booting from iSCSI IPv4 targets. 105 # 0x04 = Stop UEFI iSCSI if iSCSI HBA adapter supports booting from iSCSI IPv6 targets. 106 # 0x08 = Stop UEFI iSCSI if iSCSI HBA adapter supports an offload engine for iSCSI boot. 107 # 0x10 = Stop UEFI iSCSI if iSCSI HBA adapter supports multipath I/O for iSCSI boot. 108 # 0x20 = Stop UEFI iSCSI if iSCSI HBA adapter is currently configured to boot from iSCSI IPv4 targets. 109 # 0x40 = Stop UEFI iSCSI if iSCSI HBA adapter is currently configured to boot from iSCSI IPv6 targets. 110 # 0xFF = Always use iSCSI HBA and ignore UEFI iSCSI. 111 # @Prompt Type Value of network boot policy used in iSCSI. 112 gEfiNetworkPkgTokenSpaceGuid.PcdIScsiAIPNetworkBootPolicy|0x08|UINT8|0x10000007 113 71 114 [UserExtensions.TianoCore."ExtraFiles"] 72 115 NetworkPkgExtra.uni -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/NetworkPkg.dsc
r58466 r77662 2 2 # UEFI 2.4 Network Module Package for All Architectures 3 3 # 4 # Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> 5 6 # 6 7 # This program and the accompanying materials … … 17 18 PLATFORM_NAME = NetworkPkg 18 19 PLATFORM_GUID = 3FD34E9B-E90C-44e1-B510-1F632A509F10 19 PLATFORM_VERSION = 0.9 520 PLATFORM_VERSION = 0.98 20 21 DSC_SPECIFICATION = 0x00010005 21 22 OUTPUT_DIRECTORY = Build/NetworkPkg 22 SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM 23 BUILD_TARGETS = DEBUG|RELEASE 23 SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM|AARCH64 24 BUILD_TARGETS = DEBUG|RELEASE|NOOPT 24 25 SKUID_IDENTIFIER = DEFAULT 25 26 26 27 [LibraryClasses] 28 DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf 27 29 BaseLib|MdePkg/Library/BaseLib/BaseLib.inf 28 30 BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf … … 38 40 UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf 39 41 UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf 42 UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf 43 TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf 44 PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf 45 PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf 46 DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf 47 DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf 48 SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf 40 49 41 50 DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf … … 44 53 UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf 45 54 TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf 55 HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf 46 56 BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf 47 57 OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf 48 58 IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf 59 TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf 49 60 DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf 61 FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf 62 FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf 63 SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf 50 64 51 65 [LibraryClasses.common.UEFI_DRIVER] 66 HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf 67 ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf 52 68 DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf 53 69 54 70 [LibraryClasses.common.UEFI_APPLICATION] 55 71 DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf 56 FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf57 SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf58 72 ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf 73 74 [LibraryClasses.ARM, LibraryClasses.AARCH64] 75 # 76 # It is not possible to prevent ARM compiler calls to generic intrinsic functions. 77 # This library provides the instrinsic functions generated by a given compiler. 78 # [LibraryClasses.ARM] and NULL mean link this library into all ARM images. 79 # 80 NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf 59 81 60 82 [PcdsFeatureFlag] … … 91 113 NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf 92 114 NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf 115 NetworkPkg/DnsDxe/DnsDxe.inf 116 NetworkPkg/HttpDxe/HttpDxe.inf 117 NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf 118 NetworkPkg/HttpBootDxe/HttpBootDxe.inf 93 119 94 NetworkPkg/Application/IfConfig6/IfConfig6.inf95 120 NetworkPkg/Application/IpsecConfig/IpSecConfig.inf 96 121 NetworkPkg/Application/VConfig/VConfig.inf … … 100 125 NetworkPkg/IScsiDxe/IScsiDxe.inf 101 126 NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf 102 NetworkPkg/Application/Ping6/Ping6.inf 127 NetworkPkg/TlsDxe/TlsDxe.inf 128 NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.inf 129 130 [BuildOptions] 131 *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/NetworkPkg.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // This package provides network modules that conform to UEFI 2.4 specification. 3 3 // 4 4 // This package provides network modules that conform to UEFI 2.4 specification. 5 5 // 6 // Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>6 // Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 7 7 // 8 8 // This program and the accompanying materials are licensed and made available under … … 22 22 23 23 24 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdMaxIScsiAttemptNumber_PROMPT #language en-US "Max attempt number." 25 26 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdMaxIScsiAttemptNumber_HELP #language en-US "Max attempt number created by iSCSI." 24 27 25 28 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdIpsecUefiCaFile_PROMPT #language en-US "CA file." … … 47 50 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdIpsecUefiCertificateKeySize_HELP #language en-US "Private Key's size." 48 51 52 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdAllowHttpConnections_PROMPT #language en-US "Indicates whether HTTP connections are permitted or not." 53 54 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdAllowHttpConnections_HELP #language en-US "Indicates whether HTTP connections are permitted or not.\n" 55 "TRUE - HTTP connections are allowed.\n" 56 "FALSE - HTTP connections are denied." 57 49 58 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdIpsecCertificateEnabled_PROMPT #language en-US "Enable IPsec IKEv2 Certificate Authentication." 50 59 … … 53 62 "FALSE - Does not support Certificate Authentication.<BR>" 54 63 64 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdDhcp6UidType_PROMPT #language en-US "Type Value of Dhcp6 Unique Identifier (DUID)." 65 66 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdDhcp6UidType_HELP #language en-US "IPv6 DHCP Unique Identifier (DUID) Type configuration (From RFCs 3315 and 6355).\n" 67 "01 = DUID Based on Link-layer Address Plus Time [DUID-LLT]\n" 68 "04 = UUID-Based DHCPv6 Unique Identifier (DUID-UUID)\n" 69 "02 = DUID Assigned by Vendor Based on Enterprise Number [DUID-EN] (not supported)\n" 70 "03 = DUID Based on Link-layer Address [DUID-LL] (not supported)" 71 72 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdIScsiAIPNetworkBootPolicy_PROMPT #language en-US "Type Value of network boot policy used in iSCSI." 73 74 #string STR_gEfiNetworkPkgTokenSpaceGuid_PcdIScsiAIPNetworkBootPolicy_HELP #language en-US "Network boot policy to stop UEFI iSCSI if applicable.\n" 75 "0x00 = Always use UEFI iSCSI and ignore AIP.\n" 76 "0x01 = Stop UEFI iSCSI if iSCSI HBA adapter produces AIP protocol with Network Boot.\n" 77 "0x02 = Stop UEFI iSCSI if iSCSI HBA adapter supports booting from iSCSI IPv4 targets.\n" 78 "0x04 = Stop UEFI iSCSI if iSCSI HBA adapter supports booting from iSCSI IPv6 targets.\n" 79 "0x08 = Stop UEFI iSCSI if iSCSI HBA adapter supports an offload engine for iSCSI boot.\n" 80 "0x10 = Stop UEFI iSCSI if iSCSI HBA adapter supports multipath I/O for iSCSI boot.\n" 81 "0x20 = Stop UEFI iSCSI if iSCSI HBA adapter is currently configured to boot from iSCSI IPv4 targets.\n" 82 "0x40 = Stop UEFI iSCSI if iSCSI HBA adapter is currently configured to boot from iSCSI IPv6 targets." -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/NetworkPkgExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Network Package Localized Strings and Content. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/SockImpl.c
r58459 r77662 2 2 Implementation of the Socket. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 523 523 Parent->ConnCnt--; 524 524 DEBUG ( 525 (EFI_D_ INFO,525 (EFI_D_NET, 526 526 "SockWakeListenToken: accept a socket, now conncnt is %d", 527 527 Parent->ConnCnt) … … 573 573 RcvdBytes -= TokenRcvdBytes; 574 574 } 575 } 576 577 /** 578 Cancel the tokens in the specific token list. 579 580 @param[in] Token Pointer to the Token. If NULL, all tokens 581 in SpecifiedTokenList will be canceled. 582 @param[in, out] SpecifiedTokenList Pointer to the token list to be checked. 583 584 @retval EFI_SUCCESS Cancel the tokens in the specific token listsuccessfully. 585 @retval EFI_NOT_FOUND The Token is not found in SpecifiedTokenList. 586 587 **/ 588 EFI_STATUS 589 SockCancelToken ( 590 IN SOCK_COMPLETION_TOKEN *Token, 591 IN OUT LIST_ENTRY *SpecifiedTokenList 592 ) 593 { 594 EFI_STATUS Status; 595 LIST_ENTRY *Entry; 596 SOCK_TOKEN *SockToken; 597 598 Status = EFI_SUCCESS; 599 Entry = NULL; 600 SockToken = NULL; 601 602 if (IsListEmpty (SpecifiedTokenList) && Token != NULL) { 603 return EFI_NOT_FOUND; 604 } 605 606 // 607 // Iterate through the SpecifiedTokenList. 608 // 609 Entry = SpecifiedTokenList->ForwardLink; 610 while (Entry != SpecifiedTokenList) { 611 SockToken = NET_LIST_USER_STRUCT (Entry, SOCK_TOKEN, TokenList); 612 613 if (Token == NULL) { 614 SIGNAL_TOKEN (SockToken->Token, EFI_ABORTED); 615 RemoveEntryList (&SockToken->TokenList); 616 FreePool (SockToken); 617 618 Entry = SpecifiedTokenList->ForwardLink; 619 Status = EFI_SUCCESS; 620 } else { 621 if (Token == (VOID *) SockToken->Token) { 622 SIGNAL_TOKEN (Token, EFI_ABORTED); 623 RemoveEntryList (&(SockToken->TokenList)); 624 FreePool (SockToken); 625 626 return EFI_SUCCESS; 627 } 628 629 Status = EFI_NOT_FOUND; 630 631 Entry = Entry->ForwardLink; 632 } 633 } 634 635 ASSERT (IsListEmpty (SpecifiedTokenList) || Token != NULL); 636 637 return Status; 575 638 } 576 639 … … 714 777 715 778 DEBUG ( 716 (EFI_D_ INFO,779 (EFI_D_NET, 717 780 "SockCreate: Create a new socket and add to parent, now conncnt is %d\n", 718 781 Parent->ConnCnt) … … 766 829 ) 767 830 { 768 VOID *SockProtocol;769 EFI_GUID *TcpProtocolGuid;770 EFI_STATUS Status;771 772 831 ASSERT (SockStream == Sock->Type); 773 774 if (Sock->DestroyCallback != NULL) {775 Sock->DestroyCallback (Sock, Sock->Context);776 }777 832 778 833 // … … 809 864 Sock->Parent = NULL; 810 865 } 811 812 //813 // Set the protocol guid and driver binding handle814 // in the light of Sock->SockType815 //816 if (Sock->IpVersion == IP_VERSION_4) {817 TcpProtocolGuid = &gEfiTcp4ProtocolGuid;818 } else {819 TcpProtocolGuid = &gEfiTcp6ProtocolGuid;820 }821 822 //823 // Retrieve the protocol installed on this sock824 //825 Status = gBS->OpenProtocol (826 Sock->SockHandle,827 TcpProtocolGuid,828 &SockProtocol,829 Sock->DriverBinding,830 Sock->SockHandle,831 EFI_OPEN_PROTOCOL_GET_PROTOCOL832 );833 834 if (EFI_ERROR (Status)) {835 836 DEBUG (837 (EFI_D_ERROR,838 "SockDestroy: Open protocol installed on socket failed with %r\n",839 Status)840 );841 842 goto FreeSock;843 }844 845 //846 // Uninstall the protocol installed on this sock847 // in the light of Sock->SockType848 //849 gBS->UninstallMultipleProtocolInterfaces (850 Sock->SockHandle,851 TcpProtocolGuid,852 SockProtocol,853 NULL854 );855 856 FreeSock:857 866 858 867 FreePool (Sock); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/SockImpl.h
r48674 r77662 2 2 The function declaration that provided for Socket Interface. 3 3 4 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 18 18 19 19 #include "Socket.h" 20 #include "TcpMain.h" 20 21 21 22 /** … … 78 79 79 80 /** 81 Cancel the tokens in the specific token list. 82 83 @param[in] Token Pointer to the Token. If NULL, all tokens 84 in SpecifiedTokenList will be canceled. 85 @param[in, out] SpecifiedTokenList Pointer to the token list to be checked. 86 87 @retval EFI_SUCCESS Cancel the tokens in the specific token listsuccessfully. 88 @retval EFI_NOT_FOUND The Token is not found in SpecifiedTokenList. 89 90 **/ 91 EFI_STATUS 92 SockCancelToken ( 93 IN SOCK_COMPLETION_TOKEN *Token, 94 IN OUT LIST_ENTRY *SpecifiedTokenList 95 ); 96 97 /** 80 98 Create a socket with initial data SockInitData. 81 99 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/SockInterface.c
r58459 r77662 2 2 Interface function of the Socket. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 143 143 ) 144 144 { 145 EFI_STATUS Status; 145 EFI_STATUS Status; 146 TCP_PROTO_DATA *ProtoData; 147 TCP_CB *Tcb; 148 EFI_GUID *IpProtocolGuid; 149 EFI_GUID *TcpProtocolGuid; 150 VOID *SockProtocol; 146 151 147 152 ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL)); … … 152 157 153 158 Sock->InDestroy = TRUE; 159 160 if (Sock->IpVersion == IP_VERSION_4) { 161 IpProtocolGuid = &gEfiIp4ProtocolGuid; 162 TcpProtocolGuid = &gEfiTcp4ProtocolGuid; 163 } else { 164 IpProtocolGuid = &gEfiIp6ProtocolGuid; 165 TcpProtocolGuid = &gEfiTcp6ProtocolGuid; 166 } 167 ProtoData = (TCP_PROTO_DATA *) Sock->ProtoReserved; 168 Tcb = ProtoData->TcpPcb; 169 170 ASSERT (Tcb != NULL); 171 172 // 173 // Close the IP protocol. 174 // 175 gBS->CloseProtocol ( 176 Tcb->IpInfo->ChildHandle, 177 IpProtocolGuid, 178 ProtoData->TcpService->IpIo->Image, 179 Sock->SockHandle 180 ); 181 182 if (Sock->DestroyCallback != NULL) { 183 Sock->DestroyCallback (Sock, Sock->Context); 184 } 185 186 // 187 // Retrieve the protocol installed on this sock 188 // 189 Status = gBS->OpenProtocol ( 190 Sock->SockHandle, 191 TcpProtocolGuid, 192 &SockProtocol, 193 Sock->DriverBinding, 194 Sock->SockHandle, 195 EFI_OPEN_PROTOCOL_GET_PROTOCOL 196 ); 197 198 if (EFI_ERROR (Status)) { 199 200 DEBUG ( 201 (EFI_D_ERROR, 202 "SockDestroyChild: Open protocol installed on socket failed with %r\n", 203 Status) 204 ); 205 } 206 207 // 208 // Uninstall the protocol installed on this sock 209 // 210 gBS->UninstallMultipleProtocolInterfaces ( 211 Sock->SockHandle, 212 TcpProtocolGuid, 213 SockProtocol, 214 NULL 215 ); 216 154 217 155 218 Status = EfiAcquireLockOrFail (&(Sock->Lock)); … … 214 277 SOCKET *Sock; 215 278 EFI_STATUS Status; 279 VOID *SockProtocol; 280 EFI_GUID *TcpProtocolGuid; 216 281 217 282 // … … 237 302 Status) 238 303 ); 239 240 SockDestroy (Sock); 241 return NULL; 304 goto ERROR; 242 305 } 243 306 // … … 254 317 Status) 255 318 ); 256 257 SockDestroy (Sock); 258 Sock = NULL; 319 goto ERROR; 259 320 } 260 321 261 322 return Sock; 323 324 ERROR: 325 326 if (Sock->DestroyCallback != NULL) { 327 Sock->DestroyCallback (Sock, Sock->Context); 328 } 329 330 if (Sock->IpVersion == IP_VERSION_4) { 331 TcpProtocolGuid = &gEfiTcp4ProtocolGuid; 332 } else { 333 TcpProtocolGuid = &gEfiTcp6ProtocolGuid; 334 } 335 336 gBS->OpenProtocol ( 337 Sock->SockHandle, 338 TcpProtocolGuid, 339 &SockProtocol, 340 Sock->DriverBinding, 341 Sock->SockHandle, 342 EFI_OPEN_PROTOCOL_GET_PROTOCOL 343 ); 344 // 345 // Uninstall the protocol installed on this sock 346 // 347 gBS->UninstallMultipleProtocolInterfaces ( 348 Sock->SockHandle, 349 TcpProtocolGuid, 350 SockProtocol, 351 NULL 352 ); 353 SockDestroy (Sock); 354 return NULL; 262 355 } 263 356 … … 471 564 472 565 DEBUG ( 473 (EFI_D_ INFO,566 (EFI_D_NET, 474 567 "SockAccept: Accept a socket, now conncount is %d", 475 568 Socket->Parent->ConnCnt) … … 725 818 726 819 if (RcvdBytes != 0) { 727 Status = SockProcessRcvToken (Sock, RcvToken); 728 729 if (EFI_ERROR (Status)) { 730 goto Exit; 731 } 820 SockProcessRcvToken (Sock, RcvToken); 732 821 733 822 Status = Sock->ProtoHandler (Sock, SOCK_CONSUMED, NULL); … … 882 971 883 972 /** 973 Abort the socket associated connection, listen, transmission or receive request. 974 975 @param[in, out] Sock Pointer to the socket to abort. 976 @param[in] Token Pointer to a token that has been issued by 977 Connect(), Accept(), Transmit() or Receive(). If 978 NULL, all pending tokens issued by the four 979 functions listed above will be aborted. 980 981 @retval EFI_UNSUPPORTED The operation is not supported in the current 982 implementation. 983 **/ 984 EFI_STATUS 985 SockCancel ( 986 IN OUT SOCKET *Sock, 987 IN VOID *Token 988 ) 989 { 990 EFI_STATUS Status; 991 992 Status = EFI_SUCCESS; 993 994 ASSERT (SockStream == Sock->Type); 995 996 Status = EfiAcquireLockOrFail (&(Sock->Lock)); 997 if (EFI_ERROR (Status)) { 998 DEBUG ( 999 (EFI_D_ERROR, 1000 "SockCancel: Get the access for socket failed with %r", 1001 Status) 1002 ); 1003 1004 return EFI_ACCESS_DENIED; 1005 } 1006 1007 if (SOCK_IS_UNCONFIGURED (Sock)) { 1008 Status = EFI_NOT_STARTED; 1009 goto Exit; 1010 } 1011 1012 // 1013 // 1. Check ConnectionToken. 1014 // 1015 if (Token == NULL || (SOCK_COMPLETION_TOKEN *) Token == Sock->ConnectionToken) { 1016 if (Sock->ConnectionToken != NULL) { 1017 SIGNAL_TOKEN (Sock->ConnectionToken, EFI_ABORTED); 1018 Sock->ConnectionToken = NULL; 1019 } 1020 1021 if (Token != NULL) { 1022 Status = EFI_SUCCESS; 1023 goto Exit; 1024 } 1025 } 1026 1027 // 1028 // 2. Check ListenTokenList. 1029 // 1030 Status = SockCancelToken (Token, &Sock->ListenTokenList); 1031 if (Token != NULL && !EFI_ERROR (Status)) { 1032 goto Exit; 1033 } 1034 1035 // 1036 // 3. Check RcvTokenList. 1037 // 1038 Status = SockCancelToken (Token, &Sock->RcvTokenList); 1039 if (Token != NULL && !EFI_ERROR (Status)) { 1040 goto Exit; 1041 } 1042 1043 // 1044 // 4. Check SndTokenList. 1045 // 1046 Status = SockCancelToken (Token, &Sock->SndTokenList); 1047 if (Token != NULL && !EFI_ERROR (Status)) { 1048 goto Exit; 1049 } 1050 1051 // 1052 // 5. Check ProcessingSndTokenList. 1053 // 1054 Status = SockCancelToken (Token, &Sock->ProcessingSndTokenList); 1055 1056 Exit: 1057 EfiReleaseLock (&(Sock->Lock)); 1058 return Status; 1059 } 1060 1061 1062 /** 884 1063 Get the mode data of the low layer protocol. 885 1064 … … 899 1078 { 900 1079 return Sock->ProtoHandler (Sock, SOCK_MODE, Mode); 901 }902 903 /**904 Configure the low level protocol to join a multicast group for905 this socket's connection.906 907 @param[in] Sock Pointer to the socket of the connection to join the908 specific multicast group.909 @param[in] GroupInfo Pointer to the multicast group info.910 911 @retval EFI_SUCCESS The configuration completed successfully.912 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.913 @retval EFI_NOT_STARTED The socket is not configured.914 915 **/916 EFI_STATUS917 SockGroup (918 IN SOCKET *Sock,919 IN VOID *GroupInfo920 )921 {922 EFI_STATUS Status;923 924 Status = EfiAcquireLockOrFail (&(Sock->Lock));925 926 if (EFI_ERROR (Status)) {927 928 DEBUG (929 (EFI_D_ERROR,930 "SockGroup: Get the access for socket failed with %r",931 Status)932 );933 934 return EFI_ACCESS_DENIED;935 }936 937 if (SOCK_IS_UNCONFIGURED (Sock)) {938 Status = EFI_NOT_STARTED;939 goto Exit;940 }941 942 Status = Sock->ProtoHandler (Sock, SOCK_GROUP, GroupInfo);943 944 Exit:945 EfiReleaseLock (&(Sock->Lock));946 return Status;947 1080 } 948 1081 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/Socket.h
r58459 r77662 2 2 Common head file for TCP socket. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 362 362 typedef struct _SOCK_BUFFER { 363 363 UINT32 HighWater; ///< The buffersize upper limit of sock_buffer 364 UINT32 LowWater; ///< The low wa rter mark of sock_buffer364 UINT32 LowWater; ///< The low water mark of sock_buffer 365 365 NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data 366 366 } SOCK_BUFFER; … … 426 426 SOCKET *Parent; ///< The parent of this socket 427 427 UINT32 BackLog; ///< The connection limit for listening socket 428 UINT32 SndBufferSize; ///< The high wa rter mark of send buffer429 UINT32 RcvBufferSize; ///< The high wa rter mark of receive buffer428 UINT32 SndBufferSize; ///< The high water mark of send buffer 429 UINT32 RcvBufferSize; ///< The high water mark of receive buffer 430 430 UINT8 IpVersion; 431 431 VOID *Protocol; ///< The pointer to protocol function template … … 451 451 452 452 /// 453 /// The union type of TCP and UDPprotocol.453 /// The union type of TCP4 and TCP6 protocol. 454 454 /// 455 455 typedef union _NET_PROTOCOL { … … 503 503 UINT8 ProtoReserved[PROTO_RESERVED_LEN]; ///< Data fields reserved for protocol 504 504 UINT8 IpVersion; 505 NET_PROTOCOL NetProtocol; ///< TCP or UDPprotocol socket used505 NET_PROTOCOL NetProtocol; ///< TCP4 or TCP6 protocol socket used 506 506 // 507 507 // Callbacks after socket is created and before socket is to be destroyed. … … 866 866 867 867 /** 868 Abort the socket associated connection, listen, transmission or receive request. 869 870 @param[in, out] Sock Pointer to the socket to abort. 871 @param[in] Token Pointer to a token that has been issued by 872 Connect(), Accept(), Transmit() or Receive(). If 873 NULL, all pending tokens issued by the four 874 functions listed above will be aborted. 875 876 @retval EFI_UNSUPPORTED The operation is not supported in the current 877 implementation. 878 **/ 879 EFI_STATUS 880 SockCancel ( 881 IN OUT SOCKET *Sock, 882 IN VOID *Token 883 ); 884 885 /** 868 886 Get the mode data of the low layer protocol. 869 887 … … 880 898 IN SOCKET *Sock, 881 899 IN OUT VOID *Mode 882 );883 884 /**885 Configure the low level protocol to join a multicast group for886 this socket's connection.887 888 @param[in] Sock Pointer to the socket of the connection to join the889 specific multicast group.890 @param[in] GroupInfo Pointer to the multicast group information.891 892 @retval EFI_SUCCESS The configuration completed successfully.893 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.894 @retval EFI_NOT_STARTED The socket is not configured.895 896 **/897 EFI_STATUS898 SockGroup (899 IN SOCKET *Sock,900 IN VOID *GroupInfo901 900 ); 902 901 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpDispatcher.c
r58466 r77662 2 2 The implementation of a dispatch routine for processing TCP requests. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 99 100 AccessPoint->UseDefaultAddress = Tcb->UseDefaultAddr; 100 101 101 CopyMem (&AccessPoint->StationAddress, &Tcb->LocalEnd.Ip, sizeof (EFI_IPv4_ADDRESS));102 103 AccessPoint->SubnetMask = Tcb->SubnetMask;102 IP4_COPY_ADDRESS (&AccessPoint->StationAddress, &Tcb->LocalEnd.Ip); 103 104 IP4_COPY_ADDRESS (&AccessPoint->SubnetMask, &Tcb->SubnetMask); 104 105 AccessPoint->StationPort = NTOHS (Tcb->LocalEnd.Port); 105 106 106 CopyMem (&AccessPoint->RemoteAddress, &Tcb->RemoteEnd.Ip, sizeof (EFI_IPv4_ADDRESS));107 IP4_COPY_ADDRESS (&AccessPoint->RemoteAddress, &Tcb->RemoteEnd.Ip); 107 108 108 109 AccessPoint->RemotePort = NTOHS (Tcb->RemoteEnd.Port); … … 240 241 241 242 if (IpVersion == IP_VERSION_4) { 242 CopyMem (&Local, &TcpAp->Tcp4Ap.StationAddress, sizeof (EFI_IPv4_ADDRESS));243 IP4_COPY_ADDRESS (&Local, &TcpAp->Tcp4Ap.StationAddress); 243 244 Port = &TcpAp->Tcp4Ap.StationPort; 244 245 RandomPort = &mTcp4RandomPort; … … 423 424 TCP_PROTO_DATA *ProtoData; 424 425 TCP_CB *Tcb; 425 EFI_GUID *IpProtocolGuid;426 427 if (Sk->IpVersion == IP_VERSION_4) {428 IpProtocolGuid = &gEfiIp4ProtocolGuid;429 } else {430 IpProtocolGuid = &gEfiIp6ProtocolGuid;431 }432 426 433 427 ProtoData = (TCP_PROTO_DATA *) Sk->ProtoReserved; … … 437 431 438 432 TcpFlushPcb (Tcb); 439 440 //441 // Close the IP protocol.442 //443 gBS->CloseProtocol (444 Tcb->IpInfo->ChildHandle,445 IpProtocolGuid,446 ProtoData->TcpService->IpIo->Image,447 Sk->SockHandle448 );449 433 450 434 IpIoRemoveIp (ProtoData->TcpService->IpIo, Tcb->IpInfo); … … 496 480 IpCfgData.Ip4CfgData.TimeToLive = CfgData->Tcp4CfgData.TimeToLive; 497 481 IpCfgData.Ip4CfgData.UseDefaultAddress = CfgData->Tcp4CfgData.AccessPoint.UseDefaultAddress; 498 IpCfgData.Ip4CfgData.SubnetMask = CfgData->Tcp4CfgData.AccessPoint.SubnetMask; 482 IP4_COPY_ADDRESS ( 483 &IpCfgData.Ip4CfgData.SubnetMask, 484 &CfgData->Tcp4CfgData.AccessPoint.SubnetMask 485 ); 499 486 IpCfgData.Ip4CfgData.ReceiveTimeout = (UINT32) (-1); 500 CopyMem(487 IP4_COPY_ADDRESS ( 501 488 &IpCfgData.Ip4CfgData.StationAddress, 502 &CfgData->Tcp4CfgData.AccessPoint.StationAddress, 503 sizeof (EFI_IPv4_ADDRESS) 489 &CfgData->Tcp4CfgData.AccessPoint.StationAddress 504 490 ); 505 491 … … 534 520 // Get the default address information if the instance is configured to use default address. 535 521 // 536 CfgData->Tcp4CfgData.AccessPoint.StationAddress = IpCfgData.Ip4CfgData.StationAddress; 537 CfgData->Tcp4CfgData.AccessPoint.SubnetMask = IpCfgData.Ip4CfgData.SubnetMask; 522 IP4_COPY_ADDRESS ( 523 &CfgData->Tcp4CfgData.AccessPoint.StationAddress, 524 &IpCfgData.Ip4CfgData.StationAddress 525 ); 526 IP4_COPY_ADDRESS ( 527 &CfgData->Tcp4CfgData.AccessPoint.SubnetMask, 528 &IpCfgData.Ip4CfgData.SubnetMask 529 ); 538 530 539 531 TcpAp = (TCP_ACCESS_POINT *) &CfgData->Tcp4CfgData.AccessPoint; … … 602 594 CopyMem (&Tcb->LocalEnd.Ip, &CfgData->Tcp4CfgData.AccessPoint.StationAddress, sizeof (IP4_ADDR)); 603 595 Tcb->LocalEnd.Port = HTONS (CfgData->Tcp4CfgData.AccessPoint.StationPort); 604 Tcb->SubnetMask = CfgData->Tcp4CfgData.AccessPoint.SubnetMask;596 IP4_COPY_ADDRESS (&Tcb->SubnetMask, &CfgData->Tcp4CfgData.AccessPoint.SubnetMask); 605 597 606 598 CopyMem (&Tcb->RemoteEnd.Ip, &CfgData->Tcp4CfgData.AccessPoint.RemoteAddress, sizeof (IP4_ADDR)); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpDriver.c
r58466 r77662 2 2 The driver binding and service binding protocol for the TCP driver. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 870 870 @retval EFI_SUCCES The protocol was added to ChildHandle. 871 871 @retval EFI_INVALID_PARAMETER ChildHandle is NULL. 872 @retval EFI_OUT_OF_RESOURCES There are not enough resources availab e to create872 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create 873 873 the child. 874 874 @retval other The child handle was not created. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpDriver.h
r58459 r77662 2 2 The prototype of driver binding and service binding protocol for TCP driver. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 239 239 240 240 // 241 // Function p tototypes for the ServiceBinding Prococol241 // Function prototypes for the ServiceBinding Protocol 242 242 // 243 243 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpDxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // TCPv4 I/O and TCPv6 I/O services. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpDxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // TcpDxe Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpInput.c
r48674 r77662 2 2 TCP input process routines. 3 3 4 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 32 32 ) 33 33 { 34 return (TCP_SEQ_LEQ (Tcb->Rcv Wl2, Seg->End) &&34 return (TCP_SEQ_LEQ (Tcb->RcvNxt, Seg->End) && 35 35 TCP_SEQ_LT (Seg->Seq, Tcb->RcvWl2 + Tcb->RcvWnd)); 36 36 } … … 75 75 76 76 DEBUG ( 77 (EFI_D_ INFO,77 (EFI_D_NET, 78 78 "TcpFastRecover: enter fast retransmission for TCB %p, recover point is %d\n", 79 79 Tcb, … … 98 98 Tcb->CWnd += Tcb->SndMss; 99 99 DEBUG ( 100 (EFI_D_ INFO,100 (EFI_D_NET, 101 101 "TcpFastRecover: received another duplicated ACK (%d) for TCB %p\n", 102 102 Seg->Ack, … … 122 122 Tcb->CongestState = TCP_CONGEST_OPEN; 123 123 DEBUG ( 124 (EFI_D_ INFO,124 (EFI_D_NET, 125 125 "TcpFastRecover: received a full ACK(%d) for TCB %p, exit fast recovery\n", 126 126 Seg->Ack, … … 151 151 152 152 DEBUG ( 153 (EFI_D_ INFO,153 (EFI_D_NET, 154 154 "TcpFastRecover: received a partial ACK(%d) for TCB %p\n", 155 155 Seg->Ack, … … 189 189 190 190 DEBUG ( 191 (EFI_D_ INFO,191 (EFI_D_NET, 192 192 "TcpFastLossRecover: received a full ACK(%d) for TCB %p\n", 193 193 Seg->Ack, … … 203 203 TcpRetransmit (Tcb, Seg->Ack); 204 204 DEBUG ( 205 (EFI_D_ INFO,205 (EFI_D_NET, 206 206 "TcpFastLossRecover: received a partial ACK(%d) for TCB %p\n", 207 207 Seg->Ack, … … 265 265 266 266 DEBUG ( 267 (EFI_D_ INFO,267 (EFI_D_NET, 268 268 "TcpComputeRtt: new RTT for TCB %p computed SRTT: %d RTTVAR: %d RTO: %d\n", 269 269 Tcb, … … 282 282 @param[in] Right The sequence number of the window's right edge. 283 283 284 @retval 0 The segment is broken. 285 @retval 1 The segment is in good shape. 286 284 287 **/ 285 VOID 288 INTN 286 289 TcpTrimSegment ( 287 290 IN NET_BUF *Nbuf, … … 307 310 Seg->Seq = Seg->End; 308 311 NetbufTrim (Nbuf, Nbuf->TotalSize, NET_BUF_HEAD); 309 return ;312 return 1; 310 313 } 311 314 … … 360 363 } 361 364 362 ASSERT (TcpVerifySegment (Nbuf) != 0);365 return TcpVerifySegment (Nbuf); 363 366 } 364 367 … … 369 372 @param[in] Nbuf Pointer to the NET_BUF containing the received tcp segment. 370 373 374 @retval 0 The segment is broken. 375 @retval 1 The segment is in good shape. 376 371 377 **/ 372 VOID 378 INTN 373 379 TcpTrimInWnd ( 374 380 IN TCP_CB *Tcb, … … 376 382 ) 377 383 { 378 TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd);384 return TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd); 379 385 } 380 386 … … 422 428 Seg = TCPSEG_NETBUF (Nbuf); 423 429 424 ASSERT (TcpVerifySegment (Nbuf) != 0); 430 if (TcpVerifySegment (Nbuf) == 0) { 431 DEBUG ( 432 (EFI_D_ERROR, 433 "TcpToSendData: discard a broken segment for TCB %p\n", 434 Tcb) 435 ); 436 NetbufFree (Nbuf); 437 return -1; 438 } 439 425 440 ASSERT (Nbuf->Tcp == NULL); 426 441 … … 456 471 457 472 DEBUG ( 458 (EFI_D_ INFO,473 (EFI_D_NET, 459 474 "TcpDeliverData: processing FIN from peer of TCB %p\n", 460 475 Tcb) … … 532 547 533 548 if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RCVD_URG) && 534 TCP_SEQ_LEQ (Seg->Seq, Tcb->RcvUp) 535 ){549 TCP_SEQ_LEQ (Seg->Seq, Tcb->RcvUp)) 550 { 536 551 537 552 if (TCP_SEQ_LEQ (Seg->End, Tcb->RcvUp)) { … … 562 577 @param[in] Nbuf Pointer to the buffer containing the data to be queued. 563 578 579 @retval 0 An error condition occurred. 580 @retval 1 No error occurred to queue data. 581 564 582 **/ 565 VOID 583 INTN 566 584 TcpQueueData ( 567 585 IN OUT TCP_CB *Tcb, … … 589 607 590 608 InsertTailList (Head, &Nbuf->List); 591 return ;609 return 1; 592 610 } 593 611 … … 597 615 for (Prev = Head, Cur = Head->ForwardLink; 598 616 Cur != Head; 599 Prev = Cur, Cur = Cur->ForwardLink 600 ) { 617 Prev = Cur, Cur = Cur->ForwardLink) { 601 618 602 619 Node = NET_LIST_USER_STRUCT (Cur, NET_BUF, List); … … 617 634 618 635 if (TCP_SEQ_LEQ (Seg->End, TCPSEG_NETBUF (Node)->End)) { 619 620 NetbufFree (Nbuf);621 return; 622 }623 624 TcpTrimSegment (Nbuf, TCPSEG_NETBUF (Node)->End, Seg->End);636 return 1; 637 } 638 639 if (TcpTrimSegment (Nbuf, TCPSEG_NETBUF (Node)->End, Seg->End) == 0) { 640 return 0; 641 } 625 642 } 626 643 } … … 650 667 651 668 RemoveEntryList (&Nbuf->List); 652 NetbufFree (Nbuf); 653 return; 654 } 655 656 TcpTrimSegment (Nbuf, Seg->Seq, TCPSEG_NETBUF (Node)->Seq); 669 return 1; 670 } 671 672 if (TcpTrimSegment (Nbuf, Seg->Seq, TCPSEG_NETBUF (Node)->Seq) == 0) { 673 RemoveEntryList (&Nbuf->List); 674 return 0; 675 } 657 676 break; 658 677 } … … 660 679 Cur = Cur->ForwardLink; 661 680 } 681 682 return 1; 662 683 } 663 684 … … 669 690 @param[in] Ack The acknowledge seuqence number of the received segment. 670 691 692 @retval 0 An error condition occurred. 693 @retval 1 No error occurred. 694 671 695 **/ 672 VOID 696 INTN 673 697 TcpAdjustSndQue ( 674 698 IN TCP_CB *Tcb, … … 703 727 } 704 728 705 TcpTrimSegment (Node, Ack, Seg->End); 706 break; 707 } 729 return TcpTrimSegment (Node, Ack, Seg->End); 730 } 731 732 return 1; 708 733 } 709 734 … … 740 765 TCP_SEQNO Urg; 741 766 UINT16 Checksum; 767 INT32 Usable; 742 768 743 769 ASSERT ((Version == IP_VERSION_4) || (Version == IP_VERSION_6)); … … 750 776 Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL); 751 777 ASSERT (Head != NULL); 778 779 if (Nbuf->TotalSize < sizeof (TCP_HEAD)) { 780 DEBUG ((EFI_D_NET, "TcpInput: received a malformed packet\n")); 781 goto DISCARD; 782 } 783 752 784 Len = Nbuf->TotalSize - (Head->HeadLen << 2); 753 785 754 786 if ((Head->HeadLen < 5) || (Len < 0)) { 755 787 756 DEBUG ((EFI_D_INFO, "TcpInput: received an mal-formated packet\n")); 788 DEBUG ((EFI_D_NET, "TcpInput: received a malformed packet\n")); 789 757 790 goto DISCARD; 758 791 } … … 789 822 790 823 if ((Tcb == NULL) || (Tcb->State == TCP_CLOSED)) { 791 DEBUG ((EFI_D_ INFO, "TcpInput: send reset because no TCB find\n"));824 DEBUG ((EFI_D_NET, "TcpInput: send reset because no TCB found\n")); 792 825 793 826 Tcb = NULL; … … 804 837 DEBUG ( 805 838 (EFI_D_ERROR, 806 "TcpInput: reset the peer because of mal -format option for Tcb%p\n",839 "TcpInput: reset the peer because of malformed option for TCB %p\n", 807 840 Tcb) 808 841 ); … … 861 894 DEBUG ( 862 895 (EFI_D_ERROR, 863 "TcpInput: discard a segment because failed to clone a child for TCB %p\n",896 "TcpInput: discard a segment because failed to clone a child for TCB %p\n", 864 897 Tcb) 865 898 ); … … 869 902 870 903 DEBUG ( 871 (EFI_D_ INFO,904 (EFI_D_NET, 872 905 "TcpInput: create a child for TCB %p in listening\n", 873 906 Tcb) … … 887 920 TcpSetState (Tcb, TCP_SYN_RCVD); 888 921 TcpSetTimer (Tcb, TCP_TIMER_CONNECT, Tcb->ConnectTimeout); 889 TcpTrimInWnd (Tcb, Nbuf); 922 if (TcpTrimInWnd (Tcb, Nbuf) == 0) { 923 DEBUG ( 924 (EFI_D_ERROR, 925 "TcpInput: discard a broken segment for TCB %p\n", 926 Tcb) 927 ); 928 929 goto DISCARD; 930 } 890 931 891 932 goto StepSix; … … 941 982 942 983 // 943 // Fourth step: Check SYN. Pay attention to si timulatous open984 // Fourth step: Check SYN. Pay attention to simultaneous open 944 985 // 945 986 if (TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN)) { … … 962 1003 963 1004 if ((Tcb->CongestState == TCP_CONGEST_OPEN) && 964 TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RTT_ON) 965 ){1005 TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RTT_ON)) 1006 { 966 1007 967 1008 TcpComputeRtt (Tcb, Tcb->RttMeasure); … … 969 1010 } 970 1011 971 TcpTrimInWnd (Tcb, Nbuf); 1012 if (TcpTrimInWnd (Tcb, Nbuf) == 0) { 1013 DEBUG ( 1014 (EFI_D_ERROR, 1015 "TcpInput: discard a broken segment for TCB %p\n", 1016 Tcb) 1017 ); 1018 1019 goto DISCARD; 1020 } 972 1021 973 1022 TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW); 974 1023 975 1024 DEBUG ( 976 (EFI_D_ INFO,1025 (EFI_D_NET, 977 1026 "TcpInput: connection established for TCB %p in SYN_SENT\n", 978 1027 Tcb) … … 987 1036 988 1037 ASSERT (Tcb->SndNxt == Tcb->Iss + 1); 989 TcpAdjustSndQue (Tcb, Tcb->SndNxt); 990 991 TcpTrimInWnd (Tcb, Nbuf); 1038 1039 if (TcpAdjustSndQue (Tcb, Tcb->SndNxt) == 0 || TcpTrimInWnd (Tcb, Nbuf) == 0) { 1040 DEBUG ( 1041 (EFI_D_ERROR, 1042 "TcpInput: discard a broken segment for TCB %p\n", 1043 Tcb) 1044 ); 1045 1046 goto DISCARD; 1047 } 992 1048 993 1049 DEBUG ( 994 1050 (EFI_D_WARN, 995 "TcpInput: simultan ous open for TCB %p in SYN_SENT\n",1051 "TcpInput: simultaneous open for TCB %p in SYN_SENT\n", 996 1052 Tcb) 997 1053 ); … … 1035 1091 if ((TCP_SEQ_LT (Seg->Seq, Tcb->RcvWl2)) && 1036 1092 (Tcb->RcvWl2 == Seg->End) && 1037 !TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN | TCP_FLG_FIN) 1038 ){1093 !TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN | TCP_FLG_FIN)) 1094 { 1039 1095 1040 1096 TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW); … … 1059 1115 // 1060 1116 } else if ((Tcb->State == TCP_ESTABLISHED) || 1061 (Tcb->State == TCP_FIN_WAIT_1) ||1062 (Tcb->State == TCP_FIN_WAIT_2) ||1063 (Tcb->State == TCP_CLOSE_WAIT)1064 ){1117 (Tcb->State == TCP_FIN_WAIT_1) || 1118 (Tcb->State == TCP_FIN_WAIT_2) || 1119 (Tcb->State == TCP_CLOSE_WAIT)) 1120 { 1065 1121 1066 1122 SOCK_ERROR (Tcb->Sk, EFI_CONNECTION_RESET); … … 1075 1131 // Trim the data and flags. 1076 1132 // 1077 TcpTrimInWnd (Tcb, Nbuf); 1133 if (TcpTrimInWnd (Tcb, Nbuf) == 0) { 1134 DEBUG ( 1135 (EFI_D_ERROR, 1136 "TcpInput: discard a broken segment for TCB %p\n", 1137 Tcb) 1138 ); 1139 1140 goto DISCARD; 1141 } 1078 1142 1079 1143 // … … 1115 1179 if (Tcb->State == TCP_SYN_RCVD) { 1116 1180 1117 if (TCP_SEQ_LT (Tcb->SndUna, Seg->Ack) && TCP_SEQ_LEQ (Seg->Ack, Tcb->SndNxt)) { 1181 if (TCP_SEQ_LT (Tcb->SndUna, Seg->Ack) && 1182 TCP_SEQ_LEQ (Seg->Ack, Tcb->SndNxt)) 1183 { 1118 1184 1119 1185 Tcb->SndWnd = Seg->Wnd; … … 1127 1193 1128 1194 DEBUG ( 1129 (EFI_D_ INFO,1130 "TcpInput: connection established 1195 (EFI_D_NET, 1196 "TcpInput: connection established for TCB %p in SYN_RCVD\n", 1131 1197 Tcb) 1132 1198 ); … … 1177 1243 // defined there. 1178 1244 // 1179 if (TCP_SEQ_LEQ (Seg->Seq, Tcb->RcvWl2) && TCP_SEQ_LT (Tcb->RcvWl2, Seg->End)) { 1245 if (TCP_SEQ_LEQ (Seg->Seq, Tcb->RcvWl2) && 1246 TCP_SEQ_LT (Tcb->RcvWl2, Seg->End)) 1247 { 1180 1248 1181 1249 Tcb->TsRecent = Option.TSVal; … … 1207 1275 (Tcb->SndUna != Tcb->SndNxt) && 1208 1276 (Seg->Wnd == Tcb->SndWnd) && 1209 (0 == Len) 1210 ){1277 (0 == Len)) 1278 { 1211 1279 1212 1280 Tcb->DupAck++; … … 1220 1288 // 1221 1289 if (((Tcb->CongestState == TCP_CONGEST_OPEN) && (Tcb->DupAck < 3)) || 1222 (Tcb->CongestState == TCP_CONGEST_LOSS) 1223 ){1290 (Tcb->CongestState == TCP_CONGEST_LOSS)) 1291 { 1224 1292 1225 1293 if (TCP_SEQ_GT (Seg->Ack, Tcb->SndUna)) { … … 1246 1314 if (TCP_SEQ_GT (Seg->Ack, Tcb->SndUna)) { 1247 1315 1248 TcpAdjustSndQue (Tcb, Seg->Ack); 1316 if (TcpAdjustSndQue (Tcb, Seg->Ack) == 0) { 1317 DEBUG ( 1318 (EFI_D_ERROR, 1319 "TcpInput: discard a broken segment for TCB %p\n", 1320 Tcb) 1321 ); 1322 1323 goto DISCARD; 1324 } 1325 1249 1326 Tcb->SndUna = Seg->Ack; 1250 1327 1251 1328 if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_SND_URG) && 1252 TCP_SEQ_LT (Tcb->SndUp, Seg->Ack) 1253 ){1329 TCP_SEQ_LT (Tcb->SndUp, Seg->Ack)) 1330 { 1254 1331 1255 1332 TCP_CLEAR_FLG (Tcb->CtrlFlag, TCP_CTRL_SND_URG); … … 1261 1338 // 1262 1339 if (TCP_SEQ_LT (Tcb->SndWl1, Seg->Seq) || 1263 ((Tcb->SndWl1 == Seg->Seq) && TCP_SEQ_LEQ (Tcb->SndWl2, Seg->Ack)) 1264 ){1340 ((Tcb->SndWl1 == Seg->Seq) && TCP_SEQ_LEQ (Tcb->SndWl2, Seg->Ack))) 1341 { 1265 1342 1266 1343 Right = Seg->Ack + Seg->Wnd; … … 1270 1347 if ((Tcb->SndWl1 == Seg->Seq) && 1271 1348 (Tcb->SndWl2 == Seg->Ack) && 1272 (Len == 0) 1273 ){1349 (Len == 0)) 1350 { 1274 1351 1275 1352 goto NO_UPDATE; … … 1282 1359 ); 1283 1360 1284 if ((Tcb->CongestState == TCP_CONGEST_RECOVER) && (TCP_SEQ_LT (Right, Tcb->Recover))) { 1361 if ((Tcb->CongestState == TCP_CONGEST_RECOVER) && 1362 (TCP_SEQ_LT (Right, Tcb->Recover))) 1363 { 1285 1364 1286 1365 Tcb->Recover = Right; 1287 1366 } 1288 1367 1289 if ((Tcb->CongestState == TCP_CONGEST_LOSS) && (TCP_SEQ_LT (Right, Tcb->LossRecover))) { 1368 if ((Tcb->CongestState == TCP_CONGEST_LOSS) && 1369 (TCP_SEQ_LT (Right, Tcb->LossRecover))) 1370 { 1290 1371 1291 1372 Tcb->LossRecover = Right; … … 1293 1374 1294 1375 if (TCP_SEQ_LT (Right, Tcb->SndNxt)) { 1295 1296 Tcb->SndNxt = Right; 1297 1376 // 1377 // Check for Window Retraction in RFC7923 section 2.4. 1378 // The lower n bits of the peer's actual receive window is wiped out if TCP 1379 // window scale is enabled, it will look like the peer is shrinking the window. 1380 // Check whether the SndNxt is out of the advertised receive window by more than 1381 // 2^Rcv.Wind.Shift before moving the SndNxt to the left. 1382 // 1383 DEBUG ( 1384 (EFI_D_WARN, 1385 "TcpInput: peer advise negative useable window for connected TCB %p\n", 1386 Tcb) 1387 ); 1388 Usable = TCP_SUB_SEQ (Tcb->SndNxt, Right); 1389 if ((Usable >> Tcb->SndWndScale) > 0) { 1390 DEBUG ( 1391 (EFI_D_WARN, 1392 "TcpInput: SndNxt is out of window by more than window scale for TCB %p\n", 1393 Tcb) 1394 ); 1395 Tcb->SndNxt = Right; 1396 } 1298 1397 if (Right == Tcb->SndUna) { 1299 1398 … … 1312 1411 NO_UPDATE: 1313 1412 1314 if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT) && (Tcb->SndUna == Tcb->SndNxt)) { 1413 if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_FIN_SENT) && 1414 (Tcb->SndUna == Tcb->SndNxt)) 1415 { 1315 1416 1316 1417 DEBUG ( 1317 (EFI_D_ INFO,1418 (EFI_D_NET, 1318 1419 "TcpInput: local FIN is ACKed by peer for connected TCB %p\n", 1319 1420 Tcb) … … 1411 1512 1412 1513 DEBUG ( 1413 (EFI_D_ INFO,1514 (EFI_D_NET, 1414 1515 "TcpInput: received urgent data from peer for connected TCB %p\n", 1415 1516 Tcb) … … 1418 1519 Urg = Seg->Seq + Seg->Urg; 1419 1520 1420 if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RCVD_URG) && TCP_SEQ_GT (Urg, Tcb->RcvUp)) { 1521 if (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_RCVD_URG) && 1522 TCP_SEQ_GT (Urg, Tcb->RcvUp)) 1523 { 1421 1524 1422 1525 Tcb->RcvUp = Urg; … … 1453 1556 } 1454 1557 1455 TcpQueueData (Tcb, Nbuf); 1558 if (TcpQueueData (Tcb, Nbuf) == 0) { 1559 DEBUG ( 1560 (EFI_D_ERROR, 1561 "TcpInput: discard a broken segment for TCB %p\n", 1562 Tcb) 1563 ); 1564 1565 goto DISCARD; 1566 } 1567 1456 1568 if (TcpDeliverData (Tcb) == -1) { 1457 1569 goto RESET_THEN_DROP; … … 1481 1593 if ((Tcb->State != TCP_CLOSED) && 1482 1594 (TcpToSendData (Tcb, 0) == 0) && 1483 (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) || (Nbuf->TotalSize != 0)) 1484 ){1595 (TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_ACK_NOW) || (Nbuf->TotalSize != 0))) 1596 { 1485 1597 1486 1598 TcpToSendAck (Tcb); … … 1550 1662 BOOLEAN IcmpErrNotify; 1551 1663 1664 if (Nbuf->TotalSize < sizeof (TCP_HEAD)) { 1665 goto CLEAN_EXIT; 1666 } 1667 1552 1668 Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL); 1553 1669 ASSERT (Head != NULL); … … 1575 1691 } 1576 1692 1577 IcmpErrStatus = IpIoGetIcmpErrStatus (IcmpErr, Tcb->Sk->IpVersion, &IcmpErrIsHard, &IcmpErrNotify); 1693 IcmpErrStatus = IpIoGetIcmpErrStatus ( 1694 IcmpErr, 1695 Tcb->Sk->IpVersion, 1696 &IcmpErrIsHard, 1697 &IcmpErrNotify 1698 ); 1578 1699 1579 1700 if (IcmpErrNotify) { -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpMain.c
r48674 r77662 2 2 Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL. 3 3 4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 40 41 41 42 for (Index = 0, Len = 0; Index < FragmentCount; Index++) { 43 if (FragmentTable[Index].FragmentBuffer == NULL) { 44 return EFI_INVALID_PARAMETER; 45 } 42 46 Len = Len + FragmentTable[Index].FragmentLength; 43 47 } … … 147 151 148 152 CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR)); 149 if ( (Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {153 if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) { 150 154 return EFI_INVALID_PARAMETER; 151 155 } … … 159 163 CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR)); 160 164 CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR)); 161 if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) { 165 if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || 166 (SubnetMask != 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask)))) { 162 167 return EFI_INVALID_PARAMETER; 163 168 } … … 484 489 Abort an asynchronous connection, listen, transmission or receive request. 485 490 486 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 487 @param[in] Token Pointer to a token that has been issued by 488 Connect(), Accept(), Transmit() or Receive(). If 489 NULL, all pending tokens issued by the four 490 functions listed above will be aborted. 491 492 @retval EFI_UNSUPPORTED The operation is not supported in the current 493 implementation. 491 @param This The pointer to the EFI_TCP4_PROTOCOL instance. 492 @param Token The pointer to a token that has been issued by 493 EFI_TCP4_PROTOCOL.Connect(), 494 EFI_TCP4_PROTOCOL.Accept(), 495 EFI_TCP4_PROTOCOL.Transmit() or 496 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending 497 tokens issued by above four functions will be aborted. Type 498 EFI_TCP4_COMPLETION_TOKEN is defined in 499 EFI_TCP4_PROTOCOL.Connect(). 500 501 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event 502 is signaled. 503 @retval EFI_INVALID_PARAMETER This is NULL. 504 @retval EFI_NOT_STARTED This instance hasn't been configured. 505 @retval EFI_NO_MAPPING When using the default address, configuration 506 (DHCP, BOOTP,RARP, etc.) hasn't finished yet. 507 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the 508 transmission or receive queue. It has either 509 completed or wasn't issued by Transmit() and Receive(). 494 510 495 511 **/ … … 501 517 ) 502 518 { 503 return EFI_UNSUPPORTED; 519 SOCKET *Sock; 520 521 if (NULL == This) { 522 return EFI_INVALID_PARAMETER; 523 } 524 525 Sock = SOCK_FROM_THIS (This); 526 527 return SockCancel (Sock, Token); 504 528 } 505 529 … … 998 1022 999 1023 /** 1000 Abort an asynchronous connection, listen, transmission ,or receive request.1001 1002 The Cancel() function aborts a pending connection, listen, transmit ,or1024 Abort an asynchronous connection, listen, transmission or receive request. 1025 1026 The Cancel() function aborts a pending connection, listen, transmit or 1003 1027 receive request. 1004 1028 1005 If Token is not NULL and the token is in the connection, listen, transmission ,1029 If Token is not NULL and the token is in the connection, listen, transmission 1006 1030 or receive queue when it is being cancelled, its Token->Status will be set 1007 to EFI_ABORTED ,and then Token->Event will be signaled.1031 to EFI_ABORTED and then Token->Event will be signaled. 1008 1032 1009 1033 If the token is not in one of the queues, which usually means that the … … 1011 1035 1012 1036 If Token is NULL all asynchronous token issued by Connect(), Accept(), 1013 Transmit() ,and Receive() will be aborted.1037 Transmit() and Receive() will be aborted. 1014 1038 1015 1039 @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance. … … 1023 1047 EFI_TCP_PROTOCOL.Connect(). 1024 1048 1025 @retval EFI_UNSUPPORTED The implementation does not support this function. 1049 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event 1050 is signaled. 1051 @retval EFI_INVALID_PARAMETER This is NULL. 1052 @retval EFI_NOT_STARTED This instance hasn't been configured. 1053 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or 1054 receive queue. It has either completed or wasn't issued by 1055 Transmit() and Receive(). 1026 1056 1027 1057 **/ … … 1033 1063 ) 1034 1064 { 1035 return EFI_UNSUPPORTED; 1065 SOCKET *Sock; 1066 1067 if (NULL == This) { 1068 return EFI_INVALID_PARAMETER; 1069 } 1070 1071 Sock = SOCK_FROM_THIS (This); 1072 1073 return SockCancel (Sock, Token); 1036 1074 } 1037 1075 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpMain.h
r58459 r77662 3 3 It is the common head file for all Tcp*.c in TCP driver. 4 4 5 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 360 360 Abort an asynchronous connection, listen, transmission or receive request. 361 361 362 @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance. 363 @param[in] Token Pointer to a token that has been issued by 364 Connect(), Accept(), Transmit() or Receive(). If 365 NULL, all pending tokens issued by the above four 366 functions will be aborted. 367 368 @retval EFI_UNSUPPORTED The operation is not supported in the current 369 implementation. 362 @param This The pointer to the EFI_TCP4_PROTOCOL instance. 363 @param Token The pointer to a token that has been issued by 364 EFI_TCP4_PROTOCOL.Connect(), 365 EFI_TCP4_PROTOCOL.Accept(), 366 EFI_TCP4_PROTOCOL.Transmit() or 367 EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending 368 tokens issued by above four functions will be aborted. Type 369 EFI_TCP4_COMPLETION_TOKEN is defined in 370 EFI_TCP4_PROTOCOL.Connect(). 371 372 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event 373 is signaled. 374 @retval EFI_INVALID_PARAMETER This is NULL. 375 @retval EFI_NOT_STARTED This instance hasn't been configured. 376 @retval EFI_NO_MAPPING When using the default address, configuration 377 (DHCP, BOOTP,RARP, etc.) hasn't finished yet. 378 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the 379 transmission or receive queue. It has either 380 completed or wasn't issued by Transmit() and Receive(). 370 381 371 382 **/ … … 731 742 EFI_TCP_PROTOCOL.Connect(). 732 743 733 @retval EFI_UNSUPPORTED The implementation does not support this function. 744 @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event 745 is signaled. 746 @retval EFI_INVALID_PARAMETER This is NULL. 747 @retval EFI_NOT_STARTED This instance hasn't been configured. 748 @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or 749 receive queue. It has either completed or wasn't issued by 750 Transmit() and Receive(). 734 751 735 752 **/ -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpMisc.c
r58459 r77662 2 2 Misc support routines for TCP driver. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 86 87 // 87 88 Tcb->RcvWndScale = 0; 89 Tcb->RetxmitSeqMax = 0; 88 90 89 91 Tcb->ProbeTimerOn = FALSE; … … 160 162 TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_SND_TS); 161 163 TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_RCVD_TS); 164 165 Tcb->TsRecent = Opt->TSVal; 162 166 163 167 // … … 429 433 LIST_ENTRY *Head; 430 434 TCP_CB *Node; 431 TCP_PROTO_DATA *TcpProto;432 435 433 436 ASSERT ( … … 467 470 InsertHeadList (Head, &Tcb->List); 468 471 469 TcpProto = (TCP_PROTO_DATA *) Tcb->Sk->ProtoReserved;470 472 471 473 return 0; … … 566 568 Ip6 = TcpProto->TcpService->IpIo->Ip.Ip6; 567 569 ASSERT (Ip6 != NULL); 568 Ip6->GetModeData (Ip6, &Ip6Mode, NULL, NULL); 570 if (!EFI_ERROR (Ip6->GetModeData (Ip6, &Ip6Mode, NULL, NULL))) { 571 if (Ip6Mode.AddressList != NULL) { 572 FreePool (Ip6Mode.AddressList); 573 } 574 575 if (Ip6Mode.GroupTable != NULL) { 576 FreePool (Ip6Mode.GroupTable); 577 } 578 579 if (Ip6Mode.RouteTable != NULL) { 580 FreePool (Ip6Mode.RouteTable); 581 } 582 583 if (Ip6Mode.NeighborCache != NULL) { 584 FreePool (Ip6Mode.NeighborCache); 585 } 586 587 if (Ip6Mode.PrefixTable != NULL) { 588 FreePool (Ip6Mode.PrefixTable); 589 } 590 591 if (Ip6Mode.IcmpTypeList != NULL) { 592 FreePool (Ip6Mode.IcmpTypeList); 593 } 594 } 569 595 570 596 return (UINT16) (Ip6Mode.MaxPacketSize - sizeof (TCP_HEAD)); … … 589 615 590 616 DEBUG ( 591 (EFI_D_ INFO,617 (EFI_D_NET, 592 618 "Tcb (%p) state %s --> %s\n", 593 619 Tcb, … … 838 864 839 865 DEBUG ( 840 (EFI_D_ INFO,866 (EFI_D_NET, 841 867 "TcpOnAppConsume: send a window update for a window closed Tcb %p\n", 842 868 Tcb) … … 847 873 848 874 DEBUG ( 849 (EFI_D_ INFO,875 (EFI_D_NET, 850 876 "TcpOnAppConsume: scheduled a delayed ACK to update window for Tcb %p\n", 851 877 Tcb) -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpOutput.c
r48674 r77662 2 2 TCP output process routines. 3 3 4 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 293 293 UINT32 DataLen; 294 294 295 ASSERT ((Nbuf != NULL) && (Nbuf->Tcp == NULL) && (TcpVerifySegment (Nbuf) != 0)); 295 ASSERT ((Nbuf != NULL) && (Nbuf->Tcp == NULL)); 296 297 if (TcpVerifySegment (Nbuf) == 0) { 298 return -1; 299 } 296 300 297 301 DataLen = Nbuf->TotalSize; … … 635 639 } 636 640 637 ASSERT (TcpVerifySegment (Nbuf) != 0); 641 if (TcpVerifySegment (Nbuf) == 0) { 642 NetbufFree (Nbuf); 643 return NULL; 644 } 645 638 646 return Nbuf; 639 647 } … … 665 673 // 3. Will not change the boundaries of queued segments. 666 674 // 667 if (TCP_SEQ_LT (Tcb->SndWl2 + Tcb->SndWnd, Seq)) { 675 676 // 677 // Handle the Window Retraction if TCP window scale is enabled according to RFC7323: 678 // On first retransmission, or if the sequence number is out of 679 // window by less than 2^Rcv.Wind.Shift, then do normal 680 // retransmission(s) without regard to the receiver window as long 681 // as the original segment was in window when it was sent. 682 // 683 if ((Tcb->SndWndScale != 0) && 684 (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax) || TCP_SEQ_BETWEEN (Tcb->SndWl2 + Tcb->SndWnd, Seq, Tcb->SndWl2 + Tcb->SndWnd + (1 << Tcb->SndWndScale)))) { 685 Len = TCP_SUB_SEQ (Tcb->SndNxt, Seq); 686 DEBUG ( 687 (EFI_D_WARN, 688 "TcpRetransmit: retransmission without regard to the receiver window for TCB %p\n", 689 Tcb) 690 ); 691 692 } else if (TCP_SEQ_GEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq)) { 693 Len = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq); 694 695 } else { 668 696 DEBUG ( 669 697 (EFI_D_WARN, … … 675 703 } 676 704 677 Len = TCP_SUB_SEQ (Tcb->SndWl2 + Tcb->SndWnd, Seq); 678 Len = MIN (Len, Tcb->SndMss); 679 680 Nbuf = TcpGetSegmentSndQue (Tcb, Seq, Len); 705 Len = MIN (Len, Tcb->SndMss); 706 707 Nbuf = TcpGetSegmentSndQue (Tcb, Seq, Len); 681 708 if (Nbuf == NULL) { 682 709 return -1; 683 710 } 684 711 685 ASSERT (TcpVerifySegment (Nbuf) != 0); 712 if (TcpVerifySegment (Nbuf) == 0) { 713 goto OnError; 714 } 686 715 687 716 if (TcpTransmitSegment (Tcb, Nbuf) != 0) { 688 717 goto OnError; 718 } 719 720 if (TCP_SEQ_GT (Seq, Tcb->RetxmitSeqMax)) { 721 Tcb->RetxmitSeqMax = Seq; 689 722 } 690 723 … … 798 831 Seq = Tcb->SndNxt; 799 832 800 ASSERT ((Tcb->State) < ( sizeof (mTcpOutFlag) / sizeof (mTcpOutFlag[0])));833 ASSERT ((Tcb->State) < (ARRAY_SIZE (mTcpOutFlag))); 801 834 Flag = mTcpOutFlag[Tcb->State]; 802 835 … … 848 881 ) { 849 882 DEBUG ( 850 (EFI_D_ INFO,883 (EFI_D_NET, 851 884 "TcpToSendData: send FIN to peer for TCB %p in state %s\n", 852 885 Tcb, … … 864 897 Seg->Flag = Flag; 865 898 866 ASSERT (TcpVerifySegment (Nbuf) != 0); 867 ASSERT (TcpCheckSndQue (&Tcb->SndQue) != 0); 899 if (TcpVerifySegment (Nbuf) == 0 || TcpCheckSndQue (&Tcb->SndQue) == 0) { 900 DEBUG ( 901 (EFI_D_ERROR, 902 "TcpToSendData: discard a broken segment for TCB %p\n", 903 Tcb) 904 ); 905 goto OnError; 906 } 868 907 869 908 // … … 877 916 ); 878 917 879 NetbufFree (Nbuf); 880 return Sent; 918 goto OnError; 881 919 } 882 920 … … 928 966 929 967 DEBUG ( 930 (EFI_D_ INFO,968 (EFI_D_NET, 931 969 "TcpToSendData: set RTT measure sequence %d for TCB %p\n", 932 970 Seq, … … 1059 1097 1060 1098 DEBUG ( 1061 (EFI_D_ INFO,1099 (EFI_D_NET, 1062 1100 "TcpToSendAck: scheduled a delayed ACK for TCB %p\n", 1063 1101 Tcb) -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TcpDxe/TcpProto.h
r58459 r77662 2 2 TCP protocol header file. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 317 317 318 318 // 319 // RFC7323 320 // Addressing Window Retraction for TCP Window Scale Option. 321 // 322 TCP_SEQNO RetxmitSeqMax; ///< Max Seq number in previous retransmission. 323 324 // 319 325 // configuration parameters, for EFI_TCP4_PROTOCOL specification 320 326 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Udp6Dxe/Udp6Driver.c
r58466 r77662 2 2 Driver Binding functions and Service Binding functions for the Network driver module. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 165 165 if (EFI_ERROR (Status)) { 166 166 Udp6CleanService (Udp6Service); 167 goto EXIT;168 167 } 169 168 … … 183 182 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 184 183 185 @retval EFI_SUCCESS The entry has been removed successfully. 186 @retval Others Fail to remove the entry. 184 @retval EFI_INVALID_PARAMETER Entry is NULL or Context is NULL. 185 @retval EFI_SUCCESS The entry has been removed successfully. 186 @retval Others Fail to remove the entry. 187 187 188 188 **/ … … 244 244 ) 245 245 { 246 EFI_STATUS Status;247 EFI_HANDLE NicHandle;248 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;249 UDP6_SERVICE_DATA *Udp6Service;250 LIST_ENTRY *List;251 UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;246 EFI_STATUS Status; 247 EFI_HANDLE NicHandle; 248 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 249 UDP6_SERVICE_DATA *Udp6Service; 250 LIST_ENTRY *List; 251 UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; 252 252 253 253 // … … 291 291 ); 292 292 } else if (IsListEmpty (&Udp6Service->ChildrenList)) { 293 gBS->UninstallMultipleProtocolInterfaces (294 NicHandle,295 &gEfiUdp6ServiceBindingProtocolGuid,296 &Udp6Service->ServiceBinding,297 NULL298 );293 Status = gBS->UninstallMultipleProtocolInterfaces ( 294 NicHandle, 295 &gEfiUdp6ServiceBindingProtocolGuid, 296 &Udp6Service->ServiceBinding, 297 NULL 298 ); 299 299 300 300 Udp6CleanService (Udp6Service); 301 302 301 FreePool (Udp6Service); 303 304 Status = EFI_SUCCESS;305 302 } 306 303 … … 322 319 @retval EFI_SUCCES The protocol was added to ChildHandle. 323 320 @retval EFI_INVALID_PARAMETER This is NULL or ChildHandle is NULL. 324 @retval EFI_OUT_OF_RESOURCES There are not enough resources availab e to create321 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create 325 322 the child. 326 323 @retval other The child handle was not created. … … 511 508 // Close the Ip6 protocol on the default IpIo. 512 509 // 513 gBS->CloseProtocol ( 514 Udp6Service->IpIo->ChildHandle, 515 &gEfiIp6ProtocolGuid, 516 gUdp6DriverBinding.DriverBindingHandle, 517 Instance->ChildHandle 518 ); 510 Status = gBS->CloseProtocol ( 511 Udp6Service->IpIo->ChildHandle, 512 &gEfiIp6ProtocolGuid, 513 gUdp6DriverBinding.DriverBindingHandle, 514 Instance->ChildHandle 515 ); 516 if (EFI_ERROR (Status)) { 517 Instance->InDestroy = FALSE; 518 return Status; 519 } 520 519 521 // 520 522 // Close the Ip6 protocol on this instance's IpInfo. 521 523 // 522 gBS->CloseProtocol ( 523 Instance->IpInfo->ChildHandle, 524 &gEfiIp6ProtocolGuid, 525 gUdp6DriverBinding.DriverBindingHandle, 526 Instance->ChildHandle 527 ); 524 Status = gBS->CloseProtocol ( 525 Instance->IpInfo->ChildHandle, 526 &gEfiIp6ProtocolGuid, 527 gUdp6DriverBinding.DriverBindingHandle, 528 Instance->ChildHandle 529 ); 530 if (EFI_ERROR (Status)) { 531 Instance->InDestroy = FALSE; 532 return Status; 533 } 528 534 529 535 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Udp6Dxe/Udp6Driver.h
r48674 r77662 2 2 Driver Binding functions and Service Binding functions for the Network driver module. 3 3 4 Copyright (c) 2009 - 201 1, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 141 141 @retval EFI_SUCCES The protocol was added to ChildHandle. 142 142 @retval EFI_INVALID_PARAMETER This is NULL or ChildHandle is NULL. 143 @retval EFI_OUT_OF_RESOURCES There are not enough resources availab e to create143 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create 144 144 the child. 145 145 @retval other The child handle was not created. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Udp6Dxe/Udp6Dxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // UDP packet service based on IPv6 stack. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Udp6Dxe/Udp6DxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Udp6Dxe Localized Strings and Content 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Udp6Dxe/Udp6Impl.c
r58466 r77662 2 2 Udp6 driver's whole implementation. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 57 57 interface. It's called to signal the udp TxToken when the IpIo layer completes 58 58 transmitting of the udp datagram. 59 60 If Context is NULL, then ASSERT(). 61 If NotifyData is NULL, then ASSERT(). 59 62 60 63 @param[in] Status The completion status of the output udp datagram. … … 75 78 /** 76 79 This function processes the received datagram passed up by the IpIo layer. 80 81 If NetSession is NULL, then ASSERT(). 82 If Packet is NULL, then ASSERT(). 83 If Context is NULL, then ASSERT(). 77 84 78 85 @param[in] Status The status of this udp datagram. … … 159 166 datagram. 160 167 161 @return Pointer to the structure wrapping the RxData and the Packet. 168 @return Pointer to the structure wrapping the RxData and the Packet. NULL will 169 be returned if any error occurs. 162 170 163 171 **/ … … 200 208 201 209 /** 202 This function demultiplexes the received udp datagram to the ap ropriate instances.210 This function demultiplexes the received udp datagram to the appropriate instances. 203 211 204 212 @param[in] Udp6Service Pointer to the udp service context data. 205 @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstra ted from213 @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstracted from 206 214 the received datagram. 207 215 @param[in] Packet Pointer to the buffer containing the received udp … … 977 985 transmitting of the udp datagram. 978 986 987 If Context is NULL, then ASSERT(). 988 If NotifyData is NULL, then ASSERT(). 989 979 990 @param[in] Status The completion status of the output udp datagram. 980 991 @param[in] Context Pointer to the context data. … … 995 1006 EFI_UDP6_COMPLETION_TOKEN *Token; 996 1007 1008 ASSERT (Context != NULL && NotifyData != NULL); 1009 997 1010 Instance = (UDP6_INSTANCE_DATA *) Context; 998 1011 Token = (EFI_UDP6_COMPLETION_TOKEN *) NotifyData; … … 1011 1024 /** 1012 1025 This function processes the received datagram passed up by the IpIo layer. 1026 1027 If NetSession is NULL, then ASSERT(). 1028 If Packet is NULL, then ASSERT(). 1029 If Context is NULL, then ASSERT(). 1013 1030 1014 1031 @param[in] Status The status of this udp datagram. … … 1031 1048 ) 1032 1049 { 1050 ASSERT (NetSession != NULL && Packet != NULL && Context != NULL); 1033 1051 NET_CHECK_SIGNATURE (Packet, NET_BUF_SIGNATURE); 1034 1052 … … 1375 1393 datagram. 1376 1394 1377 @return Pointer to the structure wrapping the RxData and the Packet. 1395 @return Pointer to the structure wrapping the RxData and the Packet. NULL will 1396 be returned if any error occurs. 1378 1397 1379 1398 **/ … … 1580 1599 1581 1600 @param[in] Udp6Service Pointer to the udp service context data. 1582 @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstra ted from1601 @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA abstracted from 1583 1602 the received datagram. 1584 1603 @param[in] Packet Pointer to the buffer containing the received udp … … 1599 1618 UINTN Enqueued; 1600 1619 1620 if (Packet->TotalSize < UDP6_HEADER_SIZE) { 1621 NetbufFree (Packet); 1622 return; 1623 } 1624 1601 1625 // 1602 1626 // Get the datagram header from the packet buffer. … … 1604 1628 Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); 1605 1629 ASSERT (Udp6Header != NULL); 1630 if (Udp6Header == NULL) { 1631 NetbufFree (Packet); 1632 return; 1633 } 1606 1634 1607 1635 if (Udp6Header->Checksum != 0) { … … 1620 1648 // Wrong checksum. 1621 1649 // 1650 NetbufFree (Packet); 1622 1651 return; 1623 1652 } … … 1713 1742 Ip6ModeData = AllocateZeroPool (sizeof (EFI_IP6_MODE_DATA)); 1714 1743 ASSERT (Ip6ModeData != NULL); 1744 if (Ip6ModeData == NULL) { 1745 goto EXIT; 1746 } 1715 1747 1716 1748 // … … 1761 1793 IcmpErrHdr = (IP6_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FALSE); 1762 1794 ASSERT (IcmpErrHdr != NULL); 1795 if (IcmpErrHdr == NULL) { 1796 goto EXIT; 1797 } 1763 1798 1764 1799 // … … 1835 1870 UDP6_INSTANCE_DATA *Instance; 1836 1871 1872 if (Packet->TotalSize < UDP6_HEADER_SIZE) { 1873 NetbufFree (Packet); 1874 return; 1875 } 1876 1837 1877 Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); 1838 1878 ASSERT (Udp6Header != NULL); 1879 if (Udp6Header == NULL) { 1880 NetbufFree (Packet); 1881 return; 1882 } 1839 1883 1840 1884 IP6_COPY_ADDRESS (&Udp6Session.SourceAddress, &NetSession->Source); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Udp6Dxe/Udp6Main.c
r58466 r77662 2 2 Contains all EFI_UDP6_PROTOCOL interfaces. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 352 352 Instance = UDP6_INSTANCE_DATA_FROM_THIS (This); 353 353 if (!Instance->Configured) { 354 if (McastIp != NULL) { 355 FreePool (McastIp); 356 } 354 357 return EFI_NOT_STARTED; 355 358 } … … 379 382 } else { 380 383 381 NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, MulticastAddress); 384 Status = NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, MulticastAddress); 385 if ((MulticastAddress != NULL) && (Status == EFI_ABORTED)) { 386 Status = EFI_SUCCESS; 387 } 382 388 } 383 389 … … 526 532 Udp6Header = (EFI_UDP_HEADER *) NetbufAllocSpace (Packet, UDP6_HEADER_SIZE, TRUE); 527 533 ASSERT (Udp6Header != NULL); 534 if (Udp6Header == NULL) { 535 Status = EFI_OUT_OF_RESOURCES; 536 goto ON_EXIT; 537 } 538 528 539 ConfigData = &Instance->ConfigData; 529 540 … … 578 589 // If the calculated checksum is 0, fill the Checksum field with all ones. 579 590 // 580 Udp6Header->Checksum = 0 XFFFF;591 Udp6Header->Checksum = 0xffff; 581 592 } 582 593 } else { -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c
r58466 r77662 2 2 Boot functions implementation for UefiPxeBc Driver. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> 5 6 6 7 This program and the accompanying materials … … 145 146 TimeoutEvent, 146 147 TimerRelative, 147 Timeout * TICKS_PER_SECOND148 MultU64x32 (Timeout, TICKS_PER_SECOND) 148 149 ); 149 150 if (EFI_ERROR (Status)) { … … 621 622 622 623 // 624 // Set the station address to IP layer. 625 // 626 Status = PxeBcSetIp6Address (Private); 627 if (EFI_ERROR (Status)) { 628 return Status; 629 } 630 631 632 // 623 633 // Parse (m)tftp server ip address and bootfile name. 624 634 // 625 635 Status = PxeBcExtractBootFileUrl ( 636 Private, 626 637 &Private->BootFileName, 627 638 &Private->ServerIp.v6, … … 984 995 PxeBc = &Private->PxeBc; 985 996 Status = gBS->HandleProtocol ( 986 Private-> Controller,997 Private->Mode.UsingIpv6 ? Private->Ip6Nic->Controller : Private->Ip4Nic->Controller, 987 998 &gEfiPxeBaseCodeCallbackProtocolGuid, 988 999 (VOID **) &Private->PxeBcCallback … … 1000 1011 // 1001 1012 Status = gBS->InstallProtocolInterface ( 1002 &Private->Controller,1013 Private->Mode.UsingIpv6 ? &Private->Ip6Nic->Controller : &Private->Ip4Nic->Controller, 1003 1014 &gEfiPxeBaseCodeCallbackProtocolGuid, 1004 1015 EFI_NATIVE_INTERFACE, … … 1044 1055 1045 1056 gBS->UninstallProtocolInterface ( 1046 Private-> Controller,1057 Private->Mode.UsingIpv6 ? Private->Ip6Nic->Controller : Private->Ip4Nic->Controller, 1047 1058 &gEfiPxeBaseCodeCallbackProtocolGuid, 1048 1059 &Private->LoadFileCallback … … 1221 1232 1222 1233 if (Status == EFI_SUCCESS) { 1223 AsciiPrint ("\n Succeed to download NBP file.\n");1234 AsciiPrint ("\n NBP file downloaded successfully.\n"); 1224 1235 return EFI_SUCCESS; 1225 1236 } else if (Status == EFI_BUFFER_TOO_SMALL && Buffer != NULL) { … … 1232 1243 AsciiPrint ("\n PXE-E12: Could not detect network connection.\n"); 1233 1244 } else if (Status == EFI_NO_RESPONSE) { 1234 AsciiPrint ("\n PXE-E16: No offer received.\n");1245 AsciiPrint ("\n PXE-E16: No valid offer received.\n"); 1235 1246 } else if (Status == EFI_TIMEOUT) { 1236 1247 AsciiPrint ("\n PXE-E18: Server response timeout.\n"); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
r58466 r77662 2 2 Functions implementation related with DHCPv4 for UefiPxeBc Driver. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 20 20 // 21 21 UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = { 22 PXEBC_DHCP4_TAG_BOOTFILE_LEN,23 PXEBC_DHCP4_TAG_VENDOR,24 PXEBC_DHCP4_TAG_OVERLOAD,25 PXEBC_DHCP4_TAG_MSG_TYPE,26 PXEBC_DHCP4_TAG_SERVER_ID,27 PXEBC_DHCP4_TAG_CLASS_ID,28 PXEBC_DHCP4_TAG_BOOTFILE22 DHCP4_TAG_BOOTFILE_LEN, 23 DHCP4_TAG_VENDOR, 24 DHCP4_TAG_OVERLOAD, 25 DHCP4_TAG_MSG_TYPE, 26 DHCP4_TAG_SERVER_ID, 27 DHCP4_TAG_VENDOR_CLASS_ID, 28 DHCP4_TAG_BOOTFILE 29 29 }; 30 30 … … 59 59 Offset = 0; 60 60 61 while (Offset < Length && Option->OpCode != PXEBC_DHCP4_TAG_EOP) {61 while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) { 62 62 63 63 if (Option->OpCode == OptTag) { … … 71 71 // Skip the current option to the next. 72 72 // 73 if (Option->OpCode == PXEBC_DHCP4_TAG_PAD) {73 if (Option->OpCode == DHCP4_TAG_PAD) { 74 74 Offset++; 75 75 } else { … … 109 109 ASSERT (PxeOption != NULL); 110 110 111 while ((Offset < VendorOptionLen) && (PxeOption->OpCode != PXEBC_DHCP4_TAG_EOP)) {111 while ((Offset < VendorOptionLen) && (PxeOption->OpCode != DHCP4_TAG_EOP)) { 112 112 // 113 113 // Parse all the interesting PXE vendor options one by one. … … 202 202 // Continue to the next option. 203 203 // 204 if (PxeOption->OpCode == PXEBC_DHCP4_TAG_PAD) {204 if (PxeOption->OpCode == DHCP4_TAG_PAD) { 205 205 Offset++; 206 206 } else { … … 244 244 // Append message type. 245 245 // 246 OptList[Index]->OpCode = PXEBC_DHCP4_TAG_MSG_TYPE;246 OptList[Index]->OpCode = DHCP4_TAG_MSG_TYPE; 247 247 OptList[Index]->Length = 1; 248 248 OptEnt.Mesg = (PXEBC_DHCP4_OPTION_MESG *) OptList[Index]->Data; … … 254 254 // Append max message size. 255 255 // 256 OptList[Index]->OpCode = PXEBC_DHCP4_TAG_MAXMSG;256 OptList[Index]->OpCode = DHCP4_TAG_MAXMSG; 257 257 OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE); 258 258 OptEnt.MaxMesgSize = (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *) OptList[Index]->Data; 259 Value = NTOHS (PXEBC_DHCP4_PACKET_MAX_SIZE - 8);259 Value = NTOHS (PXEBC_DHCP4_PACKET_MAX_SIZE); 260 260 CopyMem (&OptEnt.MaxMesgSize->Size, &Value, sizeof (UINT16)); 261 261 Index++; … … 266 266 // Append parameter request list option. 267 267 // 268 OptList[Index]->OpCode = PXEBC_DHCP4_TAG_PARA_LIST;268 OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST; 269 269 OptList[Index]->Length = 35; 270 270 OptEnt.Para = (PXEBC_DHCP4_OPTION_PARA *) OptList[Index]->Data; 271 OptEnt.Para->ParaList[0] = PXEBC_DHCP4_TAG_NETMASK;272 OptEnt.Para->ParaList[1] = PXEBC_DHCP4_TAG_TIME_OFFSET;273 OptEnt.Para->ParaList[2] = PXEBC_DHCP4_TAG_ROUTER;274 OptEnt.Para->ParaList[3] = PXEBC_DHCP4_TAG_TIME_SERVER;275 OptEnt.Para->ParaList[4] = PXEBC_DHCP4_TAG_NAME_SERVER;276 OptEnt.Para->ParaList[5] = PXEBC_DHCP4_TAG_DNS_SERVER;277 OptEnt.Para->ParaList[6] = PXEBC_DHCP4_TAG_HOSTNAME;278 OptEnt.Para->ParaList[7] = PXEBC_DHCP4_TAG_BOOTFILE_LEN;279 OptEnt.Para->ParaList[8] = PXEBC_DHCP4_TAG_DOMAINNAME;280 OptEnt.Para->ParaList[9] = PXEBC_DHCP4_TAG_ROOTPATH;281 OptEnt.Para->ParaList[10] = PXEBC_DHCP4_TAG_EXTEND_PATH;282 OptEnt.Para->ParaList[11] = PXEBC_DHCP4_TAG_EMTU;283 OptEnt.Para->ParaList[12] = PXEBC_DHCP4_TAG_TTL;284 OptEnt.Para->ParaList[13] = PXEBC_DHCP4_TAG_BROADCAST;285 OptEnt.Para->ParaList[14] = PXEBC_DHCP4_TAG_NIS_DOMAIN;286 OptEnt.Para->ParaList[15] = PXEBC_DHCP4_TAG_NIS_SERVER;287 OptEnt.Para->ParaList[16] = PXEBC_DHCP4_TAG_NTP_SERVER;288 OptEnt.Para->ParaList[17] = PXEBC_DHCP4_TAG_VENDOR;289 OptEnt.Para->ParaList[18] = PXEBC_DHCP4_TAG_REQUEST_IP;290 OptEnt.Para->ParaList[19] = PXEBC_DHCP4_TAG_LEASE;291 OptEnt.Para->ParaList[20] = PXEBC_DHCP4_TAG_SERVER_ID;292 OptEnt.Para->ParaList[21] = PXEBC_DHCP4_TAG_T1;293 OptEnt.Para->ParaList[22] = PXEBC_DHCP4_TAG_T2;294 OptEnt.Para->ParaList[23] = PXEBC_DHCP4_TAG_CLASS_ID;295 OptEnt.Para->ParaList[24] = PXEBC_DHCP4_TAG_TFTP;296 OptEnt.Para->ParaList[25] = PXEBC_DHCP4_TAG_BOOTFILE;297 OptEnt.Para->ParaList[26] = PXEBC_PXE_DHCP4_TAG_UUID;271 OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK; 272 OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET; 273 OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER; 274 OptEnt.Para->ParaList[3] = DHCP4_TAG_TIME_SERVER; 275 OptEnt.Para->ParaList[4] = DHCP4_TAG_NAME_SERVER; 276 OptEnt.Para->ParaList[5] = DHCP4_TAG_DNS_SERVER; 277 OptEnt.Para->ParaList[6] = DHCP4_TAG_HOSTNAME; 278 OptEnt.Para->ParaList[7] = DHCP4_TAG_BOOTFILE_LEN; 279 OptEnt.Para->ParaList[8] = DHCP4_TAG_DOMAINNAME; 280 OptEnt.Para->ParaList[9] = DHCP4_TAG_ROOTPATH; 281 OptEnt.Para->ParaList[10] = DHCP4_TAG_EXTEND_PATH; 282 OptEnt.Para->ParaList[11] = DHCP4_TAG_EMTU; 283 OptEnt.Para->ParaList[12] = DHCP4_TAG_TTL; 284 OptEnt.Para->ParaList[13] = DHCP4_TAG_BROADCAST; 285 OptEnt.Para->ParaList[14] = DHCP4_TAG_NIS_DOMAIN; 286 OptEnt.Para->ParaList[15] = DHCP4_TAG_NIS_SERVER; 287 OptEnt.Para->ParaList[16] = DHCP4_TAG_NTP_SERVER; 288 OptEnt.Para->ParaList[17] = DHCP4_TAG_VENDOR; 289 OptEnt.Para->ParaList[18] = DHCP4_TAG_REQUEST_IP; 290 OptEnt.Para->ParaList[19] = DHCP4_TAG_LEASE; 291 OptEnt.Para->ParaList[20] = DHCP4_TAG_SERVER_ID; 292 OptEnt.Para->ParaList[21] = DHCP4_TAG_T1; 293 OptEnt.Para->ParaList[22] = DHCP4_TAG_T2; 294 OptEnt.Para->ParaList[23] = DHCP4_TAG_VENDOR_CLASS_ID; 295 OptEnt.Para->ParaList[24] = DHCP4_TAG_TFTP; 296 OptEnt.Para->ParaList[25] = DHCP4_TAG_BOOTFILE; 297 OptEnt.Para->ParaList[26] = DHCP4_TAG_UUID; 298 298 OptEnt.Para->ParaList[27] = 0x80; 299 299 OptEnt.Para->ParaList[28] = 0x81; … … 310 310 // Append UUID/Guid-based client identifier option 311 311 // 312 OptList[Index]->OpCode = PXEBC_PXE_DHCP4_TAG_UUID;312 OptList[Index]->OpCode = DHCP4_TAG_UUID; 313 313 OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UUID); 314 314 OptEnt.Uuid = (PXEBC_DHCP4_OPTION_UUID *) OptList[Index]->Data; … … 321 321 // Zero the Guid to indicate NOT programable if failed to get system Guid. 322 322 // 323 DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios table!\n")); 323 324 ZeroMem (OptEnt.Uuid->Guid, sizeof (EFI_GUID)); 324 325 } … … 327 328 // Append client network device interface option 328 329 // 329 OptList[Index]->OpCode = PXEBC_PXE_DHCP4_TAG_UNDI;330 OptList[Index]->OpCode = DHCP4_TAG_UNDI; 330 331 OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UNDI); 331 332 OptEnt.Undi = (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]->Data; … … 347 348 // Append client system architecture option 348 349 // 349 OptList[Index]->OpCode = PXEBC_PXE_DHCP4_TAG_ARCH;350 OptList[Index]->OpCode = DHCP4_TAG_ARCH; 350 351 OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_ARCH); 351 352 OptEnt.Arch = (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]->Data; … … 358 359 // Append vendor class identify option 359 360 // 360 OptList[Index]->OpCode = PXEBC_DHCP4_TAG_CLASS_ID;361 OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID; 361 362 OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_CLID); 362 363 OptEnt.Clid = (PXEBC_DHCP4_OPTION_CLID *) OptList[Index]->Data; … … 415 416 416 417 Seed->Dhcp4.Magik = PXEBC_DHCP4_MAGIC; 417 Seed->Dhcp4.Option[0] = PXEBC_DHCP4_TAG_EOP;418 Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP; 418 419 } 419 420 … … 425 426 @param[in] Src Pointer to the DHCPv4 packet to be cached. 426 427 428 @retval EFI_SUCCESS Packet is copied. 429 @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold the packet. 430 427 431 **/ 428 VOID 432 EFI_STATUS 429 433 PxeBcCacheDhcp4Packet ( 430 434 IN EFI_DHCP4_PACKET *Dst, … … 432 436 ) 433 437 { 434 ASSERT (Dst->Size >= Src->Length); 438 if (Dst->Size < Src->Length) { 439 return EFI_BUFFER_TOO_SMALL; 440 } 435 441 436 442 CopyMem (&Dst->Dhcp4, &Src->Dhcp4, Src->Length); 437 443 Dst->Length = Src->Length; 444 445 return EFI_SUCCESS; 438 446 } 439 447 … … 461 469 BOOLEAN IsPxeOffer; 462 470 UINT8 *Ptr8; 471 BOOLEAN FileFieldOverloaded; 463 472 464 473 IsProxyOffer = FALSE; 465 474 IsPxeOffer = FALSE; 475 FileFieldOverloaded = FALSE; 466 476 467 477 ZeroMem (Cache4->OptList, sizeof (Cache4->OptList)); … … 489 499 if (Option != NULL) { 490 500 if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0) { 501 FileFieldOverloaded = TRUE; 491 502 for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { 492 503 if (Options[Index] == NULL) { … … 513 524 514 525 // 515 // The offer with "yiaddr" is a proxy offer.526 // The offer with zero "yiaddr" is a proxy offer. 516 527 // 517 528 if (Offer->Dhcp4.Header.YourAddr.Addr[0] == 0) { … … 551 562 *Ptr8 = '\0'; 552 563 } 553 } else if ( Offer->Dhcp4.Header.BootFileName[0] != 0) {564 } else if (!FileFieldOverloaded && Offer->Dhcp4.Header.BootFileName[0] != 0) { 554 565 // 555 566 // If the bootfile is not present and bootfilename is present in DHCPv4 packet, just parse it. … … 618 629 @param[in] Verified If TRUE, parse the ACK packet and store info into mode data. 619 630 631 @retval EFI_SUCCESS Cache and parse the packet successfully. 632 @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold the packet. 633 620 634 **/ 621 VOID 635 EFI_STATUS 622 636 PxeBcCopyDhcp4Ack ( 623 637 IN PXEBC_PRIVATE_DATA *Private, … … 627 641 { 628 642 EFI_PXE_BASE_CODE_MODE *Mode; 643 EFI_STATUS Status; 629 644 630 645 Mode = Private->PxeBc.Mode; 631 646 632 PxeBcCacheDhcp4Packet (&Private->DhcpAck.Dhcp4.Packet.Ack, Ack); 647 Status = PxeBcCacheDhcp4Packet (&Private->DhcpAck.Dhcp4.Packet.Ack, Ack); 648 if (EFI_ERROR (Status)) { 649 return Status; 650 } 633 651 634 652 if (Verified) { … … 640 658 Mode->DhcpAckReceived = TRUE; 641 659 } 660 661 return EFI_SUCCESS; 642 662 } 643 663 … … 649 669 @param[in] OfferIndex The received order of offer packets. 650 670 671 @retval EFI_SUCCESS Cache and parse the packet successfully. 672 @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold the packet. 673 651 674 **/ 652 VOID 675 EFI_STATUS 653 676 PxeBcCopyProxyOffer ( 654 677 IN PXEBC_PRIVATE_DATA *Private, … … 658 681 EFI_PXE_BASE_CODE_MODE *Mode; 659 682 EFI_DHCP4_PACKET *Offer; 683 EFI_STATUS Status; 660 684 661 685 ASSERT (OfferIndex < Private->OfferNum); … … 668 692 // Cache the proxy offer packet and parse it. 669 693 // 670 PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Offer); 694 Status = PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Offer); 695 if (EFI_ERROR(Status)) { 696 return Status; 697 } 698 671 699 PxeBcParseDhcp4Packet (&Private->ProxyOffer.Dhcp4); 672 700 … … 676 704 CopyMem (&Mode->ProxyOffer.Dhcpv4, &Offer->Dhcp4, Offer->Length); 677 705 Mode->ProxyOfferReceived = TRUE; 706 707 return EFI_SUCCESS; 678 708 } 679 709 … … 778 808 @param[in] RcvdOffer Pointer to the received offer packet. 779 809 810 @retval EFI_SUCCESS Cache and parse the packet successfully. 811 @retval Others Operation failed. 812 780 813 **/ 781 VOID 814 EFI_STATUS 782 815 PxeBcCacheDhcp4Offer ( 783 816 IN PXEBC_PRIVATE_DATA *Private, … … 788 821 EFI_DHCP4_PACKET *Offer; 789 822 PXEBC_OFFER_TYPE OfferType; 823 EFI_STATUS Status; 790 824 791 825 ASSERT (Private->OfferNum < PXEBC_OFFER_MAX_NUM); … … 796 830 // Cache the content of DHCPv4 packet firstly. 797 831 // 798 PxeBcCacheDhcp4Packet (Offer, RcvdOffer); 832 Status = PxeBcCacheDhcp4Packet (Offer, RcvdOffer); 833 if (EFI_ERROR(Status)) { 834 return Status; 835 } 799 836 800 837 // … … 802 839 // 803 840 if (EFI_ERROR (PxeBcParseDhcp4Packet (Cache4))) { 804 return ;841 return EFI_ABORTED; 805 842 } 806 843 … … 819 856 Private->OfferCount[OfferType] = 1; 820 857 } else { 821 return ;858 return EFI_ABORTED; 822 859 } 823 860 } else { … … 835 872 Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum; 836 873 Private->OfferCount[OfferType]++; 837 } else if (Private->OfferCount[OfferType] > 0) { 874 } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) && 875 Private->OfferCount[OfferType] < 1) { 838 876 // 839 877 // Only cache the first PXE10/WFM11a offer, and discard the others. … … 842 880 Private->OfferCount[OfferType] = 1; 843 881 } else { 844 return ;882 return EFI_ABORTED; 845 883 } 846 884 } else { … … 854 892 855 893 Private->OfferNum++; 894 895 return EFI_SUCCESS; 856 896 } 857 897 … … 978 1018 Handle the DHCPv4 offer packet. 979 1019 980 @param[in] Private Pointer to PxeBc private data. 981 982 @retval EFI_SUCCESS Handled the DHCPv4 offer packet successfully. 983 @retval EFI_NO_RESPONSE No response to the following request packet. 984 @retval EFI_NOT_FOUND No boot filename received. 1020 @param[in] Private Pointer to PxeBc private data. 1021 1022 @retval EFI_SUCCESS Handled the DHCPv4 offer packet successfully. 1023 @retval EFI_NO_RESPONSE No response to the following request packet. 1024 @retval EFI_NOT_FOUND No boot filename received. 1025 @retval EFI_BUFFER_TOO_SMALL Can't cache the offer pacet. 985 1026 986 1027 **/ … … 1087 1128 // Success to try to request by a ProxyPxe10 or ProxyWfm11a offer, copy and parse it. 1088 1129 // 1089 PxeBcCopyProxyOffer (Private, ProxyIndex);1130 Status = PxeBcCopyProxyOffer (Private, ProxyIndex); 1090 1131 } 1091 1132 } else { … … 1114 1155 } 1115 1156 1116 PxeBcCopyDhcp4Ack (Private, Ack, TRUE); 1157 Status = PxeBcCopyDhcp4Ack (Private, Ack, TRUE); 1158 if (EFI_ERROR (Status)) { 1159 return Status; 1160 } 1117 1161 Mode->DhcpDiscoverValid = TRUE; 1118 1162 } … … 1168 1212 } 1169 1213 1214 ASSERT (Packet != NULL); 1215 1170 1216 Private = (PXEBC_PRIVATE_DATA *) Context; 1171 1217 Mode = Private->PxeBc.Mode; … … 1178 1224 Packet->Dhcp4.Option, 1179 1225 GET_OPTION_BUFFER_LEN (Packet), 1180 PXEBC_DHCP4_TAG_MAXMSG1226 DHCP4_TAG_MAXMSG 1181 1227 ); 1182 1228 if (MaxMsgSize != NULL) { 1183 Value = HTONS (PXEBC_DHCP4_PACKET_MAX_SIZE - 8);1229 Value = HTONS (PXEBC_DHCP4_PACKET_MAX_SIZE); 1184 1230 CopyMem (MaxMsgSize->Data, &Value, sizeof (Value)); 1185 1231 } … … 1207 1253 1208 1254 case Dhcp4SendDiscover: 1255 if (Packet->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) { 1256 // 1257 // If the to be sent packet exceeds the maximum length, abort the DHCP process. 1258 // 1259 Status = EFI_ABORTED; 1260 break; 1261 } 1262 1209 1263 // 1210 1264 // Cache the DHCPv4 discover packet to mode data directly. … … 1214 1268 1215 1269 case Dhcp4SendRequest: 1270 if (Packet->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) { 1271 // 1272 // If the to be sent packet exceeds the maximum length, abort the DHCP process. 1273 // 1274 Status = EFI_ABORTED; 1275 break; 1276 } 1277 1216 1278 if (Mode->SendGUID) { 1217 1279 // … … 1222 1284 // Zero the Guid to indicate NOT programable if failed to get system Guid. 1223 1285 // 1286 DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios table!\n")); 1224 1287 ZeroMem (Packet->Dhcp4.Header.ClientHwAddr, sizeof (EFI_GUID)); 1225 1288 } … … 1230 1293 case Dhcp4RcvdOffer: 1231 1294 Status = EFI_NOT_READY; 1295 if (Packet->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) { 1296 // 1297 // Ignore the incoming packets which exceed the maximum length. 1298 // 1299 break; 1300 } 1232 1301 if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) { 1233 1302 // 1234 1303 // Cache the DHCPv4 offers to OfferBuffer[] for select later, and record 1235 1304 // the OfferIndex and OfferCount. 1305 // If error happens, just ignore this packet and continue to wait more offer. 1236 1306 // 1237 1307 PxeBcCacheDhcp4Offer (Private, Packet); … … 1240 1310 1241 1311 case Dhcp4SelectOffer: 1312 ASSERT (NewPacket != NULL); 1313 1242 1314 // 1243 1315 // Select offer by the default policy or by order, and record the SelectIndex … … 1260 1332 ASSERT (Private->SelectIndex != 0); 1261 1333 1262 PxeBcCopyDhcp4Ack (Private, Packet, FALSE); 1334 Status = PxeBcCopyDhcp4Ack (Private, Packet, FALSE); 1335 if (EFI_ERROR (Status)) { 1336 Status = EFI_ABORTED; 1337 } 1263 1338 break; 1264 1339 … … 1354 1429 } 1355 1430 1356 OptList[OptCount]->OpCode = PXEBC_DHCP4_TAG_VENDOR;1431 OptList[OptCount]->OpCode = DHCP4_TAG_VENDOR; 1357 1432 OptList[OptCount]->Length = (UINT8) (VendorOptLen - 2); 1358 1433 PxeOpt = (EFI_DHCP4_PACKET_OPTION *) OptList[OptCount]->Data; … … 1361 1436 PxeBootItem = (PXEBC_OPTION_BOOT_ITEM *) PxeOpt->Data; 1362 1437 PxeBootItem->Type = HTONS (Type); 1363 PxeOpt->Data[PxeOpt->Length] = PXEBC_DHCP4_TAG_EOP;1438 PxeOpt->Data[PxeOpt->Length] = DHCP4_TAG_EOP; 1364 1439 1365 1440 if (Layer != NULL) { … … 1398 1473 // Zero the Guid to indicate NOT programable if failed to get system Guid. 1399 1474 // 1475 DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios table!\n")); 1400 1476 ZeroMem (Token.Packet->Dhcp4.Header.ClientHwAddr, sizeof (EFI_GUID)); 1401 1477 } … … 1459 1535 // 1460 1536 while (RepIndex < Token.ResponseCount) { 1537 if (Response->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) { 1538 SrvIndex = 0; 1539 RepIndex++; 1540 Response = (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response->Size); 1541 continue; 1542 } 1461 1543 1462 1544 while (SrvIndex < IpCount) { … … 1477 1559 SrvIndex = 0; 1478 1560 RepIndex++; 1479 1480 1561 Response = (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response->Size); 1481 1562 } … … 1487 1568 // 1488 1569 if (Private->IsDoDiscover) { 1489 PxeBcCacheDhcp4Packet (&Private->PxeReply.Dhcp4.Packet.Ack, Response); 1570 Status = PxeBcCacheDhcp4Packet (&Private->PxeReply.Dhcp4.Packet.Ack, Response); 1571 if (EFI_ERROR(Status)) { 1572 goto ON_EXIT; 1573 } 1490 1574 CopyMem (&Mode->PxeDiscover, &Token.Packet->Dhcp4, Token.Packet->Length); 1491 1575 } else { 1492 PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Response); 1576 Status = PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Response); 1577 if (EFI_ERROR(Status)) { 1578 goto ON_EXIT; 1579 } 1493 1580 } 1494 1581 } else { … … 1498 1585 Status = EFI_NOT_FOUND; 1499 1586 } 1500 if (Token.ResponseList != NULL) { 1501 FreePool (Token.ResponseList); 1502 } 1503 } 1504 1505 FreePool (Token.Packet); 1587 } 1588 ON_EXIT: 1589 1590 if (Token.ResponseList != NULL) { 1591 FreePool (Token.ResponseList); 1592 } 1593 if (Token.Packet != NULL) { 1594 FreePool (Token.Packet); 1595 } 1506 1596 return Status; 1507 1597 } 1508 1598 1599 /** 1600 Switch the Ip4 policy to static. 1601 1602 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 1603 1604 @retval EFI_SUCCESS The policy is already configured to static. 1605 @retval Others Other error as indicated.. 1606 1607 **/ 1608 EFI_STATUS 1609 PxeBcSetIp4Policy ( 1610 IN PXEBC_PRIVATE_DATA *Private 1611 ) 1612 { 1613 EFI_STATUS Status; 1614 EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; 1615 EFI_IP4_CONFIG2_POLICY Policy; 1616 UINTN DataSize; 1617 1618 Ip4Config2 = Private->Ip4Config2; 1619 DataSize = sizeof (EFI_IP4_CONFIG2_POLICY); 1620 Status = Ip4Config2->GetData ( 1621 Ip4Config2, 1622 Ip4Config2DataTypePolicy, 1623 &DataSize, 1624 &Policy 1625 ); 1626 if (EFI_ERROR (Status)) { 1627 return Status; 1628 } 1629 1630 if (Policy != Ip4Config2PolicyStatic) { 1631 Policy = Ip4Config2PolicyStatic; 1632 Status= Ip4Config2->SetData ( 1633 Ip4Config2, 1634 Ip4Config2DataTypePolicy, 1635 sizeof (EFI_IP4_CONFIG2_POLICY), 1636 &Policy 1637 ); 1638 if (EFI_ERROR (Status)) { 1639 return Status; 1640 } 1641 } 1642 1643 return EFI_SUCCESS; 1644 } 1509 1645 1510 1646 /** … … 1569 1705 ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex)); 1570 1706 1571 //1572 // Start DHCPv4 D.O.R.A. process to acquire IPv4 address.1573 //1574 1707 Status = Dhcp4->Start (Dhcp4, NULL); 1575 1708 if (EFI_ERROR (Status)) { … … 1577 1710 PxeMode->IcmpErrorReceived = TRUE; 1578 1711 } 1712 1713 if (Status == EFI_TIMEOUT && Private->OfferNum > 0) { 1714 Status = EFI_NO_RESPONSE; 1715 } 1716 1579 1717 goto ON_EXIT; 1580 1718 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.h
r58466 r77662 2 2 Functions declaration related with DHCPv4 for UefiPxeBc Driver. 3 3 4 Copyright (c) 2009 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 19 19 #define PXEBC_DHCP4_OPTION_MAX_NUM 16 20 20 #define PXEBC_DHCP4_OPTION_MAX_SIZE 312 21 #define PXEBC_DHCP4_PACKET_MAX_SIZE 147221 #define PXEBC_DHCP4_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET)) 22 22 #define PXEBC_DHCP4_S_PORT 67 23 23 #define PXEBC_DHCP4_C_PORT 68 … … 29 29 #define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order 30 30 31 //32 // Dhcp Options33 //34 #define PXEBC_DHCP4_TAG_PAD 0 // Pad Option35 #define PXEBC_DHCP4_TAG_EOP 255 // End Option36 #define PXEBC_DHCP4_TAG_NETMASK 1 // Subnet Mask37 #define PXEBC_DHCP4_TAG_TIME_OFFSET 2 // Time Offset from UTC38 #define PXEBC_DHCP4_TAG_ROUTER 3 // Router option,39 #define PXEBC_DHCP4_TAG_TIME_SERVER 4 // Time Server40 #define PXEBC_DHCP4_TAG_NAME_SERVER 5 // Name Server41 #define PXEBC_DHCP4_TAG_DNS_SERVER 6 // Domain Name Server42 #define PXEBC_DHCP4_TAG_HOSTNAME 12 // Host Name43 #define PXEBC_DHCP4_TAG_BOOTFILE_LEN 13 // Boot File Size44 #define PXEBC_DHCP4_TAG_DUMP 14 // Merit Dump File45 #define PXEBC_DHCP4_TAG_DOMAINNAME 15 // Domain Name46 #define PXEBC_DHCP4_TAG_ROOTPATH 17 // Root path47 #define PXEBC_DHCP4_TAG_EXTEND_PATH 18 // Extensions Path48 #define PXEBC_DHCP4_TAG_EMTU 22 // Maximum Datagram Reassembly Size49 #define PXEBC_DHCP4_TAG_TTL 23 // Default IP Time-to-live50 #define PXEBC_DHCP4_TAG_BROADCAST 28 // Broadcast Address51 #define PXEBC_DHCP4_TAG_NIS_DOMAIN 40 // Network Information Service Domain52 #define PXEBC_DHCP4_TAG_NIS_SERVER 41 // Network Information Servers53 #define PXEBC_DHCP4_TAG_NTP_SERVER 42 // Network Time Protocol Servers54 #define PXEBC_DHCP4_TAG_VENDOR 43 // Vendor Specific Information55 #define PXEBC_DHCP4_TAG_REQUEST_IP 50 // Requested IP Address56 #define PXEBC_DHCP4_TAG_LEASE 51 // IP Address Lease Time57 #define PXEBC_DHCP4_TAG_OVERLOAD 52 // Option Overload58 #define PXEBC_DHCP4_TAG_MSG_TYPE 53 // DHCP Message Type59 #define PXEBC_DHCP4_TAG_SERVER_ID 54 // Server Identifier60 #define PXEBC_DHCP4_TAG_PARA_LIST 55 // Parameter Request List61 #define PXEBC_DHCP4_TAG_MAXMSG 57 // Maximum DHCP Message Size62 #define PXEBC_DHCP4_TAG_T1 58 // Renewal (T1) Time Value63 #define PXEBC_DHCP4_TAG_T2 59 // Rebinding (T2) Time Value64 #define PXEBC_DHCP4_TAG_CLASS_ID 60 // Vendor class identifier65 #define PXEBC_DHCP4_TAG_CLIENT_ID 61 // Client-identifier66 #define PXEBC_DHCP4_TAG_TFTP 66 // TFTP server name67 #define PXEBC_DHCP4_TAG_BOOTFILE 67 // Bootfile name68 #define PXEBC_PXE_DHCP4_TAG_ARCH 9369 #define PXEBC_PXE_DHCP4_TAG_UNDI 9470 #define PXEBC_PXE_DHCP4_TAG_UUID 9771 31 // 72 32 // Sub-Options in Dhcp Vendor Option … … 304 264 } PXEBC_VENDOR_OPTION; 305 265 266 #define PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + PXEBC_DHCP4_PACKET_MAX_SIZE) 267 306 268 typedef union { 307 269 EFI_DHCP4_PACKET Offer; 308 270 EFI_DHCP4_PACKET Ack; 309 UINT8 Buffer[PXEBC_ DHCP4_PACKET_MAX_SIZE];271 UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE]; 310 272 } PXEBC_DHCP4_PACKET; 311 273 … … 375 337 ); 376 338 339 /** 340 Switch the Ip4 policy to static. 341 342 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 343 344 @retval EFI_SUCCESS The policy is already configured to static. 345 @retval Others Other error as indicated.. 346 347 **/ 348 EFI_STATUS 349 PxeBcSetIp4Policy ( 350 IN PXEBC_PRIVATE_DATA *Private 351 ); 352 377 353 378 354 /** -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
r58466 r77662 2 2 Functions implementation related with DHCPv6 for UefiPxeBc Driver. 3 3 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 92 93 // Append client option request option 93 94 // 94 OptList[Index]->OpCode = HTONS ( PXEBC_DHCP6_OPT_ORO);95 OptList[Index]->OpLen = HTONS ( 4);95 OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO); 96 OptList[Index]->OpLen = HTONS (8); 96 97 OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data; 97 OptEnt.Oro->OpCode[0] = HTONS(PXEBC_DHCP6_OPT_BOOT_FILE_URL); 98 OptEnt.Oro->OpCode[1] = HTONS(PXEBC_DHCP6_OPT_BOOT_FILE_PARAM); 98 OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL); 99 OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM); 100 OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS); 101 OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS); 99 102 Index++; 100 103 OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); … … 103 106 // Append client network device interface option 104 107 // 105 OptList[Index]->OpCode = HTONS ( PXEBC_DHCP6_OPT_UNDI);108 OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI); 106 109 OptList[Index]->OpLen = HTONS ((UINT16)3); 107 110 OptEnt.Undi = (PXEBC_DHCP6_OPTION_UNDI *) OptList[Index]->Data; … … 123 126 // Append client system architecture option 124 127 // 125 OptList[Index]->OpCode = HTONS ( PXEBC_DHCP6_OPT_ARCH);128 OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH); 126 129 OptList[Index]->OpLen = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_ARCH)); 127 130 OptEnt.Arch = (PXEBC_DHCP6_OPTION_ARCH *) OptList[Index]->Data; … … 134 137 // Append vendor class option to store the PXE class identifier. 135 138 // 136 OptList[Index]->OpCode = HTONS ( PXEBC_DHCP6_OPT_VENDOR_CLASS);139 OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS); 137 140 OptList[Index]->OpLen = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_VENDOR_CLASS)); 138 141 OptEnt.VendorClass = (PXEBC_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data; … … 180 183 @param[in] Src The pointer to the DHCPv6 packet to be cached. 181 184 182 **/ 183 VOID 185 @retval EFI_SUCCESS Packet is copied. 186 @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold the packet. 187 188 **/ 189 EFI_STATUS 184 190 PxeBcCacheDhcp6Packet ( 185 191 IN EFI_DHCP6_PACKET *Dst, … … 187 193 ) 188 194 { 189 ASSERT (Dst->Size >= Src->Length); 195 if (Dst->Size < Src->Length) { 196 return EFI_BUFFER_TOO_SMALL; 197 } 190 198 191 199 CopyMem (&Dst->Dhcp6, &Src->Dhcp6, Src->Length); 192 200 Dst->Length = Src->Length; 201 202 return EFI_SUCCESS; 193 203 } 194 204 … … 216 226 } 217 227 228 /** 229 Retrieve the boot server address using the EFI_DNS6_PROTOCOL. 230 231 @param[in] Private Pointer to PxeBc private data. 232 @param[in] HostName Pointer to buffer containing hostname. 233 @param[out] IpAddress On output, pointer to buffer containing IPv6 address. 234 235 @retval EFI_SUCCESS Operation succeeded. 236 @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources. 237 @retval EFI_DEVICE_ERROR An unexpected network error occurred. 238 @retval Others Other errors as indicated. 239 240 **/ 241 EFI_STATUS 242 PxeBcDns6 ( 243 IN PXEBC_PRIVATE_DATA *Private, 244 IN CHAR16 *HostName, 245 OUT EFI_IPv6_ADDRESS *IpAddress 246 ) 247 { 248 EFI_STATUS Status; 249 EFI_DNS6_PROTOCOL *Dns6; 250 EFI_DNS6_CONFIG_DATA Dns6ConfigData; 251 EFI_DNS6_COMPLETION_TOKEN Token; 252 EFI_HANDLE Dns6Handle; 253 EFI_IPv6_ADDRESS *DnsServerList; 254 BOOLEAN IsDone; 255 256 Dns6 = NULL; 257 Dns6Handle = NULL; 258 DnsServerList = Private->DnsServer; 259 ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN)); 260 261 // 262 // Create a DNSv6 child instance and get the protocol. 263 // 264 Status = NetLibCreateServiceChild ( 265 Private->Controller, 266 Private->Image, 267 &gEfiDns6ServiceBindingProtocolGuid, 268 &Dns6Handle 269 ); 270 if (EFI_ERROR (Status)) { 271 goto Exit; 272 } 273 274 Status = gBS->OpenProtocol ( 275 Dns6Handle, 276 &gEfiDns6ProtocolGuid, 277 (VOID **) &Dns6, 278 Private->Image, 279 Private->Controller, 280 EFI_OPEN_PROTOCOL_BY_DRIVER 281 ); 282 if (EFI_ERROR (Status)) { 283 goto Exit; 284 } 285 286 // 287 // Configure DNS6 instance for the DNS server address and protocol. 288 // 289 ZeroMem (&Dns6ConfigData, sizeof (EFI_DNS6_CONFIG_DATA)); 290 Dns6ConfigData.DnsServerCount = 1; 291 Dns6ConfigData.DnsServerList = DnsServerList; 292 Dns6ConfigData.EnableDnsCache = TRUE; 293 Dns6ConfigData.Protocol = EFI_IP_PROTO_UDP; 294 IP6_COPY_ADDRESS (&Dns6ConfigData.StationIp, &Private->TmpStationIp.v6); 295 Status = Dns6->Configure ( 296 Dns6, 297 &Dns6ConfigData 298 ); 299 if (EFI_ERROR (Status)) { 300 goto Exit; 301 } 302 303 Token.Status = EFI_NOT_READY; 304 IsDone = FALSE; 305 // 306 // Create event to set the IsDone flag when name resolution is finished. 307 // 308 Status = gBS->CreateEvent ( 309 EVT_NOTIFY_SIGNAL, 310 TPL_NOTIFY, 311 PxeBcCommonNotify, 312 &IsDone, 313 &Token.Event 314 ); 315 if (EFI_ERROR (Status)) { 316 goto Exit; 317 } 318 319 // 320 // Start asynchronous name resolution. 321 // 322 Status = Dns6->HostNameToIp (Dns6, HostName, &Token); 323 if (EFI_ERROR (Status)) { 324 goto Exit; 325 } 326 327 while (!IsDone) { 328 Dns6->Poll (Dns6); 329 } 330 331 // 332 // Name resolution is done, check result. 333 // 334 Status = Token.Status; 335 if (!EFI_ERROR (Status)) { 336 if (Token.RspData.H2AData == NULL) { 337 Status = EFI_DEVICE_ERROR; 338 goto Exit; 339 } 340 if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) { 341 Status = EFI_DEVICE_ERROR; 342 goto Exit; 343 } 344 // 345 // We just return the first IPv6 address from DNS protocol. 346 // 347 IP6_COPY_ADDRESS (IpAddress, Token.RspData.H2AData->IpList); 348 Status = EFI_SUCCESS; 349 } 350 351 Exit: 352 FreePool (HostName); 353 354 if (Token.Event != NULL) { 355 gBS->CloseEvent (Token.Event); 356 } 357 if (Token.RspData.H2AData != NULL) { 358 if (Token.RspData.H2AData->IpList != NULL) { 359 FreePool (Token.RspData.H2AData->IpList); 360 } 361 FreePool (Token.RspData.H2AData); 362 } 363 364 if (Dns6 != NULL) { 365 Dns6->Configure (Dns6, NULL); 366 367 gBS->CloseProtocol ( 368 Dns6Handle, 369 &gEfiDns6ProtocolGuid, 370 Private->Image, 371 Private->Controller 372 ); 373 } 374 375 if (Dns6Handle != NULL) { 376 NetLibDestroyServiceChild ( 377 Private->Controller, 378 Private->Image, 379 &gEfiDns6ServiceBindingProtocolGuid, 380 Dns6Handle 381 ); 382 } 383 384 if (DnsServerList != NULL) { 385 FreePool (DnsServerList); 386 } 387 388 return Status; 389 } 218 390 219 391 /** 220 392 Parse the Boot File URL option. 221 393 394 @param[in] Private Pointer to PxeBc private data. 222 395 @param[out] FileName The pointer to the boot file name. 223 396 @param[in, out] SrvAddr The pointer to the boot server address. … … 232 405 EFI_STATUS 233 406 PxeBcExtractBootFileUrl ( 407 IN PXEBC_PRIVATE_DATA *Private, 234 408 OUT UINT8 **FileName, 235 409 IN OUT EFI_IPv6_ADDRESS *SrvAddr, … … 247 421 CHAR8 *ServerAddress; 248 422 CHAR8 *ModeStr; 423 CHAR16 *HostName; 424 BOOLEAN IpExpressedUrl; 425 UINTN Len; 249 426 EFI_STATUS Status; 250 427 428 IpExpressedUrl = TRUE; 251 429 // 252 430 // The format of the Boot File URL option is: … … 264 442 265 443 // 266 // Based upon RFC 5970 and UEFI 2. 3 Errata D specification, bootfile-url format267 // is tftp://[SERVER_ADDRESS]/BOOTFILE_NAME444 // Based upon RFC 5970 and UEFI 2.6, bootfile-url format can be 445 // tftp://[SERVER_ADDRESS]/BOOTFILE_NAME or tftp://domain_name/BOOTFILE_NAME 268 446 // As an example where the BOOTFILE_NAME is the EFI loader and 269 447 // SERVER_ADDRESS is the ASCII encoding of an IPV6 address. … … 291 469 // 292 470 ServerAddressOption = TmpStr; 293 if (*ServerAddressOption != PXEBC_ADDR_START_DELIMITER) { 294 FreePool (TmpStr); 295 return EFI_INVALID_PARAMETER; 296 } 297 298 ServerAddressOption ++; 299 ServerAddress = ServerAddressOption; 300 while (*ServerAddress != '\0' && *ServerAddress != PXEBC_ADDR_END_DELIMITER) { 301 ServerAddress++; 302 } 303 304 if (*ServerAddress != PXEBC_ADDR_END_DELIMITER) { 305 FreePool (TmpStr); 306 return EFI_INVALID_PARAMETER; 307 } 308 309 *ServerAddress = '\0'; 310 311 // 312 // Convert the string of server address to Ipv6 address format and store it. 313 // 314 Status = NetLibAsciiStrToIp6 (ServerAddressOption, SrvAddr); 315 if (EFI_ERROR (Status)) { 316 FreePool (TmpStr); 317 return Status; 471 if (*ServerAddressOption == PXEBC_ADDR_START_DELIMITER) { 472 ServerAddressOption ++; 473 ServerAddress = ServerAddressOption; 474 while (*ServerAddress != '\0' && *ServerAddress != PXEBC_ADDR_END_DELIMITER) { 475 ServerAddress++; 476 } 477 478 if (*ServerAddress != PXEBC_ADDR_END_DELIMITER) { 479 FreePool (TmpStr); 480 return EFI_INVALID_PARAMETER; 481 } 482 483 *ServerAddress = '\0'; 484 485 // 486 // Convert the string of server address to Ipv6 address format and store it. 487 // 488 Status = NetLibAsciiStrToIp6 (ServerAddressOption, SrvAddr); 489 if (EFI_ERROR (Status)) { 490 FreePool (TmpStr); 491 return Status; 492 } 493 494 } else { 495 IpExpressedUrl = FALSE; 496 ServerAddress = ServerAddressOption; 497 while (*ServerAddress != '\0' && *ServerAddress != PXEBC_TFTP_URL_SEPARATOR) { 498 ServerAddress++; 499 } 500 501 if (*ServerAddress != PXEBC_TFTP_URL_SEPARATOR) { 502 FreePool (TmpStr); 503 return EFI_INVALID_PARAMETER; 504 } 505 *ServerAddress = '\0'; 506 507 Len = AsciiStrSize (ServerAddressOption); 508 HostName = AllocateZeroPool (Len * sizeof (CHAR16)); 509 if (HostName == NULL) { 510 FreePool (TmpStr); 511 return EFI_OUT_OF_RESOURCES; 512 } 513 AsciiStrToUnicodeStrS ( 514 ServerAddressOption, 515 HostName, 516 Len 517 ); 518 519 // 520 // Perform DNS resolution. 521 // 522 Status = PxeBcDns6 (Private,HostName, SrvAddr); 523 if (EFI_ERROR (Status)) { 524 FreePool (TmpStr); 525 return Status; 526 } 318 527 } 319 528 … … 322 531 // 323 532 BootFileNamePtr = (CHAR8*)((UINTN)ServerAddress + 1); 324 if (*BootFileNamePtr != PXEBC_TFTP_URL_SEPARATOR) { 325 FreePool (TmpStr); 326 return EFI_INVALID_PARAMETER; 327 } 328 329 ++BootFileNamePtr; 533 if (IpExpressedUrl) { 534 if (*BootFileNamePtr != PXEBC_TFTP_URL_SEPARATOR) { 535 FreePool (TmpStr); 536 return EFI_INVALID_PARAMETER; 537 } 538 ++BootFileNamePtr; 539 } 540 330 541 BootFileNameLen = (UINT16)(Length - (UINT16) ((UINTN)BootFileNamePtr - (UINTN)TmpStr) + 1); 331 542 if (BootFileNameLen != 0 || FileName != NULL) { … … 338 549 *ModeStr = '\0'; 339 550 } else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) { 551 FreePool (TmpStr); 340 552 return EFI_INVALID_PARAMETER; 341 553 } … … 471 683 while (Offset < Length) { 472 684 473 if (NTOHS (Option->OpCode) == PXEBC_DHCP6_OPT_IA_NA) {685 if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) { 474 686 Options[PXEBC_DHCP6_IDX_IA_NA] = Option; 475 } else if (NTOHS (Option->OpCode) == PXEBC_DHCP6_OPT_BOOT_FILE_URL) {687 } else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) { 476 688 // 477 689 // The server sends this option to inform the client about an URL to a boot file. 478 690 // 479 691 Options[PXEBC_DHCP6_IDX_BOOT_FILE_URL] = Option; 480 } else if (NTOHS (Option->OpCode) == PXEBC_DHCP6_OPT_BOOT_FILE_PARAM) {692 } else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_PARAM) { 481 693 Options[PXEBC_DHCP6_IDX_BOOT_FILE_PARAM] = Option; 482 } else if (NTOHS (Option->OpCode) == PXEBC_DHCP6_OPT_VENDOR_CLASS) {694 } else if (NTOHS (Option->OpCode) == DHCP6_OPT_VENDOR_CLASS) { 483 695 Options[PXEBC_DHCP6_IDX_VENDOR_CLASS] = Option; 696 } else if (NTOHS (Option->OpCode) == DHCP6_OPT_DNS_SERVERS) { 697 Options[PXEBC_DHCP6_IDX_DNS_SERVER] = Option; 484 698 } 485 699 … … 489 703 490 704 // 491 // The offer with assigned client address is a proxy offer.705 // The offer with assigned client address is NOT a proxy offer. 492 706 // An ia_na option, embeded with valid ia_addr option and a status_code of success. 493 707 // … … 497 711 Option->Data + 12, 498 712 NTOHS (Option->OpLen), 499 PXEBC_DHCP6_OPT_STATUS_CODE713 DHCP6_OPT_STATUS_CODE 500 714 ); 501 715 if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) { … … 545 759 @param[in] Verified If TRUE, parse the ACK packet and store info into mode data. 546 760 547 **/ 548 VOID 761 @retval EFI_SUCCESS Cache and parse the packet successfully. 762 @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold the packet. 763 764 **/ 765 EFI_STATUS 549 766 PxeBcCopyDhcp6Ack ( 550 767 IN PXEBC_PRIVATE_DATA *Private, … … 554 771 { 555 772 EFI_PXE_BASE_CODE_MODE *Mode; 773 EFI_STATUS Status; 556 774 557 775 Mode = Private->PxeBc.Mode; 558 776 559 PxeBcCacheDhcp6Packet (&Private->DhcpAck.Dhcp6.Packet.Ack, Ack); 777 Status = PxeBcCacheDhcp6Packet (&Private->DhcpAck.Dhcp6.Packet.Ack, Ack); 778 if (EFI_ERROR (Status)) { 779 return Status; 780 } 560 781 561 782 if (Verified) { … … 567 788 Mode->DhcpAckReceived = TRUE; 568 789 } 790 791 return EFI_SUCCESS; 569 792 } 570 793 … … 576 799 @param[in] OfferIndex The received order of offer packets. 577 800 578 **/ 579 VOID 801 @retval EFI_SUCCESS Cache and parse the packet successfully. 802 @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold the packet. 803 804 **/ 805 EFI_STATUS 580 806 PxeBcCopyDhcp6Proxy ( 581 807 IN PXEBC_PRIVATE_DATA *Private, … … 585 811 EFI_PXE_BASE_CODE_MODE *Mode; 586 812 EFI_DHCP6_PACKET *Offer; 813 EFI_STATUS Status; 587 814 588 815 ASSERT (OfferIndex < Private->OfferNum); … … 595 822 // Cache the proxy offer packet and parse it. 596 823 // 597 PxeBcCacheDhcp6Packet (&Private->ProxyOffer.Dhcp6.Packet.Offer, Offer); 824 Status = PxeBcCacheDhcp6Packet (&Private->ProxyOffer.Dhcp6.Packet.Offer, Offer); 825 if (EFI_ERROR(Status)) { 826 return Status; 827 } 598 828 PxeBcParseDhcp6Packet (&Private->ProxyOffer.Dhcp6); 599 829 … … 603 833 CopyMem (&Mode->ProxyOffer.Dhcpv6, &Offer->Dhcp6, Offer->Length); 604 834 Mode->ProxyOfferReceived = TRUE; 835 836 return EFI_SUCCESS; 605 837 } 606 838 … … 665 897 EFI_PXE_BASE_CODE_UDP_PORT SrcPort; 666 898 EFI_PXE_BASE_CODE_UDP_PORT DestPort; 667 EFI_PXE_BASE_CODE_MODE *Mode;668 899 EFI_PXE_BASE_CODE_PROTOCOL *PxeBc; 669 900 EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover; … … 679 910 UINT16 OpLen; 680 911 EFI_STATUS Status; 681 EFI_DHCP6_PACKET * ProxyOffer;912 EFI_DHCP6_PACKET *IndexOffer; 682 913 UINT8 *Option; 683 914 684 915 PxeBc = &Private->PxeBc; 685 Mode = PxeBc->Mode;686 916 Request = Private->Dhcp6Request; 687 ProxyOffer= &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;917 IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer; 688 918 SrcPort = PXEBC_BS_DISCOVER_PORT; 689 919 DestPort = PXEBC_BS_DISCOVER_PORT; … … 702 932 // Build the request packet by the cached request packet before. 703 933 // 704 Discover->TransactionId = ProxyOffer->Dhcp6.Header.TransactionId;934 Discover->TransactionId = IndexOffer->Dhcp6.Header.TransactionId; 705 935 Discover->MessageType = Request->Dhcp6.Header.MessageType; 706 936 RequestOpt = Request->Dhcp6.Option; … … 712 942 // Find Server ID Option from ProxyOffer. 713 943 // 714 Option = PxeBcDhcp6SeekOption ( 715 ProxyOffer->Dhcp6.Option, 716 ProxyOffer->Length - 4, 717 PXEBC_DHCP6_OPT_SERVER_ID 718 ); 719 if (Option == NULL) { 720 return EFI_NOT_FOUND; 721 } 722 723 // 724 // Add Server ID Option. 725 // 726 OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen); 727 CopyMem (DiscoverOpt, Option, OpLen + 4); 728 DiscoverOpt += (OpLen + 4); 729 DiscoverLen += (OpLen + 4); 944 if (Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl) { 945 Option = PxeBcDhcp6SeekOption ( 946 IndexOffer->Dhcp6.Option, 947 IndexOffer->Length - 4, 948 DHCP6_OPT_SERVER_ID 949 ); 950 if (Option == NULL) { 951 return EFI_NOT_FOUND; 952 } 953 954 // 955 // Add Server ID Option. 956 // 957 OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen); 958 CopyMem (DiscoverOpt, Option, OpLen + 4); 959 DiscoverOpt += (OpLen + 4); 960 DiscoverLen += (OpLen + 4); 961 } 730 962 731 963 while (RequestLen < Request->Length) { … … 734 966 if (OpCode != EFI_DHCP6_IA_TYPE_NA && 735 967 OpCode != EFI_DHCP6_IA_TYPE_TA && 736 OpCode != PXEBC_DHCP6_OPT_SERVER_ID968 OpCode != DHCP6_OPT_SERVER_ID 737 969 ) { 738 970 // … … 753 985 Discover->DhcpOptions, 754 986 (UINT32)(RequestLen - 4), 755 PXEBC_DHCP6_OPT_ELAPSED_TIME987 DHCP6_OPT_ELAPSED_TIME 756 988 ); 757 989 if (Option != NULL) { … … 775 1007 776 1008 if (EFI_ERROR (Status)) { 777 return Status;1009 goto ON_ERROR; 778 1010 } 779 1011 … … 790 1022 Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData); 791 1023 if (EFI_ERROR (Status)) { 792 return Status;1024 goto ON_ERROR; 793 1025 } 794 1026 795 1027 Status = PxeBc->UdpRead ( 796 1028 PxeBc, 797 EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP ,798 &Private->StationIp,1029 EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP | EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP, 1030 NULL, 799 1031 &SrcPort, 800 1032 &Private->ServerIp, … … 811 1043 812 1044 if (EFI_ERROR (Status)) { 813 return Status;1045 goto ON_ERROR; 814 1046 } 815 1047 … … 820 1052 821 1053 return EFI_SUCCESS; 1054 1055 ON_ERROR: 1056 if (Discover != NULL) { 1057 FreePool (Discover); 1058 } 1059 1060 return Status; 822 1061 } 823 1062 … … 851 1090 Private->IsDoDiscover = FALSE; 852 1091 Offer = &Private->OfferBuffer[Index].Dhcp6; 853 if (Offer->O fferType == PxeOfferTypeDhcpBinl) {1092 if (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) { 854 1093 // 855 1094 // There is no BootFileUrl option in dhcp6 offer, so use servers multi-cast address instead. … … 866 1105 // 867 1106 Status = PxeBcExtractBootFileUrl ( 1107 Private, 868 1108 &Private->BootFileName, 869 1109 &Private->ServerIp.v6, … … 918 1158 @param[in] RcvdOffer The pointer to the received offer packet. 919 1159 920 **/ 921 VOID 1160 @retval EFI_SUCCESS Cache and parse the packet successfully. 1161 @retval Others Operation failed. 1162 **/ 1163 EFI_STATUS 922 1164 PxeBcCacheDhcp6Offer ( 923 1165 IN PXEBC_PRIVATE_DATA *Private, … … 928 1170 EFI_DHCP6_PACKET *Offer; 929 1171 PXEBC_OFFER_TYPE OfferType; 1172 EFI_STATUS Status; 930 1173 931 1174 Cache6 = &Private->OfferBuffer[Private->OfferNum].Dhcp6; … … 935 1178 // Cache the content of DHCPv6 packet firstly. 936 1179 // 937 PxeBcCacheDhcp6Packet (Offer, RcvdOffer); 1180 Status = PxeBcCacheDhcp6Packet (Offer, RcvdOffer); 1181 if (EFI_ERROR (Status)) { 1182 return Status; 1183 } 938 1184 939 1185 // … … 941 1187 // 942 1188 if (EFI_ERROR (PxeBcParseDhcp6Packet (Cache6))) { 943 return ;1189 return EFI_ABORTED; 944 1190 } 945 1191 … … 963 1209 Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum; 964 1210 Private->OfferCount[OfferType]++; 965 } else if (Private->OfferCount[OfferType] > 0) { 1211 } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) && 1212 Private->OfferCount[OfferType] < 1) { 966 1213 // 967 1214 // Only cache the first PXE10/WFM11a offer, and discard the others. … … 970 1217 Private->OfferCount[OfferType] = 1; 971 1218 } else { 972 return ;1219 return EFI_ABORTED; 973 1220 } 974 1221 } else { … … 981 1228 982 1229 Private->OfferNum++; 1230 1231 return EFI_SUCCESS; 983 1232 } 984 1233 … … 1095 1344 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 1096 1345 1097 @retval EFI_SUCCESS Handled the DHCPv6 offer packet successfully. 1098 @retval EFI_NO_RESPONSE No response to the following request packet. 1346 @retval EFI_SUCCESS Handled the DHCPv6 offer packet successfully. 1347 @retval EFI_NO_RESPONSE No response to the following request packet. 1348 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. 1349 @retval EFI_BUFFER_TOO_SMALL Can't cache the offer pacet. 1099 1350 1100 1351 **/ … … 1116 1367 Cache6 = &Private->OfferBuffer[SelectIndex].Dhcp6; 1117 1368 Status = EFI_SUCCESS; 1369 1370 // 1371 // First try to cache DNS server address if DHCP6 offer provides. 1372 // 1373 if (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] != NULL) { 1374 Private->DnsServer = AllocateZeroPool (NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen)); 1375 if (Private->DnsServer == NULL) { 1376 return EFI_OUT_OF_RESOURCES; 1377 } 1378 CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS)); 1379 } 1118 1380 1119 1381 if (Cache6->OfferType == PxeOfferTypeDhcpBinl) { … … 1195 1457 // Success to try to request by a ProxyPxe10 or ProxyWfm11a offer, copy and parse it. 1196 1458 // 1197 PxeBcCopyDhcp6Proxy (Private, ProxyIndex);1459 Status = PxeBcCopyDhcp6Proxy (Private, ProxyIndex); 1198 1460 } 1199 1461 } else { … … 1209 1471 // All PXE boot information is ready by now. 1210 1472 // 1211 PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE);1473 Status = PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE); 1212 1474 Private->PxeBc.Mode->DhcpDiscoverValid = TRUE; 1213 1475 } … … 1236 1498 } 1237 1499 1238 1239 1500 /** 1240 Register the ready address by Ip6Config protocol. 1501 Check whether IP driver could route the message which will be sent to ServerIp address. 1502 1503 This function will check the IP6 route table every 1 seconds until specified timeout is expired, if a valid 1504 route is found in IP6 route table, the address will be filed in GatewayAddr and return. 1505 1506 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 1507 @param[in] TimeOutInSecond Timeout value in seconds. 1508 @param[out] GatewayAddr Pointer to store the gateway IP address. 1509 1510 @retval EFI_SUCCESS Found a valid gateway address successfully. 1511 @retval EFI_TIMEOUT The operation is time out. 1512 @retval Other Unexpect error happened. 1513 1514 **/ 1515 EFI_STATUS 1516 PxeBcCheckRouteTable ( 1517 IN PXEBC_PRIVATE_DATA *Private, 1518 IN UINTN TimeOutInSecond, 1519 OUT EFI_IPv6_ADDRESS *GatewayAddr 1520 ) 1521 { 1522 EFI_STATUS Status; 1523 EFI_IP6_PROTOCOL *Ip6; 1524 EFI_IP6_MODE_DATA Ip6ModeData; 1525 UINTN Index; 1526 EFI_EVENT TimeOutEvt; 1527 UINTN RetryCount; 1528 BOOLEAN GatewayIsFound; 1529 1530 ASSERT (GatewayAddr != NULL); 1531 ASSERT (Private != NULL); 1532 1533 Ip6 = Private->Ip6; 1534 GatewayIsFound = FALSE; 1535 RetryCount = 0; 1536 TimeOutEvt = NULL; 1537 ZeroMem (GatewayAddr, sizeof (EFI_IPv6_ADDRESS)); 1538 1539 while (TRUE) { 1540 Status = Ip6->GetModeData (Ip6, &Ip6ModeData, NULL, NULL); 1541 if (EFI_ERROR (Status)) { 1542 goto ON_EXIT; 1543 } 1544 1545 // 1546 // Find out the gateway address which can route the message which send to ServerIp. 1547 // 1548 for (Index = 0; Index < Ip6ModeData.RouteCount; Index++) { 1549 if (NetIp6IsNetEqual (&Private->ServerIp.v6, &Ip6ModeData.RouteTable[Index].Destination, Ip6ModeData.RouteTable[Index].PrefixLength)) { 1550 IP6_COPY_ADDRESS (GatewayAddr, &Ip6ModeData.RouteTable[Index].Gateway); 1551 GatewayIsFound = TRUE; 1552 break; 1553 } 1554 } 1555 1556 if (Ip6ModeData.AddressList != NULL) { 1557 FreePool (Ip6ModeData.AddressList); 1558 } 1559 if (Ip6ModeData.GroupTable != NULL) { 1560 FreePool (Ip6ModeData.GroupTable); 1561 } 1562 if (Ip6ModeData.RouteTable != NULL) { 1563 FreePool (Ip6ModeData.RouteTable); 1564 } 1565 if (Ip6ModeData.NeighborCache != NULL) { 1566 FreePool (Ip6ModeData.NeighborCache); 1567 } 1568 if (Ip6ModeData.PrefixTable != NULL) { 1569 FreePool (Ip6ModeData.PrefixTable); 1570 } 1571 if (Ip6ModeData.IcmpTypeList != NULL) { 1572 FreePool (Ip6ModeData.IcmpTypeList); 1573 } 1574 1575 if (GatewayIsFound || RetryCount == TimeOutInSecond) { 1576 break; 1577 } 1578 1579 RetryCount++; 1580 1581 // 1582 // Delay 1 second then recheck it again. 1583 // 1584 if (TimeOutEvt == NULL) { 1585 Status = gBS->CreateEvent ( 1586 EVT_TIMER, 1587 TPL_CALLBACK, 1588 NULL, 1589 NULL, 1590 &TimeOutEvt 1591 ); 1592 if (EFI_ERROR (Status)) { 1593 goto ON_EXIT; 1594 } 1595 } 1596 1597 Status = gBS->SetTimer (TimeOutEvt, TimerRelative, TICKS_PER_SECOND); 1598 if (EFI_ERROR (Status)) { 1599 goto ON_EXIT; 1600 } 1601 while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) { 1602 Ip6->Poll (Ip6); 1603 } 1604 } 1605 1606 ON_EXIT: 1607 if (TimeOutEvt != NULL) { 1608 gBS->CloseEvent (TimeOutEvt); 1609 } 1610 1611 if (GatewayIsFound) { 1612 Status = EFI_SUCCESS; 1613 } else if (RetryCount == TimeOutInSecond) { 1614 Status = EFI_TIMEOUT; 1615 } 1616 1617 return Status; 1618 } 1619 1620 /** 1621 Register the ready station address and gateway by Ip6Config protocol. 1241 1622 1242 1623 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. … … 1257 1638 EFI_IP6_CONFIG_POLICY Policy; 1258 1639 EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr; 1640 EFI_IPv6_ADDRESS GatewayAddr; 1259 1641 UINTN DataSize; 1260 EFI_EVENT TimeOutEvt;1261 1642 EFI_EVENT MappedEvt; 1262 1643 EFI_STATUS Status; 1263 UINT64 DadTriggerTime; 1264 EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits; 1644 BOOLEAN NoGateway; 1645 EFI_IPv6_ADDRESS *Ip6Addr; 1646 UINTN Index; 1265 1647 1266 1648 Status = EFI_SUCCESS; 1267 TimeOutEvt = NULL;1268 1649 MappedEvt = NULL; 1650 Ip6Addr = NULL; 1269 1651 DataSize = sizeof (EFI_IP6_CONFIG_POLICY); 1270 1652 Ip6Cfg = Private->Ip6Cfg; 1271 1653 Ip6 = Private->Ip6; 1654 NoGateway = FALSE; 1272 1655 1273 1656 ZeroMem (&CfgAddr, sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)); 1274 1657 CopyMem (&CfgAddr.Address, Address, sizeof (EFI_IPv6_ADDRESS)); 1275 1658 1276 // 1277 // Get and store the current policy of IP6 driver. 1278 // 1279 Status = Ip6Cfg->GetData ( 1280 Ip6Cfg, 1281 Ip6ConfigDataTypePolicy, 1282 &DataSize, 1283 &Private->Ip6Policy 1284 ); 1659 Status = Ip6->Configure (Ip6, &Private->Ip6CfgData); 1285 1660 if (EFI_ERROR (Status)) { 1286 1661 goto ON_EXIT; 1662 } 1663 1664 // 1665 // Retrieve the gateway address from IP6 route table. 1666 // 1667 Status = PxeBcCheckRouteTable (Private, PXEBC_IP6_ROUTE_TABLE_TIMEOUT, &GatewayAddr); 1668 if (EFI_ERROR (Status)) { 1669 NoGateway = TRUE; 1287 1670 } 1288 1671 … … 1307 1690 1308 1691 // 1309 // Get Duplicate Address Detection Transmits count.1310 //1311 DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);1312 Status = Ip6Cfg->GetData (1313 Ip6Cfg,1314 Ip6ConfigDataTypeDupAddrDetectTransmits,1315 &DataSize,1316 &DadXmits1317 );1318 if (EFI_ERROR (Status)) {1319 goto ON_EXIT;1320 }1321 1322 //1323 // Create a timer as setting address timeout event since DAD in IP6 driver.1324 //1325 Status = gBS->CreateEvent (1326 EVT_TIMER,1327 TPL_CALLBACK,1328 NULL,1329 NULL,1330 &TimeOutEvt1331 );1332 if (EFI_ERROR (Status)) {1333 goto ON_EXIT;1334 }1335 1336 //1337 1692 // Create a notify event to set address flag when DAD if IP6 driver succeeded. 1338 1693 // … … 1348 1703 } 1349 1704 1705 Private->IsAddressOk = FALSE; 1350 1706 Status = Ip6Cfg->RegisterDataNotify ( 1351 1707 Ip6Cfg, … … 1365 1721 if (EFI_ERROR(Status) && Status != EFI_NOT_READY) { 1366 1722 goto ON_EXIT; 1367 } 1368 1369 // 1370 // Start the 5 secondes timer to wait for setting address. 1371 // 1372 Status = EFI_NO_MAPPING; 1373 DadTriggerTime = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + PXEBC_DAD_ADDITIONAL_DELAY; 1374 gBS->SetTimer (TimeOutEvt, TimerRelative, DadTriggerTime); 1375 1376 while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) { 1377 Ip6->Poll (Ip6); 1378 if (Private->IsAddressOk) { 1379 Status = EFI_SUCCESS; 1380 break; 1723 } else if (Status == EFI_NOT_READY) { 1724 // 1725 // Poll the network until the asynchronous process is finished. 1726 // 1727 while (!Private->IsAddressOk) { 1728 Ip6->Poll (Ip6); 1729 } 1730 // 1731 // Check whether the IP6 address setting is successed. 1732 // 1733 DataSize = 0; 1734 Status = Ip6Cfg->GetData ( 1735 Ip6Cfg, 1736 Ip6ConfigDataTypeManualAddress, 1737 &DataSize, 1738 NULL 1739 ); 1740 if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) { 1741 Status = EFI_DEVICE_ERROR; 1742 goto ON_EXIT; 1743 } 1744 1745 Ip6Addr = AllocatePool (DataSize); 1746 if (Ip6Addr == NULL) { 1747 return EFI_OUT_OF_RESOURCES; 1748 } 1749 Status = Ip6Cfg->GetData ( 1750 Ip6Cfg, 1751 Ip6ConfigDataTypeManualAddress, 1752 &DataSize, 1753 (VOID*) Ip6Addr 1754 ); 1755 if (EFI_ERROR (Status)) { 1756 Status = EFI_DEVICE_ERROR; 1757 goto ON_EXIT; 1758 } 1759 1760 for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index++) { 1761 if (CompareMem (Ip6Addr + Index, Address, sizeof (EFI_IPv6_ADDRESS)) == 0) { 1762 break; 1763 } 1764 } 1765 if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) { 1766 Status = EFI_ABORTED; 1767 goto ON_EXIT; 1768 } 1769 } 1770 1771 // 1772 // Set the default gateway address back if needed. 1773 // 1774 if (!NoGateway && !NetIp6IsUnspecifiedAddr (&GatewayAddr)) { 1775 Status = Ip6Cfg->SetData ( 1776 Ip6Cfg, 1777 Ip6ConfigDataTypeGateway, 1778 sizeof (EFI_IPv6_ADDRESS), 1779 &GatewayAddr 1780 ); 1781 if (EFI_ERROR (Status)) { 1782 goto ON_EXIT; 1381 1783 } 1382 1784 } … … 1391 1793 gBS->CloseEvent (MappedEvt); 1392 1794 } 1393 if ( TimeOutEvt!= NULL) {1394 gBS->CloseEvent (TimeOutEvt);1795 if (Ip6Addr != NULL) { 1796 FreePool (Ip6Addr); 1395 1797 } 1396 1798 return Status; 1397 1799 } 1398 1800 1801 /** 1802 Set the IP6 policy to Automatic. 1803 1804 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 1805 1806 @retval EFI_SUCCESS Switch the IP policy succesfully. 1807 @retval Others Unexpect error happened. 1808 1809 **/ 1810 EFI_STATUS 1811 PxeBcSetIp6Policy ( 1812 IN PXEBC_PRIVATE_DATA *Private 1813 ) 1814 { 1815 EFI_IP6_CONFIG_POLICY Policy; 1816 EFI_STATUS Status; 1817 EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; 1818 UINTN DataSize; 1819 1820 Ip6Cfg = Private->Ip6Cfg; 1821 DataSize = sizeof (EFI_IP6_CONFIG_POLICY); 1822 1823 // 1824 // Get and store the current policy of IP6 driver. 1825 // 1826 Status = Ip6Cfg->GetData ( 1827 Ip6Cfg, 1828 Ip6ConfigDataTypePolicy, 1829 &DataSize, 1830 &Private->Ip6Policy 1831 ); 1832 if (EFI_ERROR (Status)) { 1833 return Status; 1834 } 1835 1836 if (Private->Ip6Policy == Ip6ConfigPolicyManual) { 1837 Policy = Ip6ConfigPolicyAutomatic; 1838 Status = Ip6Cfg->SetData ( 1839 Ip6Cfg, 1840 Ip6ConfigDataTypePolicy, 1841 sizeof(EFI_IP6_CONFIG_POLICY), 1842 &Policy 1843 ); 1844 if (EFI_ERROR (Status)) { 1845 // 1846 // There is no need to recover later. 1847 // 1848 Private->Ip6Policy = PXEBC_IP6_POLICY_MAX; 1849 } 1850 } 1851 1852 return Status; 1853 } 1854 1855 /** 1856 This function will register the station IP address and flush IP instance to start using the new IP address. 1857 1858 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 1859 1860 @retval EFI_SUCCESS The new IP address has been configured successfully. 1861 @retval Others Failed to configure the address. 1862 1863 **/ 1864 EFI_STATUS 1865 PxeBcSetIp6Address ( 1866 IN PXEBC_PRIVATE_DATA *Private 1867 ) 1868 { 1869 EFI_STATUS Status; 1870 EFI_DHCP6_PROTOCOL *Dhcp6; 1871 1872 Dhcp6 = Private->Dhcp6; 1873 1874 CopyMem (&Private->StationIp.v6, &Private->TmpStationIp.v6, sizeof (EFI_IPv6_ADDRESS)); 1875 CopyMem (&Private->PxeBc.Mode->StationIp.v6, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS)); 1876 1877 Status = PxeBcRegisterIp6Address (Private, &Private->StationIp.v6); 1878 if (EFI_ERROR (Status)) { 1879 Dhcp6->Stop (Dhcp6); 1880 return Status; 1881 } 1882 1883 Status = PxeBcFlushStationIp (Private, &Private->StationIp, NULL); 1884 if (EFI_ERROR (Status)) { 1885 PxeBcUnregisterIp6Address (Private); 1886 Dhcp6->Stop (Dhcp6); 1887 return Status; 1888 } 1889 1890 AsciiPrint ("\n Station IP address is "); 1891 PxeBcShowIp6Addr (&Private->StationIp.v6); 1892 1893 return EFI_SUCCESS; 1894 } 1399 1895 1400 1896 /** … … 1470 1966 1471 1967 case Dhcp6SendSolicit: 1968 if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { 1969 // 1970 // If the to be sent packet exceeds the maximum length, abort the DHCP process. 1971 // 1972 Status = EFI_ABORTED; 1973 break; 1974 } 1975 1472 1976 // 1473 1977 // Record the first Solicate msg time … … 1485 1989 case Dhcp6RcvdAdvertise: 1486 1990 Status = EFI_NOT_READY; 1991 if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { 1992 // 1993 // Ignore the incoming packets which exceed the maximum length. 1994 // 1995 break; 1996 } 1487 1997 if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) { 1488 1998 // … … 1495 2005 1496 2006 case Dhcp6SendRequest: 2007 if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { 2008 // 2009 // If the to be sent packet exceeds the maximum length, abort the DHCP process. 2010 // 2011 Status = EFI_ABORTED; 2012 break; 2013 } 2014 1497 2015 // 1498 2016 // Store the request packet as seed packet for discover. … … 1521 2039 *NewPacket = AllocateZeroPool (SelectAd->Size); 1522 2040 ASSERT (*NewPacket != NULL); 2041 if (*NewPacket == NULL) { 2042 return EFI_ABORTED; 2043 } 1523 2044 CopyMem (*NewPacket, SelectAd, SelectAd->Size); 1524 2045 } … … 1531 2052 // 1532 2053 ASSERT (Private->SelectIndex != 0); 1533 PxeBcCopyDhcp6Ack (Private, Packet, FALSE); 2054 Status = PxeBcCopyDhcp6Ack (Private, Packet, FALSE); 2055 if (EFI_ERROR (Status)) { 2056 Status = EFI_ABORTED; 2057 } 1534 2058 break; 1535 2059 … … 1578 2102 UINT8 *DiscoverOpt; 1579 2103 UINTN ReadSize; 1580 UINT16 OpFlags;1581 2104 UINT16 OpCode; 1582 2105 UINT16 OpLen; … … 1589 2112 SrcPort = PXEBC_BS_DISCOVER_PORT; 1590 2113 DestPort = PXEBC_BS_DISCOVER_PORT; 1591 OpFlags = 0;1592 2114 1593 2115 if (!UseBis && Layer != NULL) { … … 1633 2155 Status = PxeBc->UdpWrite ( 1634 2156 PxeBc, 1635 OpFlags,2157 0, 1636 2158 &Private->ServerIp, 1637 2159 &DestPort, … … 1645 2167 ); 1646 2168 if (EFI_ERROR (Status)) { 1647 return Status;2169 goto ON_ERROR; 1648 2170 } 1649 2171 … … 1665 2187 Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData); 1666 2188 if (EFI_ERROR (Status)) { 1667 return Status;2189 goto ON_ERROR; 1668 2190 } 1669 2191 1670 2192 Status = PxeBc->UdpRead ( 1671 2193 PxeBc, 1672 OpFlags,1673 &Private->StationIp,2194 EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP, 2195 NULL, 1674 2196 &SrcPort, 1675 2197 &Private->ServerIp, … … 1685 2207 Private->Udp6Read->Configure (Private->Udp6Read, NULL); 1686 2208 if (EFI_ERROR (Status)) { 1687 return Status;2209 goto ON_ERROR; 1688 2210 } 1689 2211 1690 2212 return EFI_SUCCESS; 2213 2214 ON_ERROR: 2215 if (Discover != NULL) { 2216 FreePool (Discover); 2217 } 2218 2219 return Status; 1691 2220 } 1692 2221 … … 1843 2372 } 1844 2373 1845 ASSERT (Mode.Ia->State == Dhcp6Bound); 1846 CopyMem (&Private->StationIp.v6, &Mode.Ia->IaAddress[0].IpAddress, sizeof (EFI_IPv6_ADDRESS)); 1847 CopyMem (&PxeMode->StationIp.v6, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS)); 1848 1849 Status = PxeBcRegisterIp6Address (Private, &Private->StationIp.v6); 2374 ASSERT ((Mode.Ia != NULL) && (Mode.Ia->State == Dhcp6Bound)); 2375 // 2376 // DHCP6 doesn't have an option to specify the router address on the subnet, the only way to get the 2377 // router address in IP6 is the router discovery mechanism (the RS and RA, which only be handled when 2378 // the IP policy is Automatic). So we just hold the station IP address here and leave the IP policy as 2379 // Automatic, until we get the server IP address. This could let IP6 driver finish the router discovery 2380 // to find a valid router address. 2381 // 2382 CopyMem (&Private->TmpStationIp.v6, &Mode.Ia->IaAddress[0].IpAddress, sizeof (EFI_IPv6_ADDRESS)); 2383 if (Mode.ClientId != NULL) { 2384 FreePool (Mode.ClientId); 2385 } 2386 if (Mode.Ia != NULL) { 2387 FreePool (Mode.Ia); 2388 } 2389 // 2390 // Check the selected offer whether BINL retry is needed. 2391 // 2392 Status = PxeBcHandleDhcp6Offer (Private); 1850 2393 if (EFI_ERROR (Status)) { 1851 2394 Dhcp6->Stop (Dhcp6); … … 1853 2396 } 1854 2397 1855 Status = PxeBcFlushStationIp (Private, &Private->StationIp, NULL);1856 if (EFI_ERROR (Status)) {1857 PxeBcUnregisterIp6Address (Private);1858 Dhcp6->Stop (Dhcp6);1859 return Status;1860 }1861 1862 //1863 // Check the selected offer whether BINL retry is needed.1864 //1865 Status = PxeBcHandleDhcp6Offer (Private);1866 if (EFI_ERROR (Status)) {1867 PxeBcUnregisterIp6Address (Private);1868 Dhcp6->Stop (Dhcp6);1869 return Status;1870 }1871 1872 AsciiPrint ("\n Station IP address is ");1873 1874 PxeBcShowIp6Addr (&Private->StationIp.v6);1875 1876 2398 return EFI_SUCCESS; 1877 2399 } 1878 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h
r58459 r77662 2 2 Functions declaration related with DHCPv6 for UefiPxeBc Driver. 3 3 4 Copyright (c) 2009 - 201 2, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 19 19 #define PXEBC_DHCP6_OPTION_MAX_NUM 16 20 20 #define PXEBC_DHCP6_OPTION_MAX_SIZE 312 21 #define PXEBC_DHCP6_PACKET_MAX_SIZE 147221 #define PXEBC_DHCP6_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET)) 22 22 #define PXEBC_IP6_POLICY_MAX 0xff 23 #define PXEBC_IP6_ROUTE_TABLE_TIMEOUT 10 23 24 24 25 #define PXEBC_DHCP6_S_PORT 547 25 26 #define PXEBC_DHCP6_C_PORT 546 26 27 27 #define PXEBC_DHCP6_OPT_CLIENT_ID 128 #define PXEBC_DHCP6_OPT_SERVER_ID 229 #define PXEBC_DHCP6_OPT_IA_NA 330 #define PXEBC_DHCP6_OPT_IA_TA 431 #define PXEBC_DHCP6_OPT_IAADDR 532 #define PXEBC_DHCP6_OPT_ORO 633 #define PXEBC_DHCP6_OPT_PREFERENCE 734 #define PXEBC_DHCP6_OPT_ELAPSED_TIME 835 #define PXEBC_DHCP6_OPT_REPLAY_MSG 936 #define PXEBC_DHCP6_OPT_AUTH 1137 #define PXEBC_DHCP6_OPT_UNICAST 1238 #define PXEBC_DHCP6_OPT_STATUS_CODE 1339 #define PXEBC_DHCP6_OPT_RAPID_COMMIT 1440 #define PXEBC_DHCP6_OPT_USER_CLASS 1541 #define PXEBC_DHCP6_OPT_VENDOR_CLASS 1642 #define PXEBC_DHCP6_OPT_VENDOR_OPTS 1743 #define PXEBC_DHCP6_OPT_INTERFACE_ID 1844 #define PXEBC_DHCP6_OPT_RECONFIG_MSG 1945 #define PXEBC_DHCP6_OPT_RECONFIG_ACCEPT 2046 #define PXEBC_DHCP6_OPT_BOOT_FILE_URL 59 // Assigned by IANA, RFC 597047 #define PXEBC_DHCP6_OPT_BOOT_FILE_PARAM 60 // Assigned by IANA, RFC 597048 #define PXEBC_DHCP6_OPT_ARCH 61 // Assigned by IANA, RFC 597049 #define PXEBC_DHCP6_OPT_UNDI 62 // Assigned by IANA, RFC 597050 28 #define PXEBC_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's 51 29 #define PXEBC_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes. … … 56 34 #define PXEBC_DHCP6_IDX_BOOT_FILE_PARAM 2 57 35 #define PXEBC_DHCP6_IDX_VENDOR_CLASS 3 58 #define PXEBC_DHCP6_IDX_MAX 4 36 #define PXEBC_DHCP6_IDX_DNS_SERVER 4 37 #define PXEBC_DHCP6_IDX_MAX 5 59 38 60 39 #define PXEBC_DHCP6_BOOT_FILE_URL_PREFIX "tftp://" … … 123 102 } PXEBC_DHCP6_OPTION_NODE; 124 103 104 #define PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + PXEBC_DHCP6_PACKET_MAX_SIZE) 105 125 106 typedef union { 126 107 EFI_DHCP6_PACKET Offer; 127 108 EFI_DHCP6_PACKET Ack; 128 UINT8 Buffer[PXEBC_ DHCP6_PACKET_MAX_SIZE];109 UINT8 Buffer[PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE]; 129 110 } PXEBC_DHCP6_PACKET; 130 111 … … 151 132 Parse the Boot File URL option. 152 133 134 @param[in] Private Pointer to PxeBc private data. 153 135 @param[out] FileName The pointer to the boot file name. 154 136 @param[in, out] SrvAddr The pointer to the boot server address. … … 163 145 EFI_STATUS 164 146 PxeBcExtractBootFileUrl ( 147 IN PXEBC_PRIVATE_DATA *Private, 165 148 OUT UINT8 **FileName, 166 149 IN OUT EFI_IPv6_ADDRESS *SrvAddr, … … 255 238 ); 256 239 240 /** 241 Set the IP6 policy to Automatic. 242 243 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 244 245 @retval EFI_SUCCESS Switch the IP policy succesfully. 246 @retval Others Unexpect error happened. 247 248 **/ 249 EFI_STATUS 250 PxeBcSetIp6Policy ( 251 IN PXEBC_PRIVATE_DATA *Private 252 ); 253 254 /** 255 This function will register the station IP address and flush IP instance to start using the new IP address. 256 257 @param[in] Private The pointer to PXEBC_PRIVATE_DATA. 258 259 @retval EFI_SUCCESS The new IP address has been configured successfully. 260 @retval Others Failed to configure the address. 261 262 **/ 263 EFI_STATUS 264 PxeBcSetIp6Address ( 265 IN PXEBC_PRIVATE_DATA *Private 266 ); 257 267 258 268 /** -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
r58466 r77662 2 2 Driver Binding functions implementationfor for UefiPxeBc Driver. 3 3 4 Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR> 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> 5 6 6 7 This program and the accompanying materials … … 254 255 NULL 255 256 ); 257 FreePool (Private->Ip4Nic->DevicePath); 256 258 257 259 if (Private->Snp != NULL) { … … 414 416 NULL 415 417 ); 418 FreePool (Private->Ip6Nic->DevicePath); 419 416 420 if (Private->Snp != NULL) { 417 421 // … … 442 446 } 443 447 448 /** 449 Check whether UNDI protocol supports IPv6. 450 451 @param[in] ControllerHandle Controller handle. 452 @param[in] Private Pointer to PXEBC_PRIVATE_DATA. 453 @param[out] Ipv6Support TRUE if UNDI supports IPv6. 454 455 @retval EFI_SUCCESS Get the result whether UNDI supports IPv6 by NII or AIP protocol successfully. 456 @retval EFI_NOT_FOUND Don't know whether UNDI supports IPv6 since NII or AIP is not available. 457 458 **/ 459 EFI_STATUS 460 PxeBcCheckIpv6Support ( 461 IN EFI_HANDLE ControllerHandle, 462 IN PXEBC_PRIVATE_DATA *Private, 463 OUT BOOLEAN *Ipv6Support 464 ) 465 { 466 EFI_HANDLE Handle; 467 EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; 468 EFI_STATUS Status; 469 EFI_GUID *InfoTypesBuffer; 470 UINTN InfoTypeBufferCount; 471 UINTN TypeIndex; 472 BOOLEAN Supported; 473 VOID *InfoBlock; 474 UINTN InfoBlockSize; 475 476 ASSERT (Private != NULL && Ipv6Support != NULL); 477 478 // 479 // Check whether the UNDI supports IPv6 by NII protocol. 480 // 481 if (Private->Nii != NULL) { 482 *Ipv6Support = Private->Nii->Ipv6Supported; 483 return EFI_SUCCESS; 484 } 485 486 // 487 // Check whether the UNDI supports IPv6 by AIP protocol. 488 // 489 490 // 491 // Get the NIC handle by SNP protocol. 492 // 493 Handle = NetLibGetSnpHandle (ControllerHandle, NULL); 494 if (Handle == NULL) { 495 return EFI_NOT_FOUND; 496 } 497 498 Aip = NULL; 499 Status = gBS->HandleProtocol ( 500 Handle, 501 &gEfiAdapterInformationProtocolGuid, 502 (VOID *) &Aip 503 ); 504 if (EFI_ERROR (Status) || Aip == NULL) { 505 return EFI_NOT_FOUND; 506 } 507 508 InfoTypesBuffer = NULL; 509 InfoTypeBufferCount = 0; 510 Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); 511 if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) { 512 FreePool (InfoTypesBuffer); 513 return EFI_NOT_FOUND; 514 } 515 516 Supported = FALSE; 517 for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) { 518 if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoUndiIpv6SupportGuid)) { 519 Supported = TRUE; 520 break; 521 } 522 } 523 524 FreePool (InfoTypesBuffer); 525 if (!Supported) { 526 return EFI_NOT_FOUND; 527 } 528 529 // 530 // We now have adapter information block. 531 // 532 InfoBlock = NULL; 533 InfoBlockSize = 0; 534 Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize); 535 if (EFI_ERROR (Status) || InfoBlock == NULL) { 536 FreePool (InfoBlock); 537 return EFI_NOT_FOUND; 538 } 539 540 *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support; 541 FreePool (InfoBlock); 542 return EFI_SUCCESS; 543 544 } 444 545 445 546 /** … … 645 746 Private->Ip4Nic->Signature = PXEBC_VIRTUAL_NIC_SIGNATURE; 646 747 748 // 749 // Locate Ip4->Ip4Config2 and store it for set IPv4 Policy. 750 // 751 Status = gBS->HandleProtocol ( 752 ControllerHandle, 753 &gEfiIp4Config2ProtocolGuid, 754 (VOID **) &Private->Ip4Config2 755 ); 756 if (EFI_ERROR (Status)) { 757 goto ON_ERROR; 758 } 759 647 760 // 648 761 // Create a device path node for Ipv4 virtual nic, and append it. … … 952 1065 Private->Ip6MaxPacketSize = Ip6ModeData.MaxPacketSize; 953 1066 1067 if (Ip6ModeData.AddressList != NULL) { 1068 FreePool (Ip6ModeData.AddressList); 1069 } 1070 1071 if (Ip6ModeData.GroupTable != NULL) { 1072 FreePool (Ip6ModeData.GroupTable); 1073 } 1074 1075 if (Ip6ModeData.RouteTable != NULL) { 1076 FreePool (Ip6ModeData.RouteTable); 1077 } 1078 1079 if (Ip6ModeData.NeighborCache != NULL) { 1080 FreePool (Ip6ModeData.NeighborCache); 1081 } 1082 1083 if (Ip6ModeData.PrefixTable != NULL) { 1084 FreePool (Ip6ModeData.PrefixTable); 1085 } 1086 1087 if (Ip6ModeData.IcmpTypeList != NULL) { 1088 FreePool (Ip6ModeData.IcmpTypeList); 1089 } 1090 954 1091 // 955 1092 // Locate Ip6->Ip6Config and store it for set IPv6 address. … … 1057 1194 // Udp6Read and Ip6 instance. 1058 1195 // 1059 Private->Mode.Ipv6Available = TRUE; 1196 Status = PxeBcCheckIpv6Support (ControllerHandle, Private, &Private->Mode.Ipv6Available); 1197 if (EFI_ERROR (Status)) { 1198 // 1199 // Fail to get the data whether UNDI supports IPv6. Set default value. 1200 // 1201 Private->Mode.Ipv6Available = TRUE; 1202 } 1203 1204 if (!Private->Mode.Ipv6Available) { 1205 goto ON_ERROR; 1206 } 1207 1060 1208 Udp6CfgData = &Private->Udp6CfgData; 1061 1209 Ip6CfgData = &Private->Ip6CfgData; … … 1401 1549 EFI_STATUS Status; 1402 1550 EFI_HANDLE NicHandle; 1403 BOOLEAN IsIpv6;1404 1551 PXEBC_PRIVATE_PROTOCOL *Id; 1405 1552 … … 1409 1556 LoadFile = NULL; 1410 1557 Id = NULL; 1411 IsIpv6 = FALSE;1412 1558 1413 1559 Status = gBS->OpenProtocol ( -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
r58466 r77662 2 2 This implementation of EFI_PXE_BASE_CODE_PROTOCOL and EFI_LOAD_FILE_PROTOCOL. 3 3 4 Copyright (c) 2007 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 96 96 // Configure block size for TFTP as a default value to handle all link layers. 97 97 // 98 Private->BlockSize = (UINTN) (Private->Ip6MaxPacketSize -99 PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE );98 Private->BlockSize = Private->Ip6MaxPacketSize - 99 PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE; 100 100 101 101 // … … 103 103 // 104 104 Private->Ip6Policy = PXEBC_IP6_POLICY_MAX; 105 Private->ProxyOffer.Dhcp6.Packet.Offer.Size = PXEBC_ DHCP6_PACKET_MAX_SIZE;106 Private->DhcpAck.Dhcp6.Packet.Ack.Size = PXEBC_ DHCP6_PACKET_MAX_SIZE;107 Private->PxeReply.Dhcp6.Packet.Ack.Size = PXEBC_ DHCP6_PACKET_MAX_SIZE;105 Private->ProxyOffer.Dhcp6.Packet.Offer.Size = PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE; 106 Private->DhcpAck.Dhcp6.Packet.Ack.Size = PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE; 107 Private->PxeReply.Dhcp6.Packet.Ack.Size = PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE; 108 108 109 109 for (Index = 0; Index < PXEBC_OFFER_MAX_NUM; Index++) { 110 Private->OfferBuffer[Index].Dhcp6.Packet.Offer.Size = PXEBC_ DHCP6_PACKET_MAX_SIZE;110 Private->OfferBuffer[Index].Dhcp6.Packet.Offer.Size = PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE; 111 111 } 112 112 … … 125 125 goto ON_ERROR; 126 126 } 127 128 // 129 // Set Ip6 policy to Automatic to start the IP6 router discovery. 130 // 131 Status = PxeBcSetIp6Policy (Private); 132 if (EFI_ERROR (Status)) { 133 goto ON_ERROR; 134 } 127 135 } else { 128 136 AsciiPrint ("\n>>Start PXE over IPv4"); … … 141 149 // Configure block size for TFTP as a default value to handle all link layers. 142 150 // 143 Private->BlockSize = (UINTN) (Private->Ip4MaxPacketSize -144 PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE );151 Private->BlockSize = Private->Ip4MaxPacketSize - 152 PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE; 145 153 146 154 // 147 155 // PXE over IPv4 starts here, initialize the fields. 148 156 // 149 Private->ProxyOffer.Dhcp4.Packet.Offer.Size = PXEBC_ DHCP4_PACKET_MAX_SIZE;150 Private->DhcpAck.Dhcp4.Packet.Ack.Size = PXEBC_ DHCP4_PACKET_MAX_SIZE;151 Private->PxeReply.Dhcp4.Packet.Ack.Size = PXEBC_ DHCP4_PACKET_MAX_SIZE;157 Private->ProxyOffer.Dhcp4.Packet.Offer.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; 158 Private->DhcpAck.Dhcp4.Packet.Ack.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; 159 Private->PxeReply.Dhcp4.Packet.Ack.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; 152 160 153 161 for (Index = 0; Index < PXEBC_OFFER_MAX_NUM; Index++) { 154 Private->OfferBuffer[Index].Dhcp4.Packet.Offer.Size = PXEBC_ DHCP4_PACKET_MAX_SIZE;162 Private->OfferBuffer[Index].Dhcp4.Packet.Offer.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; 155 163 } 156 164 … … 194 202 &Private->IcmpToken.Event 195 203 ); 204 if (EFI_ERROR (Status)) { 205 goto ON_ERROR; 206 } 207 208 // 209 //DHCP4 service allows only one of its children to be configured in 210 //the active state, If the DHCP4 D.O.R.A started by IP4 auto 211 //configuration and has not been completed, the Dhcp4 state machine 212 //will not be in the right state for the PXE to start a new round D.O.R.A. 213 //so we need to switch it's policy to static. 214 // 215 Status = PxeBcSetIp4Policy (Private); 196 216 if (EFI_ERROR (Status)) { 197 217 goto ON_ERROR; … … 339 359 Private->IcmpToken.Event = NULL; 340 360 } 361 Private->BootFileName = NULL; 341 362 } 342 363 … … 835 856 (BufferSize == NULL) || 836 857 (ServerIp == NULL) || 837 ((BufferPtr == NULL) && DontUseBuffer) || 838 ((BlockSize != NULL) && (*BlockSize < PXE_MTFTP_DEFAULT_BLOCK_SIZE)) || 839 (!NetIp4IsUnicast (NTOHL (ServerIp->Addr[0]), 0) && !NetIp6IsValidUnicast (&ServerIp->v6))) { 858 ((BlockSize != NULL) && (*BlockSize < PXE_MTFTP_DEFAULT_BLOCK_SIZE))) { 840 859 return EFI_INVALID_PARAMETER; 860 } 861 862 if (Operation == EFI_PXE_BASE_CODE_TFTP_READ_FILE || 863 Operation == EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY || 864 Operation == EFI_PXE_BASE_CODE_MTFTP_READ_FILE || 865 Operation == EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY) { 866 if (BufferPtr == NULL && !DontUseBuffer) { 867 return EFI_INVALID_PARAMETER; 868 } 841 869 } 842 870 … … 845 873 Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This); 846 874 Mode = Private->PxeBc.Mode; 875 876 if (Mode->UsingIpv6) { 877 if (!NetIp6IsValidUnicast (&ServerIp->v6)) { 878 return EFI_INVALID_PARAMETER; 879 } 880 } else { 881 if (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0]))) { 882 return EFI_INVALID_PARAMETER; 883 } 884 } 847 885 848 886 if (Mode->UsingIpv6) { … … 1056 1094 } 1057 1095 1058 if (!Mode->UsingIpv6 && GatewayIp != NULL && !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), 0)) { 1096 if (!Mode->UsingIpv6 && GatewayIp != NULL && Mode->SubnetMask.Addr[0] != 0 && 1097 !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), EFI_NTOHL(Mode->SubnetMask))) { 1059 1098 // 1060 1099 // Gateway is provided but it's not a unicast IPv4 address, while it will be ignored for IPv6. … … 1105 1144 &Private->GatewayIp.v4, 1106 1145 &Private->CurSrcPort, 1107 DoNotFragment 1146 DoNotFragment, 1147 Private->Mode.TTL, 1148 Private->Mode.ToS 1108 1149 ); 1109 1150 } … … 1257 1298 UINT8 *FragmentBuffer; 1258 1299 1259 if (This == NULL || DestIp == NULL || DestPort == NULL) {1300 if (This == NULL) { 1260 1301 return EFI_INVALID_PARAMETER; 1261 1302 } … … 1268 1309 Udp6Rx = NULL; 1269 1310 1270 if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) != 0 && DestPort == NULL) ||1271 ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) != 0 && SrcIp == NULL) ||1272 ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) != 0 && SrcPort == NULL)) {1311 if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0 && DestPort == NULL) || 1312 ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) == 0 && SrcIp == NULL) || 1313 ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) == 0 && SrcPort == NULL)) { 1273 1314 return EFI_INVALID_PARAMETER; 1274 1315 } … … 1565 1606 return EFI_INVALID_PARAMETER; 1566 1607 } 1567 if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0 && 1568 (NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), 0) || 1569 NetIp6IsValidUnicast (&NewFilter->IpList[Index].v6))) { 1570 // 1571 // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IPv4/IPv6 address 1572 // is in IpList, promiscuous mode is needed. 1573 // 1608 if (Mode->UsingIpv6) { 1609 if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0 && 1610 NetIp6IsValidUnicast (&NewFilter->IpList[Index].v6)) { 1611 NeedPromiscuous = TRUE; 1612 } 1613 } else if ((EFI_NTOHL(Mode->StationIp) != 0) && 1614 (EFI_NTOHL(Mode->SubnetMask) != 0) && 1615 IP4_NET_EQUAL(EFI_NTOHL(Mode->StationIp), EFI_NTOHL(NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask.v4)) && 1616 NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask)) && 1617 ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0)) { 1574 1618 NeedPromiscuous = TRUE; 1575 1619 } … … 1890 1934 // 1891 1935 Status = gBS->HandleProtocol ( 1892 Private->Controller,1936 Mode->UsingIpv6 ? Private->Ip6Nic->Controller : Private->Ip4Nic->Controller, 1893 1937 &gEfiPxeBaseCodeCallbackProtocolGuid, 1894 1938 (VOID **) &Private->PxeBcCallback … … 1906 1950 if (NewSendGUID != NULL) { 1907 1951 if (*NewSendGUID && EFI_ERROR (NetLibGetSystemGuid (&SystemGuid))) { 1952 DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios table!\n")); 1908 1953 return EFI_INVALID_PARAMETER; 1909 1954 } … … 1965 2010 } 1966 2011 1967 if (NewStationIp != NULL && 1968 (!NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), 0) && 1969 !NetIp6IsValidUnicast (&NewStationIp->v6))) { 2012 if (NewStationIp != NULL && !NetIp6IsValidUnicast (&NewStationIp->v6)) { 1970 2013 return EFI_INVALID_PARAMETER; 1971 2014 } … … 1979 2022 !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0]))) { 1980 2023 return EFI_INVALID_PARAMETER; 2024 } 2025 2026 if (!Mode->UsingIpv6 && NewStationIp != NULL) { 2027 if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) || 2028 IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) || 2029 (NewSubnetMask != NULL && NewSubnetMask->Addr[0] != 0 && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL (NewSubnetMask->Addr[0])))) { 2030 return EFI_INVALID_PARAMETER; 2031 } 1981 2032 } 1982 2033 … … 2306 2357 BOOLEAN UsingIpv6; 2307 2358 EFI_STATUS Status; 2308 BOOLEAN MediaPresent; 2359 EFI_STATUS MediaStatus; 2360 2361 if (This == NULL || BufferSize == NULL || FilePath == NULL || !IsDevicePathEnd (FilePath)) { 2362 return EFI_INVALID_PARAMETER; 2363 } 2364 2365 // 2366 // Only support BootPolicy 2367 // 2368 if (!BootPolicy) { 2369 return EFI_UNSUPPORTED; 2370 } 2309 2371 2310 2372 VirtualNic = PXEBC_VIRTUAL_NIC_FROM_LOADFILE (This); … … 2314 2376 Status = EFI_DEVICE_ERROR; 2315 2377 2316 if (This == NULL || BufferSize == NULL) {2317 return EFI_INVALID_PARAMETER;2318 }2319 2320 //2321 // Only support BootPolicy2322 //2323 if (!BootPolicy) {2324 return EFI_UNSUPPORTED;2325 }2326 2327 2378 // 2328 2379 // Check media status before PXE start 2329 2380 // 2330 Media Present = TRUE;2331 NetLibDetectMedia (Private->Controller, &MediaPresent);2332 if ( !MediaPresent) {2381 MediaStatus = EFI_SUCCESS; 2382 NetLibDetectMediaWaitTimeout (Private->Controller, PXEBC_CHECK_MEDIA_WAITING_TIME, &MediaStatus); 2383 if (MediaStatus != EFI_SUCCESS) { 2333 2384 return EFI_NO_MEDIA; 2334 2385 } … … 2368 2419 // 2369 2420 PxeBc->Stop (PxeBc); 2421 } else { 2422 // 2423 // The DHCP4 can have only one configured child instance so we need to stop 2424 // reset the DHCP4 child before we return. Otherwise these programs which 2425 // also need to use DHCP4 will be impacted. 2426 // 2427 if (!PxeBc->Mode->UsingIpv6) { 2428 Private->Dhcp4->Stop (Private->Dhcp4); 2429 Private->Dhcp4->Configure (Private->Dhcp4, NULL); 2430 } 2370 2431 } 2371 2432 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcImpl.h
r58466 r77662 3 3 interfaces declaration. 4 4 5 Copyright (c) 2007 - 201 2, Intel Corporation. All rights reserved.<BR>5 Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR> 6 6 7 7 This program and the accompanying materials … … 22 22 #include <Guid/SmBios.h> 23 23 #include <IndustryStandard/SmBios.h> 24 #include <IndustryStandard/Dhcp.h> 24 25 #include <Protocol/NetworkInterfaceIdentifier.h> 25 26 #include <Protocol/Arp.h> 26 27 #include <Protocol/Ip4.h> 28 #include <Protocol/Ip4Config2.h> 27 29 #include <Protocol/Ip6.h> 28 30 #include <Protocol/Ip6Config.h> … … 31 33 #include <Protocol/Dhcp4.h> 32 34 #include <Protocol/Dhcp6.h> 35 #include <Protocol/Dns6.h> 33 36 #include <Protocol/Mtftp4.h> 34 37 #include <Protocol/Mtftp6.h> … … 38 41 #include <Protocol/ServiceBinding.h> 39 42 #include <Protocol/DriverBinding.h> 43 #include <Protocol/AdapterInformation.h> 40 44 41 45 #include <Library/DebugLib.h> … … 73 77 #define PXEBC_OFFER_MAX_NUM 16 74 78 79 #define PXEBC_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) 80 75 81 #define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P') 76 82 #define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'V') … … 116 122 EFI_ARP_PROTOCOL *Arp; 117 123 EFI_IP4_PROTOCOL *Ip4; 124 EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; 118 125 EFI_DHCP4_PROTOCOL *Dhcp4; 119 126 EFI_MTFTP4_PROTOCOL *Mtftp4; … … 133 140 EFI_UDP6_PROTOCOL *Udp6Read; 134 141 EFI_UDP6_PROTOCOL *Udp6Write; 142 EFI_DNS6_PROTOCOL *Dns6; 135 143 136 144 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii; … … 161 169 BOOLEAN IsDoDiscover; 162 170 171 EFI_IP_ADDRESS TmpStationIp; 163 172 EFI_IP_ADDRESS StationIp; 164 173 EFI_IP_ADDRESS SubnetMask; 165 174 EFI_IP_ADDRESS GatewayIp; 166 175 EFI_IP_ADDRESS ServerIp; 176 EFI_IPv6_ADDRESS *DnsServer; 167 177 UINT16 CurSrcPort; 168 178 UINT32 IaId; -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.c
r58459 r77662 2 2 Functions implementation related with Mtftp for UefiPxeBc Driver. 3 3 4 Copyright (c) 2007 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 65 65 Private->Mode.TftpErrorReceived = TRUE; 66 66 Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode; 67 AsciiStrnCpy (67 AsciiStrnCpyS ( 68 68 Private->Mode.TftpError.ErrorString, 69 PXE_MTFTP_ERROR_STRING_LENGTH, 69 70 (CHAR8 *) Packet->Error.ErrorMessage, 70 PXE_MTFTP_ERROR_STRING_LENGTH 71 PXE_MTFTP_ERROR_STRING_LENGTH - 1 71 72 ); 72 73 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; … … 152 153 // 153 154 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX]; 154 PxeBcUintnToAscDec (0, OptBuf );155 PxeBcUintnToAscDec (0, OptBuf, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 155 156 ReqOpt[0].ValueStr = OptBuf; 156 157 … … 158 159 ReqOpt[1].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 159 160 ReqOpt[1].ValueStr = (UINT8 *) (ReqOpt[0].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 1); 160 PxeBcUintnToAscDec (*BlockSize, ReqOpt[1].ValueStr );161 PxeBcUintnToAscDec (*BlockSize, ReqOpt[1].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX - (AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 1)); 161 162 OptCnt++; 162 163 } … … 179 180 Private->Mode.TftpErrorReceived = TRUE; 180 181 Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode; 181 AsciiStrnCpy (182 AsciiStrnCpyS ( 182 183 Private->Mode.TftpError.ErrorString, 184 PXE_MTFTP_ERROR_STRING_LENGTH, 183 185 (CHAR8 *) Packet->Error.ErrorMessage, 184 PXE_MTFTP_ERROR_STRING_LENGTH 186 PXE_MTFTP_ERROR_STRING_LENGTH - 1 185 187 ); 186 188 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; … … 274 276 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 275 277 ReqOpt[0].ValueStr = OptBuf; 276 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr );278 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 277 279 OptCnt++; 278 280 } … … 357 359 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 358 360 ReqOpt[0].ValueStr = OptBuf; 359 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr );361 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 360 362 OptCnt++; 361 363 } … … 432 434 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 433 435 ReqOpt[0].ValueStr = OptBuf; 434 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr );436 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 435 437 OptCnt++; 436 438 } … … 509 511 Private->Mode.TftpErrorReceived = TRUE; 510 512 Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode; 511 AsciiStrnCpy (513 AsciiStrnCpyS ( 512 514 Private->Mode.TftpError.ErrorString, 515 PXE_MTFTP_ERROR_STRING_LENGTH, 513 516 (CHAR8 *) Packet->Error.ErrorMessage, 514 PXE_MTFTP_ERROR_STRING_LENGTH 517 PXE_MTFTP_ERROR_STRING_LENGTH - 1 515 518 ); 516 519 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; … … 596 599 // 597 600 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX]; 598 PxeBcUintnToAscDec (0, OptBuf );601 PxeBcUintnToAscDec (0, OptBuf, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 599 602 ReqOpt[0].ValueStr = OptBuf; 600 603 … … 602 605 ReqOpt[1].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 603 606 ReqOpt[1].ValueStr = (UINT8 *) (ReqOpt[0].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 1); 604 PxeBcUintnToAscDec (*BlockSize, ReqOpt[1].ValueStr );607 PxeBcUintnToAscDec (*BlockSize, ReqOpt[1].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX - (AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 1)); 605 608 OptCnt++; 606 609 } … … 623 626 Private->Mode.TftpErrorReceived = TRUE; 624 627 Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode; 625 AsciiStrnCpy (628 AsciiStrnCpyS ( 626 629 Private->Mode.TftpError.ErrorString, 630 PXE_MTFTP_ERROR_STRING_LENGTH, 627 631 (CHAR8 *) Packet->Error.ErrorMessage, 628 PXE_MTFTP_ERROR_STRING_LENGTH 632 PXE_MTFTP_ERROR_STRING_LENGTH - 1 629 633 ); 630 634 Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH - 1] = '\0'; … … 718 722 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 719 723 ReqOpt[0].ValueStr = OptBuf; 720 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr );724 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 721 725 OptCnt++; 722 726 } … … 801 805 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 802 806 ReqOpt[0].ValueStr = OptBuf; 803 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr );807 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 804 808 OptCnt++; 805 809 } … … 876 880 ReqOpt[0].OptionStr = (UINT8 *) mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; 877 881 ReqOpt[0].ValueStr = OptBuf; 878 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr );882 PxeBcUintnToAscDec (*BlockSize, ReqOpt[0].ValueStr, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); 879 883 OptCnt++; 880 884 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcMtftp.h
r48674 r77662 2 2 Functions declaration related with Mtftp for UefiPxeBc Driver. 3 3 4 Copyright (c) 2007 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 22 22 #define PXE_MTFTP_OPTION_MULTICAST_INDEX 3 23 23 #define PXE_MTFTP_OPTION_MAXIMUM_INDEX 4 24 #define PXE_MTFTP_OPTBUF_MAXNUM_INDEX 128 24 25 25 26 #define PXE_MTFTP_ERROR_STRING_LENGTH 127 // refer to definition of struct EFI_PXE_BASE_CODE_TFTP_ERROR. -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
r58459 r77662 2 2 Support functions implementation for UefiPxeBc Driver. 3 3 4 Copyright (c) 2007 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 31 31 PxeBcFlushStationIp ( 32 32 PXEBC_PRIVATE_DATA *Private, 33 EFI_IP_ADDRESS *StationIp, 33 EFI_IP_ADDRESS *StationIp, OPTIONAL 34 34 EFI_IP_ADDRESS *SubnetMask OPTIONAL 35 35 ) … … 38 38 EFI_STATUS Status; 39 39 40 ASSERT (StationIp != NULL);41 42 40 Mode = Private->PxeBc.Mode; 43 41 Status = EFI_SUCCESS; … … 45 43 if (Mode->UsingIpv6) { 46 44 47 CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); 48 CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); 45 if (StationIp != NULL) { 46 CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); 47 CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS)); 48 } 49 49 50 50 // … … 61 61 Status = Private->Ip6->Receive (Private->Ip6, &Private->Icmp6Token); 62 62 } else { 63 ASSERT (SubnetMask != NULL); 64 CopyMem (&Private->Udp4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS)); 65 CopyMem (&Private->Udp4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS)); 66 CopyMem (&Private->Ip4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS)); 67 CopyMem (&Private->Ip4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS)); 63 if (StationIp != NULL) { 64 CopyMem (&Private->Udp4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS)); 65 CopyMem (&Private->Ip4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS)); 66 } 67 68 if (SubnetMask != NULL) { 69 CopyMem (&Private->Udp4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS)); 70 CopyMem (&Private->Ip4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS)); 71 } 68 72 69 73 // … … 254 258 // The return status should be recognized as EFI_ICMP_ERROR. 255 259 // 256 gBS->SignalEvent (RxData->RecycleSignal); 257 goto ON_EXIT; 260 goto ON_RECYCLE; 258 261 } 259 262 260 263 if (EFI_IP4 (RxData->Header->SourceAddress) != 0 && 261 !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) { 264 (NTOHL (Mode->SubnetMask.Addr[0]) != 0) && 265 IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) && 266 !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0]))) { 262 267 // 263 268 // The source address of the received packet should be a valid unicast address. 264 269 // 265 gBS->SignalEvent (RxData->RecycleSignal); 266 goto ON_EXIT; 270 goto ON_RECYCLE; 267 271 } 268 272 … … 271 275 // The destination address of the received packet should be equal to the host address. 272 276 // 273 gBS->SignalEvent (RxData->RecycleSignal); 274 goto ON_EXIT; 275 } 276 277 if (RxData->Header->Protocol != EFI_IP_PROTO_ICMP) { 278 // 279 // The protocol value in the header of the receveid packet should be EFI_IP_PROTO_ICMP. 280 // 281 gBS->SignalEvent (RxData->RecycleSignal); 282 goto ON_EXIT; 283 } 277 goto ON_RECYCLE; 278 } 279 280 // 281 // The protocol has been configured to only receive ICMP packet. 282 // 283 ASSERT (RxData->Header->Protocol == EFI_IP_PROTO_ICMP); 284 284 285 285 Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer); … … 293 293 // The type of the receveid ICMP message should be ICMP_ERROR_MESSAGE. 294 294 // 295 gBS->SignalEvent (RxData->RecycleSignal); 296 goto ON_EXIT; 295 goto ON_RECYCLE; 297 296 } 298 297 … … 321 320 } 322 321 322 ON_RECYCLE: 323 gBS->SignalEvent (RxData->RecycleSignal); 324 323 325 ON_EXIT: 324 326 Private->IcmpToken.Status = EFI_NOT_READY; … … 390 392 // The return status should be recognized as EFI_ICMP_ERROR. 391 393 // 392 gBS->SignalEvent (RxData->RecycleSignal); 393 goto ON_EXIT; 394 goto ON_RECYCLE; 394 395 } 395 396 … … 398 399 // The source address of the received packet should be a valid unicast address. 399 400 // 400 gBS->SignalEvent (RxData->RecycleSignal); 401 goto ON_EXIT; 401 goto ON_RECYCLE; 402 402 } 403 403 … … 407 407 // The destination address of the received packet should be equal to the host address. 408 408 // 409 gBS->SignalEvent (RxData->RecycleSignal); 410 goto ON_EXIT; 411 } 412 413 if (RxData->Header->NextHeader != IP6_ICMP) { 414 // 415 // The nextheader in the header of the receveid packet should be IP6_ICMP. 416 // 417 gBS->SignalEvent (RxData->RecycleSignal); 418 goto ON_EXIT; 419 } 409 goto ON_RECYCLE; 410 } 411 412 // 413 // The protocol has been configured to only receive ICMP packet. 414 // 415 ASSERT (RxData->Header->NextHeader == IP6_ICMP); 420 416 421 417 Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer); … … 423 419 if (Type != ICMP_V6_DEST_UNREACHABLE && 424 420 Type != ICMP_V6_PACKET_TOO_BIG && 425 Type != ICMP_V6_ PACKET_TOO_BIG&&421 Type != ICMP_V6_TIME_EXCEEDED && 426 422 Type != ICMP_V6_PARAMETER_PROBLEM) { 427 423 // 428 424 // The type of the receveid packet should be an ICMP6 error message. 429 425 // 430 gBS->SignalEvent (RxData->RecycleSignal); 431 goto ON_EXIT; 426 goto ON_RECYCLE; 432 427 } 433 428 … … 456 451 } 457 452 453 ON_RECYCLE: 454 gBS->SignalEvent (RxData->RecycleSignal); 455 458 456 ON_EXIT: 459 457 Private->Icmp6Token.Status = EFI_NOT_READY; … … 490 488 @param[in] DoNotFragment If TRUE, fragment is not enabled. 491 489 Otherwise, fragment is enabled. 490 @param[in] Ttl The time to live field of the IP header. 491 @param[in] ToS The type of service field of the IP header. 492 492 493 493 @retval EFI_SUCCESS Successfully configured this instance. … … 502 502 IN EFI_IPv4_ADDRESS *Gateway, 503 503 IN OUT UINT16 *SrcPort, 504 IN BOOLEAN DoNotFragment 504 IN BOOLEAN DoNotFragment, 505 IN UINT8 Ttl, 506 IN UINT8 ToS 505 507 ) 506 508 { … … 512 514 Udp4CfgData.TransmitTimeout = PXEBC_DEFAULT_LIFETIME; 513 515 Udp4CfgData.ReceiveTimeout = PXEBC_DEFAULT_LIFETIME; 514 Udp4CfgData.TypeOfService = DEFAULT_ToS;515 Udp4CfgData.TimeToLive = DEFAULT_TTL;516 Udp4CfgData.TypeOfService = ToS; 517 Udp4CfgData.TimeToLive = Ttl; 516 518 Udp4CfgData.AllowDuplicatePort = TRUE; 517 519 Udp4CfgData.DoNotFragment = DoNotFragment; … … 1378 1380 UINTN Remainder; 1379 1381 1380 while (Length > 0) { 1381 Length--; 1382 for (; Length > 0; Length--) { 1382 1383 Remainder = Number % 10; 1383 1384 Number /= 10; 1384 Buffer[Length ] = (UINT8) ('0' + Remainder);1385 Buffer[Length - 1] = (UINT8) ('0' + Remainder); 1385 1386 } 1386 1387 } … … 1393 1394 @param[in] Number Numeric value to be converted. 1394 1395 @param[in] Buffer The pointer to the buffer for ASCII string. 1396 @param[in] BufferSize The maxsize of the buffer. 1395 1397 1396 1398 @return Length The actual length of the ASCII string. … … 1400 1402 PxeBcUintnToAscDec ( 1401 1403 IN UINTN Number, 1402 IN UINT8 *Buffer 1404 IN UINT8 *Buffer, 1405 IN UINTN BufferSize 1403 1406 ) 1404 1407 { … … 1416 1419 } while (Number != 0); 1417 1420 1418 AsciiStrCpy ((CHAR8 *) Buffer, &TempStr[Index]);1421 AsciiStrCpyS ((CHAR8 *) Buffer, BufferSize, &TempStr[Index]); 1419 1422 1420 1423 Length = AsciiStrLen ((CHAR8 *) Buffer); -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h
r58459 r77662 2 2 Support functions declaration for UefiPxeBc Driver. 3 3 4 Copyright (c) 2007 - 201 4, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 41 41 PxeBcFlushStationIp ( 42 42 PXEBC_PRIVATE_DATA *Private, 43 EFI_IP_ADDRESS *StationIp, 43 EFI_IP_ADDRESS *StationIp, OPTIONAL 44 44 EFI_IP_ADDRESS *SubnetMask OPTIONAL 45 45 ); … … 129 129 This function is to configure a UDPv4 instance for UdpWrite. 130 130 131 @param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL. 132 @param[in] StationIp Pointer to the station address. 133 @param[in] SubnetMask Pointer to the subnet mask. 134 @param[in] Gateway Pointer to the gateway address. 135 @param[in, out] SrcPort Pointer to the source port. 136 @param[in] DoNotFragment The flag of DoNotFragment bit in the IPv4 137 packet. 131 @param[in] Udp4 The pointer to EFI_UDP4_PROTOCOL. 132 @param[in] StationIp The pointer to the station address. 133 @param[in] SubnetMask The pointer to the subnet mask. 134 @param[in] Gateway The pointer to the gateway address. 135 @param[in, out] SrcPort The pointer to the source port. 136 @param[in] DoNotFragment If TRUE, fragment is not enabled. 137 Otherwise, fragment is enabled. 138 @param[in] Ttl The time to live field of the IP header. 139 @param[in] ToS The type of service field of the IP header. 138 140 139 141 @retval EFI_SUCCESS Successfully configured this instance. … … 148 150 IN EFI_IPv4_ADDRESS *Gateway, 149 151 IN OUT UINT16 *SrcPort, 150 IN BOOLEAN DoNotFragment 152 IN BOOLEAN DoNotFragment, 153 IN UINT8 Ttl, 154 IN UINT8 ToS 151 155 ); 152 156 … … 449 453 @param[in] Number Numeric value to be converted. 450 454 @param[in] Buffer Pointer to the buffer for ASCII string. 455 @param[in] BufferSize The maxsize of the buffer. 451 456 452 457 @return Length The actual length of the ASCII string. … … 456 461 PxeBcUintnToAscDec ( 457 462 IN UINTN Number, 458 IN UINT8 *Buffer 463 IN UINT8 *Buffer, 464 IN UINTN BufferSize 459 465 ); 460 466 -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
r58466 r77662 7 7 # 8 8 # 9 # Copyright (c) 2007 - 201 4, Intel Corporation. All rights reserved.<BR>9 # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR> 10 10 # 11 11 # This program and the accompanying materials … … 80 80 gEfiIp4ServiceBindingProtocolGuid ## TO_START 81 81 gEfiIp4ProtocolGuid ## TO_START 82 gEfiIp4Config2ProtocolGuid ## TO_START 82 83 gEfiIp6ServiceBindingProtocolGuid ## TO_START 83 84 gEfiIp6ProtocolGuid ## TO_START … … 95 96 gEfiDhcp6ServiceBindingProtocolGuid ## TO_START 96 97 gEfiDhcp6ProtocolGuid ## TO_START 98 gEfiDns6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES 99 gEfiDns6ProtocolGuid ## SOMETIMES_CONSUMES 97 100 gEfiPxeBaseCodeCallbackProtocolGuid ## SOMETIMES_PRODUCES 98 101 gEfiPxeBaseCodeProtocolGuid ## BY_START 99 102 gEfiLoadFileProtocolGuid ## BY_START 103 gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES 104 105 [Guids] 106 gEfiAdapterInfoUndiIpv6SupportGuid ## SOMETIMES_CONSUMES ## GUID 100 107 101 108 [Pcd] 102 gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize ## SOMETIMES_CONSUMES109 gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize ## SOMETIMES_CONSUMES 103 110 [UserExtensions.TianoCore."ExtraFiles"] 104 111 UefiPxeBcDxeExtra.uni -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // Access PXE-compatible devices for network access and network booting. 3 3 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxeExtra.uni
r58464 r77662 1 // /** @file1 // /** @file 2 2 // UefiPxeBcDxe Localized Strings and Content 3 3 //
Note:
See TracChangeset
for help on using the changeset viewer.