ether_aton(3)
β¨ ether_aton(3) β¨
okay bestie so you're in the Library Functions Manual and the page is called ether_aton(3), and it's literally all about Ethernet address manipulation routines. like the whole little family of them. come sit with me π
π NAME π
ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line, ether_ntoa_r, ether_aton_r β Ethernet address manipulation routines
no cap, that's the whole squad. seven whole functions. iconic behavior honestly.
π LIBRARY π
Standard C library (libc, -lc)
π¦ SYNOPSIS π¦
#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 *hostname);
/* 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 *addr);
see those last two? GNU extensions. special little bonus girls β¨
π DESCRIPTION π
ether_aton() takes the 48-bit Ethernet host address asc, which is written in the standard hex-digits-and-colons notation, and converts it into binary data in network byte order. it hands you back a pointer to it in a statically allocated buffer, which means the very next call lowkey overwrites it. so don't get attached π. and if the address is invalid, ether_aton() returns NULL. no address for you bestie.
ether_ntoa() goes the other way β it takes the Ethernet host address addr in network byte order and converts it to a string in standard hex-digits-and-colons notation, and it omits leading zeros (skinny legend). the string comes back in a statically allocated buffer, which again means subsequent calls will overwrite it. it's giving "borrowed and reused".
ether_ntohost() maps an Ethernet address to the corresponding hostname in /etc/ethers, and returns nonzero if it cannot be found.
ether_hostton() maps a hostname to the corresponding Ethernet address in /etc/ethers, and returns nonzero if it cannot be found. yes they're basically each other's mirror selfies πͺ
ether_line() parses a line in /etc/ethers format and returns an address and hostname pair, or nonzero if it cannot be parsed. the format is: ethernet address, then whitespace, then hostname β and a '#' introduces a comment. and listen, important detail: the buffer pointed to by hostname must be sufficiently long β like, for example, have the same length as line. do not skimp on it, she needs room to breathe πΈ
ether_ntoa_r() and ether_aton_r() are reentrant thread-safe versions of ether_ntoa() and ether_aton() respectively, and they do not use static buffers. the upgrade era fr fr π
so the structure ether_addr is defined in <net/ethernet.h> as:
struct ether_addr {
uint8_t ether_addr_octet[6];
}
six octets of pure main character energy π«Ά
π₯ ATTRIBUTES π₯
for an explanation of the terms used in this section, see attributes(7).
ether_aton(),ether_ntoa()β Thread safety:MT-Unsafeether_ntohost(),ether_hostton(),ether_line(),ether_ntoa_r(),ether_aton_r()β Thread safety:MT-Safe
so the first two are the chaotic ones (no shared-buffer safety bestie, that static buffer is a group chat everyone's typing in π) and the rest are the well-behaved thread-safe girlies β¨
β STANDARDS β
None. literally none. not a single standard. she's free-spirited like that π
π HISTORY π
4.3BSD, SunOS.
old money. vintage. we love a classic π
π BUGS π
so in glibc 2.2.5 and earlier, the implementation of ether_line() is broken. that's it, that's the bug notice. if you're on something that ancient, godspeed bestie π―οΈ
π§ SEE ALSO π§
okay and one last vibe check: those static-buffer functions (ether_aton(),ether_ntoa()) will overwrite what they gave you on the next call, so if you're doing threads, reach for the_rversions. no cap, it's literally the whole point of them π
that's the whole page, bestie β sent to you with love from the Linux man-pages 6.20, dated 2026-02-08, and it's ether_aton(3) forever and always ππ
β¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2002, Ian Redfern <redferni@logica.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms