From af5fd7b77ea00d6c1390e70310d51828016ab2b0 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 22 Sep 2010 19:59:48 +0200 Subject: Implement displaying the wireless connection speed (Thanks Felicitus) Based on a patch by Felicitus. --- src/print_wireless_info.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/print_wireless_info.c') diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index 60eb906..3a96b86 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -25,6 +25,7 @@ typedef struct { int signal_level_max; int noise_level; int noise_level_max; + int bitrate; } wireless_info_t; static int get_wireless_info(const char *interface, wireless_info_t *info) { @@ -132,6 +133,10 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) { } } + struct iwreq wrq; + if (iw_get_ext(skfd, interface, SIOCGIWRATE, &wrq) >= 0) + info->bitrate = wrq.u.bitrate.value; + close(skfd); return 1; #endif @@ -210,6 +215,15 @@ void print_wireless_info(const char *interface, const char *format_up, const cha else (void)printf("no IP"); walk += strlen("ip"); } + + if (BEGINS_WITH(walk+1, "bitrate")) { + char buffer[128]; + + iw_print_bitrate(buffer, sizeof(buffer), info.bitrate); + + printf("%s", buffer); + walk += strlen("bitrate"); + } } (void)printf("%s", endcolor()); -- cgit v1.2.3