} else {
printf("%zu known nodes:\n", nnodes);
- for(int i = 0; i < nnodes; i++) {
+ for(size_t i = 0; i < nnodes; i++) {
//printf(" %s\n", nodes[i]->name);
if(!meshlink_send(mesh[nindex], nodes[i], "magic", strlen("magic") + 1)) {
fprintf(stderr, "Could not send message to '%s': %s\n", nodes[i]->name, meshlink_strerror(meshlink_errno));
void exportmeshgraph_timer(int signum) {
+ (void)signum;
+
struct timeval ts;
gettimeofday(&ts, NULL);
#ifndef _WIN32
static bool exportmeshgraph_started = false;
-static bool exportmeshgraph_end(const char *none) {
+static bool exportmeshgraph_end(void) {
if(!exportmeshgraph_started) {
return false;
}
- struct itimerval zero_timer = { 0 };
+ struct itimerval zero_timer;
setitimer(ITIMER_REAL, &zero_timer, NULL);
}
if(exportmeshgraph_started) {
- if(!exportmeshgraph_end(NULL)) {
+ if(!exportmeshgraph_end()) {
return false;
}
}
return true;
}
#else
-static bool exportmeshgraph_end(const char *none) {
+static bool exportmeshgraph_end(void) {
return false;
}
return;
}
- invitation = meshlink_invite(mesh[nodeindex], arg);
+ invitation = meshlink_invite(mesh[nodeindex], NULL, arg);
if(!invitation) {
fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
meshlink_blacklist(mesh[nodeindex], node);
printf("Node '%s' blacklisted.\n", arg);
+ } else if(!strcasecmp(buf, "whitelist")) {
+ if(!arg) {
+ fprintf(stderr, "/whitelist requires an argument!\n");
+ return;
+ }
+
+ meshlink_node_t *node = meshlink_get_node(mesh[nodeindex], arg);
+
+ if(!node) {
+ fprintf(stderr, "Error looking up '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
+ return;
+ }
+
+ meshlink_whitelist(mesh[nodeindex], node);
+
+ printf("Node '%s' whitelisted.\n", arg);
} else if(!strcasecmp(buf, "who")) {
if(!arg) {
nodes = meshlink_get_all_nodes(mesh[nodeindex], nodes, &nnodes);
} else {
printf("%zu known nodes:", nnodes);
- for(int i = 0; i < nnodes; i++) {
+ for(size_t i = 0; i < nnodes; i++) {
printf(" %s", nodes[i]->name);
}
if(!node) {
fprintf(stderr, "Unknown node '%s'\n", arg);
} else {
- printf("Node %s found, pmtu %zd\n", arg, meshlink_get_pmtu(mesh[nodeindex], node));
+ printf("Node %s found, pmtu %ld\n", arg, (long int)meshlink_get_pmtu(mesh[nodeindex], node));
}
}
} else if(!strcasecmp(buf, "link")) {
} else if(!strcasecmp(buf, "egb")) {
exportmeshgraph_begin(arg);
} else if(!strcasecmp(buf, "ege")) {
- exportmeshgraph_end(NULL);
+ exportmeshgraph_end();
} else if(!strcasecmp(buf, "test")) {
testmesh();
} else if(!strcasecmp(buf, "select")) {
// Commands start with '/'
if(*buf == '/') {
- return parse_command(buf + 1);
+ parse_command(buf + 1);
+ return;
}
// Lines in the form "name: message..." set the destination node.
parse_input(buf);
}
- exportmeshgraph_end(NULL);
+ exportmeshgraph_end();
printf("Nodes stopping.\n");