From owner-svn-src-projects@FreeBSD.ORG Sat May 23 16:02:20 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65165106567C; Sat, 23 May 2009 16:02:20 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 523D38FC0A; Sat, 23 May 2009 16:02:20 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4NG2KxJ059883; Sat, 23 May 2009 16:02:20 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4NG2KEB059880; Sat, 23 May 2009 16:02:20 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200905231602.n4NG2KEB059880@svn.freebsd.org> From: Rui Paulo Date: Sat, 23 May 2009 16:02:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192641 - projects/mesh11s/sys/net80211 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 May 2009 16:02:20 -0000 Author: rpaulo Date: Sat May 23 16:02:19 2009 New Revision: 192641 URL: http://svn.freebsd.org/changeset/base/192641 Log: Move path handling code to HWMP module. 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 Sat May 23 16:01:58 2009 (r192640) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Sat May 23 16:02:19 2009 (r192641) @@ -62,21 +62,21 @@ __FBSDID("$FreeBSD$"); #include -int ieee80211_hwmp_maxhops = 31; -int ieee80211_hwmp_maxhopstime = 500; -int ieee80211_hwmp_maxprepretries = 3; -int ieee80211_hwmp_prepminint = 100; -int ieee80211_hwmp_perrminint = 100; -int ieee80211_hwmp_roottimeout = 5000; -int ieee80211_hwmp_pathtimeout = 5000; -int ieee80211_hwmp_rootmode = 0; -int ieee80211_hwmp_pathtoroottimeout = 5000; -int ieee80211_hmwp_rootint = 2000; -int ieee80211_hwmp_rannint = 1000; -int ieee80211_hwmp_targetonly = 1; /* reply to PREQs if we have the info */ -int ieee80211_hwmp_replyforward = 1; /* propagate PREQs */ -int ieee80211_hwmp_pathmaintenance = 2000; -int ieee80211_hwmp_confirmint = 2000; +static int ieee80211_hwmp_maxhops = 31; +static int ieee80211_hwmp_maxhopstime = 500; +static int ieee80211_hwmp_maxprepretries = 3; +static int ieee80211_hwmp_prepminint = 100; +static int ieee80211_hwmp_perrminint = 100; +static int ieee80211_hwmp_roottimeout = 5000; +static int ieee80211_hwmp_pathtimeout = 5000; +static int ieee80211_hwmp_rootmode = 0; +static int ieee80211_hwmp_pathtoroottimeout = 5000; +static int ieee80211_hmwp_rootint = 2000; +static int ieee80211_hwmp_rannint = 1000; +static int ieee80211_hwmp_targetonly = 1;/* reply to PREQs automatically */ +static int ieee80211_hwmp_replyforward = 1; /* propagate PREQs */ +static int ieee80211_hwmp_pathmaintenance = 2000; +static int ieee80211_hwmp_confirmint = 2000; SYSCTL_NODE(_net_wlan, OID_AUTO, hwmp, CTLFLAG_RD, 0, "IEEE 802.11s HWMP parameters"); @@ -86,3 +86,121 @@ SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, max SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, rootmode, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_rootmode, 0, "Root Mesh Point Node"); #endif + + +void +ieee80211_hwmp_recv_action(struct ieee80211vap *vap, struct ieee80211_node *ni, + struct mbuf *m) +{ + struct ieee80211_frame *wh; + uint8_t *frm, *efrm; + struct ieee80211_meshpreq_ie *meshpreq = NULL; + struct ieee80211_meshprep_ie *meshprep = NULL; + struct ieee80211_meshperr_ie *meshperr = NULL; + + wh = mtod(m0, struct ieee80211_frame *); + ia = (struct ieee80211_action *) &wh[1]; + frm = (uint8_t *)&wh[1] + sizeof(struct ieee80211_action); + efrm = mtod(m0, uint8_t *) + m0->m_len; + + KASSERT(ia->ia_category == IEEE80211_ACTION_CAT_MESHPATH); + + while (efrm - frm > 1) { + IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1] + 2, return); + switch (*frm) { + case IEEE80211_ELEMID_MESHPREQ: + meshpreq = (struct ieee80211_meshpreq_ie *) frm; + meshpreq->preq_id = LE_READ_4(&meshpreq->preq_id); + meshpreq->preq_origseq = + LE_READ_4(&meshpreq->preq_origseq); + meshpreq->preq_lifetime = + LE_READ_4(&meshpreq->preq_lifetime); + meshpreq->preq_metric = + LE_READ_4(&meshpreq->preq_metric); + break; + case IEEE80211_ELEMID_MESHPREP: + meshprep = (struct ieee80211_meshprep_ie *) frm; + meshprep->prep_targetseq = + LE_READ_4(&meshprep->prep_targetseq); + meshprep->prep_lifetime = + LE_READ_4(&meshprep->prep_lifetime); + meshprep->prep_metric = + LE_READ_4(&meshprep->prep_metric); + meshprep->prep_origseq = + LE_READ_4(&meshprep->prep_origseq); + break; + case IEEE80211_ELEMID_MESHPERR: + meshperr = (struct ieee80211_meshperr_ie *) frm; + break; + } + frm += frm[1] + 2; + } + + switch (ia->ia_action) { + case IEEE80211_ACTION_MESHPATH_REQ: + if (meshpreq == NULL) { + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "%s", "preq without IE"); + vap->iv_stats.is_rx_mgtdiscard++; + return; + } + /* + * Is the peer trying to find us? + */ + if (IEEE80211_ADDR_EQ(vap->iv_myaddr, + meshpreq->preq_targets[0].target_addr)) { + struct ieee80211_meshprep_ie prep; + /* + * Build and send a path reply frame. + */ + prep.prep_flags = 0; + prep.prep_hopcount = 0; + prep.prep_ttl = ieee80211_mesh_ttl; + IEEE80211_ADDR_COPY(prep.prep_targetaddr, + meshpreq->preq_targets[0].target_addr); + prep.prep_targetseq = meshpreq->preq_origseq; + prep.prep_lifetime = 5000; + prep.prep_metric = 0; + IEEE80211_ADDR_COPY(prep.prep_origaddr, + vap->iv_myaddr); + prep.prep_origseq = 1; + vargs.ptrarg = &prep; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_MESHPATH, + IEEE80211_ACTION_MESHPATH_REP, + vargs); + } + break; + case IEEE80211_ACTION_MESHPATH_REP: + break; + case IEEE80211_ACTION_MESHPATH_ERR: + break; + } + +} + + +/* + * Add a Mesh Path Reply IE to a frame. + */ +uint8_t * +ieee80211_add_meshprep(uint8_t *frm, struct ieee80211_meshprep_ie *prep) +{ + + *frm++ = IEEE80211_ELEMID_MESHPREP; + *frm++ = sizeof(struct ieee80211_meshprep_ie) - 2; + *frm++ = prep->prep_flags; + *frm++ = prep->prep_hopcount; + *frm++ = prep->prep_ttl; + IEEE80211_ADDR_COPY(frm, prep->prep_targetaddr); + frm += 6; + ADDWORD(frm, prep->prep_targetseq); + ADDWORD(frm, prep->prep_lifetime); + ADDWORD(frm, prep->prep_metric); + IEEE80211_ADDR_COPY(frm, prep->prep_origaddr); + frm += 6; + ADDWORD(frm, prep->prep_origseq); + + return frm; +} Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.h Sat May 23 16:01:58 2009 (r192640) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.h Sat May 23 16:02:19 2009 (r192641) @@ -31,9 +31,15 @@ #ifndef _NET80211_IEEE80211_HWMP_H_ #define _NET80211_IEEE80211_HWMP_H_ -#if 0 -void ieee80211_hwmp_recv_action(struct ieee80211vap *, +void ieee80211_hwmp_recv_action(struct ieee80211vap *, struct ieee80211_node *, struct mbuf *); +uint8_t * ieee80211_add_meshprep(uint8_t *, + struct ieee80211_meshprep_ie *); +#if 0 +uint8_t * ieee80211_add_meshpreq(uint8_t *, + struct ieee80211_meshpreq_ie *); +uint8_t * ieee80211_add_meshperr(uint8_t *, + struct ieee80211_meshperr_ie *); #endif #endif /* _NET80211_IEEE80211_HWMP_H_ */ Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.c Sat May 23 16:01:58 2009 (r192640) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Sat May 23 16:02:19 2009 (r192641) @@ -640,7 +640,7 @@ mesh_recv_action(struct ieee80211_node * struct ieee80211_meshperr_ie *meshperr = NULL; uint8_t *frm, *efrm; union ieee80211_send_action_args vargs; - + wh = mtod(m0, struct ieee80211_frame *); ia = (struct ieee80211_action *) &wh[1]; frm = (uint8_t *)&wh[1] + sizeof(struct ieee80211_action); @@ -672,30 +672,6 @@ mesh_recv_action(struct ieee80211_node * meshpeer->peer_rcode = LE_READ_2(&meshpeer->peer_rcode); break; - case IEEE80211_ELEMID_MESHPREQ: - meshpreq = (struct ieee80211_meshpreq_ie *) frm; - meshpreq->preq_id = LE_READ_4(&meshpreq->preq_id); - meshpreq->preq_origseq = - LE_READ_4(&meshpreq->preq_origseq); - meshpreq->preq_lifetime = - LE_READ_4(&meshpreq->preq_lifetime); - meshpreq->preq_metric = - LE_READ_4(&meshpreq->preq_metric); - break; - case IEEE80211_ELEMID_MESHPREP: - meshprep = (struct ieee80211_meshprep_ie *) frm; - meshprep->prep_targetseq = - LE_READ_4(&meshprep->prep_targetseq); - meshprep->prep_lifetime = - LE_READ_4(&meshprep->prep_lifetime); - meshprep->prep_metric = - LE_READ_4(&meshprep->prep_metric); - meshprep->prep_origseq = - LE_READ_4(&meshprep->prep_origseq); - break; - case IEEE80211_ELEMID_MESHPERR: - meshperr = (struct ieee80211_meshperr_ie *) frm; - break; } frm += frm[1] + 2; } @@ -706,7 +682,7 @@ mesh_recv_action(struct ieee80211_node * */ case IEEE80211_ACTION_CAT_MESHPEERING: /* - * Check if we agree on the required fields. + * Check if we agree on the required fields. */ if (mesh_verify_meshid(vap, meshid) || mesh_verify_meshconf(vap, meshconf) || @@ -867,45 +843,11 @@ mesh_recv_action(struct ieee80211_node * break; } break; + /* + * Mesh Path action frames are handled by the HWMP module. + */ case IEEE80211_ACTION_CAT_MESHPATH: - switch (ia->ia_action) { - case IEEE80211_ACTION_MESHPATH_REQ: - if (meshpreq == NULL) { - IEEE80211_DISCARD(vap, - IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, - wh, NULL, "%s", "preq without IE"); - vap->iv_stats.is_rx_mgtdiscard++; - return; - } - /* - * Is the peer trying to find us? - */ - if (IEEE80211_ADDR_EQ(vap->iv_myaddr, - meshpreq->preq_targets[0].target_addr)) { - struct ieee80211_meshprep_ie prep; - /* - * Build and send a path reply frame. - */ - prep.prep_flags = 0; - prep.prep_hopcount = 0; - prep.prep_ttl = ieee80211_mesh_ttl; - IEEE80211_ADDR_COPY(prep.prep_targetaddr, - meshpreq->preq_targets[0].target_addr); - prep.prep_targetseq = meshpreq->preq_origseq; - prep.prep_lifetime = 5000; - prep.prep_metric = 0; - IEEE80211_ADDR_COPY(prep.prep_origaddr, - vap->iv_myaddr); - prep.prep_origseq = 1; - - vargs.ptrarg = &prep; - ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPATH, - IEEE80211_ACTION_MESHPATH_REP, - vargs); - } - break; - } + ieee80211_hwmp_recv_action(vap, ni, m); break; /* * Airtime link metric handling. @@ -1166,30 +1108,6 @@ ieee80211_add_meshpeer(uint8_t *frm, uin } /* - * Add a Mesh Path Reply IE to a frame. - */ -uint8_t * -ieee80211_add_meshprep(uint8_t *frm, struct ieee80211_meshprep_ie *prep) -{ - - *frm++ = IEEE80211_ELEMID_MESHPREP; - *frm++ = sizeof(struct ieee80211_meshprep_ie) - 2; - *frm++ = prep->prep_flags; - *frm++ = prep->prep_hopcount; - *frm++ = prep->prep_ttl; - IEEE80211_ADDR_COPY(frm, prep->prep_targetaddr); - frm += 6; - ADDWORD(frm, prep->prep_targetseq); - ADDWORD(frm, prep->prep_lifetime); - ADDWORD(frm, prep->prep_metric); - IEEE80211_ADDR_COPY(frm, prep->prep_origaddr); - frm += 6; - ADDWORD(frm, prep->prep_origseq); - - return frm; -} - -/* * Compute an Airtime Link Metric for the link with this node. * * Based on D3.0.