X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink.c;h=4f9c5f407ba93b6680faa8aef5c8c3d6c0a10ede;hb=001cbb9549f17153536ee6a01a783eb85bf54962;hp=56da2a045452acf8004b0d0a04cbf1e7e2810ceb;hpb=c4deb6c20dceb73c0ac6baa2eb901434584e6191;p=meshlink diff --git a/src/meshlink.c b/src/meshlink.c index 56da2a04..4f9c5f40 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -2360,6 +2360,10 @@ static bool search_node_by_dev_class(const node_t *node, const void *condition) return false; } +static bool search_node_by_blacklisted(const node_t *node, const void *condition) { + return *(bool *)condition == node->status.blacklisted; +} + static bool search_node_by_submesh(const node_t *node, const void *condition) { if(condition == node->submesh) { return true; @@ -2422,6 +2426,15 @@ meshlink_node_t **meshlink_get_all_nodes_by_last_reachable(meshlink_handle_t *me return meshlink_get_all_nodes_by_condition(mesh, &range, nodes, nmemb, search_node_by_last_reachable); } +meshlink_node_t **meshlink_get_all_nodes_by_blacklisted(meshlink_handle_t *mesh, bool blacklisted, meshlink_node_t **nodes, size_t *nmemb) { + if(!mesh || !nmemb) { + meshlink_errno = MESHLINK_EINVAL; + return NULL; + } + + return meshlink_get_all_nodes_by_condition(mesh, &blacklisted, nodes, nmemb, search_node_by_blacklisted); +} + dev_class_t meshlink_get_node_dev_class(meshlink_handle_t *mesh, meshlink_node_t *node) { if(!mesh || !node) { meshlink_errno = MESHLINK_EINVAL; @@ -2441,6 +2454,28 @@ dev_class_t meshlink_get_node_dev_class(meshlink_handle_t *mesh, meshlink_node_t return devclass; } +bool meshlink_get_node_blacklisted(meshlink_handle_t *mesh, meshlink_node_t *node) { + if(!mesh) { + meshlink_errno = MESHLINK_EINVAL; + } + + if(!node) { + return mesh->default_blacklist; + } + + bool blacklisted; + + if(pthread_mutex_lock(&mesh->mutex) != 0) { + abort(); + } + + blacklisted = ((node_t *)node)->status.blacklisted; + + pthread_mutex_unlock(&mesh->mutex); + + return blacklisted; +} + meshlink_submesh_t *meshlink_get_node_submesh(meshlink_handle_t *mesh, meshlink_node_t *node) { if(!mesh || !node) { meshlink_errno = MESHLINK_EINVAL; @@ -3430,6 +3465,9 @@ static bool blacklist(meshlink_handle_t *mesh, node_t *n) { mesh->node_status_cb(mesh, (meshlink_node_t *)n, false); } + /* Remove any outstanding invitations */ + invitation_purge_node(mesh, n->name); + return node_write_config(mesh, n) && config_sync(mesh, "current"); } @@ -3609,6 +3647,9 @@ bool meshlink_forget_node(meshlink_handle_t *mesh, meshlink_node_t *node) { return false; } + /* Delete any pending invitations */ + invitation_purge_node(mesh, n->name); + /* Delete the node struct and any remaining edges referencing this node */ node_del(mesh, n); @@ -3904,9 +3945,6 @@ static void channel_poll(struct utcp_connection *connection, size_t len) { } if(sent != (ssize_t)todo) { - /* We should never get a partial send at this point */ - assert(sent <= 0); - /* Sending failed, abort all outstanding AIO buffers and send a poll callback. */ if(!aio_abort(mesh, channel, &channel->aio_send)) { return;