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>
This commit is contained in:
parent
f31e19df3a
commit
fa7187bfde
1 changed files with 20 additions and 12 deletions
|
@ -24,6 +24,18 @@
|
||||||
#include "ibss_rsn.h"
|
#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)
|
static void ibss_rsn_free(struct ibss_rsn_peer *peer)
|
||||||
{
|
{
|
||||||
wpa_auth_sta_deinit(peer->auth);
|
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)
|
if (ibss_rsn == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (peer = ibss_rsn->peers; peer; peer = peer->next) {
|
if (ibss_rsn_get_peer(ibss_rsn, addr)) {
|
||||||
if (os_memcmp(addr, peer->addr, ETH_ALEN) == 0) {
|
wpa_printf(MSG_DEBUG, "RSN: IBSS Authenticator and Supplicant "
|
||||||
wpa_printf(MSG_DEBUG, "RSN: IBSS Authenticator and "
|
"for peer " MACSTR " already running",
|
||||||
"Supplicant for peer " MACSTR " already "
|
MAC2STR(addr));
|
||||||
"running", MAC2STR(addr));
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "RSN: Starting IBSS Authenticator and "
|
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)
|
if (ibss_rsn == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (peer = ibss_rsn->peers; peer; peer = peer->next) {
|
peer = ibss_rsn_get_peer(ibss_rsn, src_addr);
|
||||||
if (os_memcmp(src_addr, peer->addr, ETH_ALEN) == 0)
|
if (peer)
|
||||||
return ibss_rsn_process_rx_eapol(ibss_rsn, peer,
|
return ibss_rsn_process_rx_eapol(ibss_rsn, peer, buf, len);
|
||||||
buf, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ibss_rsn_eapol_dst_supp(buf, len) > 0) {
|
if (ibss_rsn_eapol_dst_supp(buf, len) > 0) {
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue