Skip to content

Commit

Permalink
wireless: correctly display bitrates > 2147483647 bit/s (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
n-st authored Oct 11, 2022
1 parent 30ea2d2 commit d7bb4c9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/print_wireless_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ typedef struct {
int signal_level_max;
int noise_level;
int noise_level_max;
int bitrate;
long int bitrate;
double frequency;
} wireless_info_t;

#if defined(__linux__) || defined(__FreeBSD__)
// Like iw_print_bitrate, but without the dependency on libiw.
static void print_bitrate(char *buffer, int buflen, int bitrate, const char *format_bitrate) {
static void print_bitrate(char *buffer, int buflen, long int bitrate, const char *format_bitrate) {
const int kilo = 1e3;
const int mega = 1e6;
const int giga = 1e9;
Expand Down Expand Up @@ -191,7 +191,7 @@ static int gwi_sta_cb(struct nl_msg *msg, void *data) {

// NL80211_RATE_INFO_BITRATE is specified in units of 100 kbit/s, but iw
// used to specify bit/s, so we convert to use the same code path.
info->bitrate = (int)nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]) * 100 * 1000;
info->bitrate = (long int)nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]) * 100 * 1000;

if (sinfo[NL80211_STA_INFO_SIGNAL] != NULL) {
info->flags |= WIRELESS_INFO_FLAG_HAS_SIGNAL;
Expand Down Expand Up @@ -412,7 +412,7 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) {
info->flags |= WIRELESS_INFO_FLAG_HAS_NOISE;
// isi_txmbps is specified in units of 500 Kbit/s
// Convert them to bit/s
info->bitrate = u.req.info[0].isi_txmbps * 500 * 1000;
info->bitrate = (long int)u.req.info[0].isi_txmbps * 500 * 1000;
}

return 1;
Expand Down

0 comments on commit d7bb4c9

Please sign in to comment.