X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Fblackbox%2Fcommon%2Fmesh_event_handler.c;h=84ae63dd83436ec0cb42c780ef411ec1b36aa66a;hb=f9235480fa69f92b50156ac8b6a70f3558bb0bbf;hp=1b7ebe92aec61dd15eee952320313591d7b9f33c;hpb=1c04402a6d2f3a85d0cb4a5b4a6db5b1f3a79511;p=meshlink diff --git a/test/blackbox/common/mesh_event_handler.c b/test/blackbox/common/mesh_event_handler.c index 1b7ebe92..84ae63dd 100644 --- a/test/blackbox/common/mesh_event_handler.c +++ b/test/blackbox/common/mesh_event_handler.c @@ -38,6 +38,16 @@ #define SERVER_LISTEN_PORT "9000" /* Port number that is binded with mesh event server socket */ #define UDP_BUFF_MAX 2000 +const char *event_status[] = { + [NODE_STARTED] = "Node Started", + [NODE_JOINED] = "Node Joined", + [ERR_NETWORK] = "Network Error", + [CHANNEL_OPENED] = "Channel Opened", + [CHANNEL_DATA_RECIEVED] = "Channel Data Received", + [SIG_ABORT] = "SIG_ABORT Received", + [MESH_EVENT_COMPLETED] = "MESH_EVENT_COMPLETED Received" +}; + // TODO: Implement mesh event handling with reentrancy . static struct sockaddr_in server_addr; static int client_fd = -1; @@ -73,6 +83,7 @@ static bool wait_cond_flag(struct cond_flag *s, int seconds) { // event_receive_handler running in a separate thread queues all the events received from the UDP port static void *event_receive_handler(void *arg) { + (void)arg; size_t recv_ret; char udp_buff[UDP_BUFF_MAX]; struct sockaddr client; @@ -110,7 +121,7 @@ static void *event_handler(void *argv) { bool callback_return = false; void *data; mesh_event_payload_t mesh_event_rec_packet; - mesh_event_callback_t callback = (mesh_event_callback_t)argv; + mesh_event_callback_t callback = *(mesh_event_callback_t *)argv; while(event_handle_thread_running) { @@ -163,7 +174,7 @@ char *mesh_event_sock_create(const char *if_name) { server.sin_port = htons(atoi(SERVER_LISTEN_PORT)); assert(bind(server_fd, (struct sockaddr *) &server, sizeof(struct sockaddr)) != -1); - assert(ip = malloc(30)); + assert((ip = malloc(30))); strncpy(ip, inet_ntoa(resp_if_addr->sin_addr), 20); strcat(ip, ":"); strcat(ip, SERVER_LISTEN_PORT); @@ -245,7 +256,7 @@ bool wait_for_event(mesh_event_callback_t callback, int seconds) { } set_cond_flag(&sync_event, false); - assert(!pthread_create(&event_handle_thread, NULL, event_handler, (void *)callback)); + assert(!pthread_create(&event_handle_thread, NULL, event_handler, (void *)&callback)); bool wait_ret = wait_cond_flag(&sync_event, seconds); event_handle_thread_running = false; pthread_cancel(event_handle_thread); @@ -270,4 +281,3 @@ void mesh_event_destroy(void) { event_receive_thread_running = false; pthread_cancel(event_receive_thread); } -