ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line, ether_ntoa_r, ether_aton_r − Ethernet address manipulation routines


#include <netinet/ether.h>

char *ether_ntoa(const struct ether_addr *addr);

struct ether_addr *ether_aton(const char *asc);

int ether_ntohost(char *hostname, const struct ether_addr *addr);

int ether_hostton(const char *hostname, struct ether_addr *addr);

int ether_line(const char *line, struct ether_addr *addr,
char *

/* GNU extensions */
char *ether_ntoa_r(const struct ether_addr *
addr, char *buf);

struct ether_addr *ether_aton_r(const char *asc,
struct ether_addr *


ether_aton() converts the 48-bit Ethernet host address asc from the standard hex-digits-and-colons notation into binary data in network byte order and returns a pointer to it in a statically allocated buffer, which subsequent calls will overwrite. ether_aton() returns NULL if the address is invalid.

The ether_ntoa() function converts the Ethernet host address addr given in network byte order to a string in standard hex-digits-and-colons notation, omitting leading zeros. The string is returned in a statically allocated buffer, which subsequent calls will overwrite.

The ether_ntohost() function maps an Ethernet address to the corresponding hostname in /etc/ethers and returns nonzero if it cannot be found.

The ether_hostton() function maps a hostname to the corresponding Ethernet address in /etc/ethers and returns nonzero if it cannot be found.

The ether_line() function parses a line in /etc/ethers format (ethernet address followed by whitespace followed by hostname; '#' introduces a comment) and returns an address and hostname pair, or nonzero if it cannot be parsed. The buffer pointed to by hostname must be sufficiently long, for example, have the same length as line.

The functions ether_ntoa_r() and ether_aton_r() are reentrant thread-safe versions of ether_ntoa() and ether_aton() respectively, and do not use static buffers.

The structure ether_addr is defined in <net/ethernet.h> as:

struct ether_addr {
uint8_t ether_addr_octet[6];


Multithreading (see pthreads(7))
The ether_aton() and ether_ntoa() functions are not thread-safe.

The ether_ntohost(), ether_hostton(), ether_line(), ether_ntoa_r() and ether_aton_r() functions are thread-safe.


4.3BSD, SunOS.


The glibc 2.2.5 implementation of ether_line() is broken.




This page is part of release 3.69 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at−pages/.

More Linux Commands

gvfs(7) GIO virtual file system (Misc - Linux man page).....
GIO provides a VFS API to GLib applications. It includes a local implementation using POSIX. gvfs provides implementations that go beyond that and allow to acce

Tcl_DStringSetLength(3) - manipulate dynamic strings........
Dynamic strings provide a mechanism for building up arbitrarily long strings by gradually appending information. If the dynamic string is short then there will

ldap_abandon(3) - Abandon an LDAP operation in progress.....
The ldap_abandon_ext() routine is used to send a LDAP Abandon request for an operation in progress. The msgid passed should be the message id of an outstanding

Tcl_FSCreateDirectory(3) - procedures to interact with any f
There are several reasons for calling the Tcl_FS API functions (e.g. Tcl_FSAccess and Tcl_FSStat) rather than calling system level functions like access and sta

ldap_control_find(3) - LDAP control manipulation routines...
These routines are used to manipulate structures used for LDAP controls. ldap_control_create() creates a control with the specified OID using the contents of th

getch(3ncurses) - get (or push back) characters from curses
The getch, wgetch, mvgetch and mvwgetch, routines read a character from the window. In no-delay mode, if no input is waiting, the value ERR is returned. In dela

source(n) - Evaluate a file or resource as a Tcl script.....
This command takes the contents of the specified file or resource and passes it to the Tcl interpreter as a text script. The return value from source is the ret

SDL_UpdateRect(3) - Makes sure the given area is updated on
Makes sure the given area is updated on the given screen. The rectangle must be confined within the screen boundaries (no clipping is done). If x, y, w and h ar

wmemset(3) - fill an array of wide-characters with a constan
The wmemset() function is the wide-character equivalent of the memset(3) function. It fills the array of n wide-characters starting at wcs with n copies of the

mmount(1) - mount an MSDOS disk (Commands - Linux man page)
The mmount command is used to mount an MS-DOS disk. It is only available on Linux, as it is only useful if the OS kernel allows to configure the disk geometry.

Tcl_ExprLongObj(3) - evaluate an expression - Linux man page
These four procedures all evaluate an expression, returning the result in one of four different forms. The expression is given by the objPtr argument, and it ca

pthread_setschedprio(3) - set scheduling priority of a threa
The pthread_setschedprio() function sets the scheduling priority of the thread thread to the value specified in prio. (By contrast pthread_setschedparam(3) chan

We can't live, work or learn in freedom unless the software we use is free.