| @@ -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 | |
463 | static int | | 463 | static int |
464 | scan_exec(prop_dictionary_t env, prop_dictionary_t oenv) | | 464 | scan_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 | |
471 | static void | | 482 | static void |
472 | ieee80211_statistics(prop_dictionary_t env) | | 483 | ieee80211_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, |