svn commit: r192641 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Sat May 23 16:02:20 UTC 2009
Author: rpaulo
Date: Sat May 23 16:02:19 2009
New Revision: 192641
URL: http://svn.freebsd.org/changeset/base/192641
Log:
Move path handling code to HWMP module.
Sponsored by: The FreeBSD Foundation
Modified:
projects/mesh11s/sys/net80211/ieee80211_hwmp.c
projects/mesh11s/sys/net80211/ieee80211_hwmp.h
projects/mesh11s/sys/net80211/ieee80211_mesh.c
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Sat May 23 16:01:58 2009 (r192640)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Sat May 23 16:02:19 2009 (r192641)
@@ -62,21 +62,21 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_input.h>
-int ieee80211_hwmp_maxhops = 31;
-int ieee80211_hwmp_maxhopstime = 500;
-int ieee80211_hwmp_maxprepretries = 3;
-int ieee80211_hwmp_prepminint = 100;
-int ieee80211_hwmp_perrminint = 100;
-int ieee80211_hwmp_roottimeout = 5000;
-int ieee80211_hwmp_pathtimeout = 5000;
-int ieee80211_hwmp_rootmode = 0;
-int ieee80211_hwmp_pathtoroottimeout = 5000;
-int ieee80211_hmwp_rootint = 2000;
-int ieee80211_hwmp_rannint = 1000;
-int ieee80211_hwmp_targetonly = 1; /* reply to PREQs if we have the info */
-int ieee80211_hwmp_replyforward = 1; /* propagate PREQs */
-int ieee80211_hwmp_pathmaintenance = 2000;
-int ieee80211_hwmp_confirmint = 2000;
+static int ieee80211_hwmp_maxhops = 31;
+static int ieee80211_hwmp_maxhopstime = 500;
+static int ieee80211_hwmp_maxprepretries = 3;
+static int ieee80211_hwmp_prepminint = 100;
+static int ieee80211_hwmp_perrminint = 100;
+static int ieee80211_hwmp_roottimeout = 5000;
+static int ieee80211_hwmp_pathtimeout = 5000;
+static int ieee80211_hwmp_rootmode = 0;
+static int ieee80211_hwmp_pathtoroottimeout = 5000;
+static int ieee80211_hmwp_rootint = 2000;
+static int ieee80211_hwmp_rannint = 1000;
+static int ieee80211_hwmp_targetonly = 1;/* reply to PREQs automatically */
+static int ieee80211_hwmp_replyforward = 1; /* propagate PREQs */
+static int ieee80211_hwmp_pathmaintenance = 2000;
+static int ieee80211_hwmp_confirmint = 2000;
SYSCTL_NODE(_net_wlan, OID_AUTO, hwmp, CTLFLAG_RD, 0,
"IEEE 802.11s HWMP parameters");
@@ -86,3 +86,121 @@ SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, max
SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, rootmode, CTLTYPE_INT | CTLFLAG_RW,
&ieee80211_hwmp_rootmode, 0, "Root Mesh Point Node");
#endif
+
+
+void
+ieee80211_hwmp_recv_action(struct ieee80211vap *vap, struct ieee80211_node *ni,
+ struct mbuf *m)
+{
+ struct ieee80211_frame *wh;
+ uint8_t *frm, *efrm;
+ struct ieee80211_meshpreq_ie *meshpreq = NULL;
+ struct ieee80211_meshprep_ie *meshprep = NULL;
+ struct ieee80211_meshperr_ie *meshperr = NULL;
+
+ wh = mtod(m0, struct ieee80211_frame *);
+ ia = (struct ieee80211_action *) &wh[1];
+ frm = (uint8_t *)&wh[1] + sizeof(struct ieee80211_action);
+ efrm = mtod(m0, uint8_t *) + m0->m_len;
+
+ KASSERT(ia->ia_category == IEEE80211_ACTION_CAT_MESHPATH);
+
+ while (efrm - frm > 1) {
+ IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1] + 2, return);
+ switch (*frm) {
+ case IEEE80211_ELEMID_MESHPREQ:
+ meshpreq = (struct ieee80211_meshpreq_ie *) frm;
+ meshpreq->preq_id = LE_READ_4(&meshpreq->preq_id);
+ meshpreq->preq_origseq =
+ LE_READ_4(&meshpreq->preq_origseq);
+ meshpreq->preq_lifetime =
+ LE_READ_4(&meshpreq->preq_lifetime);
+ meshpreq->preq_metric =
+ LE_READ_4(&meshpreq->preq_metric);
+ break;
+ case IEEE80211_ELEMID_MESHPREP:
+ meshprep = (struct ieee80211_meshprep_ie *) frm;
+ meshprep->prep_targetseq =
+ LE_READ_4(&meshprep->prep_targetseq);
+ meshprep->prep_lifetime =
+ LE_READ_4(&meshprep->prep_lifetime);
+ meshprep->prep_metric =
+ LE_READ_4(&meshprep->prep_metric);
+ meshprep->prep_origseq =
+ LE_READ_4(&meshprep->prep_origseq);
+ break;
+ case IEEE80211_ELEMID_MESHPERR:
+ meshperr = (struct ieee80211_meshperr_ie *) frm;
+ break;
+ }
+ frm += frm[1] + 2;
+ }
+
+ switch (ia->ia_action) {
+ case IEEE80211_ACTION_MESHPATH_REQ:
+ if (meshpreq == NULL) {
+ IEEE80211_DISCARD(vap,
+ IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH,
+ wh, NULL, "%s", "preq without IE");
+ vap->iv_stats.is_rx_mgtdiscard++;
+ return;
+ }
+ /*
+ * Is the peer trying to find us?
+ */
+ if (IEEE80211_ADDR_EQ(vap->iv_myaddr,
+ meshpreq->preq_targets[0].target_addr)) {
+ struct ieee80211_meshprep_ie prep;
+ /*
+ * Build and send a path reply frame.
+ */
+ prep.prep_flags = 0;
+ prep.prep_hopcount = 0;
+ prep.prep_ttl = ieee80211_mesh_ttl;
+ IEEE80211_ADDR_COPY(prep.prep_targetaddr,
+ meshpreq->preq_targets[0].target_addr);
+ prep.prep_targetseq = meshpreq->preq_origseq;
+ prep.prep_lifetime = 5000;
+ prep.prep_metric = 0;
+ IEEE80211_ADDR_COPY(prep.prep_origaddr,
+ vap->iv_myaddr);
+ prep.prep_origseq = 1;
+ vargs.ptrarg = &prep;
+ ieee80211_send_action(ni,
+ IEEE80211_ACTION_CAT_MESHPATH,
+ IEEE80211_ACTION_MESHPATH_REP,
+ vargs);
+ }
+ break;
+ case IEEE80211_ACTION_MESHPATH_REP:
+ break;
+ case IEEE80211_ACTION_MESHPATH_ERR:
+ break;
+ }
+
+}
+
+
+/*
+ * Add a Mesh Path Reply IE to a frame.
+ */
+uint8_t *
+ieee80211_add_meshprep(uint8_t *frm, struct ieee80211_meshprep_ie *prep)
+{
+
+ *frm++ = IEEE80211_ELEMID_MESHPREP;
+ *frm++ = sizeof(struct ieee80211_meshprep_ie) - 2;
+ *frm++ = prep->prep_flags;
+ *frm++ = prep->prep_hopcount;
+ *frm++ = prep->prep_ttl;
+ IEEE80211_ADDR_COPY(frm, prep->prep_targetaddr);
+ frm += 6;
+ ADDWORD(frm, prep->prep_targetseq);
+ ADDWORD(frm, prep->prep_lifetime);
+ ADDWORD(frm, prep->prep_metric);
+ IEEE80211_ADDR_COPY(frm, prep->prep_origaddr);
+ frm += 6;
+ ADDWORD(frm, prep->prep_origseq);
+
+ return frm;
+}
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.h Sat May 23 16:01:58 2009 (r192640)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.h Sat May 23 16:02:19 2009 (r192641)
@@ -31,9 +31,15 @@
#ifndef _NET80211_IEEE80211_HWMP_H_
#define _NET80211_IEEE80211_HWMP_H_
-#if 0
-void ieee80211_hwmp_recv_action(struct ieee80211vap *,
+void ieee80211_hwmp_recv_action(struct ieee80211vap *,
struct ieee80211_node *, struct mbuf *);
+uint8_t * ieee80211_add_meshprep(uint8_t *,
+ struct ieee80211_meshprep_ie *);
+#if 0
+uint8_t * ieee80211_add_meshpreq(uint8_t *,
+ struct ieee80211_meshpreq_ie *);
+uint8_t * ieee80211_add_meshperr(uint8_t *,
+ struct ieee80211_meshperr_ie *);
#endif
#endif /* _NET80211_IEEE80211_HWMP_H_ */
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c Sat May 23 16:01:58 2009 (r192640)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Sat May 23 16:02:19 2009 (r192641)
@@ -640,7 +640,7 @@ mesh_recv_action(struct ieee80211_node *
struct ieee80211_meshperr_ie *meshperr = NULL;
uint8_t *frm, *efrm;
union ieee80211_send_action_args vargs;
-
+
wh = mtod(m0, struct ieee80211_frame *);
ia = (struct ieee80211_action *) &wh[1];
frm = (uint8_t *)&wh[1] + sizeof(struct ieee80211_action);
@@ -672,30 +672,6 @@ mesh_recv_action(struct ieee80211_node *
meshpeer->peer_rcode =
LE_READ_2(&meshpeer->peer_rcode);
break;
- case IEEE80211_ELEMID_MESHPREQ:
- meshpreq = (struct ieee80211_meshpreq_ie *) frm;
- meshpreq->preq_id = LE_READ_4(&meshpreq->preq_id);
- meshpreq->preq_origseq =
- LE_READ_4(&meshpreq->preq_origseq);
- meshpreq->preq_lifetime =
- LE_READ_4(&meshpreq->preq_lifetime);
- meshpreq->preq_metric =
- LE_READ_4(&meshpreq->preq_metric);
- break;
- case IEEE80211_ELEMID_MESHPREP:
- meshprep = (struct ieee80211_meshprep_ie *) frm;
- meshprep->prep_targetseq =
- LE_READ_4(&meshprep->prep_targetseq);
- meshprep->prep_lifetime =
- LE_READ_4(&meshprep->prep_lifetime);
- meshprep->prep_metric =
- LE_READ_4(&meshprep->prep_metric);
- meshprep->prep_origseq =
- LE_READ_4(&meshprep->prep_origseq);
- break;
- case IEEE80211_ELEMID_MESHPERR:
- meshperr = (struct ieee80211_meshperr_ie *) frm;
- break;
}
frm += frm[1] + 2;
}
@@ -706,7 +682,7 @@ mesh_recv_action(struct ieee80211_node *
*/
case IEEE80211_ACTION_CAT_MESHPEERING:
/*
- * Check if we agree on the required fields.
+ * Check if we agree on the required fields.
*/
if (mesh_verify_meshid(vap, meshid) ||
mesh_verify_meshconf(vap, meshconf) ||
@@ -867,45 +843,11 @@ mesh_recv_action(struct ieee80211_node *
break;
}
break;
+ /*
+ * Mesh Path action frames are handled by the HWMP module.
+ */
case IEEE80211_ACTION_CAT_MESHPATH:
- switch (ia->ia_action) {
- case IEEE80211_ACTION_MESHPATH_REQ:
- if (meshpreq == NULL) {
- IEEE80211_DISCARD(vap,
- IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH,
- wh, NULL, "%s", "preq without IE");
- vap->iv_stats.is_rx_mgtdiscard++;
- return;
- }
- /*
- * Is the peer trying to find us?
- */
- if (IEEE80211_ADDR_EQ(vap->iv_myaddr,
- meshpreq->preq_targets[0].target_addr)) {
- struct ieee80211_meshprep_ie prep;
- /*
- * Build and send a path reply frame.
- */
- prep.prep_flags = 0;
- prep.prep_hopcount = 0;
- prep.prep_ttl = ieee80211_mesh_ttl;
- IEEE80211_ADDR_COPY(prep.prep_targetaddr,
- meshpreq->preq_targets[0].target_addr);
- prep.prep_targetseq = meshpreq->preq_origseq;
- prep.prep_lifetime = 5000;
- prep.prep_metric = 0;
- IEEE80211_ADDR_COPY(prep.prep_origaddr,
- vap->iv_myaddr);
- prep.prep_origseq = 1;
-
- vargs.ptrarg = &prep;
- ieee80211_send_action(ni,
- IEEE80211_ACTION_CAT_MESHPATH,
- IEEE80211_ACTION_MESHPATH_REP,
- vargs);
- }
- break;
- }
+ ieee80211_hwmp_recv_action(vap, ni, m);
break;
/*
* Airtime link metric handling.
@@ -1166,30 +1108,6 @@ ieee80211_add_meshpeer(uint8_t *frm, uin
}
/*
- * Add a Mesh Path Reply IE to a frame.
- */
-uint8_t *
-ieee80211_add_meshprep(uint8_t *frm, struct ieee80211_meshprep_ie *prep)
-{
-
- *frm++ = IEEE80211_ELEMID_MESHPREP;
- *frm++ = sizeof(struct ieee80211_meshprep_ie) - 2;
- *frm++ = prep->prep_flags;
- *frm++ = prep->prep_hopcount;
- *frm++ = prep->prep_ttl;
- IEEE80211_ADDR_COPY(frm, prep->prep_targetaddr);
- frm += 6;
- ADDWORD(frm, prep->prep_targetseq);
- ADDWORD(frm, prep->prep_lifetime);
- ADDWORD(frm, prep->prep_metric);
- IEEE80211_ADDR_COPY(frm, prep->prep_origaddr);
- frm += 6;
- ADDWORD(frm, prep->prep_origseq);
-
- return frm;
-}
-
-/*
* Compute an Airtime Link Metric for the link with this node.
*
* Based on D3.0.
More information about the svn-src-projects
mailing list