vxworks

How do I get the MAC address using vxWorks6.8 API in real-time process?


I know endFindByName() and muxIoctl(),but these two functions depend on "muxLib.h" and END_OBJ depend on "end.h".These two header files only be used in kernel mode.


Solution

  • Not 100% sure, but try to use ioctl() with SIOCGIFLLADDR:

    sock = socket (AF_INET, SOCK_DGRAM, 0);
    
    ioctl (sock, SIOCGIFLLADDR, &ifr);
    
    close (sock);
    

    in ifr.ifr_ifru.ifru_addr is your mac.