diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index bd18f882..7b0bffb7 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -444,35 +444,3 @@ test_old_bird(char *path) close(fd); } - -/* - * DNS resolver - */ - -ip_addr -resolve_hostname(const char *host, int type, const char **err_msg) -{ - struct addrinfo *res; - struct addrinfo hints = { - .ai_family = AF_UNSPEC, - .ai_socktype = (type == SK_UDP) ? SOCK_DGRAM : SOCK_STREAM, - .ai_flags = AI_ADDRCONFIG, - }; - - *err_msg = NULL; - - int err_code = getaddrinfo(host, NULL, &hints, &res); - if (err_code != 0) - { - *err_msg = gai_strerror(err_code); - return IPA_NONE; - } - - ip_addr addr = IPA_NONE; - uint unused; - - sockaddr_read((sockaddr *) res->ai_addr, res->ai_family, &addr, NULL, &unused); - freeaddrinfo(res); - - return addr; -} diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c index 39436383..d53a0d26 100644 --- a/sysdep/unix/log.c +++ b/sysdep/unix/log.c @@ -15,10 +15,13 @@ * user's manual. */ +#include #include #include #include #include +#include +#include #include #include #include @@ -867,3 +870,35 @@ void set_daemon_name(char *path, char *def) { bird_name = get_bird_name(path, def); } + +/* + * DNS resolver + */ + +ip_addr +resolve_hostname(const char *host, int type, const char **err_msg) +{ + struct addrinfo *res; + struct addrinfo hints = { + .ai_family = AF_UNSPEC, + .ai_socktype = (type == SK_UDP) ? SOCK_DGRAM : SOCK_STREAM, + .ai_flags = AI_ADDRCONFIG, + }; + + *err_msg = NULL; + + int err_code = getaddrinfo(host, NULL, &hints, &res); + if (err_code != 0) + { + *err_msg = gai_strerror(err_code); + return IPA_NONE; + } + + ip_addr addr = IPA_NONE; + uint unused; + + sockaddr_read((sockaddr *) res->ai_addr, res->ai_family, &addr, NULL, &unused); + freeaddrinfo(res); + + return addr; +}