svn commit: r193046 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Fri May 29 18:48:19 UTC 2009
Author: rpaulo
Date: Fri May 29 18:48:18 2009
New Revision: 193046
URL: http://svn.freebsd.org/changeset/base/193046
Log:
* fill up the forwarding information table a little more
* explain root modes
* implement PREQ intermediate reply and PREQ propagation
* fix PREP propagation
* remove vap arg from ieee80211_airtime_calc()
Sponsored by: The FreeBSD Foundation
Modified:
projects/mesh11s/sys/net80211/ieee80211_hwmp.c
projects/mesh11s/sys/net80211/ieee80211_mesh.c
projects/mesh11s/sys/net80211/ieee80211_mesh.h
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Fri May 29 18:46:57 2009 (r193045)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Fri May 29 18:48:18 2009 (r193046)
@@ -65,15 +65,16 @@ __FBSDID("$FreeBSD$");
/*
* HWMP Forwarding Information table.
+ * XXX: this should be in vap
*/
struct ieee80211_hwmp_fi {
- TAILQ_ENTRY(ieee80211_hwmp_fi) fi_list;
- uint8_t fi_target[IEEE80211_ADDR_LEN];
+ TAILQ_ENTRY(ieee80211_hwmp_fi) fi_next;
+ uint8_t fi_dest[IEEE80211_ADDR_LEN];
ieee80211_seq fi_seq; /* HWMP sequence number */
- uint8_t fi_mnxthop[IEEE80211_ADDR_LEN];
+ uint8_t fi_nexthop[IEEE80211_ADDR_LEN];
uint32_t fi_metric; /* Path Metric */
uint32_t fi_nhops; /* Number of Hops */
- /* XXX percursor list */
+ uint8_t fi_prevhop[IEEE80211_ADDR_LEN];
uint32_t fi_lifetime;
};
TAILQ_HEAD(, ieee80211_hwmp_fi) ieee80211_hwmp_ft;
@@ -85,23 +86,23 @@ static void hwmp_recv_preq(struct ieee80
const struct ieee80211_meshpreq_ie *);
static int hwmp_send_preq(struct ieee80211_node *,
const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
- const struct ieee80211_meshpreq_ie *);
+ struct ieee80211_meshpreq_ie *);
static void hwmp_recv_prep(struct ieee80211vap *, struct ieee80211_node *,
const struct ieee80211_meshprep_ie *);
static int hwmp_send_prep(struct ieee80211_node *,
const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
- const struct ieee80211_meshprep_ie *);
+ struct ieee80211_meshprep_ie *);
static void hwmp_recv_perr(struct ieee80211vap *, struct ieee80211_node *,
const struct ieee80211_meshperr_ie *);
static int hwmp_send_perr(struct ieee80211_node *,
const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
- const struct ieee80211_meshperr_ie *);
+ struct ieee80211_meshperr_ie *);
static void hwmp_recv_rann(struct ieee80211vap *, struct ieee80211_node *,
- const struct ieee80211_meshrann_ie *);
+ const struct ieee80211_meshrann_ie *);
#ifdef notyet
static int hwmp_send_rann(struct ieee80211_node *,
const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN],
- const struct ieee80211_meshrann_ie *);
+ struct ieee80211_meshrann_ie *);
#endif
static int ieee80211_hwmp_maxhops = 31;
@@ -126,9 +127,12 @@ static int ieee80211_hwmp_confirmint = 2
/*
* Target Address set in a Proactive PREQ.
+ * XXX
*/
static const uint8_t proactiveaddr[IEEE80211_ADDR_LEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+static const uint8_t broadcastaddr[IEEE80211_ADDR_LEN] =
+ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
SYSCTL_NODE(_net_wlan, OID_AUTO, hwmp, CTLFLAG_RD, 0,
"IEEE 802.11s HWMP parameters");
@@ -140,7 +144,9 @@ SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, rep
&ieee80211_hwmp_replyforward, 0, "TBD");
#ifdef notyet
SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, rootmode, CTLTYPE_INT | CTLFLAG_RW,
- &ieee80211_hwmp_rootmode, 0, "Root Mesh Point Node");
+ &ieee80211_hwmp_rootmode, 0, "0 = Not a Root, "
+ "2 = Root with normal PREPs, 3 = Root with proactive PREPs, "
+ "3 = Root with RANNs");
#endif
extern int ieee80211_mesh_ttl;
@@ -374,6 +380,8 @@ static void
hwmp_recv_preq(struct ieee80211vap *vap, struct ieee80211_node *ni,
const struct ieee80211_meshpreq_ie *preq)
{
+ struct ieee80211_hwmp_fi *fi;
+
/*
* Acceptance criteria: if the PREQ is not for us and
* forwarding is disabled, discard this PREQ.
@@ -382,6 +390,14 @@ hwmp_recv_preq(struct ieee80211vap *vap,
!ieee80211_mesh_forwarding)
return;
+ fi = NULL;
+ /*HWMP_LOCK();*/
+ TAILQ_FOREACH(fi, &ieee80211_hwmp_ft, fi_next) {
+ if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), fi->fi_dest))
+ break;
+ }
+ /*HWMP_UNLOCK();*/
+
/*
* Step 1. Record the PREQ ID and the originator MAC address.
*/
@@ -418,15 +434,70 @@ hwmp_recv_preq(struct ieee80211vap *vap,
/* XXX: Step 4. Check for AE bit and update proxy information */
/*
- * Step 5. Intermediate reply: check if we have this path on our
- * table and the TO bit is unset.
+ * Step 5. Intermediate reply for PREQs with 1 target.
*/
- if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) {
+ if (preq->preq_ttl > 1 && preq->preq_tcount == 1 &&
+ !(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?
+ */
+ if (fi != NULL) {
+ struct ieee80211_meshprep_ie prep;
+ /*
+ * Propagate the original PREQ.
+ */
+ ppreq.preq_hopcount += 1;
+ ppreq.preq_ttl -= 1;
+ ppreq.preq_metric += ieee80211_airtime_calc(ni);
+ /*
+ * Set TO and unset RF bits because we are going
+ * to send a PREP next.
+ */
+ ppreq.preq_targets[0].target_flags |=
+ IEEE80211_MESHPREQ_TFLAGS_TO;
+ ppreq.preq_targets[0].target_flags &=
+ ~IEEE80211_MESHPREQ_TFLAGS_RF;
+ hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr,
+ &ppreq);
+
+ /*
+ * Build and send an intermediate PREP.
+ */
+ prep.prep_flags = 0;
+ prep.prep_hopcount = 0;
+ prep.prep_ttl = ieee80211_mesh_ttl;
+ IEEE80211_ADDR_COPY(&prep.prep_targetaddr,
+ preq->preq_origaddr);
+ prep.prep_targetseq = fi->fi_seq;
+ prep.prep_lifetime = preq->preq_lifetime;
+ prep.prep_metric = fi->fi_metric;
+ IEEE80211_ADDR_COPY(&prep.prep_origaddr,
+ vap->iv_myaddr);
+ /* XXX */
+ prep.prep_origseq = 1;
+ hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr,
+ &prep);
+ } else {
+ /*
+ * We have no information about this path,
+ * propagate the PREQ.
+ */
+ ppreq.preq_hopcount += 1;
+ ppreq.preq_ttl -= 1;
+ ppreq.preq_metric += ieee80211_airtime_calc(ni);
+ hwmp_send_preq(ni, vap->iv_myaddr, broadcastaddr,
+ &ppreq);
+ }
/*
* XXX: Step 6. Update the percursor table
*/
+ return;
}
+
/*
* XXX: Step 8. Proactive PREQ: reply with a proactive PREP to the
@@ -452,7 +523,7 @@ 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 struct ieee80211_meshpreq_ie *preq)
+ struct ieee80211_meshpreq_ie *preq)
{
/*
* mesh preq action frame format
@@ -463,6 +534,10 @@ hwmp_send_preq(struct ieee80211_node *ni
* [1] category
* [tlv] mesh path request
*/
+ /* XXX target count > 1 */
+ preq->preq_ie = IEEE80211_ELEMID_MESHPREQ;
+ preq->preq_len = sizeof(struct ieee80211_meshpreq_ie) - 2;
+
return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&preq,
sizeof(*preq));
}
@@ -471,7 +546,6 @@ static void
hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_node *ni,
const struct ieee80211_meshprep_ie *prep)
{
- union ieee80211_send_action_args vargs;
/*
* Acceptance criteria: if the PREP was not generated by us and
@@ -485,6 +559,7 @@ hwmp_recv_prep(struct ieee80211vap *vap,
* Step 1: Update the Forwarding Information.
*/
+
/*
* Step 2: If it's NOT for us, propagate the PREP if TTL is
* greater than 1.
@@ -496,14 +571,11 @@ hwmp_recv_prep(struct ieee80211vap *vap,
memcpy(&pprep, prep, sizeof(pprep));
pprep.prep_hopcount += 1;
pprep.prep_ttl -= 1;
- pprep.prep_metric += ieee80211_airtime_calc(vap, ni);
+ pprep.prep_metric += ieee80211_airtime_calc(ni);
IEEE80211_ADDR_COPY(pprep.prep_origaddr, vap->iv_myaddr);
pprep.prep_origseq = 1; /* XXX */
-
- vargs.ptrarg = &pprep;
- ieee80211_send_action(ni, IEEE80211_ACTION_CAT_MESHPATH,
- IEEE80211_ACTION_MESHPATH_REQ, vargs);
-
+ hwmp_send_prep(ni, vap->iv_myaddr, broadcastaddr,
+ &pprep);
/*
* XXX: Step 5: update the precursor list.
*/
@@ -527,7 +599,7 @@ 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 struct ieee80211_meshprep_ie *prep)
+ struct ieee80211_meshprep_ie *prep)
{
/*
* mesh prep action frame format
@@ -538,6 +610,9 @@ hwmp_send_prep(struct ieee80211_node *ni
* [1] category
* [tlv] mesh path reply
*/
+ prep->prep_ie = IEEE80211_ELEMID_MESHPREP;
+ prep->prep_len = sizeof(struct ieee80211_meshprep_ie) - 2;
+
return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&prep,
sizeof(*prep));
}
@@ -554,7 +629,7 @@ 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 struct ieee80211_meshperr_ie *perr)
+ struct ieee80211_meshperr_ie *perr)
{
/*
* mesh perr action frame format
@@ -581,7 +656,7 @@ static int
hwmp_send_rann(struct ieee80211_node *ni,
const uint8_t addr1[IEEE80211_ADDR_LEN],
const uint8_t addr2[IEEE80211_ADDR_LEN],
- const struct ieee80211_meshrann_ie *rann)
+ struct ieee80211_meshrann_ie *rann)
{
/*
* mesh rann action frame format
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c Fri May 29 18:46:57 2009 (r193045)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Fri May 29 18:48:18 2009 (r193046)
@@ -878,7 +878,7 @@ mesh_recv_action(struct ieee80211_node *
/* XXX: check if we are using airtime or
aother algorithm */
- metric = ieee80211_airtime_calc(vap, ni);
+ metric = ieee80211_airtime_calc(ni);
vargs.ptrarg = &metric;
ieee80211_send_action(ni,
IEEE80211_ACTION_CAT_MESHLMETRIC,
@@ -1151,7 +1151,7 @@ ieee80211_add_meshpeer(uint8_t *frm, uin
* Based on D3.0.
*/
uint32_t
-ieee80211_airtime_calc(struct ieee80211vap *vap, struct ieee80211_node *ni)
+ieee80211_airtime_calc(struct ieee80211_node *ni)
{
#define M_BITS 8
#define S_FACTOR (2 * M_BITS)
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.h Fri May 29 18:46:57 2009 (r193045)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.h Fri May 29 18:48:18 2009 (r193046)
@@ -353,8 +353,7 @@ uint8_t * ieee80211_add_meshid(uint8_t *
uint8_t * ieee80211_add_meshconf(uint8_t *, struct ieee80211vap *);
uint8_t * ieee80211_add_meshpeer(uint8_t *, uint8_t, uint16_t, uint16_t,
uint16_t);
-uint32_t ieee80211_airtime_calc(struct ieee80211vap *,
- struct ieee80211_node *);
+uint32_t ieee80211_airtime_calc(struct ieee80211_node *);
uint8_t * ieee80211_add_meshlmetric(uint8_t *, uint32_t);
void ieee80211_create_mbss(struct ieee80211vap *, struct
ieee80211_channel *);
More information about the svn-src-projects
mailing list