⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 get_mac.c

📁 sco unix下获取网卡程序
💻 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 + -