home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stream.h>
- #include <sys/stropts.h>
- #include <sys/macstat.h>
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- struct strioctl strioc;
- u_char ether_addr[6];
- int s;
-
- if (argc != 2) {
- fprintf(stderr, "usage: %s deviceFile\n", argv[0]);
- exit (1);
- }
-
- ether_addr[0] = 0;
- ether_addr[1] = 0;
- ether_addr[2] = 0;
- ether_addr[3] = 0;
- ether_addr[4] = 0;
- ether_addr[5] = 0;
-
- if ((s = open(argv[1], 0)) < 0) {
- perror(argv[1]);
- exit(1);
- }
- strioc.ic_cmd = MACIOC_GETADDR;
- strioc.ic_timout = -1;
- strioc.ic_len = sizeof(ether_addr);
- strioc.ic_dp = (caddr_t) ether_addr;
- if (ioctl(s, I_STR, (char *) &strioc) < 0) {
- perror("I_STR: MACIOC_GETADDR");
- exit(1);
- }
-
- printf("%s is using address %02x:%02x:%02x:%02x:%02x:%02x\n",
- argv[1],
- ether_addr[0], ether_addr[1], ether_addr[2],
- ether_addr[3], ether_addr[4], ether_addr[5]);
-
- exit(0);
- }
-