aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2016-08-15 09:43:42 (GMT)
committerJouni Malinen <j@w1.fi>2016-08-28 18:27:05 (GMT)
commit0dabf79b5d044ce8a4a188b854a720adb88cbda9 (patch)
tree1a6ed61e5800899b48d58440f06bbe1cf322df95 /src
parent53080f770ceb0d50449a3c15ebf3001775e36aca (diff)
downloadhostap-0dabf79b5d044ce8a4a188b854a720adb88cbda9.zip
hostap-0dabf79b5d044ce8a4a188b854a720adb88cbda9.tar.gz
hostap-0dabf79b5d044ce8a4a188b854a720adb88cbda9.tar.bz2
mka: Introduce compare_priorities()
This takes care of priority comparison followed by MAC address comparison if the priorities are identical. Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Diffstat (limited to 'src')
-rw-r--r--src/pae/ieee802_1x_kay.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
index f030c3b..bbeab55 100644
--- a/src/pae/ieee802_1x_kay.c
+++ b/src/pae/ieee802_1x_kay.c
@@ -2089,6 +2089,18 @@ ieee802_1x_kay_generate_new_sak(struct ieee802_1x_mka_participant *participant)
}
+static int compare_priorities(const struct ieee802_1x_kay_peer *peer,
+ const struct ieee802_1x_kay_peer *other)
+{
+ if (peer->key_server_priority < other->key_server_priority)
+ return -1;
+ if (other->key_server_priority < peer->key_server_priority)
+ return 1;
+
+ return os_memcmp(peer->sci.addr, other->sci.addr, ETH_ALEN);
+}
+
+
/**
* ieee802_1x_kay_elect_key_server - elect the key server
* when to elect: whenever the live peers list changes
@@ -2119,29 +2131,19 @@ ieee802_1x_kay_elect_key_server(struct ieee802_1x_mka_participant *participant)
continue;
}
- if (peer->key_server_priority <
- key_server->key_server_priority) {
+ if (compare_priorities(peer, key_server) < 0)
key_server = peer;
- } else if (peer->key_server_priority ==
- key_server->key_server_priority) {
- if (os_memcmp(peer->sci.addr, key_server->sci.addr,
- ETH_ALEN) < 0)
- key_server = peer;
- }
}
/* elect the key server between me and the above elected peer */
i_is_key_server = FALSE;
if (key_server && participant->can_be_key_server) {
- if (kay->actor_priority
- < key_server->key_server_priority) {
+ struct ieee802_1x_kay_peer tmp;
+
+ tmp.key_server_priority = kay->actor_priority;
+ os_memcpy(&tmp.sci, &kay->actor_sci, sizeof(tmp.sci));
+ if (compare_priorities(&tmp, key_server) < 0)
i_is_key_server = TRUE;
- } else if (kay->actor_priority
- == key_server->key_server_priority) {
- if (os_memcmp(kay->actor_sci.addr, key_server->sci.addr,
- ETH_ALEN) < 0)
- i_is_key_server = TRUE;
- }
} else if (participant->can_be_key_server) {
i_is_key_server = TRUE;
}