resolved-etc-hosts.h
resolved-etc-hosts.c
resolved-dnstls.h
- resolved-util.c
- resolved-util.h
'''.split())
resolvectl_sources = files('''
[],
[],
'ENABLE_RESOLVE', 'manual'],
-
- [['src/resolve/test-resolved-util.c',
- 'src/resolve/resolved-util.c',
- 'src/resolve/resolved-util.h'],
- [],
- []],
]
#include "parse-util.h"
#include "resolved-conf.h"
#include "resolved-dnssd.h"
-#include "resolved-util.h"
#include "resolved-manager.h"
#include "resolved-dns-search-domain.h"
#include "dns-domain.h"
+#include "socket-netlink.h"
#include "specifier.h"
#include "string-table.h"
#include "string-util.h"
+++ /dev/null
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-#include "alloc-util.h"
-#include "macro.h"
-#include "resolved-util.h"
-#include "socket-netlink.h"
-
-int in_addr_ifindex_name_from_string_auto(const char *s, int *family, union in_addr_union *ret, int *ifindex, char **server_name) {
- _cleanup_free_ char *buf = NULL, *name = NULL;
- const char *m;
- int r;
-
- assert(s);
-
- m = strchr(s, '#');
- if (m) {
- name = strdup(m+1);
- if (!name)
- return -ENOMEM;
-
- buf = strndup(s, m - s);
- if (!buf)
- return -ENOMEM;
-
- s = buf;
- }
-
- r = in_addr_ifindex_from_string_auto(s, family, ret, ifindex);
- if (r < 0)
- return r;
-
- if (server_name)
- *server_name = TAKE_PTR(name);
-
- return r;
-}
+++ /dev/null
-/* SPDX-License-Identifier: LGPL-2.1+ */
-#pragma once
-
-#include "in-addr-util.h"
-
-int in_addr_ifindex_name_from_string_auto(const char *s, int *family, union in_addr_union *ret, int *ifindex, char **server_name);
+++ /dev/null
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-#include "log.h"
-#include "resolved-util.h"
-#include "string-util.h"
-#include "tests.h"
-
-
-static void test_in_addr_ifindex_name_from_string_auto_one(const char *a, const char *expected) {
- int family, ifindex;
- union in_addr_union ua;
- _cleanup_free_ char *server_name = NULL;
-
- assert_se(in_addr_ifindex_name_from_string_auto(a, &family, &ua, &ifindex, &server_name) >= 0);
- assert_se(streq_ptr(server_name, expected));
-}
-
-static void test_in_addr_ifindex_name_from_string_auto(void) {
- log_info("/* %s */", __func__);
-
- test_in_addr_ifindex_name_from_string_auto_one("192.168.0.1", NULL);
- test_in_addr_ifindex_name_from_string_auto_one("192.168.0.1#test.com", "test.com");
- test_in_addr_ifindex_name_from_string_auto_one("fe80::18%19", NULL);
- test_in_addr_ifindex_name_from_string_auto_one("fe80::18%19#another.test.com", "another.test.com");
-}
-
-int main(int argc, char **argv) {
- test_setup_logging(LOG_DEBUG);
-
- test_in_addr_ifindex_name_from_string_auto();
- return 0;
-}
return r;
}
+
+int in_addr_ifindex_name_from_string_auto(const char *s, int *family, union in_addr_union *ret, int *ifindex, char **server_name) {
+ _cleanup_free_ char *buf = NULL, *name = NULL;
+ const char *m;
+ int r;
+
+ assert(s);
+
+ m = strchr(s, '#');
+ if (m) {
+ name = strdup(m+1);
+ if (!name)
+ return -ENOMEM;
+
+ buf = strndup(s, m - s);
+ if (!buf)
+ return -ENOMEM;
+
+ s = buf;
+ }
+
+ r = in_addr_ifindex_from_string_auto(s, family, ret, ifindex);
+ if (r < 0)
+ return r;
+
+ if (server_name)
+ *server_name = TAKE_PTR(name);
+
+ return r;
+}
bool socket_address_is_netlink(const SocketAddress *a, const char *s);
int in_addr_ifindex_from_string_auto(const char *s, int *family, union in_addr_union *ret, int *ifindex);
+int in_addr_ifindex_name_from_string_auto(const char *s, int *family, union in_addr_union *ret, int *ifindex, char **server_name);
assert_se(in_addr_ifindex_from_string_auto("fe80::19%thisinterfacecantexist", &family, &ua, &ifindex) == -ENODEV);
}
+static void test_in_addr_ifindex_name_from_string_auto_one(const char *a, const char *expected) {
+ int family, ifindex;
+ union in_addr_union ua;
+ _cleanup_free_ char *server_name = NULL;
+
+ assert_se(in_addr_ifindex_name_from_string_auto(a, &family, &ua, &ifindex, &server_name) >= 0);
+ assert_se(streq_ptr(server_name, expected));
+}
+
+static void test_in_addr_ifindex_name_from_string_auto(void) {
+ log_info("/* %s */", __func__);
+
+ test_in_addr_ifindex_name_from_string_auto_one("192.168.0.1", NULL);
+ test_in_addr_ifindex_name_from_string_auto_one("192.168.0.1#test.com", "test.com");
+ test_in_addr_ifindex_name_from_string_auto_one("fe80::18%19", NULL);
+ test_in_addr_ifindex_name_from_string_auto_one("fe80::18%19#another.test.com", "another.test.com");
+}
+
static void test_sockaddr_equal(void) {
union sockaddr_union a = {
.in.sin_family = AF_INET,
test_in_addr_to_string();
test_in_addr_ifindex_to_string();
test_in_addr_ifindex_from_string_auto();
+ test_in_addr_ifindex_name_from_string_auto();
test_sockaddr_equal();