diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-12 16:53:24 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-12 16:53:24 +0200 |
commit | 7ebbe05f46e1b8530a61dd144a4bf36a1c63a4a3 (patch) | |
tree | b06313240468ccee6923366d66eebf583e029162 /src/peer.h | |
parent | d116950984d78392e1daf0adfd89f6cdb4fe8076 (diff) | |
download | fastd-7ebbe05f46e1b8530a61dd144a4bf36a1c63a4a3.tar fastd-7ebbe05f46e1b8530a61dd144a4bf36a1c63a4a3.zip |
Add per-peer stats
Diffstat (limited to 'src/peer.h')
-rw-r--r-- | src/peer.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -72,6 +72,8 @@ struct fastd_peer { fastd_timeout_t timeout; /**< The timeout after which the peer is reset */ fastd_timeout_t keepalive_timeout; /**< The timeout after which a keepalive is sent to the peer */ + fastd_stats_t stats; /**< Traffic statistics */ + const fastd_peer_group_t *group; /**< The peer group the peer belongs to */ VECTOR(fastd_remote_t) remotes; /**< The vector of the peer's remotes */ @@ -270,3 +272,17 @@ fastd_peer_t * fastd_peer_find_by_eth_addr(fastd_eth_addr_t addr); void fastd_peer_handle_handshake_queue(void); void fastd_peer_maintenance(void); + +/** Adds statistics for a single packet of a given size */ +static inline void fastd_stats_add(UNUSED fastd_peer_t *peer, UNUSED fastd_stat_type_t stat, UNUSED size_t bytes) { +#ifdef WITH_STATUS_SOCKET + if (!bytes) + return; + + ctx.stats.packets[stat]++; + ctx.stats.bytes[stat] += bytes; + + peer->stats.packets[stat]++; + peer->stats.bytes[stat] += bytes; +#endif +} |