Tue Jan 7 20:25:24 2014 UTC ()
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.


(degroote)
diff -r1.25 -r1.26 src/sbin/ifconfig/ieee80211.c
diff -r1.105 -r1.106 src/sbin/ifconfig/ifconfig.8

cvs diff -r1.25 -r1.26 src/sbin/ifconfig/ieee80211.c (expand / switch to unified diff)

--- src/sbin/ifconfig/ieee80211.c 2010/12/13 17:35:08 1.25
+++ src/sbin/ifconfig/ieee80211.c 2014/01/07 20:25:24 1.26
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ieee80211.c,v 1.25 2010/12/13 17:35:08 pooka Exp $ */ 1/* $NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1983, 1993 4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__RCSID("$NetBSD: ieee80211.c,v 1.25 2010/12/13 17:35:08 pooka Exp $"); 34__RCSID("$NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $");
35#endif /* not lint */ 35#endif /* not lint */
36 36
37#include <sys/param.h> 37#include <sys/param.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include <sys/socket.h> 39#include <sys/socket.h>
40 40
41#include <net/if.h> 41#include <net/if.h>
42#include <net/if_ether.h> 42#include <net/if_ether.h>
43#include <net/if_media.h> 43#include <net/if_media.h>
44#include <net/route.h> 44#include <net/route.h>
45#include <net80211/ieee80211.h> 45#include <net80211/ieee80211.h>
46#include <net80211/ieee80211_ioctl.h> 46#include <net80211/ieee80211_ioctl.h>
47#include <net80211/ieee80211_netbsd.h> 47#include <net80211/ieee80211_netbsd.h>
@@ -453,28 +453,39 @@ setifpowersavesleep(prop_dictionary_t en @@ -453,28 +453,39 @@ setifpowersavesleep(prop_dictionary_t en
453 453
454 if (direct_ioctl(env, SIOCG80211POWER, &power) == -1) 454 if (direct_ioctl(env, SIOCG80211POWER, &power) == -1)
455 err(EXIT_FAILURE, "SIOCG80211POWER"); 455 err(EXIT_FAILURE, "SIOCG80211POWER");
456 456
457 power.i_maxsleep = maxsleep; 457 power.i_maxsleep = maxsleep;
458 if (direct_ioctl(env, SIOCS80211POWER, &power) == -1) 458 if (direct_ioctl(env, SIOCS80211POWER, &power) == -1)
459 err(EXIT_FAILURE, "SIOCS80211POWER"); 459 err(EXIT_FAILURE, "SIOCS80211POWER");
460 return 0; 460 return 0;
461} 461}
462 462
463static int 463static int
464scan_exec(prop_dictionary_t env, prop_dictionary_t oenv) 464scan_exec(prop_dictionary_t env, prop_dictionary_t oenv)
465{ 465{
 466 struct ifreq ifr;
 467
 468 if (direct_ioctl(env, SIOCGIFFLAGS, &ifr) == -1) {
 469 perror("ioctl(SIOCGIFFLAGS");
 470 return -1;
 471 }
 472
 473 if ((ifr.ifr_flags & IFF_UP) == 0)
 474 errx(EXIT_FAILURE, "The interface must be up before scanning.");
 475
466 scan_and_wait(env); 476 scan_and_wait(env);
467 list_scan(env); 477 list_scan(env);
 478
468 return 0; 479 return 0;
469} 480}
470 481
471static void 482static void
472ieee80211_statistics(prop_dictionary_t env) 483ieee80211_statistics(prop_dictionary_t env)
473{ 484{
474 struct ieee80211_stats stats; 485 struct ieee80211_stats stats;
475 struct ifreq ifr; 486 struct ifreq ifr;
476 487
477 memset(&ifr, 0, sizeof(ifr)); 488 memset(&ifr, 0, sizeof(ifr));
478 ifr.ifr_buflen = sizeof(stats); 489 ifr.ifr_buflen = sizeof(stats);
479 ifr.ifr_buf = (caddr_t)&stats; 490 ifr.ifr_buf = (caddr_t)&stats;
480 if (direct_ioctl(env, (zflag) ? SIOCG80211ZSTATS : SIOCG80211STATS, 491 if (direct_ioctl(env, (zflag) ? SIOCG80211ZSTATS : SIOCG80211STATS,

cvs diff -r1.105 -r1.106 src/sbin/ifconfig/ifconfig.8 (expand / switch to unified diff)

--- src/sbin/ifconfig/ifconfig.8 2013/11/09 13:10:35 1.105
+++ src/sbin/ifconfig/ifconfig.8 2014/01/07 20:25:24 1.106
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: ifconfig.8,v 1.105 2013/11/09 13:10:35 kefren Exp $ 1.\" $NetBSD: ifconfig.8,v 1.106 2014/01/07 20:25:24 degroote Exp $
2.\" 2.\"
3.\" Copyright (c) 1983, 1991, 1993 3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors 14.\" 3. Neither the name of the University nor the names of its contributors
@@ -493,26 +493,27 @@ to be used for IEEE 802.11-based wireles @@ -493,26 +493,27 @@ to be used for IEEE 802.11-based wireles
493.Pq IEEE 802.11 devices only 493.Pq IEEE 802.11 devices only
494Unset the desired channel to be used 494Unset the desired channel to be used
495for IEEE 802.11-based wireless network interfaces. 495for IEEE 802.11-based wireless network interfaces.
496It doesn't affect the channel to be created for IBSS or hostap mode. 496It doesn't affect the channel to be created for IBSS or hostap mode.
497.It Cm list scan 497.It Cm list scan
498.Pq IEEE 802.11 devices only 498.Pq IEEE 802.11 devices only
499Display the access points and/or ad-hoc neighbors 499Display the access points and/or ad-hoc neighbors
500located in the vicinity. 500located in the vicinity.
501The 501The
502.Fl v 502.Fl v
503flag may be used to display long SSIDs. 503flag may be used to display long SSIDs.
504.Fl v 504.Fl v
505also causes received information elements to be displayed symbolically. 505also causes received information elements to be displayed symbolically.
 506The interface must be up before any scanning operation.
506Only the super-user can use this command. 507Only the super-user can use this command.
507.It Cm tunnel Ar src_addr Ns Oo Ar ,src_port Oc Ar dest_addr Ns Oo Ar ,dest_port 508.It Cm tunnel Ar src_addr Ns Oo Ar ,src_port Oc Ar dest_addr Ns Oo Ar ,dest_port
508.Oc 509.Oc
509.Pq IP tunnel devices only 510.Pq IP tunnel devices only
510Configure the physical source and destination address for IP tunnel 511Configure the physical source and destination address for IP tunnel
511interfaces, including 512interfaces, including
512.Xr gif 4 . 513.Xr gif 4 .
513The arguments 514The arguments
514.Ar src_addr 515.Ar src_addr
515and 516and
516.Ar dest_addr 517.Ar dest_addr
517are interpreted as the outer source/destination for the encapsulating 518are interpreted as the outer source/destination for the encapsulating
518IPv4/IPv6 header. 519IPv4/IPv6 header.