- sendto(sock, &rs, sizeof(rs), MSG_DONTWAIT, (struct sockaddr*)&dest, sizeof(dest));
+ size_t len = sizeof(rs);
+
+ struct ifreq ifr;
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));
+ if ((rs_attempt % 2 == 0) && !ioctl(sock, SIOCGIFHWADDR, &ifr)
+ && memcmp(rs.lladdr.data, ifr.ifr_hwaddr.sa_data, 6))
+ memcpy(rs.lladdr.data, ifr.ifr_hwaddr.sa_data, 6);
+ else
+ len = sizeof(struct icmp6_hdr);
+
+ sendto(sock, &rs, len, MSG_DONTWAIT, (struct sockaddr*)&dest, sizeof(dest));