+/// A handle for a node Sub-Mesh.
+struct meshlink_submesh {
+ const char *name;
+ void *priv;
+};
+
+/// An AIO buffer.
+typedef struct meshlink_aio_buffer {
+ const void *data;
+ int fd;
+ size_t len;
+ size_t done;
+ union {
+ meshlink_aio_cb_t buffer;
+ meshlink_aio_fd_cb_t fd;
+ } cb;
+ void *priv;
+ struct meshlink_aio_buffer *next;
+} meshlink_aio_buffer_t;
+
+/// A channel.
+struct meshlink_channel {
+ struct node_t *node;
+ void *priv;
+ bool in_callback;
+
+ struct utcp_connection *c;
+ meshlink_aio_buffer_t *aio_send;
+ meshlink_aio_buffer_t *aio_receive;
+ meshlink_channel_receive_cb_t receive_cb;
+ meshlink_channel_poll_cb_t poll_cb;
+};
+
+/// Header for data packets routed between nodes
+typedef struct meshlink_packethdr {
+ uint8_t destination[16];
+ uint8_t source[16];
+} __attribute__((__packed__)) meshlink_packethdr_t;
+
+void meshlink_send_from_queue(event_loop_t *loop, void *mesh);
+void update_node_status(meshlink_handle_t *mesh, struct node_t *n);
+void update_node_pmtu(meshlink_handle_t *mesh, struct node_t *n);
+extern meshlink_log_level_t global_log_level;
+extern meshlink_log_cb_t global_log_cb;
+void handle_duplicate_node(meshlink_handle_t *mesh, struct node_t *n);
+void handle_network_change(meshlink_handle_t *mesh, bool online);
+void call_error_cb(meshlink_handle_t *mesh, meshlink_errno_t meshlink_errno);
+
+/// Per-instance PRNG
+static inline int prng(meshlink_handle_t *mesh, uint64_t max) {
+ return xoshiro(mesh->prng_state) % max;
+}