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.
This bug should be filed against the man-pages package. Changing component and bug owner.
The network number is used in both functions inet_network and inet_netof but this number is in different formats.
(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
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.