lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <netinet/ether.h> |
| 4 | |
| 5 | |
| 6 | static int |
| 7 | do_test (void) |
| 8 | { |
| 9 | struct ether_addr a; |
| 10 | char buf[1000]; |
| 11 | if (ether_line ("00:01:02:03:04:05 aaaaa \n", &a, buf) != 0) |
| 12 | { |
| 13 | puts ("ether_line failed"); |
| 14 | return 1; |
| 15 | } |
| 16 | |
| 17 | int res = 0; |
| 18 | int i; |
| 19 | for (i = 0; i < ETH_ALEN; ++i) |
| 20 | { |
| 21 | printf ("%02x%s", |
| 22 | (int) a.ether_addr_octet[i], i + 1 == ETH_ALEN ? "" : ":"); |
| 23 | if (a.ether_addr_octet[i] != i) |
| 24 | { |
| 25 | printf ("octet %d is %d, expected %d\n", |
| 26 | i, (int) a.ether_addr_octet[i], i); |
| 27 | res = 1; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | printf (" \"%s\"\n", buf); |
| 32 | res |= strcmp (buf, "aaaaa") != 0; |
| 33 | |
| 34 | return res; |
| 35 | } |
| 36 | |
| 37 | #define TEST_FUNCTION do_test () |
| 38 | #include "../test-skeleton.c" |