svn commit: r195204 - projects/mesh11s/sys/net80211
Rui Paulo
rpaulo at FreeBSD.org
Tue Jun 30 19:23:45 UTC 2009
Author: rpaulo
Date: Tue Jun 30 19:23:44 2009
New Revision: 195204
URL: http://svn.freebsd.org/changeset/base/195204
Log:
General cleanup:
* use LE_WRITE
* fix add_meshconf() to be reentrant
* add a mesh seq number type
Pointed out by: sam
Sponsored by: The FreeBSD Foundation
> Submitted by: If someone else sent in the change.
> Reviewed by: If someone else reviewed your modification.
> Approved by: If you needed approval for this commit.
> Obtained from: If the change is from a third party.
> MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email.
> Security: Vulnerability reference (one per line) or description.
> Empty fields above will be automatically removed.
M ieee80211_output.c
M ieee80211_mesh.c
M ieee80211_mesh.h
Modified:
projects/mesh11s/sys/net80211/ieee80211_mesh.c
projects/mesh11s/sys/net80211/ieee80211_mesh.h
projects/mesh11s/sys/net80211/ieee80211_output.c
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.c Tue Jun 30 19:10:17 2009 (r195203)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Tue Jun 30 19:23:44 2009 (r195204)
@@ -1505,7 +1505,8 @@ ieee80211_add_meshconf(uint8_t *frm, str
{
uint8_t neighs = 0;
struct ieee80211_mesh_state *ms = vap->iv_mesh;
- static struct ieee80211_meshconf_ie ie = {
+ /* XXX needs to be changed for other protocols */
+ static const struct ieee80211_meshconf_ie ie = {
.conf_ie = IEEE80211_ELEMID_MESHCONF,
.conf_len = sizeof(struct ieee80211_meshconf_ie) - 2,
.conf_ver = IEEE80211_MESHCONF_VERSION,
@@ -1514,25 +1515,25 @@ ieee80211_add_meshconf(uint8_t *frm, str
.conf_ccid = IEEE80211_MESHCONF_NULL,
.conf_syncid = IEEE80211_MESHCONF_NULL,
.conf_authid = IEEE80211_MESHCONF_NULL,
- /* NB: set below */
- .conf_form = 0,
- .conf_cap = 0,
};
KASSERT(vap->iv_opmode == IEEE80211_M_MBSS, ("not a MBSS vap"));
- /* NB: set the number of neighbors before anything else */
+ memcpy(frm, &ie, sizeof(ie));
+ frm += __offsetof(struct ieee80211_meshconf_ie, conf_form);
ieee80211_iterate_nodes(&vap->iv_ic->ic_sta, meshconf_neighbors,
&neighs);
- ie.conf_form = neighs << 1;
+ /* NB: set the number of neighbors before the rest */
+ *frm = neighs << 1;
if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL)
- ie.conf_form |= IEEE80211_MESHCONF_FORM_MP;
+ *frm |= IEEE80211_MESHCONF_FORM_MP;
+ frm += 1;
if (ms->ms_flags & IEEE80211_MESHFLAGS_AP)
- ie.conf_cap |= IEEE80211_MESHCONF_CAP_AP;
+ *frm |= IEEE80211_MESHCONF_CAP_AP;
if (ms->ms_flags & IEEE80211_MESHFLAGS_FWD)
- ie.conf_cap |= IEEE80211_MESHCONF_CAP_FWRD;
- memcpy(frm, &ie, sizeof(ie));
- return frm + sizeof(ie);
+ *frm |= IEEE80211_MESHCONF_CAP_FWRD;
+ frm += 1;
+ return frm;
}
/*
Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.h
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_mesh.h Tue Jun 30 19:10:17 2009 (r195203)
+++ projects/mesh11s/sys/net80211/ieee80211_mesh.h Tue Jun 30 19:23:44 2009 (r195204)
@@ -390,10 +390,13 @@ struct ieee80211_mesh_proto {
uint32_t (*mpr_linkmetric)(struct ieee80211_node *);
/* XXX needs more methods */
};
+
+typedef uint32_t ieee80211_mesh_seq;
+
struct ieee80211_mesh_state {
int ms_idlen;
uint8_t ms_id[IEEE80211_MESHID_LEN];
- uint32_t ms_seq; /* seq no for meshcntl */
+ ieee80211_mesh_seq 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 */
Modified: projects/mesh11s/sys/net80211/ieee80211_output.c
==============================================================================
--- projects/mesh11s/sys/net80211/ieee80211_output.c Tue Jun 30 19:10:17 2009 (r195203)
+++ projects/mesh11s/sys/net80211/ieee80211_output.c Tue Jun 30 19:23:44 2009 (r195204)
@@ -73,6 +73,18 @@ __FBSDID("$FreeBSD$");
#define ETHER_HEADER_COPY(dst, src) \
memcpy(dst, src, sizeof(struct ether_header))
+/* unalligned little endian access */
+#define LE_WRITE_2(p, v) do { \
+ ((uint8_t *)(p))[0] = (v) & 0xff; \
+ ((uint8_t *)(p))[1] = ((v) >> 8) & 0xff; \
+} while (0)
+#define LE_WRITE_4(p, v) do { \
+ ((uint8_t *)(p))[0] = (v) & 0xff; \
+ ((uint8_t *)(p))[1] = ((v) >> 8) & 0xff; \
+ ((uint8_t *)(p))[2] = ((v) >> 16) & 0xff; \
+ ((uint8_t *)(p))[3] = ((v) >> 24) & 0xff; \
+} while (0)
+
static int ieee80211_fragment(struct ieee80211vap *, struct mbuf *,
u_int hdrsize, u_int ciphdrsize, u_int mtu);
static void ieee80211_tx_mgt_cb(struct ieee80211_node *, void *, int);
@@ -567,10 +579,9 @@ ieee80211_send_action(struct ieee80211_n
int category, int action, union ieee80211_send_action_args sargs)
{
#define senderr(_x, _v) do { vap->iv_stats._v++; ret = _x; goto bad; } while (0)
-#define ADDSHORT(frm, v) do { \
- frm[0] = (v) & 0xff; \
- frm[1] = (v) >> 8; \
- frm += 2; \
+#define ADDSHORT(frm, v) do { \
+ LE_WRITE_2(frm, v); \
+ frm += 2; \
} while (0)
#define MS(_v, _f) (((_v) & _f) >> _f##_S)
#define SM(_v, _f) (((_v) << _f##_S) & _f)
@@ -1261,7 +1272,6 @@ ieee80211_encap(struct ieee80211vap *vap
ieee80211_seq seqno;
int meshhdrsize, meshae;
struct ieee80211_meshcntl_ae11 *mc;
- uint32_t seq;
uint8_t *qos;
/*
@@ -1487,11 +1497,7 @@ ieee80211_encap(struct ieee80211vap *vap
break;
}
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;
- mc->mc_seq[3] = (seq >> 24) & 0xff;
+ LE_WRITE_4(mc->mc_seq, ++ms->ms_seq);
break;
case IEEE80211_M_MONITOR:
case IEEE80211_M_WDS: /* NB: is4addr should always be true */
@@ -1760,10 +1766,9 @@ ieee80211_add_erp(uint8_t *frm, struct i
static uint8_t *
ieee80211_add_cfparms(uint8_t *frm, struct ieee80211com *ic)
{
-#define ADDSHORT(frm, v) do { \
- frm[0] = (v) & 0xff; \
- frm[1] = (v) >> 8; \
- frm += 2; \
+#define ADDSHORT(frm, v) do { \
+ LE_WRITE_2(frm, v); \
+ frm += 2; \
} while (0)
*frm++ = IEEE80211_ELEMID_CFPARMS;
*frm++ = 6;
@@ -1816,10 +1821,9 @@ static uint8_t *
ieee80211_add_wme_param(uint8_t *frm, struct ieee80211_wme_state *wme)
{
#define SM(_v, _f) (((_v) << _f##_S) & _f)
-#define ADDSHORT(frm, v) do { \
- frm[0] = (v) & 0xff; \
- frm[1] = (v) >> 8; \
- frm += 2; \
+#define ADDSHORT(frm, v) do { \
+ LE_WRITE_2(frm, v); \
+ frm += 2; \
} while (0)
/* NB: this works 'cuz a param has an info at the front */
static const struct ieee80211_wme_info param = {
More information about the svn-src-projects
mailing list