+ return -1;
+ }
+
+ return 0;
+}
+
+static void __init_ll_addr(struct sockaddr_ll *ll_addr, int ifindex, unsigned char *mac)
+{
+ ll_addr->sll_family = AF_PACKET;
+ ll_addr->sll_protocol = htons(ETH_P_ARP);
+ ll_addr->sll_hatype = htons(ARPHRD_ETHER);
+ ll_addr->sll_pkttype = (PACKET_BROADCAST);
+ ll_addr->sll_halen = MAC_ADDRESS_LENGTH;
+ ll_addr->sll_addr[6] = 0x00;
+ ll_addr->sll_addr[7] = 0x00;
+ ll_addr->sll_ifindex = ifindex;
+ memcpy(ll_addr->sll_addr, mac, MAC_ADDRESS_LENGTH);
+}
+
+static void __set_defend_arp_ethhdr(unsigned char *hw_addr, struct ethhdr *eh)
+{
+ memset(eh->h_dest, 0xff, MAC_ADDRESS_LENGTH);
+ memcpy(eh->h_source, hw_addr, MAC_ADDRESS_LENGTH);
+ eh->h_proto = htons(ETH_P_ARP);
+ return;
+}
+
+static void __set_defend_arp(unsigned char *hw_addr, unsigned char *ip_addr, arp_message_s *ah)
+{
+ ah->arp_hrd = htons(ARPHRD_ETHER);
+ ah->arp_pro = htons(ETH_P_IP);
+ ah->arp_hln = ETH_ALEN;
+ ah->arp_pln = 4;
+ ah->arp_op = htons(ARPOP_REQUEST);
+
+ memcpy(ah->arp_sha, hw_addr, ETH_ALEN);
+ /* by RFC 5227 2.1.1. Probe Details,
+ 'sender IP address' field MUST be set to all zeroes;
+ this is to avoid polluting ARP caches in other hosts
+ on the same link in the case where the address turns
+ out to be already in use by another host. */
+
+ memset(ah->arp_sip, 0x00, 4);
+ //memcpy(ah->arp_sip, ip_conflict_mons.ipaddr, 4);
+
+ memset(ah->arp_tha, 0x00, ETH_ALEN);
+
+ memcpy(ah->arp_tip, ip_addr, 4);
+ return;
+}
+
+static gboolean send_arp(gpointer data)
+{
+ struct sock_data *sd = data;
+ char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, };
+ unsigned int source_ip = 0;
+ unsigned int target_ip = 0;
+ struct sockaddr_ll addr = {0};
+ int ifindex = 0;
+ errno = 0;
+ const char *default_ip = NULL;
+ static int initial_send_arp_count = 0;
+ unsigned char buf[60] = {0, };
+ unsigned char *pos = NULL;
+
+ if (initial_bursts && initial_send_arp_count >= INITIAL_BURST_ARP_COUNT) {
+ initial_bursts = false;
+ initial_send_arp_count = 0;
+ }
+
+ if (initial_bursts)
+ initial_send_arp_count++;
+
+ if (__get_iface_info(&ifindex, mac, ip) == -1) {
+ ERR("__get_iface_info fail");