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