]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Avoid using typedefs in meshlink.h.
[meshlink] / src / meshlink.c
index 1b33e88d47d3e3a9801c907f44be42d1a617f306..bb77ccf85da0ad8687d8520b76278738df1ddf12 100644 (file)
@@ -1672,6 +1672,17 @@ void meshlink_set_node_status_cb(meshlink_handle_t *mesh, meshlink_node_status_c
        pthread_mutex_unlock(&(mesh->mesh_mutex));
 }
 
+void meshlink_set_node_pmtu_cb(meshlink_handle_t *mesh, meshlink_node_pmtu_cb_t cb) {
+       if(!mesh) {
+               meshlink_errno = MESHLINK_EINVAL;
+               return;
+       }
+
+       pthread_mutex_lock(&(mesh->mesh_mutex));
+       mesh->node_pmtu_cb = cb;
+       pthread_mutex_unlock(&(mesh->mesh_mutex));
+}
+
 void meshlink_set_node_duplicate_cb(meshlink_handle_t *mesh, meshlink_node_duplicate_cb_t cb) {
        if(!mesh) {
                meshlink_errno = MESHLINK_EINVAL;
@@ -2812,6 +2823,10 @@ void meshlink_whitelist(meshlink_handle_t *mesh, meshlink_node_t *node) {
        node_write_config(mesh, n);
        config_sync(mesh, "current");
 
+       if(n->status.reachable) {
+               update_node_status(mesh, n);
+       }
+
        pthread_mutex_unlock(&(mesh->mesh_mutex));
        return;
 }
@@ -3379,6 +3394,16 @@ void update_node_status(meshlink_handle_t *mesh, node_t *n) {
        if(mesh->node_status_cb) {
                mesh->node_status_cb(mesh, (meshlink_node_t *)n, n->status.reachable && !n->status.blacklisted);
        }
+
+       if(mesh->node_pmtu_cb) {
+               mesh->node_pmtu_cb(mesh, (meshlink_node_t *)n, n->minmtu);
+       }
+}
+
+void update_node_pmtu(meshlink_handle_t *mesh, node_t *n) {
+       if(mesh->node_pmtu_cb && !n->status.blacklisted) {
+               mesh->node_pmtu_cb(mesh, (meshlink_node_t *)n, n->minmtu);
+       }
 }
 
 void handle_duplicate_node(meshlink_handle_t *mesh, node_t *n) {