Hi,
I'm writing a program which receives ARP packets and have noticed that
broadcast ARP packets seem to come in with the destination hardware
address set as all zeros.
Whereas tethereal indicates that the packet has a broadcast MAC address.
My code:
int arp_open(struct intf *intf)
{
int as;
struct sockaddr_ll ll;
if ((as = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ARP))) < 0) {
fprintf(stderr,"arp socket failed: %s\n", strerror(errno));
return -1;
}
memset(&ll, 0, sizeof(ll));
ll.sll_family = AF_PACKET;
ll.sll_ifindex = intf->index;
if (bind(as, (struct sockaddr *)&ll, sizeof(ll)) < 0) {
fprintf(stderr,"arp bind failed: %s\n", strerror(errno));
return -1;
}
return as;
}
it then polls the descriptor and does a recv if there is anything to be
read . What I get back from the kernel is, hex values seperates by '!'s
!00!01!08!00!06!04!00!01!00!10!B5!12!E1!F8!CB!07!E3!81!00!00!00!00!00!00!CB!07!E3!BA!00!00!00!00!00!00!00!00!00!00!00!00!00!00!00!00!00!00
which I translate into:
1 2048 6 4 1: 00:10:B5:12:E1:F8 203.7.227.129 -> 00:00:00:00:00:00 203.7.227.186
Is my code doing anything wrong? Should I expect broadcast to be
represented as 00s? I tried looking into the kernel (2.6.15) but quickly
got bogged down in net/packet/afpacket.c.
Thanks,
Anand
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html