2009-07-05 17:59:19 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2009 Sam Leffler, Errno Consulting
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IEEE 802.11 send/recv action frame support.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opt_inet.h"
|
|
|
|
#include "opt_wlan.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
2016-02-01 17:41:21 +00:00
|
|
|
#include <sys/malloc.h>
|
2009-07-05 17:59:19 +00:00
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2009-07-05 17:59:19 +00:00
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
|
|
|
#include <net80211/ieee80211_action.h>
|
Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.
Authentication and encryption are not implemented.
There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).
A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.
Drivers that support mesh networks right now are: ath, ral and mwl.
More information at: http://wiki.freebsd.org/WifiMesh
Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.
Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.
Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s
2009-07-11 15:02:45 +00:00
|
|
|
#include <net80211/ieee80211_mesh.h>
|
2009-07-05 17:59:19 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
send_inval(struct ieee80211_node *ni, int cat, int act, void *sa)
|
|
|
|
{
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ieee80211_send_action_func *ba_send_action[8] = {
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
};
|
|
|
|
static ieee80211_send_action_func *ht_send_action[8] = {
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
};
|
|
|
|
static ieee80211_send_action_func *meshpl_send_action[8] = {
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
};
|
2013-02-07 21:21:05 +00:00
|
|
|
static ieee80211_send_action_func *meshaction_send_action[12] = {
|
2009-07-05 17:59:19 +00:00
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
};
|
|
|
|
static ieee80211_send_action_func *vendor_send_action[8] = {
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
send_inval, send_inval, send_inval, send_inval,
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211_send_action_register(int cat, int act, ieee80211_send_action_func *f)
|
|
|
|
{
|
|
|
|
switch (cat) {
|
|
|
|
case IEEE80211_ACTION_CAT_BA:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(ba_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
ba_send_action[act] = f;
|
|
|
|
return 0;
|
|
|
|
case IEEE80211_ACTION_CAT_HT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(ht_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
ht_send_action[act] = f;
|
|
|
|
return 0;
|
2012-05-01 15:35:10 +00:00
|
|
|
case IEEE80211_ACTION_CAT_SELF_PROT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(meshpl_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
meshpl_send_action[act] = f;
|
|
|
|
return 0;
|
2012-03-04 05:49:39 +00:00
|
|
|
case IEEE80211_ACTION_CAT_MESH:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(meshaction_send_action))
|
2013-02-07 21:21:05 +00:00
|
|
|
break;
|
|
|
|
meshaction_send_action[act] = f;
|
|
|
|
return 0;
|
2009-07-05 17:59:19 +00:00
|
|
|
case IEEE80211_ACTION_CAT_VENDOR:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(vendor_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
vendor_send_action[act] = f;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_send_action_unregister(int cat, int act)
|
|
|
|
{
|
|
|
|
ieee80211_send_action_register(cat, act, send_inval);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211_send_action(struct ieee80211_node *ni, int cat, int act, void *sa)
|
|
|
|
{
|
|
|
|
ieee80211_send_action_func *f = send_inval;
|
|
|
|
|
|
|
|
switch (cat) {
|
|
|
|
case IEEE80211_ACTION_CAT_BA:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act < nitems(ba_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = ba_send_action[act];
|
|
|
|
break;
|
|
|
|
case IEEE80211_ACTION_CAT_HT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act < nitems(ht_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = ht_send_action[act];
|
|
|
|
break;
|
2012-05-01 15:35:10 +00:00
|
|
|
case IEEE80211_ACTION_CAT_SELF_PROT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act < nitems(meshpl_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = meshpl_send_action[act];
|
|
|
|
break;
|
2012-03-04 05:49:39 +00:00
|
|
|
case IEEE80211_ACTION_CAT_MESH:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act < nitems(meshaction_send_action))
|
2013-02-07 21:21:05 +00:00
|
|
|
f = meshaction_send_action[act];
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
case IEEE80211_ACTION_CAT_VENDOR:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act < nitems(vendor_send_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = vendor_send_action[act];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return f(ni, cat, act, sa);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
recv_inval(struct ieee80211_node *ni, const struct ieee80211_frame *wh,
|
|
|
|
const uint8_t *frm, const uint8_t *efrm)
|
|
|
|
{
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ieee80211_recv_action_func *ba_recv_action[8] = {
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
};
|
|
|
|
static ieee80211_recv_action_func *ht_recv_action[8] = {
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
};
|
|
|
|
static ieee80211_recv_action_func *meshpl_recv_action[8] = {
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
};
|
2013-02-07 21:21:05 +00:00
|
|
|
static ieee80211_recv_action_func *meshaction_recv_action[12] = {
|
2009-07-05 17:59:19 +00:00
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
};
|
|
|
|
static ieee80211_recv_action_func *vendor_recv_action[8] = {
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
recv_inval, recv_inval, recv_inval, recv_inval,
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211_recv_action_register(int cat, int act, ieee80211_recv_action_func *f)
|
|
|
|
{
|
|
|
|
switch (cat) {
|
|
|
|
case IEEE80211_ACTION_CAT_BA:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(ba_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
ba_recv_action[act] = f;
|
|
|
|
return 0;
|
|
|
|
case IEEE80211_ACTION_CAT_HT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(ht_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
ht_recv_action[act] = f;
|
|
|
|
return 0;
|
2012-05-01 15:35:10 +00:00
|
|
|
case IEEE80211_ACTION_CAT_SELF_PROT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(meshpl_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
meshpl_recv_action[act] = f;
|
|
|
|
return 0;
|
2012-03-04 05:49:39 +00:00
|
|
|
case IEEE80211_ACTION_CAT_MESH:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(meshaction_recv_action))
|
2013-02-07 21:21:05 +00:00
|
|
|
break;
|
|
|
|
meshaction_recv_action[act] = f;
|
|
|
|
return 0;
|
2009-07-05 17:59:19 +00:00
|
|
|
case IEEE80211_ACTION_CAT_VENDOR:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (act >= nitems(vendor_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
vendor_recv_action[act] = f;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ieee80211_recv_action_unregister(int cat, int act)
|
|
|
|
{
|
|
|
|
ieee80211_recv_action_register(cat, act, recv_inval);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211_recv_action(struct ieee80211_node *ni,
|
|
|
|
const struct ieee80211_frame *wh,
|
|
|
|
const uint8_t *frm, const uint8_t *efrm)
|
|
|
|
{
|
|
|
|
ieee80211_recv_action_func *f = recv_inval;
|
2013-02-07 21:21:40 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
2009-07-05 17:59:19 +00:00
|
|
|
const struct ieee80211_action *ia =
|
|
|
|
(const struct ieee80211_action *) frm;
|
|
|
|
|
|
|
|
switch (ia->ia_category) {
|
|
|
|
case IEEE80211_ACTION_CAT_BA:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (ia->ia_action < nitems(ba_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = ba_recv_action[ia->ia_action];
|
|
|
|
break;
|
|
|
|
case IEEE80211_ACTION_CAT_HT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (ia->ia_action < nitems(ht_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = ht_recv_action[ia->ia_action];
|
|
|
|
break;
|
2012-05-01 15:35:10 +00:00
|
|
|
case IEEE80211_ACTION_CAT_SELF_PROT:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (ia->ia_action < nitems(meshpl_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = meshpl_recv_action[ia->ia_action];
|
|
|
|
break;
|
2012-03-04 05:49:39 +00:00
|
|
|
case IEEE80211_ACTION_CAT_MESH:
|
2013-02-07 21:21:40 +00:00
|
|
|
if (ni == vap->iv_bss ||
|
|
|
|
ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED) {
|
|
|
|
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_MESH,
|
|
|
|
ni->ni_macaddr, NULL,
|
|
|
|
"peer link not yet established (%d), cat %s act %u",
|
|
|
|
ni->ni_mlstate, "mesh action", ia->ia_action);
|
|
|
|
vap->iv_stats.is_mesh_nolink++;
|
|
|
|
break;
|
|
|
|
}
|
2013-08-14 04:24:25 +00:00
|
|
|
if (ia->ia_action < nitems(meshaction_recv_action))
|
2013-02-07 21:21:05 +00:00
|
|
|
f = meshaction_recv_action[ia->ia_action];
|
2009-07-05 17:59:19 +00:00
|
|
|
break;
|
|
|
|
case IEEE80211_ACTION_CAT_VENDOR:
|
2013-08-14 04:24:25 +00:00
|
|
|
if (ia->ia_action < nitems(vendor_recv_action))
|
2009-07-05 17:59:19 +00:00
|
|
|
f = vendor_recv_action[ia->ia_action];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return f(ni, wh, frm, efrm);
|
|
|
|
}
|