]> git.meshlink.io Git - meshlink/blob - test/blackbox/test_case_optimal_pmtu_01/node_sim_relay.c
822f1d2b418afc5e3e046095b4da46eaf0d3935a
[meshlink] / test / blackbox / test_case_optimal_pmtu_01 / node_sim_relay.c
1 /*
2     node_sim_relay.c -- Implementation of Node Simulation for Meshlink Testing
3     Copyright (C) 2019  Guus Sliepen <guus@meshlink.io>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <pthread.h>
23 #include <assert.h>
24 #include <signal.h>
25 #include <time.h>
26 #include "../common/common_handlers.h"
27 #include "../common/test_step.h"
28 #include "../common/network_namespace_framework.h"
29 #include "../../utils.h"
30 #include "../run_blackbox_tests/test_optimal_pmtu.h"
31
32 extern bool test_pmtu_relay_running;
33
34 void *node_sim_pmtu_relay_01(void *arg) {
35         mesh_arg_t *mesh_arg = (mesh_arg_t *)arg;
36         struct timeval main_loop_wait = { 5, 0 };
37
38         // Run relay node instance
39
40
41         meshlink_handle_t *mesh;
42         mesh = meshlink_open(mesh_arg->node_name , mesh_arg->confbase, mesh_arg->app_name, mesh_arg->dev_class);
43         assert(mesh);
44
45         //meshlink_set_log_cb(mesh, MESHLINK_DEBUG, meshlink_callback_logger);
46         meshlink_enable_discovery(mesh, false);
47
48         meshlink_start(mesh);
49         //send_event(NODE_STARTED);
50
51         /* All test steps executed - wait for signals to stop/start or close the mesh */
52         while(test_pmtu_relay_running) {
53                 select(1, NULL, NULL, NULL, &main_loop_wait);
54         }
55
56         meshlink_close(mesh);
57
58         return 0;
59 }