[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <201007301615.o6UGFill008660@xs8.xs4all.nl>
Date: Fri, 30 Jul 2010 18:15:44 +0200
From: "Miquel van Smoorenburg" <mikevs@...all.net>
To: savinov.guram@...il.com
Cc: linux-kernel@...r.kernel.org
Subject: Re: Get interface MAC address in sys_accept4() syscall
In article <AANLkTin8vaiWTRTM+WzZ_PAWO6j-voP29n1jHfLv+=q3@...l.gmail.com> 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).
Mike.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists