From nobody  Tue Feb  9 08:27:18 1999
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id IAA05434;
          Tue, 9 Feb 1999 08:27:18 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199902091627.IAA05434@hub.freebsd.org>
Date: Tue, 9 Feb 1999 08:27:18 -0800 (PST)
From: motoyuki@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: inet_addr(3) should be return 32bit uint.
X-Send-Pr-Version: www-1.0

>Number:         9982
>Category:       bin
>Synopsis:       inet_addr(3) should be return 32bit uint.
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    ume
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb  9 08:30:01 PST 1999
>Closed-Date:    Fri Mar 23 11:03:51 PST 2001
>Last-Modified:  Fri Mar 23 11:10:58 PST 2001
>Originator:     Motoyuki Konno
>Release:        FreeBSD-current
>Organization:
>Environment:
>Description:
inet_addr(3) return unsigned long (64bit uint) value.
it should be return 32bit uint.
>How-To-Repeat:

>Fix:
For example,
1. Add "typedef in_addr_t u_int32_t;" to sys/types.h.
2. Change the difinition of inet_addr(3) in arpa/inet.h
      "unsigned long inet_addr (const char *);
   -> "in_addr_t inet_addr (const char *);

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: fenner 
Responsible-Changed-When: Wed Feb 10 12:13:00 PST 1999 
Responsible-Changed-Why:  
Fixing misfiled PR. 
State-Changed-From-To: open->feedback 
State-Changed-By: johan 
State-Changed-When: Tue Aug 22 02:50:32 PDT 2000 
State-Changed-Why:  
Excuse my ignorance, by why should inet_addr return  
a 32 bit unsigned int instead of unsigned long? 


http://www.freebsd.org/cgi/query-pr.cgi?pr=9982 

From: Peter Pentchev <roam@orbitel.bg>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/9982: inet_addr(3) should be return 32bit uint.
Date: Tue, 22 Aug 2000 13:13:09 +0300

 On Tue, Aug 22, 2000 at 02:53:38AM -0700, johan@FreeBSD.org wrote:
 > Synopsis: inet_addr(3) should be return 32bit uint.
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: johan
 > State-Changed-When: Tue Aug 22 02:50:32 PDT 2000
 > State-Changed-Why: 
 > Excuse my ignorance, by why should inet_addr return 
 > a 32 bit unsigned int instead of unsigned long?
 > 
 >
 
 I think the original poster was considering 32-bit IPv4 addresses,
 in which case the 64-bit ulong is indeed a bit of an overkill.
 
 Actually, IMHO a 64-bit value is precisely the wrong choice in any case -
 a bit too long for 32-bit IPv4 addresses, and quite a bit too short
 for 128-bit IPv6 addresses.  True, nowhere in the inet_addr(3) manpage
 is it even implied that inet_addr() works correctly for the AF_INET6 family,
 but if it is an IPv4-only function, why the 64-bit return value? :)
 It is (mostly) harmless, yet there are cases when a picky (-Wall -W)
 compiler would complain about a 64-to-32 bit truncating.
 
State-Changed-From-To: feedback->open 
State-Changed-By: johan 
State-Changed-When: Wed Aug 23 01:10:41 PDT 2000 
State-Changed-Why:  
Over to IPv6 maintainer to decide if inet_addr and friends should be 
IPv6 aware. 



Responsible-Changed-From-To: freebsd-bugs->ume 
Responsible-Changed-By: johan 
Responsible-Changed-When: Wed Aug 23 01:10:41 PDT 2000 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=9982 
State-Changed-From-To: open->feedback 
State-Changed-By: ume 
State-Changed-When: Wed Aug 23 02:10:22 PDT 2000 
State-Changed-Why:  
IPv6 doesn't concern with inet_addr(), net_ntoa() and so on.  Because, 
these functions are IPv4 specific, and RFC2553 defines inet_pton() and 
inet_ntop() for IPv6 (and other families contains IPv4). 

BTW, IPv4 address is 32bits.  Maybe, use of unsigned int came from the 
asumption that int is 32bits long.  It may be corrected to use 32bit 
uint.  However, when inet_addr() fails, it returns INADDR_NONE.  It 
means you cannot distinguish 255.255.255.255 from conversion failure 
in 32bit uint world.  So, existing use of unsigned int may better in 
the future.  Of cource, to distinguish them, the spec of inet_addr() 
should be changed. 

Further more, at least NetBSD stays to use unsigned int.  We should 
avoid changing the defines around here within FreeBSD alone. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=9982 

From: Peter Pentchev <roam@orbitel.bg>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/9982: inet_addr(3) should be return 32bit uint.
Date: Wed, 23 Aug 2000 12:40:04 +0300

 Actually, I just did some standards digging.. Is FreeBSD trying to
 be SUSv2 compliant?  If there is any move in that direction (and from
 various other postings, I'm left with the impression that there is),
 then (to quote from the SUSv2 specification):
 
   NAME
       inet_addr, inet_network, inet_makeaddr, inet_lnaof, inet_netof,
       inet_ntoa - Internet address manipulation
 
   SYNOPSIS
 
       #include <arpa/inet.h>
 
       in_addr_t inet_addr(const char *cp);
 
 and in the arpa/inet.h specification, there is a cross-reference to
 netinet/in.h, where it says:
 
     DESCRIPTION
     
          When header file <netinet/in.h> is included, the following types
          are defined through typedef.
 	 
          in_port_t - An unsigned integral type of exactly 16 bits.
 	 
 	 in_addr_t - An unsigned integral type of exactly 32 bits.
 
 
 Apparently, SUSv2 is not too much concerned with IPv6, yet it specifically
 mentions 'exactly 32 bits'.
 
 The SUSv2 specification is available at http://www.unix-systems.org/version2/
 
 On Wed, Aug 23, 2000 at 01:14:21AM -0700, johan@FreeBSD.org wrote:
 > Synopsis: inet_addr(3) should be return 32bit uint.
 > 
 > State-Changed-From-To: feedback->open
 > State-Changed-By: johan
 > State-Changed-When: Wed Aug 23 01:10:41 PDT 2000
 > State-Changed-Why: 
 > Over to IPv6 maintainer to decide if inet_addr and friends should be
 > IPv6 aware.
 > 
 > 
 > 
 > Responsible-Changed-From-To: freebsd-bugs->ume
 > Responsible-Changed-By: johan
 > Responsible-Changed-When: Wed Aug 23 01:10:41 PDT 2000
 > Responsible-Changed-Why: 
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=9982
 > 
 > 
 > To Unsubscribe: send mail to majordomo@FreeBSD.org
 > with "unsubscribe freebsd-bugs" in the body of the message
 

From: Johan Karlsson <k@numeri.campus.luth.se>
To: roam@orbitel.bg
Cc: motoyuki@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/9982: inet_addr(3) should be return 32bit uint. 
Date: Wed, 23 Aug 2000 12:15:09 +0200

 I think this should be closed since if inet_addr should return 
 32bit uint instead of ulong (64bit?) there is no way to distinguish 
 failure from succesfull address 255.255.255.255 (see audit-trail).
 
 Peter, does this sound ok?
 
 
 /Johan K
 

From: Peter Pentchev <roam@orbitel.bg>
To: Johan Karlsson <k@numeri.campus.luth.se>
Cc: motoyuki@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/9982: inet_addr(3) should be return 32bit uint.
Date: Wed, 23 Aug 2000 13:29:39 +0300

 On Wed, Aug 23, 2000 at 12:15:09PM +0200, Johan Karlsson wrote:
 > 
 > I think this should be closed since if inet_addr should return 
 > 32bit uint instead of ulong (64bit?) there is no way to distinguish 
 > failure from succesfull address 255.255.255.255 (see audit-trail).
 > 
 > Peter, does this sound ok?
 > 
 > 
 > /Johan K
 > 
 
 I'm still a bit worried about standards - I cannot check at the moment,
 but I'm fairly sure most other OS's have inet_addr() returning a uint32..
 
 G'luck,
 Peter
 

From: Johan Karlsson <k@numeri.campus.luth.se>
To: Peter Pentchev <roam@orbitel.bg>
Cc: motoyuki@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/9982: inet_addr(3) should be return 32bit uint. 
Date: Wed, 23 Aug 2000 13:31:17 +0200

 At Wed, 23 Aug 2000 13:29:39 +0300, Peter Pentchev wrote:
 > On Wed, Aug 23, 2000 at 12:15:09PM +0200, Johan Karlsson wrote:
 > > 
 > > I think this should be closed since if inet_addr should return 
 > > 32bit uint instead of ulong (64bit?) there is no way to distinguish 
 > > failure from succesfull address 255.255.255.255 (see audit-trail).
 > > 
 > > Peter, does this sound ok?
 > > 
 > > 
 > > /Johan K
 > > 
 > 
 > I'm still a bit worried about standards - I cannot check at the moment,
 > but I'm fairly sure most other OS's have inet_addr() returning a uint32..
 > 
 
 The two that I realy care about do not agree.
 
 NetBSD: 
 unsigned long 			http://www.FreeBSD.org/cgi/cvsweb.cgi/basesrc/include/arpa/inet.h?rev=1.9&content-type=text/x-cvsweb-markup&cvsroot=netbsd
 
 OpenBSD: 
 in_addr_t 			http://www.FreeBSD.org/cgi/cvsweb.cgi/src/include/arpa/inet.h?rev=1.4&content-type=text/x-cvsweb-markup&cvsroot=openbs
 typedef u_int32_t in_addr_t; 	http://www.FreeBSD.org/cgi/cvsweb.cgi/src/sys/sys/types.h?rev=1.16&content-type=text/x-cvsweb-markup&cvsroot=openbsd 
 
 /Johan K
 
 
 

From: Peter Pentchev <roam@orbitel.bg>
To: Johan Karlsson <k@numeri.campus.luth.se>
Cc: motoyuki@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/9982: inet_addr(3) should be return 32bit uint.
Date: Wed, 23 Aug 2000 15:43:35 +0300

 On Wed, Aug 23, 2000 at 01:31:17PM +0200, Johan Karlsson wrote:
 > 
 > The two that I realy care about do not agree.
 > 
 > NetBSD: 
 > unsigned long 			http://www.FreeBSD.org/cgi/cvsweb.cgi/basesrc/include/arpa/inet.h?rev=1.9&content-type=text/x-cvsweb-markup&cvsroot=netbsd
 > 
 > OpenBSD: 
 > in_addr_t 			http://www.FreeBSD.org/cgi/cvsweb.cgi/src/include/arpa/inet.h?rev=1.4&content-type=text/x-cvsweb-markup&cvsroot=openbs
 > typedef u_int32_t in_addr_t; 	http://www.FreeBSD.org/cgi/cvsweb.cgi/src/sys/sys/types.h?rev=1.16&content-type=text/x-cvsweb-markup&cvsroot=openbsd 
 > 
 > /Johan K
 
 Well, if NetBSD is the platform that FreeBSD wants to maintain
 compatibility with, alright, close the PR; but I feel that it won't be
 too long before the standards' compliance issue pops up again.
 
 G'luck,
 Peter
 

From: Johan Karlsson <k@numeri.campus.luth.se>
To: Peter Pentchev <roam@orbitel.bg>
Cc: motoyuki@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/9982: inet_addr(3) should be return 32bit uint. 
Date: Wed, 23 Aug 2000 15:19:59 +0200

 At Wed, 23 Aug 2000 15:43:35 +0300, Peter Pentchev wrote:
 > 
 > Well, if NetBSD is the platform that FreeBSD wants to maintain
 > compatibility with, alright, close the PR; but I feel that it won't be
 > too long before the standards' compliance issue pops up again.
 > 
 > G'luck,
 > Peter
 > 
 
 Do you know if the other inet funcions complie to SUSv2 in our tree?
 
 If not they should be change at the same time.
 
 /Johan K
 
 
State-Changed-From-To: feedback->closed 
State-Changed-By: ume 
State-Changed-When: Fri Mar 23 11:03:51 PST 2001 
State-Changed-Why:  
I took in_addr_t from OpenBSD and just committed to -CURRENT. 

src/include/arpa/inet.h		1.11 -> 1.12 
src/sys/netinet/in.h			1.53 -> 1.54 
src/sys/sys/types.h			1.41 -> 1.42 
src/lib/libc/net/inet.3		1.11 -> 1.12 
src/lib/libc/net/inet_addr.c		1.12 -> 1.13 
src/lib/libc/net/inet_lnaof.c		1.2  -> 1.3 
src/lib/libc/net/inet_makeaddr.c	1.2  -> 1.3 
src/lib/libc/net/inet_neta.c		1.6  -> 1.7 
src/lib/libc/net/inet_netof.c		1.2  -> 1.3 
src/lib/libc/net/inet_network.c	1.6  -> 1.7 

http://www.freebsd.org/cgi/query-pr.cgi?pr=9982 
>Unformatted:
