summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2018-08-06 11:28:02 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2018-08-06 11:28:02 +0000
commit8a942ff219550e8037c532317e798dc6542949ce (patch)
tree9b9d8f7d347edd430c7c2c01c69eb6ef6dfc67ce
parent756513a8315b6ca749ecd30c0f81bb32e3f9e24e (diff)
Refactor ieee80211_add_ess():
Drop ieee80211_add_ess's nwid parameter. Read nwid and length directly from the ic to make it more obvious where this function is reading from. nwids are binary data with an explicit length, so treat them as such instead of treating them like strings. ok florian phessler
-rw-r--r--sys/net80211/ieee80211_ioctl.c10
-rw-r--r--sys/net80211/ieee80211_node.c11
-rw-r--r--sys/net80211/ieee80211_var.h4
3 files changed, 13 insertions, 12 deletions
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c
index 4d6b7eb1b71..40791460678 100644
--- a/sys/net80211/ieee80211_ioctl.c
+++ b/sys/net80211/ieee80211_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_ioctl.c,v 1.61 2018/07/11 20:18:09 phessler Exp $ */
+/* $OpenBSD: ieee80211_ioctl.c,v 1.62 2018/08/06 11:28:01 stsp Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */
/*-
@@ -466,7 +466,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
ieee80211_disable_wep(ic);
/* save nwid for auto-join */
if (!(join.i_flags & IEEE80211_JOIN_DEL))
- ieee80211_add_ess(ic, ic->ic_des_essid, 0, 0);
+ ieee80211_add_ess(ic, 0, 0);
ieee80211_set_ess(ic, ic->ic_des_essid);
error = ENETRESET;
break;
@@ -493,7 +493,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
error = ieee80211_ioctl_setnwkeys(ic, (void *)data);
if (error == ENETRESET)
- ieee80211_add_ess(ic, ic->ic_des_essid, 0, 1);
+ ieee80211_add_ess(ic, 0, 1);
break;
case SIOCG80211NWKEY:
error = ieee80211_ioctl_getnwkeys(ic, (void *)data);
@@ -503,7 +503,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
error = ieee80211_ioctl_setwpaparms(ic, (void *)data);
if (error == ENETRESET)
- ieee80211_add_ess(ic, ic->ic_des_essid, 1, 0);
+ ieee80211_add_ess(ic, 1, 0);
break;
case SIOCG80211WPAPARMS:
error = ieee80211_ioctl_getwpaparms(ic, (void *)data);
@@ -521,7 +521,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
ic->ic_flags &= ~IEEE80211_F_PSK;
memset(ic->ic_psk, 0, sizeof(ic->ic_psk));
}
- ieee80211_add_ess(ic, ic->ic_des_essid, 1, 0);
+ ieee80211_add_ess(ic, 1, 0);
error = ENETRESET;
break;
case SIOCG80211WPAPSK:
diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index 434bec3001c..3a821b235a2 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.c,v 1.137 2018/08/06 09:34:17 florian Exp $ */
+/* $OpenBSD: ieee80211_node.c,v 1.138 2018/08/06 11:28:01 stsp Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*-
@@ -196,7 +196,7 @@ ieee80211_del_ess(struct ieee80211com *ic, char *nwid, int all)
}
int
-ieee80211_add_ess(struct ieee80211com *ic, char *nwid, int wpa, int wep)
+ieee80211_add_ess(struct ieee80211com *ic, int wpa, int wep)
{
struct ieee80211_ess *ess;
int i = 0, new = 0, ness = 0;
@@ -206,11 +206,12 @@ ieee80211_add_ess(struct ieee80211com *ic, char *nwid, int wpa, int wep)
return (0);
/* Don't save an empty nwid */
- if (strnlen(nwid, IEEE80211_NWID_LEN) == 0)
+ if (ic->ic_des_esslen == 0)
return (0);
TAILQ_FOREACH(ess, &ic->ic_ess, ess_next) {
- if (memcmp(ess->essid, nwid, IEEE80211_NWID_LEN) == 0)
+ if (ess->esslen == ic->ic_des_esslen &&
+ memcmp(ess->essid, ic->ic_des_essid, ess->esslen) == 0)
break;
ness++;
}
@@ -229,7 +230,7 @@ ieee80211_add_ess(struct ieee80211com *ic, char *nwid, int wpa, int wep)
ess = malloc(sizeof(*ess), M_DEVBUF, M_NOWAIT|M_ZERO);
if (ess == NULL)
return (ENOMEM);
- memcpy(ess->essid, nwid, ic->ic_des_esslen);
+ memcpy(ess->essid, ic->ic_des_essid, ic->ic_des_esslen);
ess->esslen = ic->ic_des_esslen;
}
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 49143878e69..406b1601106 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_var.h,v 1.86 2018/07/11 20:18:09 phessler Exp $ */
+/* $OpenBSD: ieee80211_var.h,v 1.87 2018/08/06 11:28:01 stsp Exp $ */
/* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */
/*-
@@ -451,7 +451,7 @@ enum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *,
const struct ieee80211_channel *);
void ieee80211_disable_wep(struct ieee80211com *);
void ieee80211_disable_rsn(struct ieee80211com *);
-int ieee80211_add_ess(struct ieee80211com *, char *, int, int);
+int ieee80211_add_ess(struct ieee80211com *, int, int);
void ieee80211_del_ess(struct ieee80211com *, char *, int);
void ieee80211_set_ess(struct ieee80211com *, char *);