expose traffic stats to 'tinc info ___' and 'tinc dump nodes'
[tinc] / src / info.c
index 652c4ae..9ac7bbc 100644 (file)
@@ -71,15 +71,16 @@ static int info_node(int fd, const char *item) {
        node_status_t status;
        long int last_state_change;
        long int udp_ping_rtt;
+       uint64_t in_packets, in_bytes, out_packets, out_bytes;
 
        while(recvline(fd, line, sizeof(line))) {
-               int n = sscanf(line, "%d %d %4095s %4095s %4095s port %4095s %d %d %d %d %x %"PRIx32" %4095s %4095s %d %hd %hd %hd %ld %ld", &code, &req, node, id, host, port, &cipher, &digest, &maclength, &compression, &options, &status_union.raw, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change, &udp_ping_rtt);
+               int n = sscanf(line, "%d %d %4095s %4095s %4095s port %4095s %d %d %d %d %x %"PRIx32" %4095s %4095s %d %hd %hd %hd %ld %ld %lu %lu %lu %lu", &code, &req, node, id, host, port, &cipher, &digest, &maclength, &compression, &options, &status_union.raw, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change, &udp_ping_rtt, &in_packets, &in_bytes, &out_packets, &out_bytes);
 
                if(n == 2) {
                        break;
                }
 
-               if(n != 20) {
+               if(n != 24) {
                        fprintf(stderr, "Unable to parse node dump from tincd.\n");
                        return 1;
                }
@@ -188,6 +189,9 @@ static int info_node(int fd, const char *item) {
                printf("none, forwarded via %s\n", nexthop);
        }
 
+       printf("RX:          %lu packets  %lu bytes\n", in_packets, in_bytes);
+       printf("TX:          %lu packets  %lu bytes\n", out_packets, out_bytes);
+
        // List edges
        printf("Edges:       ");
        sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_EDGES, item);