1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

socket-util: introduce in_addr_is_multicast

This patch add support to test whether a internet
address is multicast or not.
This commit is contained in:
Susant Sahani 2017-02-23 23:28:12 +05:30
parent ecc0eab247
commit 85257f48be
2 changed files with 14 additions and 0 deletions

View File

@ -66,6 +66,18 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) {
return -EAFNOSUPPORT;
}
int in_addr_is_multicast(int family, const union in_addr_union *u) {
assert(u);
if (family == AF_INET)
return IN_MULTICAST(be32toh(u->in.s_addr));
if (family == AF_INET6)
return IN6_IS_ADDR_MULTICAST(&u->in6);
return -EAFNOSUPPORT;
}
bool in4_addr_is_localhost(const struct in_addr *a) {
assert(a);

View File

@ -39,6 +39,8 @@ struct in_addr_data {
bool in4_addr_is_null(const struct in_addr *a);
int in_addr_is_null(int family, const union in_addr_union *u);
int in_addr_is_multicast(int family, const union in_addr_union *u);
bool in4_addr_is_link_local(const struct in_addr *a);
int in_addr_is_link_local(int family, const union in_addr_union *u);