?? get_mac.c
字號:
/********************************* begin ********************************/
#include <stdio.h>
#include <sys/types.h>
#include <strings.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/macstat.h>
int main(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);
}
bzero(ether_addr, sizeof(ether_addr));
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);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -