public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: "Fu, Siyuan" <siyuan.fu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ye, Ting" <ting.ye@intel.com>
Subject: Re: [Patch 2/4] MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries
Date: Wed, 26 Jul 2017 03:00:25 +0000	[thread overview]
Message-ID: <895558F6EA4E3B41AC93A00D163B7274162FC56A@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: B1FF2E9001CE9041BD10B825821D5BC58B3541C4@SHSMSX103.ccr.corp.intel.com

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



  parent reply	other threads:[~2017-07-26  2:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=895558F6EA4E3B41AC93A00D163B7274162FC56A@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox