1 /* $NetBSD: trygetea.c,v 1.5 2007/03/10 00:16:51 hubertf Exp $ */ 2 3 #include <sys/cdefs.h> 4 #ifndef lint 5 __RCSID("$NetBSD: trygetea.c,v 1.5 2007/03/10 00:16:51 hubertf Exp $"); 6 #endif 7 8 /* 9 * trygetea.c - test program for getether.c 10 */ 11 12 #include <sys/types.h> 13 #include <sys/socket.h> 14 15 #if defined(SUNOS) || defined(SVR4) 16 #include <sys/sockio.h> 17 #endif 18 19 #include <net/if.h> /* for struct ifreq */ 20 #include <netinet/in.h> 21 #include <arpa/inet.h> /* inet_ntoa */ 22 23 #include <netdb.h> 24 #include <stdio.h> 25 #include <errno.h> 26 27 int main(int argc,char ** argv)28main(int argc, char **argv) 29 { 30 u_char ea[16]; /* Ethernet address */ 31 int i; 32 33 if (argc < 2) { 34 fprintf(stderr, "need interface name\n"); 35 exit(1); 36 } 37 if ((i = getether(argv[1], ea)) < 0) { 38 fprintf(stderr, "Could not get Ethernet address (rc=%d)\n", i); 39 exit(1); 40 } 41 printf("Ether-addr"); 42 for (i = 0; i < 6; i++) 43 printf(":%x", ea[i] & 0xFF); 44 printf("\n"); 45 46 return 0; 47 } 48