]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Moved hostname resolver to logger
authorMaria Matejka <mq@ucw.cz>
Thu, 29 Aug 2024 08:21:08 +0000 (10:21 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 23 Feb 2025 17:28:45 +0000 (18:28 +0100)
sysdep/unix/io.c
sysdep/unix/log.c

index 427b22973829ed9b0d56161c965e45dc8ab8d66e..d9f86360108f69a5e27199a2bca2437d20cac7a3 100644 (file)
@@ -446,35 +446,3 @@ test_old_bird(const 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;
-}
index d6614cd1a9af1f222f5c8deebee60a2945dfbb76..8fb0d3c3d17e2f63b27e46e58c43dac1aebfade2 100644 (file)
  * user's manual.
  */
 
+#include <netdb.h>
 #include <stdatomic.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <time.h>
 #include <unistd.h>
 #include <errno.h>
@@ -878,3 +881,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;
+}