From owner-freebsd-arch Fri Aug 9 11:34:36 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 9A79837B400 for ; Fri, 9 Aug 2002 11:34:34 -0700 (PDT) Received: from mail1.qc.uunet.ca (mail1.qc.uunet.ca [198.168.54.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 151A143E77 for ; Fri, 9 Aug 2002 11:34:33 -0700 (PDT) (envelope-from anarcat@anarcat.ath.cx) Received: from xtanbul (IDENT:506@[216.94.147.34]) by mail1.qc.uunet.ca (8.10.2/8.10.2) with ESMTP id g79IYMN06486 for ; Fri, 9 Aug 2002 14:34:24 -0400 Date: Fri, 9 Aug 2002 14:24:22 -0400 Mime-Version: 1.0 (Apple Message framework v482) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: implementation differences between inet_aton() and inet_pton() From: Antoine Beaupre To: freebsd-arch@freebsd.org Content-Transfer-Encoding: 7bit Message-Id: <3A565436-ABC5-11D6-BAC6-0050E4A0BB3F@anarcat.ath.cx> X-Mailer: Apple Mail (2.482) 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 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? In either case it should be documented how each function parses the numbers, because it is rather important. A. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message