return (node *)meshlink_get_node(handle, name);
}
+ /// Get a handle for our own node.
+ /** This function returns a handle for the local node.
+ *
+ * @return A pointer to a meshlink::node which represents the local node.
+ */
+ node *get_self() {
+ return (node *)meshlink_get_self(handle);
+ }
+
/// Get a list of all nodes.
/** This function returns a list with handles for all known nodes.
*
return fingerprint;
}
+meshlink_node_t *meshlink_get_self(meshlink_handle_t *mesh) {
+ if(!mesh) {
+ meshlink_errno = MESHLINK_EINVAL;
+ return NULL;
+ }
+
+ return (meshlink_node_t *)mesh->self;
+}
+
meshlink_node_t *meshlink_get_node(meshlink_handle_t *mesh, const char *name) {
if(!mesh || !name) {
meshlink_errno = MESHLINK_EINVAL;
*/
extern ssize_t meshlink_get_pmtu(meshlink_handle_t *mesh, meshlink_node_t *destination);
+/// Get a handle for our own node.
+/** This function returns a handle for the local node.
+ *
+ * @param mesh A handle which represents an instance of MeshLink.
+ *
+ * @return A pointer to a meshlink_node_t which represents the local node.
+ * The pointer is guaranteed to be valid until meshlink_close() is called.
+ */
+extern meshlink_node_t *meshlink_get_self(meshlink_handle_t *mesh);
+
/// Get a handle for a specific node.
/** This function returns a handle for the node with the given name.
*
// Check that our own node exists.
- meshlink_node_t *self = meshlink_get_node(mesh, "foo");
+ meshlink_node_t *self = meshlink_get_self(mesh);
if(!self) {
fprintf(stderr, "Foo does not know about itself\n");
return 1;
return 1;
}
- self = meshlink_get_node(mesh, "foo");
+ self = meshlink_get_self(mesh);
if(!self) {
fprintf(stderr, "Foo doesn't know about itself the second time\n");
return 1;
// Check that our own node exists.
- meshlink::node *self = mesh.get_node("foo");
+ meshlink::node *self = mesh.get_self();
if(!self) {
cerr << "Foo does not know about itself\n";
return 1;
return 1;
}
- self = mesh.get_node("foo");
+ self = mesh.get_self();
if(!self) {
cerr << "Foo doesn't know about itself the second time\n";
return 1;