fill_arp_packet(&pkt, rif, spa, tpa);
- pkt.arp.arp_op = htons(ARPOP_REPLY);
if (tha) {
+ pkt.arp.arp_op = htons(ARPOP_REPLY);
memcpy(pkt.eth.ether_dhost, tha, ETH_ALEN);
memcpy(pkt.arp.arp_tha, tha, ETH_ALEN);
rif->ifname, IP_BUF(pkt.arp.arp_tpa),
IP_BUF(pkt.arp.arp_spa), MAC_BUF(pkt.eth.ether_shost));
} else {
+ pkt.arp.arp_op = htons(ARPOP_REQUEST);
memset(pkt.eth.ether_dhost, 0xff, ETH_ALEN);
- memset(pkt.arp.arp_tha, 0, ETH_ALEN);
+ memset(pkt.arp.arp_tha, 0xff, ETH_ALEN);
DPRINTF(2, "%s: sending gratuitous ARP: "IP_FMT" is at ("MAC_FMT")\n",
rif->ifname, IP_BUF(pkt.arp.arp_tpa),
sendto(rif->fd.fd, &pkt, sizeof(pkt), 0,
(struct sockaddr *) &rif->sll, sizeof(rif->sll));
+
+ if (tha)
+ return;
+
+ /*
+ * Gratuitous ARP comes in two flavours, request and reply.
+ * Some operating systems only accept request, some only reply.
+ * Let's just send both...
+ */
+ pkt.arp.arp_op = htons(ARPOP_REPLY);
+
+ sendto(rif->fd.fd, &pkt, sizeof(pkt), 0,
+ (struct sockaddr *) &rif->sll, sizeof(rif->sll));
+
}
static void host_entry_timeout(struct uloop_timeout *timeout)