Commit 8186abb6 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Print RTT values in milliseconds rather than microseconds

parent 72ded7c1
......@@ -1053,13 +1053,13 @@ dump_tables(FILE *out)
FOR_ALL_NEIGHBOURS(neigh) {
fprintf(out, "Neighbour %s dev %s reach %04x rxcost %d txcost %d "
"rtt %d rttcost %d chan %d%s.\n",
"rtt %s rttcost %d chan %d%s.\n",
format_address(neigh->address),
neigh->ifp->name,
neigh->reach,
neighbour_rxcost(neigh),
neigh->txcost,
neigh->rtt,
format_thousands(neigh->rtt),
neighbour_rttcost(neigh),
neigh->ifp->channel,
if_up(neigh->ifp) ? "" : " (down)");
......
......@@ -138,8 +138,8 @@ local_notify_neighbour_1(int s, struct neighbour *neigh, int kind)
rttbuf[0] = '\0';
if(valid_rtt(neigh)) {
rc = snprintf(rttbuf, 64, " rtt %d rttcost %d", neigh->rtt,
neighbour_rttcost(neigh));
rc = snprintf(rttbuf, 64, " rtt %s rttcost %d",
format_thousands(neigh->rtt), neighbour_rttcost(neigh));
if(rc < 0 || rc >= 64)
rttbuf[0] = '\0';
}
......
......@@ -295,6 +295,16 @@ format_eui64(const unsigned char *eui)
return buf[i];
}
const char *
format_thousands(unsigned int value)
{
static char buf[4][30];
static int i = 0;
i = (i + 1) % 4;
snprintf(buf[i], 30, "%d.%.3d", value / 1000, value % 1000);
return buf[i];
}
int
parse_address(const char *address, unsigned char *addr_r, int *af_r)
{
......
......@@ -98,6 +98,7 @@ unsigned char *mask_prefix(unsigned char *restrict ret,
const char *format_address(const unsigned char *address);
const char *format_prefix(const unsigned char *address, unsigned char prefix);
const char *format_eui64(const unsigned char *eui);
const char *format_thousands(unsigned int value);
int parse_address(const char *address, unsigned char *addr_r, int *af_r);
int parse_net(const char *net, unsigned char *prefix_r, unsigned char *plen_r,
int *af_r);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment