32
33
memset(&arp[24], 0xff, ETHER_ADDR_LEN);
34
35
if ((pkt = ALLOCA(sizeof *eh_ptr + sizeof arp)) == NULL) {
35
perror("out of memory to send gratuitous arp");
36
logfile(LOG_ERR, _("out of memory to send gratuitous ARP"));
38
39
memcpy(pkt + sizeof *eh_ptr, arp, sizeof arp);
39
eh_ptr = (struct ether_header *) pkt;
40
memcpy(eh_ptr->ether_shost, &arp[8], ETHER_ADDR_LEN);
41
memcpy(eh_ptr->ether_dhost, &arp[18], ETHER_ADDR_LEN);
42
eh_ptr->ether_type = htons(ETHERTYPE_ARP);
41
struct ether_header eh;
43
memcpy(&eh, pkt, sizeof eh);
44
memcpy(&eh.ether_shost, &arp[8], ETHER_ADDR_LEN);
45
memcpy(&eh.ether_dhost, &arp[18], ETHER_ADDR_LEN);
46
eh.ether_type = htons(ETHERTYPE_ARP);
47
memcpy(pkt, &eh, sizeof eh);
43
49
if (write(dev_desc_fd, pkt, sizeof *eh_ptr + sizeof arp) < 0) {
51
logfile(LOG_DEBUG, "write() in garp: %s", strerror(errno));