svn commit: r193834 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Tue Jun 9 15:03:23 UTC 2009
Author: rpaulo
Date: Tue Jun 9 15:03:22 2009
New Revision: 193834
URL: http://svn.freebsd.org/changeset/base/193834
Log:
* properly setup and send the mesh conf IE; this breaks linux
compatibility
* verify mesh conf IE on peer link establishment
* move forwarding sysctl to a per vap ioctl
* implement accept peerings flag that will enable disable peering
* add ioctls for peering and fowarding bits
Sponsored by: The FreeBSD Foundation
Modified:
projects/mesh11s/sys/net80211/ieee80211_hwmp.c
projects/mesh11s/sys/net80211/ieee80211_ioctl.h
projects/mesh11s/sys/net80211/ieee80211_mesh.c
projects/mesh11s/sys/net80211/ieee80211_mesh.h
projects/mesh11s/sys/net80211/ieee80211_var.h
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Tue Jun 9 14:26:23 2009 (r193833)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Tue Jun 9 15:03:22 2009 (r193834)
@@ -144,7 +144,6 @@ SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, roo
#endif
extern int ieee80211_mesh_ttl;
-extern int ieee80211_mesh_forwarding;
void
ieee80211_hwmp_vattach(struct ieee80211vap *vap)
@@ -486,7 +485,7 @@ hwmp_recv_preq(struct ieee80211vap *vap,
* forwarding is disabled, discard this PREQ.
*/
if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) &&
- !ieee80211_mesh_forwarding) {
+ !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) {
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_MESH,
preq->preq_origaddr, NULL, "%s", "not accepting PREQ");
return;
@@ -675,7 +674,7 @@ hwmp_recv_prep(struct ieee80211vap *vap,
* forwarding is disabled, discard this PREP.
*/
if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) &&
- !ieee80211_mesh_forwarding)
+ !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD))
return;
/*
@@ -753,7 +752,7 @@ hwmp_recv_perr(struct ieee80211vap *vap,
*/
if (ni == vap->iv_bss ||
ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED ||
- !ieee80211_mesh_forwarding)
+ !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD))
return;
mtx_lock(&hs->hs_lock);
@@ -833,7 +832,8 @@ hwmp_recv_rann(struct ieee80211vap *vap,
* We have a path for this Root Mesh station, so
* propagate the RANN if forwarding is enabled.
*/
- } else if (rann->rann_ttl > 1 && ieee80211_mesh_forwarding) {
+ } else if (rann->rann_ttl > 1 &&
+ (vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) {
struct ieee80211_meshrann_ie prann;
memcpy(&prann, rann, sizeof(prann));
@@ -956,11 +956,11 @@ hwmp_ioctl_get80211(struct ieee80211vap
struct ieee80211_hwmp_fi *fi;
uint8_t *p;
+ if (vap->iv_opmode != IEEE80211_M_MBSS)
+ return EINVAL;
error = 0;
switch (ireq->i_type) {
case IEEE80211_IOC_HWMP_TABLE:
- if (vap->iv_opmode != IEEE80211_M_MBSS)
- return EINVAL;
hs = vap->iv_hwmp;
len = 0;
mtx_lock(&hs->hs_lock);
@@ -999,11 +999,12 @@ hwmp_ioctl_set80211(struct ieee80211vap
{
int error;
+ if (vap->iv_opmode != IEEE80211_M_MBSS)
+ return EINVAL;
+
error = 0;
switch (ireq->i_type) {
case IEEE80211_IOC_HWMP_TABLE:
- if (vap->iv_opmode != IEEE80211_M_MBSS)
- return EINVAL;
default:
return ENOSYS;
}
Modified: projects/mesh11s/sys/net80211/ieee80211_ioctl.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_ioctl.h Tue Jun 9 14:26:23 2009 (r193833)
+++ projects/mesh11s/sys/net80211/ieee80211_ioctl.h Tue Jun 9 15:03:22 2009 (r193834)
@@ -641,6 +641,8 @@ struct ieee80211req {
#define IEEE80211_IOC_STBC 113 /* STBC Tx/RX (on, off) */
#define IEEE80211_IOC_MESH_ID 190 /* Mesh identifier */
+#define IEEE80211_IOC_MESH_AP 191 /* Accepting Peerings */
+#define IEEE80211_IOC_MESH_FWRD 192 /* Forward frames */
#define IEEE80211_IOC_HWMP_TABLE 195 /* HWMP Forwarding Table */
#define IEEE80211_IOC_TDMA_SLOT 201 /* TDMA: assigned slot */
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c Tue Jun 9 14:26:23 2009 (r193833)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Tue Jun 9 15:03:22 2009 (r193834)
@@ -87,14 +87,11 @@ static const int ieee80211_mesh_confirmt
#define CONFIRM_TIMEOUT msecs_to_ticks(ieee80211_mesh_confirmtimeout)
static const int ieee80211_mesh_maxretries = 2;
int ieee80211_mesh_ttl = 31;
-int ieee80211_mesh_forwarding = 1;
SYSCTL_NODE(_net_wlan, OID_AUTO, mesh, CTLFLAG_RD, 0,
"IEEE 802.11s parameters");
SYSCTL_INT(_net_wlan_mesh, OID_AUTO, ttl, CTLTYPE_INT | CTLFLAG_RW,
&ieee80211_mesh_ttl, 0, "TTL for mesh packets");
-SYSCTL_INT(_net_wlan_mesh, OID_AUTO, forwarding, CTLTYPE_INT | CTLFLAG_RW,
- &ieee80211_mesh_forwarding, 0, "Forward mesh packets");
static const char *nodemeshstates[] = {
"IDLE",
@@ -121,6 +118,7 @@ mesh_vdetach(struct ieee80211vap *vap)
{
ieee80211_hwmp_vdetach(vap);
vap->iv_meshseq = 0;
+ vap->iv_meshflags = (IEEE80211_MFLAGS_AP | IEEE80211_MFLAGS_FWRD);
}
static void
@@ -1039,19 +1037,19 @@ mesh_verify_meshid(struct ieee80211vap *
return memcmp(vap->iv_meshid, (uint8_t *)&meshid[1], vap->iv_meshidlen);
}
+/*
+ * Check if we are using the same algorithms for this mesh.
+ */
static int
mesh_verify_meshconf(struct ieee80211vap *vap,
struct ieee80211_meshconf_ie *meshconf)
{
-#ifdef notyet
static const uint8_t null[4] = IEEE80211_MESHCONF_NULL;
static const uint8_t hwmp[4] = IEEE80211_MESHCONF_HWMP;
static const uint8_t airtime[4] = IEEE80211_MESHCONF_AIRTIME;
-#endif
+
if (meshconf == NULL)
return 1;
-
-#ifdef notyet
if (meshconf->conf_ver != IEEE80211_MESHCONF_VERSION)
return 1;
if (memcmp(meshconf->conf_pselid, hwmp, 4) != 0)
@@ -1064,7 +1062,9 @@ mesh_verify_meshconf(struct ieee80211vap
return 1;
if (memcmp(meshconf->conf_authid, null, 4) != 0)
return 1;
-#endif
+ /* Not accepting peers */
+ if (!(meshconf->conf_cap & IEEE80211_MESHCONF_CAP_AP))
+ return 1;
return 0;
}
@@ -1097,6 +1097,19 @@ ieee80211_add_meshid(uint8_t *frm, struc
}
/*
+ * Helper function to find the number of mesh neighbors.
+ */
+static void
+meshconf_neighbors(void *arg, struct ieee80211_node *ni)
+{
+ uint8_t *neighbors = arg;
+
+ /* NB: avoid overflow */
+ if (*neighbors < 15 &&
+ ni->ni_mlstate == IEEE80211_NODE_MESH_ESTABLISHED)
+ (*neighbors)++;
+}
+/*
* Add a Mesh Configuration IE to a frame.
* For now just use HWMP routing, Airtime link metric, Null Congestion
* Signaling, Null Sync Protocol and Null Authentication.
@@ -1104,20 +1117,34 @@ ieee80211_add_meshid(uint8_t *frm, struc
uint8_t *
ieee80211_add_meshconf(uint8_t *frm, struct ieee80211vap *vap)
{
- static const struct ieee80211_meshconf_ie ie = {
+ uint8_t neighs = 0;
+ struct ieee80211_meshconf_ie ie = {
.conf_ie = IEEE80211_ELEMID_MESHCONF,
.conf_len = sizeof(struct ieee80211_meshconf_ie) - 2,
.conf_ver = IEEE80211_MESHCONF_VERSION,
.conf_pselid = IEEE80211_MESHCONF_HWMP,
.conf_pmetid = IEEE80211_MESHCONF_AIRTIME,
.conf_ccid = IEEE80211_MESHCONF_CCSIG,
- .conf_syncid = { 0, 0, 0, 0 }, /* XXX */
- .conf_authid = { 0x80, 0, 0, 0 }, /* XXX */
- .conf_form = 0, /* XXX */
- .conf_cap = 1, /* XXX */
+ .conf_syncid = IEEE80211_MESHCONF_NULL,
+ .conf_authid = IEEE80211_MESHCONF_NULL,
+ /* NB: set below */
+ .conf_form = 0,
+ .conf_cap = 0,
};
KASSERT(vap->iv_opmode == IEEE80211_M_MBSS, ("not a MBSS vap"));
+
+ /* NB: set the number of neighbors before anything else */
+ ieee80211_iterate_nodes(&vap->iv_ic->ic_sta, meshconf_neighbors,
+ &neighs);
+ ie.conf_form = neighs << 1;
+ if (vap->iv_meshflags & IEEE80211_MFLAGS_MP)
+ ie.conf_form |= IEEE80211_MESHCONF_FORM_MP;
+ if (vap->iv_meshflags & IEEE80211_MFLAGS_AP)
+ ie.conf_cap |= IEEE80211_MESHCONF_CAP_AP;
+ if (vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)
+ ie.conf_cap |= IEEE80211_MESHCONF_CAP_FWRD;
+
memcpy(frm, &ie, sizeof(ie));
return frm + sizeof(ie);
@@ -1281,15 +1308,28 @@ mesh_ioctl_get80211(struct ieee80211vap
int error;
uint8_t tmpmeshid[IEEE80211_NWID_LEN];
+ if (vap->iv_opmode != IEEE80211_M_MBSS)
+ return EINVAL;
+
error = 0;
switch (ireq->i_type) {
case IEEE80211_IOC_MESH_ID:
- if (vap->iv_opmode != IEEE80211_M_MBSS)
- return EINVAL;
ireq->i_len = vap->iv_meshidlen;
memcpy(tmpmeshid, vap->iv_meshid, ireq->i_len);
error = copyout(tmpmeshid, ireq->i_data, ireq->i_len);
break;
+ case IEEE80211_IOC_MESH_AP:
+ if (ireq->i_val)
+ vap->iv_meshflags |= IEEE80211_MFLAGS_AP;
+ else
+ vap->iv_meshflags &= ~IEEE80211_MFLAGS_AP;
+ break;
+ case IEEE80211_IOC_MESH_FWRD:
+ if (ireq->i_val)
+ vap->iv_meshflags |= IEEE80211_MFLAGS_FWRD;
+ else
+ vap->iv_meshflags &= ~IEEE80211_MFLAGS_FWRD;
+ break;
default:
return ENOSYS;
}
@@ -1304,6 +1344,9 @@ mesh_ioctl_set80211(struct ieee80211vap
int error;
uint8_t tmpmeshid[IEEE80211_NWID_LEN];
+ if (vap->iv_opmode != IEEE80211_M_MBSS)
+ return EINVAL;
+
error = 0;
switch (ireq->i_type) {
case IEEE80211_IOC_MESH_ID:
@@ -1316,6 +1359,12 @@ mesh_ioctl_set80211(struct ieee80211vap
vap->iv_meshidlen = ireq->i_len;
memcpy(vap->iv_meshid, tmpmeshid, ireq->i_len);
break;
+ case IEEE80211_IOC_MESH_AP:
+ ireq->i_val = vap->iv_meshflags & IEEE80211_MFLAGS_AP;
+ break;
+ case IEEE80211_IOC_MESH_FWRD:
+ ireq->i_val = vap->iv_meshflags & IEEE80211_MFLAGS_FWRD;
+ break;
default:
return ENOSYS;
}
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.h Tue Jun 9 14:26:23 2009 (r193833)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.h Tue Jun 9 15:03:22 2009 (r193834)
@@ -56,17 +56,17 @@ struct ieee80211_meshconf_ie {
IEEE80211_MESHCONF_NULL_VALUE }
/* Hybrid Wireless Mesh Protocol */
#define IEEE80211_MESHCONF_HWMP_OUI 0x00, 0x0f, 0xac
-#define IEEE80211_MESHCONF_HWMP_VALUE 0xff /* XXX Linux */
+#define IEEE80211_MESHCONF_HWMP_VALUE 0x00
#define IEEE80211_MESHCONF_HWMP { IEEE80211_MESHCONF_HWMP_OUI, \
IEEE80211_MESHCONF_HWMP_VALUE }
/* Airtime Link Metric */
#define IEEE80211_MESHCONF_AIRTIME_OUI 0x00, 0x0f, 0xac
-#define IEEE80211_MESHCONF_AIRTIME_VALUE 0xff /* XXX Linux */
+#define IEEE80211_MESHCONF_AIRTIME_VALUE 0x00
#define IEEE80211_MESHCONF_AIRTIME { IEEE80211_MESHCONF_AIRTIME_OUI, \
IEEE80211_MESHCONF_AIRTIME_VALUE }
/* Congestion Control Signaling */
#define IEEE80211_MESHCONF_CCSIG_OUI 0x00, 0x0f, 0xac
-#define IEEE80211_MESHCONF_CCSIG_VALUE 0xff /* XXX Linux */
+#define IEEE80211_MESHCONF_CCSIG_VALUE 0x00
#define IEEE80211_MESHCONF_CCSIG { IEEE80211_MESHCONF_CCSIG_OUI,\
IEEE80211_MESHCONF_CCSIG_VALUE }
/* Neighbour Offset */
@@ -84,7 +84,7 @@ struct ieee80211_meshconf_ie {
#define IEEE80211_MESHCONF_CAP_AP 0x01 /* Accepting Peers */
#define IEEE80211_MESHCONF_CAP_MCCAS 0x02 /* MCCA supported */
#define IEEE80211_MESHCONF_CAP_MCCAE 0x04 /* MCCA enabled */
-#define IEEE80211_MESHCONF_CAP_FRWD 0x08 /* forwarding enabled */
+#define IEEE80211_MESHCONF_CAP_FWRD 0x08 /* forwarding enabled */
#define IEEE80211_MESHCONF_CAP_BTR 0x10 /* Beacon Timing Report Enab */
#define IEEE80211_MESHCONF_CAP_TBTTA 0x20 /* TBTT Adj. Enabled */
#define IEEE80211_MESHCONF_CAP_PSL 0x40 /* Power Save Level */
Modified: projects/mesh11s/sys/net80211/ieee80211_var.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_var.h Tue Jun 9 14:26:23 2009 (r193833)
+++ projects/mesh11s/sys/net80211/ieee80211_var.h Tue Jun 9 15:03:22 2009 (r193834)
@@ -393,9 +393,14 @@ struct ieee80211vap {
uint8_t iv_dtim_count; /* DTIM count from last bcn */
/* set/unset aid pwrsav state */
int iv_csa_count; /* count for doing CSA */
+
int iv_meshidlen;
uint8_t iv_meshid[IEEE80211_MESHID_LEN];
- uint32_t iv_meshseq;
+ uint32_t iv_meshseq; /* seq no for meshcntl */
+#define IEEE80211_MFLAGS_AP 0x01 /* accept peers */
+#define IEEE80211_MFLAGS_MP 0x02 /* mesh portal role */
+#define IEEE80211_MFLAGS_FWRD 0x04 /* forward packets */
+ uint8_t iv_meshflags;
struct ieee80211_node *iv_bss; /* information for this node */
struct ieee80211_txparam iv_txparms[IEEE80211_MODE_MAX];
More information about the svn-src-projects
mailing list