Date: Sat, 30 May 2009 16:26:08 +0000 (UTC) From: Rui Paulo <rpaulo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r193099 - projects/mesh11s/sys/net80211 Message-ID: <200905301626.n4UGQ8Sv012807@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rpaulo Date: Sat May 30 16:26:08 2009 New Revision: 193099 URL: http://svn.freebsd.org/changeset/base/193099 Log: * move struct ieee80211_hwmp_fi to ieee80211_hwmp.h so we can add one per vap * add initial hanlding of root annoucement frames, the proactive side of HWMP * add initial handling of PERR frames 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_var.h Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Sat May 30 15:20:25 2009 (r193098) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Sat May 30 16:26:08 2009 (r193099) @@ -63,20 +63,6 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_hwmp.h> #include <net80211/ieee80211_input.h> -/* - * HWMP Forwarding Information table. - * XXX: this should be in vap - */ -struct ieee80211_hwmp_fi { - TAILQ_ENTRY(ieee80211_hwmp_fi) fi_next; - uint8_t fi_dest[IEEE80211_ADDR_LEN]; - ieee80211_seq fi_seq; /* HWMP sequence number */ - uint8_t fi_nexthop[IEEE80211_ADDR_LEN]; - uint32_t fi_metric; /* Path Metric */ - uint32_t fi_nhops; /* Number of Hops */ - uint8_t fi_prevhop[IEEE80211_ADDR_LEN]; - uint32_t fi_lifetime; -}; TAILQ_HEAD(, ieee80211_hwmp_fi) ieee80211_hwmp_ft; static int ieee80211_hwmp_send_action(struct ieee80211_node *, @@ -99,11 +85,9 @@ static int hwmp_send_perr(struct ieee802 struct ieee80211_meshperr_ie *); static void hwmp_recv_rann(struct ieee80211vap *, struct ieee80211_node *, 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], struct ieee80211_meshrann_ie *); -#endif static int ieee80211_hwmp_maxhops = 31; #ifdef notyet @@ -111,9 +95,11 @@ static int ieee80211_hwmp_maxhopstime = static int ieee80211_hwmp_maxprepretries = 3; static int ieee80211_hwmp_prepminint = 100; static int ieee80211_hwmp_perrminint = 100; +#endif static int ieee80211_hwmp_roottimeout = 5000; +#ifdef notyet static int ieee80211_hwmp_pathtimeout = 5000; -static int ieee80211_hwmp_rootmode = 0; +static int ieee80211_hwmp_rootmode = 0; /* XXX move to vap */ static int ieee80211_hwmp_pathtoroottimeout = 5000; static int ieee80211_hmwp_rootint = 2000; static int ieee80211_hwmp_rannint = 1000; @@ -515,9 +501,9 @@ hwmp_recv_preq(struct ieee80211vap *vap, } } } -#undef PREQ_TFLAGS -#undef PREQ_TADDR -#undef PREQ_TSEQ +#undef PREQ_TFLAGS +#undef PREQ_TADDR +#undef PREQ_TSEQ static inline int hwmp_send_preq(struct ieee80211_node *ni, @@ -617,13 +603,39 @@ hwmp_send_prep(struct ieee80211_node *ni sizeof(*prep)); } +#define PERR_DADDR(n) perr->perr_dests[n].dest_addr +#define PREQ_DSEQ(n) perr->perr_dests[n].dest_seq static void hwmp_recv_perr(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_meshperr_ie *perr) { + struct ieee80211_hwmp_fi *fi; +/* struct ieee80211_meshperr_ie pperr;*/ -} + /* + * Acceptance criteria: check if we received a PERR from a + * neighbor and forwarding is 1. + */ + if (ni == vap->iv_bss || + ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED || + !ieee80211_mesh_forwarding) + return; + + fi = NULL; + /*HWMP_LOCK();*/ + TAILQ_FOREACH(fi, &ieee80211_hwmp_ft, fi_next) { + if (IEEE80211_ADDR_EQ(PERR_DADDR(0), fi->fi_dest)) + break; + } + + if (fi == NULL) + return; + + /* + * Propagate the PERR. + */ +} static inline int hwmp_send_perr(struct ieee80211_node *ni, @@ -640,6 +652,9 @@ hwmp_send_perr(struct ieee80211_node *ni * [1] category * [tlv] mesh path error */ + perr->perr_ie = IEEE80211_ELEMID_MESHPERR; + perr->perr_len = sizeof(struct ieee80211_meshperr_ie) - 2; + return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&perr, sizeof(*perr)); } @@ -648,10 +663,56 @@ static void hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_meshrann_ie *rann) { + struct ieee80211_hwmp_fi *fi; + /* + * Acceptance criteria: check the HWMP sequence number + * and the path metric is better than what we have. + */ + fi = NULL; + /*HWMP_LOCK();*/ + TAILQ_FOREACH(fi, &ieee80211_hwmp_ft, fi_next) { + if (IEEE80211_ADDR_EQ(rann->rann_addr, fi->fi_dest)) + break; + } + /*HWMP_UNLOCK();*/ + + if (fi == 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 = ieee80211_mesh_ttl; + IEEE80211_ADDR_COPY(&preq.preq_origaddr, + vap->iv_myaddr); + preq.preq_origseq = 0; /* XXX */ + 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 = 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. + */ + } else if (rann->rann_ttl > 1 && ieee80211_mesh_forwarding) { + 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, broadcastaddr, vap->iv_myaddr, &prann); + } } -#ifdef notyet static int hwmp_send_rann(struct ieee80211_node *ni, const uint8_t addr1[IEEE80211_ADDR_LEN], @@ -667,10 +728,12 @@ hwmp_send_rann(struct ieee80211_node *ni * [1] category * [tlv] root annoucement */ + rann->rann_ie = IEEE80211_ELEMID_MESHRANN; + rann->rann_len = sizeof(struct ieee80211_meshrann_ie) - 2; + return ieee80211_hwmp_send_action(ni, addr1, addr2, (uint8_t *)&rann, sizeof(*rann)); } -#endif static int hwmp_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq) Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.h Sat May 30 15:20:25 2009 (r193098) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.h Sat May 30 16:26:08 2009 (r193099) @@ -31,6 +31,20 @@ #ifndef _NET80211_IEEE80211_HWMP_H_ #define _NET80211_IEEE80211_HWMP_H_ +/* + * HWMP Forwarding Information table, part of each VAP. + */ +struct ieee80211_hwmp_fi { + TAILQ_ENTRY(ieee80211_hwmp_fi) fi_next; + uint8_t fi_dest[IEEE80211_ADDR_LEN]; + ieee80211_seq fi_seq; /* HWMP sequence number */ + uint8_t fi_nexthop[IEEE80211_ADDR_LEN]; + uint32_t fi_metric; /* Path Metric */ + uint32_t fi_nhops; /* Number of Hops */ + uint8_t fi_prevhop[IEEE80211_ADDR_LEN]; + uint32_t fi_lifetime; +}; + void ieee80211_hwmp_recv_action(struct ieee80211vap *, struct ieee80211_node *, struct mbuf *); uint8_t * ieee80211_add_meshprep(uint8_t *, Modified: projects/mesh11s/sys/net80211/ieee80211_var.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_var.h Sat May 30 15:20:25 2009 (r193098) +++ projects/mesh11s/sys/net80211/ieee80211_var.h Sat May 30 16:26:08 2009 (r193099) @@ -53,6 +53,7 @@ #include <net80211/ieee80211_proto.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_scan.h> +#include <net80211/ieee80211_hwmp.h> /* for ieee80211_hwmp_fi */ #define IEEE80211_TXPOWER_MAX 100 /* .5 dbM (XXX units?) */ #define IEEE80211_TXPOWER_MIN 0 /* kill radio */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905301626.n4UGQ8Sv012807>