svn commit: r193353 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Tue Jun 2 21:40:58 UTC 2009
Author: rpaulo
Date: Tue Jun 2 21:40:57 2009
New Revision: 193353
URL: http://svn.freebsd.org/changeset/base/193353
Log:
Fix previous commits.
Sponsored by: The FreeBSD Foundation
Modified:
projects/mesh11s/sys/net80211/ieee80211_hwmp.c
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Tue Jun 2 21:17:56 2009 (r193352)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Tue Jun 2 21:40:57 2009 (r193353)
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
static int ieee80211_hwmp_send_action(struct ieee80211_node *,
const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
- const uint8_t *, size_t);
+ uint8_t *, size_t);
static uint8_t *hwmp_add_meshpreq(uint8_t *,
const struct ieee80211_meshpreq_ie *);
static uint8_t *hwmp_add_meshprep(uint8_t *,
@@ -110,7 +110,7 @@ static int ieee80211_hwmp_pathtoroottime
static int ieee80211_hmwp_rootint = 2000;
static int ieee80211_hwmp_rannint = 1000;
#endif
-static int ieee80211_hwmp_targetonly = 1;
+static int ieee80211_hwmp_targetonly = 0;
static int ieee80211_hwmp_replyforward = 1;
#ifdef notyet
static int ieee80211_hwmp_pathmaintenance = 2000;
@@ -281,9 +281,9 @@ ieee80211_hwmp_recv_action(struct ieee80
static int
ieee80211_hwmp_send_action(struct ieee80211_node *ni,
- const uint8_t addr1[IEEE80211_ADDR_LEN],
- const uint8_t addr2[IEEE80211_ADDR_LEN],
- const uint8_t *ie, size_t len)
+ const uint8_t sa[IEEE80211_ADDR_LEN],
+ const uint8_t da[IEEE80211_ADDR_LEN],
+ uint8_t *ie, size_t len)
{
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
@@ -325,22 +325,22 @@ ieee80211_hwmp_send_action(struct ieee80
case IEEE80211_ELEMID_MESHPREQ:
*frm++ = IEEE80211_ACTION_MESHPATH_REQ;
frm = hwmp_add_meshpreq(frm,
- (struct ieee80211_meshpreq_ie *)&ie);
+ (struct ieee80211_meshpreq_ie *)ie);
break;
case IEEE80211_ELEMID_MESHPREP:
*frm++ = IEEE80211_ACTION_MESHPATH_REP;
frm = hwmp_add_meshprep(frm,
- (struct ieee80211_meshprep_ie *)&ie);
+ (struct ieee80211_meshprep_ie *)ie);
break;
case IEEE80211_ELEMID_MESHPERR:
*frm++ = IEEE80211_ACTION_MESHPATH_ERR;
frm = hwmp_add_meshperr(frm,
- (struct ieee80211_meshperr_ie *)&ie);
+ (struct ieee80211_meshperr_ie *)ie);
break;
case IEEE80211_ELEMID_MESHRANN:
*frm++ = IEEE80211_ACTION_MESHPATH_RANN;
frm = hwmp_add_meshrann(frm,
- (struct ieee80211_meshrann_ie *)&ie);
+ (struct ieee80211_meshrann_ie *)ie);
break;
}
@@ -353,7 +353,7 @@ ieee80211_hwmp_send_action(struct ieee80
}
ieee80211_send_setup(ni, m,
IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_ACTION,
- IEEE80211_NONQOS_TID, addr1, addr2, addr2);
+ IEEE80211_NONQOS_TID, sa, da, sa);
m->m_flags |= M_ENCAP; /* mark encapsulated */
IEEE80211_NODE_STAT(ni, tx_mgmt);
@@ -476,6 +476,9 @@ hwmp_recv_preq(struct ieee80211vap *vap,
struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
struct ieee80211_hwmp_fi *fi = NULL;
+ IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+ "received PREQ, source %s", ether_sprintf(preq->preq_origaddr));
+
/*
* Acceptance criteria: if the PREQ is not for us and
* forwarding is disabled, discard this PREQ.
@@ -505,6 +508,9 @@ hwmp_recv_preq(struct ieee80211vap *vap,
*/
if (IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0))) {
struct ieee80211_meshprep_ie prep;
+
+ IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+ "replying to %s", ether_sprintf(preq->preq_origaddr));
/*
* Build and send a PREP frame.
*/
@@ -519,7 +525,7 @@ hwmp_recv_preq(struct ieee80211vap *vap,
IEEE80211_ADDR_COPY(prep.prep_origaddr, vap->iv_myaddr);
prep.prep_origseq = hs->hs_seq++;
/* XXX addr1 = next hop */
- hwmp_send_prep(ni, preq->preq_origaddr, vap->iv_myaddr, &prep);
+ hwmp_send_prep(ni, vap->iv_myaddr, preq->preq_origaddr, &prep);
return;
}
@@ -532,6 +538,7 @@ hwmp_recv_preq(struct ieee80211vap *vap,
!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) {
struct ieee80211_meshpreq_ie ppreq; /* propagated PREQ */
+
memcpy(&ppreq, preq, sizeof(ppreq));
/*
* Can we do an intermediate path reply?
@@ -539,6 +546,9 @@ hwmp_recv_preq(struct ieee80211vap *vap,
if (fi != NULL) {
struct ieee80211_meshprep_ie prep;
+ IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+ "replying and forwarding PREQ from %s",
+ ether_sprintf(preq->preq_origaddr));
/*
* Propagate the original PREQ.
*/
@@ -573,6 +583,9 @@ hwmp_recv_preq(struct ieee80211vap *vap,
hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr,
&prep);
} else {
+ IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+ "forwarding PREQ from %s",
+ ether_sprintf(preq->preq_origaddr));
/*
* We have no information about this path,
* propagate the PREQ.
@@ -612,21 +625,23 @@ hwmp_recv_preq(struct ieee80211vap *vap,
static inline int
hwmp_send_preq(struct ieee80211_node *ni,
- const uint8_t addr1[IEEE80211_ADDR_LEN],
- const uint8_t addr2[IEEE80211_ADDR_LEN],
+ const uint8_t sa[IEEE80211_ADDR_LEN],
+ const uint8_t da[IEEE80211_ADDR_LEN],
struct ieee80211_meshpreq_ie *preq)
{
/*
* mesh preq action frame format
- * [6] addr1
- * [6] addr2
- * [6] addr3 = addr2
+ * [6] da
+ * [6] sa
+ * [6] addr3 = sa
* [1] action
* [1] category
* [tlv] mesh path request
*/
- return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&preq,
- sizeof(*preq));
+ preq->preq_ie = IEEE80211_ELEMID_MESHPREQ;
+
+ return ieee80211_hwmp_send_action(ni, sa, da, (uint8_t *)preq,
+ sizeof(struct ieee80211_meshpreq_ie));
}
static void
@@ -660,8 +675,7 @@ hwmp_recv_prep(struct ieee80211vap *vap,
pprep.prep_ttl -= 1;
pprep.prep_metric += ieee80211_airtime_calc(ni);
IEEE80211_ADDR_COPY(pprep.prep_origaddr, vap->iv_myaddr);
- hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr,
- &pprep);
+ hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr, &pprep);
/*
* XXX: Step 5: update the precursor list.
*/
@@ -683,21 +697,23 @@ hwmp_recv_prep(struct ieee80211vap *vap,
static inline int
hwmp_send_prep(struct ieee80211_node *ni,
- const uint8_t addr1[IEEE80211_ADDR_LEN],
- const uint8_t addr2[IEEE80211_ADDR_LEN],
+ const uint8_t sa[IEEE80211_ADDR_LEN],
+ const uint8_t da[IEEE80211_ADDR_LEN],
struct ieee80211_meshprep_ie *prep)
{
/*
* mesh prep action frame format
- * [6] addr1
- * [6] addr2
- * [6] addr3 = addr2
+ * [6] da
+ * [6] sa
+ * [6] addr3 = sa
* [1] action
* [1] category
* [tlv] mesh path reply
*/
- return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&prep,
- sizeof(*prep));
+ prep->prep_ie = IEEE80211_ELEMID_MESHPREP;
+
+ return ieee80211_hwmp_send_action(ni, sa, da, (uint8_t *)prep,
+ sizeof(struct ieee80211_meshprep_ie));
}
#define PERR_DADDR(n) perr->perr_dests[n].dest_addr
@@ -737,21 +753,21 @@ hwmp_recv_perr(struct ieee80211vap *vap,
static inline int
hwmp_send_perr(struct ieee80211_node *ni,
- const uint8_t addr1[IEEE80211_ADDR_LEN],
- const uint8_t addr2[IEEE80211_ADDR_LEN],
+ const uint8_t sa[IEEE80211_ADDR_LEN],
+ const uint8_t da[IEEE80211_ADDR_LEN],
struct ieee80211_meshperr_ie *perr)
{
/*
* mesh perr action frame format
- * [6] addr1
- * [6] addr2
- * [6] addr3 = addr2
+ * [6] da
+ * [6] sa
+ * [6] addr3 = sa
* [1] action
* [1] category
* [tlv] mesh path error
*/
- return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&perr,
- sizeof(*perr));
+ return ieee80211_hwmp_send_action(ni, sa, da, (uint8_t *)perr,
+ sizeof(struct ieee80211_meshperr_ie));
}
static void
@@ -791,8 +807,7 @@ hwmp_recv_rann(struct ieee80211vap *vap,
preq.preq_targets[0].target_seq = rann->rann_seq;
preq.preq_lifetime = ieee80211_hwmp_roottimeout;
preq.preq_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
- hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr,
- &preq);
+ 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.
@@ -804,27 +819,27 @@ hwmp_recv_rann(struct ieee80211vap *vap,
prann.rann_hopcount += 1;
prann.rann_ttl -= 1;
prann.rann_metric += ieee80211_airtime_calc(ni);
- hwmp_send_rann(ni, broadcastaddr, vap->iv_myaddr, &prann);
+ hwmp_send_rann(ni, vap->iv_myaddr, broadcastaddr, &prann);
}
}
static inline int
hwmp_send_rann(struct ieee80211_node *ni,
- const uint8_t addr1[IEEE80211_ADDR_LEN],
- const uint8_t addr2[IEEE80211_ADDR_LEN],
+ const uint8_t sa[IEEE80211_ADDR_LEN],
+ const uint8_t da[IEEE80211_ADDR_LEN],
struct ieee80211_meshrann_ie *rann)
{
/*
* mesh rann action frame format
- * [6] addr1
- * [6] addr2
- * [6] addr3 = addr2
+ * [6] da
+ * [6] sa
+ * [6] addr3 = sa
* [1] action
* [1] category
* [tlv] root annoucement
*/
- return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&rann,
- sizeof(*rann));
+ return ieee80211_hwmp_send_action(ni, sa, da, (uint8_t *)rann,
+ sizeof(struct ieee80211_meshrann_ie));
}
#define PREQ_TFLAGS(n) preq.preq_targets[n].target_flags
@@ -843,6 +858,12 @@ ieee80211_hwmp_discover(struct ieee80211
KASSERT(vap->iv_opmode == IEEE80211_M_MBSS,
("not a mesh vap, opmode %d", vap->iv_opmode));
+ if (IEEE80211_IS_MULTICAST(dest))
+ return ieee80211_find_txnode(vap, dest);
+
+ IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, dest,
+ "%s", "initiating path discovery");
+
mtx_lock(&hs->hs_lock);
TAILQ_FOREACH(fi, &hs->hs_head, fi_next) {
if (IEEE80211_ADDR_EQ(fi->fi_dest, dest)) {
@@ -850,43 +871,54 @@ ieee80211_hwmp_discover(struct ieee80211
/* XXX check preq retries */
sendpreq = 1;
unknowndst = 1;
- break;
}
+ break;
}
}
mtx_unlock(&hs->hs_lock);
+ if (fi == NULL) {
+ fi = malloc(sizeof(struct ieee80211_hwmp_fi), M_80211_VAP,
+ M_NOWAIT | M_ZERO);
+ memcpy(fi->fi_dest, dest, IEEE80211_ADDR_LEN);
+ fi->fi_seq = ++hs->hs_seq;
+ fi->fi_metric = IEEE80211_MESHLMETRIC_INITIALVAL;
+ fi->fi_lifetime = ieee80211_hwmp_pathtimeout;
+ mtx_lock(&hs->hs_lock);
+ TAILQ_INSERT_TAIL(&hs->hs_head, fi, fi_next);
+ mtx_unlock(&hs->hs_lock);
+ sendpreq = 1;
+ unknowndst = 1;
+ }
+
if (sendpreq) {
/*
- * Try to discover the path for this
- * node.
+ * Try to discover the path for this node.
*/
+ preq.preq_flags = 0;
preq.preq_hopcount = 0;
preq.preq_ttl = ieee80211_mesh_ttl;
preq.preq_id = ++hs->hs_preqid;
- IEEE80211_ADDR_COPY(preq.preq_origaddr,
- vap->iv_myaddr);
- preq.preq_origseq = ++hs->hs_seq;
- preq.preq_lifetime =
- ieee80211_hwmp_pathtimeout;
- preq.preq_metric =
- IEEE80211_MESHLMETRIC_INITIALVAL;
+ IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr);
+ preq.preq_origseq = fi->fi_seq;
+ preq.preq_lifetime = fi->fi_lifetime;
+ preq.preq_metric = fi->fi_metric;
preq.preq_tcount = 1;
IEEE80211_ADDR_COPY(PREQ_TADDR(0), dest);
if (ieee80211_hwmp_targetonly)
PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_TO;
if (ieee80211_hwmp_replyforward)
PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_RF;
- if (unknowndst)
+ if (unknowndst) {
PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_USN;
- else
+ PREQ_TSEQ(0) = 0;
+ } else
PREQ_TSEQ(0) = fi->fi_seq;
hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr,
&preq);
} else
return ieee80211_find_txnode(vap, fi->fi_nexthop);
- /* XXX */
return vap->iv_bss;
}
#undef PREQ_TFLAGS
More information about the svn-src-projects
mailing list