AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags]))
AS_IF([test "x$enable_hardening" != "xno"],
- [CPPFLAGS="$CPPFLAGS -W -pedantic"
+ [CPPFLAGS="$CPPFLAGS -Wall -W -pedantic"
AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"],
[AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])]
#include <string.h>
#include <unistd.h>
#include <errno.h>
+#include <sys/time.h>
#include "meshlink.h"
return -1;
}
-void mesh_close_signal_handler(int a) {
+void mesh_close_signal_handler(int signum) {
+ (void)signum;
test_running = false;
exit(EXIT_SUCCESS);
struct lxc_container *old_container;
/* Stop the old container if its still running */
- assert(old_container = find_container(old_name));
+ assert((old_container = find_container(old_name)));
old_container->shutdown(old_container, CONTAINER_SHUTDOWN_TIMEOUT);
/* Call stop() in case shutdown() fails - one of these two will always succeed */
old_container->stop(old_container);
assert(container_name);
assert(snprintf(container_find_name, sizeof(container_find_name), "%s_%s",
state_ptr->test_case_name, container_name) >= 0);
- assert(container = find_container(container_find_name));
+ assert((container = find_container(container_find_name)));
return run_in_container_ex(cmd, container, daemonize);
}
assert(cmd);
assert(container_name);
- assert(container = find_container(container_name));
+ assert((container = find_container(container_name)));
return run_in_container_ex(cmd, container, daemonize);
}
"%s/" LXC_UTIL_REL_PATH "/" LXC_RUN_SCRIPT " \"%s\" %s", meshlink_root_path, cmd,
container->name) >= 0);
FILE *attach_fp;
- assert(attach_fp = popen(attach_command, "r"));
+ assert((attach_fp = popen(attach_command, "r")));
free(attach_command);
/* If the command has an output, strip out any trailing carriage returns or newlines and
return it, otherwise return NULL */
int timeout;
FILE *lxcls_fp;
- assert(test_container = find_container(container_name));
+ assert((test_container = find_container(container_name)));
assert(snprintf(lxcls_command, sizeof(lxcls_command),
"lxc-ls -f | grep %s | tr -s ' ' | cut -d ' ' -f 5", test_container->name) >= 0);
PRINT_TEST_CASE_MSG("Waiting for Container '%s' to acquire IP\n", test_container->name);
- assert(ip = malloc(20));
+ assert((ip = malloc(20)));
ip_len = sizeof(ip);
ip_found = false;
timeout = 60;
while(!ip_found && timeout) {
- assert(lxcls_fp = popen(lxcls_command, "r")); // Run command
+ assert((lxcls_fp = popen(lxcls_command, "r"))); // Run command
assert(getline((char **)&ip, &ip_len, lxcls_fp) != -1); // Read its output
/* Strip newlines and carriage returns from output */
i = strlen(ip) - 1;
/* If this is the first Container, create it otherwise restore the snapshot saved
for the first Container to create an additional Container */
if(i == 0) {
- assert(first_container = lxc_container_new(container_name, NULL));
+ assert((first_container = lxc_container_new(container_name, NULL)));
assert(!first_container->is_defined(first_container));
create_status = first_container->createl(first_container, "download", NULL, NULL,
LXC_CREATE_QUIET, "-d", "ubuntu", "-r", "trusty", "-a", choose_arch, NULL);
after setting the state of the test case to an instance of black_box_state_t */
void setup_containers(void **state) {
black_box_state_t *test_state = (black_box_state_t *)(*state);
- int i, confbase_del_status;
+ int i;
char build_command[200];
struct lxc_container *test_container, *new_container;
char container_find_name[100];
test_state->node_names[i]) >= 0);
if(!(test_container = find_container(container_find_name))) {
- assert(test_container = lxc_container_new(container_find_name, NULL));
+ assert((test_container = lxc_container_new(container_find_name, NULL)));
assert(!test_container->is_defined(test_container));
create_status = test_container->createl(test_container, "download", NULL, NULL,
LXC_CREATE_QUIET, "-d", "ubuntu", "-r", "trusty", "-a", choose_arch, NULL);
if(!(new_container = find_container(container_new_name))) {
rename_container(test_container->name, container_new_name);
- assert(new_container = find_container(container_new_name));
+ assert((new_container = find_container(container_new_name)));
}
/* Start the Container */
/* Shutdown, then start the Container, then wait for it to acquire an IP Address */
assert(snprintf(container_name, sizeof(container_name), "%s_%s", state_ptr->test_case_name,
state_ptr->node_names[i]) >= 0);
- assert(test_container = find_container(container_name));
+ assert((test_container = find_container(container_name)));
test_container->shutdown(test_container, CONTAINER_SHUTDOWN_TIMEOUT);
test_container->stop(test_container);
test_container->start(test_container, 0, NULL);
assert(snprintf(invite_command, sizeof(invite_command),
"LD_LIBRARY_PATH=/home/ubuntu/test/.libs /home/ubuntu/test/gen_invite %s %s "
"2> gen_invite.log", inviter, invitee) >= 0);
- assert(invite_url = run_in_container(invite_command, inviter, false));
+ assert((invite_url = run_in_container(invite_command, inviter, false)));
PRINT_TEST_CASE_MSG("Invite Generated from '%s' to '%s': %s\n", inviter,
invitee, invite_url);
assert(snprintf(invite_command, sizeof(invite_command),
"LD_LIBRARY_PATH=/home/ubuntu/test/.libs /home/ubuntu/test/gen_invite %s %s %s "
"2> gen_invite.log", inviter, invitee, submesh) >= 0);
- assert(invite_url = run_in_container(invite_command, inviter, false));
+ assert((invite_url = run_in_container(invite_command, inviter, false)));
PRINT_TEST_CASE_MSG("Invite Generated from '%s' to '%s': %s\n", inviter,
invitee, invite_url);
Changes begin from X.X.X.254 and continue iteratively till an available address is found */
void change_ip(int node) {
char *gateway_addr;
- char new_ip[20];
+ char new_ip[20] = "";
char *netmask;
char *last_dot_in_ip;
int last_ip_byte = 254;
/* Get IP Address of LXC Bridge Interface - this will be set up as the Gateway Address
of the Static IP assigned to the Container */
- assert(gateway_addr = get_ip(lxc_bridge));
+ assert((gateway_addr = get_ip(lxc_bridge)));
/* Get Netmask of LXC Brdige Interface */
- assert(netmask = get_netmask(lxc_bridge));
+ assert((netmask = get_netmask(lxc_bridge)));
/* Replace last byte of Container's IP with 254 to form the new Container IP */
assert(container_ips[node]);
- strncpy(new_ip, container_ips[node], sizeof(new_ip));
- assert(last_dot_in_ip = strrchr(new_ip, '.'));
+ strncpy(new_ip, container_ips[node], sizeof(new_ip) - 1);
+ assert((last_dot_in_ip = strrchr(new_ip, '.')));
assert(snprintf(last_dot_in_ip + 1, 4, "%d", last_ip_byte) >= 0);
/* Check that the new IP does not match the Container's existing IP
}
/* Create new 'interfaces' file for Container */
- assert(if_fp = fopen("interfaces", "w"));
+ assert((if_fp = fopen("interfaces", "w")));
fprintf(if_fp, "auto lo\n");
fprintf(if_fp, "iface lo inet loopback\n");
fprintf(if_fp, "\n");
/* Restart Container to apply new IP Address */
assert(snprintf(container_name, sizeof(container_name), "%s_%s", state_ptr->test_case_name,
state_ptr->node_names[node]) >= 0);
- assert(container = find_container(container_name));
+ assert((container = find_container(container_name)));
container->shutdown(container, CONTAINER_SHUTDOWN_TIMEOUT);
/* Call stop() in case shutdown() fails
One of these two calls with always succeed */
container->stop(container);
assert(container->start(container, 0, NULL));
- strncpy(container_ips[node], new_ip, sizeof(new_ip)); // Save the new IP Address
+ strncpy(container_ips[node], new_ip, sizeof(container_ips[node])); // Save the new IP Address
PRINT_TEST_CASE_MSG("Node '%s' IP Address changed to %s\n", state_ptr->node_names[node],
container_ips[node]);
}
assert(snprintf(install_cmd, sizeof(install_cmd),
"apt-get install %s -y >> /dev/null", app) >= 0);
- char *ret = run_in_container(install_cmd, node, false);
+ run_in_container(install_cmd, node, false);
// TODO: Check in container whether app has installed or not with a timeout
sleep(10);
}
/* Return container's IP address */
char *get_container_ip(const char *node_name) {
- char *ip;
- int n, node = -1, i;
+ int node = -1, i;
for(i = 0; i < state_ptr->num_nodes; i++) {
if(!strcasecmp(state_ptr->node_names[i], node_name)) {
return NULL;
}
- n = strlen(container_ips[node]) + 1;
- ip = malloc(n);
+ char *ip = strdup(container_ips[node]);
assert(ip);
- strncpy(ip, container_ips[node], n);
return ip;
}
void add_full_cone_nat_rules(const char *container_name, const char *pub_interface, const char *priv_interface_listen_address) {
char nat_cmd[500];
- char *ret;
char **pub_interface_ips = get_container_interface_ips(container_name, pub_interface);
assert(pub_interface_ips[0]);
/* Create a NAT and a bridge, bridge connected to NAT and containers to be NATed can be switched
to the NAT bridge from lxcbr0 */
void nat_create(const char *nat_name, const char *nat_bridge, int nat_type) {
+ (void)nat_type;
+
char build_command[200];
assert(snprintf(build_command, sizeof(build_command),
"%s/" LXC_UTIL_REL_PATH "/" LXC_NAT_BUILD " %s %s %s >/dev/stderr",
FILE *fp_temp = fopen(".temp_file", "w");
assert(fp_temp);
- char search_str[500];
int net_no;
while((fgets(buffer, sizeof(buffer), fp)) != NULL) {
/* Bring the interface up for the bridge created */
void bring_if_up(const char *bridgeName) {
char command[300] = "ifconfig ";
- char dhcommand[300] = "dhclient ";
strcat(command, bridgeName);
strcat(command, " up");
int if_up_status = system(command);
int container_create_status = system(command);
assert(container_create_status == 0);
sleep(3);
- assert(fPtr = fopen(path, "a+"));
+ assert((fPtr = fopen(path, "a+")));
fprintf(fPtr, "lxc.net.0.name = eth0\n");
fprintf(fPtr, "\n");
fprintf(fPtr, "lxc.net.1.type = veth\n");
char *last_dot_in_ip;
int last_ip_byte = 0;
char new_ip[300] = {0};
- strncpy(new_ip, listenAddress, sizeof(new_ip));
- assert(last_dot_in_ip = strrchr(new_ip, '.'));
+ strncpy(new_ip, listenAddress, sizeof(new_ip) - 1);
+ assert((last_dot_in_ip = strrchr(new_ip, '.')));
assert(snprintf(last_dot_in_ip + 1, 4, "%d", last_ip_byte) >= 0);
char comd[300] = "echo \"iptables -t nat -A POSTROUTING -s ";
strcat(comd, new_ip);
// 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;
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) {
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);
}
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);
mesh_events_flush();
event_receive_thread_running = false;
pthread_cancel(event_receive_thread);
-}
\ No newline at end of file
+}
/* Create new network namespace using namespace handle */
static void netns_create_namespace(netns_state_t *test_state, namespace_t *namespace_handle) {
+ (void)test_state;
+
char cmd[200];
- int cmd_ret;
// Add the network namespace
}
static void netns_create_bridge(netns_state_t *test_state, namespace_t *namespace_handle) {
+ (void)test_state;
+
char cmd[200];
- int cmd_ret;
sprintf(cmd, "ip link add name %s type bridge", namespace_handle->name);
assert(system(cmd) == 0);
}
interface_t *get_peer_interface_handle(netns_state_t *test_state, namespace_t *namespace, namespace_t *peer_namespace) {
+ (void)test_state;
+
int i;
interface_t *interfaces = namespace->interfaces;
int if_no = namespace->interfaces_no;
}
void netns_connect_namespaces(netns_state_t *test_state, namespace_t *ns1, namespace_t *ns2) {
- char buff[20], cmd[200], ns_eth0[20], ns_peer0[20];
- int cmd_ret, if_no, i;
+ char buff[20], cmd[200];
+ int i;
char eth_pairs[2][20];
namespace_t *ns[2] = { ns1, ns2 };
interface_t *interface;
// Delete veth pair if already exists
for(i = 0; i < 2; i++) {
assert(sprintf(cmd, "ip link del %s 2>/dev/null", eth_pairs[i]) >= 0);
- cmd_ret = system(cmd);
+ system(cmd);
}
// Create veth pair
}
void netns_configure_ip_address(netns_state_t *test_state) {
- int i, if_no, cmd_ret;
+ int i, if_no;
namespace_t *namespace;
interface_t *if_handle;
char cmd[200];
}
void netns_create_all_namespaces(netns_state_t *test_state) {
- int i, j;
- namespace_t *namespace, *peer_namespace;
- interface_t *interfaces;
+ int i;
+ namespace_t *namespace;
for(i = 0; i < test_state->num_namespaces; i++) {
namespace = get_namespace_handle_by_index(test_state, i);
char *ptr = strchr(ip, '/');
*ptr = '\0';
increment_ipv4_str(ip, INET6_ADDRSTRLEN);
- sprintf(ip, "%s/%d", ip, subnet);
+ sprintf(ip + strlen(ip), "/%d", subnet);
}
interface_t *netns_get_priv_addr(netns_state_t *test_state, const char *namespace_name) {
void netns_assign_ip_addresses(netns_state_t *test_state) {
int ns, j;
namespace_t *namespace_handle;
- interface_t *interface_handle, *peer_interface_handle;
- int sub_net;
-
+ interface_t *interface_handle;
char *addr = malloc(INET6_ADDRSTRLEN);
assert(addr);
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
#include <unistd.h>
#include <sys/prctl.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include "common_handlers.h"
#include "tcpdump.h"
pid_t tcpdump_start(char *interface) {
- pid_t tcpdump_pid;
char *argv[] = { "tcpdump", "-i", interface, NULL };
// child process have a pipe to the parent process when parent process terminates SIGPIPE kills the tcpdump
int pipes[2];
assert(pipe(pipes) != -1);
PRINT_TEST_CASE_MSG("\x1b[32mLaunching TCP Dump ..\x1b[0m\n");
- if((tcpdump_pid = fork()) == 0) {
+ pid_t tcpdump_pid = fork();
+
+ if(tcpdump_pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGHUP);
close(pipes[1]);
// Open log file for TCP Dump
assert(dup2(fd, STDOUT_FILENO) != -1);
// Launch TCPDump with port numbers of sleepy, gateway & relay
- int ret = execvp("/usr/sbin/tcpdump", argv);
+ execvp("/usr/sbin/tcpdump", argv);
perror("execvp ");
- assert(ret != -1);
+ exit(1);
} else {
close(pipes[0]);
- return tcpdump_pid;
}
+
+ return tcpdump_pid;
}
void tcpdump_stop(pid_t tcpdump_pid) {
void execute_change_ip(void) {
char *eth_if_ip;
int last_byte;
- char new_ip[20], gateway_ip[20];
+ char new_ip[20] = "", gateway_ip[20] = "";
char *last_dot_in_ip;
char *eth_if_netmask;
- char route_chg_command[200];
- int route_chg_status;
/* Get existing IP Address of Ethernet Bridge Interface */
- assert(eth_if_ip = get_ip(eth_if_name));
+ assert((eth_if_ip = get_ip(eth_if_name)));
/* Set new IP Address by replacing the last byte with last byte + 1 */
- strncpy(new_ip, eth_if_ip, sizeof(new_ip));
- assert(last_dot_in_ip = strrchr(new_ip, '.'));
+ strncpy(new_ip, eth_if_ip, sizeof(new_ip) - 1);
+ assert((last_dot_in_ip = strrchr(new_ip, '.')));
last_byte = atoi(last_dot_in_ip + 1);
assert(snprintf(last_dot_in_ip + 1, 4, "%d", (last_byte > 253) ? 2 : (last_byte + 1)) >= 0);
/* Bring the network interface down before making changes */
stop_nw_intf(eth_if_name);
/* Save the netmask first, then restore it after setting the new IP Address */
- assert(eth_if_netmask = get_netmask(eth_if_name));
+ assert((eth_if_netmask = get_netmask(eth_if_name)));
set_ip(eth_if_name, new_ip);
set_netmask(eth_if_name, eth_if_netmask);
/* Bring the network interface back up again to apply changes */
/* Get Gateway's IP Address, by replacing the last byte with 1 in the current IP Address */
/* TO DO: Obtain the actual Gateway IP Address */
- strncpy(gateway_ip, eth_if_ip, sizeof(gateway_ip));
- assert(last_dot_in_ip = strrchr(gateway_ip, '.'));
+ strncpy(gateway_ip, eth_if_ip, sizeof(gateway_ip) - 1);
+ assert((last_dot_in_ip = strrchr(gateway_ip, '.')));
assert(snprintf(last_dot_in_ip + 1, 4, "%d", 1) >= 0);
/* Add the default route back again, which would have been deleted when the
};
int black_box_group0_setup(void **state) {
+ (void)state;
+
const char *nodes[] = { "peer", "relay", "nut"};
int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
}
int black_box_group0_teardown(void **state) {
+ (void)state;
+
PRINT_TEST_CASE_MSG("Destroying Containers\n");
destroy_containers();
}
int black_box_all_nodes_setup(void **state) {
+ (void)state;
+
const char *nodes[] = { "peer" };
int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
case META_RECONN_SUCCESSFUL :
meta_conn01_reconn = true;
break;
+
+ default:
+ break;
}
return true;
*/
static bool test_steps_meta_conn_01(void) {
char *invite_peer, *invite_nut;
- int i;
char *import;
import = mesh_event_sock_create(eth_if_name);
case NODE_STARTED :
fprintf(stderr, "Node started\n");
break;
+
+ default:
+ break;
}
return true;
*/
static bool test_steps_meta_conn_02(void) {
char *invite_peer, *invite_nut;
- int i;
char *import;
import = mesh_event_sock_create(eth_if_name);
fprintf(stderr, "Reconnected\n");
meta_conn03_result = true;
break;
+
+ default:
+ break;
}
return true;
*/
static bool test_steps_meta_conn_03(void) {
char *invite_peer, *invite_nut;
- int i;
char *import;
import = mesh_event_sock_create(eth_if_name);
default :
fprintf(stderr, "Undefined mesh event\n");
+ break;
}
return true;
case NODE_STARTED :
fprintf(stderr, "Node started\n");
break;
+
+ default:
+ break;
}
return true;
assert(len);
}
-static bool bar_reachable;
-
static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
(void)mesh;
fprintf(stderr, "Status of node {%s} is %d\n", node->name, reachable);
static bool received;
static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *data, size_t len) {
+ (void)mesh;
+
const char *msg = data;
assert(len);
static bool bar_reachable;
static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcmp(node->name, "bar") && reachable) {
bar_reachable = true;
}
static mesh_arg_t nut_arg = {.node_name = "nut", .confbase = "nut", .app_name = "nut", .dev_class = 1 };
static mesh_invite_arg_t relay_nut_invite_arg = {.mesh_arg = &relay_arg, .invitee_name = "nut" };
static mesh_invite_arg_t relay_peer_invite_arg = {.mesh_arg = &relay_arg, .invitee_name = "peer" };
-static mesh_invite_arg_t peer_nut_invite_arg = {.mesh_arg = &peer_arg, .invitee_name = "nut" };
static netns_thread_t netns_relay_nut_invite = {.namespace_name = "relay", .netns_thread = gen_inv, .arg = &relay_nut_invite_arg};
static netns_thread_t netns_relay_peer_invite = {.namespace_name = "relay", .netns_thread = gen_inv, .arg = &relay_peer_invite_arg};
-static netns_thread_t netns_peer_nut_invite = {.namespace_name = "peer", .netns_thread = gen_inv, .arg = &peer_nut_invite_arg};
static netns_thread_t netns_relay_handle = {.namespace_name = "relay", .netns_thread = test_channel_blacklist_disonnection_relay_01, .arg = &relay_arg};
static netns_thread_t netns_peer_handle = {.namespace_name = "peer", .netns_thread = test_channel_blacklist_disonnection_peer_01, .arg = &peer_arg};
static netns_thread_t netns_nut_handle = {.namespace_name = "nut", .netns_thread = test_channel_blacklist_disonnection_nut_01, .arg = &nut_arg};
struct sync_flag test_channel_discon_nut_close = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static int setup_test(void **state) {
+ (void)state;
+
netns_create_topology(test_channel_disconnection_state);
fprintf(stderr, "\nCreated topology\n");
}
static int teardown_test(void **state) {
+ (void)state;
+
meshlink_destroy("nut");
meshlink_destroy("peer");
meshlink_destroy("relay");
}
static void execute_test(test_step_func_t step_func, void **state) {
+ (void)state;
+
fprintf(stderr, "\n\x1b[32mRunning Test\x1b[0m\n");
bool test_result = step_func();
assert(invitation);
mesh_invite_arg->invite_str = invitation;
meshlink_close(mesh);
+
+ return NULL;
}
static void launch_3_nodes(void) {
/* Test Steps for meshlink_channel_close Test Case # 1*/
static bool test_steps_mesh_channel_close_01(void) {
- bool result = false;
- char *msg = NULL;
- char buf[] = "bar";
- msg = buf;
- size_t len = sizeof(buf);
meshlink_destroy("chan_close_conf.3");
meshlink_destroy("chan_close_conf.4");
}
static int black_box_group_setup(void **state) {
+ (void)state;
+
const char *nodes[] = { "peer", "nut", "relay" };
int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
}
static int black_box_group_teardown(void **state) {
+ (void)state;
+
printf("Destroying Containers\n");
destroy_containers();
int test_meshlink_channel_conn(void) {
const struct CMUnitTest blackbox_group0_tests[] = {
cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_01, setup_test, teardown_test,
- (void *)&test_case_channel_conn_01_state),/*
- cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_02, setup_test, teardown_test,
- (void *)&test_case_channel_conn_02_state),
- cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_03, setup_test, teardown_test,
- (void *)&test_case_channel_conn_03_state),
- cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_04, setup_test, teardown_test,
- (void *)&test_case_channel_conn_04_state),
- cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_05, setup_test, teardown_test,
- (void *)&test_case_channel_conn_05_state),
- cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_06, setup_test, teardown_test,
- (void *)&test_case_channel_conn_06_state),
- cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_07, setup_test, teardown_test,
- (void *)&test_case_channel_conn_07_state),
- cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_08, setup_test, teardown_test,
- (void *)&test_case_channel_conn_08_state)*/
+ (void *)&test_case_channel_conn_01_state),
+ cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_02, setup_test, teardown_test,
+ (void *)&test_case_channel_conn_02_state),
+ cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_03, setup_test, teardown_test,
+ (void *)&test_case_channel_conn_03_state),
+ cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_04, setup_test, teardown_test,
+ (void *)&test_case_channel_conn_04_state),
+ cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_05, setup_test, teardown_test,
+ (void *)&test_case_channel_conn_05_state),
+ cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_06, setup_test, teardown_test,
+ (void *)&test_case_channel_conn_06_state),
+ cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_07, setup_test, teardown_test,
+ (void *)&test_case_channel_conn_07_state),
+ cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_08, setup_test, teardown_test,
+ (void *)&test_case_channel_conn_08_state),
};
total_tests += sizeof(blackbox_group0_tests) / sizeof(blackbox_group0_tests[0]);
static black_box_state_t test_case_channel_ex_06_state = {
.test_case_name = "test_case_channel_ex_06",
};
-static black_box_state_t test_case_channel_ex_07_state = {
- .test_case_name = "test_case_channel_ex_07",
-};
-
/* mutex for the common variable */
static pthread_mutex_t accept_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t accept_cond = PTHREAD_COND_INITIALIZER;
}
static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) {
+ (void)mesh;
+ (void)channel;
(void)dat;
(void)len;
- char *data = (char *) dat;
+
assert_int_equal(port, PORT);
pthread_mutex_lock(&accept_lock);
static black_box_state_t test_case_channel_get_flags_01_state = {
.test_case_name = "test_case_channel_get_flags_01",
};
+
static black_box_state_t test_case_channel_get_flags_02_state = {
.test_case_name = "test_case_channel_get_flags_02",
};
+
static black_box_state_t test_case_channel_get_flags_03_state = {
.test_case_name = "test_case_channel_get_flags_03",
};
-static black_box_state_t test_case_channel_get_flags_04_state = {
- .test_case_name = "test_case_channel_get_flags_04",
-};
-
/* Execute meshlink_channel_get_flags Test Case # 1 - Valid case*/
static void test_case_channel_get_flags_01(void **state) {
execute_test(test_steps_mesh_channel_open_01, state);
}
-static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
- (void)mesh;
- (void)channel;
-}
-
/* Test Steps for meshlink_channel_open Test Case # 1
Test Steps:
// Open a channel from foo to bar.
meshlink_node_t *bar = meshlink_get_node(mesh1, "bar");
assert(bar != NULL);
- meshlink_channel_t *channel = meshlink_channel_open(mesh1, bar, 7000, receive_cb, NULL, 0);
+ meshlink_channel_t *channel = meshlink_channel_open(mesh1, bar, 7000, NULL, NULL, 0);
assert_int_not_equal(channel, NULL);
// Clean up.
}
static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)data;
+
assert(port == 7);
assert(!len);
/* channel receive callback */
static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+ (void)channel;
+
if(len == 5 && !memcmp(dat, "Hello", 5)) {
pthread_mutex_lock(& bar_responded_lock);
bar_responded = true;
/* Test Steps for meshlink_channel_send Test Case # 3*/
static bool test_steps_mesh_channel_send_03(void) {
- struct timespec timeout = {0};
meshlink_destroy("chan_send_conf.7");
// Open new meshlink instance.
static bool channel_reject(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len);
static bool channel_acc;
-static bool channel_rej;
static bool polled;
static bool rejected;
/* mutex for the common variable */
static pthread_mutex_t accept_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t reject_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t poll_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t lock_receive = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t accept_cond = PTHREAD_COND_INITIALIZER;
-static pthread_cond_t reject_cond = PTHREAD_COND_INITIALIZER;
static pthread_cond_t poll_cond = PTHREAD_COND_INITIALIZER;
static pthread_cond_t receive_cond = PTHREAD_COND_INITIALIZER;
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)dat;
+
if(!len) {
if(!meshlink_errno) {
- pthread_mutex_lock(& lock_receive);
+ pthread_mutex_lock(&lock_receive);
rejected = true;
assert(!pthread_cond_broadcast(&receive_cond));
- pthread_mutex_unlock(& lock_receive);
+ pthread_mutex_unlock(&lock_receive);
}
}
}
}
static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) {
+ (void)mesh;
+ (void)channel;
(void)dat;
(void)len;
- char *data = (char *) dat;
+
assert_int_equal(port, PORT);
pthread_mutex_lock(&accept_lock);
}
static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *source, bool reach) {
+ (void)mesh;
+ (void)source;
+
+ if(!reach) {
+ return;
+ }
+
pthread_mutex_lock(&reachable_lock);
reachable = true;
assert(!pthread_cond_broadcast(&reachable_cond));
static bool test_steps_set_channel_receive_cb_02(void);
static void test_case_set_channel_receive_cb_03(void **state);
static bool test_steps_set_channel_receive_cb_03(void);
-static void test_case_set_channel_receive_cb_04(void **state);
-static bool test_steps_set_channel_receive_cb_04(void);
-
-static void channel_poll(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len);
-static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len);
static bool rec_stat = false;
static bool accept_stat = false;
static black_box_state_t test_case_channel_set_receive_cb_01_state = {
.test_case_name = "test_case_channel_set_receive_cb_01",
};
+
static black_box_state_t test_case_channel_set_receive_cb_02_state = {
.test_case_name = "test_case_channel_set_receive_cb_02",
};
+
static black_box_state_t test_case_channel_set_receive_cb_03_state = {
.test_case_name = "test_case_channel_set_receive_cb_03",
};
-static black_box_state_t test_case_channel_set_receive_cb_04_state = {
- .test_case_name = "test_case_channel_set_receive_cb_04",
-};
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)dat;
+ (void)len;
+
pthread_mutex_lock(& lock_receive);
rec_stat = true;
assert(!pthread_cond_broadcast(&receive_cond));
}
static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)port;
+ (void)data;
+ (void)len;
+
meshlink_set_channel_receive_cb(mesh, channel, channel_receive_cb);
pthread_mutex_lock(& lock_accept);
static bool test_steps_mesh_channel_shutdown_02(void);
static void test_case_mesh_channel_shutdown_03(void **state);
static bool test_steps_mesh_channel_shutdown_03(void);
-static void test_case_mesh_channel_shutdown_04(void **state);
-static bool test_steps_mesh_channel_shutdown_04(void);
-static void test_case_mesh_channel_shutdown_05(void **state);
-static bool test_steps_mesh_channel_shutdown_05(void);
static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len);
-static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable);
static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len);
/* State structure for meshlink_channel_shutdown Test Case #1 */
.test_case_name = "test_case_mesh_channel_shutdown_03",
};
-/* State structure for meshlink_channel_shutdown Test Case #4 */
-static black_box_state_t test_mesh_channel_shutdown_04_state = {
- .test_case_name = "test_case_mesh_channel_shutdown_04",
-};
-
-/* State structure for meshlink_channel_shutdown Test Case #5 */
-static black_box_state_t test_mesh_channel_shutdown_05_state = {
- .test_case_name = "test_case_mesh_channel_shutdown_05",
-};
-
static bool channel_acc;
static bool polled;
static bool foo_responded;
static pthread_cond_t bar_cond = PTHREAD_COND_INITIALIZER;
static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)data;
+
assert(port == 7);
assert(!len);
/* channel receive callback */
static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)dat;
+ (void)len;
+
if(!strcmp(mesh->name, "foo")) {
pthread_mutex_lock(& foo_responded_lock);
foo_responded = true;
pthread_mutex_unlock(&accept_lock);
- meshlink_channel_t *channel2 = bar->priv;
-
// Sending to bar and testing the echo
assert(meshlink_channel_send(mesh1, channel1, "echo", 4) >= 0);
static bool received = false;
static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *data, size_t len) {
+ (void)mesh;
+ (void)data;
+
assert(len);
if(!strcmp(src->name, "bar") || !strcmp(src->name, "foz")) {
static bool foz_reachable = false;
void status_cb1(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcmp(node->name, "bar")) {
bar_reachable = reachable;
} else if(!strcmp(node->name, "foz")) {
static bool test_get_all_nodes_02(void);
static void test_case_get_all_nodes_03(void **state);
static bool test_get_all_nodes_03(void);
-static void test_case_get_all_nodes_04(void **state);
-static bool test_get_all_nodes_04(void);
/* State structure for get_all_nodes Test Case #1 */
static black_box_state_t test_case_get_all_nodes_01_state = {
Error reported correctly by returning NULL
*/
static bool test_get_all_nodes_02(void) {
- meshlink_node_t **nodes = NULL;
size_t nmemb = 0;
- meshlink_node_t **node = meshlink_get_all_nodes(NULL, nodes, &nmemb);
- assert_int_equal(nodes, NULL);
+ meshlink_node_t **nodes = meshlink_get_all_nodes(NULL, NULL, &nmemb);
+ assert_null(nodes);
+ assert_int_equal(nmemb, NULL);
return true;
}
static bool test_steps_mesh_get_node_by_dev_class_02(void) {
meshlink_node_t **nodes;
size_t nnodes = 0;
- int i;
+
meshlink_destroy("getnodeconf.1");
/* Create meshlink instance for NUT */
}
static int black_box_setup_test_case(void **state) {
+ (void)state;
+
fprintf(stderr, "Destroying confbases\n");
meshlink_destroy("getnodeconf.1");
meshlink_destroy("getnodeconf.2");
static bool test_import_04(void);
static void test_case_import_05(void **state);
static bool test_import_05(void);
-static void test_case_import_06(void **state);
-static bool test_import_06(void);
/* State structure for import API Test Case #1 */
static black_box_state_t test_case_import_01_state = {
.test_case_name = "test_case_import_01",
};
+
/* State structure for import API Test Case #2 */
static black_box_state_t test_case_import_02_state = {
.test_case_name = "test_case_import_02",
};
+
/* State structure for import API Test Case #3 */
static black_box_state_t test_case_import_03_state = {
.test_case_name = "test_case_import_03",
};
+
/* State structure for import API Test Case #4 */
static black_box_state_t test_case_import_04_state = {
.test_case_name = "test_case_import_04",
};
+
/* State structure for import API Test Case #5 */
static black_box_state_t test_case_import_05_state = {
.test_case_name = "test_case_import_05",
};
-/* State structure for import API Test Case #6 */
-static black_box_state_t test_case_import_06_state = {
- .test_case_name = "test_case_import_06",
-};
-
/* Execute import Test Case # 1 - valid case*/
static void test_case_import_01(void **state) {
meshlink_set_log_cb(mesh_handle, TEST_MESHLINK_LOG_LEVEL, meshlink_callback_logger);
char *hostname1 = "127.1.1.1";
- bool ret = meshlink_add_address(mesh_handle, hostname1);
+ meshlink_add_address(mesh_handle, hostname1);
char *invitation = meshlink_invite(mesh_handle, NULL, "foo");
assert_int_not_equal(strstr(invitation, hostname1), NULL);
char *hostname2 = "127.1.2.3";
- ret = meshlink_add_address(mesh_handle, hostname2);
+ meshlink_add_address(mesh_handle, hostname2);
invitation = meshlink_invite(mesh_handle, NULL, "bar");
// Verify we have both the added addresses
static bool test_meshlink_join_02(void);
static void test_case_meshlink_join_03(void **state);
static bool test_meshlink_join_03(void);
-static void test_case_meshlink_join_04(void **state);
-static bool test_meshlink_join_04(void);
/* State structure for join Test Case #1 */
static black_box_state_t test_case_join_01_state = {
static int break_stage;
static void nop_stage(int stage) {
+ (void)stage;
+
return;
}
of the instance should be unchanged.
*/
bool test_steps_mesh_random_port_bindings_01(void) {
- struct sockaddr_in servaddr;
meshlink_handle_t *relay = NULL;
meshlink_destroy("relay_conf");
The meshlink_set_port() API should fail.
*/
bool test_steps_mesh_random_port_bindings_02(void) {
- int port = -1;
meshlink_handle_t *relay = NULL;
meshlink_destroy("relay_conf");
assert_true(meshlink_start(relay));
sleep(1);
- port = meshlink_get_port(relay);
devtool_trybind_probe = occupy_trybind_port;
meshlink_stop(relay);
previous port number.
*/
bool test_steps_mesh_random_port_bindings_03(void) {
- int mode = 1;
int port, new_port;
- struct sockaddr_in servaddr;
- struct sockaddr_in6 ipv6addr;
meshlink_handle_t *relay = NULL;
meshlink_destroy("relay_conf");
static bool localnode = false;
static int setup_test(void **state) {
+ (void)state;
+
netns_create_topology(test_random_port_bindings_state);
fprintf(stderr, "\nCreated topology\n");
}
static int teardown_test(void **state) {
+ (void)state;
+
meshlink_destroy("nut");
meshlink_destroy("peer");
meshlink_destroy("relay");
}
static void execute_test(test_step_func_t step_func, void **state) {
+ (void)state;
+
fprintf(stderr, "\n\x1b[32mRunning Test\x1b[0m\n");
bool test_result = step_func();
}
static void message_log(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)level;
+
char *levelstr = "\x1b[32mRELAY";
if(strcmp(mesh->name, "peer") == 0) {
static bool test_set_rec_cb_02(void);
static void test_case_set_rec_cb_03(void **state);
static bool test_set_rec_cb_03(void);
-static void test_case_set_rec_cb_04(void **state);
-static bool test_set_rec_cb_04(void);
/* Test Steps for meshlink_set_receive_cb Test Case #1 */
static black_box_state_t test_case_set_rec_cb_01_state = {
/* receive callback function */
static void rec_cb(meshlink_handle_t *mesh, meshlink_node_t *source, const void *data, size_t len) {
+ (void)mesh;
+ (void)source;
+
assert(len);
pthread_mutex_lock(&lock);
.test_case_name = "test_case_mesh_send_03",
};
-/* State structure for meshlink_send Test Case #4 */
-static black_box_state_t test_mesh_send_04_state = {
- .test_case_name = "test_case_mesh_send_04",
-};
-
-/* State structure for meshlink_send Test Case #5 */
-static black_box_state_t test_mesh_send_05_state = {
- .test_case_name = "test_case_mesh_send_05",
-};
-
-/* State structure for meshlink_send Test Case #6 */
-static black_box_state_t test_mesh_send_06_state = {
- .test_case_name = "test_case_mesh_send_06",
-};
-
/* Execute meshlink_send Test Case # 1 */
static void test_case_mesh_send_01(void **state) {
execute_test(test_steps_mesh_send_01, state);
static bool receive_data = false;
static void receive(meshlink_handle_t *mesh, meshlink_node_t *dest_node, const void *data, size_t len) {
- const char *msg = data;
+ (void)mesh;
+ (void)dest_node;
assert(len);
/* Meta-connection try callback handler */
static void connection_try_cb(meshlink_handle_t *mesh, meshlink_node_t *source) {
+ (void)source;
+
if(!strcmp(mesh->name, "foo")) {
++connection_attempts;
assert(exp1 != NULL);
char *exp2 = meshlink_export(mesh2);
assert(exp2 != NULL);
- bool imp1 = meshlink_import(mesh1, exp2);
- bool imp2 = meshlink_import(mesh2, exp1);
+ meshlink_import(mesh1, exp2);
+ meshlink_import(mesh2, exp1);
free(exp1);
free(exp2);
static bool test_set_log_cb_01(void);
static void test_case_set_log_cb_02(void **state);
static bool test_set_log_cb_02(void);
-static void test_case_set_log_cb_03(void **state);
-static bool test_set_log_cb_03(void);
/* log variable gives access to the log callback to know whether invoked or not */
static bool log;
/* log callback */
static void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)mesh;
+ (void)level;
+
fprintf(stderr, "Received log text : %s\n", text);
log = true;
}
meshlink_close(mesh_handle);
meshlink_destroy("getportconf");
+
+ return false;
}
// Signing data
char *data = "Test";
- char sig[MESHLINK_SIGLEN];
size_t ssize = MESHLINK_SIGLEN;
bool ret = meshlink_sign(mesh_handle, data, strlen(data) + 1, NULL, &ssize);
char *data = "Test";
char sig[MESHLINK_SIGLEN];
- size_t ssize = MESHLINK_SIGLEN;
bool ret = meshlink_sign(mesh_handle, data, strlen(data) + 1, sig, NULL);
// Clean up
static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *source, bool reach) {
+ (void)mesh;
+
fprintf(stderr, "In status callback\n");
if(reach) {
assert(exp1 != NULL);
char *exp2 = meshlink_export(mesh2);
assert(exp2 != NULL);
- bool imp1 = meshlink_import(mesh1, exp2);
- bool imp2 = meshlink_import(mesh2, exp1);
+ meshlink_import(mesh1, exp2);
+ meshlink_import(mesh2, exp1);
assert(meshlink_start(mesh1));
assert(meshlink_start(mesh2));
};
static int black_box_group0_setup(void **state) {
+ (void)state;
+
const char *nodes[] = { "corenode1", "app1node1", "app2node1", "corenode2", "app1node2", "app2node2" };
int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
}
static int black_box_group0_teardown(void **state) {
+ (void)state;
+
PRINT_TEST_CASE_MSG("Destroying Containers\n");
destroy_containers();
return 0;
}
-static int black_box_all_nodes_setup(void **state) {
- const char *nodes[] = { "corenode1" };
- int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
-
- PRINT_TEST_CASE_MSG("Creating Containers\n");
- destroy_containers();
- create_containers(nodes, num_nodes);
- PRINT_TEST_CASE_MSG("Created Containers\n");
- return 0;
-}
-
static bool event_cb(mesh_event_payload_t payload) {
static node_status_t node_status[6] = {
- {core_node1, 0, 3, false},
- {app1_node1, 0, 4, false},
- {app2_node1, 0, 4, false},
- {core_node2, 0, 4, false},
- {app1_node2, 0, 7, false},
- {app2_node2, 0, 7, false}
+ {core_node1, 0, 3},
+ {app1_node1, 0, 4},
+ {app2_node1, 0, 4},
+ {core_node2, 0, 4},
+ {app1_node2, 0, 7},
+ {app2_node2, 0, 7},
};
fprintf(stderr, "%s(%lu) : %s\n", event_node_name[payload.client_id], time(NULL), event_status[payload.mesh_event]);
*/
static bool test_steps_submesh_01(void) {
char *invite_corenode2, *invite_app1node1, *invite_app2node1, *invite_app1node2, *invite_app2node2;
- bool result = false;
- int i;
char *import;
- pthread_t thread1, thread2;
import = mesh_event_sock_create(eth_if_name);
invite_corenode2 = invite_in_container("corenode1", "corenode2");
};
static int black_box_group0_setup(void **state) {
+ (void)state;
+
const char *nodes[] = { "corenode1", "app1node1", "app2node1", "corenode2", "app1node2", "app2node2" };
int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
}
static int black_box_group0_teardown(void **state) {
+ (void)state;
+
PRINT_TEST_CASE_MSG("Destroying Containers\n");
destroy_containers();
return 0;
}
-static int black_box_all_nodes_setup(void **state) {
- const char *nodes[] = { "corenode1" };
- int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
-
- PRINT_TEST_CASE_MSG("Creating Containers\n");
- destroy_containers();
- create_containers(nodes, num_nodes);
- PRINT_TEST_CASE_MSG("Created Containers\n");
- return 0;
-}
-
static bool event_cb(mesh_event_payload_t payload) {
static node_status_t node_status[6] = {
- {core_node1, 0, 3, false},
- {app1_node1, 0, 4, false},
- {app2_node1, 0, 4, false},
- {core_node2, 0, 4, false},
- {app1_node2, 0, 7, false},
- {app2_node2, 0, 7, false}
+ {core_node1, 0, 3},
+ {app1_node1, 0, 4},
+ {app2_node1, 0, 4},
+ {core_node2, 0, 4},
+ {app1_node2, 0, 7},
+ {app2_node2, 0, 7},
};
fprintf(stderr, "%s(%lu) : %s\n", event_node_name[payload.client_id], time(NULL), event_status[payload.mesh_event]);
*/
static bool test_steps_submesh_02(void) {
char *invite_corenode2, *invite_app1node1, *invite_app2node1, *invite_app1node2, *invite_app2node2;
- bool result = false;
- int i;
char *import;
- pthread_t thread1, thread2;
import = mesh_event_sock_create(eth_if_name);
invite_corenode2 = invite_in_container("corenode1", "corenode2");
static mesh_event_t app1_node2[] = { NODE_STARTED, NODE_JOINED, CHANNEL_OPENED, CHANNEL_DATA_RECIEVED, CHANNEL_OPENED, CHANNEL_DATA_RECIEVED, MESH_EVENT_COMPLETED};
static node_status_t node_status[3] = {
- {core_node1, 0, 3, false},
- {app1_node1, 0, 4, false},
- {app1_node2, 0, 7, false}
+ {core_node1, 0, 3},
+ {app1_node1, 0, 4},
+ {app1_node2, 0, 7},
};
/* State structure for SubMesh Test Case #3 */
};
static int black_box_group0_setup(void **state) {
+ (void)state;
+
const char *nodes[] = { "corenode1", "app1node1", "app1node2" };
int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
}
static int black_box_group0_teardown(void **state) {
+ (void)state;
+
PRINT_TEST_CASE_MSG("Destroying Containers\n");
destroy_containers();
return 0;
}
-static int black_box_all_nodes_setup(void **state) {
- const char *nodes[] = { "corenode1" };
- int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
-
- PRINT_TEST_CASE_MSG("Creating Containers\n");
- destroy_containers();
- create_containers(nodes, num_nodes);
- PRINT_TEST_CASE_MSG("Created Containers\n");
- return 0;
-}
-
static void restart_all_nodes(char *import) {
int i;
*/
static bool test_steps_submesh_03(void) {
char *invite_app1node1, *invite_app1node2;
- bool result = false;
- int i;
char *import;
- pthread_t thread1, thread2;
import = mesh_event_sock_create(eth_if_name);
invite_app1node1 = invite_in_container("corenode1", "app1node1");
};
static int black_box_group0_setup(void **state) {
+ (void)state;
+
const char *nodes[] = { "corenode1", "app1node1", "app1node2" };
int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
}
static int black_box_group0_teardown(void **state) {
+ (void)state;
+
PRINT_TEST_CASE_MSG("Destroying Containers\n");
destroy_containers();
return 0;
}
-static int black_box_all_nodes_setup(void **state) {
- const char *nodes[] = { "corenode1" };
- int num_nodes = sizeof(nodes) / sizeof(nodes[0]);
-
- PRINT_TEST_CASE_MSG("Creating Containers\n");
- destroy_containers();
- create_containers(nodes, num_nodes);
- PRINT_TEST_CASE_MSG("Created Containers\n");
- return 0;
-}
-
static bool event_cb(mesh_event_payload_t payload) {
static node_status_t node_status[3] = {
- {core_node1, 0, 3, false},
- {app1_node1, 0, 4, false},
- {app1_node2, 0, 7, false}
+ {core_node1, 0, 3},
+ {app1_node1, 0, 4},
+ {app1_node2, 0, 7},
};
fprintf(stderr, "%s(%lu) : %s\n", event_node_name[payload.client_id], time(NULL), event_status[payload.mesh_event]);
*/
static bool test_steps_submesh_04(void) {
char *invite_app1node1, *invite_app1node2;
- bool result = false;
- int i;
char *import;
- pthread_t thread1, thread2;
import = mesh_event_sock_create(eth_if_name);
invite_app1node1 = invite_in_container("corenode1", "app1node1");
static bool test_verify_05(void);
static void test_case_verify_06(void **state);
static bool test_verify_06(void);
-static void test_case_verify_07(void **state);
-static bool test_verify_07(void);
-static void test_case_verify_08(void **state);
-static bool test_verify_08(void);
/* State structure for verify API Test Case #1 */
static black_box_state_t test_case_verify_01_state = {
static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *data, size_t len) {
- const char *msg = data;
+ (void)mesh;
+ (void)src;
+ (void)data;
+
assert(len);
pthread_mutex_lock(& lock_receive);
}
static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reach) {
+ (void)mesh;
+
if(!strcmp(node->name, "bar")) {
pthread_mutex_lock(&reachable_lock);
reachable = reach;
static netns_state_t *test_pmtu_state;
static int setup_test(void **state) {
+ (void)state;
+
netns_create_topology(test_pmtu_state);
fprintf(stderr, "\nCreated topology\n");
test_pmtu_peer_running = true;
test_pmtu_nut_running = true;
ping_channel_enable_07 = false;
- memset(node_pmtu, 2, sizeof(node_pmtu[0]));
+ memset(node_pmtu, 0, sizeof(node_pmtu));
set_sync_flag(&test_pmtu_nut_closed, false);
meshlink_destroy("nut");
meshlink_destroy("peer");
}
static int teardown_test(void **state) {
+ (void)state;
+
meshlink_destroy("nut");
meshlink_destroy("peer");
meshlink_destroy("relay");
}
static void execute_test(test_step_func_t step_func, void **state) {
+ (void)state;
+
fprintf(stderr, "\n\x1b[32mRunning Test\x1b[0m\n");
bool test_result = step_func();
assert(invitation);
mesh_invite_arg->invite_str = invitation;
meshlink_close(mesh);
+
+ return NULL;
}
/* Test Steps for optimal PMTU discovery Test Case # 1 -
static bool run_conntrack;
static pthread_t pmtu_test_case_conntrack_thread;
static void *conntrack_flush(void *arg) {
+ (void)arg;
+
// flushes mappings for every 60 seconds
while(run_conntrack) {
int mtu_size;
} pmtu_attr_t;
-#define NODE_PMTU_RELAY 1
-#define NODE_PMTU_PEER 2
+#define NODE_PMTU_RELAY 0
+#define NODE_PMTU_PEER 1
#define find_node_index(i, node_name) if(!strcasecmp(node_name, "peer")) { \
i = NODE_PMTU_PEER; \
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag channels_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
fprintf(stderr, "Node %s %s\n", node->name, reachable ? "reachable" : "unreachable");
}
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
fprintf(stderr, "Closed channel with %s\n", (char *)channel->priv);
}
static void log_message(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)level;
+
(void)mesh;
fprintf(stderr, "\x1b[32m nut:\x1b[0m %s\n", text);
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len);
static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len);
-static int client_id = -1;
-
static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) {
(void)dat;
(void)len;
static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
-static struct sync_flag channel_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable);
-static void mesh_siguser1_signal_handler(int sig_num);
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable);
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr_received, true);
return;
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer") && reachable) {
set_sync_flag(&peer_reachable, true);
}
}
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
send_event(ERR_NETWORK);
assert(false);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
- int i;
// Import mesh event handler
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
// Import mesh event handler
static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable);
-static void mesh_siguser1_signal_handler(int sig_num);
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable);
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr_received, true);
return;
}
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer") && reachable) {
set_sync_flag(&peer_reachable, true);
}
}
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
set_sync_flag(&channel_closed, true);
send_event(ERR_NETWORK);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
- int i;
// Import mesh event handler
#define CHANNEL_PORT 1234
static int client_id = -1;
-static bool channel_rec;
-static bool channel_reply;
-static pthread_mutex_t reply_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t reply_cond = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t recv_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t recv_cond = PTHREAD_COND_INITIALIZER;
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
// Import mesh event handler
static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable);
-static void mesh_siguser1_signal_handler(int sig_num);
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable);
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr_received, true);
return;
}
static void send_event(mesh_event_t event) {
- bool send_ret = false;
int attempts;
for(attempts = 0; attempts < 5; attempts += 1) {
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer")) {
if(reachable) {
set_sync_flag(&peer_reachable, true);
}
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(!strcmp(channel->node->name, "peer")) {
if(len == 5 && !memcmp(dat, "reply", 5)) {
set_sync_flag(&channel_opened, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
- int i;
// Import mesh event handler
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
// Import mesh event handler
static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
-static struct sync_flag channel_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer")) {
if(reachable) {
set_sync_flag(&peer_reachable, true);
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
//send_event(ERR_NETWORK);
return;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- int i;
// Import mesh event handler
static int client_id = -1;
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr, true);
return;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
// Import mesh event handler
static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
-static struct sync_flag channel_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable);
-static void mesh_siguser1_signal_handler(int sig_num);
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable);
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr_received, true);
return;
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer") && reachable) {
set_sync_flag(&peer_reachable, true);
}
}
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
send_event(ERR_NETWORK);
assert(false);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
- int i;
// Import mesh event handler
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
// Import mesh event handler
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
// Setup required signals
static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable);
-static void mesh_siguser1_signal_handler(int sig_num);
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable);
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr_received, true);
return;
}
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer") && reachable) {
set_sync_flag(&peer_reachable, true);
}
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
set_sync_flag(&channel_closed, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
- int i;
// Import mesh event handler
#define CHANNEL_PORT 1234
static int client_id = -1;
-static bool channel_rec;
-static bool channel_reply;
-static pthread_mutex_t reply_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t reply_cond = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t recv_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t recv_cond = PTHREAD_COND_INITIALIZER;
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- struct timespec timeout = {0};
// Import mesh event handler
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
// Setup required signals
static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable);
-static void mesh_siguser1_signal_handler(int sig_num);
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable);
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr_received, true);
return;
}
static void send_event(mesh_event_t event) {
- bool send_ret = false;
int attempts;
for(attempts = 0; attempts < 5; attempts += 1) {
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer")) {
if(reachable) {
}
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
send_event(ERR_NETWORK);
return;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- struct timespec timeout = {0};
- int i;
// Import mesh event handler
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
- struct timespec timeout = {0};
// Import mesh event handler
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
// Setup required signals
static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
-static struct sync_flag channel_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void send_event(mesh_event_t event);
static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "peer")) {
if(reachable) {
set_sync_flag(&peer_reachable, true);
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
if(len == 0) {
//send_event(ERR_NETWORK);
return;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- int i;
// Import mesh event handler
static int client_id = -1;
static void mesh_siguser1_signal_handler(int sig_num) {
+ (void)sig_num;
+
set_sync_flag(&sigusr, true);
return;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
// Import mesh event handler
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
// Setup required signals
static bool conn_status = false;
-static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level,
- const char *text) {
+static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)mesh;
+ (void)level;
+
char connection_match_msg[100];
fprintf(stderr, "meshlink>> %s\n", text);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
int client_id = -1;
- bool result = false;
- int i;
if((argv[3]) && (argv[4])) {
client_id = atoi(argv[3]);
#include "../common/mesh_event_handler.h"
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
#include "../common/mesh_event_handler.h"
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
--- /dev/null
+# node_step.sh -- Script to send signal to control Mesh Node Simulation
+# Copyright (C) 2018 Guus Sliepen <guus@meshlink.io>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Read command-line arguments
+prog_name=$1
+signal=$2
+
+# Find instance of running program and send the named signal to it
+pid=`/bin/pidof -s ${prog_name}`
+kill -${signal} ${pid}
+exit $?
static bool conn_status = false;
-static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level,
- const char *text) {
+static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)mesh;
+ (void)level;
+
char connection_match_msg[100];
fprintf(stderr, "meshlink>> %s\n", text);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
int client_id = -1;
- bool result = false;
- int i;
if((argv[3]) && (argv[4])) {
client_id = atoi(argv[3]);
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
static bool conn_status = false;
-void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level,
- const char *text) {
+void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)mesh;
+ (void)level;
+
char connection_match_msg[100];
fprintf(stderr, "meshlink>> %s\n", text);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
int client_id = -1;
bool result = false;
int i;
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
static bool conn_status = false;
-void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level,
- const char *text) {
+void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)mesh;
+ (void)level;
+
char connection_match_msg[100];
fprintf(stderr, "meshlink>> %s\n", text);
}
int main(int argc, char *argv[]) {
- struct timeval main_loop_wait = { 5, 0 };
- int i, clientId = -1;
- bool result;
+ (void)argc;
+
+ int clientId = -1;
char *invite_peer;
if((argv[3]) && (argv[4])) {
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int clientid = -1;
static bool conn_status = false;
-void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level,
- const char *text) {
+void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)mesh;
+ (void)level;
+
char connection_match_msg[100];
fprintf(stderr, "meshlink>> %s\n", text);
}
int main(int argc, char *argv[]) {
- struct timeval main_loop_wait = { 5, 0 };
- int i, clientId = -1;
- bool result;
+ (void)argc;
+
+ int clientId = -1;
char *invite_peer;
if((argv[3]) && (argv[4])) {
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int client_id = -1;
#define CMD_LINE_ARG_INVITEURL 5
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
int clientid = -1;
static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
bool reachable);
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len);
-static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len);
pmtu_attr_t node_pmtu[2];
static time_t node_shutdown_time = 0;
}
// Node status callback
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
// Signal pthread_cond_wait if peer is reachable
if(!strcasecmp(node->name, "peer") && reachable) {
set_sync_flag(&peer_reachable, true);
return;
}
-static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) {
- (void)dat;
- (void)len;
-
- assert(port == CHANNEL_PORT);
-
- // If the channel is from peer node set receive callback for it else reject the channel
- if(!strcmp(channel->node->name, "peer")) {
- meshlink_set_channel_receive_cb(mesh, channel, channel_receive_cb);
- mesh->priv = channel;
-
- return true;
- }
-
- return false;
-}
-
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
if(len == 0) {
cur_time = time(NULL);
assert(cur_time != -1);
- bool mtu_probe = false;
-
if(node_shutdown_time && cur_time >= node_shutdown_time) {
test_pmtu_nut_running = false;
}
print_mtu_calc(node_pmtu[NODE_PMTU_PEER]);
fprintf(stderr, "\nNODE_PMTU_RELAY :\n");
print_mtu_calc(node_pmtu[NODE_PMTU_RELAY]);
+
+ return NULL;
}
extern bool test_pmtu_peer_running;
-static struct sync_flag nut_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER};
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len);
return false;
}
-static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
- (void)len;
- meshlink_set_channel_poll_cb(mesh, channel, NULL);
- assert(meshlink_channel_send(mesh, channel, "test", 5) >= 0);
- return;
-}
-
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node1\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app2node1\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app2node2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
#define CMD_LINE_ARG_INVITEURL 5
#define CHANNEL_PORT 1234
-static bool conn_status = false;
static int client_id = -1;
-static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static meshlink_handle_t *mesh = NULL;
-static void mesh_send_message_handler(char *destination);
+static void mesh_send_message_handler(const char *destination);
static void send_event(mesh_event_t event) {
int attempts;
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(reachable) {
fprintf(stderr, "Node %s became reachable\n", node->name);
} else {
}
static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
- char *message = "Channel Message";
- char *node = channel->node->name;
+ const char *message = "Channel Message";
+ const char *node = channel->node->name;
(void)len;
meshlink_set_channel_poll_cb(mesh, channel, NULL);
fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL));
return true;
}
-void mesh_send_message_handler(char *destination) {
+static void mesh_send_message_handler(const char *destination) {
meshlink_channel_t *channel = NULL;
meshlink_node_t *target_node = NULL;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- int i;
// Import mesh event handler
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "Node corenode2 became reachable");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in corenode2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node1\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
size_t num_nodes, i;
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
num_nodes = 0;
node_handles = meshlink_get_all_nodes(mesh, NULL, &num_nodes);
- fprintf(stderr, "\tGot %d nodes in list with error : %s\n", num_nodes, meshlink_strerror(meshlink_errno));
+ fprintf(stderr, "\tGot %d nodes in list with error : %s\n", (int)num_nodes, meshlink_strerror(meshlink_errno));
assert(node_handles);
assert((num_nodes == 4));
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app2node1\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app2node2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
size_t num_nodes, i;
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
num_nodes = 0;
node_handles = meshlink_get_all_nodes(mesh, NULL, &num_nodes);
- fprintf(stderr, "\tGot %d nodes in list with error : %s\n", num_nodes, meshlink_strerror(meshlink_errno));
+ fprintf(stderr, "\tGot %d nodes in list with error : %s\n", (int)num_nodes, meshlink_strerror(meshlink_errno));
assert(node_handles);
assert((num_nodes == 4));
#define CMD_LINE_ARG_INVITEURL 5
#define CHANNEL_PORT 1234
-static bool conn_status = false;
static int client_id = -1;
-static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static meshlink_handle_t *mesh = NULL;
-static void mesh_send_message_handler(char *destination);
+static void mesh_send_message_handler(const char *destination);
static void send_event(mesh_event_t event) {
int attempts;
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(reachable) {
fprintf(stderr, "Node %s became reachable\n", node->name);
} else {
}
static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
- char *message = "Channel Message";
- char *node = channel->node->name;
+ const char *message = "Channel Message";
+ const char *node = channel->node->name;
(void)len;
meshlink_set_channel_poll_cb(mesh, channel, NULL);
fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL));
return true;
}
-void mesh_send_message_handler(char *destination) {
+static void mesh_send_message_handler(const char *destination) {
meshlink_channel_t *channel = NULL;
meshlink_node_t *target_node = NULL;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- int i;
// Import mesh event handler
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "Node corenode2 became reachable");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in corenode2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node1\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
size_t num_nodes, i;
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
#define CMD_LINE_ARG_INVITEURL 5
#define CHANNEL_PORT 1234
-static bool conn_status = false;
static int client_id = -1;
-static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static meshlink_handle_t *mesh = NULL;
-static void mesh_send_message_handler(char *destination);
+static void mesh_send_message_handler(const char *destination);
static void send_event(mesh_event_t event) {
int attempts;
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
fprintf(stderr, "corenode1 got message from %s as %s\n", channel->node->name, data);
if(!memcmp(dat, "Channel Message", len)) {
- mesh_send_message_handler((char *)channel->node->name);
+ mesh_send_message_handler(channel->node->name);
if(0 == strcmp("app1node1", channel->node->name)) {
set_sync_flag(&channel_data_recieved, true);
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(reachable) {
fprintf(stderr, "Node %s became reachable\n", node->name);
} else {
}
static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
- char *message = "Channel Message";
- char *node = (char *)channel->node->name;
+ const char *message = "Channel Message";
+ const char *node = channel->node->name;
(void)len;
meshlink_set_channel_poll_cb(mesh, channel, NULL);
fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL));
return true;
}
-void mesh_send_message_handler(char *destination) {
+static void mesh_send_message_handler(const char *destination) {
meshlink_channel_t *channel = NULL;
meshlink_node_t *target_node = NULL;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- int i;
// Import mesh event handler
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node1\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_close(mesh);
return EXIT_SUCCESS;
-}
\ No newline at end of file
+}
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcasecmp(node->name, "corenode1")) {
if(reachable) {
fprintf(stderr, "\tNode corenode1 became reachable\n");
return;
}
-void mesh_start_test_handler(int a) {
+void mesh_start_test_handler(int signum) {
+ (void)signum;
+
fprintf(stderr, "Starting test in app1node2\n");
set_sync_flag(&start_test, true);
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
size_t num_nodes, i;
struct timeval main_loop_wait = { 2, 0 };
meshlink_channel_t *channel = NULL;
meshlink_node_t *core_node = NULL;
meshlink_node_t **node_handles = NULL;
- ssize_t retvalue = -1;
fprintf(stderr, "\tMesh node 'app1node2' starting up........\n");
#define CMD_LINE_ARG_INVITEURL 5
#define CHANNEL_PORT 1234
-static bool conn_status = false;
static int client_id = -1;
-static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false};
static meshlink_handle_t *mesh = NULL;
-static void mesh_send_message_handler(char *destination);
+static void mesh_send_message_handler(const char *destination);
static void send_event(mesh_event_t event) {
int attempts;
/* channel receive callback */
static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) {
+ (void)mesh;
+
char data[100] = {0};
if(len == 0) {
fprintf(stderr, "corenode1 got message from %s as %s\n", channel->node->name, data);
if(!memcmp(dat, "Channel Message", len)) {
- mesh_send_message_handler((char *)channel->node->name);
+ mesh_send_message_handler(channel->node->name);
if(0 == strcmp("app1node2", channel->node->name)) {
set_sync_flag(&channel_data_recieved, true);
return;
}
-static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node,
- bool reachable) {
+static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(reachable) {
fprintf(stderr, "Node %s became reachable\n", node->name);
} else {
}
static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
- char *message = "Channel Message";
- char *node = (char *)channel->node->name;
+ const char *message = "Channel Message";
+ const char *node = channel->node->name;
(void)len;
meshlink_set_channel_poll_cb(mesh, channel, NULL);
fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL));
return true;
}
-void mesh_send_message_handler(char *destination) {
+static void mesh_send_message_handler(const char *destination) {
meshlink_channel_t *channel = NULL;
meshlink_node_t *target_node = NULL;
}
int main(int argc, char *argv[]) {
+ (void)argc;
+
struct timeval main_loop_wait = { 5, 0 };
- int i;
// Import mesh event handler
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/time.h>
#include "meshlink.h"
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/time.h>
#include "meshlink.h"