From 4ef618069cca4eaa62cd2dc2529e8fc7ca2db7d9 Mon Sep 17 00:00:00 2001 From: monthadar Date: Thu, 7 Feb 2013 21:24:52 +0000 Subject: Mark root mesh as gate when mesh gate flag set. * Add function ieee80211_mesh_mark_gate in ieee80211_mesh.h; * When received a proactive PREQ or RANN with corresponding mesh gate flag set, create a new entry in the known mesh gate list; Approved by: adrian (mentor) --- sys/net80211/ieee80211_hwmp.c | 19 +++++++++++++++++++ sys/net80211/ieee80211_mesh.c | 37 +++++++++++++++++++++++++++++++++++++ sys/net80211/ieee80211_mesh.h | 3 +++ 3 files changed, 59 insertions(+) (limited to 'sys') diff --git a/sys/net80211/ieee80211_hwmp.c b/sys/net80211/ieee80211_hwmp.c index 0305199..c740afd 100644 --- a/sys/net80211/ieee80211_hwmp.c +++ b/sys/net80211/ieee80211_hwmp.c @@ -1092,6 +1092,16 @@ hwmp_recv_preq(struct ieee80211vap *vap, struct ieee80211_node *ni, IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "root mesh station @ %6D", preq->preq_origaddr, ":"); + /* Check if root is a mesh gate, mark it */ + if (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_GATE) { + struct ieee80211_mesh_gate_route *gr; + + rtorig->rt_flags |= IEEE80211_MESHRT_FLAGS_GATE; + gr = ieee80211_mesh_mark_gate(vap, preq->preq_origaddr, + rtorig); + gr->gr_lastseq = 0; /* NOT GANN */ + } + /* * Reply with a PREP if we don't have a path to the root * or if the root sent us a proactive PREQ. @@ -1745,6 +1755,15 @@ hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_node *ni, } } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); + /* Check if root is a mesh gate, mark it */ + if (rann->rann_flags & IEEE80211_MESHRANN_FLAGS_GATE) { + struct ieee80211_mesh_gate_route *gr; + + rt->rt_flags |= IEEE80211_MESHRT_FLAGS_GATE; + gr = ieee80211_mesh_mark_gate(vap, rann->rann_addr, + rt); + gr->gr_lastseq = 0; /* NOT GANN */ + } /* discovery timeout */ ieee80211_mesh_rt_update(rt, ticks_to_msecs(ieee80211_hwmp_roottimeout)); diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c index 0c3d77d..9449c62 100644 --- a/sys/net80211/ieee80211_mesh.c +++ b/sys/net80211/ieee80211_mesh.c @@ -854,6 +854,43 @@ mesh_rt_cleanup_cb(void *arg) mesh_rt_cleanup_cb, vap); } +/* + * Mark a mesh STA as gate and return a pointer to it. + * If this is first time, we create a new gate route. + * Always update the path route to this mesh gate. + */ +struct ieee80211_mesh_gate_route * +ieee80211_mesh_mark_gate(struct ieee80211vap *vap, const uint8_t *addr, + struct ieee80211_mesh_route *rt) +{ + struct ieee80211_mesh_state *ms = vap->iv_mesh; + struct ieee80211_mesh_gate_route *gr = NULL, *next; + int found = 0; + + MESH_RT_LOCK(ms); + TAILQ_FOREACH_SAFE(gr, &ms->ms_known_gates, gr_next, next) { + if (IEEE80211_ADDR_EQ(gr->gr_addr, addr)) { + found = 1; + break; + } + } + + if (!found) { + /* New mesh gate add it to known table. */ + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, addr, + "%s", "stored new gate information from pro-PREQ."); + gr = malloc(ALIGN(sizeof(struct ieee80211_mesh_gate_route)), + M_80211_MESH_GT_RT, M_NOWAIT | M_ZERO); + IEEE80211_ADDR_COPY(gr->gr_addr, addr); + TAILQ_INSERT_TAIL(&ms->ms_known_gates, gr, gr_next); + } + gr->gr_route = rt; + /* TODO: link from path route to gate route */ + MESH_RT_UNLOCK(ms); + + return gr; +} + /* * Helper function to note the Mesh Peer Link FSM change. diff --git a/sys/net80211/ieee80211_mesh.h b/sys/net80211/ieee80211_mesh.h index 6d4a2f7..9023eee 100644 --- a/sys/net80211/ieee80211_mesh.h +++ b/sys/net80211/ieee80211_mesh.h @@ -566,6 +566,9 @@ void ieee80211_mesh_init_neighbor(struct ieee80211_node *, const struct ieee80211_scanparams *); void ieee80211_mesh_update_beacon(struct ieee80211vap *, struct ieee80211_beacon_offsets *); +struct ieee80211_mesh_gate_route * + ieee80211_mesh_mark_gate(struct ieee80211vap *, + const uint8_t *, struct ieee80211_mesh_route *); /* * Return non-zero if proxy operation is enabled. -- cgit v1.1