Your skill will accomplish
what the force of many cannot
(OT) Getting the source hardware address of received UDP packets?by Anonymous Monk
|on Jun 01, 2006 at 07:18 UTC||Need Help??|
Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
Say I have a perl program that listens on a udp port/socket on a Linux 2.6 kernel system.
How do I get the source physical/hardware/ethernet address of the received packets?
I want to do this without looking at /proc/net/arp or running /sbin/arp - because this will only have stuff that has a verified IP address.
I know how to get the source IPs of the received packets (the getpeer thingies etc), and the interface the packets come in on (using the Linux specific IP_PKTINFO stuff).
So is it possible to similarly access something like the sockaddr_ll stuff at normal udp socket levels?
I do not want to resort to using a PF_PACKET,SOCK_RAW/SOCK_DGRAM socket or libpcap because I do not want the program to parse and sift through "all" packets. Just want packets destined to that port.
And yes I know ethernet addresses can also be spoofed, I just would like to know what they are when a packet comes in.