14 meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
16 // Open two ephemeral meshlink instance.
18 meshlink_handle_t *mesh1 = meshlink_open_ephemeral("foo", "ephemeral", DEV_CLASS_BACKBONE);
19 meshlink_handle_t *mesh2 = meshlink_open_ephemeral("bar", "ephemeral", DEV_CLASS_BACKBONE);
24 meshlink_set_log_cb(mesh1, MESHLINK_DEBUG, log_cb);
25 meshlink_set_log_cb(mesh2, MESHLINK_DEBUG, log_cb);
29 char *export1 = meshlink_export(mesh1);
30 char *export2 = meshlink_export(mesh2);
35 assert(meshlink_import(mesh1, export2));
36 assert(meshlink_import(mesh2, export1));
41 // Check that they know each other
43 assert(meshlink_get_node(mesh1, "bar"));
44 assert(meshlink_get_node(mesh2, "foo"));
46 // Close the ephemeral instances and reopen them.
48 meshlink_close(mesh1);
49 meshlink_close(mesh2);
51 mesh1 = meshlink_open_ephemeral("foo", "ephemeral", DEV_CLASS_BACKBONE);
52 mesh2 = meshlink_open_ephemeral("bar", "ephemeral", DEV_CLASS_BACKBONE);
57 meshlink_set_log_cb(mesh1, MESHLINK_DEBUG, log_cb);
58 meshlink_set_log_cb(mesh2, MESHLINK_DEBUG, log_cb);
60 // Check that the nodes no longer know each other
62 assert(!meshlink_get_node(mesh1, "bar"));
63 assert(!meshlink_get_node(mesh2, "foo"));
67 meshlink_close(mesh1);
68 meshlink_close(mesh2);