* [Patch 0/4] Add DNS device path node @ 2017-07-25 12:12 Jiaxin Wu 2017-07-25 12:12 ` [Patch 1/4] MdePkg/DevicePath.h: Add DNS Device Path definition Jiaxin Wu ` (4 more replies) 0 siblings, 5 replies; 11+ messages in thread From: Jiaxin Wu @ 2017-07-25 12:12 UTC (permalink / raw) To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin The series patches implement the DNS device path node according the UEFI Spec 2.7, section 10.3.5.30. Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Jiaxin Wu (4): MdePkg/DevicePath.h: Add DNS Device Path definition MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries MdeModulePkg/UefiBootManagerLib: Support DNS device path description NetworkPkg/HttpBootDxe: Update device path node to include DNS information .../Library/UefiBootManagerLib/BmBootDescription.c | 13 +- MdePkg/Include/Protocol/DevicePath.h | 18 +++ .../Library/UefiDevicePathLib/DevicePathFromText.c | 72 +++++++++++ .../Library/UefiDevicePathLib/DevicePathToText.c | 46 +++++++ NetworkPkg/HttpBootDxe/HttpBootClient.c | 138 +++++++++++++++++---- NetworkPkg/HttpBootDxe/HttpBootDxe.h | 2 + NetworkPkg/HttpBootDxe/HttpBootImpl.c | 7 +- 7 files changed, 269 insertions(+), 27 deletions(-) -- 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Patch 1/4] MdePkg/DevicePath.h: Add DNS Device Path definition 2017-07-25 12:12 [Patch 0/4] Add DNS device path node Jiaxin Wu @ 2017-07-25 12:12 ` Jiaxin Wu 2017-07-25 12:12 ` [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries Jiaxin Wu ` (3 subsequent siblings) 4 siblings, 0 replies; 11+ messages in thread From: Jiaxin Wu @ 2017-07-25 12:12 UTC (permalink / raw) To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin This patch adds the DNS device path node definition. Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> --- 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; /// +/// 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; 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; -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries 2017-07-25 12:12 [Patch 0/4] Add DNS device path node Jiaxin Wu 2017-07-25 12:12 ` [Patch 1/4] MdePkg/DevicePath.h: Add DNS Device Path definition Jiaxin Wu @ 2017-07-25 12:12 ` Jiaxin Wu 2017-07-26 0:42 ` Fu, Siyuan 2017-07-25 12:12 ` [Patch 3/4] MdeModulePkg/UefiBootManagerLib: Support DNS device path description Jiaxin Wu ` (2 subsequent siblings) 4 siblings, 1 reply; 11+ messages in thread From: Jiaxin Wu @ 2017-07-25 12:12 UTC (permalink / raw) To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> --- .../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; } /** + 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 = TextDeviceNode; + DnsServerIpCount = 0; + while (DeviceNodeStr != NULL) { + GetNextParamStr (&DeviceNodeStr); + DnsServerIpCount ++; + } + + // + // Create the DNS DeviceNode. + // + DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS)); + DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_DNS_DP, + DnsDeviceNodeLength + ); + + // + // Confirm the DNS server address is IPv4 or IPv6 type. + // + DeviceNodeStr = TextDeviceNode; + while (!IS_NULL (*DeviceNodeStr)) { + if (*DeviceNodeStr == L'.') { + DnsDeviceNode->IsIPv6 = 0x00; + break; + } + + if (*DeviceNodeStr == L':') { + DnsDeviceNode->IsIPv6 = 0x01; + break; + } + + DeviceNodeStr++; + } + + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) { + DnsServerIp = GetNextParamStr (&TextDeviceNode); + if (DnsDeviceNode->IsIPv6 == 0x00) { + StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v4), NULL); + } else { + StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v6), NULL); + } + } + + return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode; +} + +/** Converts a text device path node to URI device path structure. @param TextDeviceNode The input Text device path node. @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/Library/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 ); } /** + 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 representation + 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 forms of text + representation for a device node can be used, where 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 = DevPath; + DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP_ADDRESS); + + UefiDevicePathLibCatPrint (Str, L"Dns("); + + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) { + if (DnsDevPath->IsIPv6 == 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. @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 representation @@ -2223,10 +2268,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand }, {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart }, {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor }, {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI }, {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan }, + {MESSAGING_DEVICE_PATH, MSG_DNS_DP, DevPathToTextDns }, {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri }, {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth }, {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi }, {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE }, {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive }, -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries 2017-07-25 12:12 ` [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries Jiaxin Wu @ 2017-07-26 0:42 ` Fu, Siyuan 2017-07-26 2:08 ` Wu, Jiaxin 0 siblings, 1 reply; 11+ messages in thread From: Fu, Siyuan @ 2017-07-26 0:42 UTC (permalink / raw) To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting Hi, Jiaxin Is an empty DNS text node a valid representation, like "Dns()"? Can below code handle such kind of input string? + DeviceNodeStr = TextDeviceNode; + DnsServerIpCount = 0; + while (DeviceNodeStr != NULL) { + GetNextParamStr (&DeviceNodeStr); + DnsServerIpCount ++; + } Best Regards, Siyuan -----Original Message----- From: Wu, Jiaxin Sent: Tuesday, July 25, 2017 8:13 PM To: edk2-devel@lists.01.org Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com> Subject: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> --- .../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; } /** + 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 = TextDeviceNode; + DnsServerIpCount = 0; + while (DeviceNodeStr != NULL) { + GetNextParamStr (&DeviceNodeStr); + DnsServerIpCount ++; + } + + // + // Create the DNS DeviceNode. + // + DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS)); + DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_DNS_DP, + DnsDeviceNodeLength + ); + + // + // Confirm the DNS server address is IPv4 or IPv6 type. + // + DeviceNodeStr = TextDeviceNode; + while (!IS_NULL (*DeviceNodeStr)) { + if (*DeviceNodeStr == L'.') { + DnsDeviceNode->IsIPv6 = 0x00; + break; + } + + if (*DeviceNodeStr == L':') { + DnsDeviceNode->IsIPv6 = 0x01; + break; + } + + DeviceNodeStr++; + } + + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) { + DnsServerIp = GetNextParamStr (&TextDeviceNode); + if (DnsDeviceNode->IsIPv6 == 0x00) { + StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v4), NULL); + } else { + StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v6), NULL); + } + } + + return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode; +} + +/** Converts a text device path node to URI device path structure. @param TextDeviceNode The input Text device path node. @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/Library/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 ); } /** + 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 representation + 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 forms of text + representation for a device node can be used, where 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 = DevPath; + DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP_ADDRESS); + + UefiDevicePathLibCatPrint (Str, L"Dns("); + + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) { + if (DnsDevPath->IsIPv6 == 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. @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 representation @@ -2223,10 +2268,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, DevPathToTextInfiniBand }, {MESSAGING_DEVICE_PATH, MSG_UART_DP, DevPathToTextUart }, {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, DevPathToTextVendor }, {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, DevPathToTextiSCSI }, {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, DevPathToTextVlan }, + {MESSAGING_DEVICE_PATH, MSG_DNS_DP, DevPathToTextDns }, {MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri }, {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth }, {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi }, {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE }, {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive }, -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries 2017-07-26 0:42 ` Fu, Siyuan @ 2017-07-26 2:08 ` Wu, Jiaxin 2017-07-26 2:12 ` Fu, Siyuan 0 siblings, 1 reply; 11+ messages in thread From: Wu, Jiaxin @ 2017-07-26 2:08 UTC (permalink / raw) To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting Hi Siyuan, For DevPathFromTextDns(), it's impossible to input the string with "Dns()". The input param is in pair of parentheses follow the given node name. For example, given the "Dns(192.168.10.12,192.168.10.16)" and NodeName "Dns", the param is "192.168.10.12,192.168.10.16". We can check the detailed implementation from UefiDevicePathLibConvertTextToDeviceNode() function. Thanks, Jiaxin > -----Original Message----- > From: Fu, Siyuan > Sent: Wednesday, July 26, 2017 8:43 AM > To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com> > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > DevPathFromTextDns and DevPathToTextDns libraries > > Hi, Jiaxin > > Is an empty DNS text node a valid representation, like "Dns()"? > Can below code handle such kind of input string? > > + DeviceNodeStr = TextDeviceNode; > + DnsServerIpCount = 0; > + while (DeviceNodeStr != NULL) { > + GetNextParamStr (&DeviceNodeStr); > + DnsServerIpCount ++; > + } > > Best Regards, > Siyuan > > -----Original Message----- > From: Wu, Jiaxin > Sent: Tuesday, July 25, 2017 8:13 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, > Jiaxin <jiaxin.wu@intel.com> > Subject: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns > and DevPathToTextDns libraries > > Cc: Ye Ting <ting.ye@intel.com> > Cc: Fu Siyuan <siyuan.fu@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> > --- > .../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; > } > > /** > + 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 = TextDeviceNode; > + DnsServerIpCount = 0; > + while (DeviceNodeStr != NULL) { > + GetNextParamStr (&DeviceNodeStr); > + DnsServerIpCount ++; > + } > + > + // > + // Create the DNS DeviceNode. > + // > + DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) > + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS)); > + DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode ( > + MESSAGING_DEVICE_PATH, > + MSG_DNS_DP, > + DnsDeviceNodeLength > + ); > + > + // > + // Confirm the DNS server address is IPv4 or IPv6 type. > + // > + DeviceNodeStr = TextDeviceNode; > + while (!IS_NULL (*DeviceNodeStr)) { > + if (*DeviceNodeStr == L'.') { > + DnsDeviceNode->IsIPv6 = 0x00; > + break; > + } > + > + if (*DeviceNodeStr == L':') { > + DnsDeviceNode->IsIPv6 = 0x01; > + break; > + } > + > + DeviceNodeStr++; > + } > + > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > DnsServerIpIndex++) { > + DnsServerIp = GetNextParamStr (&TextDeviceNode); > + if (DnsDeviceNode->IsIPv6 == 0x00) { > + StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode- > >DnsServerIp[DnsServerIpIndex].v4), NULL); > + } else { > + StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode- > >DnsServerIp[DnsServerIpIndex].v6), NULL); > + } > + } > + > + return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode; > +} > + > +/** > Converts a text device path node to URI device path structure. > > @param TextDeviceNode The input Text device path node. > > @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/Library/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 > ); > } > > /** > + 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 > representation > + 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 > forms of text > + representation for a device node can be used, where > 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 = DevPath; > + DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - > sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / > sizeof (EFI_IP_ADDRESS); > + > + UefiDevicePathLibCatPrint (Str, L"Dns("); > + > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > DnsServerIpIndex++) { > + if (DnsDevPath->IsIPv6 == 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. > > @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 > representation > @@ -2223,10 +2268,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const > DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib > {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, > DevPathToTextInfiniBand }, > {MESSAGING_DEVICE_PATH, MSG_UART_DP, > DevPathToTextUart }, > {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, > DevPathToTextVendor }, > {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, > DevPathToTextiSCSI }, > {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, > DevPathToTextVlan }, > + {MESSAGING_DEVICE_PATH, MSG_DNS_DP, > DevPathToTextDns }, > {MESSAGING_DEVICE_PATH, MSG_URI_DP, > DevPathToTextUri }, > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, > DevPathToTextBluetooth }, > {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, > DevPathToTextWiFi }, > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, > DevPathToTextBluetoothLE }, > {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, > DevPathToTextHardDrive }, > -- > 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries 2017-07-26 2:08 ` Wu, Jiaxin @ 2017-07-26 2:12 ` Fu, Siyuan 2017-07-26 2:29 ` Wu, Jiaxin 2017-07-26 3:00 ` Wu, Jiaxin 0 siblings, 2 replies; 11+ messages in thread From: Fu, Siyuan @ 2017-07-26 2:12 UTC (permalink / raw) To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting Jiaxin, If "Dns()" is not a valid test represent device path node, I think DevPathFromTextDns() should return an error code for this. Best Regards, Siyuan -----Original Message----- From: Wu, Jiaxin Sent: Wednesday, July 26, 2017 10:08 AM To: Fu, Siyuan <siyuan.fu@intel.com>; edk2-devel@lists.01.org Cc: Ye, Ting <ting.ye@intel.com> Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries Hi Siyuan, For DevPathFromTextDns(), it's impossible to input the string with "Dns()". The input param is in pair of parentheses follow the given node name. For example, given the "Dns(192.168.10.12,192.168.10.16)" and NodeName "Dns", the param is "192.168.10.12,192.168.10.16". We can check the detailed implementation from UefiDevicePathLibConvertTextToDeviceNode() function. Thanks, Jiaxin > -----Original Message----- > From: Fu, Siyuan > Sent: Wednesday, July 26, 2017 8:43 AM > To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com> > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > DevPathFromTextDns and DevPathToTextDns libraries > > Hi, Jiaxin > > Is an empty DNS text node a valid representation, like "Dns()"? > Can below code handle such kind of input string? > > + DeviceNodeStr = TextDeviceNode; > + DnsServerIpCount = 0; > + while (DeviceNodeStr != NULL) { > + GetNextParamStr (&DeviceNodeStr); > + DnsServerIpCount ++; > + } > > Best Regards, > Siyuan > > -----Original Message----- > From: Wu, Jiaxin > Sent: Tuesday, July 25, 2017 8:13 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, > Jiaxin <jiaxin.wu@intel.com> > Subject: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns > and DevPathToTextDns libraries > > Cc: Ye Ting <ting.ye@intel.com> > Cc: Fu Siyuan <siyuan.fu@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> > --- > .../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; > } > > /** > + 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 = TextDeviceNode; > + DnsServerIpCount = 0; > + while (DeviceNodeStr != NULL) { > + GetNextParamStr (&DeviceNodeStr); > + DnsServerIpCount ++; > + } > + > + // > + // Create the DNS DeviceNode. > + // > + DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) > + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS)); > + DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode ( > + MESSAGING_DEVICE_PATH, > + MSG_DNS_DP, > + DnsDeviceNodeLength > + ); > + > + // > + // Confirm the DNS server address is IPv4 or IPv6 type. > + // > + DeviceNodeStr = TextDeviceNode; > + while (!IS_NULL (*DeviceNodeStr)) { > + if (*DeviceNodeStr == L'.') { > + DnsDeviceNode->IsIPv6 = 0x00; > + break; > + } > + > + if (*DeviceNodeStr == L':') { > + DnsDeviceNode->IsIPv6 = 0x01; > + break; > + } > + > + DeviceNodeStr++; > + } > + > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > DnsServerIpIndex++) { > + DnsServerIp = GetNextParamStr (&TextDeviceNode); > + if (DnsDeviceNode->IsIPv6 == 0x00) { > + StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode- > >DnsServerIp[DnsServerIpIndex].v4), NULL); > + } else { > + StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode- > >DnsServerIp[DnsServerIpIndex].v6), NULL); > + } > + } > + > + return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode; > +} > + > +/** > Converts a text device path node to URI device path structure. > > @param TextDeviceNode The input Text device path node. > > @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/Library/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 > ); > } > > /** > + 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 > representation > + 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 > forms of text > + representation for a device node can be used, where > 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 = DevPath; > + DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - > sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / > sizeof (EFI_IP_ADDRESS); > + > + UefiDevicePathLibCatPrint (Str, L"Dns("); > + > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > DnsServerIpIndex++) { > + if (DnsDevPath->IsIPv6 == 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. > > @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 > representation > @@ -2223,10 +2268,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const > DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib > {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, > DevPathToTextInfiniBand }, > {MESSAGING_DEVICE_PATH, MSG_UART_DP, > DevPathToTextUart }, > {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, > DevPathToTextVendor }, > {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, > DevPathToTextiSCSI }, > {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, > DevPathToTextVlan }, > + {MESSAGING_DEVICE_PATH, MSG_DNS_DP, > DevPathToTextDns }, > {MESSAGING_DEVICE_PATH, MSG_URI_DP, > DevPathToTextUri }, > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, > DevPathToTextBluetooth }, > {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, > DevPathToTextWiFi }, > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, > DevPathToTextBluetoothLE }, > {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, > DevPathToTextHardDrive }, > -- > 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries 2017-07-26 2:12 ` Fu, Siyuan @ 2017-07-26 2:29 ` Wu, Jiaxin 2017-07-26 3:00 ` Wu, Jiaxin 1 sibling, 0 replies; 11+ messages in thread From: Wu, Jiaxin @ 2017-07-26 2:29 UTC (permalink / raw) To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting Siyuan, I mean the string of Dns() can't be input as param and the library is inner function of UefiDevicePathLibConvertTextToDeviceNode(). So, the error code for such string looks weird. Moreover, other libraries also don't have such check (e.g. DevPathFromTextIPv4/ DevPathFromTextVlan/...). What do you think? Thanks, Jiaxin > -----Original Message----- > From: Fu, Siyuan > Sent: Wednesday, July 26, 2017 10:13 AM > To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com> > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > DevPathFromTextDns and DevPathToTextDns libraries > > Jiaxin, > > If "Dns()" is not a valid test represent device path node, I think > DevPathFromTextDns() should return an error code for this. > > Best Regards, > Siyuan > > -----Original Message----- > From: Wu, Jiaxin > Sent: Wednesday, July 26, 2017 10:08 AM > To: Fu, Siyuan <siyuan.fu@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com> > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > DevPathFromTextDns and DevPathToTextDns libraries > > Hi Siyuan, > > For DevPathFromTextDns(), it's impossible to input the string with "Dns()". > The input param is in pair of parentheses follow the given node name. > > For example, given the "Dns(192.168.10.12,192.168.10.16)" and NodeName > "Dns", the param is "192.168.10.12,192.168.10.16". > > We can check the detailed implementation from > UefiDevicePathLibConvertTextToDeviceNode() function. > > > Thanks, > Jiaxin > > > -----Original Message----- > > From: Fu, Siyuan > > Sent: Wednesday, July 26, 2017 8:43 AM > > To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org > > Cc: Ye, Ting <ting.ye@intel.com> > > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > > DevPathFromTextDns and DevPathToTextDns libraries > > > > Hi, Jiaxin > > > > Is an empty DNS text node a valid representation, like "Dns()"? > > Can below code handle such kind of input string? > > > > + DeviceNodeStr = TextDeviceNode; > > + DnsServerIpCount = 0; > > + while (DeviceNodeStr != NULL) { > > + GetNextParamStr (&DeviceNodeStr); > > + DnsServerIpCount ++; > > + } > > > > Best Regards, > > Siyuan > > > > -----Original Message----- > > From: Wu, Jiaxin > > Sent: Tuesday, July 25, 2017 8:13 PM > > To: edk2-devel@lists.01.org > > Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, > > Jiaxin <jiaxin.wu@intel.com> > > Subject: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > DevPathFromTextDns > > and DevPathToTextDns libraries > > > > Cc: Ye Ting <ting.ye@intel.com> > > Cc: Fu Siyuan <siyuan.fu@intel.com> > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> > > --- > > .../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; > > } > > > > /** > > + 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 = TextDeviceNode; > > + DnsServerIpCount = 0; > > + while (DeviceNodeStr != NULL) { > > + GetNextParamStr (&DeviceNodeStr); > > + DnsServerIpCount ++; > > + } > > + > > + // > > + // Create the DNS DeviceNode. > > + // > > + DnsDeviceNodeLength = (UINT16) (sizeof > (EFI_DEVICE_PATH_PROTOCOL) > > + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS)); > > + DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode ( > > + MESSAGING_DEVICE_PATH, > > + MSG_DNS_DP, > > + DnsDeviceNodeLength > > + ); > > + > > + // > > + // Confirm the DNS server address is IPv4 or IPv6 type. > > + // > > + DeviceNodeStr = TextDeviceNode; > > + while (!IS_NULL (*DeviceNodeStr)) { > > + if (*DeviceNodeStr == L'.') { > > + DnsDeviceNode->IsIPv6 = 0x00; > > + break; > > + } > > + > > + if (*DeviceNodeStr == L':') { > > + DnsDeviceNode->IsIPv6 = 0x01; > > + break; > > + } > > + > > + DeviceNodeStr++; > > + } > > + > > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > > DnsServerIpIndex++) { > > + DnsServerIp = GetNextParamStr (&TextDeviceNode); > > + if (DnsDeviceNode->IsIPv6 == 0x00) { > > + StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode- > > >DnsServerIp[DnsServerIpIndex].v4), NULL); > > + } else { > > + StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode- > > >DnsServerIp[DnsServerIpIndex].v6), NULL); > > + } > > + } > > + > > + return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode; > > +} > > + > > +/** > > Converts a text device path node to URI device path structure. > > > > @param TextDeviceNode The input Text device path node. > > > > @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/Library/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 > > ); > > } > > > > /** > > + 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 > > representation > > + 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 > > forms of text > > + representation for a device node can be used, where > > 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 = DevPath; > > + DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - > > sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / > > sizeof (EFI_IP_ADDRESS); > > + > > + UefiDevicePathLibCatPrint (Str, L"Dns("); > > + > > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > > DnsServerIpIndex++) { > > + if (DnsDevPath->IsIPv6 == 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. > > > > @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 > > representation > > @@ -2223,10 +2268,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const > > DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib > > {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, > > DevPathToTextInfiniBand }, > > {MESSAGING_DEVICE_PATH, MSG_UART_DP, > > DevPathToTextUart }, > > {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, > > DevPathToTextVendor }, > > {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, > > DevPathToTextiSCSI }, > > {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, > > DevPathToTextVlan }, > > + {MESSAGING_DEVICE_PATH, MSG_DNS_DP, > > DevPathToTextDns }, > > {MESSAGING_DEVICE_PATH, MSG_URI_DP, > > DevPathToTextUri }, > > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, > > DevPathToTextBluetooth }, > > {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, > > DevPathToTextWiFi }, > > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, > > DevPathToTextBluetoothLE }, > > {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, > > DevPathToTextHardDrive }, > > -- > > 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries 2017-07-26 2:12 ` Fu, Siyuan 2017-07-26 2:29 ` Wu, Jiaxin @ 2017-07-26 3:00 ` Wu, Jiaxin 1 sibling, 0 replies; 11+ messages in thread From: Wu, Jiaxin @ 2017-07-26 3:00 UTC (permalink / raw) To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting After talk with Siyuan, I agree with the update to handle Dns() case since the input is 0, not NULL of UefiDevicePathLibConvertTextToDeviceNode(). Thanks the comments! Jiaxin > -----Original Message----- > From: Wu, Jiaxin > Sent: Wednesday, July 26, 2017 10:29 AM > To: Fu, Siyuan <siyuan.fu@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com> > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > DevPathFromTextDns and DevPathToTextDns libraries > > Siyuan, > > I mean the string of Dns() can't be input as param and the library is inner > function of UefiDevicePathLibConvertTextToDeviceNode(). So, the error > code for such string looks weird. Moreover, other libraries also don't have > such check (e.g. DevPathFromTextIPv4/ DevPathFromTextVlan/...). > > What do you think? > > Thanks, > Jiaxin > > > -----Original Message----- > > From: Fu, Siyuan > > Sent: Wednesday, July 26, 2017 10:13 AM > > To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org > > Cc: Ye, Ting <ting.ye@intel.com> > > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > > DevPathFromTextDns and DevPathToTextDns libraries > > > > Jiaxin, > > > > If "Dns()" is not a valid test represent device path node, I think > > DevPathFromTextDns() should return an error code for this. > > > > Best Regards, > > Siyuan > > > > -----Original Message----- > > From: Wu, Jiaxin > > Sent: Wednesday, July 26, 2017 10:08 AM > > To: Fu, Siyuan <siyuan.fu@intel.com>; edk2-devel@lists.01.org > > Cc: Ye, Ting <ting.ye@intel.com> > > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > > DevPathFromTextDns and DevPathToTextDns libraries > > > > Hi Siyuan, > > > > For DevPathFromTextDns(), it's impossible to input the string with "Dns()". > > The input param is in pair of parentheses follow the given node name. > > > > For example, given the "Dns(192.168.10.12,192.168.10.16)" and NodeName > > "Dns", the param is "192.168.10.12,192.168.10.16". > > > > We can check the detailed implementation from > > UefiDevicePathLibConvertTextToDeviceNode() function. > > > > > > Thanks, > > Jiaxin > > > > > -----Original Message----- > > > From: Fu, Siyuan > > > Sent: Wednesday, July 26, 2017 8:43 AM > > > To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org > > > Cc: Ye, Ting <ting.ye@intel.com> > > > Subject: RE: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > > > DevPathFromTextDns and DevPathToTextDns libraries > > > > > > Hi, Jiaxin > > > > > > Is an empty DNS text node a valid representation, like "Dns()"? > > > Can below code handle such kind of input string? > > > > > > + DeviceNodeStr = TextDeviceNode; > > > + DnsServerIpCount = 0; > > > + while (DeviceNodeStr != NULL) { > > > + GetNextParamStr (&DeviceNodeStr); > > > + DnsServerIpCount ++; > > > + } > > > > > > Best Regards, > > > Siyuan > > > > > > -----Original Message----- > > > From: Wu, Jiaxin > > > Sent: Tuesday, July 25, 2017 8:13 PM > > > To: edk2-devel@lists.01.org > > > Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, > > > Jiaxin <jiaxin.wu@intel.com> > > > Subject: [Patch 2/4] MdePkg/UefiDevicePathLib: Add > > DevPathFromTextDns > > > and DevPathToTextDns libraries > > > > > > Cc: Ye Ting <ting.ye@intel.com> > > > Cc: Fu Siyuan <siyuan.fu@intel.com> > > > Contributed-under: TianoCore Contribution Agreement 1.0 > > > Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> > > > --- > > > .../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; > > > } > > > > > > /** > > > + 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 = TextDeviceNode; > > > + DnsServerIpCount = 0; > > > + while (DeviceNodeStr != NULL) { > > > + GetNextParamStr (&DeviceNodeStr); > > > + DnsServerIpCount ++; > > > + } > > > + > > > + // > > > + // Create the DNS DeviceNode. > > > + // > > > + DnsDeviceNodeLength = (UINT16) (sizeof > > (EFI_DEVICE_PATH_PROTOCOL) > > > + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS)); > > > + DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode ( > > > + MESSAGING_DEVICE_PATH, > > > + MSG_DNS_DP, > > > + DnsDeviceNodeLength > > > + ); > > > + > > > + // > > > + // Confirm the DNS server address is IPv4 or IPv6 type. > > > + // > > > + DeviceNodeStr = TextDeviceNode; > > > + while (!IS_NULL (*DeviceNodeStr)) { > > > + if (*DeviceNodeStr == L'.') { > > > + DnsDeviceNode->IsIPv6 = 0x00; > > > + break; > > > + } > > > + > > > + if (*DeviceNodeStr == L':') { > > > + DnsDeviceNode->IsIPv6 = 0x01; > > > + break; > > > + } > > > + > > > + DeviceNodeStr++; > > > + } > > > + > > > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > > > DnsServerIpIndex++) { > > > + DnsServerIp = GetNextParamStr (&TextDeviceNode); > > > + if (DnsDeviceNode->IsIPv6 == 0x00) { > > > + StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode- > > > >DnsServerIp[DnsServerIpIndex].v4), NULL); > > > + } else { > > > + StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode- > > > >DnsServerIp[DnsServerIpIndex].v6), NULL); > > > + } > > > + } > > > + > > > + return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode; > > > +} > > > + > > > +/** > > > Converts a text device path node to URI device path structure. > > > > > > @param TextDeviceNode The input Text device path node. > > > > > > @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/Library/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 > > > ); > > > } > > > > > > /** > > > + 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 > > > representation > > > + 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 > > > forms of text > > > + representation for a device node can be used, where > > > 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 = DevPath; > > > + DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - > > > sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / > > > sizeof (EFI_IP_ADDRESS); > > > + > > > + UefiDevicePathLibCatPrint (Str, L"Dns("); > > > + > > > + for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; > > > DnsServerIpIndex++) { > > > + if (DnsDevPath->IsIPv6 == 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. > > > > > > @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 > > > representation > > > @@ -2223,10 +2268,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const > > > DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib > > > {MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, > > > DevPathToTextInfiniBand }, > > > {MESSAGING_DEVICE_PATH, MSG_UART_DP, > > > DevPathToTextUart }, > > > {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, > > > DevPathToTextVendor }, > > > {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, > > > DevPathToTextiSCSI }, > > > {MESSAGING_DEVICE_PATH, MSG_VLAN_DP, > > > DevPathToTextVlan }, > > > + {MESSAGING_DEVICE_PATH, MSG_DNS_DP, > > > DevPathToTextDns }, > > > {MESSAGING_DEVICE_PATH, MSG_URI_DP, > > > DevPathToTextUri }, > > > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, > > > DevPathToTextBluetooth }, > > > {MESSAGING_DEVICE_PATH, MSG_WIFI_DP, > > > DevPathToTextWiFi }, > > > {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, > > > DevPathToTextBluetoothLE }, > > > {MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, > > > DevPathToTextHardDrive }, > > > -- > > > 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Patch 3/4] MdeModulePkg/UefiBootManagerLib: Support DNS device path description 2017-07-25 12:12 [Patch 0/4] Add DNS device path node Jiaxin Wu 2017-07-25 12:12 ` [Patch 1/4] MdePkg/DevicePath.h: Add DNS Device Path definition Jiaxin Wu 2017-07-25 12:12 ` [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries Jiaxin Wu @ 2017-07-25 12:12 ` Jiaxin Wu 2017-07-25 12:12 ` [Patch 4/4] NetworkPkg/HttpBootDxe: Update device path node to include DNS information Jiaxin Wu 2017-08-14 3:28 ` [Patch 0/4] Add DNS device path node Ye, Ting 4 siblings, 0 replies; 11+ messages in thread From: Jiaxin Wu @ 2017-07-25 12:12 UTC (permalink / raw) To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin This patch is to update UEFI Boot manager to support DNS device path for HTTP(S) network boot. Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> --- 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) != MESSAGING_DEVICE_PATH) || (DevicePathSubType (DevicePath) != MSG_MAC_ADDR_DP)) ) { @@ -435,10 +435,19 @@ BmGetNetworkDescription ( Ip = DevicePath; DevicePath = NextDevicePathNode (DevicePath); } else { Ip = NULL; } + + // + // Skip the optional DNS node + // + if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) && + (DevicePathSubType (DevicePath) == MSG_DNS_DP) + ) { + DevicePath = NextDevicePathNode (DevicePath); + } // // Locate the URI node // if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) && -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Patch 4/4] NetworkPkg/HttpBootDxe: Update device path node to include DNS information 2017-07-25 12:12 [Patch 0/4] Add DNS device path node Jiaxin Wu ` (2 preceding siblings ...) 2017-07-25 12:12 ` [Patch 3/4] MdeModulePkg/UefiBootManagerLib: Support DNS device path description Jiaxin Wu @ 2017-07-25 12:12 ` Jiaxin Wu 2017-08-14 3:28 ` [Patch 0/4] Add DNS device path node Ye, Ting 4 siblings, 0 replies; 11+ messages in thread From: Jiaxin Wu @ 2017-07-25 12:12 UTC (permalink / raw) To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Jiaxin Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> --- 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/HttpBootDxe/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, EITHER EXPRESS OR IMPLIED. **/ #include "HttpBootDxe.h" /** - Update the IP and URL device path node to include the boot resource information. + Update the device path node to include the boot resource information. @param[in] Private The pointer to the driver's private data. @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; - TmpDevicePath = NULL; + TmpIpDevicePath = NULL; + TmpDnsDevicePath = NULL; // // Update the IP node with DHCP assigned information. // if (!Private->UsingIpv6) { @@ -70,33 +72,69 @@ HttpBootUpdateDevicePath ( CopyMem (&Node->Ipv6.LocalIpAddress, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Node->Ipv6.RemoteIpAddress, &Private->ServerIp.v6, sizeof (EFI_IPv6_ADDRESS)); CopyMem (&Node->Ipv6.GatewayIpAddress, &Private->GatewayIp.v6, sizeof (EFI_IPv6_ADDRESS)); } - TmpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); + TmpIpDevicePath = AppendDevicePathNode (Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); FreePool (Node); - if (TmpDevicePath == NULL) { + if (TmpIpDevicePath == NULL) { return EFI_OUT_OF_RESOURCES; } // + // Update the DNS node with DNS server IP list if existed. + // + if (Private->DnsServerIp != NULL) { + Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6) + Private->DnsServerCount * sizeof (EFI_IP_ADDRESS); + Node = AllocatePool (Length); + if (Node == NULL) { + FreePool (TmpIpDevicePath); + return EFI_OUT_OF_RESOURCES; + } + Node->DevPath.Type = MESSAGING_DEVICE_PATH; + Node->DevPath.SubType = MSG_DNS_DP; + SetDevicePathNodeLength (Node, Length); + Node->Dns.IsIPv6 = Private->UsingIpv6 ? 0x01 : 0x00; + CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (Node->Dns.IsIPv6), Private->DnsServerIp, Private->DnsServerCount * sizeof (EFI_IP_ADDRESS)); + + TmpDnsDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); + FreePool (Node); + FreePool (TmpIpDevicePath); + TmpIpDevicePath = NULL; + if (TmpDnsDevicePath == NULL) { + return EFI_OUT_OF_RESOURCES; + } + } + + // // Update the URI node with the boot file URI. // Length = sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiStrSize (Private->BootFileUri); Node = AllocatePool (Length); if (Node == NULL) { - FreePool (TmpDevicePath); + if (TmpIpDevicePath != NULL) { + FreePool (TmpIpDevicePath); + } + if (TmpDnsDevicePath != NULL) { + FreePool (TmpDnsDevicePath); + } return EFI_OUT_OF_RESOURCES; } Node->DevPath.Type = MESSAGING_DEVICE_PATH; Node->DevPath.SubType = MSG_URI_DP; SetDevicePathNodeLength (Node, Length); CopyMem ((UINT8*) Node + sizeof (EFI_DEVICE_PATH_PROTOCOL), Private->BootFileUri, AsciiStrSize (Private->BootFileUri)); - - NewDevicePath = AppendDevicePathNode (TmpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); + + if (TmpDnsDevicePath != NULL) { + NewDevicePath = AppendDevicePathNode (TmpDnsDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); + FreePool (TmpDnsDevicePath); + } else { + ASSERT (TmpIpDevicePath != NULL); + NewDevicePath = AppendDevicePathNode (TmpIpDevicePath, (EFI_DEVICE_PATH_PROTOCOL*) Node); + FreePool (TmpIpDevicePath); + } FreePool (Node); - FreePool (TmpDevicePath); if (NewDevicePath == NULL) { return EFI_OUT_OF_RESOURCES; } 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; ASSERT (Private != NULL); ASSERT (Private->SelectIndex != 0); SelectIndex = Private->SelectIndex - 1; ASSERT (SelectIndex < HTTP_BOOT_OFFER_MAX_NUM); + DnsServerIndex = 0; + Status = EFI_SUCCESS; // // SelectOffer contains the IP address configuration and name server configuration. // 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; } - // - // Configure the default DNS server if server assigned. - // if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) { Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER]; ASSERT (Option != NULL); + + // + // Record the Dns Server address list. + // + Private->DnsServerCount = (Option->Length) / sizeof (EFI_IPv4_ADDRESS); + + Private->DnsServerIp = AllocateZeroPool (Private->DnsServerCount * sizeof (EFI_IP_ADDRESS)); + if (Private->DnsServerIp == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) { + CopyMem (&(Private->DnsServerIp[DnsServerIndex].v4), &(((EFI_IPv4_ADDRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv4_ADDRESS)); + } + + // + // Configure the default DNS server if server assigned. + // Status = HttpBootRegisterIp4Dns ( Private, Option->Length, Option->Data ); if (EFI_ERROR (Status)) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp = NULL; return Status; } } // @@ -233,13 +291,17 @@ HttpBootDhcp4ExtractUriInfo ( // // All boot informations are valid here. // // - // Update the device path to include the IP and boot URI information. + // Update the device path to include the boot resource information. // Status = HttpBootUpdateDevicePath (Private); + if (EFI_ERROR (Status) && Private->DnsServerIp != NULL) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp = NULL; + } return Status; } /** @@ -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 != NULL); ASSERT (Private->SelectIndex != 0); SelectIndex = Private->SelectIndex - 1; ASSERT (SelectIndex < HTTP_BOOT_OFFER_MAX_NUM); + DnsServerIndex = 0; + Status = EFI_SUCCESS; HostName = NULL; // // SelectOffer contains the IP address configuration and name server configuration. // HttpOffer contains the boot file URL. @@ -324,26 +389,41 @@ HttpBootDhcp6ExtractUriInfo ( // Status = HttpBootSetIp6Gateway (Private); if (EFI_ERROR (Status)) { return Status; } - - // - // Configure the default DNS server if server assigned. - // + if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) { Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER]; ASSERT (Option != NULL); + + // + // Record the Dns Server address list. + // + Private->DnsServerCount = HTONS (Option->OpLen) / sizeof (EFI_IPv6_ADDRESS); + + Private->DnsServerIp = AllocateZeroPool (Private->DnsServerCount * sizeof (EFI_IP_ADDRESS)); + if (Private->DnsServerIp == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + for (DnsServerIndex = 0; DnsServerIndex < Private->DnsServerCount; DnsServerIndex++) { + CopyMem (&(Private->DnsServerIp[DnsServerIndex].v6), &(((EFI_IPv6_ADDRESS *) Option->Data)[DnsServerIndex]), sizeof (EFI_IPv6_ADDRESS)); + } + + // + // Configure the default DNS server if server assigned. + // Status = HttpBootSetIp6Dns ( Private, HTONS (Option->OpLen), Option->Data ); if (EFI_ERROR (Status)) { - return Status; + goto Error; } } // // Extract the HTTP server Ip frome URL. This is used to Check route table @@ -363,21 +443,26 @@ HttpBootDhcp6ExtractUriInfo ( Private->BootFileUri, Private->BootFileUriParser, &HostName ); if (EFI_ERROR (Status)) { - return Status; + goto Error; } HostNameSize = AsciiStrSize (HostName); HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16)); if (HostNameStr == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Error; } AsciiStrToUnicodeStrS (HostName, HostNameStr, HostNameSize); + + if (HostName != NULL) { + FreePool (HostName); + } + Status = HttpBootDns (Private, HostNameStr, &IpAddr); FreePool (HostNameStr); if (EFI_ERROR (Status)) { goto Error; } @@ -400,20 +485,25 @@ HttpBootDhcp6ExtractUriInfo ( // // All boot informations are valid here. // // - // Update the device path to include the IP and boot URI information. + // Update the device path to include the boot resource information. // Status = HttpBootUpdateDevicePath (Private); + if (EFI_ERROR (Status)) { + goto Error; + } + + return Status; Error: - - if (HostName != NULL) { - FreePool (HostName); + if (Private->DnsServerIp != NULL) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp = NULL; } - + return Status; } /** 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; // // 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. -Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR> (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -463,10 +463,15 @@ HttpBootStop ( HttpUrlFreeParser (Private->OfferBuffer[Index].Dhcp6.UriParser); } } } + if (Private->DnsServerIp != NULL) { + FreePool (Private->DnsServerIp); + Private->DnsServerIp = NULL; + } + if (Private->FilePathUri!= NULL) { FreePool (Private->FilePathUri); HttpUrlFreeParser (Private->FilePathUriParser); Private->FilePathUri = NULL; Private->FilePathUriParser = NULL; -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Patch 0/4] Add DNS device path node 2017-07-25 12:12 [Patch 0/4] Add DNS device path node Jiaxin Wu ` (3 preceding siblings ...) 2017-07-25 12:12 ` [Patch 4/4] NetworkPkg/HttpBootDxe: Update device path node to include DNS information Jiaxin Wu @ 2017-08-14 3:28 ` Ye, Ting 4 siblings, 0 replies; 11+ messages in thread From: Ye, Ting @ 2017-08-14 3:28 UTC (permalink / raw) To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Fu, Siyuan Series Reviewed-by: Ye Ting <ting.ye@intel.com> -----Original Message----- From: Wu, Jiaxin Sent: Tuesday, July 25, 2017 8:13 PM To: edk2-devel@lists.01.org Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com> Subject: [Patch 0/4] Add DNS device path node The series patches implement the DNS device path node according the UEFI Spec 2.7, section 10.3.5.30. Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Jiaxin Wu (4): MdePkg/DevicePath.h: Add DNS Device Path definition MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries MdeModulePkg/UefiBootManagerLib: Support DNS device path description NetworkPkg/HttpBootDxe: Update device path node to include DNS information .../Library/UefiBootManagerLib/BmBootDescription.c | 13 +- MdePkg/Include/Protocol/DevicePath.h | 18 +++ .../Library/UefiDevicePathLib/DevicePathFromText.c | 72 +++++++++++ .../Library/UefiDevicePathLib/DevicePathToText.c | 46 +++++++ NetworkPkg/HttpBootDxe/HttpBootClient.c | 138 +++++++++++++++++---- NetworkPkg/HttpBootDxe/HttpBootDxe.h | 2 + NetworkPkg/HttpBootDxe/HttpBootImpl.c | 7 +- 7 files changed, 269 insertions(+), 27 deletions(-) -- 1.9.5.msysgit.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-08-14 3:25 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-25 12:12 [Patch 0/4] Add DNS device path node Jiaxin Wu 2017-07-25 12:12 ` [Patch 1/4] MdePkg/DevicePath.h: Add DNS Device Path definition Jiaxin Wu 2017-07-25 12:12 ` [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries Jiaxin Wu 2017-07-26 0:42 ` Fu, Siyuan 2017-07-26 2:08 ` Wu, Jiaxin 2017-07-26 2:12 ` Fu, Siyuan 2017-07-26 2:29 ` Wu, Jiaxin 2017-07-26 3:00 ` Wu, Jiaxin 2017-07-25 12:12 ` [Patch 3/4] MdeModulePkg/UefiBootManagerLib: Support DNS device path description Jiaxin Wu 2017-07-25 12:12 ` [Patch 4/4] NetworkPkg/HttpBootDxe: Update device path node to include DNS information Jiaxin Wu 2017-08-14 3:28 ` [Patch 0/4] Add DNS device path node Ye, Ting
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox