From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dggrg03-dlp.huawei.com (unknown [45.249.212.189]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 22EB92008090B for ; Wed, 5 Apr 2017 03:56:13 -0700 (PDT) Received: from 172.30.72.56 (EHLO DGGEMA401-HUB.china.huawei.com) ([172.30.72.56]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ALF40840; Wed, 05 Apr 2017 18:56:10 +0800 (CST) Received: from DGGEMA505-MBS.china.huawei.com ([169.254.4.120]) by DGGEMA401-HUB.china.huawei.com ([10.3.20.42]) with mapi id 14.03.0301.000; Wed, 5 Apr 2017 18:56:00 +0800 From: Guoheyi To: "edk2-devel@lists.01.org" CC: Feng Tian , Star Zeng , "Siyuan Fu" , Jiaxin Wu Thread-Topic: [edk2] [DxeNetLib] Why do we restrict each field to have the same leading zero format? Thread-Index: AdKt+zTi9rTUxGx8ThGF9YVHIyc3FQ== Date: Wed, 5 Apr 2017 10:55:59 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.31.55] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.58E4CD4A.0033, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.4.120, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: c25a205f60457595a0c048baf271dc21 Subject: [DxeNetLib] Why do we restrict each field to have the same leading zero format? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Apr 2017 10:56:15 -0000 Content-Language: zh-CN Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi folks, We are using NetLibAsciiStrToIp6 function in DxeNetLib.c of MdeModulePkg to= convert string to IPv6 address. We found this function will return invalid= parameter with below input: 2001:3456:789a:0000:f012:2:2003:2005 We trace the code and believe it is handled by the branch in line 2955: if ((Cnt !=3D 0) && (Cnt < 4) && LeadZero) { return EFI_INVALID_PARAMETER; } I think the reason is that we have field 3 of "0000" which has leading zero= and causes LeadZero flag to be true, and it requires all the following fie= lds to have the same leading zero format, while field 5 of "2" is not. I checked RFC 4291 and only found below text; I didn't find any restriction= that requires each field to have the same leading zero format. 1. The preferred form is x:x:x:x:x:x:x:x, where the 'x's are one to four hexadecimal digits of the eight 16-bit pieces of the address. Examples: ABCD:EF01:2345:6789:ABCD:EF01:2345:6789 2001:DB8:0:0:8:800:200C:417A Note that it is not necessary to write the leading zeros in an individual field, but there must be at least one numeral in every field (except for the case described in 2.). Could you help to confirm whether it is a bug or there is some special reas= on for this? Thanks and regards, Gary (Heyi Guo)