diff options
Diffstat (limited to 'src/fastd.h')
-rw-r--r-- | src/fastd.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h index 6eaf831..464a7fd 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -147,8 +147,10 @@ struct fastd_socket { /** Some kind of network transfer stratistics */ struct fastd_stats { +#ifdef WITH_STATUS_SOCKET uint64_t packets; /**< The number of packets transferred */ uint64_t bytes; /**< The number of bytes transferred */ +#endif }; /** A data structure keeping track of an unknown addresses that a handshakes was received from recently */ @@ -379,6 +381,16 @@ static inline size_t fastd_max_payload(void) { } } +/** Adds statistics for a single packet of a given size */ +static inline void fastd_stats_add(fastd_stats_t *stats UNUSED, size_t stat_size UNUSED) { +#ifdef WITH_STATUS_SOCKET + if (stat_size) { + stats->packets++; + stats->bytes += stat_size; + } +#endif +} + /** Checks if a fastd_peer_address_t is an IPv6 link-local address */ static inline bool fastd_peer_address_is_v6_ll(const fastd_peer_address_t *addr) { return (addr->sa.sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr)); |