Subject: lib/6355: attempt to clear up some of the network byte order confusion in inet(3)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <woods@weird.com>
List: netbsd-bugs
Date: 10/25/1998 02:45:16
>Number:         6355
>Category:       lib
>Synopsis:       attempt to clear up some of the network byte order confusion in inet(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 25 00:50:01 1998
>Last-Modified:
>Originator:     Greg A. Woods
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Release:        NetBSD-current sup 909143147
>Environment:

irrelevant

>Description:

	as per the BUG noted at the bottom of the inet(3) manual page,
	it always takes me a bit of time and hard thinking to remember
	exactly what's what with the byte order of arguments and reutrn
	values for each function described therein

>How-To-Repeat:

	Write some code that attempts to pass raw network addresses back
	through inet_ntoa(inet_makeaddr()) and wonder why it doesn't
	work on i386....

>Fix:

	apply the attached patch (but do *not* remove the BUG! ;-):

Index: inet.3
===================================================================
RCS file: /cvs/NetBSD/src/lib/libc/net/inet.3,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 inet.3
*** inet.3	1998/02/20 00:31:47	1.1.1.1
--- inet.3	1998/10/25 07:16:30
***************
*** 126,140 ****
  .Ql \&.
  notation.  The routine
  .Fn inet_makeaddr
! takes an Internet network number and a local
! network address and constructs an Internet address
! from it.  The routines
  .Fn inet_netof
  and
  .Fn inet_lnaof
! break apart Internet host addresses, returning
! the network number and local network address part,
! respectively.
  .Pp
  All Internet addresses are returned in network
  order (bytes ordered from left to right).
--- 126,145 ----
  .Ql \&.
  notation.  The routine
  .Fn inet_makeaddr
! takes an Internet network number and a local network address (both in
! host order) and constructs an Internet address from it.  Note that to
! convert only a single value to a
! .Ft struct in_addr
! form that value shoud be passed as the first parameter and
! .Ql 0L
! should be given for the second parameter.
! .Pp
! The routines
  .Fn inet_netof
  and
  .Fn inet_lnaof
! break apart Internet host addresses, returning the network number and
! local network address part, respectively (both in host order).
  .Pp
  All Internet addresses are returned in network
  order (bytes ordered from left to right).

>Audit-Trail:
>Unformatted: