+class mesh;
+class node;
+class channel;
+
+/// Severity of log messages generated by MeshLink.
+typedef meshlink_log_level_t log_level_t;
+
+/// Code of most recent error encountered.
+typedef meshlink_errno_t errno_t;
+
+/// A callback for receiving data from the mesh.
+/** @param mesh A handle which represents an instance of MeshLink.
+ * @param source A pointer to a meshlink::node describing the source of the data.
+ * @param data A pointer to a buffer containing the data sent by the source.
+ * @param len The length of the received data.
+ */
+typedef void (*receive_cb_t)(mesh *mesh, node *source, const void *data, size_t len);
+
+/// A callback reporting node status changes.
+/** @param mesh A handle which represents an instance of MeshLink.
+ * @param node A pointer to a meshlink::node describing the node whose status changed.
+ * @param reachable True if the node is reachable, false otherwise.
+ */
+typedef void (*node_status_cb_t)(mesh *mesh, node *node, bool reachable);
+
+/// A callback for receiving log messages generated by MeshLink.
+/** @param mesh A handle which represents an instance of MeshLink.
+ * @param level An enum describing the severity level of the message.
+ * @param text A pointer to a string containing the textual log message.
+ */
+typedef void (*log_cb_t)(mesh *mesh, log_level_t level, const char *text);
+
+/// A callback for accepting incoming channels.
+/** @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the incoming channel.
+ * @param port The port number the peer wishes to connect to.
+ * @param data A pointer to a buffer containing data already received. (Not yet used.)
+ * @param len The length of the data. (Not yet used.)
+ *
+ * @return This function should return true if the application accepts the incoming channel, false otherwise.
+ * If returning false, the channel is invalid and may not be used anymore.
+ */
+typedef bool (*channel_accept_cb_t)(mesh *mesh, channel *channel, uint16_t port, const void *data, size_t len);
+
+/// A callback for receiving data from a channel.
+/** @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param data A pointer to a buffer containing data sent by the source.
+ * @param len The length of the data.
+ */
+typedef void (*channel_receive_cb_t)(mesh *mesh, channel *channel, const void *data, size_t len);
+
+/// A callback that is called when data can be send on a channel.
+/** @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param len The maximum length of data that is guaranteed to be accepted by a call to channel_send().
+ */
+typedef void (*channel_poll_cb_t)(mesh *mesh, channel *channel, size_t len);
+
+/// A class describing a MeshLink node.
+class node: public meshlink_node_t {
+};
+
+/// A class describing a MeshLink channel.
+class channel: public meshlink_channel_t {
+public:
+ static const uint32_t RELIABLE = MESHLINK_CHANNEL_RELIABLE;
+ static const uint32_t ORDERED = MESHLINK_CHANNEL_ORDERED;
+ static const uint32_t FRAMED = MESHLINK_CHANNEL_FRAMED;
+ static const uint32_t DROP_LATE = MESHLINK_CHANNEL_DROP_LATE;
+ static const uint32_t TCP = MESHLINK_CHANNEL_TCP;
+ static const uint32_t UDP = MESHLINK_CHANNEL_UDP;
+};
+
+/// A class describing a MeshLink mesh.
+class mesh {
+public:
+ mesh() : handle(0) {}
+
+ virtual ~mesh() {
+ this->close();
+ }