diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-01-04 12:30:40 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-01-04 12:30:40 +0000 |
commit | 11e22c6125c49fc01f5752389ca129e42973f458 (patch) | |
tree | e9d81069272cfd1ff428b43c163bf47f49fa2052 /sbin/ifconfig/ifconfig.c | |
parent | 6d6fb9bf9b307a8cc345f261ac93019ed5ef3ce0 (diff) |
Sort wireless nodes by signal strength, from Simon Nicolussi.
ok stsp@, deraadt@
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 92aab12aed1..95819b4b293 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.291 2015/01/03 06:09:36 jsg Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.292 2015/01/04 12:30:39 mpi Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -2221,6 +2221,17 @@ ieee80211_listchans(void) } } +/* + * Returns an integer less than, equal to, or greater than zero if nr1's + * RSSI is respectively greater than, equal to, or less than nr2's RSSI. + */ +static int +rssicmp(const void *nr1, const void *nr2) +{ + const struct ieee80211_nodereq *x = nr1, *y = nr2; + return y->nr_rssi < x->nr_rssi ? -1 : y->nr_rssi > x->nr_rssi; +} + void ieee80211_listnodes(void) { @@ -2256,6 +2267,8 @@ ieee80211_listnodes(void) if (!na.na_nodes) printf("\t\tnone\n"); + else + qsort(nr, na.na_nodes, sizeof(*nr), rssicmp); for (i = 0; i < na.na_nodes; i++) { printf("\t\t"); |