Main index | Section 3 | 日本語 | Options |
#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
/* * The number of bytes in an ethernet (MAC) address. */ #define ETHER_ADDR_LEN 6/* * Structure of a 48-bit Ethernet address. */ struct ether_addr { u_char octet[ETHER_ADDR_LEN]; };
The function ether_line() scans l, an ASCII string in ethers(5) format and sets e to the ethernet address specified in the string and h to the hostname. This function is used to parse lines from /etc/ethers into their component parts.
The ether_aton() and ether_aton_r() functions convert ASCII representation of ethernet addresses into ether_addr structures. Likewise, the ether_ntoa() and ether_ntoa_r() functions convert ethernet addresses specified as ether_addr structures into ASCII strings.
The ether_ntohost() and ether_hostton() functions map ethernet addresses to their corresponding hostnames as specified in the /etc/ethers database. The ether_ntohost() function converts from ethernet address to hostname, and ether_hostton() converts from hostname to ethernet address.
On success, ether_ntoa() and ether_ntoa_r() functions return a pointer to a string containing an ASCII representation of an ethernet address. If it is unable to convert the supplied ether_addr structure, it returns a NULL pointer. ether_ntoa() stores the result in a static buffer; ether_ntoa_r() stores the result in a user-passed buffer.
Likewise, ether_aton() and ether_aton_r() return a pointer to an ether_addr structure on success and a NULL pointer on failure. ether_aton() stores the result in a static buffer; ether_aton_r() stores the result in a user-passed buffer.
The ether_ntohost() and ether_hostton() functions both return zero on success or non-zero if they were unable to find a match in the /etc/ethers database.
ether_ntoa_r() accepts a character buffer pointer, but not a buffer length. The caller must ensure adequate space is available in the buffer in order to avoid a buffer overflow.
ETHERS (3) | October 30, 2007 |
Main index | Section 3 | 日本語 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | Do you laugh when the waiter drops a tray full of dishes? Unix weenies do. They're the first ones to laugh at hapless users, trying to figure out an error message that doesn't have anything to do with what they just typed. | ” |
— The Unix Haters' handbook |