summaryrefslogtreecommitdiff
path: root/src/shared
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
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')
-rw-r--r--src/shared/bus-errors.h4
-rw-r--r--src/shared/in-addr-util.c22
-rw-r--r--src/shared/in-addr-util.h1
-rw-r--r--src/shared/macro.h3
4 files changed, 30 insertions, 0 deletions
diff --git a/src/shared/bus-errors.h b/src/shared/bus-errors.h
index 48a2b4ef1b..388b42b4fd 100644
--- a/src/shared/bus-errors.h
+++ b/src/shared/bus-errors.h
@@ -59,3 +59,7 @@
#define BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED "org.freedesktop.timedate1.AutomaticTimeSyncEnabled"
#define BUS_ERROR_NO_SUCH_PROCESS "org.freedesktop.systemd1.NoSuchProcess"
+
+#define BUS_ERROR_NO_NAME_SERVERS "org.freedesktop.resolve1.NoNameServers"
+#define BUS_ERROR_INVALID_REPLY "org.freedesktop.resolve1.InvalidReply"
+#define _BUS_ERROR_DNS "org.freedesktop.resolve1.DnsError."
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;
+}
diff --git a/src/shared/in-addr-util.h b/src/shared/in-addr-util.h
index ae3aa9021d..108f1f3ace 100644
--- a/src/shared/in-addr-util.h
+++ b/src/shared/in-addr-util.h
@@ -37,6 +37,7 @@ int in_addr_prefix_intersect(unsigned family, const union in_addr_union *a, unsi
int in_addr_prefix_next(unsigned family, union in_addr_union *u, unsigned prefixlen);
int in_addr_to_string(unsigned family, const union in_addr_union *u, char **ret);
int in_addr_from_string(unsigned family, const char *s, union in_addr_union *ret);
+int in_addr_from_string_auto(const char *s, unsigned *family, union in_addr_union *ret);
static inline size_t PROTO_ADDRESS_SIZE(int proto) {
assert(proto == AF_INET || proto == AF_INET6);
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 70c5fb50a7..5619c32e45 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -241,6 +241,9 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
#define PTR_TO_UINT64(p) ((uint64_t) ((uintptr_t) (p)))
#define UINT64_TO_PTR(u) ((void *) ((uintptr_t) (u)))
+#define PTR_TO_SIZE(p) ((size_t) ((uintptr_t) (p)))
+#define SIZE_TO_PTR(u) ((void *) ((uintptr_t) (u)))
+
#define memzero(x,l) (memset((x), 0, (l)))
#define zero(x) (memzero(&(x), sizeof(x)))