]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.h
Fix compiler warnings
[meshlink] / src / meshlink.h
index ffd05af2275d81f62f75ffb78f4199fabd29a0e4..f7b3f94836734dd8a17b1f9dbc7025fb4d3dc62f 100644 (file)
 
 #include <stdbool.h>
 #include <stddef.h>
+#include "event.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /// A handle for an instance of MeshLink.
 typedef struct meshlink_handle meshlink_handle_t;
@@ -35,11 +40,16 @@ typedef enum {
        MESHLINK_ENOMEM, // Out of memory
        MESHLINK_ENOENT, // Node is not known
 } meshlink_errno_t;
+typedef struct outpacketqueue {
+       meshlink_node_t *destination;
+       const void *data;
+       unsigned int len;
+} outpacketqueue_t;
 
 #ifndef MESHLINK_INTERNAL_H
 
 struct meshlink_handle {
-       meshlink_errno_t errno; /// Code of the last encountered error.
+       meshlink_errno_t meshlink_errno; /// Code of the last encountered error.
        const char *errstr;     /// Textual representation of most recent error encountered.
 };
 
@@ -66,6 +76,9 @@ extern const char *meshlink_strerror(meshlink_errno_t errno);
  *  but it is not a problem if it is run more than once, as long as
  *  the arguments given are the same.
  *
+ *  This function does not start any network I/O yet. The application should
+ *  first set callbacks, and then call meshlink_start().
+ *
  *  @param confbase The directory in which MeshLink will store its configuration files.
  *  @param name     The name which this instance of the application will use in the mesh.
  *
@@ -74,8 +87,8 @@ extern const char *meshlink_strerror(meshlink_errno_t errno);
 extern meshlink_handle_t *meshlink_open(const char *confbase, const char *name);
 
 /// Start MeshLink.
-/** This function causes MeshLink to create a new thread, which will
- *  handle all network I/O.
+/** This function causes MeshLink to open network sockets, make outgoing connections, and
+ *  create a new thread, which will handle all network I/O.
  *
  *  @param confbase The directory in which MeshLink will store its configuration files.
  *
@@ -85,7 +98,7 @@ extern bool meshlink_start(meshlink_handle_t *mesh);
 
 /// Stop MeshLink.
 /** This function causes MeshLink to disconnect from all other nodes,
- *  and shuts down its own thread.
+ *  close all sockets, and shut down its own thread.
  *
  * @param handle    A handle which represents an instance of MeshLink.
  */
@@ -184,6 +197,8 @@ extern void meshlink_set_log_cb(meshlink_handle_t *mesh, meshlink_log_level_t le
  */
 extern bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const void *data, unsigned int len);
 
+extern void meshlink_send_from_queue(event_loop_t* el,meshlink_handle_t *mesh);
+
 /// Get a handle for a specific node.
 /** This function returns a handle for the node with the given name.
  *
@@ -232,6 +247,16 @@ extern char *meshlink_sign(meshlink_handle_t *mesh, const char *data, size_t len
  */
 extern bool meshlink_verify(meshlink_handle_t *mesh, meshlink_node_t *source, const char *data, size_t len, const char *signature);
 
+/// Add an Address for the local node.
+/** This function adds an Address for the local node, which will be used for invitation URLs.
+ *
+ *  @param mesh         A handle which represents an instance of MeshLink.
+ *  @param address      A string containing the address, which can be either in numeric format or a hostname.
+ *
+ *  @return             This function returns true if the address was added, false otherwise.
+ */
+extern bool meshlink_add_address(meshlink_handle_t *mesh, const char *address);
+
 /// Invite another node into the mesh.
 /** This function generates an invitation that can be used by another node to join the same mesh as the local node.
  *  The generated invitation is a string containing a URL.
@@ -291,4 +316,8 @@ extern bool meshlink_import(meshlink_handle_t *mesh, const char *data);
  */
 extern void meshlink_blacklist(meshlink_handle_t *mesh, meshlink_node_t *node);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif // MESHLINK_H