aton3abz
Convert a string to a network structure.
Usage
#include <abz/aton.h> int aton(struct network *net, const char *str);
Libraries
Abz Library (-labz), Debug Library (-ldebug)
Overview
The aton() function converts a string to a network structure which is defined in <abz/aton.h> as follows:
struct network
{
uint32_t address;
uint32_t netmask;
};
Both the address and netmask fields are stored in network byte order.
The network string should be either a valid ip-address, network and CIDR mask, or a valid (resolvable) hostname.
Return value
The aton() function returns 0 if successful or -1 if the string is not a valid network.
Notes
None of the libabz routines are thread-safe. I'm not planning to change this either! For more information, please see http://threading.2038bug.com/
If the library was compiled without the GETHOSTBYNAME flag, only the ip-address and network functionality will be available.
At the time of writing, the glibc library gethostbyname() function had a bug which caused it to resolve some invalid hostnames. In order to detect those cases, the aton() function also does a reverse lookup using gethostbyaddr() to see if the domain really exist.