Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4be3c8e authored by Bernie Innocenti's avatar Bernie Innocenti Committed by Luke Huang
Browse files

Export the list the resolver caches from res_cache

To be used for dumps

Test: none :-)
Change-Id: Ia5236eb1be86ab87323ed1a85b56862777a5d3ee
parent 9f8d8b7b
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1643,6 +1643,17 @@ void resolv_delete_cache_for_net(unsigned netid) {
    }
}

std::vector<unsigned> resolv_list_caches() {
    std::lock_guard guard(cache_mutex);
    struct resolv_cache_info* cache_info = res_cache_list.next;
    std::vector<unsigned> result;
    while (cache_info) {
        result.push_back(cache_info->netid);
        cache_info = cache_info->next;
    }
    return result;
}

static resolv_cache_info* create_cache_info() {
    return (struct resolv_cache_info*) calloc(sizeof(struct resolv_cache_info), 1);
}
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@

#include <stddef.h>

#include <vector>

struct __res_state;

/* sets the name server addresses to the provided res_state structure. The
@@ -39,6 +41,8 @@ struct __res_state;
 * with the network to which the res_state structure is associated */
void _resolv_populate_res_for_net(struct __res_state* statp);

std::vector<unsigned> resolv_list_caches();

typedef enum {
    RESOLV_CACHE_UNSUPPORTED, /* the cache can't handle that kind of queries */
                              /* or the answer buffer is too small */