summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-27 01:18:38 +0100
committerTom Gundersen <teg@jklm.no>2015-11-27 01:18:38 +0100
commit90c739259fc35feb773b953d61f75790cacf6b15 (patch)
treea3057f2649986351c1364626261f46f1880ad7d6 /src/basic
parent8a7a7e971e97830fd722fb73ef87f7180180cc27 (diff)
parentdaa27350c373b3b177f86e89c0d1dbe0b94554d6 (diff)
Merge pull request #2042 from poettering/resolved-various-3
resolved: Flush caches more agressively, fixes #2038
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/in-addr-util.c15
-rw-r--r--src/basic/in-addr-util.h1
2 files changed, 15 insertions, 1 deletions
diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c
index f4e24121e7..1f61b68efd 100644
--- a/src/basic/in-addr-util.c
+++ b/src/basic/in-addr-util.c
@@ -44,7 +44,7 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) {
assert(u);
if (family == AF_INET)
- return (be32toh(u->in.s_addr) & 0xFFFF0000) == (169U << 24 | 254U << 16);
+ return (be32toh(u->in.s_addr) & UINT32_C(0xFFFF0000)) == (UINT32_C(169) << 24 | UINT32_C(254) << 16);
if (family == AF_INET6)
return IN6_IS_ADDR_LINKLOCAL(&u->in6);
@@ -52,6 +52,19 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) {
return -EAFNOSUPPORT;
}
+int in_addr_is_localhost(int family, const union in_addr_union *u) {
+ assert(u);
+
+ if (family == AF_INET)
+ /* All of 127.x.x.x is localhost. */
+ return (be32toh(u->in.s_addr) & UINT32_C(0xFF000000)) == UINT32_C(127) << 24;
+
+ if (family == AF_INET)
+ return IN6_IS_ADDR_LOOPBACK(&u->in6);
+
+ return -EAFNOSUPPORT;
+}
+
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b) {
assert(a);
assert(b);
diff --git a/src/basic/in-addr-util.h b/src/basic/in-addr-util.h
index 51af08868c..58f55b3418 100644
--- a/src/basic/in-addr-util.h
+++ b/src/basic/in-addr-util.h
@@ -33,6 +33,7 @@ union in_addr_union {
int in_addr_is_null(int family, const union in_addr_union *u);
int in_addr_is_link_local(int family, const union in_addr_union *u);
+int in_addr_is_localhost(int family, const union in_addr_union *u);
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b);
int in_addr_prefix_intersect(int family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen);
int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen);