]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Add a callback that notifies the application when it is blacklisted.
[meshlink] / src / meshlink.c
index 4f9c5f407ba93b6680faa8aef5c8c3d6c0a10ede..ee62078d8b16a55a31c363eb3d77f01fdbdb5b63 100644 (file)
@@ -2060,6 +2060,20 @@ void meshlink_set_error_cb(struct meshlink_handle *mesh, meshlink_error_cb_t cb)
        pthread_mutex_unlock(&mesh->mutex);
 }
 
+void meshlink_set_blacklisted_cb(struct meshlink_handle *mesh, meshlink_blacklisted_cb_t cb) {
+       if(!mesh) {
+               meshlink_errno = MESHLINK_EINVAL;
+               return;
+       }
+
+       if(pthread_mutex_lock(&mesh->mutex) != 0) {
+               abort();
+       }
+
+       mesh->blacklisted_cb = cb;
+       pthread_mutex_unlock(&mesh->mutex);
+}
+
 static bool prepare_packet(meshlink_handle_t *mesh, meshlink_node_t *destination, const void *data, size_t len, vpn_packet_t *packet) {
        meshlink_packethdr_t *hdr;