Skip to content

Commit

Permalink
Merge pull request #43 from WFA-achuang/wfadev
Browse files Browse the repository at this point in the history
Delete ARP entry before sending loopback data for STAUT randomized MAC
  • Loading branch information
WFA-achuang authored Oct 13, 2021
2 parents d2c00d4 + e321143 commit 3d4c211
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions indigo_api_callback_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ static int send_loopback_data_handler(struct packet_wrapper *req, struct packet_
snprintf(pkt_type, sizeof(pkt_type), "udp");
}

/* Detect and delete existing ARP entry for STAUT randomized MAC */
detect_del_arp_entry(dut_ip);

/* Start loopback */
snprintf(recv_count, sizeof(recv_count), "0");

Expand Down
25 changes: 25 additions & 0 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,31 @@ int reset_interface_ip(char *ifname) {
return system(cmd);
}

void detect_del_arp_entry(char *ip) {
char buffer[S_BUFFER_LEN];
char res_ip[32], res_dev[16], res_inf[16];
FILE *fp;

snprintf(buffer, sizeof(buffer), "ip neigh show %s", ip);
fp = popen(buffer, "r");
if (fp == NULL)
return;

if (NULL == fgets(buffer, sizeof(buffer), fp)) {
} else if (3 == sscanf(buffer, "%s %s %s", res_ip, res_dev, res_inf)) {
if (!strcmp(res_ip, ip) && !strcmp(res_dev, "dev")) {
indigo_logger(LOG_LEVEL_INFO, "Delete existing ARP entry: %s", ip);
snprintf(buffer, sizeof(buffer), "ip neigh del %s %s %s", res_ip, res_dev, res_inf);
system(buffer);
} else {
indigo_logger(LOG_LEVEL_INFO, "Format mismatch?: %s %s %s\n", res_ip, res_dev, res_inf);
}
}
pclose(fp);

return;
}

int add_all_wireless_interface_to_bridge(char *br) {
int i;

Expand Down
1 change: 1 addition & 0 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ int reset_interface_ip(char *ifname);
int add_wireless_interface(char *ifname);
int delete_wireless_interface(char *ifname);
void bridge_init(char *br);
void detect_del_arp_entry(char *ip);

#define DEBUG_LEVEL_DISABLE 0
#define DEBUG_LEVEL_BASIC 1
Expand Down

0 comments on commit 3d4c211

Please sign in to comment.