1 1.5 hubertf /* $NetBSD: trygetea.c,v 1.5 2007/03/10 00:16:51 hubertf Exp $ */ 2 1.3 lukem 3 1.3 lukem #include <sys/cdefs.h> 4 1.3 lukem #ifndef lint 5 1.5 hubertf __RCSID("$NetBSD: trygetea.c,v 1.5 2007/03/10 00:16:51 hubertf 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 <errno.h> 26 1.1 gwr 27 1.4 wiz int 28 1.4 wiz main(int argc, char **argv) 29 1.1 gwr { 30 1.1 gwr u_char ea[16]; /* Ethernet address */ 31 1.1 gwr int i; 32 1.1 gwr 33 1.1 gwr if (argc < 2) { 34 1.5 hubertf fprintf(stderr, "need interface name\n"); 35 1.1 gwr exit(1); 36 1.1 gwr } 37 1.1 gwr if ((i = getether(argv[1], ea)) < 0) { 38 1.5 hubertf fprintf(stderr, "Could not get Ethernet address (rc=%d)\n", i); 39 1.1 gwr exit(1); 40 1.1 gwr } 41 1.1 gwr printf("Ether-addr"); 42 1.1 gwr for (i = 0; i < 6; i++) 43 1.1 gwr printf(":%x", ea[i] & 0xFF); 44 1.1 gwr printf("\n"); 45 1.1 gwr 46 1.5 hubertf return 0; 47 1.1 gwr } 48