Add bug 18604 to NEWS
[glibc.git] / inet / tst-ether_aton.c
blobeba350ed3a7481f0b66cbdfa74be36874c607652
1 #include <stdio.h>
2 #include <string.h>
3 #include <netinet/ether.h>
5 static int
6 do_test (void)
8 struct ether_addr *valp, val;
9 int result, r;
10 char hostname[32], buf[64], *p;
12 valp = ether_aton ("12:34:56:78:9a:bc");
14 printf ("ether_aton (\"12:34:56:78:9a:bc\") = %hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n",
15 valp->ether_addr_octet[0],
16 valp->ether_addr_octet[1],
17 valp->ether_addr_octet[2],
18 valp->ether_addr_octet[3],
19 valp->ether_addr_octet[4],
20 valp->ether_addr_octet[5]);
22 result = (valp->ether_addr_octet[0] != 0x12
23 || valp->ether_addr_octet[1] != 0x34
24 || valp->ether_addr_octet[2] != 0x56
25 || valp->ether_addr_octet[3] != 0x78
26 || valp->ether_addr_octet[4] != 0x9a
27 || valp->ether_addr_octet[5] != 0xbc);
29 if ((r = ether_line ("0:c0:f0:46:5f:97 host.ether.com \t# comment",
30 &val, hostname)) == 0)
32 ether_ntoa_r (&val, buf);
33 p = strchr (buf, '\0');
34 *p++ = ' ';
35 strcpy (p, hostname);
37 printf ("ether_line (\"0:c0:f0:46:5f:97 host.ether.com\") = \"%s\"\n",
38 buf);
40 result |= strcmp ("0:c0:f0:46:5f:97 host.ether.com", buf) != 0;
42 else
44 printf ("ether_line (\"0:c0:f0:46:5f:97 host.ether.com\") = %d\n", r);
45 result |= 1;
48 r = ether_line ("0:c0:2:d0 foo.bar ", &val, hostname);
49 printf ("ether_line (\"0:c0:2:d0 foo.bar \") = %d\n", r);
50 result |= r != -1;
52 r = ether_line ("0:c0:2:d0:1a:2a ", &val, hostname);
53 printf ("ether_line (\"0:c0:2:d0:1a:2a \") = %d\n", r);
54 result |= r != -1;
56 return result;
59 #define TEST_FUNCTION do_test ()
60 #include "../test-skeleton.c"