From a2a0f702e632d9219628fc467e1d2e5bde2eab7d Mon Sep 17 00:00:00 2001 From: venaas Date: Thu, 21 Aug 2008 14:33:11 +0000 Subject: made dtls server do proper certificate matching git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@356 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- hash.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'hash.c') diff --git a/hash.c b/hash.c index ea36860..dd27f77 100644 --- a/hash.c +++ b/hash.c @@ -92,3 +92,25 @@ void *hash_read(struct hash *h, void *key, uint32_t keylen) { pthread_mutex_unlock(&h->mutex); return NULL; } + +/* extracts entry from hash */ +void *hash_extract(struct hash *h, void *key, uint32_t keylen) { + struct list_node *ln; + struct entry *e; + + if (!h) + return 0; + pthread_mutex_lock(&h->mutex); + for (ln = list_first(h->hashlist); ln; ln = list_next(ln)) { + e = (struct entry *)ln->data; + if (e->keylen == keylen && !memcmp(e->key, key, keylen)) { + free(e->key); + list_removedata(h->hashlist, e); + free(e); + pthread_mutex_unlock(&h->mutex); + return e->data; + } + } + pthread_mutex_unlock(&h->mutex); + return NULL; +} -- cgit v1.1