/*
top.c -- Show real-time statistics from a running tincd
- Copyright (C) 2011 Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2011-2012 Guus Sliepen <guus@tinc-vpn.org>
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
static bool cumulative = false;
static list_t node_list;
-static struct timeval now, prev, diff;
+static struct timeval cur, prev, diff;
static int delay = 1000;
static bool changed = true;
static const char *unit = "bytes";
static void update(int fd) {
sendline(fd, "%d %d", CONTROL, REQ_DUMP_TRAFFIC);
- gettimeofday(&now, NULL);
+ gettimeofday(&cur, NULL);
- timersub(&now, &prev, &diff);
- prev = now;
+ timersub(&cur, &prev, &diff);
+ prev = cur;
float interval = diff.tv_sec + diff.tv_usec * 1e-6;
char line[4096];
for(int i = 0; i < n; i++)
sorted[i]->i = i;
-
+
int cmpfloat(float a, float b) {
if(a < b)
return -1;