home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / bootpd-2.zip / TRYGETEA.C < prev    next >
C/C++ Source or Header  |  1995-02-16  |  924b  |  54 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. #ifdef _AIX32
  13. #include <sys/time.h>    /* for struct timeval in net/if.h */
  14. #endif
  15. #include <net/if.h>                /* for struct ifreq */
  16. #include <netinet/in.h>
  17. #include <arpa/inet.h>            /* inet_ntoa */
  18.  
  19. #include <netdb.h>
  20. #include <stdio.h>
  21. #include <ctype.h>
  22. #include <errno.h>
  23.  
  24. #include "getether.h"
  25.  
  26. int debug = 0;
  27. char *progname;
  28.  
  29. void
  30. main(argc, argv)
  31.     int argc;
  32.     char **argv;
  33. {
  34.     u_char ea[16];                /* Ethernet address */
  35.     int i;
  36.  
  37.     progname = argv[0];            /* for report */
  38.  
  39.     if (argc < 2) {
  40.         printf("need interface name\n");
  41.         exit(1);
  42.     }
  43.     if ((i = getether(argv[1], (char*)ea)) < 0) {
  44.         printf("Could not get Ethernet address (rc=%d)\n", i);
  45.         exit(1);
  46.     }
  47.     printf("Ether-addr");
  48.     for (i = 0; i < 6; i++)
  49.         printf(":%x", ea[i] & 0xFF);
  50.     printf("\n");
  51.  
  52.     exit(0);
  53. }
  54.