diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-09-03 21:53:45 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-09-03 21:53:45 +0200 |
commit | 02c1cb4ce21dca6cc63545cd5bd7ed621ed61529 (patch) | |
tree | 7c953fbb9c062936b66f63a8d95b5702da7ece8e /src/fastd.c | |
parent | f0fa4e0c9085e0b4476b144185040ce9fbdc11e3 (diff) | |
download | fastd-02c1cb4ce21dca6cc63545cd5bd7ed621ed61529.tar fastd-02c1cb4ce21dca6cc63545cd5bd7ed621ed61529.zip |
Add packet/byte statistics
Diffstat (limited to 'src/fastd.c')
-rw-r--r-- | src/fastd.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/fastd.c b/src/fastd.c index 6ce10fc..e5c1364 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -246,6 +246,9 @@ void fastd_handle_receive(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer fastd_peer_eth_addr_add(ctx, peer, src_addr); } + ctx->rx.packets++; + ctx->rx.bytes += buffer.len; + fastd_tuntap_write(ctx, buffer); if (ctx->conf->mode == MODE_TAP && ctx->conf->forward) { @@ -360,8 +363,12 @@ static void delete_peers(fastd_context_t *ctx) { } } -static void dump_peers(fastd_context_t *ctx) { - pr_info(ctx, "dumping peers..."); +static void dump_state(fastd_context_t *ctx) { + pr_info(ctx, "TX stats: %U packet(s), %U byte(s); dropped: %U packet(s), %U byte(s); error: %U packet(s), %U byte(s)", + ctx->tx.packets, ctx->tx.bytes, ctx->tx_dropped.packets, ctx->tx_dropped.bytes, ctx->tx_error.packets, ctx->tx_error.bytes); + pr_info(ctx, "RX stats: %U packet(s), %U byte(s)", ctx->rx.packets, ctx->rx.bytes); + + pr_info(ctx, "dumping peers:"); fastd_peer_t *peer; for (peer = ctx->peers; peer; peer = peer->next) { @@ -385,7 +392,7 @@ static void dump_peers(fastd_context_t *ctx) { } } - pr_info(ctx, "peer dump finished."); + pr_info(ctx, "dump finished."); } static inline void update_time(fastd_context_t *ctx) { @@ -849,7 +856,7 @@ int main(int argc, char *argv[]) { if (dump) { dump = false; - dump_peers(&ctx); + dump_state(&ctx); } pthread_sigmask(SIG_SETMASK, &oldset, NULL); |