Home | History | Annotate | Line # | Download | only in common
ieee80211_20.c revision 1.1.2.1
      1 /*	$NetBSD: ieee80211_20.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $	*/
      2 /*-
      3  * Copyright (c) 2001 Atsushi Onoe
      4  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * Alternatively, this software may be distributed under the terms of the
     19  * GNU General Public License ("GPL") version 2 as published by the Free
     20  * Software Foundation.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 #include <sys/cdefs.h>
     35 #ifdef __FreeBSD__
     36 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.35 2005/08/30 14:27:47 avatar Exp $");
     37 #endif
     38 #ifdef __NetBSD__
     39 __KERNEL_RCSID(0, "$NetBSD: ieee80211_20.c,v 1.1.2.1 2018/03/30 02:28:49 pgoyette Exp $");
     40 #endif
     41 
     42 /*
     43  * IEEE 802.11 ioctl support
     44  */
     45 
     46 #ifdef _KERNEL_OPT
     47 #include "opt_inet.h"
     48 #include "opt_compat_netbsd.h"
     49 #endif
     50 
     51 #include <sys/endian.h>
     52 #include <sys/param.h>
     53 #include <sys/kernel.h>
     54 #include <sys/socket.h>
     55 #include <sys/sockio.h>
     56 #include <sys/systm.h>
     57 #include <sys/proc.h>
     58 #include <sys/kauth.h>
     59 #include <sys/compat_stub.h>
     60 
     61 #include <net/if.h>
     62 #include <net/if_arp.h>
     63 #include <net/if_media.h>
     64 #include <net/if_ether.h>
     65 
     66 #include <net80211/ieee80211_var.h>
     67 #include <net80211/ieee80211_ioctl.h>
     68 
     69 #include <dev/ic/wi_ieee.h>
     70 
     71 #include <compat/common/compat_mod.h>
     72 
     73 #include <compat/sys/sockio.h>
     74 
     75 static int
     76 ieee80211_get_ostats(struct ieee80211_ostats *ostats,
     77     struct ieee80211_stats *stats)
     78 {
     79 #define	COPYSTATS1(__ostats, __nstats, __dstmemb, __srcmemb, __lastmemb)\
     80 	(void)memcpy(&(__ostats)->__dstmemb, &(__nstats)->__srcmemb,	\
     81 	    offsetof(struct ieee80211_stats, __lastmemb) -		\
     82 	    offsetof(struct ieee80211_stats, __srcmemb))
     83 #define	COPYSTATS(__ostats, __nstats, __dstmemb, __lastmemb)		\
     84 	COPYSTATS1(__ostats, __nstats, __dstmemb, __dstmemb, __lastmemb)
     85 
     86 	COPYSTATS(ostats, stats, is_rx_badversion, is_rx_unencrypted);
     87 	COPYSTATS(ostats, stats, is_rx_wepfail, is_rx_beacon);
     88 	COPYSTATS(ostats, stats, is_rx_rstoobig, is_rx_auth_countermeasures);
     89 	COPYSTATS(ostats, stats, is_rx_assoc_bss, is_rx_assoc_badwpaie);
     90 	COPYSTATS(ostats, stats, is_rx_deauth, is_rx_unauth);
     91 	COPYSTATS1(ostats, stats, is_tx_nombuf, is_tx_nobuf, is_tx_badcipher);
     92 	COPYSTATS(ostats, stats, is_scan_active, is_crypto_tkip);
     93 
     94 	return 0;
     95 }
     96 
     97 void
     98 ieee80211_20_init(void)
     99 {
    100 
    101 	ieee80211_get_ostats_20 = ieee80211_get_ostats;
    102 }
    103 void
    104 ieee80211_20_fini(void)
    105 {
    106 
    107 	ieee80211_get_ostats_20 = (void *)enosys;
    108 }
    109