Back to index

glibc  2.9
tst-ether_line.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <netinet/ether.h>
00004 
00005 
00006 static int
00007 do_test (void)
00008 {
00009   struct ether_addr a;
00010   char buf[1000];
00011   if (ether_line ("00:01:02:03:04:05       aaaaa   \n", &a, buf) != 0)
00012     {
00013       puts ("ether_line failed");
00014       return 1;
00015     }
00016 
00017   int res = 0;
00018   int i;
00019   for (i = 0; i < ETH_ALEN; ++i)
00020     {
00021       printf ("%02x%s",
00022              (int) a.ether_addr_octet[i], i + 1 == ETH_ALEN ? "" : ":");
00023       if (a.ether_addr_octet[i] != i)
00024        {
00025          printf ("octet %d is %d, expected %d\n",
00026                 i, (int) a.ether_addr_octet[i], i);
00027          res = 1;
00028        }
00029     }
00030 
00031   printf (" \"%s\"\n", buf);
00032   res |= strcmp (buf, "aaaaa") != 0;
00033 
00034   return res;
00035 }
00036 
00037 #define TEST_FUNCTION do_test ()
00038 #include "../test-skeleton.c"