]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.h
New API function for address hinting.
[meshlink] / src / meshlink.h
index ebd330368dda43727b645c535b3e345cc0394e11..b3059c39a73c50bab102f92b57647bd37847d92b 100644 (file)
@@ -238,7 +238,22 @@ extern void meshlink_set_log_cb(meshlink_handle_t *mesh, meshlink_log_level_t le
  *  @return             This function will return true if MeshLink has queued the message for transmission, and false otherwise.
  *                      A return value of true does not guarantee that the message will actually arrive at the destination.
  */
-extern bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const void *data, unsigned int len);
+extern bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const void *data, size_t len);
+
+/// 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.
+ *
+ *  @param mesh         A handle which represents an instance of MeshLink.
+ *  @param destination  A pointer to a meshlink_node_t 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.
+ */
+extern ssize_t meshlink_get_pmtu(meshlink_handle_t *mesh, meshlink_node_t *destination);
 
 /// Get a handle for a specific node.
 /** This function returns a handle for the node with the given name.
@@ -526,6 +541,20 @@ extern void meshlink_channel_close(meshlink_handle_t *mesh, meshlink_channel_t *
  */
 extern ssize_t meshlink_channel_send(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len);
 
+/// 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.
+ *
+ *  @param mesh                A handle which represents an instance of MeshLink.
+ *  @param hostname    The hostname which can be found at the given address.
+ *                     The caller is free to overwrite or free this string
+ *                     once meshlink returns.
+ *  @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(meshlink_handle_t *mesh, char *hostname, struct sockaddr *addr);
+
 #ifdef __cplusplus
 }
 #endif