diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-19 19:11:48 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-19 19:11:48 +0200 |
commit | 91a7ca50f3f8a2c7bb01113fa3849cb5e153a70f (patch) | |
tree | 18c5b7c76f4ec3069e9033a1c222eefd2c945da6 /config.h | |
parent | 445647adc4475c0b8264ce8b6c97d748eec69e7b (diff) |
Add support for async DNS
Diffstat (limited to 'config.h')
-rw-r--r-- | config.h | 38 |
1 files changed, 32 insertions, 6 deletions
@@ -1,31 +1,57 @@ #ifndef fooconfighfoo #define fooconfighfoo +#define _GNU_SOURCE +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> +#include <signal.h> + 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); |