+extern void meshlink_set_channel_sndbuf(struct meshlink_handle *mesh, struct meshlink_channel *channel, size_t size);
+
+/// Set the receive buffer size of a channel.
+/** This function sets the desired size of the receive buffer.
+ * The default size is 128 kB.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param size The desired size for the send buffer.
+ * If a NULL pointer is given, the callback will be disabled.
+ */
+extern void meshlink_set_channel_rcvbuf(struct meshlink_handle *mesh, struct meshlink_channel *channel, size_t size);
+
+/// Open a reliable stream channel to another node.
+/** This function is called whenever a remote node wants to open a channel to the local node.
+ * The application then has to decide whether to accept or reject this channel.
+ *
+ * This function returns a pointer to a struct meshlink_channel that will be allocated by MeshLink.
+ * When the application does no longer need to use this channel, it must call meshlink_close()
+ * to free its resources.
+ *
+ * \memberof meshlink_node
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param node The node to which this channel is being initiated.
+ * @param port The port number the peer wishes to connect to.
+ * @param cb A pointer to the function which will be called when the remote node sends data to the local node.
+ * The pointer may be NULL, in which case incoming data is ignored.
+ * @param data A pointer to a buffer containing data to already queue for sending, or NULL if there is no data to send.
+ * After meshlink_send() returns, the application is free to overwrite or free this buffer.
+ * If len is 0, the data pointer is copied into the channel's priv member.
+ * @param len The length of the data, or 0 if there is no data to send.
+ * @param flags A bitwise-or'd combination of flags that set the semantics for this channel.
+ *
+ * @return A handle for the channel, or NULL in case of an error.
+ * The handle is valid until meshlink_channel_close() is called.
+ */
+extern struct meshlink_channel *meshlink_channel_open_ex(struct meshlink_handle *mesh, struct meshlink_node *node, uint16_t port, meshlink_channel_receive_cb_t cb, const void *data, size_t len, uint32_t flags) __attribute__((__warn_unused_result__));
+
+/// Open a reliable stream channel to another node.
+/** This function is called whenever a remote node wants to open a channel to the local node.
+ * The application then has to decide whether to accept or reject this channel.
+ *
+ * This function returns a pointer to a struct meshlink_channel that will be allocated by MeshLink.
+ * When the application does no longer need to use this channel, it must call meshlink_close()
+ * to free its resources.
+ *
+ * Calling this function is equivalent to calling meshlink_channel_open_ex()
+ * with the flags set to MESHLINK_CHANNEL_TCP.
+ *
+ * \memberof meshlink_node
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param node The node to which this channel is being initiated.
+ * @param port The port number the peer wishes to connect to.
+ * @param cb A pointer to the function which will be called when the remote node sends data to the local node.
+ * The pointer may be NULL, in which case incoming data is ignored.
+ * @param data A pointer to a buffer containing data to already queue for sending, or NULL if there is no data to send.
+ * After meshlink_send() returns, the application is free to overwrite or free this buffer.
+ * @param len The length of the data, or 0 if there is no data to send.
+ * If len is 0, the data pointer is copied into the channel's priv member.
+ *
+ * @return A handle for the channel, or NULL in case of an error.
+ * The handle is valid until meshlink_channel_close() is called.
+ */
+extern struct meshlink_channel *meshlink_channel_open(struct meshlink_handle *mesh, struct meshlink_node *node, uint16_t port, meshlink_channel_receive_cb_t cb, const void *data, size_t len) __attribute__((__warn_unused_result__));
+
+/// Partially close a reliable stream channel.
+/** This shuts down the read or write side of a channel, or both, without closing the handle.
+ * It can be used to inform the remote node that the local node has finished sending all data on the channel,
+ * but still allows waiting for incoming data from the remote node.
+ *
+ * Shutting down the receive direction is also possible, and is equivalent to setting the receive callback to NULL.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param direction Must be one of SHUT_RD, SHUT_WR or SHUT_RDWR, otherwise this call will not have any affect.
+ */
+extern void meshlink_channel_shutdown(struct meshlink_handle *mesh, struct meshlink_channel *channel, int direction);
+
+/// Close a reliable stream channel.
+/** This informs the remote node that the local node has finished sending all data on the channel.
+ * It also causes the local node to stop accepting incoming data from the remote node.
+ * It will free the struct meshlink_channel and all associated resources.
+ * Afterwards, the channel handle is invalid and must not be used any more.
+ *
+ * It is allowed to call this function at any time on a valid handle, even inside callback functions.
+ * If called with a valid handle, this function always succeeds, otherwise the result is undefined.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ */
+extern void meshlink_channel_close(struct meshlink_handle *mesh, struct meshlink_channel *channel);
+
+/// Transmit data on a channel
+/** This queues data to send to the remote node.
+ *
+ * \memberof meshlink_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, or NULL if there is no data to send.
+ * After meshlink_send() returns, the application is free to overwrite or free this buffer.
+ * @param len The length of the data, or 0 if there is no data to send.
+ *
+ * @return The amount of data that was queued, which can be less than len, or a negative value in case of an error.
+ * If MESHLINK_CHANNEL_NO_PARTIAL is set, then the result will either be len,
+ * 0 if the buffer is currently too full, or -1 if len is too big even for an empty buffer.
+ */
+extern ssize_t meshlink_channel_send(struct meshlink_handle *mesh, struct meshlink_channel *channel, const void *data, size_t len) __attribute__((__warn_unused_result__));
+
+/// A callback for cleaning up buffers submitted for asynchronous I/O.
+/** This callbacks signals that MeshLink has finished using this buffer.
+ * The ownership of the buffer is now back into the application's hands.
+ *
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel which used this buffer.
+ * @param data A pointer to a buffer containing the enqueued data.
+ * @param len The length of the buffer.
+ * @param priv A private pointer which was set by the application when submitting the buffer.
+ */
+typedef void (*meshlink_aio_cb_t)(struct meshlink_handle *mesh, struct meshlink_channel *channel, const void *data, size_t len, void *priv);
+
+/// A callback for asynchronous I/O to and from filedescriptors.
+/** This callbacks signals that MeshLink has finished using this filedescriptor.
+ *
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel which used this filedescriptor.
+ * @param fd The filedescriptor that was used.
+ * @param len The length of the data that was successfully sent or received.
+ * @param priv A private pointer which was set by the application when submitting the buffer.
+ */
+typedef void (*meshlink_aio_fd_cb_t)(struct meshlink_handle *mesh, struct meshlink_channel *channel, int fd, size_t len, void *priv);
+
+/// Transmit data on a channel asynchronously
+/** This registers a buffer that will be used to send data to the remote node.
+ * Multiple buffers can be registered, in which case data will be sent in the order the buffers were registered.
+ * While there are still buffers with unsent data, the poll callback will not be called.
+ *
+ * \memberof meshlink_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, or NULL if there is no data to send.
+ * After meshlink_channel_aio_send() returns, the buffer may not be modified or freed by the application
+ * until the callback routine is called.
+ * @param len The length of the data, or 0 if there is no data to send.
+ * @param cb A pointer to the function which will be called when MeshLink has finished using the buffer.
+ * @param priv A private pointer which is passed unchanged to the callback.
+ *
+ * @return True if the buffer was enqueued, false otherwise.
+ */
+extern bool meshlink_channel_aio_send(struct meshlink_handle *mesh, struct meshlink_channel *channel, const void *data, size_t len, meshlink_aio_cb_t cb, void *priv) __attribute__((__warn_unused_result__));
+
+/// Transmit data on a channel asynchronously from a filedescriptor
+/** This will read up to the specified length number of bytes from the given filedescriptor, and send it over the channel.
+ * The callback may be returned early if there is an error reading from the filedescriptor.
+ * While there is still with unsent data, the poll callback will not be called.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param fd A file descriptor from which data will be read.
+ * @param len The length of the data, or 0 if there is no data to send.
+ * @param cb A pointer to the function which will be called when MeshLink has finished using the filedescriptor.
+ * @param priv A private pointer which is passed unchanged to the callback.
+ *
+ * @return True if the buffer was enqueued, false otherwise.
+ */
+extern bool meshlink_channel_aio_fd_send(struct meshlink_handle *mesh, struct meshlink_channel *channel, int fd, size_t len, meshlink_aio_fd_cb_t cb, void *priv) __attribute__((__warn_unused_result__));
+
+/// Receive data on a channel asynchronously
+/** This registers a buffer that will be filled with incoming channel data.
+ * Multiple buffers can be registered, in which case data will be received in the order the buffers were registered.
+ * While there are still buffers that have not been filled, the receive callback will not be called.
+ *
+ * \memberof meshlink_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 that will be filled with incoming data.
+ * After meshlink_channel_aio_receive() returns, the buffer may not be modified or freed by the application
+ * until the callback routine is called.
+ * @param len The length of the data.
+ * @param cb A pointer to the function which will be called when MeshLink has finished using the buffer.
+ * @param priv A private pointer which is passed unchanged to the callback.
+ *
+ * @return True if the buffer was enqueued, false otherwise.
+ */
+extern bool meshlink_channel_aio_receive(struct meshlink_handle *mesh, struct meshlink_channel *channel, const void *data, size_t len, meshlink_aio_cb_t cb, void *priv) __attribute__((__warn_unused_result__));
+
+/// Receive data on a channel asynchronously and send it to a filedescriptor
+/** This will read up to the specified length number of bytes from the channel, and send it to the filedescriptor.
+ * The callback may be returned early if there is an error writing to the filedescriptor.
+ * While there is still unread data, the receive callback will not be called.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param fd A file descriptor to which data will be written.
+ * @param len The length of the data.
+ * @param cb A pointer to the function which will be called when MeshLink has finished using the filedescriptor.
+ * @param priv A private pointer which was set by the application when submitting the buffer.
+ *
+ * @return True if the buffer was enqueued, false otherwise.
+ */
+extern bool meshlink_channel_aio_fd_receive(struct meshlink_handle *mesh, struct meshlink_channel *channel, int fd, size_t len, meshlink_aio_fd_cb_t cb, void *priv) __attribute__((__warn_unused_result__));
+
+/// Get channel flags.
+/** This returns the flags used when opening this channel.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ *
+ * @return The flags set for this channel.
+ */
+extern uint32_t meshlink_channel_get_flags(struct meshlink_handle *mesh, struct meshlink_channel *channel) __attribute__((__warn_unused_result__));
+
+/// Get the amount of bytes in the send buffer.
+/** This returns the amount of bytes in the send buffer.
+ * These bytes have not been received by the peer yet.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ *
+ * @return The amount of un-ACKed bytes in the send buffer.
+ */
+extern size_t meshlink_channel_get_sendq(struct meshlink_handle *mesh, struct meshlink_channel *channel) __attribute__((__warn_unused_result__));
+
+/// Get the amount of bytes in the receive buffer.
+/** This returns the amount of bytes in the receive buffer.
+ * These bytes have not been processed by the application yet.
+ *
+ * \memberof meshlink_channel
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ *
+ * @return The amount of bytes in the receive buffer.
+ */
+extern size_t meshlink_channel_get_recvq(struct meshlink_handle *mesh, struct meshlink_channel *channel) __attribute__((__warn_unused_result__));
+
+/// Set the connection timeout used for channels to the given node.
+/** This sets the timeout after which unresponsive channels will be reported as closed.
+ * The timeout is set for all current and future channels to the given node.
+ *
+ * \memberof meshlink_node
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param channel A handle for the channel.
+ * @param timeout The timeout in seconds after which unresponsive channels will be reported as closed.
+ * The default is 60 seconds.
+ */
+extern void meshlink_set_node_channel_timeout(struct meshlink_handle *mesh, struct meshlink_node *node, int timeout);
+
+/// Hint that a hostname may be found at an address
+/** This function indicates to meshlink that the given hostname is likely found
+ * at the given IP address and port.
+ *
+ * \memberof meshlink_node
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param node A pointer to a struct meshlink_node describing the node to add the address hint for.
+ * @param addr The IP address and port which should be tried for the
+ * given hostname. The caller is free to overwrite or free
+ * this memory once meshlink returns.
+ */
+extern void meshlink_hint_address(struct meshlink_handle *mesh, struct meshlink_node *node, const struct sockaddr *addr);
+
+/// Enable or disable zeroconf discovery of local peers
+/** This controls whether zeroconf discovery using the Catta library will be
+ * enabled to search for peers on the local network. By default, it is enabled.
+ *
+ * \memberof meshlink_handle
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param enable Set to true to enable discovery, false to disable.
+ */
+extern void meshlink_enable_discovery(struct meshlink_handle *mesh, bool enable);
+
+/// Performs key rotation for an encrypted storage
+/** This rotates the (master) key for an encrypted storage and discards the old key
+ * if the call succeeded. This is an atomic call.
+ *
+ * \memberof meshlink_handle
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param key A pointer to the new key used to encrypt storage.
+ * @param keylen The length of the new key in bytes.
+ *
+ * @return This function returns true if the key rotation for the encrypted storage succeeds, false otherwise.
+ */
+extern bool meshlink_encrypted_key_rotate(struct meshlink_handle *mesh, const void *key, size_t keylen) __attribute__((__warn_unused_result__));
+
+/// Set device class timeouts
+/** This sets the ping interval and timeout for a given device class.
+ *
+ * \memberof meshlink_handle
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param devclass The device class to update
+ * @param pinginterval The interval between keepalive packets, in seconds. The default is 60.
+ * @param pingtimeout The required time within which a peer should respond, in seconds. The default is 5.
+ * The timeout must be smaller than the interval.
+ */
+extern void meshlink_set_dev_class_timeouts(struct meshlink_handle *mesh, dev_class_t devclass, int pinginterval, int pingtimeout);
+
+/// Set device class fast retry period
+/** This sets the fast retry period for a given device class.
+ * During this period after the last time the mesh becomes unreachable, connections are tried once a second.
+ *
+ * \memberof meshlink_handle
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param devclass The device class to update
+ * @param fast_retry_period The period during which fast connection retries are done. The default is 0.
+ */
+extern void meshlink_set_dev_class_fast_retry_period(struct meshlink_handle *mesh, dev_class_t devclass, int fast_retry_period);
+
+/// Set which order invitations are committed
+/** This determines in which order configuration files are written to disk during an invitation.
+ * By default, the invitee saves the configuration to disk first, then the inviter.
+ * By calling this function with @a inviter_commits_first set to true, the order is reversed.
+ *
+ * \memberof meshlink_handle
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param inviter_commits_first If true, then the node that invited a peer will commit data to disk first.
+ */
+extern void meshlink_set_inviter_commits_first(struct meshlink_handle *mesh, bool inviter_commits_first);
+
+/// Set the URL used to discover the host's external address
+/** For generating invitation URLs, MeshLink can look up the externally visible address of the local node.
+ * It does so by querying an external service. By default, this is http://meshlink.io/host.cgi.
+ * Only URLs starting with http:// are supported.
+ *
+ * \memberof meshlink_handle
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param url The URL to use for external address queries, or NULL to revert back to the default URL.
+ */
+extern void meshlink_set_external_address_discovery_url(struct meshlink_handle *mesh, const char *url);
+
+#ifdef __cplusplus
+}
+#endif