svn commit: r194666 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Mon Jun 22 22:09:20 UTC 2009
Author: rpaulo
Date: Mon Jun 22 22:09:19 2009
New Revision: 194666
URL: http://svn.freebsd.org/changeset/base/194666
Log:
Checkpoint forwarding code. We can now forward packets between mesh
nodes.
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_mesh.c
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Mon Jun 22 22:09:18 2009 (r194665)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Mon Jun 22 22:09:19 2009 (r194666)
@@ -1051,14 +1051,36 @@ ieee80211_hwmp_discover(struct ieee80211
#undef PREQ_TADDR
#undef PREQ_TSEQ
+/*
+ * Iterate the forwarding information table and locate the
+ * next hop.
+ */
+struct ieee80211_node *
+ieee80211_hwmp_find_txnode(struct ieee80211vap *vap,
+ uint8_t dest[IEEE80211_ADDR_LEN])
+{
+ struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
+ struct ieee80211_hwmp_fi *fi;
+
+ HWMP_LOCK(hs);
+ TAILQ_FOREACH(fi, &hs->hs_head, fi_next) {
+ if (IEEE80211_ADDR_EQ(fi->fi_dest, dest))
+ break;
+ }
+ HWMP_UNLOCK(hs);
+ if (fi == NULL)
+ return NULL;
+ return ieee80211_find_txnode(vap, fi->fi_nexthop);
+}
+
static int
hwmp_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq)
{
- int error;
- size_t len, off;
struct ieee80211_hwmp_state *hs = vap->iv_hwmp;
struct ieee80211_hwmp_fi *fi;
+ size_t len, off;
uint8_t *p;
+ int error;
if (vap->iv_opmode != IEEE80211_M_MBSS ||
ireq->i_type != IEEE80211_IOC_HWMP_CMD)
Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_hwmp.h Mon Jun 22 22:09:18 2009 (r194665)
+++ projects/mesh11s/sys/net80211/ieee80211_hwmp.h Mon Jun 22 22:09:19 2009 (r194666)
@@ -73,6 +73,9 @@ void ieee80211_hwmp_recv_action(struct i
struct ieee80211_node *
ieee80211_hwmp_discover(struct ieee80211vap *,
uint8_t [IEEE80211_ADDR_LEN]);
+struct ieee80211_node *
+ieee80211_hwmp_find_txnode(struct ieee80211vap *vap,
+ uint8_t dest[IEEE80211_ADDR_LEN]);
#endif /* _KERNEL */
#endif /* _NET80211_IEEE80211_HWMP_H_ */
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c Mon Jun 22 22:09:18 2009 (r194665)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Mon Jun 22 22:09:19 2009 (r194666)
@@ -389,23 +389,22 @@ mesh_input(struct ieee80211_node *ni, st
} else
qos = 0;
/*
- * Forward multicast packets. We just decrement the TTL and
- * set TA to our MAC address.
+ * Forward packets if they are not destined to us.
+ * We just decrement the TTL and set TA to our MAC address.
*/
- if (IEEE80211_IS_MULTICAST(wh->i_addr1) && mc->mc_ttl > 0 &&
+ if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr2) &&
!IEEE80211_ADDR_EQ(vap->iv_myaddr, wh->i_addr3) &&
+ !IEEE80211_ADDR_EQ(wh->i_addr1, wh->i_addr3) &&
+ mc->mc_ttl > 0 &&
(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) {
struct mbuf *mcopy;
struct ieee80211_meshcntl *mccopy;
struct ieee80211_frame *whcopy;
const struct ieee80211_txparam *tp;
struct ieee80211_bpf_params params;
+ struct ieee80211_node *nidest;
int err;
- IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
- "forwarding mcast frame from %s ttl %d",
- ether_sprintf(wh->i_addr3), mc->mc_ttl);
-
mcopy = m_dup(m, M_DONTWAIT);
if (mcopy == NULL) {
ifp->if_oerrors++;
@@ -422,27 +421,46 @@ mesh_input(struct ieee80211_node *ni, st
mccopy = (struct ieee80211_meshcntl *)
(mtod(mcopy, uint8_t *) +
ieee80211_hdrspace(ic, wh));
+ memset(¶ms, 0, sizeof(params));
+ tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)];
/* XXX clear other bits? */
whcopy->i_fc[1] &= ~IEEE80211_FC1_RETRY;
IEEE80211_ADDR_COPY(whcopy->i_addr2, vap->iv_myaddr);
+ if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
+ IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+ "forwarding multicast frame from %s ttl %d",
+ ether_sprintf(wh->i_addr3), mc->mc_ttl);
+ nidest = vap->iv_bss;
+ params.ibp_rate0 = tp->mcastrate;
+ } else {
+ IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni,
+ "forwarding unicast frame from %s ttl %d",
+ ether_sprintf(wh->i_addr3), mc->mc_ttl);
+ params.ibp_rate0 = tp->ucastrate;
+ nidest = ieee80211_hwmp_find_txnode(vap,
+ whcopy->i_addr3);
+ if (nidest == NULL) {
+ m_freem(mcopy);
+ goto deliver;
+ }
+ IEEE80211_ADDR_COPY(whcopy->i_addr1,
+ nidest->ni_macaddr);
+ }
mccopy->mc_ttl--;
/* XXX calculate priority so drivers can find the tx queue */
mcopy->m_flags |= M_MCAST;
M_WME_SETAC(mcopy, WME_AC_BE);
- memset(¶ms, 0, sizeof(params));
params.ibp_pri = M_WME_GETAC(mcopy);
- params.ibp_power = vap->iv_bss->ni_txpower;
- tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)];
- params.ibp_rate0 = tp->mcastrate;
+ params.ibp_power = nidest->ni_txpower;
params.ibp_flags |= IEEE80211_BPF_NOACK;
params.ibp_try0 = 1;
IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
"ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n",
__func__, __LINE__,
- ni, ether_sprintf(ni->ni_macaddr),
- ieee80211_node_refcnt(ni)+1);
- ieee80211_ref_node(vap->iv_bss);
- err = ic->ic_raw_xmit(vap->iv_bss, mcopy, ¶ms);
+ ni, ether_sprintf(nidest->ni_macaddr),
+ ieee80211_node_refcnt(nidest)+1);
+ ieee80211_ref_node(nidest);
+ err = ic->ic_raw_xmit(nidest, mcopy, ¶ms);
if (err) {
/* NB: IFQ_HANDOFF reclaims mbuf */
ifp->if_oerrors++;
More information about the svn-src-projects
mailing list