]> git.meshlink.io Git - meshlink-tiny/blobdiff - src/meshlink-tiny.h
Add a metering test.
[meshlink-tiny] / src / meshlink-tiny.h
index a0ca5fe2b07bf80e95a0789b3362b5418123fc13..953a0e930d541cc14bdc0db13e863bf11c73fdc6 100644 (file)
@@ -48,9 +48,6 @@ typedef struct meshlink_handle meshlink_handle_t;
 /// A handle for a MeshLink node.
 typedef struct meshlink_node meshlink_node_t;
 
-/// A handle for a MeshLink channel.
-typedef struct meshlink_channel meshlink_channel_t;
-
 /// A struct containing all parameters used for opening a mesh.
 typedef struct meshlink_open_params meshlink_open_params_t;
 
@@ -94,15 +91,6 @@ static const uint32_t MESHLINK_INVITE_IPV4 = 4;     // Only use IPv4 addresses i
 static const uint32_t MESHLINK_INVITE_IPV6 = 8;     // Only use IPv6 addresses in the URL
 static const uint32_t MESHLINK_INVITE_NUMERIC = 16; // Don't look up hostnames
 
-/// Channel flags
-static const uint32_t MESHLINK_CHANNEL_RELIABLE = 1;   // Data is retransmitted when packets are lost.
-static const uint32_t MESHLINK_CHANNEL_ORDERED = 2;    // Data is delivered in-order to the application.
-static const uint32_t MESHLINK_CHANNEL_FRAMED = 4;     // Data is delivered in chunks of the same length as data was originally sent.
-static const uint32_t MESHLINK_CHANNEL_DROP_LATE = 8;  // When packets are reordered, late packets are ignored.
-static const uint32_t MESHLINK_CHANNEL_NO_PARTIAL = 16; // Calls to meshlink_channel_send() will either send all data or nothing.
-static const uint32_t MESHLINK_CHANNEL_TCP = 3;        // Select TCP semantics.
-static const uint32_t MESHLINK_CHANNEL_UDP = 0;        // Select UDP semantics.
-
 /// A variable holding the last encountered error from MeshLink.
 /** This is a thread local variable that contains the error code of the most recent error
  *  encountered by a MeshLink API function called in the current thread.
@@ -123,11 +111,6 @@ struct meshlink_node {
        void *priv;             ///< Private pointer which may be set freely by the application, and is never used or modified by MeshLink.
 };
 
-struct meshlink_channel {
-       struct meshlink_node *const node; ///< Pointer to the peer of this channel.
-       void *priv;                       ///< Private pointer which may be set freely by the application, and is never used or modified by MeshLink.
-};
-
 #endif // MESHLINK_INTERNAL_H
 
 /// Get the text for the given MeshLink error code.
@@ -333,7 +316,6 @@ bool meshlink_start(struct meshlink_handle *mesh) __attribute__((__warn_unused_r
  *  close all sockets, and shut down its own thread.
  *
  *  This function always succeeds. It is allowed to call meshlink_stop() even if MeshLink is already stopped or has never been started.
- *  Channels that are still open will remain valid, but any communication via channels will stop as well.
  *
  *  \memberof meshlink_handle
  *  @param mesh     A handle which represents an instance of MeshLink.
@@ -342,8 +324,8 @@ void meshlink_stop(struct meshlink_handle *mesh);
 
 /// Close the MeshLink handle.
 /** This function calls meshlink_stop() if necessary,
- *  and frees the struct meshlink_handle and all associacted memory allocated by MeshLink, including all channels.
- *  Afterwards, the handle and any pointers to a struct meshlink_node or struct meshlink_channel are invalid.
+ *  and frees the struct meshlink_handle and all associacted memory allocated by MeshLink.
+ *  Afterwards, the handle and any pointers to a struct meshlink_node are invalid.
  *
  *  It is allowed to call this function at any time on a valid handle, except inside callback functions.
  *  If called at a proper time with a valid handle, this function always succeeds.
@@ -448,28 +430,6 @@ typedef void (*meshlink_node_status_cb_t)(struct meshlink_handle *mesh, struct m
  */
 void meshlink_set_node_status_cb(struct meshlink_handle *mesh, meshlink_node_status_cb_t cb);
 
-/// A callback reporting node path MTU changes.
-/** @param mesh      A handle which represents an instance of MeshLink.
- *  @param node       A pointer to a struct meshlink_node describing the node whose status changed.
- *                    This pointer is valid until meshlink_close() is called.
- *  @param pmtu       The current path MTU to the node, or 0 if UDP communication is not (yet) possible.
- */
-typedef void (*meshlink_node_pmtu_cb_t)(struct meshlink_handle *mesh, struct meshlink_node *node, uint16_t pmtu);
-
-/// Set the node extended status callback.
-/** This functions sets the callback that is called whenever certain connectivity parameters for a node change.
- *  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.
- *
- *  \memberof meshlink_handle
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param cb        A pointer to the function which will be called when another node's extended status changes.
- *                   If a NULL pointer is given, the callback will be disabled.
- */
-void meshlink_set_node_pmtu_cb(struct meshlink_handle *mesh, meshlink_node_pmtu_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 struct meshlink_node describing the node which is duplicate.
@@ -572,7 +532,6 @@ void meshlink_set_error_cb(struct meshlink_handle *mesh, meshlink_error_cb_t cb)
  *  the packet is sent as one unit and is received as one unit,
  *  and that there is no guarantee that the packet will arrive at the destination.
  *  Packets that are too big to be sent over the network as one unit might be dropped, and this function may return an error if this situation can be detected beforehand.
- *  The application should not send packets that are larger than the path MTU, which can be queried with meshlink_get_pmtu().
  *  The application should take care of getting an acknowledgement and retransmission if necessary.
  *
  *  \memberof meshlink_node
@@ -587,22 +546,6 @@ void meshlink_set_error_cb(struct meshlink_handle *mesh, meshlink_error_cb_t cb)
  */
 bool meshlink_send(struct meshlink_handle *mesh, struct meshlink_node *destination, const void *data, size_t len) __attribute__((__warn_unused_result__));
 
-/// Query the maximum packet size that can be sent to a node.
-/** This functions returns the maximum size of packets (path MTU) that can be sent to a specific node with meshlink_send().
- *  The path MTU is a property of the path packets will take to the destination node over the Internet.
- *  It can be different for different destination nodes.
- *  and the path MTU can change at any point in time due to changes in the Internet.
- *  Therefore, although this should only occur rarely, it can still happen that packets that do not exceed this size get dropped.
- *
- *  \memberof meshlink_node
- *  @param mesh         A handle which represents an instance of MeshLink.
- *  @param destination  A pointer to a struct meshlink_node describing the destination for the data.
- *
- *  @return             The recommended maximum size of packets that are to be sent to the destination node, 0 if the node is unreachable,
- *                      or a negative value in case of an error.
- */
-ssize_t meshlink_get_pmtu(struct meshlink_handle *mesh, struct meshlink_node *destination) __attribute__((__warn_unused_result__));
-
 /// Get a handle for our own node.
 /** This function returns a handle for the local node.
  *
@@ -734,22 +677,6 @@ struct meshlink_node **meshlink_get_all_nodes_by_last_reachable(struct meshlink_
  */
 dev_class_t meshlink_get_node_dev_class(struct meshlink_handle *mesh, struct meshlink_node *node) __attribute__((__warn_unused_result__));
 
-/// Get a node's reachability status.
-/** This function returns the current reachability of a given node, and the times of the last state changes.
- *  If a given state change never happened, the time returned will be 0.
- *
- *  \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.
- *  @param last_reachable    A pointer to a time_t variable that will be filled in with the last time the node became reachable.
- *                           Pass NULL to not have anything written.
- *  @param last_unreachable  A pointer to a time_t variable that will be filled in with the last time the node became unreachable.
- *                           Pass NULL to not have anything written.
- *
- *  @return                  This function returns true if the node is currently reachable, false otherwise.
- */
-bool meshlink_get_node_reachability(struct meshlink_handle *mesh, struct meshlink_node *node, time_t *last_reachable, time_t *last_unreachable);
-
 /// Verify the signature generated by another node of a piece of data.
 /** This function verifies the signature that another node generated for a piece of data.
  *
@@ -855,8 +782,6 @@ bool meshlink_import(struct meshlink_handle *mesh, const char *data) __attribute
 /** This function allows the local node to forget any information it has about a node,
  *  and if possible will remove any data it has stored on disk about the node.
  *
- *  Any open channels to this node must be closed before calling this function.
- *
  *  After this call returns, the node handle is invalid and may no longer be used, regardless
  *  of the return value of this call.
  *
@@ -873,461 +798,6 @@ bool meshlink_import(struct meshlink_handle *mesh, const char *data) __attribute
  */
 bool meshlink_forget_node(struct meshlink_handle *mesh, struct meshlink_node *node);
 
-/// A callback for listening for incoming channels.
-/** This function is called whenever a remote node wants to open a channel to the local node.
- *  This callback should only make a decision whether to accept or reject this channel.
- *  The accept callback should be set to get a handle to the actual channel.
- *
- *  The callback is run in MeshLink's own thread.
- *  It is therefore important that the callback return quickly and uses apprioriate methods (queues, pipes, locking, etc.)
- *  to hand any data over to the application's thread.
- *
- *  @param mesh         A handle which represents an instance of MeshLink.
- *  @param node         A handle for the node that wants to open a channel.
- *  @param port         The port number the peer wishes to connect to.
- *
- *  @return             This function should return true if the application accepts the incoming channel, false otherwise.
- */
-typedef bool (*meshlink_channel_listen_cb_t)(struct meshlink_handle *mesh, struct meshlink_node *node, uint16_t port);
-
-/// A callback for accepting incoming channels.
-/** This function is called whenever a remote node has opened a channel to the local node.
- *
- *  The callback is run in MeshLink's own thread.
- *  It is therefore important that the callback return quickly and uses apprioriate methods (queues, pipes, locking, etc.)
- *  to hand any data over to the application's thread.
- *
- *  @param mesh         A handle which represents an instance of MeshLink.
- *  @param channel      A handle for the incoming channel.
- *                      If the application accepts the incoming channel by returning true,
- *                      then this handle is valid until meshlink_channel_close() is called on it.
- *                      If the application rejects the incoming channel by returning false,
- *                      then this handle is invalid after the callback returns
- *                      (the callback does not need to call meshlink_channel_close() itself in this case).
- *  @param port         The port number the peer wishes to connect to.
- *  @param data         A pointer to a buffer containing data already received, or NULL in case no data has been received yet. (Not yet used.)
- *                      The pointer is only valid during the lifetime of the callback.
- *                      The callback should mempcy() the data if it needs to be available outside the callback.
- *  @param len          The length of the data, or 0 in case no data has been received yet. (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 (*meshlink_channel_accept_cb_t)(struct meshlink_handle *mesh, struct meshlink_channel *channel, uint16_t port, const void *data, size_t len);
-
-/// A callback for receiving data from a channel.
-/** This function is called whenever data is received from a remote node on a channel.
- *
- *  This function is also called in case the channel has been closed by the remote node, or when the channel is terminated abnormally.
- *  In both cases, @a data will be NULL and @a len will be 0, and meshlink_errno will be set.
- *  In any case, the @a channel handle will still be valid until the application calls meshlink_close().
- *
- *  @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 in case of an error.
- *                      The pointer is only valid during the lifetime of the callback.
- *                      The callback should mempcy() the data if it needs to be available outside the callback.
- *  @param len          The length of the data, or 0 in case of an error.
- */
-typedef void (*meshlink_channel_receive_cb_t)(struct meshlink_handle *mesh, struct meshlink_channel *channel, const void *data, size_t len);
-
-/// A callback informing the application when data can be sent on a channel.
-/** This function is called whenever there is enough free buffer space so a call to meshlink_channel_send() will succeed.
- *
- *  @param mesh         A handle which represents an instance of MeshLink.
- *  @param channel      A handle for the channel.
- *  @param len          The maximum amount of data that is guaranteed to be accepted by meshlink_channel_send(),
- *                      or 0 in case of an error.
- */
-typedef void (*meshlink_channel_poll_cb_t)(struct meshlink_handle *mesh, struct meshlink_channel *channel, size_t len);
-
-/// Set the listen callback.
-/** This functions sets the callback that is called whenever another node wants to open a channel to the local node.
- *  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.
- *
- *  If no listen or accept callbacks are set, incoming channels are rejected.
- *
- *  \memberof meshlink_handle
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param cb        A pointer to the function which will be called when another node want to open a channel.
- *                   If a NULL pointer is given, the callback will be disabled.
- */
-void meshlink_set_channel_listen_cb(struct meshlink_handle *mesh, meshlink_channel_listen_cb_t cb);
-
-/// Set the accept callback.
-/** This functions sets the callback that is called whenever a remote node has opened a channel to the local node.
- *  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.
- *
- *  If no listen or accept callbacks are set, incoming channels are rejected.
- *
- *  \memberof meshlink_handle
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param cb        A pointer to the function which will be called when a new channel has been opened by a remote node.
- *                   If a NULL pointer is given, the callback will be disabled.
- */
-void meshlink_set_channel_accept_cb(struct meshlink_handle *mesh, meshlink_channel_accept_cb_t cb);
-
-/// Set the receive callback.
-/** This functions sets the callback that is called whenever another node sends data to the local node.
- *  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.
- *
- *  \memberof meshlink_channel
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param channel   A handle for the channel.
- *  @param cb        A pointer to the function which will be called when another node sends data to the local node.
- *                   If a NULL pointer is given, the callback will be disabled and incoming data is ignored.
- */
-void meshlink_set_channel_receive_cb(struct meshlink_handle *mesh, struct meshlink_channel *channel, meshlink_channel_receive_cb_t cb);
-
-/// Set the poll callback.
-/** This functions sets the callback that is called whenever data can be sent to another node.
- *  The callback is run in MeshLink's own thread.
- *  It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
- *  to pass data to or from the application's thread.
- *  The callback should also not block itself and return as quickly as possible.
- *
- *  \memberof meshlink_channel
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param channel   A handle for the channel.
- *  @param cb        A pointer to the function which will be called when data can be sent to another node.
- *                   If a NULL pointer is given, the callback will be disabled.
- */
-void meshlink_set_channel_poll_cb(struct meshlink_handle *mesh, struct meshlink_channel *channel, meshlink_channel_poll_cb_t cb);
-
-/// Set the send buffer size of a channel.
-/** This function sets the desired size of the send 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.
- */
-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.
- */
-void meshlink_set_channel_rcvbuf(struct meshlink_handle *mesh, struct meshlink_channel *channel, size_t size);
-
-/// Set the send buffer storage of a channel.
-/** This function provides MeshLink with a send buffer allocated by the application.
- *  The buffer must be valid until the channel is closed or until this function is called again with a NULL pointer for @a buf.
- *
- *  \memberof meshlink_channel
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param channel   A handle for the channel.
- *  @param buf       A pointer to the start of the buffer.
- *                   If a NULL pointer is given, MeshLink will use its own internal buffer again.
- *  @param size      The size of the buffer.
- */
-void meshlink_set_channel_sndbuf_storage(struct meshlink_handle *mesh, struct meshlink_channel *channel, void *buf, size_t size);
-
-/// Set the receive buffer storage of a channel.
-/** This function provides MeshLink with a receive buffer allocated by the application.
- *  The buffer must be valid until the channel is closed or until this function is called again with a NULL pointer for @a buf.
- *
- *  \memberof meshlink_channel
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param channel   A handle for the channel.
- *  @param buf       A pointer to the start of the buffer.
- *                   If a NULL pointer is given, MeshLink will use its own internal buffer again.
- *  @param size      The size of the buffer.
- */
-void meshlink_set_channel_rcvbuf_storage(struct meshlink_handle *mesh, struct meshlink_channel *channel, void *buf, size_t size);
-
-/// Set the flags of a channel.
-/** This function allows changing some of the channel flags.
- *  Currently only MESHLINK_CHANNEL_NO_PARTIAL and MESHLINK_CHANNEL_DROP_LATE are supported, other flags are ignored.
- *  These flags only affect the local side of the channel with the peer.
- *  The changes take effect immediately.
- *
- *  \memberof meshlink_channel
- *  @param mesh      A handle which represents an instance of MeshLink.
- *  @param channel   A handle for the channel.
- *  @param flags     A bitwise-or'd combination of flags that set the semantics for this channel.
- */
-void meshlink_set_channel_flags(struct meshlink_handle *mesh, struct meshlink_channel *channel, uint32_t flags);
-
-/// 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.
- */
-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.
- */
-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.
- */
-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.
- *  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.
- */
-void meshlink_channel_close(struct meshlink_handle *mesh, struct meshlink_channel *channel);
-
-/// Abort a reliable stream channel.
-/** This aborts a channel.
- *  Data that was in the send and receive buffers is dropped, so potentially there is some data that
- *  was sent on this channel that will not be received by the peer.
- *  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.
- */
-void meshlink_channel_abort(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.
- */
-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.
- */
-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.
- */
-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.
- */
-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.
- */
-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.
- */
-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.
- */
-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.
- */
-size_t meshlink_channel_get_recvq(struct meshlink_handle *mesh, struct meshlink_channel *channel) __attribute__((__warn_unused_result__));
-
-/// Get the maximum segment size of a channel.
-/** This returns the amount of bytes that can be sent at once for channels with UDP semantics.
- *
- *  \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.
- */
-size_t meshlink_channel_get_mss(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 node         A pointer to a struct meshlink_node describing the node to set the channel connection timeout for.
- *  @param timeout      The timeout in seconds after which unresponsive channels will be reported as closed.
- *                      The default is 60 seconds.
- */
-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.