Date: Fri, 26 Jun 2009 17:30:33 +0000 (UTC) From: Rui Paulo <rpaulo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r195063 - projects/mesh11s/sys/net80211 Message-ID: <200906261730.n5QHUYMT092994@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rpaulo Date: Fri Jun 26 17:30:33 2009 New Revision: 195063 URL: http://svn.freebsd.org/changeset/base/195063 Log: Move the mesh state in ieee80211vap struct to a new struct ieee80211_mesh_state. 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 projects/mesh11s/sys/net80211/ieee80211_output.c projects/mesh11s/sys/net80211/ieee80211_var.h Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Fri Jun 26 16:57:12 2009 (r195062) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Fri Jun 26 17:30:33 2009 (r195063) @@ -538,6 +538,7 @@ static void hwmp_recv_preq(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshpreq_ie *preq) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_hwmp_fi *fi = NULL; @@ -556,7 +557,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, * forwarding is disabled, discard this PREQ. */ if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) && - !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) { + !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_HWMP, preq->preq_origaddr, NULL, "%s", "not accepting PREQ"); return; @@ -590,7 +591,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, */ prep.prep_flags = 0; prep.prep_hopcount = 0; - prep.prep_ttl = vap->iv_meshttl; + prep.prep_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(prep.prep_targetaddr, preq->preq_origaddr); prep.prep_targetseq = preq->preq_origseq; prep.prep_lifetime = preq->preq_lifetime; @@ -656,7 +657,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, ether_sprintf(preq->preq_origaddr)); prep.prep_flags = 0; prep.prep_hopcount = 0; - prep.prep_ttl = vap->iv_meshttl; + prep.prep_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(&prep.prep_targetaddr, preq->preq_origaddr); prep.prep_targetseq = fi->fi_seq; @@ -742,6 +743,7 @@ static void hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshprep_ie *prep) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_fi *fi = NULL; /* @@ -749,7 +751,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, * forwarding is disabled, discard this PREP. */ if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) && - !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) + !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) return; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -840,6 +842,7 @@ static void hwmp_recv_perr(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshperr_ie *perr) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_fi *fi = NULL; /* struct ieee80211_meshperr_ie pperr;*/ @@ -849,7 +852,7 @@ hwmp_recv_perr(struct ieee80211vap *vap, */ if (ni == vap->iv_bss || ni->ni_mlstate != IEEE80211_NODE_MESH_ESTABLISHED || - !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) + !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) return; fi = hwmp_rt_find(vap, PERR_DADDR(0)); @@ -895,6 +898,7 @@ static void hwmp_recv_rann(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_frame *wh, const struct ieee80211_meshrann_ie *rann) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_hwmp_fi *fi = NULL; @@ -914,7 +918,7 @@ hwmp_recv_rann(struct ieee80211vap *vap, */ preq.preq_flags = 0; preq.preq_hopcount = 0; - preq.preq_ttl = vap->iv_meshttl; + preq.preq_ttl = ms->ms_ttl; IEEE80211_ADDR_COPY(&preq.preq_origaddr, vap->iv_myaddr); preq.preq_origseq = hs->hs_seq++; @@ -931,7 +935,7 @@ hwmp_recv_rann(struct ieee80211vap *vap, * propagate the RANN if forwarding is enabled. */ } else if (rann->rann_ttl > 1 && - (vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) { + (ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) { struct ieee80211_meshrann_ie prann; memcpy(&prann, rann, sizeof(prann)); @@ -968,6 +972,7 @@ struct ieee80211_node * ieee80211_hwmp_discover(struct ieee80211vap *vap, uint8_t dest[IEEE80211_ADDR_LEN]) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_hwmp_fi *fi = NULL; struct ieee80211_meshpreq_ie preq; @@ -1003,7 +1008,7 @@ ieee80211_hwmp_discover(struct ieee80211 */ preq.preq_flags = 0; preq.preq_hopcount = 0; - preq.preq_ttl = vap->iv_meshttl; + preq.preq_ttl = ms->ms_ttl; preq.preq_id = fi->fi_preqid; IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); preq.preq_origseq = fi->fi_seq; Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.c Fri Jun 26 16:57:12 2009 (r195062) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Fri Jun 26 17:30:33 2009 (r195063) @@ -131,18 +131,28 @@ mesh_vdetach(struct ieee80211vap *vap) ieee80211_iterate_nodes(&vap->iv_ic->ic_sta, mesh_vdetach_peers, NULL); ieee80211_hwmp_vdetach(vap); + free(vap->iv_mesh, M_80211_VAP); } static void mesh_vattach(struct ieee80211vap *vap) { + struct ieee80211_mesh_state *ms; + vap->iv_newstate = mesh_newstate; vap->iv_input = mesh_input; vap->iv_opdetach = mesh_vdetach; vap->iv_recv_mgmt = mesh_recv_mgmt; - vap->iv_meshseq = 0; - vap->iv_meshflags = (IEEE80211_MFLAGS_AP | IEEE80211_MFLAGS_FWRD); - vap->iv_meshttl = 31; /* default TTL */ + ms = malloc(sizeof(struct ieee80211_mesh_state), M_80211_VAP, + M_NOWAIT | M_ZERO); + if (ms == NULL) { + printf("%s: couldn't alloc MBSS state\n", __func__); + return; + } + vap->iv_mesh = ms; + ms->ms_seq = 0; + ms->ms_flags = (IEEE80211_MESHFLAGS_AP | IEEE80211_MESHFLAGS_FWD); + ms->ms_ttl = 31; /* default TTL */ ieee80211_hwmp_vattach(vap); } @@ -152,6 +162,7 @@ mesh_vattach(struct ieee80211vap *vap) static int mesh_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211com *ic = vap->iv_ic; struct ieee80211_node *ni; enum ieee80211_state ostate; @@ -189,7 +200,7 @@ mesh_newstate(struct ieee80211vap *vap, case IEEE80211_S_INIT: if (vap->iv_des_chan != IEEE80211_CHAN_ANYC && !IEEE80211_IS_CHAN_RADAR(vap->iv_des_chan) && - vap->iv_meshidlen != 0) { + ms->ms_idlen != 0) { /* * Already have a channel and a mesh ID; bypass * the scan and startup immediately. @@ -392,6 +403,7 @@ static int mesh_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int noise) { struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211com *ic = ni->ni_ic; struct ifnet *ifp = vap->iv_ifp; struct ieee80211_frame *wh; @@ -504,7 +516,7 @@ mesh_input(struct ieee80211_node *ni, st !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)) + (ms->ms_flags & IEEE80211_MESHFLAGS_FWD)) mesh_forward(vap, m); /* * Next up, any fragmentation. @@ -628,6 +640,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni int rssi, int noise) { struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211com *ic = ni->ni_ic; struct ieee80211_frame *wh; uint8_t *frm, *efrm; @@ -682,7 +695,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni * Ignore non-mesh STAs and STAs for other mesh networks. */ if (scan.meshid && - memcmp(scan.meshid+2, vap->iv_meshid, vap->iv_meshidlen) != 0) { + memcmp(scan.meshid+2, ms->ms_id, ms->ms_idlen) != 0) { IEEE80211_NOTE(vap, IEEE80211_MSG_MESH, ni, "beacon not for our mesh (%s)", scan.meshid+2); return; @@ -707,7 +720,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni * Try to peer with this node if possible. */ if (ni != vap->iv_bss && - vap->iv_meshflags & IEEE80211_MFLAGS_AP && + ms->ms_flags & IEEE80211_MESHFLAGS_AP && ni->ni_mlstate == IEEE80211_NODE_MESH_IDLE) { union ieee80211_send_action_args vargs; @@ -1315,10 +1328,11 @@ static inline int mesh_verify_meshid(struct ieee80211vap *vap, struct ieee80211_meshid_ie *meshid) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; + if (meshid == NULL) return 1; - - return memcmp(vap->iv_meshid, (uint8_t *)&meshid[1], vap->iv_meshidlen); + return memcmp(ms->ms_id, (uint8_t *)&meshid[1], ms->ms_idlen); } /* @@ -1402,14 +1416,14 @@ mesh_verify_meshconf(struct ieee80211vap uint8_t * ieee80211_add_meshid(uint8_t *frm, struct ieee80211vap *vap) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; KASSERT(vap->iv_opmode == IEEE80211_M_MBSS, ("not a mbss vap")); *frm++ = IEEE80211_ELEMID_MESHID; - *frm++ = vap->iv_meshidlen; - memcpy(frm, vap->iv_meshid, vap->iv_meshidlen); - - return frm + vap->iv_meshidlen; + *frm++ = ms->ms_idlen; + memcpy(frm, ms->ms_id, ms->ms_idlen); + return frm + ms->ms_idlen; } /* @@ -1434,6 +1448,7 @@ uint8_t * ieee80211_add_meshconf(uint8_t *frm, struct ieee80211vap *vap) { uint8_t neighs = 0; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_meshconf_ie ie = { .conf_ie = IEEE80211_ELEMID_MESHCONF, .conf_len = sizeof(struct ieee80211_meshconf_ie) - 2, @@ -1454,11 +1469,11 @@ ieee80211_add_meshconf(uint8_t *frm, str ieee80211_iterate_nodes(&vap->iv_ic->ic_sta, meshconf_neighbors, &neighs); ie.conf_form = neighs << 1; - if (vap->iv_meshflags & IEEE80211_MFLAGS_MP) + if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL) ie.conf_form |= IEEE80211_MESHCONF_FORM_MP; - if (vap->iv_meshflags & IEEE80211_MFLAGS_AP) + if (ms->ms_flags & IEEE80211_MESHFLAGS_AP) ie.conf_cap |= IEEE80211_MESHCONF_CAP_AP; - if (vap->iv_meshflags & IEEE80211_MFLAGS_FWRD) + if (ms->ms_flags & IEEE80211_MESHFLAGS_FWD) ie.conf_cap |= IEEE80211_MESHCONF_CAP_FWRD; memcpy(frm, &ie, sizeof(ie)); return frm + sizeof(ie); @@ -1554,11 +1569,9 @@ ieee80211_airtime_calc(struct ieee80211_ uint8_t * ieee80211_add_meshlmetric(uint8_t *frm, uint32_t metric) { - *frm++ = IEEE80211_ELEMID_MESHLINK; *frm++ = 4; ADDWORD(frm, metric); - return frm; } #undef ADDSHORT @@ -1568,6 +1581,7 @@ void ieee80211_create_mbss(struct ieee80211vap *vap, struct ieee80211_channel *chan) { struct ieee80211com *ic = vap->iv_ic; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_node *ni; IEEE80211_DPRINTF(vap, IEEE80211_MSG_MESH, @@ -1580,8 +1594,8 @@ ieee80211_create_mbss(struct ieee80211va return; } IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_myaddr); - ni->ni_meshidlen = vap->iv_meshidlen; - memcpy(ni->ni_meshid, vap->iv_meshid, ni->ni_meshidlen); + ni->ni_meshidlen = ms->ms_idlen; + memcpy(ni->ni_meshid, ms->ms_id, ni->ni_meshidlen); ni->ni_intval = ic->ic_bintval; /* NB: mesh nodes must be QoS capable */ ni->ni_flags |= IEEE80211_NODE_QOS; @@ -1638,6 +1652,7 @@ ieee80211_create_mbss(struct ieee80211va static int mesh_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; int error; uint8_t tmpmeshid[IEEE80211_NWID_LEN]; @@ -1647,18 +1662,18 @@ mesh_ioctl_get80211(struct ieee80211vap error = 0; switch (ireq->i_type) { case IEEE80211_IOC_MESH_ID: - ireq->i_len = vap->iv_meshidlen; - memcpy(tmpmeshid, vap->iv_meshid, ireq->i_len); + ireq->i_len = ms->ms_idlen; + memcpy(tmpmeshid, ms->ms_id, ireq->i_len); error = copyout(tmpmeshid, ireq->i_data, ireq->i_len); break; case IEEE80211_IOC_MESH_AP: - ireq->i_val = (vap->iv_meshflags & IEEE80211_MFLAGS_AP) != 0; + ireq->i_val = (ms->ms_flags & IEEE80211_MESHFLAGS_AP) != 0; break; case IEEE80211_IOC_MESH_FWRD: - ireq->i_val = (vap->iv_meshflags & IEEE80211_MFLAGS_FWRD) != 0; + ireq->i_val = (ms->ms_flags & IEEE80211_MESHFLAGS_FWD) != 0; break; case IEEE80211_IOC_MESH_TTL: - ireq->i_val = vap->iv_meshttl; + ireq->i_val = ms->ms_ttl; break; default: return ENOSYS; @@ -1671,6 +1686,7 @@ IEEE80211_IOCTL_GET(mesh, mesh_ioctl_get static int mesh_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) { + struct ieee80211_mesh_state *ms = vap->iv_mesh; int error; uint8_t tmpmeshid[IEEE80211_NWID_LEN]; @@ -1685,24 +1701,24 @@ mesh_ioctl_set80211(struct ieee80211vap error = copyin(ireq->i_data, tmpmeshid, ireq->i_len); if (error) break; - memset(vap->iv_meshid, 0, IEEE80211_NWID_LEN); - vap->iv_meshidlen = ireq->i_len; - memcpy(vap->iv_meshid, tmpmeshid, ireq->i_len); + memset(ms->ms_id, 0, IEEE80211_NWID_LEN); + ms->ms_idlen = ireq->i_len; + memcpy(ms->ms_id, tmpmeshid, ireq->i_len); break; case IEEE80211_IOC_MESH_AP: if (ireq->i_val) - vap->iv_meshflags |= IEEE80211_MFLAGS_AP; + ms->ms_flags |= IEEE80211_MESHFLAGS_AP; else - vap->iv_meshflags &= ~IEEE80211_MFLAGS_AP; + ms->ms_flags &= ~IEEE80211_MESHFLAGS_AP; break; case IEEE80211_IOC_MESH_FWRD: if (ireq->i_val) - vap->iv_meshflags |= IEEE80211_MFLAGS_FWRD; + ms->ms_flags |= IEEE80211_MESHFLAGS_FWD; else - vap->iv_meshflags &= ~IEEE80211_MFLAGS_FWRD; + ms->ms_flags &= ~IEEE80211_MESHFLAGS_FWD; break; case IEEE80211_IOC_MESH_TTL: - vap->iv_meshttl = (uint8_t) ireq->i_val; + ms->ms_ttl = (uint8_t) ireq->i_val; break; default: return ENOSYS; Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.h Fri Jun 26 16:57:12 2009 (r195062) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.h Fri Jun 26 17:30:33 2009 (r195063) @@ -371,6 +371,17 @@ struct ieee80211_meshcntl_ae11 { }; #ifdef _KERNEL +struct ieee80211_mesh_state { + int ms_idlen; + uint8_t ms_id[IEEE80211_MESHID_LEN]; + uint32_t ms_seq; /* seq no for meshcntl */ + uint8_t ms_ttl; /* mesh ttl set in packets */ +#define IEEE80211_MESHFLAGS_AP 0x01 /* accept peers */ +#define IEEE80211_MESHFLAGS_PORTAL 0x02 /* mesh portal role */ +#define IEEE80211_MESHFLAGS_FWD 0x04 /* forward packets */ + uint8_t ms_flags; + +}; void ieee80211_mesh_attach(struct ieee80211com *); void ieee80211_mesh_detach(struct ieee80211com *); void ieee80211_parse_meshid(struct ieee80211_node *, const uint8_t *); Modified: projects/mesh11s/sys/net80211/ieee80211_output.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_output.c Fri Jun 26 16:57:12 2009 (r195062) +++ projects/mesh11s/sys/net80211/ieee80211_output.c Fri Jun 26 17:30:33 2009 (r195063) @@ -567,6 +567,7 @@ ieee80211_send_action(struct ieee80211_n #define SM(_v, _f) (((_v) << _f##_S) & _f) struct ieee80211vap *vap = ni->ni_vap; struct ieee80211com *ic = ni->ni_ic; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_bpf_params params; const struct ieee80211_rateset *rs; struct mbuf *m; @@ -598,7 +599,7 @@ ieee80211_send_action(struct ieee80211_n + 2 + IEEE80211_RATE_SIZE + 2 + (IEEE80211_RATE_MAXSIZE - IEEE80211_RATE_SIZE) + sizeof(struct ieee80211_meshpeerver_ie) - + 2 + vap->iv_meshidlen /* Mesh ID */ + + 2 + ms->ms_idlen /* Mesh ID */ + sizeof(struct ieee80211_meshconf_ie) + sizeof(struct ieee80211_meshpeer_ie); break; @@ -1242,6 +1243,7 @@ ieee80211_encap(struct ieee80211vap *vap { #define WH4(wh) ((struct ieee80211_frame_addr4 *)(wh)) struct ieee80211com *ic = ni->ni_ic; + struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ether_header eh; struct ieee80211_frame *wh; struct ieee80211_key *key; @@ -1475,8 +1477,8 @@ ieee80211_encap(struct ieee80211vap *vap KASSERT(0, ("meshae %d", meshae)); break; } - mc->mc_ttl = vap->iv_meshttl; - seq = vap->iv_meshseq++; + mc->mc_ttl = ms->ms_ttl; + seq = ms->ms_seq++; mc->mc_seq[0] = seq & 0xff; mc->mc_seq[1] = (seq >> 8) & 0xff; mc->mc_seq[2] = (seq >> 16) & 0xff; Modified: projects/mesh11s/sys/net80211/ieee80211_var.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_var.h Fri Jun 26 16:57:12 2009 (r195062) +++ projects/mesh11s/sys/net80211/ieee80211_var.h Fri Jun 26 17:30:33 2009 (r195063) @@ -314,6 +314,7 @@ struct ieee80211com { struct ieee80211_aclator; struct ieee80211_tdma_state; +struct ieee80211_mesh_state; struct ieee80211_hwmp_state; struct ieee80211vap { @@ -394,15 +395,6 @@ struct ieee80211vap { /* set/unset aid pwrsav state */ int iv_csa_count; /* count for doing CSA */ - int iv_meshidlen; - uint8_t iv_meshid[IEEE80211_MESHID_LEN]; - uint32_t iv_meshseq; /* seq no for meshcntl */ - uint8_t iv_meshttl; /* mesh ttl set in packets */ -#define IEEE80211_MFLAGS_AP 0x01 /* accept peers */ -#define IEEE80211_MFLAGS_MP 0x02 /* mesh portal role */ -#define IEEE80211_MFLAGS_FWRD 0x04 /* forward packets */ - uint8_t iv_meshflags; - struct ieee80211_node *iv_bss; /* information for this node */ struct ieee80211_txparam iv_txparms[IEEE80211_MODE_MAX]; uint16_t iv_rtsthreshold; @@ -438,6 +430,7 @@ struct ieee80211vap { void *iv_as; /* private aclator state */ struct ieee80211_tdma_state *iv_tdma; /* tdma state */ + struct ieee80211_mesh_state *iv_mesh; /* MBSS state */ struct ieee80211_hwmp_state *iv_hwmp; /* HWMP state */ /* operate-mode detach hook */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906261730.n5QHUYMT092994>