Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ifconfig Before scanning, check if the card is up. If i...



details:   https://anonhg.NetBSD.org/src/rev/e5510f15829d
branches:  trunk
changeset: 325822:e5510f15829d
user:      degroote <degroote%NetBSD.org@localhost>
date:      Tue Jan 07 20:25:24 2014 +0000

description:
Before scanning, check if the card is up. If it is not the case, exit
with some useful error message. Add some note about this fact in the man
page too.

diffstat:

 sbin/ifconfig/ieee80211.c |  15 +++++++++++++--
 sbin/ifconfig/ifconfig.8  |   3 ++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diffs (55 lines):

diff -r 2b3f9233cc20 -r e5510f15829d sbin/ifconfig/ieee80211.c
--- a/sbin/ifconfig/ieee80211.c Tue Jan 07 20:11:35 2014 +0000
+++ b/sbin/ifconfig/ieee80211.c Tue Jan 07 20:25:24 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ieee80211.c,v 1.25 2010/12/13 17:35:08 pooka Exp $     */
+/*     $NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $  */
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ieee80211.c,v 1.25 2010/12/13 17:35:08 pooka Exp $");
+__RCSID("$NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -463,8 +463,19 @@
 static int
 scan_exec(prop_dictionary_t env, prop_dictionary_t oenv)
 {
+       struct ifreq ifr;
+
+       if (direct_ioctl(env, SIOCGIFFLAGS, &ifr) == -1) {
+               perror("ioctl(SIOCGIFFLAGS");
+               return -1;
+       }
+
+       if ((ifr.ifr_flags & IFF_UP) == 0) 
+               errx(EXIT_FAILURE, "The interface must be up before scanning.");
+
        scan_and_wait(env);
        list_scan(env);
+
        return 0;
 }
 
diff -r 2b3f9233cc20 -r e5510f15829d sbin/ifconfig/ifconfig.8
--- a/sbin/ifconfig/ifconfig.8  Tue Jan 07 20:11:35 2014 +0000
+++ b/sbin/ifconfig/ifconfig.8  Tue Jan 07 20:25:24 2014 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ifconfig.8,v 1.105 2013/11/09 13:10:35 kefren Exp $
+.\"    $NetBSD: ifconfig.8,v 1.106 2014/01/07 20:25:24 degroote Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -503,6 +503,7 @@
 flag may be used to display long SSIDs.
 .Fl v
 also causes received information elements to be displayed symbolically.
+The interface must be up before any scanning operation.
 Only the super-user can use this command.
 .It Cm tunnel Ar src_addr Ns Oo Ar ,src_port Oc Ar dest_addr Ns Oo Ar ,dest_port
 .Oc



Home | Main Index | Thread Index | Old Index