]> git.meshlink.io Git - meshlink/blobdiff - src/node.c
Finish implementation of log callbacks.
[meshlink] / src / node.c
index b7b39927948b2e8579b71a1f07a2aa9261266f99..e6b9f018f46657519b7cceab1939b139ad6f010b 100644 (file)
@@ -104,11 +104,9 @@ void node_del(meshlink_handle_t *mesh, node_t *n) {
        pthread_mutex_unlock(&(mesh->nodes_mutex));
 }
 
-node_t *lookup_node(meshlink_handle_t *mesh, char *name) {
-       node_t n = {NULL};
-       node_t* result;
-
-       n.name = name;
+node_t *lookup_node(meshlink_handle_t *mesh, const char *name) {
+       const node_t n = {.name = (char *)name};
+       node_t *result;
 
        pthread_mutex_lock(&(mesh->nodes_mutex));
        result = splay_search(mesh->nodes, &n);
@@ -123,7 +121,7 @@ node_t *lookup_node_udp(meshlink_handle_t *mesh, const sockaddr_t *sa) {
 
 void update_node_udp(meshlink_handle_t *mesh, node_t *n, const sockaddr_t *sa) {
        if(n == mesh->self) {
-               logger(DEBUG_ALWAYS, LOG_WARNING, "Trying to update UDP address of mesh->self!");
+               logger(mesh, MESHLINK_WARNING, "Trying to update UDP address of mesh->self!");
                return;
        }
 
@@ -141,6 +139,6 @@ void update_node_udp(meshlink_handle_t *mesh, node_t *n, const sockaddr_t *sa) {
                hash_insert(mesh->node_udp_cache, sa, n);
                free(n->hostname);
                n->hostname = sockaddr2hostname(&n->address);
-               logger(DEBUG_PROTOCOL, LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
+               logger(mesh, MESHLINK_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
        }
 }