Bug 189147 - Incorrect description of inet_network in man page
Incorrect description of inet_network in man page
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: man-pages (Show other bugs)
rawhide
All Linux
medium Severity low
: ---
: ---
Assigned To: Ivana Varekova
Ben Levenson
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-17 12:48 EDT by brett.anderson@speakeasy.net
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-06-29 07:02:19 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description brett.anderson@speakeasy.net 2006-04-17 12:48:52 EDT
Description of problem:
The description of inet_network in the man page states:
The inet_network() function extracts the network number in host byte order from
the address cp in numbers-and-dots notation. If the input is invalid, -1 is
returned.

The function, when used, does not extract the network number, but instead
extracts a 32-bit Internet address in host byte order.

The description of inet_netof() states:
The inet_netof() function returns the network number part of the Internet
Address in. The network number is returned in local host byte order.

If you compare the wording of the two descriptions, they both claim to extract
the network number, when this is only true for inet_netof().

Version-Release number of selected component (if applicable):
man-pages-1.67-8

How reproducible:
always

Steps to Reproduce:
1. man inet_network
  
Actual results:
The inet_network() function extracts the network number in host byte order from
the address cp in numbers-and-dots notation. If  the input is invalid, -1 is
returned.

Expected results:
The inet_network() function extracts a number suitable for use as an Internet
address in host byte order from the address cp in numbers-and-dots notation. If
 the input is invalid, -1 is returned.
Comment 1 Tammy Fox 2006-04-22 22:25:46 EDT
This bug should be filed against the man-pages package. Changing component and
bug owner.
Comment 2 Ivana Varekova 2006-04-24 05:04:24 EDT
The network number is used in both functions inet_network and inet_netof but
this number is in different formats.
Comment 3 brett.anderson@speakeasy.net 2006-04-25 11:33:18 EDT
(In reply to comment #2)
> The network number is used in both functions inet_network and inet_netof but
> this number is in different formats.

I think there is some confusion over what a network number is. A network number
is not simply an IPv4 internet address. A network number, is the network portion
of an IPv4 address. The network number is what you get when you do a bitwise AND
of an IP address with a netmask. another way to look at it is that the network
number is the first n bytes of an address where your CIDR is /n. See the
following for a better understanding of the network number and CIDR masking:
http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

The documentation in the man page states that inet_network() extracts the
network number, when it is actually extracting an internet address.
inet_network() does the same thing as inet_addr except that it returns the
address in host byte order instead of network byte order. The description in the
man page is incorrect in that it makes it sound as if inet_network() behaves the
same as inet_netof()

The following code illustrates what I am trying to say:
/*****************************************/
struct sockaddr_in addr;
unsigned long net1, net2;

net1 = inet_network("192.168.0.1");

inet_aton("192.168.0.1", &addr.sin_addr);
net2 = inet_netof(addr.sin_addr);

pprintf("0x%08lX\n", net1);
printf("0x%08lX\n", net2);
/*****************************************/

If you run the above code, you can see that inet_network() returns a 32bit
internet address in host byte order and inet_netof() returns a network address.
If inet_network was to do what the man page description says, it would return
the same result as inet_netof().

Please take a closer look at this. If you do, you should see what I am saying.
If you have any questions, please let me know.

Thanks,
Brett
Comment 4 Ivana Varekova 2006-06-29 07:02:19 EDT
Thank you for your bug report. You are right the man page should be changed.
The problem should be fixed in man-pages-2.34-1.

Note You need to log in before you can comment on or make changes to this bug.