1ETHER_ATON(3) Linux Programmer's Manual ETHER_ATON(3)
2
3
4
6 ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line,
7 ether_ntoa_r, ether_aton_r - Ethernet address manipulation routines
8
10 #include <netinet/ether.h>
11
12 char *ether_ntoa(const struct ether_addr *addr);
13
14 struct ether_addr *ether_aton(const char *asc);
15
16 int ether_ntohost(char *hostname, const struct ether_addr *addr);
17
18 int ether_hostton(const char *hostname, struct ether_addr *addr);
19
20 int ether_line(const char *line, struct ether_addr *addr,
21 char *hostname);
22
23 /* GNU extensions */
24 char *ether_ntoa_r(const struct ether_addr *addr, char *buf);
25
26 struct ether_addr *ether_aton_r(const char *asc,
27 struct ether_addr *addr);
28
30 ether_aton() converts the 48-bit Ethernet host address asc from the
31 standard hex-digits-and-colons notation into binary data in network
32 byte order and returns a pointer to it in a statically allocated buf‐
33 fer, which subsequent calls will overwrite. ether_aton() returns NULL
34 if the address is invalid.
35
36 The ether_ntoa() function converts the Ethernet host address addr given
37 in network byte order to a string in standard hex-digits-and-colons
38 notation, omitting leading zeros. The string is returned in a stati‐
39 cally allocated buffer, which subsequent calls will overwrite.
40
41 The ether_ntohost() function maps an Ethernet address to the corre‐
42 sponding hostname in /etc/ethers and returns nonzero if it cannot be
43 found.
44
45 The ether_hostton() function maps a hostname to the corresponding Eth‐
46 ernet address in /etc/ethers and returns nonzero if it cannot be found.
47
48 The ether_line() function parses a line in /etc/ethers format (ethernet
49 address followed by whitespace followed by hostname; '#' introduces a
50 comment) and returns an address and hostname pair, or nonzero if it
51 cannot be parsed. The buffer pointed to by hostname must be suffi‐
52 ciently long, for example, have the same length as line.
53
54 The functions ether_ntoa_r() and ether_aton_r() are reentrant thread-
55 safe versions of ether_ntoa() and ether_aton() respectively, and do not
56 use static buffers.
57
58 The structure ether_addr is defined in <net/ethernet.h> as:
59
60 struct ether_addr {
61 uint8_t ether_addr_octet[6];
62 }
63
65 For an explanation of the terms used in this section, see
66 attributes(7).
67
68 ┌──────────────────────────────────┬───────────────┬───────────┐
69 │Interface │ Attribute │ Value │
70 ├──────────────────────────────────┼───────────────┼───────────┤
71 │ether_aton(), ether_ntoa() │ Thread safety │ MT-Unsafe │
72 ├──────────────────────────────────┼───────────────┼───────────┤
73 │ether_ntohost(), ether_hostton(), │ Thread safety │ MT-Safe │
74 │ether_line(), ether_ntoa_r(), │ │ │
75 │ether_aton_r() │ │ │
76 └──────────────────────────────────┴───────────────┴───────────┘
78 4.3BSD, SunOS.
79
81 In glibc 2.2.5 and earlier, the implementation of ether_line() is bro‐
82 ken.
83
85 ethers(5)
86
88 This page is part of release 5.02 of the Linux man-pages project. A
89 description of the project, information about reporting bugs, and the
90 latest version of this page, can be found at
91 https://www.kernel.org/doc/man-pages/.
92
93
94
95GNU 2017-09-15 ETHER_ATON(3)