/*
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
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
*/
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.