summaryrefslogtreecommitdiff
path: root/src/shared/in-addr-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-16 00:26:02 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-16 00:31:38 +0200
commit74b2466e14a1961bf3ac0e8a60cfaceec705bd59 (patch)
tree48e9e848b04562dc1f547ba7079fb3568e03f0fe /src/shared/in-addr-util.c
parent337ede5693cb8860ee86a2d71ffedec682abf6bc (diff)
resolved: add a DNS client stub resolver
Let's turn resolved into a something truly useful: a fully asynchronous DNS stub resolver that subscribes to network changes. (More to come: caching, LLMNR, mDNS/DNS-SD, DNSSEC, IDN, NSS module)
Diffstat (limited to 'src/shared/in-addr-util.c')
-rw-r--r--src/shared/in-addr-util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/shared/in-addr-util.c b/src/shared/in-addr-util.c
index 98d2446e5d..6ece85e37d 100644
--- a/src/shared/in-addr-util.c
+++ b/src/shared/in-addr-util.c
@@ -209,3 +209,25 @@ int in_addr_from_string(unsigned family, const char *s, union in_addr_union *ret
return 0;
}
+
+int in_addr_from_string_auto(const char *s, unsigned *family, union in_addr_union *ret) {
+ int r;
+
+ assert(s);
+ assert(family);
+ assert(ret);
+
+ r = in_addr_from_string(AF_INET, s, ret);
+ if (r >= 0) {
+ *family = AF_INET;
+ return 0;
+ }
+
+ r = in_addr_from_string(AF_INET6, s, ret);
+ if (r >= 0) {
+ *family = AF_INET6;
+ return 0;
+ }
+
+ return -EINVAL;
+}