Skip to content

Commit

Permalink
monitor: avoid adding node twice
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Feb 7, 2024
1 parent 4abb332 commit 0ea722d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ static int monitor_gluon_node_add(const char *bssid,
struct gluon_node *node;
char mac_addr_string[20];
char *ie_hex;
size_t i;
int ret;

/* Format MAC-address */
Expand Down Expand Up @@ -456,6 +457,15 @@ static int monitor_gluon_node_add(const char *bssid,
goto out_free;
}

/* Check if node_id was already seen on a prior node in the list */
for (i = 0; i < scanned_nodes.len; i++) {
if (memcmp(node->node_id, scanned_nodes.nodes[i].node_id, 6) == 0) {
log_debug("Node-ID was already seen on a prior node.");
ret = 0;
goto out_free;
}
}

if (!node->node_id[0] && !node->node_id[1] && !node->node_id[2] && !node->node_id[3] && !node->node_id[4] && !node->node_id[5]) {
log_error("Node has no node_id.");
ret = -EINVAL;
Expand Down

0 comments on commit 0ea722d

Please sign in to comment.