diff --git a/core/net/neighbor-attr.c b/core/net/neighbor-attr.c index 361aabf0b..aa1e50b10 100644 --- a/core/net/neighbor-attr.c +++ b/core/net/neighbor-attr.c @@ -151,6 +151,23 @@ neighbor_attr_add_neighbor(const rimeaddr_t *addr) return 1; } /*---------------------------------------------------------------------------*/ +int +neighbor_attr_remove_neighbor(const rimeaddr_t *addr) +{ + struct neighbor_addr *item = neighbor_attr_list_neighbors(); + + while(item != NULL) { + if(rimeaddr_cmp(&item->addr, addr)) { + memb_free(&neighbor_addr_mem, item); + list_remove(neighbor_addrs, item); + return 0; + } else { + item = item->next; + } + } + return -1; +} +/*---------------------------------------------------------------------------*/ void * neighbor_attr_get_data(struct neighbor_attr *def, const rimeaddr_t *addr) { diff --git a/core/net/neighbor-attr.h b/core/net/neighbor-attr.h index a14633e41..bfde86260 100644 --- a/core/net/neighbor-attr.h +++ b/core/net/neighbor-attr.h @@ -112,6 +112,12 @@ int neighbor_attr_has_neighbor(const rimeaddr_t * addr); */ int neighbor_attr_add_neighbor(const rimeaddr_t * addr); +/** + * \brief Remove a neighbor entry to neighbor table + * \retval -1 if unsuccessful, 0 if the neighbor was removed + */ +int neighbor_attr_remove_neighbor(const rimeaddr_t * addr); + /** * \brief Get pointer to neighbor table data specified by id * \param requested attribute