summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/basic/in-addr-util.c8
-rw-r--r--src/basic/in-addr-util.h17
2 files changed, 24 insertions, 1 deletions
diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c
index 641c5de7a3..6ee3a6ad63 100644
--- a/src/basic/in-addr-util.c
+++ b/src/basic/in-addr-util.c
@@ -24,6 +24,12 @@ bool in4_addr_is_null(const struct in_addr *a) {
return a->s_addr == 0;
}
+bool in6_addr_is_null(const struct in6_addr *a) {
+ assert(a);
+
+ return IN6_IS_ADDR_UNSPECIFIED(a);
+}
+
int in_addr_is_null(int family, const union in_addr_union *u) {
assert(u);
@@ -31,7 +37,7 @@ int in_addr_is_null(int family, const union in_addr_union *u) {
return in4_addr_is_null(&u->in);
if (family == AF_INET6)
- return IN6_IS_ADDR_UNSPECIFIED(&u->in6);
+ return in6_addr_is_null(&u->in6);
return -EAFNOSUPPORT;
}
diff --git a/src/basic/in-addr-util.h b/src/basic/in-addr-util.h
index a5ce8258fd..f7cdf0d9bc 100644
--- a/src/basic/in-addr-util.h
+++ b/src/basic/in-addr-util.h
@@ -21,7 +21,24 @@ struct in_addr_data {
};
bool in4_addr_is_null(const struct in_addr *a);
+static inline bool in4_addr_is_set(const struct in_addr *a) {
+ return !in4_addr_is_null(a);
+}
+bool in6_addr_is_null(const struct in6_addr *a);
+static inline bool in6_addr_is_set(const struct in6_addr *a) {
+ return !in6_addr_is_null(a);
+}
int in_addr_is_null(int family, const union in_addr_union *u);
+static inline bool in_addr_is_set(int family, const union in_addr_union *u) {
+ return in_addr_is_null(family, u) == 0;
+}
+static inline int in_addr_data_is_null(const struct in_addr_data *a) {
+ assert(a);
+ return in_addr_is_null(a->family, &a->address);
+}
+static inline bool in_addr_data_is_set(const struct in_addr_data *a) {
+ return in_addr_data_is_null(a);
+}
int in_addr_is_multicast(int family, const union in_addr_union *u);