NAME | SYNOPSIS | DESCRIPTION | FILES | ATTRIBUTES | SEE ALSO | BUGS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ] #include <sys/types.h> #include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/if_ether.h>char *ether_ntoa(struct ether_addr *e);
These routines are useful for mapping 48 bit Ethernet numbers to their ASCII representations or their corresponding host names, and vice versa.
The function ether_ntoa() converts a 48 bit Ethernet number pointed to by e to its standard ASCII representation; it returns a pointer to the ASCII string. The representation is of the form x :x :x : x :x :x where x is a hexadecimal number between 0 and ff . The function ether_aton() converts an ASCII string in the standard representation back to a 48 bit Ethernet number; the function returns NULL if the string cannot be scanned successfully.
The function ether_ntohost() maps an Ethernet number (pointed to by e ) to its associated hostname. The string pointed to by hostname must be long enough to hold the hostname and a NULL character. The function returns zero upon success and non-zero upon failure. Inversely, the function ether_hostton() maps a hostname string to its corresponding Ethernet number; the function modifies the Ethernet number pointed to by e . The function also returns zero upon success and non-zero upon failure. In order to do the mapping, both these functions may lookup one or more of the following sources: the ethers file, the NIS maps ``ethers.byname'' and ``ethers.byaddr'' and the NIS+ table ``ethers''. The sources and their lookup order are specified in the /etc/nsswitch.conf file (see nsswitch.conf(4) for details).
The function ether_line() scans a line (pointed to by l ) and sets the hostname and the Ethernet number (pointed to by e ). The string pointed to by hostname must be long enough to hold the hostname and a NULL character. The function returns zero upon success and non-zero upon failure. The format of the scanned line is described by ethers(4) .
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
MT-Level | MT-Safe |
Programs that call ether_hostton() or ether_ntohost() routines cannot be linked statically since the implementation of these routines requires dynamic linker functionality to access shared objects at run time.
NAME | SYNOPSIS | DESCRIPTION | FILES | ATTRIBUTES | SEE ALSO | BUGS