From 91a7ca50f3f8a2c7bb01113fa3849cb5e153a70f Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Fri, 19 Jun 2020 19:11:48 +0200 Subject: Add support for async DNS --- config.h | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'config.h') diff --git a/config.h b/config.h index 1868217..4e43e7b 100644 --- a/config.h +++ b/config.h @@ -1,31 +1,57 @@ #ifndef fooconfighfoo #define fooconfighfoo +#define _GNU_SOURCE +#include +#include +#include +#include + enum cfg_value_type { CFG_VAL_TYPE_INVALID, CFG_VAL_TYPE_STRING, CFG_VAL_TYPE_UINT16, CFG_VAL_TYPE_ADDRS, + CFG_VAL_TYPE_ASYNC_ADDRS, CFG_VAL_TYPE_BOOL, }; +struct dns_async; + +typedef void (dns_callback_t)(struct dns_async *); + +struct dns_async { + char name[FQDN_STR_LEN + 1]; + char port[PORT_STR_LEN + 1]; + struct addrinfo req; + struct gaicb gcb; + struct sigevent sev; + dns_callback_t *callback; + void *priv; + struct list_head list; +}; + struct cfg_key_value_map { const char *key_name; int key_value; enum cfg_value_type value_type; }; -union cfg_value { - const char *str; - uint16_t uint16; - struct list_head saddrs; - bool boolean; +struct cfg_value { + enum cfg_value_type type; + union { + const char *str; + uint16_t uint16; + struct list_head saddrs; + struct dns_async *dns_async; + bool boolean; + }; }; bool config_parse_line(struct cfg *cfg, const char *filename, char **buf, struct cfg_key_value_map *kvmap, int *rkey, const char **rkeyname, - union cfg_value *rvalue); + struct cfg_value *rvalue); bool config_parse_header(struct cfg *cfg, const char *filename, const char *title, char **buf); -- cgit v1.2.3