The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/net80211/ieee80211_monitor.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   24  */
   25 
   26 #include <sys/cdefs.h>
   27 #ifdef __FreeBSD__
   28 __FBSDID("$FreeBSD: releng/11.0/sys/net80211/ieee80211_monitor.c 283535 2015-05-25 16:37:41Z adrian $");
   29 #endif
   30 
   31 /*
   32  * IEEE 802.11 Monitor mode support.
   33  */
   34 #include "opt_inet.h"
   35 #include "opt_wlan.h"
   36 
   37 #include <sys/param.h>
   38 #include <sys/systm.h> 
   39 #include <sys/mbuf.h>   
   40 #include <sys/malloc.h>
   41 #include <sys/kernel.h>
   42 
   43 #include <sys/socket.h>
   44 #include <sys/sockio.h>
   45 #include <sys/endian.h>
   46 #include <sys/errno.h>
   47 #include <sys/proc.h>
   48 #include <sys/sysctl.h>
   49 
   50 #include <net/if.h>
   51 #include <net/if_var.h>
   52 #include <net/if_media.h>
   53 #include <net/if_llc.h>
   54 #include <net/ethernet.h>
   55 
   56 #include <net/bpf.h>
   57 
   58 #include <net80211/ieee80211_var.h>
   59 #include <net80211/ieee80211_monitor.h>
   60 
   61 static void monitor_vattach(struct ieee80211vap *);
   62 static int monitor_newstate(struct ieee80211vap *, enum ieee80211_state, int);
   63 static int monitor_input(struct ieee80211_node *ni, struct mbuf *m,
   64         const struct ieee80211_rx_stats *rxs, int rssi, int nf);
   65 
   66 void
   67 ieee80211_monitor_attach(struct ieee80211com *ic)
   68 {
   69         ic->ic_vattach[IEEE80211_M_MONITOR] = monitor_vattach;
   70 }
   71 
   72 void
   73 ieee80211_monitor_detach(struct ieee80211com *ic)
   74 {
   75 }
   76 
   77 static void
   78 monitor_vdetach(struct ieee80211vap *vap)
   79 {
   80 }
   81 
   82 static void
   83 monitor_vattach(struct ieee80211vap *vap)
   84 {
   85         vap->iv_newstate = monitor_newstate;
   86         vap->iv_input = monitor_input;
   87         vap->iv_opdetach = monitor_vdetach;
   88 }
   89 
   90 /*
   91  * IEEE80211_M_MONITOR vap state machine handler.
   92  */
   93 static int
   94 monitor_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
   95 {
   96         struct ieee80211com *ic = vap->iv_ic;
   97         enum ieee80211_state ostate;
   98 
   99         IEEE80211_LOCK_ASSERT(ic);
  100 
  101         ostate = vap->iv_state;
  102         IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s -> %s (%d)\n",
  103             __func__, ieee80211_state_name[ostate],
  104             ieee80211_state_name[nstate], arg);
  105         vap->iv_state = nstate;                 /* state transition */
  106         if (nstate == IEEE80211_S_RUN) {
  107                 switch (ostate) {
  108                 case IEEE80211_S_INIT:
  109                         ieee80211_create_ibss(vap, ic->ic_curchan);
  110                         break;
  111                 default:
  112                         break;
  113                 }
  114                 /*
  115                  * NB: this shouldn't be here but many people use
  116                  * monitor mode for raw packets; once we switch
  117                  * them over to adhoc demo mode remove this.
  118                  */
  119                 ieee80211_node_authorize(vap->iv_bss);
  120         }
  121         return 0;
  122 }
  123 
  124 /*
  125  * Process a received frame in monitor mode.
  126  */
  127 static int
  128 monitor_input(struct ieee80211_node *ni, struct mbuf *m,
  129     const struct ieee80211_rx_stats *rxs, int rssi, int nf)
  130 {
  131         struct ieee80211vap *vap = ni->ni_vap;
  132         struct ifnet *ifp = vap->iv_ifp;
  133 
  134         if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
  135 
  136         if (ieee80211_radiotap_active_vap(vap))
  137                 ieee80211_radiotap_rx(vap, m);
  138         m_freem(m);
  139         return -1;
  140 }

Cache object: 13965e79747be56d29a3f7bc9cfca46e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.