return (node *)meshlink_get_node(handle, name);
}
+ /// Get a handle for a specific submesh.
+ /** This function returns a handle for the submesh with the given name.
+ *
+ * @param name The name of the submesh for which a handle is requested.
+ *
+ * @return A pointer to a meshlink::submesh which represents the requested submesh,
+ * or NULL if the requested submesh does not exist.
+ */
+ submesh *get_submesh(const char *name) {
+ return (submesh *)meshlink_get_submesh(handle, name);
+ }
+
/// Get a handle for our own node.
/** This function returns a handle for the local node.
*
return node;
}
+meshlink_submesh_t *meshlink_get_submesh(meshlink_handle_t *mesh, const char *name) {
+ if(!mesh || !name) {
+ meshlink_errno = MESHLINK_EINVAL;
+ return NULL;
+ }
+
+ meshlink_submesh_t *submesh = NULL;
+
+ pthread_mutex_lock(&(mesh->mesh_mutex));
+ submesh = (meshlink_submesh_t *)lookup_submesh(mesh, name);
+ pthread_mutex_unlock(&(mesh->mesh_mutex));
+ return submesh;
+}
+
meshlink_node_t **meshlink_get_all_nodes(meshlink_handle_t *mesh, meshlink_node_t **nodes, size_t *nmemb) {
if(!mesh || !nmemb || (*nmemb && !nodes)) {
meshlink_errno = MESHLINK_EINVAL;
*/
extern meshlink_node_t *meshlink_get_node(meshlink_handle_t *mesh, const char *name);
+/// Get a handle for a specific submesh.
+/** This function returns a handle for the submesh with the given name.
+ *
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param name The name of the submesh for which a handle is requested.
+ * After this function returns, the application is free to overwrite or free @a name @a.
+ *
+ * @return A pointer to a meshlink_submesh_t which represents the requested submesh,
+ * or NULL if the requested submesh does not exist.
+ * The pointer is guaranteed to be valid until meshlink_close() is called.
+ */
+extern meshlink_submesh_t *meshlink_get_submesh(meshlink_handle_t *mesh, const char *name);
+
/// Get the fingerprint of a node's public key.
/** This function returns a fingerprint of the node's public key.
* It should be treated as an opaque blob.
extern void destroy_containers(void);
extern void restart_all_containers(void);
extern char *invite_in_container(const char *inviter, const char *invitee);
+extern char *submesh_invite_in_container(const char *inviter, const char *invitee, const char *submesh);
extern void node_sim_in_container(const char *node, const char *device_class, const char *invite_url);
extern void node_sim_in_container_event(const char *node, const char *device_class,
const char *invite_url, const char *clientId, const char *import);
failed_tests += test_meshlink_channel_close();
failed_tests += test_meshlink_channel_conn();
+ */
failed_tests += test_optimal_pmtu();
failed_tests += test_cases_submesh01();
failed_tests += test_cases_submesh02();
failed_tests += test_cases_submesh03();
failed_tests += test_cases_submesh04();
- */
+
failed_tests += test_meshlink_autoconnect();
failed_tests += test_optimal_pmtu();
assert(change_state(&node_status[payload.client_id], payload.mesh_event));
if(payload.mesh_event == NODE_JOINED) {
- signal_node_start(node_status, 1, 5, node_ids);
+ signal_node_start(node_status, 1, 5, (char **)node_ids);
}
if(check_nodes_finished(node_status, 6)) {
total_tests += sizeof(blackbox_group0_tests) / sizeof(blackbox_group0_tests[0]);
return cmocka_run_group_tests(blackbox_group0_tests, black_box_group0_setup, black_box_group0_teardown);
-}
\ No newline at end of file
+}
assert(change_state(&node_status[payload.client_id], payload.mesh_event));
if(payload.mesh_event == NODE_JOINED) {
- signal_node_start(node_status, 1, 5, node_ids);
+ signal_node_start(node_status, 1, 5, (char **)node_ids);
}
if(check_nodes_finished(node_status, 6)) {
total_tests += sizeof(blackbox_group0_tests) / sizeof(blackbox_group0_tests[0]);
return cmocka_run_group_tests(blackbox_group0_tests, black_box_group0_setup, black_box_group0_teardown);
-}
\ No newline at end of file
+}
assert(change_state(&node_status[payload.client_id], payload.mesh_event));
if(payload.mesh_event == NODE_JOINED) {
- signal_node_start(node_status, 1, 2, node_ids);
+ signal_node_start(node_status, 1, 2, (char **)node_ids);
}
if(check_nodes_finished(node_status, 3)) {
total_tests += sizeof(blackbox_group0_tests) / sizeof(blackbox_group0_tests[0]);
return cmocka_run_group_tests(blackbox_group0_tests, black_box_group0_setup, black_box_group0_teardown);
-}
\ No newline at end of file
+}
assert(change_state(&node_status[payload.client_id], payload.mesh_event));
if(payload.mesh_event == NODE_JOINED) {
- signal_node_start(node_status, 1, 2, node_ids);
+ signal_node_start(node_status, 1, 2, (char **)node_ids);
}
if(check_nodes_finished(node_status, 3)) {
total_tests += sizeof(blackbox_group0_tests) / sizeof(blackbox_group0_tests[0]);
return cmocka_run_group_tests(blackbox_group0_tests, black_box_group0_setup, black_box_group0_teardown);
-}
\ No newline at end of file
+}
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_node_t **node_handles = NULL;
+ meshlink_submesh_t *submesh = NULL;
fprintf(stderr, "\tMesh node 'app1node2' starting up........\n");
meshlink_node_t *node = meshlink_get_self(mesh);
assert(node);
- meshlink_submesh_t *submesh = meshlink_get_node_submesh(mesh, node);
+ submesh = meshlink_get_node_submesh(mesh, node);
assert(submesh);
node_handles = meshlink_get_all_nodes_by_submesh(mesh, submesh, node_handles, &num_nodes);
}
}
+ submesh = meshlink_get_submesh(mesh, "app1");
+
+ if(submesh == NULL) {
+ fprintf(stderr, "\tapp1node2 Got invalid submesh handle\n");
+ send_event(ERR_NETWORK);
+ }
+
+ submesh = meshlink_get_submesh(mesh, "app2");
+
+ if(submesh != NULL) {
+ fprintf(stderr, "\tapp1node2 Submesh handle should be NULL\n");
+ send_event(ERR_NETWORK);
+ }
+
send_event(MESH_EVENT_COMPLETED);
// All test steps executed - wait for signals to stop/start or close the mesh
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_node_t **node_handles = NULL;
+ meshlink_submesh_t *submesh = NULL;
fprintf(stderr, "\tMesh node 'app2node2' starting up........\n");
meshlink_node_t *node = meshlink_get_self(mesh);
assert(node);
- meshlink_submesh_t *submesh = meshlink_get_node_submesh(mesh, node);
+ submesh = meshlink_get_node_submesh(mesh, node);
assert(submesh);
node_handles = meshlink_get_all_nodes_by_submesh(mesh, submesh, node_handles, &num_nodes);
}
}
+ submesh = meshlink_get_submesh(mesh, "app2");
+
+ if(submesh == NULL) {
+ fprintf(stderr, "\tapp2node2 Got invalid submesh handle\n");
+ send_event(ERR_NETWORK);
+ }
+
+ submesh = meshlink_get_submesh(mesh, "app1");
+
+ if(submesh != NULL) {
+ fprintf(stderr, "\tapp2node2 Submesh handle should be NULL\n");
+ send_event(ERR_NETWORK);
+ }
+
send_event(MESH_EVENT_COMPLETED);
// All test steps executed - wait for signals to stop/start or close the mesh
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}