home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume28 / bootp-2.4.0 / part01 / trygetea.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-22  |  798 b   |  47 lines

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