]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Trivial test for meshlink_blacklist
[meshlink] / src / meshlink.c
index c88059b1e02fe0be95777a15d10a1848d9d16ec8..0efdb39780c372d3182d7eab89a0c1f1d2128e93 100644 (file)
@@ -426,6 +426,7 @@ static bool finalize_join(meshlink_handle_t *mesh) {
        FILE *fh = fopen(filename, "w");
        if(!fh) {
                fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno));
+               fclose(f);
                return false;
        }
 
@@ -548,7 +549,7 @@ static bool finalize_join(meshlink_handle_t *mesh) {
        return true;
 }
 
-static bool invitation_send(void *handle, uint8_t type, const char *data, size_t len) {
+static bool invitation_send(void *handle, uint8_t type, const void *data, size_t len) {
        meshlink_handle_t* mesh = handle;
        while(len) {
                int result = send(mesh->sock, data, len, 0);
@@ -562,7 +563,7 @@ static bool invitation_send(void *handle, uint8_t type, const char *data, size_t
        return true;
 }
 
-static bool invitation_receive(void *handle, uint8_t type, const char *msg, uint16_t len) {
+static bool invitation_receive(void *handle, uint8_t type, const void *msg, uint16_t len) {
        meshlink_handle_t* mesh = handle;
        switch(type) {
                case SPTPS_HANDSHAKE:
@@ -827,7 +828,12 @@ bool meshlink_start(meshlink_handle_t *mesh) {
 }
 
 void meshlink_stop(meshlink_handle_t *mesh) {
-       // TODO: close the listening sockets to signal the main thread to shut down
+       // Shut down the listening sockets to signal the main thread to shut down
+
+       for(int i = 0; i < mesh->listen_sockets; i++) {
+               shutdown(mesh->listen_socket[i].tcp.fd, SHUT_RDWR);
+               shutdown(mesh->listen_socket[i].udp.fd, SHUT_RDWR);
+       }
 
        // Wait for the main thread to finish
 
@@ -1242,6 +1248,11 @@ bool meshlink_import(meshlink_handle_t *mesh, const char *data) {
 }
 
 void meshlink_blacklist(meshlink_handle_t *mesh, meshlink_node_t *node) {
+    node_t *n;
+    n = (node_t*)node;
+    n->status.blacklisted=true;
+    return;
+
 }
 
 static void __attribute__((constructor)) meshlink_init(void) {