summaryrefslogtreecommitdiffstats
path: root/src/protocols/ec25519_fhmqvc/handshake.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-19 20:00:36 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-19 20:00:36 +0200
commit6798a76ffa1b4de4ec0ea07286c3510d86c0e3b6 (patch)
treea755a36afca70baaab878d391341129eb95e0873 /src/protocols/ec25519_fhmqvc/handshake.c
parent2e14d72936d1ccfb6faed4a20dec7072fb6d8232 (diff)
downloadfastd-6798a76ffa1b4de4ec0ea07286c3510d86c0e3b6.tar
fastd-6798a76ffa1b4de4ec0ea07286c3510d86c0e3b6.zip
Store peers as vectors of pointers instead of linked lists
Diffstat (limited to 'src/protocols/ec25519_fhmqvc/handshake.c')
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c
index 9339475..ef601df 100644
--- a/src/protocols/ec25519_fhmqvc/handshake.c
+++ b/src/protocols/ec25519_fhmqvc/handshake.c
@@ -391,12 +391,15 @@ static void handle_finish_handshake(fastd_context_t *ctx, fastd_socket_t *sock,
clear_shared_handshake_key(ctx, peer);
}
-static fastd_peer_t* find_sender_key(fastd_context_t *ctx, const fastd_peer_address_t *address, const unsigned char key[32], fastd_peer_t *peers) {
+static fastd_peer_t* find_sender_key(fastd_context_t *ctx, const fastd_peer_address_t *address, const unsigned char key[32]) {
errno = 0;
- fastd_peer_t *ret = NULL, *peer;
+ fastd_peer_t *ret = NULL;
+ size_t i;
+
+ for (i = 0; i < VECTOR_LEN(ctx->peers); i++) {
+ fastd_peer_t *peer = VECTOR_INDEX(ctx->peers, i);
- for (peer = peers; peer; peer = peer->next) {
if (memcmp(&peer->protocol_config->public_key, key, PUBLICKEYBYTES) == 0) {
if (!fastd_peer_matches_address(ctx, peer, address)) {
errno = EPERM;
@@ -435,12 +438,7 @@ static fastd_peer_t* match_sender_key(fastd_context_t *ctx, const fastd_socket_t
}
}
- peer = find_sender_key(ctx, address, key, ctx->peers);
-
- if (!peer && errno == ENOENT)
- peer = find_sender_key(ctx, address, key, ctx->peers_temp);
-
- return peer;
+ return find_sender_key(ctx, address, key);
}
static size_t key_count(fastd_context_t *ctx, const unsigned char key[32]) {