From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8F1B91A1DEB for ; Thu, 27 Oct 2016 19:52:31 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP; 27 Oct 2016 19:52:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,407,1473145200"; d="scan'208";a="24658159" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 27 Oct 2016 19:52:30 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 27 Oct 2016 19:52:30 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.139]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.209]) with mapi id 14.03.0248.002; Fri, 28 Oct 2016 10:52:26 +0800 From: "Wu, Jiaxin" To: "Fu, Siyuan" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Zhang, Lubo" Thread-Topic: [edk2] [PATCH v2 1/3] MdeModulePkg: Update NetLib interface to support classless addressing. Thread-Index: AQHSMEAjJDCV/X4iE0aIMVx8Wkz4TaC9I1fw Date: Fri, 28 Oct 2016 02:52:26 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B72741389FE74@SHSMSX103.ccr.corp.intel.com> References: <1477565499-11764-1-git-send-email-siyuan.fu@intel.com> <1477565499-11764-2-git-send-email-siyuan.fu@intel.com> In-Reply-To: <1477565499-11764-2-git-send-email-siyuan.fu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTk0NGNhNDEtN2IzYy00Yzk2LWJkZDgtODk1YjJmYjQ5NDRjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNS45LjYuNiIsIlRydXN0ZWRMYWJlbEhhc2giOiJXeTk2enNlYXVuMmZ0VDNScHlodXpCejdObmRXMGJJcm1JSGhGV1YxcFwvWT0ifQ== x-ctpclassification: CTP_PUBLIC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 1/3] MdeModulePkg: Update NetLib interface to support classless addressing. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 02:52:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Siyuan, One comment for the NetIp4IsUnicast(), we should add more check for BROADCA= ST IP since the it's also not a valid unicast address. if (Ip =3D=3D 0 || IP4_IS_LOCAL_BROADCAST (Ip)) { return FALSE; } Others is good to me. Reviewed-By: Wu Jiaxin Best Regards! Jiaxin > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Fu > Siyuan > Sent: Thursday, October 27, 2016 6:52 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Zhang, Lubo ; Wu, > Jiaxin > Subject: [edk2] [PATCH v2 1/3] MdeModulePkg: Update NetLib interface to > support classless addressing. >=20 > V2: > Add macro IP4_IS_UNSPECIFIED. >=20 > The classful addressing (IP class A/B/C) has been deprecated according to > RFC4632. This patch updates the NetLib NetGetIpClass() and NetIp4IsUnicas= t() > accordingly. >=20 > NetGetIpClass() > The function is kept for compatibility, while the caller of this function= could only > check the returned value against with IP4_ADDR_CLASSD (multicast) or > IP4_ADDR_CLASSE (reserved) now. The function has been updated to note thi= s. >=20 > NetIp4IsUnicast() > The NetMask becomes a required parameter to check the unicast address. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Fu Siyuan > Cc: Ye Ting > Cc: Zhang Lubo > Cc: Wu Jiaxin > --- > MdeModulePkg/Include/Library/NetLib.h | 23 ++++++++++++++--------- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 26 ++++++++++++------------= -- > 2 files changed, 26 insertions(+), 23 deletions(-) >=20 > diff --git a/MdeModulePkg/Include/Library/NetLib.h > b/MdeModulePkg/Include/Library/NetLib.h > index c5c0fc2..26709af 100644 > --- a/MdeModulePkg/Include/Library/NetLib.h > +++ b/MdeModulePkg/Include/Library/NetLib.h > @@ -43,9 +43,9 @@ typedef UINT16 TCP_PORTNO; > // > // The address classification > // > -#define IP4_ADDR_CLASSA 1 > -#define IP4_ADDR_CLASSB 2 > -#define IP4_ADDR_CLASSC 3 > +#define IP4_ADDR_CLASSA 1 // Deprecated > +#define IP4_ADDR_CLASSB 2 // Deprecated > +#define IP4_ADDR_CLASSC 3 // Deprecated > #define IP4_ADDR_CLASSD 4 > #define IP4_ADDR_CLASSE 5 >=20 > @@ -231,6 +231,7 @@ typedef struct { > // Test the IP's attribute, All the IPs are in host byte order. > // > #define IP4_IS_MULTICAST(Ip) (((Ip) & 0xF0000000) =3D=3D 0x= E0000000) > +#define IP4_IS_UNSPECIFIED(Ip) ((Ip) =3D=3D 0) > #define IP4_IS_LOCAL_BROADCAST(Ip) ((Ip) =3D=3D 0xFFFFFFFF) > #define IP4_NET_EQUAL(Ip1, Ip2, NetMask) (((Ip1) & (NetMask)) =3D=3D ((= Ip2) & > (NetMask))) > #define IP4_IS_VALID_NETMASK(Ip) (NetGetMaskLength (Ip) !=3D > (IP4_MASK_MAX + 1)) > @@ -379,6 +380,11 @@ NetGetMaskLength ( > Return the class of the IP address, such as class A, B, C. > Addr is in host byte order. >=20 > + [ATTENTION] > + Classful addressing (IP class A/B/C) has been deprecated according to > RFC4632. > + Caller of this function could only check the returned value against > + IP4_ADDR_CLASSD (multicast) or IP4_ADDR_CLASSE (reserved) now. > + > The address of class A starts with 0. > If the address belong to class A, return IP4_ADDR_CLASSA. > The address of class B starts with 10. > @@ -404,17 +410,16 @@ NetGetIpClass ( >=20 > /** > Check whether the IP is a valid unicast address according to > - the netmask. If NetMask is zero, use the IP address's class to get the= default > mask. > + the netmask. >=20 > - If Ip is 0, IP is not a valid unicast address. > - Class D address is used for multicasting and class E address is reserv= ed for > future. If Ip > - belongs to class D or class E, Ip is not a valid unicast address. > - If all bits of the host address of Ip are 0 or 1, Ip is not a valid un= icast address. > + ASSERT if NetMask is zero. > + > + If all bits of the host address of IP are 0 or 1, IP is also not a val= id unicast > address. >=20 > @param[in] Ip The IP to check against. > @param[in] NetMask The mask of the IP. >=20 > - @return TRUE if Ip is a valid unicast address on the network, otherwis= e FALSE. > + @return TRUE if IP is a valid unicast address on the network, otherwis= e > FALSE. >=20 > **/ > BOOLEAN > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index 148bebf..f520845 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -580,6 +580,11 @@ NetGetMaskLength ( > Return the class of the IP address, such as class A, B, C. > Addr is in host byte order. >=20 > + [ATTENTION] > + Classful addressing (IP class A/B/C) has been deprecated according to > RFC4632. > + Caller of this function could only check the returned value against > + IP4_ADDR_CLASSD (multicast) or IP4_ADDR_CLASSE (reserved) now. > + > The address of class A starts with 0. > If the address belong to class A, return IP4_ADDR_CLASSA. > The address of class B starts with 10. > @@ -628,11 +633,10 @@ NetGetIpClass ( >=20 > /** > Check whether the IP is a valid unicast address according to > - the netmask. If NetMask is zero, use the IP address's class to get the= default > mask. > + the netmask. >=20 > - If Ip is 0, IP is not a valid unicast address. > - Class D address is used for multicasting and class E address is reserv= ed for > future. If Ip > - belongs to class D or class E, IP is not a valid unicast address. > + ASSERT if NetMask is zero. > + > If all bits of the host address of IP are 0 or 1, IP is also not a val= id unicast > address. >=20 > @param[in] Ip The IP to check against. > @@ -648,18 +652,12 @@ NetIp4IsUnicast ( > IN IP4_ADDR NetMask > ) > { > - INTN Class; > - > - Class =3D NetGetIpClass (Ip); > - > - if ((Ip =3D=3D 0) || (Class >=3D IP4_ADDR_CLASSD)) { > + ASSERT (NetMask !=3D 0); > + > + if (Ip =3D=3D 0) { > return FALSE; > } > - > - if (NetMask =3D=3D 0) { > - NetMask =3D gIp4AllMasks[Class << 3]; > - } > - > + > if (((Ip &~NetMask) =3D=3D ~NetMask) || ((Ip &~NetMask) =3D=3D 0)) { > return FALSE; > } > -- > 2.7.4.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel