From 6871825565d0ba24436dbd5b92cc09e02f93af6a Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 26 Oct 2026 16:59:39 +0100 Subject: First run of making variable names more readable --- ot_accesslist.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'ot_accesslist.c') diff --git a/ot_accesslist.c b/ot_accesslist.c index d7e88ee..ef845d6 100644 --- a/ot_accesslist.c +++ b/ot_accesslist.c @@ -339,7 +339,7 @@ static void *accesslist_adddel_worker(const char *fifoname, ot_accesslist *_ } } else { int exactmatch = 0; - ot_hash *insert_point = binary_search(info_hash, (*adding_to)->list, (*adding_to)->size, sizeof(ot_hash), OT_HASH_COMPARE_SIZE, &exactmatch); + ot_hash *insert_point = vector_binary_search(info_hash, (*adding_to)->list, (*adding_to)->size, sizeof(ot_hash), OT_HASH_COMPARE_SIZE, &exactmatch); /* Only if the info hash is not in the adding_to list, create a new head with that entry */ if (!exactmatch) { @@ -416,7 +416,7 @@ void accesslist_cleanup(void) { } #endif -int address_in_net(const ot_ip6 address, const ot_net *net) { +int accesslist_address_in_net(const ot_ip6 address, const ot_net *net) { int bits = net->bits, checkbits = (0x7f00 >> (bits & 7)); int result = memcmp(address, &net->address, bits >> 3); if (!result && (bits & 7)) @@ -424,7 +424,7 @@ int address_in_net(const ot_ip6 address, const ot_net *net) { return result == 0; } -void *set_value_for_net(const ot_net *net, ot_vector *vector, const void *value, const size_t member_size) { +void *accesslist_set_value_for_net(const ot_net *net, ot_vector *vector, const void *value, const size_t member_size) { size_t i; int exactmatch; @@ -435,7 +435,7 @@ void *set_value_for_net(const ot_net *net, ot_vector *vector, const void *value, /* Check each net in vector for overlap */ uint8_t *member = ((uint8_t *)vector->data); for (i = 0; i < vector->size; ++i) { - if (address_in_net(*(ot_ip6 *)member, net) || address_in_net(net->address, (ot_net *)member)) + if (accesslist_address_in_net(*(ot_ip6 *)member, net) || accesslist_address_in_net(net->address, (ot_net *)member)) return 0; member += member_size; } @@ -451,16 +451,16 @@ void *set_value_for_net(const ot_net *net, ot_vector *vector, const void *value, /* Takes a vector filled with { ot_net net, uint8_t[x] value }; Returns value associated with the net, or NULL if not found */ -void *get_value_for_net(const ot_ip6 address, const ot_vector *vector, const size_t member_size) { +void *accesslist_get_value_for_net(const ot_ip6 address, const ot_vector *vector, const size_t member_size) { int exactmatch; /* This binary search will return a pointer to the first non-containing network... */ - ot_net *net = binary_search(address, vector->data, vector->size, member_size, sizeof(ot_ip6), &exactmatch); + ot_net *net = vector_binary_search(address, vector->data, vector->size, member_size, sizeof(ot_ip6), &exactmatch); if (!net) return NULL; /* ... so we'll need to move back one step unless we've exactly hit the first address in network */ if (!exactmatch && ((void *)net > vector->data)) --net; - if (!address_in_net(address, net)) + if (!accesslist_address_in_net(address, net)) return NULL; return (void *)net; } @@ -472,7 +472,7 @@ static pthread_mutex_t g_lognets_list_mutex = PTHREAD_MUTEX_INITIALIZER; void loglist_add_network(const ot_net *net) { pthread_mutex_lock(&g_lognets_list_mutex); - set_value_for_net(net, &g_lognets_list, NULL, sizeof(ot_net)); + accesslist_set_value_for_net(net, &g_lognets_list, NULL, sizeof(ot_net)); pthread_mutex_unlock(&g_lognets_list_mutex); } @@ -487,7 +487,7 @@ void loglist_reset(void) { int loglist_check_address(const ot_ip6 address) { int result; pthread_mutex_lock(&g_lognets_list_mutex); - result = (NULL != get_value_for_net(address, &g_lognets_list, sizeof(ot_net))); + result = (NULL != accesslist_get_value_for_net(address, &g_lognets_list, sizeof(ot_net))); pthread_mutex_unlock(&g_lognets_list_mutex); return result; } @@ -508,17 +508,17 @@ int proxylist_add_network(const ot_net *proxy, const ot_net *net) { pthread_mutex_lock(&g_proxies_list_mutex); /* If we have a direct hit, use and extend the vector there */ - map = binary_search(proxy, g_proxies_list.data, g_proxies_list.size, sizeof(ot_proxymap), sizeof(ot_net), &exactmatch); + map = vector_binary_search(proxy, g_proxies_list.data, g_proxies_list.size, sizeof(ot_proxymap), sizeof(ot_net), &exactmatch); if (!map || !exactmatch) { /* else see, if we've got overlapping networks and get a new empty vector if not */ ot_vector empty; memset(&empty, 0, sizeof(ot_vector)); - map = set_value_for_net(proxy, &g_proxies_list, &empty, sizeof(ot_proxymap)); + map = accesslist_set_value_for_net(proxy, &g_proxies_list, &empty, sizeof(ot_proxymap)); } - if (map && set_value_for_net(net, &map->networks, NULL, sizeof(ot_net))) + if (map && accesslist_set_value_for_net(net, &map->networks, NULL, sizeof(ot_net))) result = 1; pthread_mutex_unlock(&g_proxies_list_mutex); @@ -531,8 +531,8 @@ int proxylist_check_proxy(const ot_ip6 proxy, const ot_ip6 address) { pthread_mutex_lock(&g_proxies_list_mutex); - if ((map = get_value_for_net(proxy, &g_proxies_list, sizeof(ot_proxymap)))) - if (!address || get_value_for_net(address, &map->networks, sizeof(ot_net))) + if ((map = accesslist_get_value_for_net(proxy, &g_proxies_list, sizeof(ot_proxymap)))) + if (!address || accesslist_get_value_for_net(address, &map->networks, sizeof(ot_net))) result = 1; pthread_mutex_unlock(&g_proxies_list_mutex); @@ -587,7 +587,7 @@ int accesslist_bless_net(ot_net *net, ot_permissions permissions) { int accesslist_is_blessed(ot_ip6 ip, ot_permissions permissions) { size_t i; for (i = 0; i < g_admin_nets_count; ++i) - if (address_in_net(ip, g_admin_nets + i) && (g_admin_nets_permissions[i] & permissions)) + if (accesslist_address_in_net(ip, g_admin_nets + i) && (g_admin_nets_permissions[i] & permissions)) return 1; return 0; } -- cgit v1.3