mi_node_t * mi_tbl_add(EXTAP_DBG_PARM mi_node_t **root, u_int8_t *ip, u_int8_t *mac, int ipver) { int i, len = mi_ip_len(ipver); mi_node_t *a; /* * Non unicast addresses should not be added. Since the * addresses being added come from ARP request/response * (for IPv4), or Neighbor Discovery/Advertisement * (for IPv6) packets, the input need not be validated. */ if ((a = mi_tbl_lkup2(*root, ip, ipver)) != NULL) { eadbg3("%s(%d): ignore dup " eamstr " for " eaistr "\n", f, l, eamac(mac), eaip(ip)); return a; } for (i = 0; i < NUM_MITBL_ENTRIES; i++) { if (mi_node_is_free(&mi_tbl[i])) { OS_MEMCPY(mi_tbl[i].h_dest, mac, ETH_ALEN); OS_MEMCPY(mi_tbl[i].ip, ip, len); mi_tbl[i].ip_ver = ipver; mi_tbl[i].len = len; eadbg3("%s(%d): saving " eamstr " for " eaistr "\n", f, l, eamac(mac), eaip(ip)); return &mi_tbl[i]; } } eadbg3("%s(%d): cant save " eamstr " for " eaistr "\n", f, l, eamac(mac), eaip(ip)); return NULL; }
u_int8_t * mi_tbl_lkup(EXTAP_DBG_PARM mi_node_t *root, u_int8_t *ip, int ipver) { mi_node_t *a = mi_tbl_lkup2(root, ip, ipver); if (a) { return a->h_dest; } eadbg3("%s(%d): lkup failed for " eaistr "\n", f, l, eaip(ip)); return NULL; }
void mi_tbl_del(EXTAP_DBG_PARM mi_node_t **root, u_int8_t *ip, int ipver) { mi_node_t *a = mi_tbl_lkup2(*root, ip, ipver); if (a) { mi_node_free(a); eadbg3("%s(%d): deleting " eamstr " for " eaistr "\n", f, l, eamac(a->h_dest), eaip(ip)); return; } eadbg3("%s(%d): delete failed for " eaistr "\n", f, l, eaip(ip)); return; }