Skip to content
Snippets Groups Projects
Commit 5b5ff583 authored by Lotte Steenbrink's avatar Lotte Steenbrink
Browse files

Merge pull request #3045 from Lotterleben/sixlow_ifs_no_duplicates

sixlowpan_netif: don't add duplicates
parents 1d74a730 74254f5c
No related branches found
No related tags found
No related merge requests found
......@@ -29,17 +29,27 @@ void ng_sixlowpan_netif_init(void)
void ng_sixlowpan_netif_add(kernel_pid_t pid, uint16_t max_frag_size)
{
ng_sixlowpan_netif_t *free_entry = NULL;
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
if (sixlow_ifs[i].pid == pid) {
return;
}
if (sixlow_ifs[i].pid == KERNEL_PID_UNDEF) {
sixlow_ifs[i].pid = pid;
sixlow_ifs[i].max_frag_size = max_frag_size;
return;
if ((sixlow_ifs[i].pid == KERNEL_PID_UNDEF) && !free_entry) {
/* found the first free entry */
free_entry = &sixlow_ifs[i];
}
}
if (!free_entry) {
DEBUG("ng_sixlowpan_netif_add: couldn't add interface with PID %d: No space left.\n", pid);
return;
}
free_entry->pid = pid;
free_entry->max_frag_size = max_frag_size;
return;
}
void ng_sixlowpan_netif_remove(kernel_pid_t pid)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment