From: Felix Fietkau Date: Wed, 18 Oct 2023 12:44:45 +0000 (+0200) Subject: cache: make record/hostname lookup case-insensitive X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=479c7f8676d9cb6543ef516dc82cc53ed11b1142;p=project%2Fmdnsd.git cache: make record/hostname lookup case-insensitive Fixes lookup issues on hosts that announce themselves with uppercase in their hostname Signed-off-by: Felix Fietkau --- diff --git a/cache.c b/cache.c index 046e8b9..8c851a3 100644 --- a/cache.c +++ b/cache.c @@ -42,7 +42,13 @@ static struct uloop_timeout cache_gc; struct avl_tree services; -AVL_TREE(records, avl_strcmp, true, NULL); + +static int avl_strcasecmp(const void *k1, const void *k2, void *ptr) +{ + return strcasecmp(k1, k2); +} + +AVL_TREE(records, avl_strcasecmp, true, NULL); static void cache_record_free(struct cache_record *r) @@ -111,7 +117,7 @@ cache_gc_timer(struct uloop_timeout *timeout) int cache_init(void) { - avl_init(&services, avl_strcmp, true, NULL); + avl_init(&services, avl_strcasecmp, true, NULL); cache_gc.cb = cache_gc_timer; uloop_timeout_set(&cache_gc, 10000);