summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-30 00:48:59 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-30 00:48:59 +0200
commitaf93291cc4cbd2fe2fb4af7d3c56138fb39f31dc (patch)
tree18600359a8412751275aa86b607f0b35c21e0b3a /src/shared
parent2442b93d15f5523aba0c5dc56a42757af889c483 (diff)
resolved: when answer A or AAAA questions, order responses by whether addresses are link-local or not
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/in-addr-util.c13
-rw-r--r--src/shared/in-addr-util.h3
2 files changed, 14 insertions, 2 deletions
diff --git a/src/shared/in-addr-util.c b/src/shared/in-addr-util.c
index e9a99177fc..459f846173 100644
--- a/src/shared/in-addr-util.c
+++ b/src/shared/in-addr-util.c
@@ -23,7 +23,7 @@
#include "in-addr-util.h"
-int in_addr_null(int family, const union in_addr_union *u) {
+int in_addr_is_null(int family, const union in_addr_union *u) {
assert(u);
if (family == AF_INET)
@@ -39,6 +39,17 @@ int in_addr_null(int family, const union in_addr_union *u) {
return -EAFNOSUPPORT;
}
+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);
+
+ if (family == AF_INET6)
+ return IN6_IS_ADDR_LINKLOCAL(&u->in6);
+
+ return -EAFNOSUPPORT;
+}
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b) {
assert(a);
diff --git a/src/shared/in-addr-util.h b/src/shared/in-addr-util.h
index cff2c321ed..7d1d6baa27 100644
--- a/src/shared/in-addr-util.h
+++ b/src/shared/in-addr-util.h
@@ -31,7 +31,8 @@ union in_addr_union {
struct in6_addr in6;
};
-int in_addr_null(int family, const union in_addr_union *u);
+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_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);