[MESHLINK_EPEER] = "Error communicating with peer",
[MESHLINK_ENOTSUP] = "Operation not supported",
[MESHLINK_EBUSY] = "MeshLink instance already in use",
+ [MESHLINK_EBLACKLISTED] = "Node is blacklisted",
};
const char *meshlink_strerror(meshlink_errno_t err) {
if(n->status.blacklisted) {
logger(mesh, MESHLINK_ERROR, "Node %s blacklisted, dropping packet\n", n->name);
+ meshlink_errno = MESHLINK_EBLACKLISTED;
return false;
}
node_t *n = (node_t *)node;
+ if(n == mesh->self) {
+ logger(mesh, MESHLINK_ERROR, "%s whitelisting itself?\n", node->name);
+ meshlink_errno = MESHLINK_EINVAL;
+ pthread_mutex_unlock(&mesh->mutex);
+ return;
+ }
+
if(!n->status.blacklisted) {
logger(mesh, MESHLINK_DEBUG, "Node %s was already whitelisted\n", node->name);
- meshlink_errno = MESHLINK_EINVAL;
pthread_mutex_unlock(&mesh->mutex);
return;
}
update_node_status(mesh, n);
}
+ logger(mesh, MESHLINK_DEBUG, "Whitelisted %s.\n", node->name);
+
pthread_mutex_unlock(&mesh->mutex);
return;
}
if(n->status.blacklisted) {
logger(mesh, MESHLINK_ERROR, "Cannot open a channel with blacklisted node\n");
+ meshlink_errno = MESHLINK_EBLACKLISTED;
pthread_mutex_unlock(&mesh->mutex);
return NULL;
}