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.
This commit is contained in:
degroote 2014-01-07 20:25:24 +00:00
parent 6c190f50bb
commit f2475e079d
2 changed files with 15 additions and 3 deletions

View File

@ -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 @@ setifpowersavesleep(prop_dictionary_t env, prop_dictionary_t oenv)
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;
}

View File

@ -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 @@ The
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