Solaris 8.0 获取 MAC地址的API是什么?

老板逼的,请大虾赐教
---------------------------------------------------------------

获得mac你需要root权限,除非你修改/dev/hme的权限。
源程序如下:(老兄,我花了几个小时跟踪ifconfig才搞定的,还不快给分)

/****************** cut here ******************/
#include

 1<stropts.h>   
 2#include <poll.h>   
 3#include <stdio.h>   
 4  
 5main()   
 6{   
 7int fd;   
 8int flag=0;   
 9unsigned char buf[32];   
10struct strbuf sb;   
11struct pollfd fds[1];   
12  
13sb.maxlen=sizeof(buf);   
14sb.buf=(char *)buf;   
15  
16fd=open("/dev/hme", O_RDWR);   
17if (fd&lt;0)   
18{   
19perror("Error");   
20return(1);   
21}   
22fds[0].fd=fd;   
23fds[0].events=POLLRDNORM &amp;brvbarPOLLRDBAND &amp;brvbarPOLLIN &amp;brvbarPOLLPRI   
24  
25memset(buf, 0, sizeof(buf));   
26sb.len=8;   
27buf[3]=0x0B;   
28putmsg(fd, &amp;sb, NULL, 0);   
29poll(fds, 1, 60000);   
30getmsg(fd, &amp;sb, NULL, &amp;flag);   
31  
32memset(buf, 0, sizeof(buf));   
33sb.len=8;   
34buf[3]=0x31;   
35buf[7]=0x02;   
36putmsg(fd, &amp;sb, NULL, 0);   
37poll(fds, 1, 60000);   
38getmsg(fd, &amp;sb, NULL, &amp;flag);   
39  
40close(fd);   
41printf("%02X:%02X:%02X:%02X:%02X:%02X\n",   
42buf[12], buf[13], buf[14],   
43buf[15], buf[16], buf[17]);   
44return(0);   
45}</stdio.h></poll.h></stropts.h>
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus