X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/9ca15a2679f3e00e5ea647e3fce2d0d3221ec9e6..27c0f6d8f406658655cc45a0a7f2d0a0f120244b:/ircd/dns.c?ds=sidebyside diff --git a/ircd/dns.c b/ircd/dns.c index 67776e66..fa3c530a 100644 --- a/ircd/dns.c +++ b/ircd/dns.c @@ -37,9 +37,6 @@ #include "msg.h" #include "hash.h" -#define DNS_IDTABLE_SIZE 0x2000 -#define DNS_STATTABLE_SIZE 0x10 - #define DNS_HOST_IPV4 ((char)'4') #define DNS_HOST_IPV6 ((char)'6') #define DNS_REVERSE_IPV4 ((char)'R') @@ -61,16 +58,23 @@ struct dnsstatreq }; /* These serve as a form of sparse array */ -static struct Dictionary *query_dict; -static struct Dictionary *stat_dict; +static rb_dictionary *query_dict; +static rb_dictionary *stat_dict; rb_dlink_list nameservers; static uint32_t query_id = 0; static uint32_t stat_id = 0; -#define ASSIGN_ID(id) (id++) +static inline uint32_t +assign_id(uint32_t *id) +{ + if(++(*id) == 0) + *id = 1; + + return *id; +} static void handle_dns_failure(uint32_t xid) @@ -125,7 +129,7 @@ lookup_hostname(const char *hostname, int aftype, DNSCB callback, void *data) { struct dnsreq *req = rb_malloc(sizeof(struct dnsreq)); int aft; - uint32_t rid = ASSIGN_ID(query_id); + uint32_t rid = assign_id(&query_id); check_authd(); @@ -150,7 +154,7 @@ lookup_ip(const char *addr, int aftype, DNSCB callback, void *data) { struct dnsreq *req = rb_malloc(sizeof(struct dnsreq)); int aft; - uint32_t rid = ASSIGN_ID(query_id); + uint32_t rid = assign_id(&query_id); check_authd(); @@ -170,11 +174,11 @@ lookup_ip(const char *addr, int aftype, DNSCB callback, void *data) return (rid); } -uint32_t +static uint32_t get_nameservers(DNSLISTCB callback, void *data) { struct dnsstatreq *req = rb_malloc(sizeof(struct dnsstatreq)); - uint32_t qid = ASSIGN_ID(stat_id); + uint32_t qid = assign_id(&stat_id); check_authd(); @@ -231,7 +235,7 @@ dns_stats_results_callback(const char *callid, const char *status, int resc, con { struct dnsstatreq *req; uint32_t qid; - int st, i; + int st; long lqid = strtol(callid, NULL, 16); if(lqid > UINT32_MAX) @@ -306,7 +310,7 @@ void reload_nameservers(void) { check_authd(); - rb_helper_write(authd_helper, "H D"); + rb_helper_write(authd_helper, "R D"); (void)get_nameservers(stats_results_callback, NULL); }