Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Oct 2009 10:08:58 +0000 (UTC)
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r197975 - head/sys/net80211
Message-ID:  <200910121008.n9CA8wId052976@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rpaulo
Date: Mon Oct 12 10:08:58 2009
New Revision: 197975
URL: http://svn.freebsd.org/changeset/base/197975

Log:
  Another 3.03 draft bit that I missed in the previous 802.11s stack
  update. The Mesh Configuration IE has changed quite a bit. Refactor the
  code to handle this change.
  
  MFC after:	3 days

Modified:
  head/sys/net80211/ieee80211_hwmp.c
  head/sys/net80211/ieee80211_mesh.c
  head/sys/net80211/ieee80211_mesh.h

Modified: head/sys/net80211/ieee80211_hwmp.c
==============================================================================
--- head/sys/net80211/ieee80211_hwmp.c	Mon Oct 12 07:29:50 2009	(r197974)
+++ head/sys/net80211/ieee80211_hwmp.c	Mon Oct 12 10:08:58 2009	(r197975)
@@ -192,7 +192,7 @@ static	ieee80211_recv_action_func hwmp_r
 
 static struct ieee80211_mesh_proto_path mesh_proto_hwmp = {
 	.mpp_descr	= "HWMP",
-	.mpp_ie		= IEEE80211_MESHCONF_HWMP,
+	.mpp_ie		= IEEE80211_MESHCONF_PATH_HWMP,
 	.mpp_discover	= hwmp_discover,
 	.mpp_peerdown	= hwmp_peerdown,
 	.mpp_vattach	= hwmp_vattach,

Modified: head/sys/net80211/ieee80211_mesh.c
==============================================================================
--- head/sys/net80211/ieee80211_mesh.c	Mon Oct 12 07:29:50 2009	(r197974)
+++ head/sys/net80211/ieee80211_mesh.c	Mon Oct 12 10:08:58 2009	(r197975)
@@ -132,7 +132,7 @@ static	ieee80211_send_action_func mesh_s
 
 static const struct ieee80211_mesh_proto_metric mesh_metric_airtime = {
 	.mpm_descr	= "AIRTIME",
-	.mpm_ie		= IEEE80211_MESHCONF_AIRTIME,
+	.mpm_ie		= IEEE80211_MESHCONF_METRIC_AIRTIME,
 	.mpm_metric	= mesh_airtime_calc,
 };
 
@@ -344,18 +344,18 @@ int
 ieee80211_mesh_register_proto_path(const struct ieee80211_mesh_proto_path *mpp)
 {
 	int i, firstempty = -1;
-	static const uint8_t emptyie[4] = { 0, 0, 0, 0 };
 
 	for (i = 0; i < N(mesh_proto_paths); i++) {
-		if (memcmp(mpp->mpp_ie, mesh_proto_paths[i].mpp_ie, 4) == 0)
+		if (strncmp(mpp->mpp_descr, mesh_proto_paths[i].mpp_descr,
+		    IEEE80211_MESH_PROTO_DSZ) == 0)
 			return EEXIST;
-		if (memcmp(mesh_proto_paths[i].mpp_ie, emptyie, 4) == 0 &&
-		    firstempty == -1)
+		if (!mesh_proto_paths[i].mpp_active && firstempty == -1)
 			firstempty = i;
 	}
 	if (firstempty < 0)
 		return ENOSPC;
 	memcpy(&mesh_proto_paths[firstempty], mpp, sizeof(*mpp));
+	mesh_proto_paths[firstempty].mpp_active = 1;
 	return 0;
 }
 
@@ -364,18 +364,18 @@ ieee80211_mesh_register_proto_metric(con
     ieee80211_mesh_proto_metric *mpm)
 {
 	int i, firstempty = -1;
-	static const uint8_t emptyie[4] = { 0, 0, 0, 0 };
 
 	for (i = 0; i < N(mesh_proto_metrics); i++) {
-		if (memcmp(mpm->mpm_ie, mesh_proto_metrics[i].mpm_ie, 4) == 0)
+		if (strncmp(mpm->mpm_descr, mesh_proto_metrics[i].mpm_descr,
+		    IEEE80211_MESH_PROTO_DSZ) == 0)
 			return EEXIST;
-		if (memcmp(mesh_proto_metrics[i].mpm_ie, emptyie, 4) == 0 &&
-		    firstempty == -1)
+		if (!mesh_proto_metrics[i].mpm_active && firstempty == -1)
 			firstempty = i;
 	}
 	if (firstempty < 0)
 		return ENOSPC;
 	memcpy(&mesh_proto_metrics[firstempty], mpm, sizeof(*mpm));
+	mesh_proto_metrics[firstempty].mpm_active = 1;
 	return 0;
 }
 
@@ -2282,51 +2282,40 @@ mesh_verify_meshid(struct ieee80211vap *
 static int
 mesh_verify_meshconf(struct ieee80211vap *vap, const uint8_t *ie)
 {
-	static const uint8_t null[4] = IEEE80211_MESHCONF_NULL;
 	const struct ieee80211_meshconf_ie *meshconf =
 	    (const struct ieee80211_meshconf_ie *) ie;
 	const struct ieee80211_mesh_state *ms = vap->iv_mesh;
 
 	if (meshconf == NULL)
 		return 1;
-	if (meshconf->conf_ver != IEEE80211_MESHCONF_VERSION) {
+	if (meshconf->conf_pselid != ms->ms_ppath->mpp_ie) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_MESH,
-		    "wrong mesh conf version: %d\n", meshconf->conf_ver);
+		    "unknown path selection algorithm: 0x%x\n",
+		    meshconf->conf_pselid);
 		return 1;
 	}
-	if (memcmp(meshconf->conf_pselid, ms->ms_ppath->mpp_ie, 4) != 0) {
+	if (meshconf->conf_pmetid != ms->ms_pmetric->mpm_ie) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_MESH,
-		    "unknown path selection algorithm: 0x%x%x%x%x\n",
-		    meshconf->conf_pselid[0], meshconf->conf_pselid[1],
-		    meshconf->conf_pselid[2], meshconf->conf_pselid[3]);
+		    "unknown path metric algorithm: 0x%x\n",
+		    meshconf->conf_pmetid);
 		return 1;
 	}
-	if (memcmp(meshconf->conf_pmetid, ms->ms_pmetric->mpm_ie, 4) != 0) {
+	if (meshconf->conf_ccid != 0) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_MESH,
-		    "unknown path metric algorithm: 0x%x%x%x%x\n",
-		    meshconf->conf_pmetid[0], meshconf->conf_pmetid[1],
-		    meshconf->conf_pmetid[2], meshconf->conf_pmetid[3]);
+		    "unknown congestion control algorithm: 0x%x\n",
+		    meshconf->conf_ccid);
 		return 1;
 	}
-	if (memcmp(meshconf->conf_ccid, null, 4) != 0) {
+	if (meshconf->conf_syncid != IEEE80211_MESHCONF_SYNC_NEIGHOFF) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_MESH,
-		    "unknown congestion sig algorithm: 0x%x%x%x%x\n",
-		    meshconf->conf_ccid[0], meshconf->conf_ccid[1],
-		    meshconf->conf_ccid[2], meshconf->conf_ccid[3]);
+		    "unknown sync algorithm: 0x%x\n",
+		    meshconf->conf_syncid);
 		return 1;
 	}
-	if (memcmp(meshconf->conf_syncid, null, 4) != 0) {
+	if (meshconf->conf_authid != 0) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_MESH,
-		    "unknown sync algorithm: 0x%x%x%x%x\n",
-		    meshconf->conf_syncid[0], meshconf->conf_syncid[1],
-		    meshconf->conf_syncid[2], meshconf->conf_syncid[3]);
-		return 1;
-	}
-	if (memcmp(meshconf->conf_authid, null, 4) != 0) {
-		IEEE80211_DPRINTF(vap, IEEE80211_MSG_MESH,
-		    "unknown auth auth algorithm: 0x%x%x%x%x\n",
-		    meshconf->conf_pselid[0], meshconf->conf_pselid[1],
-		    meshconf->conf_pselid[2], meshconf->conf_pselid[3]);
+		    "unknown auth auth algorithm: 0x%x\n",
+		    meshconf->conf_pselid);
 		return 1;
 	}
 	/* Not accepting peers */
@@ -2394,24 +2383,16 @@ uint8_t *
 ieee80211_add_meshconf(uint8_t *frm, struct ieee80211vap *vap)
 {
 	const struct ieee80211_mesh_state *ms = vap->iv_mesh;
-	static const uint8_t null[4] = IEEE80211_MESHCONF_NULL;
 
 	KASSERT(vap->iv_opmode == IEEE80211_M_MBSS, ("not a MBSS vap"));
 
 	*frm++ = IEEE80211_ELEMID_MESHCONF;
 	*frm++ = sizeof(struct ieee80211_meshconf_ie) - 2;
-	*frm++ = IEEE80211_MESHCONF_VERSION;
-	memcpy(frm, ms->ms_ppath->mpp_ie, 4);	/* path selection */
-	frm += 4;
-	memcpy(frm, ms->ms_pmetric->mpm_ie, 4);	/* link metric */
-	frm += 4;
-	/* XXX null for now */
-	memcpy(frm, null, 4);			/* congestion control */
-	frm += 4;
-	memcpy(frm, null, 4);			/* sync */
-	frm += 4;
-	memcpy(frm, null, 4);			/* auth */
-	frm += 4;
+	*frm++ = ms->ms_ppath->mpp_ie;		/* path selection */
+	*frm++ = ms->ms_pmetric->mpm_ie;	/* link metric */
+	*frm++ = IEEE80211_MESHCONF_CC_DISABLED;
+	*frm++ = IEEE80211_MESHCONF_SYNC_NEIGHOFF;
+	*frm++ = IEEE80211_MESHCONF_AUTH_DISABLED;
 	/* NB: set the number of neighbors before the rest */
 	*frm = (ms->ms_neighbors > 15 ? 15 : ms->ms_neighbors) << 1;
 	if (ms->ms_flags & IEEE80211_MESHFLAGS_PORTAL)
@@ -2440,7 +2421,7 @@ ieee80211_add_meshpeer(uint8_t *frm, uin
 	*frm++ = IEEE80211_ELEMID_MESHPEER;
 	switch (subtype) {
 	case IEEE80211_MESH_PEER_LINK_OPEN:
-		*frm++ = 6;		/* length */
+		frm++ = 6;		/* length */
 		memcpy(frm, meshpeerproto, 4);
 		frm += 4;
 		ADDSHORT(frm, localid);	/* local ID */

Modified: head/sys/net80211/ieee80211_mesh.h
==============================================================================
--- head/sys/net80211/ieee80211_mesh.h	Mon Oct 12 07:29:50 2009	(r197974)
+++ head/sys/net80211/ieee80211_mesh.h	Mon Oct 12 10:08:58 2009	(r197975)
@@ -43,47 +43,27 @@
 struct ieee80211_meshconf_ie {
 	uint8_t		conf_ie;	/* IEEE80211_ELEMID_MESHCONF */
 	uint8_t		conf_len;
-	uint8_t		conf_ver;
-	uint8_t		conf_pselid[4];	/* Active Path Sel. Proto. ID */
-	uint8_t		conf_pmetid[4];	/* APS Metric Identifier */
-	uint8_t		conf_ccid[4];	/* Congestion Control Mode ID  */
-	uint8_t		conf_syncid[4];	/* Sync. Protocol ID */
-	uint8_t		conf_authid[4];	/* Auth. Protocol ID */
+	uint8_t		conf_pselid;	/* Active Path Sel. Proto. ID */
+	uint8_t		conf_pmetid;	/* Active Metric Identifier */
+	uint8_t		conf_ccid;	/* Congestion Control Mode ID  */
+	uint8_t		conf_syncid;	/* Sync. Protocol ID */
+	uint8_t		conf_authid;	/* Auth. Protocol ID */
 	uint8_t		conf_form;	/* Formation Information */
 	uint8_t		conf_cap;
 } __packed;
 
-#define	IEEE80211_MESHCONF_VERSION		1
-/* Null Protocol */
-#define	IEEE80211_MESHCONF_NULL_OUI		0x00, 0x0f, 0xac
-#define	IEEE80211_MESHCONF_NULL_VALUE		0xff
-#define	IEEE80211_MESHCONF_NULL		{ IEEE80211_MESHCONF_NULL_OUI, \
-					  IEEE80211_MESHCONF_NULL_VALUE }
 /* Hybrid Wireless Mesh Protocol */
-#define	IEEE80211_MESHCONF_HWMP_OUI		0x00, 0x0f, 0xac
-#define	IEEE80211_MESHCONF_HWMP_VALUE		0x00
-#define	IEEE80211_MESHCONF_HWMP		{ IEEE80211_MESHCONF_HWMP_OUI, \
-					  IEEE80211_MESHCONF_HWMP_VALUE }
+#define	IEEE80211_MESHCONF_PATH_HWMP		0x00
 /* Airtime Link Metric */
-#define	IEEE80211_MESHCONF_AIRTIME_OUI		0x00, 0x0f, 0xac
-#define	IEEE80211_MESHCONF_AIRTIME_VALUE	0x00
-#define	IEEE80211_MESHCONF_AIRTIME	{ IEEE80211_MESHCONF_AIRTIME_OUI, \
-					  IEEE80211_MESHCONF_AIRTIME_VALUE }
-/* Congestion Control Signaling */
-#define	IEEE80211_MESHCONF_CCSIG_OUI		0x00, 0x0f, 0xac
-#define	IEEE80211_MESHCONF_CCSIG_VALUE		0x00
-#define	IEEE80211_MESHCONF_CCSIG	{ IEEE80211_MESHCONF_CCSIG_OUI,\
-					  IEEE80211_MESHCONF_CCSIG_VALUE }
+#define	IEEE80211_MESHCONF_METRIC_AIRTIME	0x00
+/* Congestion Control */
+#define	IEEE80211_MESHCONF_CC_DISABLED		0x00
+#define	IEEE80211_MESHCONF_CC_SIG		0x01
 /* Neighbour Offset */
-#define	IEEE80211_MESHCONF_NEIGHOFF_OUI		0x00, 0x0f, 0xac
-#define	IEEE80211_MESHCONF_NEIGHOFF_VALUE	0x00
-#define	IEEE80211_MESHCONF_NEIGHOFF	{ IEEE80211_MESHCONF_NEIGHOFF_OUI, \
-					  IEEE80211_MESHCONF_NEIGHOFF_VALUE }
+#define	IEEE80211_MESHCONF_SYNC_NEIGHOFF	0x00
+#define	IEEE80211_MESHCONF_AUTH_DISABLED	0x00
 /* Simultaneous Authenticaction of Equals */
-#define	IEEE80211_MESHCONF_SAE_OUI		0x00, 0x0f, 0xac
-#define	IEEE80211_MESHCONF_SAE_VALUE		0x01
-#define	IEEE80211_MESHCONF_SAE		{ IEEE80211_MESHCONF_SAE_OUI, \
-					  IEEE80211_MESHCONF_SAE_VALUE }
+#define	IEEE80211_MESHCONF_AUTH_SAE		0x01
 #define	IEEE80211_MESHCONF_FORM_MP		0x01 /* Connected to Portal */
 #define	IEEE80211_MESHCONF_FORM_NNEIGH_MASK	0x04 /* Number of Neighbours */
 #define	IEEE80211_MESHCONF_CAP_AP	0x01	/* Accepting Peers */
@@ -390,8 +370,9 @@ struct ieee80211_mesh_route {
  */
 enum ieee80211_state;
 struct ieee80211_mesh_proto_path {
+	uint8_t		mpp_active;
 	char 		mpp_descr[IEEE80211_MESH_PROTO_DSZ];
-	uint8_t		mpp_ie[4];
+	uint8_t		mpp_ie;
 	struct ieee80211_node *
 	    		(*mpp_discover)(struct ieee80211vap *,
 				const uint8_t [IEEE80211_ADDR_LEN],
@@ -411,8 +392,9 @@ struct ieee80211_mesh_proto_path {
  * Mesh Link Metric Report Protocol.
  */
 struct ieee80211_mesh_proto_metric {
+	uint8_t		mpm_active;
 	char		mpm_descr[IEEE80211_MESH_PROTO_DSZ];
-	uint8_t		mpm_ie[4];
+	uint8_t		mpm_ie;
 	uint32_t	(*mpm_metric)(struct ieee80211_node *);
 };
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910121008.n9CA8wId052976>