From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 02316210DF740 for ; Tue, 7 Aug 2018 20:38:03 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2018 20:38:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,456,1526367600"; d="scan'208";a="79842755" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 07 Aug 2018 20:38:00 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 7 Aug 2018 20:37:59 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.240]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.150]) with mapi id 14.03.0319.002; Wed, 8 Aug 2018 11:37:58 +0800 From: "Zhu, Yonghong" To: "Feng, YunhuaX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH] BaseTools: Add Dns and BluetoothLE DevicePath Thread-Index: AdQtWENt7IPVX1JGTPCaEtjdKnT0BABcO4nQ Date: Wed, 8 Aug 2018 03:37:58 +0000 Message-ID: References: <47C64442C08CCD4089DC43B6B5E46BC48AC7C0@shsmsx102.ccr.corp.intel.com> In-Reply-To: <47C64442C08CCD4089DC43B6B5E46BC48AC7C0@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Add Dns and BluetoothLE DevicePath X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2018 03:38:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Feng, YunhuaX=20 Sent: Monday, August 06, 2018 3:37 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming Subject: [PATCH] BaseTools: Add Dns and BluetoothLE DevicePath Add Dns and BluetoothLE for support DevicePath Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/DevicePath/DevicePathFromText.c | 127 +++++++++++++++++= ++++ 1 file changed, 127 insertions(+) diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools= /Source/C/DevicePath/DevicePathFromText.c index bfd91d23b5..bb74e2e170 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c @@ -2537,10 +2537,135 @@ DevPathFromTextWiFi ( =20 return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp; } =20 /** + Converts a text device path node to Bluetooth LE device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Bluetooth LE device path structur= e. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextBluetoothLE ( + IN CHAR16 *TextDeviceNode + ) +{ + CHAR16 *BluetoothLeAddrStr; + CHAR16 *BluetoothLeAddrTypeStr; + BLUETOOTH_LE_DEVICE_PATH *BluetoothLeDp; + + BluetoothLeAddrStr =3D GetNextParamStr (&TextDeviceNode); + BluetoothLeAddrTypeStr =3D GetNextParamStr (&TextDeviceNode); =20 + BluetoothLeDp =3D (BLUETOOTH_LE_DEVICE_PATH *) CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_BLUETOOTH_LE_DP, + (UINT16) sizeof (BLUETOOT= H_LE_DEVICE_PATH) + ); + + BluetoothLeDp->Address.Type =3D (UINT8) Strtoi=20 +(BluetoothLeAddrTypeStr); + StrHexToBytes ( + BluetoothLeAddrStr, sizeof (BluetoothLeDp->Address.Address) * 2, + BluetoothLeDp->Address.Address, sizeof (BluetoothLeDp->Address.Address= ) + ); + return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp; } + +/** + 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; + CHAR16 *DeviceNodeStrPtr; + UINT32 DnsServerIpCount; + UINT16 DnsDeviceNodeLength; + DNS_DEVICE_PATH *DnsDeviceNode; + UINT32 DnsServerIpIndex; + CHAR16 *DnsServerIp; + + + // + // Count the DNS server address number. + // + DeviceNodeStr =3D UefiDevicePathLibStrDuplicate (TextDeviceNode); if=20 + (DeviceNodeStr =3D=3D NULL) { + return NULL; + } + + DeviceNodeStrPtr =3D DeviceNodeStr; + + DnsServerIpCount =3D 0; + while (DeviceNodeStrPtr !=3D NULL && *DeviceNodeStrPtr !=3D L'\0') { + GetNextParamStr (&DeviceNodeStrPtr); + DnsServerIpCount ++; + } + + free (DeviceNodeStr); + DeviceNodeStr =3D NULL; + + // + // One or more instances of the DNS server address in EFI_IP_ADDRESS, =20 + // otherwise, NULL will be returned. + // + if (DnsServerIpCount =3D=3D 0) { + return NULL; + } + + // + // 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 + ); if (DnsDeviceNode =3D=3D= =20 + NULL) { + return NULL; + } + + // + // Confirm the DNS server address is IPv4 or IPv6 type. + // + DeviceNodeStrPtr =3D TextDeviceNode; + while (!IS_NULL (*DeviceNodeStrPtr)) { + if (*DeviceNodeStrPtr =3D=3D L'.') { + DnsDeviceNode->IsIPv6 =3D 0x00; + break; + } + + if (*DeviceNodeStrPtr =3D=3D L':') { + DnsDeviceNode->IsIPv6 =3D 0x01; + break; + } + + DeviceNodeStrPtr++; + } + + 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); + } + } + + 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. @@ -3209,13 +3334,15 @@ DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevPa= thFromTextTable[] =3D { {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 }, {L"HD", DevPathFromTextHD }, {L"CDROM", DevPathFromTextCDROM }, {L"VenMedia", DevPathFromTextVenMedia }, {L"Media", DevPathFromTextMedia }, -- 2.12.2.windows.2