- if(!sendline(fd, "%d %d", CONTROL, REQ_DUMP_TRAFFIC))
+ if(!sendline(fd, "%d %d", CONTROL, REQ_DUMP_TRAFFIC)) {
gettimeofday(&cur, NULL);
timersub(&cur, &prev, &diff);
prev = cur;
gettimeofday(&cur, NULL);
timersub(&cur, &prev, &diff);
prev = cur;
int n = sscanf(line, "%d %d %4095s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, &code, &req, name, &in_packets, &in_bytes, &out_packets, &out_bytes);
int n = sscanf(line, "%d %d %4095s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, &code, &req, name, &in_packets, &in_bytes, &out_packets, &out_bytes);
nodestats_t *found = NULL;
for list_each(nodestats_t, ns, &node_list) {
int result = strcmp(name, ns->name);
nodestats_t *found = NULL;
for list_each(nodestats_t, ns, &node_list) {
int result = strcmp(name, ns->name);
found->name = xstrdup(name);
list_insert_before(&node_list, node, found);
changed = true;
found->name = xstrdup(name);
list_insert_before(&node_list, node, found);
changed = true;
found->name = xstrdup(name);
list_insert_tail(&node_list, found);
changed = true;
}
found->known = true;
found->name = xstrdup(name);
list_insert_tail(&node_list, found);
changed = true;
}
found->known = true;
- found->in_packets_rate = (in_packets - found->in_packets) / interval;
- found->in_bytes_rate = (in_bytes - found->in_bytes) / interval;
- found->out_packets_rate = (out_packets - found->out_packets) / interval;
- found->out_bytes_rate = (out_bytes - found->out_bytes) / interval;
+ found->in_packets_rate = (float)(in_packets - found->in_packets) / interval;
+ found->in_bytes_rate = (float)(in_bytes - found->in_bytes) / interval;
+ found->out_packets_rate = (float)(out_packets - found->out_packets) / interval;
+ found->out_bytes_rate = (float)(out_bytes - found->out_bytes) / interval;
found->in_packets = in_packets;
found->in_bytes = in_bytes;
found->out_packets = out_packets;
found->in_packets = in_packets;
found->in_bytes = in_bytes;
found->out_packets = out_packets;
- case 1:
- if(cumulative)
- result = -cmpu64(na->in_packets, nb->in_packets);
- else
- result = -cmpfloat(na->in_packets_rate, nb->in_packets_rate);
- break;
- case 2:
- if(cumulative)
- result = -cmpu64(na->in_bytes, nb->in_bytes);
- else
- result = -cmpfloat(na->in_bytes_rate, nb->in_bytes_rate);
- break;
- case 3:
- if(cumulative)
- result = -cmpu64(na->out_packets, nb->out_packets);
- else
- result = -cmpfloat(na->out_packets_rate, nb->out_packets_rate);
- break;
- case 4:
- if(cumulative)
- result = -cmpu64(na->out_bytes, nb->out_bytes);
- else
- result = -cmpfloat(na->out_bytes_rate, nb->out_bytes_rate);
- break;
- case 5:
- if(cumulative)
- result = -cmpu64(na->in_packets + na->out_packets, nb->in_packets + nb->out_packets);
- else
- result = -cmpfloat(na->in_packets_rate + na->out_packets_rate, nb->in_packets_rate + nb->out_packets_rate);
- break;
- case 6:
- if(cumulative)
- result = -cmpu64(na->in_bytes + na->out_bytes, nb->in_bytes + nb->out_bytes);
- else
- result = -cmpfloat(na->in_bytes_rate + na->out_bytes_rate, nb->in_bytes_rate + nb->out_bytes_rate);
- break;
- default:
- result = strcmp(na->name, nb->name);
- break;
+ case 1:
+ if(cumulative) {
+ result = -cmpu64(na->in_packets, nb->in_packets);
+ } else {
+ result = -cmpfloat(na->in_packets_rate, nb->in_packets_rate);
+ }
+
+ break;
+
+ case 2:
+ if(cumulative) {
+ result = -cmpu64(na->in_bytes, nb->in_bytes);
+ } else {
+ result = -cmpfloat(na->in_bytes_rate, nb->in_bytes_rate);
+ }
+
+ break;
+
+ case 3:
+ if(cumulative) {
+ result = -cmpu64(na->out_packets, nb->out_packets);
+ } else {
+ result = -cmpfloat(na->out_packets_rate, nb->out_packets_rate);
+ }
+
+ break;
+
+ case 4:
+ if(cumulative) {
+ result = -cmpu64(na->out_bytes, nb->out_bytes);
+ } else {
+ result = -cmpfloat(na->out_bytes_rate, nb->out_bytes_rate);
+ }
+
+ break;
+
+ case 5:
+ if(cumulative) {
+ result = -cmpu64(na->in_packets + na->out_packets, nb->in_packets + nb->out_packets);
+ } else {
+ result = -cmpfloat(na->in_packets_rate + na->out_packets_rate, nb->in_packets_rate + nb->out_packets_rate);
+ }
+
+ break;
+
+ case 6:
+ if(cumulative) {
+ result = -cmpu64(na->in_bytes + na->out_bytes, nb->in_bytes + nb->out_bytes);
+ } else {
+ result = -cmpfloat(na->in_bytes_rate + na->out_bytes_rate, nb->in_bytes_rate + nb->out_bytes_rate);
+ }
+
+ break;
+
+ default:
+ result = strcmp(na->name, nb->name);
+ break;
- mvprintw(0, 0, "Tinc %-16s Nodes: %4d Sort: %-10s %s", netname ?: "", node_list.count, sortname[sortmode], cumulative ? "Cumulative" : "Current");
+ mvprintw(0, 0, "Tinc %-16s Nodes: %4d Sort: %-10s %s", netname ? netname : "", node_list.count, sortname[sortmode], cumulative ? "Cumulative" : "Current");
attrset(A_REVERSE);
mvprintw(2, 0, "Node IN %s IN %s OUT %s OUT %s", punit, bunit, punit, bunit);
chgat(-1, A_REVERSE, 0, NULL);
static nodestats_t **sorted = 0;
static int n = 0;
attrset(A_REVERSE);
mvprintw(2, 0, "Node IN %s IN %s OUT %s OUT %s", punit, bunit, punit, bunit);
chgat(-1, A_REVERSE, 0, NULL);
static nodestats_t **sorted = 0;
static int n = 0;
- sorted = xrealloc(sorted, node_list.count * sizeof *sorted);
- for list_each(nodestats_t, ns, &node_list)
+ sorted = xrealloc(sorted, node_list.count * sizeof(*sorted));
+
+ for list_each(nodestats_t, ns, &node_list) {
for(int i = 0, row = 3; i < n; i++, row++) {
nodestats_t *node = sorted[i];
for(int i = 0, row = 3; i < n; i++, row++) {
nodestats_t *node = sorted[i];
if(cumulative)
mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f",
if(cumulative)
mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f",
- node->name, node->in_packets * pscale, node->in_bytes * bscale, node->out_packets * pscale, node->out_bytes * bscale);
+ node->name, (float) node->in_packets * pscale, (float) node->in_bytes * bscale,
+ (float) node->out_packets * pscale, (float) node->out_bytes * bscale);
else
mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f",
else
mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f",
- node->name, node->in_packets_rate * pscale, node->in_bytes_rate * bscale, node->out_packets_rate * pscale, node->out_bytes_rate * bscale);
+ node->name, node->in_packets_rate * pscale, node->in_bytes_rate * bscale, node->out_packets_rate * pscale, node->out_bytes_rate * bscale);
- case 's': {
- timeout(-1);
- float input = delay * 1e-3;
- mvprintw(1, 0, "Change delay from %.1fs to: ", input);
- scanw("%f", &input);
- if(input < 0.1)
- input = 0.1;
- delay = input * 1e3;
- timeout(delay);
- break;
+ case 's': {
+ timeout(-1);
+ float input = (float)delay * 1e-3f;
+ mvprintw(1, 0, "Change delay from %.1fs to: ", input);
+ scanw("%f", &input);
+
+ if(input < 0.1) {
+ input = 0.1f;