2 common_handlers.h -- Declarations of common callback handlers and signal handlers for
4 Copyright (C) 2018 Guus Sliepen <guus@meshlink.io>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef COMMON_HANDLERS_H
22 #define COMMON_HANDLERS_H
24 #include "common_types.h"
26 #define PRINT_TEST_CASE_HEADER() if(state_ptr) \
27 fprintf(stderr, "[ %s ]\n", state_ptr->test_case_name)
28 #define PRINT_TEST_CASE_MSG(...) if(state_ptr) \
30 fprintf(stderr, "[ %s ] ", \
31 state_ptr->test_case_name); \
32 fprintf(stderr, __VA_ARGS__); \
35 extern bool meta_conn_status[];
36 extern bool node_reachable_status[];
37 extern bool test_running;
39 char *get_ip(const char *if_name);
40 char *get_netmask(const char *if_name);
41 void stop_nw_intf(const char *if_name);
42 void start_nw_intf(const char *if_name);
43 void set_ip(const char *if_name, const char *new_ip);
44 void set_netmask(const char *if_name, const char *new_ip);
45 void mesh_close_signal_handler(int a);
46 void mesh_stop_start_signal_handler(int a);
47 void setup_signals(void);
48 void meshlink_callback_node_status(meshlink_handle_t *mesh, meshlink_node_t *node,
50 void meshlink_callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level,
53 #endif // COMMON_HANDLERS_H