]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.h
Remove make check warnings
[meshlink] / src / meshlink.h
index 6e03343bfc6997558f1b91ec4a2808b1bf8145fa..6f645373a4faa7e552864b32b93c31875ced053b 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
     meshlink.h -- MeshLink API
-    Copyright (C) 2014-2018 Guus Sliepen <guus@meshlink.io>
+    Copyright (C) 2014-2019 Guus Sliepen <guus@meshlink.io>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -127,10 +127,6 @@ struct meshlink_channel {
        void *priv;                       ///< Private pointer which may be set freely by the application, and is never used or modified by MeshLink.
 };
 
-struct meshlink_open_params {
-       /* This is an opaque struct, all parameters must be set using the corresponding meshlink_open_params_*() functions. */
-};
-
 #endif // MESHLINK_INTERNAL_H
 
 /// Get the text for the given MeshLink error code.
@@ -219,7 +215,7 @@ extern meshlink_handle_t *meshlink_open_ex(const meshlink_open_params_t *params)
 extern meshlink_handle_t *meshlink_open(const char *confbase, const char *name, const char *appname, dev_class_t devclass);
 
 /// Create Sub-Mesh.
-/** This function causes MeshLink to open a new Sub-Mesh network 
+/** This function causes MeshLink to open a new Sub-Mesh network
  *  create a new thread, which will handle all network I/O.
  *
  *  It is allowed to call this function even if MeshLink is already started, in which case it will return true.
@@ -512,6 +508,26 @@ extern bool meshlink_sign(meshlink_handle_t *mesh, const void *data, size_t len,
  */
 extern meshlink_node_t **meshlink_get_all_nodes_by_dev_class(meshlink_handle_t *mesh, dev_class_t devclass, meshlink_node_t **nodes, size_t *nmemb);
 
+/// Get the list of all nodes by Submesh.
+/** This function returns a list with handles for all the nodes that matches with the given @a Submesh @a .
+ *
+ *  @param mesh         A handle which represents an instance of MeshLink.
+ *  @param submesh      Submesh handle of the nodes for which the list has to be obtained.
+ *  @param nodes        A pointer to a previously allocated array of pointers to meshlink_node_t, or NULL in which case MeshLink will allocate a new array.
+ *                      The application can supply an array it allocated itself with malloc, or the return value from the previous call to this function (which is the preferred way).
+ *                      The application is allowed to call free() on the array whenever it wishes.
+ *                      The pointers in the array are valid until meshlink_close() is called.
+ *  @param nmemb        A pointer to a variable holding the number of nodes with the same @a device class @a that are stored in the array.
+ *                      In case the @a nodes @a argument is not NULL, MeshLink might call realloc() on the array to change its size.
+ *                      The contents of this variable will be changed to reflect the new size of the array.
+ *
+ *  @return             A pointer to an array containing pointers to all known nodes of the given Submesh, or NULL in case of an error.
+ *                      If the @a nodes @a argument was not NULL, then the return value can either be the same value or a different value.
+ *                      If it is a new value, the old value of @a nodes @a should not be used anymore.
+ *                      If the new value is NULL, then the old array will have been freed by MeshLink.
+ */
+extern meshlink_node_t **meshlink_get_all_nodes_by_submesh(meshlink_handle_t *mesh, meshlink_submesh_t *submesh, meshlink_node_t **nodes, size_t *nmemb);
+
 /// Get the node's device class.
 /** This function returns the device class of the given node.
  *
@@ -522,6 +538,16 @@ extern meshlink_node_t **meshlink_get_all_nodes_by_dev_class(meshlink_handle_t *
  */
 extern dev_class_t meshlink_get_node_dev_class(meshlink_handle_t *mesh, meshlink_node_t *node);
 
+/// Get the node's submesh handle.
+/** This function returns the submesh handle of the given node.
+ *
+ *  @param mesh          A handle which represents an instance of MeshLink.
+ *  @param node          A pointer to a meshlink_node_t describing the node.
+ *
+ *  @return              This function returns the submesh handle of the @a node @a , or NULL in case of an error.
+ */
+extern meshlink_submesh_t *meshlink_get_node_submesh(meshlink_handle_t *mesh, meshlink_node_t *node);
+
 /// 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.
  *
@@ -693,6 +719,7 @@ extern void meshlink_set_invitation_timeout(meshlink_handle_t *mesh, int timeout
  *  The URL can only be used once, after the user has joined the mesh the URL is no longer valid.
  *
  *  @param mesh         A handle which represents an instance of MeshLink.
+ *  @param submesh      A handle which represents an instance of SubMesh.
  *  @param name         A nul-terminated C string containing the name that the invitee will be allowed to use in the mesh.
  *                      After this function returns, the application is free to overwrite or free @a name @a.
  *  @param flags        A bitwise-or'd combination of flags that controls how the URL is generated.
@@ -700,7 +727,7 @@ extern void meshlink_set_invitation_timeout(meshlink_handle_t *mesh, int timeout
  *  @return             This function returns a nul-terminated C string that contains the invitation URL, or NULL in case of an error.
  *                      The application should call free() after it has finished using the URL.
  */
-extern char *meshlink_invite_ex(meshlink_handle_t *mesh, const char *name, uint32_t flags);
+extern char *meshlink_invite_ex(meshlink_handle_t *mesh, meshlink_submesh_t *submesh, const char *name, uint32_t flags);
 
 /// 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.
@@ -711,13 +738,14 @@ extern char *meshlink_invite_ex(meshlink_handle_t *mesh, const char *name, uint3
  *  Calling this function is equal to callen meshlink_invite_ex() with flags set to 0.
  *
  *  @param mesh         A handle which represents an instance of MeshLink.
+ *  @param submesh      A handle which represents an instance of SubMesh.
  *  @param name         A nul-terminated C string containing the name that the invitee will be allowed to use in the mesh.
  *                      After this function returns, the application is free to overwrite or free @a name @a.
  *
  *  @return             This function returns a nul-terminated C string that contains the invitation URL, or NULL in case of an error.
  *                      The application should call free() after it has finished using the URL.
  */
-extern char *meshlink_invite(meshlink_handle_t *mesh, const char *name);
+extern char *meshlink_invite(meshlink_handle_t *mesh, meshlink_submesh_t *submesh, const char *name);
 
 /// Use an invitation to join a mesh.
 /** This function allows the local node to join an existing mesh using an invitation URL generated by another node.