When available, use 64-bit byte counters rx/tx_bytes64. New 32-bit counters rx/tx_bytes32 are guaranteed to clamp to max 32-bit value and never wrap around. For compatibility with legacy clients the old values rx/tx_bytes are just aliases of new rx/tx_bytes32.
Signed-off-by: Dainis Jonitis <dainis.joni...@ubnt.com> --- include/iwinfo.h | 12 ++++++++++-- iwinfo_nl80211.c | 24 ++++++++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/include/iwinfo.h b/include/iwinfo.h index 5e64294..8610fcb 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -119,8 +119,16 @@ struct iwinfo_assoclist_entry { uint64_t rx_drop_misc; struct iwinfo_rate_entry rx_rate; struct iwinfo_rate_entry tx_rate; - uint32_t rx_bytes; - uint32_t tx_bytes; + uint64_t rx_bytes64; + uint64_t tx_bytes64; + union { + uint32_t rx_bytes32; /* clamped to max uint32_t */ + uint32_t rx_bytes; /* OBSOLETED: alias for legacy clients*/ + }; + union { + uint32_t tx_bytes32; /* clamped to max uint32_t */ + uint32_t tx_bytes; /* OBSOLETED: alias for legacy clients*/ + }; uint32_t tx_retries; uint32_t tx_failed; uint64_t t_offset; diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 2b2a043..6b35888 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -1953,6 +1953,8 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) [NL80211_STA_INFO_SIGNAL_AVG] = { .type = NLA_U8 }, [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 }, [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 }, + [NL80211_STA_INFO_RX_BYTES64] = { .type = NLA_U64 }, + [NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 }, [NL80211_STA_INFO_TX_RETRIES] = { .type = NLA_U32 }, [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 }, [NL80211_STA_INFO_CONNECTED_TIME]= { .type = NLA_U32 }, @@ -2016,11 +2018,25 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) nl80211_parse_rateinfo(rinfo, &e->tx_rate); - if (sinfo[NL80211_STA_INFO_RX_BYTES]) - e->rx_bytes = nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]); + if (sinfo[NL80211_STA_INFO_RX_BYTES64]) { + uint64_t u64 = nla_get_u64(sinfo[NL80211_STA_INFO_RX_BYTES64]); + e->rx_bytes64 = u64; + e->rx_bytes32 = (u64 <= UINT32_MAX) ? (uint32_t)u64 : UINT32_MAX; + } else if (sinfo[NL80211_STA_INFO_RX_BYTES]) { + uint32_t u32 = nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]); + e->rx_bytes32 = u32; + e->rx_bytes64 = u32; + } - if (sinfo[NL80211_STA_INFO_TX_BYTES]) - e->tx_bytes = nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]); + if (sinfo[NL80211_STA_INFO_TX_BYTES64]) { + uint64_t u64 = nla_get_u64(sinfo[NL80211_STA_INFO_TX_BYTES64]); + e->tx_bytes64 = u64; + e->tx_bytes32 = (u64 <= UINT32_MAX) ? (uint32_t)u64 : UINT32_MAX; + } else if (sinfo[NL80211_STA_INFO_TX_BYTES]) { + uint32_t u32 = nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]); + e->tx_bytes32 = u32; + e->tx_bytes64 = u32; + } if (sinfo[NL80211_STA_INFO_TX_RETRIES]) e->tx_retries = nla_get_u32(sinfo[NL80211_STA_INFO_TX_RETRIES]); -- 2.19.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel