|
|
#include <sys/types.h> #include <sys/socket.h> #include <net/if.h> #include <netinet/in.h> #include <netinet/if_ether.h>char * ether_ntoa(ea) struct ether_addr *ea;
struct ether_addr * ether_aton(s) const char *s;
int ether_ntohost(hn, ea) const char *hn; struct ether_addr *ea;
int ether_hostton(hn, ea) const char *hn; struct ether_addr *ea;
int ether_line(l, ea, hn) const char *l; struct ether_addr *ea; char *hn;
The function ether_ntoa converts a 48-bit address (pointed to by ea) to its 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 (with leading 0) between 0 and ff.
The function ether_aton converts an ASCII string back to a 48-bit adddress; the function returns NULL if the string cannot be scanned successfully.
The function ether_ntohost maps a 48-bit address (pointed to by ea) to its associated hostname. The string pointed to by hn must be long enough to hold the hostname and a NULL character.
The function ether_hostton maps a hostname string to its corresponding 48-bit address. This function modifies the address pointed to by ea.
The function ether_line scans a line (pointed to by l) and sets the hostname and the address (pointed to by ea). The string pointed to by hn must be long enough to hold the hostname and a null character. The format of the scanned line is documented in ethers(SFF). If unsuccesful, the function returns the number of missing fields.