From nobody Sun Apr 28 09:11:05 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1500984777899307.9939926147657; Tue, 25 Jul 2017 05:12:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7185E21C9125F; Tue, 25 Jul 2017 05:10:49 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 67F3621C91255 for ; Tue, 25 Jul 2017 05:10:48 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 05:12:49 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.255.27.40]) by orsmga001.jf.intel.com with ESMTP; 25 Jul 2017 05:12:48 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,411,1496127600"; d="scan'208";a="1155145650" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 25 Jul 2017 20:12:42 +0800 Message-Id: <1500984765-8040-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> References: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 1/4] MdePkg/DevicePath.h: Add DNS Device Path definition X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds the DNS device path node definition. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdePkg/Include/Protocol/DevicePath.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MdePkg/Include/Protocol/DevicePath.h b/MdePkg/Include/Protocol= /DevicePath.h index 220fa90..fb8ab56 100644 --- a/MdePkg/Include/Protocol/DevicePath.h +++ b/MdePkg/Include/Protocol/DevicePath.h @@ -816,10 +816,26 @@ typedef struct { UINT32 NamespaceId; UINT64 NamespaceUuid; } NVME_NAMESPACE_DEVICE_PATH; =20 /// +/// DNS Device Path SubType +/// +#define MSG_DNS_DP 0x1F +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Indicates the DNS server address is IPv4 or IPv6 address. + /// + UINT8 IsIPv6; + /// + /// Instance of the DNS server address. + /// + EFI_IP_ADDRESS DnsServerIp[]; +} DNS_DEVICE_PATH; + +/// /// Uniform Resource Identifiers (URI) Device Path SubType /// #define MSG_URI_DP 0x18 typedef struct { EFI_DEVICE_PATH_PROTOCOL Header; @@ -1250,10 +1266,11 @@ typedef union { UART_DEVICE_PATH Uart; UART_FLOW_CONTROL_DEVICE_PATH UartFlowControl; SAS_DEVICE_PATH Sas; SASEX_DEVICE_PATH SasEx; NVME_NAMESPACE_DEVICE_PATH NvmeNamespace; + DNS_DEVICE_PATH Dns;=20 URI_DEVICE_PATH Uri; BLUETOOTH_DEVICE_PATH Bluetooth; WIFI_DEVICE_PATH WiFi; UFS_DEVICE_PATH Ufs; SD_DEVICE_PATH Sd; @@ -1307,10 +1324,11 @@ typedef union { UART_DEVICE_PATH *Uart; UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl; SAS_DEVICE_PATH *Sas; SASEX_DEVICE_PATH *SasEx; NVME_NAMESPACE_DEVICE_PATH *NvmeNamespace; + DNS_DEVICE_PATH *Dns; URI_DEVICE_PATH *Uri; BLUETOOTH_DEVICE_PATH *Bluetooth; WIFI_DEVICE_PATH *WiFi; UFS_DEVICE_PATH *Ufs; SD_DEVICE_PATH *Sd; --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 09:11:05 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1500984781482756.9198185013593; Tue, 25 Jul 2017 05:13:01 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A79E421C91265; Tue, 25 Jul 2017 05:10:51 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E633321C91258 for ; Tue, 25 Jul 2017 05:10:49 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 05:12:51 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.255.27.40]) by orsmga001.jf.intel.com with ESMTP; 25 Jul 2017 05:12:50 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,411,1496127600"; d="scan'208";a="1155145658" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 25 Jul 2017 20:12:43 +0800 Message-Id: <1500984765-8040-3-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> References: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- .../Library/UefiDevicePathLib/DevicePathFromText.c | 72 ++++++++++++++++++= ++++ .../Library/UefiDevicePathLib/DevicePathToText.c | 46 ++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg= /Library/UefiDevicePathLib/DevicePathFromText.c index f50c11c..60057ec 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c @@ -2723,10 +2723,81 @@ DevPathFromTextBluetoothLE ( ); return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp; } =20 /** + Converts a text device path node to DNS device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created DNS device path structure. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextDns ( + IN CHAR16 *TextDeviceNode + ) +{ + CHAR16 *DeviceNodeStr; + UINT32 DnsServerIpCount; + UINT16 DnsDeviceNodeLength; + DNS_DEVICE_PATH *DnsDeviceNode; + UINT32 DnsServerIpIndex; + CHAR16 *DnsServerIp; + + + // + // Count the DNS server address number. + // + DeviceNodeStr =3D TextDeviceNode; + DnsServerIpCount =3D 0; + while (DeviceNodeStr !=3D NULL) { + GetNextParamStr (&DeviceNodeStr); + DnsServerIpCount ++;=20 + } + + // + // Create the DNS DeviceNode. + // + DnsDeviceNodeLength =3D (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + si= zeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS)); + DnsDeviceNode =3D (DNS_DEVICE_PATH *) CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_DNS_DP, + DnsDeviceNodeLength + ); + + // + // Confirm the DNS server address is IPv4 or IPv6 type. + // + DeviceNodeStr =3D TextDeviceNode; + while (!IS_NULL (*DeviceNodeStr)) { + if (*DeviceNodeStr =3D=3D L'.') { + DnsDeviceNode->IsIPv6 =3D 0x00; + break; + } + + if (*DeviceNodeStr =3D=3D L':') { + DnsDeviceNode->IsIPv6 =3D 0x01; + break; + } + + DeviceNodeStr++; + } + + for (DnsServerIpIndex =3D 0; DnsServerIpIndex < DnsServerIpCount; DnsSer= verIpIndex++) { + DnsServerIp =3D GetNextParamStr (&TextDeviceNode); + if (DnsDeviceNode->IsIPv6 =3D=3D 0x00) { + StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[D= nsServerIpIndex].v4), NULL); + } else { + StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[Dn= sServerIpIndex].v6), NULL); + } + } + =20 + return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode; +} + +/** Converts a text device path node to URI device path structure. =20 @param TextDeviceNode The input Text device path node. =20 @return A pointer to the newly-created URI device path structure. @@ -3395,10 +3466,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT= _TABLE mUefiDevicePathLibDevP {L"UsbTestAndMeasurement", DevPathFromTextUsbTestAndMeasurement }, {L"UsbWwid", DevPathFromTextUsbWwid }, {L"Unit", DevPathFromTextUnit }, {L"iSCSI", DevPathFromTextiSCSI }, {L"Vlan", DevPathFromTextVlan }, + {L"Dns", DevPathFromTextDns }, {L"Uri", DevPathFromTextUri }, {L"Bluetooth", DevPathFromTextBluetooth }, {L"Wi-Fi", DevPathFromTextWiFi }, {L"BluetoothLE", DevPathFromTextBluetoothLE }, {L"MediaPath", DevPathFromTextMediaPath }, diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/L= ibrary/UefiDevicePathLib/DevicePathToText.c index b8d9491..63542db 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c @@ -1695,10 +1695,55 @@ DevPathToTextBluetoothLE ( BluetoothLE->Address.Type ); } =20 /** + Converts a DNS device path structure to its string representative. + + @param Str The string representative of input device. + @param DevPath The input device path structure. + @param DisplayOnly If DisplayOnly is TRUE, then the shorter text rep= resentation + of the display node is used, where applicable. If= DisplayOnly + is FALSE, then the longer text representation of = the display node + is used. + @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut form= s of text + representation for a device node can be used, whe= re applicable. + +**/ +VOID +DevPathToTextDns ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ) +{ + DNS_DEVICE_PATH *DnsDevPath; + UINT32 DnsServerIpCount; + UINT32 DnsServerIpIndex; + + DnsDevPath =3D DevPath; + DnsServerIpCount =3D (UINT32) (DevicePathNodeLength(DnsDevPath) - sizeof= (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP= _ADDRESS); + + UefiDevicePathLibCatPrint (Str, L"Dns("); + =20 + for (DnsServerIpIndex =3D 0; DnsServerIpIndex < DnsServerIpCount; DnsSer= verIpIndex++) { + if (DnsDevPath->IsIPv6 =3D=3D 0x00) { + CatIPv4Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v4)= ); + } else { + CatIPv6Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v6)= ); + } + + if (DnsServerIpIndex < DnsServerIpCount - 1) { + UefiDevicePathLibCatPrint (Str, L","); + } + } + + UefiDevicePathLibCatPrint (Str, L")"); +} + +/** Converts a URI device path structure to its string representative. =20 @param Str The string representative of input device. @param DevPath The input device path structure. @param DisplayOnly If DisplayOnly is TRUE, then the shorter text rep= resentation @@ -2223,10 +2268,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_= TEXT_TABLE mUefiDevicePathLib {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextI= nfiniBand }, {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextU= art }, {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextV= endor }, {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTexti= SCSI }, {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextV= lan }, + {MESSAGING_DEVICE_PATH, MSG_DNS_DP, DevPathToTextD= ns }, {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextU= ri }, {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextB= luetooth }, {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextW= iFi }, {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextB= luetoothLE }, {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextH= ardDrive }, --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 09:11:05 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1500984783052945.1054660969468; Tue, 25 Jul 2017 05:13:03 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DC21321C9126B; Tue, 25 Jul 2017 05:10:52 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5017221C91264 for ; Tue, 25 Jul 2017 05:10:51 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 05:12:52 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.255.27.40]) by orsmga001.jf.intel.com with ESMTP; 25 Jul 2017 05:12:51 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,411,1496127600"; d="scan'208";a="1155145662" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 25 Jul 2017 20:12:44 +0800 Message-Id: <1500984765-8040-4-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> References: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 3/4] MdeModulePkg/UefiBootManagerLib: Support DNS device path description X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch is to update UEFI Boot manager to support DNS device path for HTTP(S) network boot. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c | 13 +++++++++= ++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/= MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c index 6e69a15..7647bac 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c @@ -385,12 +385,12 @@ BmGetNetworkDescription ( // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)] // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...) // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...) // // The HTTP device path is like: - // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)/Uri(...) - // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)/Uri(...) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(.= ..) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(.= ..) // while (!IsDevicePathEnd (DevicePath) && ((DevicePathType (DevicePath) !=3D MESSAGING_DEVICE_PATH) || (DevicePathSubType (DevicePath) !=3D MSG_MAC_ADDR_DP)) ) { @@ -435,10 +435,19 @@ BmGetNetworkDescription ( Ip =3D DevicePath; DevicePath =3D NextDevicePathNode (DevicePath); } else { Ip =3D NULL; } + =20 + // + // Skip the optional DNS node + // + if ((DevicePathType (DevicePath) =3D=3D MESSAGING_DEVICE_PATH) && + (DevicePathSubType (DevicePath) =3D=3D MSG_DNS_DP) + ) { + DevicePath =3D NextDevicePathNode (DevicePath); + } =20 // // Locate the URI node // if ((DevicePathType (DevicePath) =3D=3D MESSAGING_DEVICE_PATH) && --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 09:11:05 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1500984786077958.9747622582539; Tue, 25 Jul 2017 05:13:06 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 23F3321C9126A; Tue, 25 Jul 2017 05:10:55 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9800221C91269 for ; Tue, 25 Jul 2017 05:10:52 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 05:12:54 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.255.27.40]) by orsmga001.jf.intel.com with ESMTP; 25 Jul 2017 05:12:52 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,411,1496127600"; d="scan'208";a="1155145673" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Tue, 25 Jul 2017 20:12:45 +0800 Message-Id: <1500984765-8040-5-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> References: <1500984765-8040-1-git-send-email-jiaxin.wu@intel.com> Subject: [edk2] [Patch 4/4] NetworkPkg/HttpBootDxe: Update device path node to include DNS information X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/HttpBootDxe/HttpBootClient.c | 138 ++++++++++++++++++++++++++--= ---- NetworkPkg/HttpBootDxe/HttpBootDxe.h | 2 + NetworkPkg/HttpBootDxe/HttpBootImpl.c | 7 +- 3 files changed, 122 insertions(+), 25 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootD= xe/HttpBootClient.c index 68f5a49..5c87171 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootClient.c +++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c @@ -14,11 +14,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. **/ =20 #include "HttpBootDxe.h" =20 /** - Update the IP and URL device path node to include the boot resource info= rmation. + Update the device path node to include the boot resource information. =20 @param[in] Private The pointer to the driver's private dat= a. =20 @retval EFI_SUCCESS Device patch successfully updated. @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources. @@ -29,16 +29,18 @@ EFI_STATUS HttpBootUpdateDevicePath ( IN HTTP_BOOT_PRIVATE_DATA *Private ) { EFI_DEV_PATH *Node; - EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath; + EFI_DEVICE_PATH_PROTOCOL *TmpIpDevicePath; + EFI_DEVICE_PATH_PROTOCOL *TmpDnsDevicePath; EFI_DEVICE_PATH_PROTOCOL *NewDevicePath; UINTN Length; EFI_STATUS Status; =20 - TmpDevicePath =3D NULL; + TmpIpDevicePath =3D NULL; + TmpDnsDevicePath =3D NULL; =20 // // Update the IP node with DHCP assigned information. // if (!Private->UsingIpv6) { @@ -70,33 +72,69 @@ HttpBootUpdateDevicePath ( CopyMem (&Node->Ipv6.LocalIpAddress, &Private->StationIp.v6, sizeof (E= FI_IPv6_ADDRESS)); CopyMem (&Node->Ipv6.RemoteIpAddress, &Private->ServerIp.v6, sizeof (E= FI_IPv6_ADDRESS)); CopyMem (&Node->Ipv6.GatewayIpAddress, &Private->GatewayIp.v6, sizeof = (EFI_IPv6_ADDRESS)); } =20 - TmpDevicePath =3D AppendDevicePathNode (Private->ParentDevicePath, (EFI_= DEVICE_PATH_PROTOCOL*) Node); + TmpIpDevicePath =3D AppendDevicePathNode (Private->ParentDevicePath, (EF= I_DEVICE_PATH_PROTOCOL*) Node); FreePool (Node); - if (TmpDevicePath =3D=3D NULL) { + if (TmpIpDevicePath =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 // + // Update the DNS node with DNS server IP list if existed. + // + if (Private->DnsServerIp !=3D NULL) { + Length =3D sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv= 6) + Private->DnsServerCount * sizeof (EFI_IP_ADDRESS); + Node =3D AllocatePool (Length); + if (Node =3D=3D NULL) { + FreePool (TmpIpDevicePath); + return EFI_OUT_OF_RESOURCES; + } + Node->DevPath.Type =3D MESSAGING_DEVICE_PATH; + Node->DevPath.SubType =3D MSG_DNS_DP; + SetDevicePathNodeLength (Node, Length); + Node->Dns.IsIPv6 =3D Private->UsingIpv6 ? 0x01 : 0x00; + CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (N= ode->Dns.IsIPv6), Private->DnsServerIp, Private->DnsServerCount * sizeof (E= FI_IP_ADDRESS)); + =20 + TmpDnsDevicePath =3D AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVIC= E_PATH_PROTOCOL*) Node); + FreePool (Node); + FreePool (TmpIpDevicePath); + TmpIpDevicePath =3D NULL; + if (TmpDnsDevicePath =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + } + + // // Update the URI node with the boot file URI. // Length =3D sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (Private->Bo= otFileUri); Node =3D AllocatePool (Length); if (Node =3D=3D NULL) { - FreePool (TmpDevicePath); + if (TmpIpDevicePath !=3D NULL) { + FreePool (TmpIpDevicePath); + } + if (TmpDnsDevicePath !=3D NULL) { + FreePool (TmpDnsDevicePath); + } return EFI_OUT_OF_RESOURCES; } Node->DevPath.Type =3D MESSAGING_DEVICE_PATH; Node->DevPath.SubType =3D MSG_URI_DP; SetDevicePathNodeLength (Node, Length); CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), Private->Boo= tFileUri, AsciiStrSize (Private->BootFileUri)); - =20 - NewDevicePath =3D AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_= PROTOCOL*) Node); + + if (TmpDnsDevicePath !=3D NULL) { + NewDevicePath =3D AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_= PATH_PROTOCOL*) Node); + FreePool (TmpDnsDevicePath); + } else { + ASSERT (TmpIpDevicePath !=3D NULL); + NewDevicePath =3D AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_P= ATH_PROTOCOL*) Node); + FreePool (TmpIpDevicePath); + } FreePool (Node); - FreePool (TmpDevicePath); if (NewDevicePath =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 if (!Private->UsingIpv6) { @@ -151,18 +189,21 @@ HttpBootDhcp4ExtractUriInfo ( { HTTP_BOOT_DHCP4_PACKET_CACHE *SelectOffer; HTTP_BOOT_DHCP4_PACKET_CACHE *HttpOffer; UINT32 SelectIndex; UINT32 ProxyIndex; + UINT32 DnsServerIndex; EFI_DHCP4_PACKET_OPTION *Option; EFI_STATUS Status; =20 ASSERT (Private !=3D NULL); ASSERT (Private->SelectIndex !=3D 0); SelectIndex =3D Private->SelectIndex - 1; ASSERT (SelectIndex < HTTP_BOOT_OFFER_MAX_NUM); =20 + DnsServerIndex =3D 0; + =20 Status =3D EFI_SUCCESS; =20 // // SelectOffer contains the IP address configuration and name server con= figuration. // HttpOffer contains the boot file URL. @@ -198,24 +239,41 @@ HttpBootDhcp4ExtractUriInfo ( if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "HttpBootDhcp4ExtractUriInfo: %r.\n", Status)); return Status; } =20 - // - // Configure the default DNS server if server assigned. - // if ((SelectOffer->OfferType =3D=3D HttpOfferTypeDhcpNameUriDns) ||=20 (SelectOffer->OfferType =3D=3D HttpOfferTypeDhcpDns) || (SelectOffer->OfferType =3D=3D HttpOfferTypeDhcpIpUriDns)) { Option =3D SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER]; ASSERT (Option !=3D NULL); + + // + // Record the Dns Server address list. + // + Private->DnsServerCount =3D (Option->Length) / sizeof (EFI_IPv4_ADDRES= S); + + Private->DnsServerIp =3D AllocateZeroPool (Private->DnsServerCount * s= izeof (EFI_IP_ADDRESS)); + if (Private->DnsServerIp =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + for (DnsServerIndex =3D 0; DnsServerIndex < Private->DnsServerCount; D= nsServerIndex++) { + CopyMem (&(Private->DnsServerIp[DnsServerIndex].v4), &(((EFI_IPv4_AD= DRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv4_ADDRESS)); + } + =20 + // + // Configure the default DNS server if server assigned. + // =20 Status =3D HttpBootRegisterIp4Dns ( Private, Option->Length, Option->Data ); if (EFI_ERROR (Status)) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp =3D NULL; return Status; } } =20 // @@ -233,13 +291,17 @@ HttpBootDhcp4ExtractUriInfo ( // // All boot informations are valid here. // =20 // - // Update the device path to include the IP and boot URI information. + // Update the device path to include the boot resource information. // Status =3D HttpBootUpdateDevicePath (Private); + if (EFI_ERROR (Status) && Private->DnsServerIp !=3D NULL) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp =3D NULL; + } =20 return Status; } =20 /** @@ -258,10 +320,11 @@ HttpBootDhcp6ExtractUriInfo ( { HTTP_BOOT_DHCP6_PACKET_CACHE *SelectOffer; HTTP_BOOT_DHCP6_PACKET_CACHE *HttpOffer; UINT32 SelectIndex; UINT32 ProxyIndex; + UINT32 DnsServerIndex; EFI_DHCP6_PACKET_OPTION *Option; EFI_IPv6_ADDRESS IpAddr; CHAR8 *HostName; UINTN HostNameSize; CHAR16 *HostNameStr; @@ -270,10 +333,12 @@ HttpBootDhcp6ExtractUriInfo ( ASSERT (Private !=3D NULL); ASSERT (Private->SelectIndex !=3D 0); SelectIndex =3D Private->SelectIndex - 1; ASSERT (SelectIndex < HTTP_BOOT_OFFER_MAX_NUM); =20 + DnsServerIndex =3D 0; + Status =3D EFI_SUCCESS; HostName =3D NULL; // // SelectOffer contains the IP address configuration and name server con= figuration. // HttpOffer contains the boot file URL. @@ -324,26 +389,41 @@ HttpBootDhcp6ExtractUriInfo ( // Status =3D HttpBootSetIp6Gateway (Private); if (EFI_ERROR (Status)) { return Status; } - =20 - // - // Configure the default DNS server if server assigned. - // + if ((SelectOffer->OfferType =3D=3D HttpOfferTypeDhcpNameUriDns) ||=20 (SelectOffer->OfferType =3D=3D HttpOfferTypeDhcpDns) || (SelectOffer->OfferType =3D=3D HttpOfferTypeDhcpIpUriDns)) { Option =3D SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER]; ASSERT (Option !=3D NULL); + + // + // Record the Dns Server address list. + // + Private->DnsServerCount =3D HTONS (Option->OpLen) / sizeof (EFI_IPv6_A= DDRESS); + + Private->DnsServerIp =3D AllocateZeroPool (Private->DnsServerCount * s= izeof (EFI_IP_ADDRESS)); + if (Private->DnsServerIp =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + for (DnsServerIndex =3D 0; DnsServerIndex < Private->DnsServerCount; D= nsServerIndex++) { + CopyMem (&(Private->DnsServerIp[DnsServerIndex].v6), &(((EFI_IPv6_AD= DRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv6_ADDRESS)); + } + + // + // Configure the default DNS server if server assigned. + // Status =3D HttpBootSetIp6Dns ( Private, HTONS (Option->OpLen), Option->Data ); if (EFI_ERROR (Status)) { - return Status; + goto Error; } } =20 // // Extract the HTTP server Ip frome URL. This is used to Check route tab= le=20 @@ -363,21 +443,26 @@ HttpBootDhcp6ExtractUriInfo ( Private->BootFileUri, Private->BootFileUriParser, &HostName ); if (EFI_ERROR (Status)) { - return Status; + goto Error; } =20 HostNameSize =3D AsciiStrSize (HostName); HostNameStr =3D AllocateZeroPool (HostNameSize * sizeof (CHAR16)); if (HostNameStr =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; goto Error; } =20 AsciiStrToUnicodeStrS (HostName, HostNameStr, HostNameSize); + + if (HostName !=3D NULL) { + FreePool (HostName); + } + =20 Status =3D HttpBootDns (Private, HostNameStr, &IpAddr); FreePool (HostNameStr); if (EFI_ERROR (Status)) { goto Error; } =20 @@ -400,20 +485,25 @@ HttpBootDhcp6ExtractUriInfo ( // // All boot informations are valid here. // =20 // - // Update the device path to include the IP and boot URI information. + // Update the device path to include the boot resource information. // Status =3D HttpBootUpdateDevicePath (Private); + if (EFI_ERROR (Status)) { + goto Error; + } + =20 + return Status; =20 Error: - =20 - if (HostName !=3D NULL) { - FreePool (HostName); + if (Private->DnsServerIp !=3D NULL) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp =3D NULL; } - =20 + =20 return Status; } =20 =20 /** diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.h b/NetworkPkg/HttpBootDxe/= HttpBootDxe.h index 8d89b3e..aa4fc43 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDxe.h +++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.h @@ -196,10 +196,12 @@ struct _HTTP_BOOT_PRIVATE_DATA { EFI_IP_ADDRESS StationIp; EFI_IP_ADDRESS SubnetMask; EFI_IP_ADDRESS GatewayIp; EFI_IP_ADDRESS ServerIp; UINT16 Port; + UINT32 DnsServerCount; + EFI_IP_ADDRESS *DnsServerIp; =20 // // The URI string attempt to download through HTTP, may point to // the memory in cached DHCP offer, or to the memory in FilePathUri. // diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe= /HttpBootImpl.c index 63cf396..40f7356 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c @@ -1,9 +1,9 @@ /** @file The implementation of EFI_LOAD_FILE_PROTOCOL for UEFI HTTP boot. =20 -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made availabl= e under=20 the terms and conditions of the BSD License that accompanies this distribu= tion. =20 The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. = =20 @@ -463,10 +463,15 @@ HttpBootStop ( HttpUrlFreeParser (Private->OfferBuffer[Index].Dhcp6.UriParser); } } } =20 + if (Private->DnsServerIp !=3D NULL) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp =3D NULL; + } + if (Private->FilePathUri!=3D NULL) { FreePool (Private->FilePathUri); HttpUrlFreeParser (Private->FilePathUriParser); Private->FilePathUri =3D NULL; Private->FilePathUriParser =3D NULL; --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel