2 #include <netinet/ether.h>
5 struct ether_addr *ether_aton_r (const char *x, struct ether_addr *p_a)
9 for (int ii = 0; ii < 6; ii++) {
12 if (x[0] != ':') return 0; /* bad format */
15 n = strtoul (x, &y, 16);
17 if (n > 0xFF) return 0; /* bad byte */
18 a.ether_addr_octet[ii] = n;
20 if (x[0] != 0) return 0; /* bad format */
25 struct ether_addr *ether_aton (const char *x)
27 static struct ether_addr a;
28 return ether_aton_r (x, &a);
31 char *ether_ntoa_r (const struct ether_addr *p_a, char *x) {
34 for (int ii = 0; ii < 6; ii++) {
35 x += sprintf (x, ii == 0 ? "%.2X" : ":%.2X", p_a->ether_addr_octet[ii]);
40 char *ether_ntoa (const struct ether_addr *p_a) {
42 return ether_ntoa_r (p_a, x);
45 int ether_line(const char *l, struct ether_addr *e, char *hostname)
50 int ether_ntohost(char *hostname, const struct ether_addr *e)
55 int ether_hostton(const char *hostname, struct ether_addr *e)