[lkml]   [2010]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Get interface MAC address in sys_accept4() syscall
    In article <> you write:
    >Yes, I know, but sys_accept4() have int fd argument, that is socket
    >descriptor, can I work with it like raw socket and get MAC from
    >ethernet frame?

    You can do getsockname(2) on the socket and you'll get the IP address
    of the local interface.

    You can then use getifaddrs(3) to get a list of local interfaces,
    loop over all of them, and compare the IP address to the one you got
    from getsockame().

    Once you have the name of the interface, loop over the results
    from getifaddrs() again, and find the AF_PACKET address of that
    interface. The AF_PACKET address has the MAC address. See packet(7).


     \ /
      Last update: 2010-07-30 18:19    [W:0.024 / U:23.388 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site