Re: [edk2] [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

2016-02-16 Thread Wu, Jiaxin
That's fine, thanks Siyuan.

-Original Message-
From: Fu, Siyuan 
Sent: Wednesday, February 17, 2016 12:17 PM
To: Wu, Jiaxin ; edk2-devel@lists.01.org
Cc: Hegde Nagaraj P ; Ye, Ting 
Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

For public library interface, we should check the input parameters and return 
error code or NULL pointer if it's invalid, instead of use assert.

> -Original Message-
> From: Wu, Jiaxin
> Sent: Wednesday, February 17, 2016 12:09 PM
> To: Fu, Siyuan ; edk2-devel@lists.01.org
> Cc: Hegde Nagaraj P ; Ye, Ting 
> 
> Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create 
> DNS QName
> 
> Thanks Siyuan,
> 
> I don't have strong opinion about the name DNS_MAX_BLKSIZE or 
> DNS_MAX_MESSAGE_SIZE.
> 
> For comments 1 and 2, I agree the changes.
> 
> For comments 3 and 4, according RFC1035 descriptions as below:
> <<
> Various objects and parameters in the DNS have size limits. They are 
> listed below. Some could be easily changed, others are more fundamental.
> 1. labels 63 octets or less
> 2. names255 octets or less
> 3. TTL  positive values of a signed 32 bit number.
> 4. UDP messages  512 octets or less
> ...
> To simplify implementations, the total length of a domain name (i.e., 
> label octets and label length octets) is restricted to 255 octets or less.
> >>
> So, since the domain name is restricted to 255 octets or less, after 
> preprocessing, the total length must less than 512 octets or less. But 
> you are right, we'd better add a 'Assert' to assert the DomainName 
> length is restricted to 255 octets or less.
> 
> Thanks.
> Jiaxin
> 
> 
> -Original Message-
> From: Fu, Siyuan
> Sent: Wednesday, February 17, 2016 11:24 AM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: Hegde Nagaraj P ; Ye, Ting 
> 
> Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create 
> DNS QName
> 
> BTW, the DNS_MAX_BLKSIZE better to be DNS_MAX_MESSAGE_SIZE, according 
> to the words in RFC.
> 
> > -Original Message-
> > From: Fu, Siyuan
> > Sent: Wednesday, February 17, 2016 11:20 AM
> > To: Wu, Jiaxin ; edk2-devel@lists.01.org
> > Cc: Hegde Nagaraj P ; Ye, Ting 
> > 
> > Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create 
> > DNS QName
> >
> > Hi, Jiaxin
> >
> > Comments as below.
> > 1. In the function description of NetLibCreateDnsQName(), whether 
> > below sentence
> > The domain name terminates with the zero...
> > Should be
> > The QName terminates with the zero...
> >
> > The
> > Caller should take responsibility to the buffer in QName.
> > Should be
> > Caller should take responsibility to free the buffer in returned 
> > pointer.
> >
> > 2. The @param mismatch with the parameter name DomainName.
> >
> > 3. There will be buffer overflow if the StrSize(DomainName) > 
> > DNS_MAX_BLKSIZE in NetLibCreateDnsQName().
> >
> > 4. What the spec requirement if a label is large than 255, which 
> > exceed the max value of a UINT8?
> >
> > Best Regards
> > Siyuan
> >
> >
> >
> >
> > > -Original Message-
> > > From: Wu, Jiaxin
> > > Sent: Friday, January 22, 2016 1:54 AM
> > > To: edk2-devel@lists.01.org
> > > Cc: Hegde Nagaraj P ; Ye, Ting 
> > > ; Fu, Siyuan 
> > > Subject: [Patch 1/2] MdeModulePkg: Define one function to create 
> > > DNS QName
> > >
> > > This patch is used to define a general function to create DNS QName.
> > > QName is a domain name represented as a sequence of labels, where 
> > > each label consists of a length octet followed by that number of 
> > > octets. The domain name terminates with the zero length octet for 
> > > the null label of the root.
> > >
> > > Cc: Hegde Nagaraj P 
> > > Cc: Ye Ting 
> > > Cc: Fu Siyuan 
> > > Contributed-under: TianoCore Contribution Agreement 1.0
> > > Signed-off-by: Jiaxin Wu 
> > > ---
> > >  MdeModulePkg/Include/Library/NetLib.h  | 21 +++
> > >  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 58
> > > +-
> > >  2 files changed, 78 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/MdeModulePkg/Include/Library/NetLib.h
> > > b/MdeModulePkg/Include/Library/NetLib.h
> > > index e4456fa..a257815 100644
> > > --- a/MdeModulePkg/Include/Library/NetLib.h
> > > +++ b/MdeModulePkg/Include/Library/NetLib.h
> > > @@ -35,10 +35,11 @@ typedef UINT16  TCP_PORTNO;
> > >  #define  EFI_IP_PROTO_UDP  0x11
> > >  #define  EFI_IP_PROTO_TCP  0x06
> > >  #define  EFI_IP_PROTO_ICMP 0x01
> > >  #define  

Re: [edk2] [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

2016-02-16 Thread Fu, Siyuan
For public library interface, we should check the input parameters and return 
error code or NULL pointer if it's invalid, instead of use assert.

> -Original Message-
> From: Wu, Jiaxin
> Sent: Wednesday, February 17, 2016 12:09 PM
> To: Fu, Siyuan ; edk2-devel@lists.01.org
> Cc: Hegde Nagaraj P ; Ye, Ting
> 
> Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create DNS
> QName
> 
> Thanks Siyuan,
> 
> I don't have strong opinion about the name DNS_MAX_BLKSIZE or
> DNS_MAX_MESSAGE_SIZE.
> 
> For comments 1 and 2, I agree the changes.
> 
> For comments 3 and 4, according RFC1035 descriptions as below:
> <<
> Various objects and parameters in the DNS have size limits. They are listed
> below. Some could be easily changed, others are more fundamental.
> 1. labels 63 octets or less
> 2. names255 octets or less
> 3. TTL  positive values of a signed 32 bit number.
> 4. UDP messages  512 octets or less
> ...
> To simplify implementations, the total length of a domain name (i.e., label
> octets and label length octets) is restricted to 255 octets or less.
> >>
> So, since the domain name is restricted to 255 octets or less, after
> preprocessing, the total length must less than 512 octets or less. But you are
> right, we'd better add a 'Assert' to assert the DomainName length is
> restricted to 255 octets or less.
> 
> Thanks.
> Jiaxin
> 
> 
> -Original Message-
> From: Fu, Siyuan
> Sent: Wednesday, February 17, 2016 11:24 AM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: Hegde Nagaraj P ; Ye, Ting
> 
> Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create DNS
> QName
> 
> BTW, the DNS_MAX_BLKSIZE better to be DNS_MAX_MESSAGE_SIZE,
> according to the words in RFC.
> 
> > -Original Message-
> > From: Fu, Siyuan
> > Sent: Wednesday, February 17, 2016 11:20 AM
> > To: Wu, Jiaxin ; edk2-devel@lists.01.org
> > Cc: Hegde Nagaraj P ; Ye, Ting
> > 
> > Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create
> > DNS QName
> >
> > Hi, Jiaxin
> >
> > Comments as below.
> > 1. In the function description of NetLibCreateDnsQName(), whether
> > below sentence
> > The domain name terminates with the zero...
> > Should be
> > The QName terminates with the zero...
> >
> > The
> > Caller should take responsibility to the buffer in QName.
> > Should be
> > Caller should take responsibility to free the buffer in returned 
> > pointer.
> >
> > 2. The @param mismatch with the parameter name DomainName.
> >
> > 3. There will be buffer overflow if the StrSize(DomainName) >
> > DNS_MAX_BLKSIZE in NetLibCreateDnsQName().
> >
> > 4. What the spec requirement if a label is large than 255, which
> > exceed the max value of a UINT8?
> >
> > Best Regards
> > Siyuan
> >
> >
> >
> >
> > > -Original Message-
> > > From: Wu, Jiaxin
> > > Sent: Friday, January 22, 2016 1:54 AM
> > > To: edk2-devel@lists.01.org
> > > Cc: Hegde Nagaraj P ; Ye, Ting
> > > ; Fu, Siyuan 
> > > Subject: [Patch 1/2] MdeModulePkg: Define one function to create DNS
> > > QName
> > >
> > > This patch is used to define a general function to create DNS QName.
> > > QName is a domain name represented as a sequence of labels, where
> > > each label consists of a length octet followed by that number of
> > > octets. The domain name terminates with the zero length octet for
> > > the null label of the root.
> > >
> > > Cc: Hegde Nagaraj P 
> > > Cc: Ye Ting 
> > > Cc: Fu Siyuan 
> > > Contributed-under: TianoCore Contribution Agreement 1.0
> > > Signed-off-by: Jiaxin Wu 
> > > ---
> > >  MdeModulePkg/Include/Library/NetLib.h  | 21 +++
> > >  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 58
> > > +-
> > >  2 files changed, 78 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/MdeModulePkg/Include/Library/NetLib.h
> > > b/MdeModulePkg/Include/Library/NetLib.h
> > > index e4456fa..a257815 100644
> > > --- a/MdeModulePkg/Include/Library/NetLib.h
> > > +++ b/MdeModulePkg/Include/Library/NetLib.h
> > > @@ -35,10 +35,11 @@ typedef UINT16  TCP_PORTNO;
> > >  #define  EFI_IP_PROTO_UDP  0x11
> > >  #define  EFI_IP_PROTO_TCP  0x06
> > >  #define  EFI_IP_PROTO_ICMP 0x01
> > >  #define  IP4_PROTO_IGMP0x02
> > >  #define  IP6_ICMP  58
> > > +#define  DNS_MAX_BLKSIZE   512
> > >
> > >  //
> > >  // The address classification
> > >  //
> > >  #define  IP4_ADDR_CLASSA   1
> > > @@ -2154,6 +2155,26 @@ EFI_STATUS
> > >  EFIAPI
> > >  NetLibGetSystemGuid (
> > >OUT EFI_GUID  *SystemGuid
> > >);
> 

Re: [edk2] [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

2016-02-16 Thread Wu, Jiaxin
Thanks Siyuan,

I don't have strong opinion about the name DNS_MAX_BLKSIZE or 
DNS_MAX_MESSAGE_SIZE.

For comments 1 and 2, I agree the changes.

For comments 3 and 4, according RFC1035 descriptions as below:
<<
Various objects and parameters in the DNS have size limits. They are listed 
below. Some could be easily changed, others are more fundamental.
1. labels 63 octets or less
2. names255 octets or less
3. TTL  positive values of a signed 32 bit number.
4. UDP messages  512 octets or less
...
To simplify implementations, the total length of a domain name (i.e., label 
octets and label length octets) is restricted to 255 octets or less.
>>
So, since the domain name is restricted to 255 octets or less, after 
preprocessing, the total length must less than 512 octets or less. But you are 
right, we'd better add a 'Assert' to assert the DomainName length is restricted 
to 255 octets or less.

Thanks.
Jiaxin
 

-Original Message-
From: Fu, Siyuan 
Sent: Wednesday, February 17, 2016 11:24 AM
To: Wu, Jiaxin ; edk2-devel@lists.01.org
Cc: Hegde Nagaraj P ; Ye, Ting 
Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

BTW, the DNS_MAX_BLKSIZE better to be DNS_MAX_MESSAGE_SIZE, according to the 
words in RFC.

> -Original Message-
> From: Fu, Siyuan
> Sent: Wednesday, February 17, 2016 11:20 AM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: Hegde Nagaraj P ; Ye, Ting 
> 
> Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create 
> DNS QName
> 
> Hi, Jiaxin
> 
> Comments as below.
> 1. In the function description of NetLibCreateDnsQName(), whether 
> below sentence
>   The domain name terminates with the zero...
> Should be
>   The QName terminates with the zero...
> 
> The
>   Caller should take responsibility to the buffer in QName.
> Should be
>   Caller should take responsibility to free the buffer in returned 
> pointer.
> 
> 2. The @param mismatch with the parameter name DomainName.
> 
> 3. There will be buffer overflow if the StrSize(DomainName) > 
> DNS_MAX_BLKSIZE in NetLibCreateDnsQName().
> 
> 4. What the spec requirement if a label is large than 255, which 
> exceed the max value of a UINT8?
> 
> Best Regards
> Siyuan
> 
> 
> 
> 
> > -Original Message-
> > From: Wu, Jiaxin
> > Sent: Friday, January 22, 2016 1:54 AM
> > To: edk2-devel@lists.01.org
> > Cc: Hegde Nagaraj P ; Ye, Ting 
> > ; Fu, Siyuan 
> > Subject: [Patch 1/2] MdeModulePkg: Define one function to create DNS 
> > QName
> >
> > This patch is used to define a general function to create DNS QName.
> > QName is a domain name represented as a sequence of labels, where 
> > each label consists of a length octet followed by that number of 
> > octets. The domain name terminates with the zero length octet for 
> > the null label of the root.
> >
> > Cc: Hegde Nagaraj P 
> > Cc: Ye Ting 
> > Cc: Fu Siyuan 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Jiaxin Wu 
> > ---
> >  MdeModulePkg/Include/Library/NetLib.h  | 21 +++
> >  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 58
> > +-
> >  2 files changed, 78 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Include/Library/NetLib.h
> > b/MdeModulePkg/Include/Library/NetLib.h
> > index e4456fa..a257815 100644
> > --- a/MdeModulePkg/Include/Library/NetLib.h
> > +++ b/MdeModulePkg/Include/Library/NetLib.h
> > @@ -35,10 +35,11 @@ typedef UINT16  TCP_PORTNO;
> >  #define  EFI_IP_PROTO_UDP  0x11
> >  #define  EFI_IP_PROTO_TCP  0x06
> >  #define  EFI_IP_PROTO_ICMP 0x01
> >  #define  IP4_PROTO_IGMP0x02
> >  #define  IP6_ICMP  58
> > +#define  DNS_MAX_BLKSIZE   512
> >
> >  //
> >  // The address classification
> >  //
> >  #define  IP4_ADDR_CLASSA   1
> > @@ -2154,6 +2155,26 @@ EFI_STATUS
> >  EFIAPI
> >  NetLibGetSystemGuid (
> >OUT EFI_GUID  *SystemGuid
> >);
> >
> > +/**
> > +  Create Dns QName according the queried domain name.
> > +  QName is a domain name represented as a sequence of labels,
> > +  where each label consists of a length octet followed by that
> > +  number of octets. The domain name terminates with the zero
> > +  length octet for the null label of the root. Caller should
> > +  take responsibility to the buffer in QName.
> > +
> > +  @param  StringThe pointer to the queried Ascii string.
> > +
> > +  @retval NULL  Failed to fill QName.
> > +  @return   QName filled successfully.
> > +
> > +**/
> > +CHAR8 *
> > +EFIAPI
> > +NetLibCreateDnsQName (
> > +  IN  CHAR16  *DomainName
> > +  

Re: [edk2] [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

2016-02-16 Thread Fu, Siyuan
BTW, the DNS_MAX_BLKSIZE better to be DNS_MAX_MESSAGE_SIZE, according to the 
words in RFC.

> -Original Message-
> From: Fu, Siyuan
> Sent: Wednesday, February 17, 2016 11:20 AM
> To: Wu, Jiaxin ; edk2-devel@lists.01.org
> Cc: Hegde Nagaraj P ; Ye, Ting
> 
> Subject: RE: [Patch 1/2] MdeModulePkg: Define one function to create DNS
> QName
> 
> Hi, Jiaxin
> 
> Comments as below.
> 1. In the function description of NetLibCreateDnsQName(), whether below
> sentence
>   The domain name terminates with the zero...
> Should be
>   The QName terminates with the zero...
> 
> The
>   Caller should take responsibility to the buffer in QName.
> Should be
>   Caller should take responsibility to free the buffer in returned 
> pointer.
> 
> 2. The @param mismatch with the parameter name DomainName.
> 
> 3. There will be buffer overflow if the StrSize(DomainName) >
> DNS_MAX_BLKSIZE in NetLibCreateDnsQName().
> 
> 4. What the spec requirement if a label is large than 255, which exceed the
> max value of a UINT8?
> 
> Best Regards
> Siyuan
> 
> 
> 
> 
> > -Original Message-
> > From: Wu, Jiaxin
> > Sent: Friday, January 22, 2016 1:54 AM
> > To: edk2-devel@lists.01.org
> > Cc: Hegde Nagaraj P ; Ye, Ting
> > ; Fu, Siyuan 
> > Subject: [Patch 1/2] MdeModulePkg: Define one function to create DNS
> > QName
> >
> > This patch is used to define a general function to create
> > DNS QName.
> > QName is a domain name represented as a sequence
> > of labels, where each label consists of a length octet
> > followed by that number of octets. The domain name terminates
> > with the zero length octet for the null label of the root.
> >
> > Cc: Hegde Nagaraj P 
> > Cc: Ye Ting 
> > Cc: Fu Siyuan 
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Jiaxin Wu 
> > ---
> >  MdeModulePkg/Include/Library/NetLib.h  | 21 +++
> >  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 58
> > +-
> >  2 files changed, 78 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Include/Library/NetLib.h
> > b/MdeModulePkg/Include/Library/NetLib.h
> > index e4456fa..a257815 100644
> > --- a/MdeModulePkg/Include/Library/NetLib.h
> > +++ b/MdeModulePkg/Include/Library/NetLib.h
> > @@ -35,10 +35,11 @@ typedef UINT16  TCP_PORTNO;
> >  #define  EFI_IP_PROTO_UDP  0x11
> >  #define  EFI_IP_PROTO_TCP  0x06
> >  #define  EFI_IP_PROTO_ICMP 0x01
> >  #define  IP4_PROTO_IGMP0x02
> >  #define  IP6_ICMP  58
> > +#define  DNS_MAX_BLKSIZE   512
> >
> >  //
> >  // The address classification
> >  //
> >  #define  IP4_ADDR_CLASSA   1
> > @@ -2154,6 +2155,26 @@ EFI_STATUS
> >  EFIAPI
> >  NetLibGetSystemGuid (
> >OUT EFI_GUID  *SystemGuid
> >);
> >
> > +/**
> > +  Create Dns QName according the queried domain name.
> > +  QName is a domain name represented as a sequence of labels,
> > +  where each label consists of a length octet followed by that
> > +  number of octets. The domain name terminates with the zero
> > +  length octet for the null label of the root. Caller should
> > +  take responsibility to the buffer in QName.
> > +
> > +  @param  StringThe pointer to the queried Ascii string.
> > +
> > +  @retval NULL  Failed to fill QName.
> > +  @return   QName filled successfully.
> > +
> > +**/
> > +CHAR8 *
> > +EFIAPI
> > +NetLibCreateDnsQName (
> > +  IN  CHAR16  *DomainName
> > +  );
> > +
> >  #endif
> > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> > index e112d45..dd67a1c 100644
> > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> > @@ -1,9 +1,9 @@
> >  /** @file
> >Network library.
> >
> > -Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
> > +Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
> >  (C) Copyright 2015 Hewlett Packard Enterprise Development LP
> >  This program and the accompanying materials
> >  are licensed and made available under the terms and conditions of the
> BSD
> > License
> >  which accompanies this distribution.  The full text of the license may be
> > found at
> >  http://opensource.org/licenses/bsd-license.php
> > @@ -3324,5 +3324,61 @@ NetLibGetSystemGuid (
> >}
> >  } while (TRUE);
> >} while (Smbios.Raw < SmbiosEnd.Raw);
> >return EFI_NOT_FOUND;
> >  }
> > +
> > +/**
> > +  Create Dns QName according the queried domain name.
> > +  QName is a domain name represented as a sequence of labels,
> > +  where each label consists of a length octet followed by that
> > +  number of octets. The domain name terminates with the zero
> > +  length octet for the null 

Re: [edk2] [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

2016-02-16 Thread Fu, Siyuan
Hi, Jiaxin

Comments as below.
1. In the function description of NetLibCreateDnsQName(), whether below sentence
The domain name terminates with the zero...
Should be
The QName terminates with the zero...

The
Caller should take responsibility to the buffer in QName.
Should be 
Caller should take responsibility to free the buffer in returned 
pointer.

2. The @param mismatch with the parameter name DomainName. 

3. There will be buffer overflow if the StrSize(DomainName) > DNS_MAX_BLKSIZE 
in NetLibCreateDnsQName().

4. What the spec requirement if a label is large than 255, which exceed the max 
value of a UINT8?

Best Regards
Siyuan




> -Original Message-
> From: Wu, Jiaxin
> Sent: Friday, January 22, 2016 1:54 AM
> To: edk2-devel@lists.01.org
> Cc: Hegde Nagaraj P ; Ye, Ting
> ; Fu, Siyuan 
> Subject: [Patch 1/2] MdeModulePkg: Define one function to create DNS
> QName
> 
> This patch is used to define a general function to create
> DNS QName.
> QName is a domain name represented as a sequence
> of labels, where each label consists of a length octet
> followed by that number of octets. The domain name terminates
> with the zero length octet for the null label of the root.
> 
> Cc: Hegde Nagaraj P 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu 
> ---
>  MdeModulePkg/Include/Library/NetLib.h  | 21 +++
>  MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 58
> +-
>  2 files changed, 78 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Include/Library/NetLib.h
> b/MdeModulePkg/Include/Library/NetLib.h
> index e4456fa..a257815 100644
> --- a/MdeModulePkg/Include/Library/NetLib.h
> +++ b/MdeModulePkg/Include/Library/NetLib.h
> @@ -35,10 +35,11 @@ typedef UINT16  TCP_PORTNO;
>  #define  EFI_IP_PROTO_UDP  0x11
>  #define  EFI_IP_PROTO_TCP  0x06
>  #define  EFI_IP_PROTO_ICMP 0x01
>  #define  IP4_PROTO_IGMP0x02
>  #define  IP6_ICMP  58
> +#define  DNS_MAX_BLKSIZE   512
> 
>  //
>  // The address classification
>  //
>  #define  IP4_ADDR_CLASSA   1
> @@ -2154,6 +2155,26 @@ EFI_STATUS
>  EFIAPI
>  NetLibGetSystemGuid (
>OUT EFI_GUID  *SystemGuid
>);
> 
> +/**
> +  Create Dns QName according the queried domain name.
> +  QName is a domain name represented as a sequence of labels,
> +  where each label consists of a length octet followed by that
> +  number of octets. The domain name terminates with the zero
> +  length octet for the null label of the root. Caller should
> +  take responsibility to the buffer in QName.
> +
> +  @param  StringThe pointer to the queried Ascii string.
> +
> +  @retval NULL  Failed to fill QName.
> +  @return   QName filled successfully.
> +
> +**/
> +CHAR8 *
> +EFIAPI
> +NetLibCreateDnsQName (
> +  IN  CHAR16  *DomainName
> +  );
> +
>  #endif
> diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> index e112d45..dd67a1c 100644
> --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
> @@ -1,9 +1,9 @@
>  /** @file
>Network library.
> 
> -Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
>  (C) Copyright 2015 Hewlett Packard Enterprise Development LP
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
>  http://opensource.org/licenses/bsd-license.php
> @@ -3324,5 +3324,61 @@ NetLibGetSystemGuid (
>}
>  } while (TRUE);
>} while (Smbios.Raw < SmbiosEnd.Raw);
>return EFI_NOT_FOUND;
>  }
> +
> +/**
> +  Create Dns QName according the queried domain name.
> +  QName is a domain name represented as a sequence of labels,
> +  where each label consists of a length octet followed by that
> +  number of octets. The domain name terminates with the zero
> +  length octet for the null label of the root. Caller should
> +  take responsibility to the buffer in QName.
> +
> +  @param  StringThe pointer to the queried Ascii string.
> +
> +  @retval NULL  Failed to fill QName.
> +  @return   QName filled successfully.
> +
> +**/
> +CHAR8 *
> +EFIAPI
> +NetLibCreateDnsQName (
> +  IN  CHAR16  *DomainName
> +  )
> +{
> +  CHAR8 *QueryName;
> +  CHAR8 *Header;
> +  CHAR8 *Tail;
> +  UINTN Len;
> +  UINTN Index;
> +
> +  QueryName  = NULL;
> +  Header = NULL;
> +  Tail   = NULL;
> +
> +  QueryName = AllocateZeroPool 

[edk2] [Patch 1/2] MdeModulePkg: Define one function to create DNS QName

2016-01-21 Thread Jiaxin Wu
This patch is used to define a general function to create
DNS QName.
QName is a domain name represented as a sequence
of labels, where each label consists of a length octet
followed by that number of octets. The domain name terminates
with the zero length octet for the null label of the root.

Cc: Hegde Nagaraj P 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 MdeModulePkg/Include/Library/NetLib.h  | 21 +++
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 58 +-
 2 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Library/NetLib.h 
b/MdeModulePkg/Include/Library/NetLib.h
index e4456fa..a257815 100644
--- a/MdeModulePkg/Include/Library/NetLib.h
+++ b/MdeModulePkg/Include/Library/NetLib.h
@@ -35,10 +35,11 @@ typedef UINT16  TCP_PORTNO;
 #define  EFI_IP_PROTO_UDP  0x11
 #define  EFI_IP_PROTO_TCP  0x06
 #define  EFI_IP_PROTO_ICMP 0x01
 #define  IP4_PROTO_IGMP0x02
 #define  IP6_ICMP  58
+#define  DNS_MAX_BLKSIZE   512
 
 //
 // The address classification
 //
 #define  IP4_ADDR_CLASSA   1
@@ -2154,6 +2155,26 @@ EFI_STATUS
 EFIAPI
 NetLibGetSystemGuid (
   OUT EFI_GUID  *SystemGuid
   );
 
+/**
+  Create Dns QName according the queried domain name. 
+  QName is a domain name represented as a sequence of labels, 
+  where each label consists of a length octet followed by that 
+  number of octets. The domain name terminates with the zero 
+  length octet for the null label of the root. Caller should 
+  take responsibility to the buffer in QName.
+
+  @param  StringThe pointer to the queried Ascii string.  
+
+  @retval NULL  Failed to fill QName.
+  @return   QName filled successfully.
+  
+**/ 
+CHAR8 *
+EFIAPI
+NetLibCreateDnsQName (
+  IN  CHAR16  *DomainName
+  );
+
 #endif
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c 
b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index e112d45..dd67a1c 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -1,9 +1,9 @@
 /** @file
   Network library.
 
-Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php
@@ -3324,5 +3324,61 @@ NetLibGetSystemGuid (
   }
 } while (TRUE);
   } while (Smbios.Raw < SmbiosEnd.Raw);
   return EFI_NOT_FOUND;
 }
+
+/**
+  Create Dns QName according the queried domain name. 
+  QName is a domain name represented as a sequence of labels, 
+  where each label consists of a length octet followed by that 
+  number of octets. The domain name terminates with the zero 
+  length octet for the null label of the root. Caller should 
+  take responsibility to the buffer in QName.
+
+  @param  StringThe pointer to the queried Ascii string.  
+
+  @retval NULL  Failed to fill QName.
+  @return   QName filled successfully.
+  
+**/ 
+CHAR8 *
+EFIAPI
+NetLibCreateDnsQName (
+  IN  CHAR16  *DomainName
+  )
+{
+  CHAR8 *QueryName;
+  CHAR8 *Header;
+  CHAR8 *Tail;
+  UINTN Len;
+  UINTN Index;
+
+  QueryName  = NULL;
+  Header = NULL;
+  Tail   = NULL;
+
+  QueryName = AllocateZeroPool (DNS_MAX_BLKSIZE);
+  if (QueryName == NULL) {
+return NULL;
+  }
+  
+  Header = QueryName;
+  Tail = Header + 1;
+  Len = 0;
+  for (Index = 0; DomainName[Index] != 0; Index++) {
+*Tail = (CHAR8) DomainName[Index];
+if (*Tail == '.') {
+  *Header = (CHAR8) Len;
+  Header = Tail;
+  Tail ++;
+  Len = 0;
+} else {
+  Tail++;
+  Len++;
+}
+  }
+  *Header = (CHAR8) Len;
+  *Tail = 0;
+
+  return QueryName;
+}
\ No newline at end of file
-- 
1.9.5.msysgit.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel