开发者

IOKit header assert.h gone?

I want to get the hardware address of my mac's ethernet card. In all samples I saw in include on IOKit/assert.h . Which doesn't seem to exist on my system. GCC throws an error saying he doesn't know the type开发者_如何学Python IOEthernetAddress. Is assert.h necessary for my task? It would be great if someone coud give me a working sample. [edit] here's my code, think this will help understanding the problem:

#include <IOKit/assert.h>
#include <IOKit/network/IOEthernetController.h>
#include <IOKit/network/IOEthernetInterface.h>

int main(){
    IOEthernetAddress addr;
    getHardwareAddress(&addr);
    printf("%x", addr);
    return 0;
}


You must be trying to do this from userspace; you wouldn't be using main() if you were writing for the kernel. however, these are kernel include files. One way to do this from userspace is to look at the I/O registry, and find the IOMACAddress for the piece of hardware that interests you. To get started with this, take a look at I/O Registry Explorer.

Another way is to use ioctl with SIOCSIFLLADDR, to get the link level address.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜