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_action.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2009 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/8.3/sys/net80211/ieee80211_action.c 200433 2009-12-12 12:31:11Z antoine $");
   29 #endif
   30 
   31 /*
   32  * IEEE 802.11 send/recv action frame support.
   33  */
   34 
   35 #include "opt_inet.h"
   36 #include "opt_wlan.h"
   37 
   38 #include <sys/param.h>
   39 #include <sys/kernel.h>
   40 #include <sys/systm.h> 
   41  
   42 #include <sys/socket.h>
   43 
   44 #include <net/if.h>
   45 #include <net/if_media.h>
   46 #include <net/ethernet.h>
   47 
   48 #include <net80211/ieee80211_var.h>
   49 #include <net80211/ieee80211_action.h>
   50 #include <net80211/ieee80211_mesh.h>
   51 
   52 static int
   53 send_inval(struct ieee80211_node *ni, int cat, int act, void *sa)
   54 {
   55         return EINVAL;
   56 }
   57 
   58 static ieee80211_send_action_func *ba_send_action[8] = {
   59         send_inval, send_inval, send_inval, send_inval,
   60         send_inval, send_inval, send_inval, send_inval,
   61 };
   62 static ieee80211_send_action_func *ht_send_action[8] = {
   63         send_inval, send_inval, send_inval, send_inval,
   64         send_inval, send_inval, send_inval, send_inval,
   65 };
   66 static ieee80211_send_action_func *meshpl_send_action[8] = {
   67         send_inval, send_inval, send_inval, send_inval,
   68         send_inval, send_inval, send_inval, send_inval,
   69 };
   70 static ieee80211_send_action_func *meshlm_send_action[4] = {
   71         send_inval, send_inval, send_inval, send_inval,
   72 };
   73 static ieee80211_send_action_func *hwmp_send_action[8] = {
   74         send_inval, send_inval, send_inval, send_inval,
   75         send_inval, send_inval, send_inval, send_inval,
   76 };
   77 static ieee80211_send_action_func *vendor_send_action[8] = {
   78         send_inval, send_inval, send_inval, send_inval,
   79         send_inval, send_inval, send_inval, send_inval,
   80 };
   81 
   82 int
   83 ieee80211_send_action_register(int cat, int act, ieee80211_send_action_func *f)
   84 {
   85 #define N(a)    (sizeof(a) / sizeof(a[0]))
   86         switch (cat) {
   87         case IEEE80211_ACTION_CAT_BA:
   88                 if (act >= N(ba_send_action))
   89                         break;
   90                 ba_send_action[act] = f;
   91                 return 0;
   92         case IEEE80211_ACTION_CAT_HT:
   93                 if (act >= N(ht_send_action))
   94                         break;
   95                 ht_send_action[act] = f;
   96                 return 0;
   97         case IEEE80211_ACTION_CAT_MESHPEERING:
   98                 if (act >= N(meshpl_send_action))
   99                         break;
  100                 meshpl_send_action[act] = f;
  101                 return 0;
  102         case IEEE80211_ACTION_CAT_MESHLMETRIC:
  103                 if (act >= N(meshlm_send_action))
  104                         break;
  105                 meshlm_send_action[act] = f;
  106                 return 0;
  107         case IEEE80211_ACTION_CAT_MESHPATH:
  108                 if (act >= N(hwmp_send_action))
  109                         break;
  110                 hwmp_send_action[act] = f;
  111                 return 0;
  112         case IEEE80211_ACTION_CAT_VENDOR:
  113                 if (act >= N(vendor_send_action))
  114                         break;
  115                 vendor_send_action[act] = f;
  116                 return 0;
  117         }
  118         return EINVAL;
  119 #undef N
  120 }
  121 
  122 void
  123 ieee80211_send_action_unregister(int cat, int act)
  124 {
  125         ieee80211_send_action_register(cat, act, send_inval);
  126 }
  127 
  128 int
  129 ieee80211_send_action(struct ieee80211_node *ni, int cat, int act, void *sa)
  130 {
  131 #define N(a)    (sizeof(a) / sizeof(a[0]))
  132         ieee80211_send_action_func *f = send_inval;
  133 
  134         switch (cat) {
  135         case IEEE80211_ACTION_CAT_BA:
  136                 if (act < N(ba_send_action))
  137                         f = ba_send_action[act];
  138                 break;
  139         case IEEE80211_ACTION_CAT_HT:
  140                 if (act < N(ht_send_action))
  141                         f = ht_send_action[act];
  142                 break;
  143         case IEEE80211_ACTION_CAT_MESHPEERING:
  144                 if (act < N(meshpl_send_action))
  145                         f = meshpl_send_action[act];
  146                 break;
  147         case IEEE80211_ACTION_CAT_MESHLMETRIC:
  148                 if (act < N(meshlm_send_action))
  149                         f = meshlm_send_action[act];
  150                 break;
  151         case IEEE80211_ACTION_CAT_MESHPATH:
  152                 if (act < N(hwmp_send_action))
  153                         f = hwmp_send_action[act];
  154                 break;
  155         case IEEE80211_ACTION_CAT_VENDOR:
  156                 if (act < N(vendor_send_action))
  157                         f = vendor_send_action[act];
  158                 break;
  159         }
  160         return f(ni, cat, act, sa);
  161 #undef N
  162 }
  163 
  164 static int
  165 recv_inval(struct ieee80211_node *ni, const struct ieee80211_frame *wh,
  166         const uint8_t *frm, const uint8_t *efrm)
  167 {
  168         return EINVAL;
  169 }
  170 
  171 static ieee80211_recv_action_func *ba_recv_action[8] = {
  172         recv_inval, recv_inval, recv_inval, recv_inval,
  173         recv_inval, recv_inval, recv_inval, recv_inval,
  174 };
  175 static ieee80211_recv_action_func *ht_recv_action[8] = {
  176         recv_inval, recv_inval, recv_inval, recv_inval,
  177         recv_inval, recv_inval, recv_inval, recv_inval,
  178 };
  179 static ieee80211_recv_action_func *meshpl_recv_action[8] = {
  180         recv_inval, recv_inval, recv_inval, recv_inval,
  181         recv_inval, recv_inval, recv_inval, recv_inval,
  182 };
  183 static ieee80211_recv_action_func *meshlm_recv_action[4] = {
  184         recv_inval, recv_inval, recv_inval, recv_inval,
  185 };
  186 static ieee80211_recv_action_func *hwmp_recv_action[8] = {
  187         recv_inval, recv_inval, recv_inval, recv_inval,
  188         recv_inval, recv_inval, recv_inval, recv_inval,
  189 };
  190 static ieee80211_recv_action_func *vendor_recv_action[8] = {
  191         recv_inval, recv_inval, recv_inval, recv_inval,
  192         recv_inval, recv_inval, recv_inval, recv_inval,
  193 };
  194 
  195 int
  196 ieee80211_recv_action_register(int cat, int act, ieee80211_recv_action_func *f)
  197 {
  198 #define N(a)    (sizeof(a) / sizeof(a[0]))
  199         switch (cat) {
  200         case IEEE80211_ACTION_CAT_BA:
  201                 if (act >= N(ba_recv_action))
  202                         break;
  203                 ba_recv_action[act] = f;
  204                 return 0;
  205         case IEEE80211_ACTION_CAT_HT:
  206                 if (act >= N(ht_recv_action))
  207                         break;
  208                 ht_recv_action[act] = f;
  209                 return 0;
  210         case IEEE80211_ACTION_CAT_MESHPEERING:
  211                 if (act >= N(meshpl_recv_action))
  212                         break;
  213                 meshpl_recv_action[act] = f;
  214                 return 0;
  215         case IEEE80211_ACTION_CAT_MESHLMETRIC:
  216                 if (act >= N(meshlm_recv_action))
  217                         break;
  218                 meshlm_recv_action[act] = f;
  219                 return 0;
  220         case IEEE80211_ACTION_CAT_MESHPATH:
  221                 if (act >= N(hwmp_recv_action))
  222                         break;
  223                 hwmp_recv_action[act] = f;
  224                 return 0;
  225         case IEEE80211_ACTION_CAT_VENDOR:
  226                 if (act >= N(vendor_recv_action))
  227                         break;
  228                 vendor_recv_action[act] = f;
  229                 return 0;
  230         }
  231         return EINVAL;
  232 #undef N
  233 }
  234 
  235 void
  236 ieee80211_recv_action_unregister(int cat, int act)
  237 {
  238         ieee80211_recv_action_register(cat, act, recv_inval);
  239 }
  240 
  241 int
  242 ieee80211_recv_action(struct ieee80211_node *ni,
  243         const struct ieee80211_frame *wh,
  244         const uint8_t *frm, const uint8_t *efrm)
  245 {
  246 #define N(a)    (sizeof(a) / sizeof(a[0]))
  247         ieee80211_recv_action_func *f = recv_inval;
  248         const struct ieee80211_action *ia =
  249             (const struct ieee80211_action *) frm;
  250 
  251         switch (ia->ia_category) {
  252         case IEEE80211_ACTION_CAT_BA:
  253                 if (ia->ia_action < N(ba_recv_action))
  254                         f = ba_recv_action[ia->ia_action];
  255                 break;
  256         case IEEE80211_ACTION_CAT_HT:
  257                 if (ia->ia_action < N(ht_recv_action))
  258                         f = ht_recv_action[ia->ia_action];
  259                 break;
  260         case IEEE80211_ACTION_CAT_MESHPEERING:
  261                 if (ia->ia_action < N(meshpl_recv_action))
  262                         f = meshpl_recv_action[ia->ia_action];
  263                 break;
  264         case IEEE80211_ACTION_CAT_MESHLMETRIC:
  265                 if (ia->ia_action < N(meshlm_recv_action))
  266                         f = meshlm_recv_action[ia->ia_action];
  267                 break;
  268         case IEEE80211_ACTION_CAT_MESHPATH:
  269                 if (ia->ia_action < N(hwmp_recv_action))
  270                         f = hwmp_recv_action[ia->ia_action];
  271                 break;
  272         case IEEE80211_ACTION_CAT_VENDOR:
  273                 if (ia->ia_action < N(vendor_recv_action))
  274                         f = vendor_recv_action[ia->ia_action];
  275                 break;
  276         }
  277         return f(ni, wh, frm, efrm);
  278 #undef N
  279 }

Cache object: 465c2959751d2f201298ce3923f0f6a0


[ 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.