Date: Mon, 29 Jun 2009 18:33:58 +0000 (UTC) From: Rui Paulo <rpaulo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r195170 - projects/mesh11s/sys/net80211 Message-ID: <200906291833.n5TIXwsK052805@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rpaulo Date: Mon Jun 29 18:33:58 2009 New Revision: 195170 URL: http://svn.freebsd.org/changeset/base/195170 Log: Rename hwmp route variables to something more meaningful. Sponsored by: The FreeBSD Foundation Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c projects/mesh11s/sys/net80211/ieee80211_hwmp.h Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Mon Jun 29 18:17:24 2009 (r195169) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Mon Jun 29 18:33:58 2009 (r195170) @@ -63,10 +63,10 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_hwmp.h> #include <net80211/ieee80211_input.h> -static struct ieee80211_hwmp_fi * +static struct ieee80211_hwmp_route * hwmp_rt_find(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); -static struct ieee80211_hwmp_fi * +static struct ieee80211_hwmp_route * hwmp_rt_add(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); static void hwmp_rt_del(struct ieee80211vap *, @@ -145,54 +145,54 @@ MALLOC_DEFINE(M_80211_HWMP, "80211hwmp", /* * Helper functions to manipulate the HWMP routing table. */ -static struct ieee80211_hwmp_fi * +static struct ieee80211_hwmp_route * hwmp_rt_find(struct ieee80211vap *vap, const uint8_t dest[IEEE80211_ADDR_LEN]) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi; + struct ieee80211_hwmp_route *rt; HWMP_LOCK(hs); - TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { - if (IEEE80211_ADDR_EQ(dest, fi->fi_dest)) { + TAILQ_FOREACH(rt, &hs->hs_routes, rt_next) { + if (IEEE80211_ADDR_EQ(dest, rt->rt_dest)) { HWMP_UNLOCK(hs); - return fi; + return rt; } } HWMP_UNLOCK(hs); return NULL; } -static struct ieee80211_hwmp_fi * +static struct ieee80211_hwmp_route * hwmp_rt_add(struct ieee80211vap *vap, const uint8_t dest[IEEE80211_ADDR_LEN]) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi; + struct ieee80211_hwmp_route *rt; KASSERT(hwmp_rt_find(vap, dest) == NULL, ("%s: duplicate entry in the routing table", __func__)); - fi = malloc(sizeof(struct ieee80211_hwmp_fi), M_80211_HWMP, + rt = malloc(sizeof(struct ieee80211_hwmp_route), M_80211_HWMP, M_NOWAIT | M_ZERO); - memset(fi, 0, sizeof(*fi)); - IEEE80211_ADDR_COPY(fi->fi_dest, dest); + memset(rt, 0, sizeof(*rt)); + IEEE80211_ADDR_COPY(rt->rt_dest, dest); HWMP_LOCK(hs); - TAILQ_INSERT_TAIL(&hs->hs_head, fi, fi_next); + TAILQ_INSERT_TAIL(&hs->hs_routes, rt, rt_next); HWMP_UNLOCK(hs); - return fi; + return rt; } static void hwmp_rt_del(struct ieee80211vap *vap, const uint8_t dest[IEEE80211_ADDR_LEN]) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi, *next; + struct ieee80211_hwmp_route *rt, *next; KASSERT(hs != NULL, ("no HWMP state")); HWMP_LOCK(hs); - TAILQ_FOREACH_SAFE(fi, &hs->hs_head, fi_next, next) { - if (IEEE80211_ADDR_EQ(fi->fi_dest, dest)) { - TAILQ_REMOVE(&hs->hs_head, fi, fi_next); - free(fi, M_80211_HWMP); + TAILQ_FOREACH_SAFE(rt, &hs->hs_routes, rt_next, next) { + if (IEEE80211_ADDR_EQ(rt->rt_dest, dest)) { + TAILQ_REMOVE(&hs->hs_routes, rt, rt_next); + free(rt, M_80211_HWMP); HWMP_UNLOCK(hs); return; } @@ -204,14 +204,14 @@ static void hwmp_rt_flush(struct ieee80211vap *vap) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi, *next; + struct ieee80211_hwmp_route *rt, *next; if (hs == NULL) return; HWMP_LOCK(hs); - TAILQ_FOREACH_SAFE(fi, &hs->hs_head, fi_next, next) { - TAILQ_REMOVE(&hs->hs_head, fi, fi_next); - free(fi, M_80211_HWMP); + TAILQ_FOREACH_SAFE(rt, &hs->hs_routes, rt_next, next) { + TAILQ_REMOVE(&hs->hs_routes, rt, rt_next); + free(rt, M_80211_HWMP); } HWMP_UNLOCK(hs); } @@ -230,7 +230,7 @@ ieee80211_hwmp_vattach(struct ieee80211v printf("%s: couldn't alloc HWMP state\n", __func__); return; } - TAILQ_INIT(&hs->hs_head); + TAILQ_INIT(&hs->hs_routes); mtx_init(&hs->hs_lock, "HWMP", "802.11s HWMP", MTX_DEF); hs->hs_maxhops = IEEE80211_HWMP_DEFAULT_MAXHOPS; hs->hs_ttl = IEEE80211_HWMP_DEFAULT_TTL; @@ -563,7 +563,7 @@ hwmp_recv_preq(struct ieee80211vap *vap, { struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi = NULL; + struct ieee80211_hwmp_route *rt = NULL; /* * Ignore PREQs from us. Could happen because someone forward it @@ -611,17 +611,17 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* * Build the reverse path, if we don't have it already. */ - fi = hwmp_rt_find(vap, preq->preq_origaddr); - if (fi == NULL) { + rt = hwmp_rt_find(vap, preq->preq_origaddr); + if (rt == NULL) { uint8_t *dest = (uint8_t *)preq->preq_origaddr; ieee80211_hwmp_discover(vap, dest, NULL); - } else if (IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) - ieee80211_hwmp_discover(vap, fi->fi_dest, NULL); + } else if (IEEE80211_ADDR_EQ(rt->rt_nexthop, invalidaddr)) + ieee80211_hwmp_discover(vap, rt->rt_dest, NULL); #endif return; } - fi = hwmp_rt_find(vap, PREQ_TADDR(0)); + rt = hwmp_rt_find(vap, PREQ_TADDR(0)); /* XXX missing. Check for AE bit and update proxy information */ @@ -635,10 +635,10 @@ hwmp_recv_preq(struct ieee80211vap *vap, /* * We have a valid route to this node. */ - if (fi != NULL && - !IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) { - fi->fi_preqid = preq->preq_id; - fi->fi_seq = preq->preq_origseq; + if (rt != NULL && + !IEEE80211_ADDR_EQ(rt->rt_nexthop, invalidaddr)) { + rt->rt_preqid = preq->preq_id; + rt->rt_seq = preq->preq_origseq; if (preq->preq_ttl > 1) { IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, @@ -672,13 +672,13 @@ hwmp_recv_preq(struct ieee80211vap *vap, "intermediate reply for PREQ from %s", ether_sprintf(preq->preq_origaddr)); prep.prep_flags = 0; - prep.prep_hopcount = fi->fi_nhops + 1; + prep.prep_hopcount = rt->rt_nhops + 1; prep.prep_ttl = hs->hs_ttl; IEEE80211_ADDR_COPY(&prep.prep_targetaddr, preq->preq_origaddr); - prep.prep_targetseq = fi->fi_seq; + prep.prep_targetseq = rt->rt_seq; prep.prep_lifetime = preq->preq_lifetime; - prep.prep_metric = fi->fi_metric + + prep.prep_metric = rt->rt_metric + ieee80211_airtime_calc(ni); IEEE80211_ADDR_COPY(&prep.prep_origaddr, PREQ_TADDR(0)); @@ -691,13 +691,13 @@ hwmp_recv_preq(struct ieee80211vap *vap, * propagate the PREQ based on TTL. */ } else if (preq->preq_ttl > 1) { - if (fi == NULL) { - fi = hwmp_rt_add(vap, PREQ_TADDR(0)); - fi->fi_metric = preq->preq_metric; - fi->fi_lifetime = preq->preq_lifetime; + if (rt == NULL) { + rt = hwmp_rt_add(vap, PREQ_TADDR(0)); + rt->rt_metric = preq->preq_metric; + rt->rt_lifetime = preq->preq_lifetime; } - fi->fi_seq = preq->preq_origseq; - fi->fi_preqid = preq->preq_id; + rt->rt_seq = preq->preq_origseq; + rt->rt_preqid = preq->preq_id; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "forwarding PREQ from %s", @@ -768,7 +768,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, 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; + struct ieee80211_hwmp_route *rt = NULL; /* * Acceptance criteria: if the PREP was not generated by us and @@ -805,16 +805,16 @@ hwmp_recv_prep(struct ieee80211vap *vap, return; } - fi = hwmp_rt_find(vap, prep->prep_origaddr); - if (fi != NULL) { + rt = hwmp_rt_find(vap, prep->prep_origaddr); + if (rt != NULL) { /* * Build the rest of the entry. * XXX check for SEQ and PREQ ID. */ - IEEE80211_ADDR_COPY(fi->fi_nexthop, wh->i_addr2); - fi->fi_nhops = prep->prep_hopcount; - fi->fi_lifetime = prep->prep_lifetime; - fi->fi_metric = prep->prep_metric; + IEEE80211_ADDR_COPY(rt->rt_nexthop, wh->i_addr2); + rt->rt_nhops = prep->prep_hopcount; + rt->rt_lifetime = prep->prep_lifetime; + rt->rt_metric = prep->prep_metric; } /* @@ -827,7 +827,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, * update the proxy information table. */ #if 0 - if (fi != NULL) { + if (rt != NULL) { struct ieee80211com *ic = vap->iv_ic; struct ifnet *ifp = vap->iv_ifp; struct mbuf *m, *next; @@ -840,7 +840,7 @@ hwmp_recv_prep(struct ieee80211vap *vap, */ m = ieee80211_ageq_remove(&ic->ic_stageq, (struct ieee80211_node *)(uintptr_t) - ieee80211_mac_hash(ic, fi->fi_dest)); + ieee80211_mac_hash(ic, rt->rt_dest)); for (; m != NULL; m = next) { next = m->m_nextpkt; m->m_nextpkt = NULL; @@ -886,17 +886,17 @@ ieee80211_hwmp_peerdown(struct ieee80211 { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211_meshperr_ie perr; - struct ieee80211_hwmp_fi *fi; + struct ieee80211_hwmp_route *rt; - fi = hwmp_rt_find(vap, ni->ni_macaddr); - if (fi == NULL) + rt = hwmp_rt_find(vap, ni->ni_macaddr); + if (rt == NULL) return; IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "%s", "deleting route entry"); perr.perr_mode = 0; perr.perr_ndests = 1; - IEEE80211_ADDR_COPY(PERR_DADDR(0), fi->fi_dest); - PERR_DSEQ(0) = fi->fi_seq; + IEEE80211_ADDR_COPY(PERR_DADDR(0), rt->rt_dest); + PERR_DSEQ(0) = rt->rt_seq; hwmp_rt_del(vap, ni->ni_macaddr); hwmp_send_perr(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &perr); } @@ -911,7 +911,7 @@ hwmp_recv_perr(struct ieee80211vap *vap, 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_hwmp_route *rt = NULL; struct ieee80211_meshperr_ie pperr; int i, forward = 0; @@ -927,12 +927,12 @@ hwmp_recv_perr(struct ieee80211vap *vap, * Find all routing entries that match and delete them. */ for (i = 0; i < perr->perr_ndests; i++) { - fi = hwmp_rt_find(vap, PERR_DADDR(i)); - if (fi == NULL) + rt = hwmp_rt_find(vap, PERR_DADDR(i)); + if (rt == NULL) continue; - if (PERR_DSEQ(i) >= fi->fi_seq) { - hwmp_rt_del(vap, fi->fi_dest); - fi = NULL; + if (PERR_DSEQ(i) >= rt->rt_seq) { + hwmp_rt_del(vap, rt->rt_dest); + rt = NULL; forward = 1; } } @@ -985,7 +985,7 @@ hwmp_recv_rann(struct ieee80211vap *vap, { struct ieee80211_mesh_state *ms = vap->iv_mesh; struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi = NULL; + struct ieee80211_hwmp_route *rt = NULL; /* * Acceptance criteria: check the HWMP sequence number @@ -993,9 +993,9 @@ hwmp_recv_rann(struct ieee80211vap *vap, * XXX: TBD */ - fi = hwmp_rt_find(vap, rann->rann_addr); + rt = hwmp_rt_find(vap, rann->rann_addr); - if (fi == NULL) { + if (rt == NULL) { struct ieee80211_meshpreq_ie preq; /* @@ -1058,7 +1058,7 @@ ieee80211_hwmp_discover(struct ieee80211 uint8_t dest[IEEE80211_ADDR_LEN], struct mbuf *m) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi = NULL; + struct ieee80211_hwmp_route *rt = NULL; struct ieee80211_meshpreq_ie preq; struct ieee80211_node *ni; int sendpreq = 0, unknowndst = 0; @@ -1071,21 +1071,21 @@ ieee80211_hwmp_discover(struct ieee80211 ni = NULL; if (!IEEE80211_IS_MULTICAST(dest)) { - fi = hwmp_rt_find(vap, dest); - if (fi == NULL) { - fi = hwmp_rt_add(vap, dest); - if (fi == NULL) { + rt = hwmp_rt_find(vap, dest); + if (rt == NULL) { + rt = hwmp_rt_add(vap, dest); + if (rt == NULL) { /* XXX stat+msg */ goto done; } - fi->fi_seq = ++hs->hs_seq; - fi->fi_preqid = ++hs->hs_preqid; - fi->fi_metric = IEEE80211_MESHLMETRIC_INITIALVAL; - fi->fi_lifetime = + rt->rt_seq = ++hs->hs_seq; + rt->rt_preqid = ++hs->hs_preqid; + rt->rt_metric = IEEE80211_MESHLMETRIC_INITIALVAL; + rt->rt_lifetime = timeval2msecs(ieee80211_hwmp_pathtimeout); sendpreq = 1; unknowndst = 1; - } else if (IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) { + } else if (IEEE80211_ADDR_EQ(rt->rt_nexthop, invalidaddr)) { /* XXX check preq retries */ sendpreq = 1; unknowndst = 1; @@ -1099,11 +1099,11 @@ ieee80211_hwmp_discover(struct ieee80211 preq.preq_flags = 0; preq.preq_hopcount = 0; preq.preq_ttl = hs->hs_ttl; - preq.preq_id = fi->fi_preqid; + preq.preq_id = rt->rt_preqid; IEEE80211_ADDR_COPY(preq.preq_origaddr, vap->iv_myaddr); - preq.preq_origseq = fi->fi_seq; - preq.preq_lifetime = fi->fi_lifetime; - preq.preq_metric = fi->fi_metric; + preq.preq_origseq = rt->rt_seq; + preq.preq_lifetime = rt->rt_lifetime; + preq.preq_metric = rt->rt_metric; preq.preq_tcount = 1; IEEE80211_ADDR_COPY(PREQ_TADDR(0), dest); PREQ_TFLAGS(0) = 0; @@ -1115,13 +1115,13 @@ ieee80211_hwmp_discover(struct ieee80211 PREQ_TFLAGS(0) |= IEEE80211_MESHPREQ_TFLAGS_USN; PREQ_TSEQ(0) = 0; } else - PREQ_TSEQ(0) = fi->fi_seq; + PREQ_TSEQ(0) = rt->rt_seq; /* XXX check return value */ hwmp_send_preq(vap->iv_bss, vap->iv_myaddr, broadcastaddr, &preq); } - if (!IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) - ni = ieee80211_find_txnode(vap, fi->fi_nexthop); + if (!IEEE80211_ADDR_EQ(rt->rt_nexthop, invalidaddr)) + ni = ieee80211_find_txnode(vap, rt->rt_nexthop); } else { ni = ieee80211_find_txnode(vap, dest); return ni; @@ -1161,19 +1161,19 @@ struct ieee80211_node * ieee80211_hwmp_find_txnode(struct ieee80211vap *vap, uint8_t dest[IEEE80211_ADDR_LEN]) { - struct ieee80211_hwmp_fi *fi; + struct ieee80211_hwmp_route *rt; - fi = hwmp_rt_find(vap, dest); - if (fi == NULL) + rt = hwmp_rt_find(vap, dest); + if (rt == NULL) return NULL; - return ieee80211_find_txnode(vap, fi->fi_nexthop); + return ieee80211_find_txnode(vap, rt->rt_nexthop); } static int hwmp_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq) { struct ieee80211_hwmp_state *hs = vap->iv_hwmp; - struct ieee80211_hwmp_fi *fi; + struct ieee80211_hwmp_route *rt; size_t len, off; uint8_t *p; int error; @@ -1187,11 +1187,11 @@ hwmp_ioctl_get80211(struct ieee80211vap case IEEE80211_HWMP_CMD_LIST: len = 0; HWMP_LOCK(hs); - TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { - len += sizeof(*fi); + TAILQ_FOREACH(rt, &hs->hs_routes, rt_next) { + len += sizeof(*rt); } HWMP_UNLOCK(hs); - if (len > ireq->i_len || ireq->i_len < sizeof(*fi)) + if (len > ireq->i_len || ireq->i_len < sizeof(*rt)) return ENOMEM; ireq->i_len = len; p = malloc(len, M_TEMP, M_NOWAIT | M_ZERO); @@ -1199,11 +1199,11 @@ hwmp_ioctl_get80211(struct ieee80211vap return ENOMEM; off = 0; HWMP_LOCK(hs); - TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { + TAILQ_FOREACH(rt, &hs->hs_routes, rt_next) { if (off >= len) break; - memcpy(p + off, fi, sizeof(*fi)); - off += sizeof(*fi); + memcpy(p + off, rt, sizeof(*rt)); + off += sizeof(*rt); } HWMP_UNLOCK(hs); error = copyout(p, (uint8_t *)ireq->i_data, Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.h Mon Jun 29 18:17:24 2009 (r195169) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.h Mon Jun 29 18:33:58 2009 (r195170) @@ -37,17 +37,17 @@ typedef uint32_t ieee80211_hwmp_seq; /* * 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_hwmp_seq fi_seq; /* HWMP sequence number */ - ieee80211_hwmp_seq fi_preqid; /* Last PREQ ID seen */ - 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; - int fi_preqretries; +struct ieee80211_hwmp_route { + TAILQ_ENTRY(ieee80211_hwmp_route) rt_next; + uint8_t rt_dest[IEEE80211_ADDR_LEN]; + ieee80211_hwmp_seq rt_seq; /* HWMP sequence number */ + ieee80211_hwmp_seq rt_preqid; /* Last PREQ ID seen */ + uint8_t rt_nexthop[IEEE80211_ADDR_LEN]; + uint32_t rt_metric; /* Path Metric */ + uint32_t rt_nhops; /* Number of Hops */ + uint8_t rt_prevhop[IEEE80211_ADDR_LEN]; + uint32_t rt_lifetime; + int rt_preqretries; }; #ifdef _KERNEL @@ -55,7 +55,7 @@ struct ieee80211_hwmp_fi { MALLOC_DECLARE(M_80211_HWMP); struct ieee80211_hwmp_state { - TAILQ_HEAD(, ieee80211_hwmp_fi) hs_head; + TAILQ_HEAD(, ieee80211_hwmp_route) hs_routes; ieee80211_hwmp_seq hs_seq; /* next seq to be used */ ieee80211_hwmp_seq hs_preqid; /* next PREQ ID to be used */ struct timeval hs_lastpreq; /* last time we sent a PREQ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906291833.n5TIXwsK052805>