X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink.c;h=c720c766e48deda084ad42a03b22eddff4f410f8;hb=f13d66f20a227a87075f6456f41b83ce269b67f4;hp=9a0e914ac9be34a863103df10965889a29026705;hpb=4a839c62c32ae4933b24215e3fb25cdb159fcd4e;p=meshlink diff --git a/src/meshlink.c b/src/meshlink.c index 9a0e914a..c720c766 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1,6 +1,6 @@ /* meshlink.c -- Implementation of the MeshLink API. - Copyright (C) 2014, 2017 Guus Sliepen + Copyright (C) 2014-2018 Guus Sliepen 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 @@ -1048,6 +1048,12 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name, const c return NULL; } + if(strchr(appname, ' ')) { + logger(NULL, MESHLINK_ERROR, "Invalid appname given!\n"); + meshlink_errno = MESHLINK_EINVAL; + return NULL; + } + if(!name || !*name) { logger(NULL, MESHLINK_ERROR, "No name given!\n"); //return NULL; @@ -1209,9 +1215,11 @@ bool meshlink_start(meshlink_handle_t *mesh) { mesh->threadstarted = true; +#if HAVE_CATTA if(mesh->discovery) { discovery_start(mesh); } +#endif pthread_mutex_unlock(&(mesh->mesh_mutex)); return true; @@ -1226,10 +1234,12 @@ void meshlink_stop(meshlink_handle_t *mesh) { pthread_mutex_lock(&(mesh->mesh_mutex)); logger(mesh, MESHLINK_DEBUG, "meshlink_stop called\n"); +#if HAVE_CATTA // Stop discovery if(mesh->discovery) { discovery_stop(mesh); } +#endif // Shut down the main thread event_loop_stop(&mesh->loop); @@ -2120,7 +2130,7 @@ bool meshlink_join(meshlink_handle_t *mesh, const char *invitation) { mesh->blen = 0; - if(!sendline(mesh->sock, "0 ?%s %d.%d", b64key, PROT_MAJOR, 1)) { + if(!sendline(mesh->sock, "0 ?%s %d.%d %s", b64key, PROT_MAJOR, 1, mesh->appname)) { logger(mesh, MESHLINK_DEBUG, "Error sending request to %s port %s: %s\n", address, port, strerror(errno)); closesocket(mesh->sock); meshlink_errno = MESHLINK_ENETWORK; @@ -2647,6 +2657,7 @@ void update_node_status(meshlink_handle_t *mesh, node_t *n) { } void meshlink_enable_discovery(meshlink_handle_t *mesh, bool enable) { +#if HAVE_CATTA if(!mesh) { meshlink_errno = MESHLINK_EINVAL; return; @@ -2670,6 +2681,11 @@ void meshlink_enable_discovery(meshlink_handle_t *mesh, bool enable) { end: pthread_mutex_unlock(&mesh->mesh_mutex); +#else + (void)mesh; + (void)enable; + meshlink_errno = MESHLINK_ENOTSUP; +#endif } static void __attribute__((constructor)) meshlink_init(void) {