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