svn commit: r195304 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Fri Jul 3 11:18:09 UTC 2009
Author: rpaulo
Date: Fri Jul 3 11:18:08 2009
New Revision: 195304
URL: http://svn.freebsd.org/changeset/base/195304
Log:
Finish RANN implementation.
Sponsored by: The FreeBSD Foundation
Modified:
projects/mesh11s/sys/net80211/ieee80211_hwmp.c
projects/mesh11s/sys/net80211/ieee80211_ioctl.h
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Fri Jul 3 04:39:18 2009 (r195303)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Fri Jul 3 11:18:08 2009 (r195304)
@@ -86,6 +86,7 @@ static uint8_t *hwmp_add_meshrann(uint8_
const struct ieee80211_meshrann_ie *);
static void hwmp_rootmode_setup(struct ieee80211vap *);
static void hwmp_rootmode_cb(void *);
+static void hwmp_rootmode_rann_cb(void *);
static void hwmp_recv_preq(struct ieee80211vap *, struct ieee80211_node *,
const struct ieee80211_frame *, const struct ieee80211_meshpreq_ie *);
static int hwmp_send_preq(struct ieee80211_node *,
@@ -117,15 +118,15 @@ static const struct timeval ieee80211_hw
static const struct timeval ieee80211_hwmp_roottimeout = { 5, 0 };
static const struct timeval ieee80211_hwmp_pathtimeout = { 5, 0 };
static const struct timeval ieee80211_hwmp_pathtoroottimeout = { 5, 0 };
-static const struct timeval ieee80211_hmwp_rootint = { 2, 0 };
+static const struct timeval ieee80211_hwmp_rootint = { 2, 0 };
static const struct timeval ieee80211_hwmp_rannint = { 1, 0 };
static const struct timeval ieee80211_hwmp_pathmaintenanceint = { 2, 0 };
static const struct timeval ieee80211_hwmp_confirmint = { 2, 0 };
#define timeval2msecs(tv) (tv.tv_sec * 1000 + tv.tv_usec / 1000)
-#define HWMP_ROOTMODEINT msecs_to_ticks(timeval2msecs(ieee80211_hmwp_rootint))
-#define HWMP_RANNMODEINT msecs_to_ticks(timeval2msecs(ieee80211_hmwp_rannint))
+#define HWMP_ROOTMODEINT msecs_to_ticks(timeval2msecs(ieee80211_hwmp_rootint))
+#define HWMP_RANNMODEINT msecs_to_ticks(timeval2msecs(ieee80211_hwmp_rannint))
#define HWMP_LOCK(hs) mtx_lock(&(hs)->hs_lock)
#define HWMP_UNLOCK(hs) mtx_unlock(&(hs)->hs_lock)
@@ -599,11 +600,20 @@ hwmp_rootmode_setup(struct ieee80211vap
{
struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
- if (hs->hs_rootmode != IEEE80211_HWMP_ROOTMODE_DISABLED)
+ switch (hs->hs_rootmode) {
+ case IEEE80211_HWMP_ROOTMODE_DISABLED:
+ callout_drain(&hs->hs_roottimer);
+ break;
+ case IEEE80211_HWMP_ROOTMODE_NORMAL:
+ case IEEE80211_HWMP_ROOTMODE_PROACTIVE:
callout_reset(&hs->hs_roottimer, HWMP_ROOTMODEINT,
hwmp_rootmode_cb, vap);
- else
- callout_stop(&hs->hs_roottimer);
+ break;
+ case IEEE80211_HWMP_ROOTMODE_RANN:
+ callout_reset(&hs->hs_roottimer, HWMP_RANNMODEINT,
+ hwmp_rootmode_rann_cb, vap);
+ break;
+ }
}
/*
@@ -647,6 +657,34 @@ hwmp_rootmode_cb(void *arg)
#undef PREQ_TADDR
#undef PREQ_TSEQ
+/*
+ * Send a Root Annoucement (RANN) to find all the nodes on the mesh. We are
+ * called when the vap is configured as a HWMP RANN root node.
+ */
+static void
+hwmp_rootmode_rann_cb(void *arg)
+{
+ struct ieee80211vap *vap = (struct ieee80211vap *)arg;
+ struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
+ struct ieee80211_meshrann_ie rann;
+
+ IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, vap->iv_bss,
+ "%s", "sending broadcast RANN");
+
+ /* XXX check portal role */
+ rann.rann_flags = 0;
+ rann.rann_hopcount = 0;
+ rann.rann_ttl = hs->hs_ttl;
+ IEEE80211_ADDR_COPY(rann.rann_addr, vap->iv_myaddr);
+ rann.rann_seq = ++hs->hs_seq;
+ rann.rann_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
+
+ vap->iv_stats.is_hwmp_rootrann++;
+ hwmp_send_rann(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &rann);
+ hwmp_rootmode_setup(vap);
+}
+
+
#define PREQ_TFLAGS(n) preq->preq_targets[n].target_flags
#define PREQ_TADDR(n) preq->preq_targets[n].target_addr
#define PREQ_TSEQ(n) preq->preq_targets[n].target_seq
@@ -1122,53 +1160,28 @@ hwmp_recv_rann(struct ieee80211vap *vap,
const struct ieee80211_frame *wh, const struct ieee80211_meshrann_ie *rann)
{
struct ieee80211_mesh_state *ms = vap->iv_mesh;
- struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
struct ieee80211_hwmp_route *rt = NULL;
+ struct ieee80211_meshrann_ie prann;
- /*
- * Acceptance criteria: check the HWMP sequence number
- * and the path metric is better than what we have.
- * XXX: TBD
- */
if (ni == vap->iv_bss ||
ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED)
return;
rt = hwmp_rt_find(vap, rann->rann_addr);
-
- if (rt == NULL) {
- struct ieee80211_meshpreq_ie preq;
-
- /*
- * Try to establish a path to this root mesh station.
- */
- preq.preq_flags = 0;
- preq.preq_hopcount = 0;
- preq.preq_ttl = hs->hs_ttl;
- IEEE80211_ADDR_COPY(&preq.preq_origaddr,
- vap->iv_myaddr);
- preq.preq_origseq = hs->hs_seq++;
- preq.preq_targets[0].target_flags |=
- IEEE80211_MESHPREQ_TFLAGS_TO;
- IEEE80211_ADDR_COPY(preq.preq_targets[0].target_addr,
- rann->rann_addr);
- preq.preq_targets[0].target_seq = rann->rann_seq;
- preq.preq_lifetime = timeval2msecs(ieee80211_hwmp_roottimeout);
- preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
- hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr, &preq);
/*
- * We have a path for this Root Mesh station, so
- * propagate the RANN if forwarding is enabled.
+ * Discover the path to the root mesh STA.
+ * If we already know it, propagate the RANN element.
*/
- } else if (rann->rann_ttl > 1 &&
+ if (rt == NULL)
+ ieee80211_hwmp_discover(vap, rann->rann_addr, NULL);
+ else if (rann->rann_seq > rt->rt_seq && rann->rann_ttl > 1 &&
(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) {
- struct ieee80211_meshrann_ie prann;
-
memcpy(&prann, rann, sizeof(prann));
prann.rann_hopcount += 1;
prann.rann_ttl -= 1;
prann.rann_metric += ieee80211_airtime_calc(ni);
- hwmp_send_rann(ni, vap->iv_myaddr, broadcastaddr, &prann);
+ hwmp_send_rann(vap->iv_bss, vap->iv_myaddr, broadcastaddr,
+ &prann);
}
}
@@ -1187,6 +1200,7 @@ hwmp_send_rann(struct ieee80211_node *ni
* [1] category
* [tlv] root annoucement
*/
+ rann->rann_ie = IEEE80211_ELEMID_MESHRANN;
return ieee80211_hwmp_send_action(ni, sa, da, (uint8_t *)rann,
sizeof(struct ieee80211_meshrann_ie));
}
Modified: projects/mesh11s/sys/net80211/ieee80211_ioctl.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_ioctl.h Fri Jul 3 04:39:18 2009 (r195303)
+++ projects/mesh11s/sys/net80211/ieee80211_ioctl.h Fri Jul 3 11:18:08 2009 (r195304)
@@ -234,8 +234,9 @@ struct ieee80211_stats {
uint32_t is_hwmp_wrongseq; /* wrong hwmp seq no. */
uint32_t is_hwmp_rootreqs; /* root PREQs sent */
+ uint32_t is_hwmp_rootrann; /* root RANNs sent */
- uint32_t is_spare[8];
+ uint32_t is_spare[7];
};
/*
More information about the svn-src-projects
mailing list