aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2012-01-29 10:23:27 (GMT)
committerJouni Malinen <j@w1.fi>2012-01-29 10:23:27 (GMT)
commitfa7187bfde9bed2bbf25c73337c787ea75b5dfc7 (patch)
tree2d9f9931c1e86cbca39780d441641b87383477a4 /wpa_supplicant
parentf31e19df3a97f0610300c847f13c4e4b4656c477 (diff)
downloadhostap-fa7187bfde9bed2bbf25c73337c787ea75b5dfc7.zip
hostap-fa7187bfde9bed2bbf25c73337c787ea75b5dfc7.tar.gz
hostap-fa7187bfde9bed2bbf25c73337c787ea75b5dfc7.tar.bz2
IBSS RSN: Provide ibss_rsn_get_peer() helper function
This is a useful function that simplifies some code and can eventually be used somewhere else in future. Signed-hostap: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/ibss_rsn.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/wpa_supplicant/ibss_rsn.c b/wpa_supplicant/ibss_rsn.c
index d4fa39d..f9a9090 100644
--- a/wpa_supplicant/ibss_rsn.c
+++ b/wpa_supplicant/ibss_rsn.c
@@ -24,6 +24,18 @@
#include "ibss_rsn.h"
+static struct ibss_rsn_peer * ibss_rsn_get_peer(struct ibss_rsn *ibss_rsn,
+ const u8 *addr)
+{
+ struct ibss_rsn_peer *peer;
+
+ for (peer = ibss_rsn->peers; peer; peer = peer->next)
+ if (os_memcmp(addr, peer->addr, ETH_ALEN) == 0)
+ break;
+ return peer;
+}
+
+
static void ibss_rsn_free(struct ibss_rsn_peer *peer)
{
wpa_auth_sta_deinit(peer->auth);
@@ -383,13 +395,11 @@ int ibss_rsn_start(struct ibss_rsn *ibss_rsn, const u8 *addr)
if (ibss_rsn == NULL)
return -1;
- for (peer = ibss_rsn->peers; peer; peer = peer->next) {
- if (os_memcmp(addr, peer->addr, ETH_ALEN) == 0) {
- wpa_printf(MSG_DEBUG, "RSN: IBSS Authenticator and "
- "Supplicant for peer " MACSTR " already "
- "running", MAC2STR(addr));
- return 0;
- }
+ if (ibss_rsn_get_peer(ibss_rsn, addr)) {
+ wpa_printf(MSG_DEBUG, "RSN: IBSS Authenticator and Supplicant "
+ "for peer " MACSTR " already running",
+ MAC2STR(addr));
+ return 0;
}
wpa_printf(MSG_DEBUG, "RSN: Starting IBSS Authenticator and "
@@ -577,11 +587,9 @@ int ibss_rsn_rx_eapol(struct ibss_rsn *ibss_rsn, const u8 *src_addr,
if (ibss_rsn == NULL)
return -1;
- for (peer = ibss_rsn->peers; peer; peer = peer->next) {
- if (os_memcmp(src_addr, peer->addr, ETH_ALEN) == 0)
- return ibss_rsn_process_rx_eapol(ibss_rsn, peer,
- buf, len);
- }
+ peer = ibss_rsn_get_peer(ibss_rsn, src_addr);
+ if (peer)
+ return ibss_rsn_process_rx_eapol(ibss_rsn, peer, buf, len);
if (ibss_rsn_eapol_dst_supp(buf, len) > 0) {
/*