- snprintf(name, sizeof(name), "graph_%ld_%ld.json", ts.tv_sec, ts.tv_usec/1000);
+ snprintf(name, sizeof(name), "graph_%ld_%03ld.json", ts.tv_sec, ts.tv_usec/1000);
/* Install timer_handler as the signal handler for SIGALRM. */
signal(SIGALRM, exportmeshgraph_timer);
/* Install timer_handler as the signal handler for SIGALRM. */
signal(SIGALRM, exportmeshgraph_timer);
if(!invitation) {
fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
return;
if(!invitation) {
fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno));
return;
- meshlink_stop(mesh[0]);
- if(!meshlink_join(mesh[0], arg))
+ meshlink_stop(mesh[nodeindex]);
+ if(!meshlink_join(mesh[nodeindex], arg))
fprintf(stderr, "Could not join using invitation: %s\n", meshlink_strerror(meshlink_errno));
else {
fprintf(stderr, "Invitation accepted!\n");
fprintf(stderr, "Could not join using invitation: %s\n", meshlink_strerror(meshlink_errno));
else {
fprintf(stderr, "Invitation accepted!\n");
printf("Node '%s' blacklisted.\n", arg);
} else if(!strcasecmp(buf, "who")) {
if(!arg) {
printf("Node '%s' blacklisted.\n", arg);
} else if(!strcasecmp(buf, "who")) {
if(!arg) {
- printf("Node %s found, pmtu %zd\n", arg, meshlink_get_pmtu(mesh[0], node));
+ printf("Node %s found, pmtu %zd\n", arg, meshlink_get_pmtu(mesh[nodeindex], node));
exportmeshgraph_end(NULL);
} else if(!strcasecmp(buf, "test")) {
testmesh();
exportmeshgraph_end(NULL);
} else if(!strcasecmp(buf, "test")) {
testmesh();
+ } else if(!strcasecmp(buf, "select")) {
+ if(!arg) {
+ fprintf(stderr, "/select requires an argument!\n");
+ return;
+ }
+ nodeindex = atoi(arg);
+ printf("Index is now %d\n",nodeindex);
+
"/link Link all nodes together.\n"
"/eg <path> Export graph as json file.\n"
"/test Test functionality sending some data to all nodes\n"
"/link Link all nodes together.\n"
"/eg <path> Export graph as json file.\n"
"/test Test functionality sending some data to all nodes\n"
- if(!meshlink_send(mesh[0], destination, msg, strlen(msg) + 1)) {
+ if(!meshlink_send(mesh[nodeindex], destination, msg, strlen(msg) + 1)) {
fprintf(stderr, "Could not send message to '%s': %s\n", destination->name, meshlink_strerror(meshlink_errno));
return;
}
fprintf(stderr, "Could not send message to '%s': %s\n", destination->name, meshlink_strerror(meshlink_errno));
return;
}
int main(int argc, char *argv[]) {
const char *basebase = ".manynodes";
const char *namesprefix = "machine1";
int main(int argc, char *argv[]) {
const char *basebase = ".manynodes";
const char *namesprefix = "machine1";
- fprintf(stderr, "Usage: %s [number of local nodes] [confbase] [prefixnodenames]\n", argv[0]);
+ fprintf(stderr, "Usage: %s [number of local nodes] [confbase] [prefixnodenames] [graphexport timeout]\n", argv[0]);
mesh = calloc(n, sizeof *mesh);
meshlink_set_log_cb(NULL, MESHLINK_WARNING, log_message);
mesh = calloc(n, sizeof *mesh);
meshlink_set_log_cb(NULL, MESHLINK_WARNING, log_message);
bool itsnew = access(filename, R_OK);
mesh[i] = meshlink_open(filename, nodename, "manynodes", i%_DEV_CLASS_MAX);
meshlink_set_log_cb(mesh[i], MESHLINK_WARNING, log_message);
bool itsnew = access(filename, R_OK);
mesh[i] = meshlink_open(filename, nodename, "manynodes", i%_DEV_CLASS_MAX);
meshlink_set_log_cb(mesh[i], MESHLINK_WARNING, log_message);
if(!mesh[i]) {
fprintf(stderr, "errno is: %d\n", meshlink_errno);
fprintf(stderr, "Could not open %s: %s\n", filename, meshlink_strerror(meshlink_errno));
if(!mesh[i]) {
fprintf(stderr, "errno is: %d\n", meshlink_errno);
fprintf(stderr, "Could not open %s: %s\n", filename, meshlink_strerror(meshlink_errno));
printf("%d nodes started.\nType /help for a list of commands.\n", started);
// handle input
while(fgets(buf, sizeof buf, stdin))
parse_input(buf);
printf("%d nodes started.\nType /help for a list of commands.\n", started);
// handle input
while(fgets(buf, sizeof buf, stdin))
parse_input(buf);