mesh->threadstarted = false;
+ // Close all metaconnections
+ if(mesh->connections) {
+ for(list_node_t *node = mesh->connections->head, *next; node; node = next) {
+ next = node->next;
+ connection_t *c = node->data;
+ c->outgoing = NULL;
+ terminate_connection(mesh, c, false);
+ }
+ }
+
+ if(mesh->outgoings)
+ list_delete_list(mesh->outgoings);
+ mesh->outgoings = NULL;
+
pthread_mutex_unlock(&(mesh->mesh_mutex));
}
memset(hdr, 0, sizeof(*hdr));
// leave the last byte as 0 to make sure strings are always
// null-terminated if they are longer than the buffer
- strncpy(hdr->destination, destination->name, (sizeof(hdr)->destination) - 1);
- strncpy(hdr->source, mesh->self->name, (sizeof(hdr)->source) - 1);
+ strncpy((char *)hdr->destination, destination->name, (sizeof(hdr)->destination) - 1);
+ strncpy((char *)hdr->source, mesh->self->name, (sizeof(hdr)->source) - 1);
memcpy(packet->data + sizeof(*hdr), data, len);
if(fread(buf + len - fsize - 1, fsize, 1, f) != 1) {
logger(mesh, MESHLINK_DEBUG, "Error reading from %s: %s\n", filename, strerror(errno));
fclose(f);
+ free(buf);
meshlink_errno = MESHLINK_ESTORAGE;
pthread_mutex_unlock(&(mesh->mesh_mutex));
return NULL;
if(host && port) {
xasprintf(&str, "%s %s", host, port);
if((strncmp("fe80", host, 4) != 0) && (strncmp("127.", host, 4) != 0) && (strcmp("localhost", host) != 0))
- append_config_file(mesh, node->name, "Address", str);
+ modify_config_file(mesh, node->name, "Address", str, 5);
else
logger(mesh, MESHLINK_DEBUG, "Not adding Link Local IPv6 Address to config\n");
}
}
static bool channel_pre_accept(struct utcp *utcp, uint16_t port) {
- //TODO: implement
- return true;
+ node_t *n = utcp->priv;
+ meshlink_handle_t *mesh = n->mesh;
+ return mesh->channel_accept_cb;
}
static ssize_t channel_recv(struct utcp_connection *connection, const void *data, size_t len) {