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