From owner-freebsd-arch Mon Aug 12 20:24: 7 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 93A4237B400 for ; Mon, 12 Aug 2002 20:24:05 -0700 (PDT) Received: from sccrmhc01.attbi.com (sccrmhc01.attbi.com [204.127.202.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id D25E843E42 for ; Mon, 12 Aug 2002 20:24:04 -0700 (PDT) (envelope-from crist.clark@attbi.com) Received: from blossom.cjclark.org ([12.234.91.48]) by sccrmhc01.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020813032403.KNLD23732.sccrmhc01.attbi.com@blossom.cjclark.org>; Tue, 13 Aug 2002 03:24:03 +0000 Received: from blossom.cjclark.org (localhost. [127.0.0.1]) by blossom.cjclark.org (8.12.3/8.12.3) with ESMTP id g7D3O2JK001779; Mon, 12 Aug 2002 20:24:02 -0700 (PDT) (envelope-from crist.clark@attbi.com) Received: (from cjc@localhost) by blossom.cjclark.org (8.12.3/8.12.3/Submit) id g7D3NvOn001778; Mon, 12 Aug 2002 20:23:57 -0700 (PDT) X-Authentication-Warning: blossom.cjclark.org: cjc set sender to crist.clark@attbi.com using -f Date: Mon, 12 Aug 2002 20:23:57 -0700 From: "Crist J. Clark" To: Antoine Beaupre Cc: freebsd-arch@FreeBSD.ORG Subject: Re: implementation differences between inet_aton() and inet_pton() Message-ID: <20020813032357.GA1675@blossom.cjclark.org> Reply-To: "Crist J. Clark" References: <3A565436-ABC5-11D6-BAC6-0050E4A0BB3F@anarcat.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3A565436-ABC5-11D6-BAC6-0050E4A0BB3F@anarcat.ath.cx> User-Agent: Mutt/1.4i X-URL: http://people.freebsd.org/~cjc/ Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Aug 09, 2002 at 02:24:22PM -0400, Antoine Beaupre wrote: > Hi > > I just stumbled upon some differences between the results given by > inet_aton() and inet_pton(). > > inet_aton() converts substrings to numbers using strtoul(). This means > that an address like "127.0x0.0.01" will be parsed as "127.0.0.1". > > On the other hand, inet_pton() parses the number directly, using a > clever hack: > > u_int new = *tp * 10 + (pch - digits); > > This assumes the number is in base 10. This means that an address like > "127.0x0.0.01" will result in a parse error. (more precisely: 0 if the > address wasn't parseable in the specified address family). > > Is this difference there by design or accident? I think I went through this a few months ago when I noticed that "127.0x0.0.01" and "127.1" don't work with inet_pton(3). > In either case it should be documented how each function parses the > numbers, because it is rather important. Did you read the whole page? inet_pton(3) says, STANDARDS The inet_ntop() and inet_pton() functions conform to X/Open Networking Services Issue 5.2 (``XNS5.2''). Note that inet_pton() does not accept 1-, 2-, or 3-part dotted addresses; all four parts must be specified and are interpreted only as decimal values. This is a narrower input set than that accepted by inet_aton(). -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message