]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.h
Add duplicate node detection callback.
[meshlink] / src / meshlink.h
index a0cb11877a1d6190ace6d69f903561e80ffa9980..15fb6e6965cedd6569f6de89c30afc00d85eaef3 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
     meshlink.h -- MeshLink API
-    Copyright (C) 2014, 2017 Guus Sliepen <guus@meshlink.io>
+    Copyright (C) 2014-2018 Guus Sliepen <guus@meshlink.io>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -63,6 +63,7 @@ typedef enum {
        MESHLINK_ESTORAGE, ///< MeshLink coud not load or write data from/to disk
        MESHLINK_ENETWORK, ///< MeshLink encountered a network error
        MESHLINK_EPEER, ///< A peer caused an error
+       MESHLINK_ENOTSUP, ///< The operation is not supported in the current configuration of MeshLink
 } meshlink_errno_t;
 
 /// Device class
@@ -241,6 +242,26 @@ typedef void (*meshlink_node_status_cb_t)(meshlink_handle_t *mesh, meshlink_node
  */
 extern void meshlink_set_node_status_cb(meshlink_handle_t *mesh, meshlink_node_status_cb_t cb);
 
+/// A callback reporting duplicate node detection.
+/** @param mesh       A handle which represents an instance of MeshLink.
+ *  @param node       A pointer to a meshlink_node_t describing the node which is duplicate.
+ *                    This pointer is valid until meshlink_close() is called.
+ */
+typedef void (*meshlink_node_duplicate_cb_t)(meshlink_handle_t *mesh, meshlink_node_t *node);
+
+/// Set the node duplicate callback.
+/** This functions sets the callback that is called whenever a duplicate node is detected.
+ *  The callback is run in MeshLink's own thread.
+ *  It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
+ *  to hand the data over to the application's thread.
+ *  The callback should also not block itself and return as quickly as possible.
+ *
+ *  @param mesh      A handle which represents an instance of MeshLink.
+ *  @param cb        A pointer to the function which will be called when a duplicate node is detected.
+ *                   If a NULL pointer is given, the callback will be disabled.
+ */
+extern void meshlink_set_node_duplicate_cb(meshlink_handle_t *mesh, meshlink_node_duplicate_cb_t cb);
+
 /// Severity of log messages generated by MeshLink.
 typedef enum {
        MESHLINK_DEBUG,    ///< Internal debugging messages. Only useful during application development.