diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-07-30 00:48:59 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-07-30 00:48:59 +0200 |
commit | af93291cc4cbd2fe2fb4af7d3c56138fb39f31dc (patch) | |
tree | 18600359a8412751275aa86b607f0b35c21e0b3a /src/shared/in-addr-util.c | |
parent | 2442b93d15f5523aba0c5dc56a42757af889c483 (diff) |
resolved: when answer A or AAAA questions, order responses by whether addresses are link-local or not
Diffstat (limited to 'src/shared/in-addr-util.c')
-rw-r--r-- | src/shared/in-addr-util.c | 13 |
1 files changed, 12 insertions, 1 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); |