Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jun 2009 20:41:33 +0000 (UTC)
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r193261 - projects/mesh11s/sys/net80211
Message-ID:  <200906012041.n51KfXE3091194@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rpaulo
Date: Mon Jun  1 20:41:33 2009
New Revision: 193261
URL: http://svn.freebsd.org/changeset/base/193261

Log:
  Initial try at implementing path discovery from our node.
  
  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_output.c

Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c	Mon Jun  1 20:35:39 2009	(r193260)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c	Mon Jun  1 20:41:33 2009	(r193261)
@@ -103,15 +103,15 @@ static int	ieee80211_hwmp_prepminint = 1
 static int	ieee80211_hwmp_perrminint = 100;
 #endif
 static int	ieee80211_hwmp_roottimeout = 5000;
-#ifdef notyet
 static int	ieee80211_hwmp_pathtimeout = 5000;
+#ifdef notyet
 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;
 #endif
-static int	ieee80211_hwmp_targetonly = 1;/* reply to PREQs automatically */
-static int	ieee80211_hwmp_replyforward = 1; /* propagate PREQs */
+static int	ieee80211_hwmp_targetonly = 1;
+static int	ieee80211_hwmp_replyforward = 1;
 #ifdef notyet
 static int	ieee80211_hwmp_pathmaintenance = 2000;
 static int	ieee80211_hwmp_confirmint = 2000;
@@ -131,9 +131,9 @@ SYSCTL_NODE(_net_wlan, OID_AUTO, hwmp, C
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, maxhops, CTLTYPE_INT | CTLFLAG_RW,
     &ieee80211_hwmp_maxhops, 0, "Maximum number of hops for paths");
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, targetonly, CTLTYPE_INT | CTLFLAG_RW,
-    &ieee80211_hwmp_targetonly, 0, "TBD");
+    &ieee80211_hwmp_targetonly, 0, "Set TO bit on generated PREQs");
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, replyforward, CTLTYPE_INT | CTLFLAG_RW,
-    &ieee80211_hwmp_replyforward, 0, "TBD");
+    &ieee80211_hwmp_replyforward, 0, "Set RF bit on generated PREQs");
 #ifdef notyet
 SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, rootmode, CTLTYPE_INT | CTLFLAG_RW,
     &ieee80211_hwmp_rootmode, 0, "0 = Not a Root, "
@@ -827,6 +827,73 @@ hwmp_send_rann(struct ieee80211_node *ni
 	    sizeof(*rann));
 }
 
+#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
+struct ieee80211_node *
+ieee80211_hwmp_discover_dest(struct ieee80211vap *vap,
+    uint8_t dest[IEEE80211_ADDR_LEN])
+{
+	struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
+	struct ieee80211_hwmp_fi *fi = NULL;
+	static const uint8_t invalidaddr[] = { 0, 0, 0, 0, 0, 0 };
+	struct ieee80211_meshpreq_ie preq;
+	int sendpreq = 0, unknowndst = 0;
+
+	KASSERT(vap->iv_opmode == IEEE80211_M_MBSS,
+	    ("not a mesh vap, opmode %d", vap->iv_opmode));
+
+	mtx_lock(&hs->hs_lock);
+	TAILQ_FOREACH(fi, &hs->hs_head, fi_next) {
+		if (IEEE80211_ADDR_EQ(fi->fi_dest, dest)) {
+			if (IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) {
+				/* XXX check preq retries */
+				sendpreq = 1;
+				unknowndst = 1;
+				break;
+			}
+		}
+	}
+	mtx_unlock(&hs->hs_lock);
+
+	if (sendpreq) {
+		/*
+		 * Try to discover the path for this
+		 * node.
+		 */
+		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;
+		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)
+			PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_USN;
+		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
+#undef	PREQ_TADDR
+#undef	PREQ_TSEQ
+
+
 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	Mon Jun  1 20:35:39 2009	(r193260)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.h	Mon Jun  1 20:41:33 2009	(r193261)
@@ -48,14 +48,18 @@ struct ieee80211_hwmp_fi {
 #ifdef _KERNEL
 struct ieee80211_hwmp_state {
 	TAILQ_HEAD(, ieee80211_hwmp_fi)	hs_head;
-	ieee80211_seq			hs_seq;	    /* next seq to be used */
-	struct mtx			hs_lock;    /* lock for the fi table */
+	ieee80211_seq			hs_seq;	   /* next seq to be used */
+	ieee80211_seq			hs_preqid; /* next PREQ ID to be used */
+	struct mtx			hs_lock;   /* lock for the fi table */
 };
 
 void		ieee80211_hwmp_vattach(struct ieee80211vap *);
 void		ieee80211_hwmp_vdetach(struct ieee80211vap *);
 void		ieee80211_hwmp_recv_action(struct ieee80211vap *,
     struct ieee80211_node *, struct mbuf *);
+struct ieee80211_node *
+		ieee80211_hwmp_discover_dest(struct ieee80211vap *,
+    uint8_t [IEEE80211_ADDR_LEN]);
 #endif /* _KERNEL */
 
 #endif /* _NET80211_IEEE80211_HWMP_H_ */

Modified: projects/mesh11s/sys/net80211/ieee80211_output.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_output.c	Mon Jun  1 20:35:39 2009	(r193260)
+++ projects/mesh11s/sys/net80211/ieee80211_output.c	Mon Jun  1 20:41:33 2009	(r193261)
@@ -207,7 +207,10 @@ ieee80211_start(struct ifnet *ifp)
 				
 			}
 		}
-		ni = ieee80211_find_txnode(vap, eh->ether_dhost);
+		if (vap->iv_opmode == IEEE80211_M_MBSS)
+			ni = ieee80211_hwmp_discover_dest(vap, eh->ether_dhost);
+		else
+			ni = ieee80211_find_txnode(vap, eh->ether_dhost);
 		if (ni == NULL) {
 			/* NB: ieee80211_find_txnode does stat+msg */
 			ifp->if_oerrors++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906012041.n51KfXE3091194>