return 0;
}
-int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *dst,
- triple_timestamp *timestamp) {
+int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *ret_dst,
+ triple_timestamp *ret_timestamp) {
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int)) + /* ttl */
CMSG_SPACE(sizeof(struct timeval))) control;
.msg_controllen = sizeof(control),
};
struct cmsghdr *cmsg;
+ struct in6_addr addr = {};
+ triple_timestamp t;
ssize_t len;
iov = IOVEC_MAKE(buffer, size);
if (msg.msg_namelen == sizeof(struct sockaddr_in6) &&
sa.in6.sin6_family == AF_INET6) {
- *dst = sa.in6.sin6_addr;
- if (in_addr_is_link_local(AF_INET6, (union in_addr_union*) dst) <= 0)
+ addr = sa.in6.sin6_addr;
+ if (!in6_addr_is_link_local(&addr))
return -EADDRNOTAVAIL;
} else if (msg.msg_namelen > 0)
if (cmsg->cmsg_level == SOL_SOCKET &&
cmsg->cmsg_type == SO_TIMESTAMP &&
cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval)))
- triple_timestamp_from_realtime(timestamp, timeval_load((struct timeval*) CMSG_DATA(cmsg)));
+ triple_timestamp_from_realtime(&t, timeval_load((struct timeval*) CMSG_DATA(cmsg)));
}
- if (!triple_timestamp_is_set(timestamp))
- triple_timestamp_get(timestamp);
+ if (!triple_timestamp_is_set(&t))
+ triple_timestamp_get(&t);
+ *ret_dst = addr;
+ *ret_timestamp = t;
return 0;
}
int icmp6_bind_router_solicitation(int ifindex);
int icmp6_bind_router_advertisement(int ifindex);
int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr);
-int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *dst,
- triple_timestamp *timestamp);
+int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *ret_dst,
+ triple_timestamp *ret_timestamp);
assert_return(rt, -EINVAL);
assert_return(ret_addr, -EINVAL);
- if (IN6_IS_ADDR_UNSPECIFIED(&rt->address))
+ if (in6_addr_is_null(&rt->address))
return -ENODATA;
*ret_addr = rt->address;
assert_return(client, -EINVAL);
assert_return(local_address, -EINVAL);
- assert_return(in_addr_is_link_local(AF_INET6, (const union in_addr_union *) local_address) > 0, -EINVAL);
+ assert_return(in6_addr_is_link_local(local_address) > 0, -EINVAL);
assert_return(IN_SET(client->state, DHCP6_STATE_STOPPED), -EBUSY);
assert_return(client, -EINVAL);
assert_return(client->event, -EINVAL);
assert_return(client->ifindex > 0, -EINVAL);
- assert_return(in_addr_is_link_local(AF_INET6, (const union in_addr_union *) &client->local_address) > 0, -EINVAL);
+ assert_return(in6_addr_is_link_local(&client->local_address) > 0, -EINVAL);
if (!IN_SET(client->state, DHCP6_STATE_STOPPED))
return -EBUSY;
static bool ipv4ll_address_is_valid(const struct in_addr *address) {
assert(address);
- if (!in_addr_is_link_local(AF_INET, (const union in_addr_union *) address))
+ if (!in4_addr_is_link_local(address))
return false;
return !IN_SET(be32toh(address->s_addr) & 0x0000FF00U, 0x0000U, 0xFF00U);
if (r < 0)
return r;
- if (dst && !IN6_IS_ADDR_UNSPECIFIED(dst))
+ if (dst && in6_addr_is_set(dst))
dst_addr.sin6_addr = *dst;
adv.nd_ra_type = ND_ROUTER_ADVERT;
return -EINVAL;
/* Refuse prefixes that don't have a prefix set */
- if (IN6_IS_ADDR_UNSPECIFIED(&p->opt.in6_addr))
+ if (in6_addr_is_null(&p->opt.in6_addr))
return -ENOEXEC;
LIST_FOREACH(prefix, cur, ra->prefixes) {
if (prefixlen != cur->opt.prefixlen)
continue;
- if (!in_addr_equal(AF_INET6,
- (union in_addr_union *)prefix,
- (union in_addr_union *)&cur->opt.in6_addr))
+ if (!in6_addr_equal(prefix, &cur->opt.in6_addr))
continue;
LIST_REMOVE(prefix, ra->prefixes, cur);
union in_addr_union *addr, union in_addr_union *peer) {
Network *network;
- if (in_addr_is_null(family, addr) != 0)
+ if (!in_addr_is_set(family, addr))
return 0;
network = network_get(context, ifname);
Network *network;
int r;
- if (in_addr_is_null(family, gateway) != 0)
+ if (!in_addr_is_set(family, gateway))
return 0;
network = network_get(context, ifname);
if (r < 0)
return r;
- if (in_addr_is_null(address->family, &address->peer) == 0) {
+ if (in_addr_is_set(address->family, &address->peer)) {
r = in_addr_to_string(address->family, &address->peer, &peer);
if (r < 0)
return r;
_cleanup_free_ char *dest = NULL, *gateway = NULL;
int r;
- if (in_addr_is_null(route->family, &route->dest) == 0) {
+ if (in_addr_is_set(route->family, &route->dest)) {
r = in_addr_prefix_to_string(route->family, &route->dest, route->prefixlen, &dest);
if (r < 0)
return r;
return log_netdev_error_errno(netdev, r, "Could not append IFLA_GENEVE_ID attribute: %m");
}
- if (in_addr_is_null(v->remote_family, &v->remote) == 0) {
+ if (in_addr_is_set(v->remote_family, &v->remote)) {
if (v->remote_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_GENEVE_REMOTE, &v->remote.in);
else
if (a->family != t->family)
return -EINVAL;
- if (in_addr_is_null(a->family, &a->in_addr_peer) <= 0)
+ if (in_addr_is_set(a->family, &a->in_addr_peer))
return -EINVAL;
if (t->local_address_type == NETDEV_L2TP_LOCAL_ADDRESS_STATIC &&
assert(ret);
assert(IN_SET(t->family, AF_INET, AF_INET6));
- if (!in_addr_is_null(t->family, &t->local)) {
+ if (in_addr_is_set(t->family, &t->local)) {
/* local address is explicitly specified. */
*ret = t->local;
return 0;
addr_type = l2tp_local_address_type_from_string(rvalue);
if (addr_type >= 0) {
- if (in_addr_is_null(t->family, &t->remote) != 0)
+ if (!in_addr_is_set(t->family, &t->remote))
/* If Remote= is not specified yet, then also clear family. */
t->family = AF_UNSPEC;
"%s: L2TP tunnel with invalid address family configured. Ignoring",
filename);
- if (in_addr_is_null(t->family, &t->remote))
+ if (!in_addr_is_set(t->family, &t->remote))
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
"%s: L2TP tunnel without a remote address configured. Ignoring",
filename);
"vti/ipip/sit/gre tunnel without a local/remote IPv4 address configured in %s. Ignoring", filename);
if (IN_SET(netdev->kind, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN) &&
- (t->family != AF_INET || in_addr_is_null(t->family, &t->remote)))
+ (t->family != AF_INET || !in_addr_is_set(t->family, &t->remote)))
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
"gretap/erspan tunnel without a remote IPv4 address configured in %s. Ignoring", filename);
"vti6/ip6tnl/ip6gre tunnel without a local/remote IPv6 address configured in %s. Ignoring", filename);
if (netdev->kind == NETDEV_KIND_IP6GRETAP &&
- (t->family != AF_INET6 || in_addr_is_null(t->family, &t->remote)))
+ (t->family != AF_INET6 || !in_addr_is_set(t->family, &t->remote)))
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
"ip6gretap tunnel without a remote IPv6 address configured in %s. Ignoring", filename);
*addr = IN_ADDR_NULL;
/* As a special case, if both the local and remote addresses are
- * unspecified, also clear the address family.
- */
- if (t->family != AF_UNSPEC &&
- in_addr_is_null(t->family, &t->local) != 0 &&
- in_addr_is_null(t->family, &t->remote) != 0)
+ * unspecified, also clear the address family. */
+ if (!in_addr_is_set(t->family, &t->local) &&
+ !in_addr_is_set(t->family, &t->remote))
t->family = AF_UNSPEC;
return 0;
}
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_ID attribute: %m");
}
- if (in_addr_is_null(v->group_family, &v->group) == 0) {
+ if (in_addr_is_set(v->group_family, &v->group)) {
if (v->group_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->group.in);
else
r = sd_netlink_message_append_in6_addr(m, IFLA_VXLAN_GROUP6, &v->group.in6);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_GROUP attribute: %m");
- } else if (in_addr_is_null(v->remote_family, &v->remote) == 0) {
+ } else if (in_addr_is_set(v->remote_family, &v->remote)) {
if (v->remote_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->remote.in);
else
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_GROUP attribute: %m");
}
- if (in_addr_is_null(v->local_family, &v->local) == 0) {
+ if (in_addr_is_set(v->local_family, &v->local)) {
if (v->local_family == AF_INET)
r = sd_netlink_message_append_in_addr(m, IFLA_VXLAN_LOCAL, &v->local.in);
else
if (!v->dest_port && v->generic_protocol_extension)
v->dest_port = 4790;
- if (in_addr_is_null(v->group_family, &v->group) == 0 && in_addr_is_null(v->remote_family, &v->remote) == 0)
+ if (in_addr_is_set(v->group_family, &v->group) && in_addr_is_set(v->remote_family, &v->remote))
return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
"%s: VXLAN both 'Group=' and 'Remote=' cannot be specified. Ignoring.",
filename);
if (r < 0)
return table_log_add_error(r);
} else if (STRPTR_IN_SET(info->netdev_kind, "ipip", "sit", "gre", "gretap", "erspan", "vti")) {
- if (!in_addr_is_null(AF_INET, &info->local)) {
+ if (in_addr_is_set(AF_INET, &info->local)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Local:",
return table_log_add_error(r);
}
- if (!in_addr_is_null(AF_INET, &info->remote)) {
+ if (in_addr_is_set(AF_INET, &info->remote)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Remote:",
return table_log_add_error(r);
}
} else if (STRPTR_IN_SET(info->netdev_kind, "ip6gre", "ip6gretap", "ip6erspan", "vti6")) {
- if (!in_addr_is_null(AF_INET6, &info->local)) {
+ if (in_addr_is_set(AF_INET6, &info->local)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Local:",
return table_log_add_error(r);
}
- if (!in_addr_is_null(AF_INET6, &info->remote)) {
+ if (in_addr_is_set(AF_INET6, &info->remote)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Remote:",
if (r < 0)
return table_log_add_error(r);
- if (info->has_tunnel_ipv4 && !in_addr_is_null(AF_INET, &info->remote)) {
+ if (info->has_tunnel_ipv4 && in_addr_is_set(AF_INET, &info->remote)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Remote:",
TABLE_IN_ADDR, &info->remote);
if (r < 0)
return table_log_add_error(r);
- } else if (!in_addr_is_null(AF_INET6, &info->remote)) {
+ } else if (in_addr_is_set(AF_INET6, &info->remote)) {
r = table_add_many(table,
TABLE_EMPTY,
TABLE_STRING, "Remote:",
if (n->address == address)
free(set_remove(address->link->ndisc_addresses, n));
- if (in_addr_equal(AF_INET6, &address->in_addr, (const union in_addr_union *) &address->link->ipv6ll_address))
+ if (address->family == AF_INET6 &&
+ in6_addr_equal(&address->in_addr.in6, &address->link->ipv6ll_address))
memzero(&address->link->ipv6ll_address, sizeof(struct in6_addr));
}
/* A /31 or /32 IPv4 address does not have a broadcast address.
* See https://tools.ietf.org/html/rfc3021 */
- return a->family == AF_INET && in4_addr_is_null(&a->in_addr_peer.in) && a->prefixlen <= 30;
+ return a->family == AF_INET &&
+ in_addr_is_null(AF_INET, &a->in_addr_peer) &&
+ a->prefixlen <= 30;
}
static uint32_t address_prefix(const Address *a) {
if (address->family == AF_INET6 &&
in_addr_is_link_local(AF_INET6, &address->in_addr) > 0 &&
- IN6_IS_ADDR_UNSPECIFIED(&address->link->ipv6ll_address) > 0) {
+ in6_addr_is_null(&address->link->ipv6ll_address)) {
r = link_ipv6ll_gained(address->link, &address->in_addr.in6);
if (r < 0)
bool has_peer;
(void) in_addr_to_string(address->family, &address->in_addr, &addr);
- has_peer = in_addr_is_null(address->family, &address->in_addr_peer) == 0;
+ has_peer = in_addr_is_set(address->family, &address->in_addr_peer);
if (has_peer)
(void) in_addr_to_string(address->family, &address->in_addr_peer, &peer);
assert(ret);
/* Something useful was configured? just use it */
- r = in_addr_is_null(original->family, &original->in_addr);
- if (r < 0)
- return r;
- if (r == 0) {
+ if (in_addr_is_set(original->family, &original->in_addr)) {
*ret = NULL;
return 0;
}
if (r < 0)
return log_link_error_errno(link, r, "Could not set scope: %m");
- if (in_addr_is_null(address->family, &address->in_addr_peer) == 0) {
+ if (in_addr_is_set(address->family, &address->in_addr_peer)) {
r = netlink_message_append_in_addr_union(req, IFA_ADDRESS, address->family, &address->in_addr_peer);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_ADDRESS attribute: %m");
/* The first statically configured address if there is any */
ORDERED_HASHMAP_FOREACH(address, link->network->addresses_by_section)
if (address->family == AF_INET &&
- !in_addr_is_null(address->family, &address->in_addr))
+ in_addr_is_set(address->family, &address->in_addr))
return address;
/* If that didn't work, find a suitable address we got from the pool */
assert(self_addr);
if (in4_addr_is_localhost(&route->dst.in) ||
- (!in4_addr_is_null(self_addr) && in4_addr_equal(&route->dst.in, self_addr)))
+ (in4_addr_is_set(self_addr) && in4_addr_equal(&route->dst.in, self_addr)))
return RT_SCOPE_HOST;
else if (in4_addr_is_null(&route->gw.in))
return RT_SCOPE_LINK;
if (r < 0 && r != -ENODATA)
return log_link_error_errno(link, r, "DHCP error: Could not get gateway: %m");
- if (r > 0 && !in4_addr_is_null(&router[0]))
+ if (r > 0 && in4_addr_is_set(&router[0]))
log_struct(LOG_INFO,
LOG_LINK_INTERFACE(link),
LOG_LINK_MESSAGE(link, "DHCPv4 address "IPV4_ADDRESS_FMT_STR"/%u via "IPV4_ADDRESS_FMT_STR,
address->in_addr = *prefix;
- if (!in_addr_is_null(AF_INET6, &link->network->dhcp6_pd_token))
+ if (in_addr_is_set(AF_INET6, &link->network->dhcp6_pd_token))
memcpy(address->in_addr.in6.s6_addr + 8, link->network->dhcp6_pd_token.in6.s6_addr + 8, 8);
else {
r = generate_ipv6_eui_64_address(link, &address->in_addr.in6);
assert(link);
assert(link->dhcp6_client);
assert(link->network);
- assert(in_addr_is_link_local(AF_INET6, (const union in_addr_union*) &link->ipv6ll_address) > 0);
+ assert(in6_addr_is_link_local(&link->ipv6ll_address));
r = sd_dhcp6_client_is_running(link->dhcp6_client);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NDA_VLAN attribute: %m");
}
- if (!in_addr_is_null(fdb_entry->family, &fdb_entry->destination_addr)) {
+ if (in_addr_is_set(fdb_entry->family, &fdb_entry->destination_addr)) {
r = netlink_message_append_in_addr_union(req, NDA_DST, fdb_entry->family, &fdb_entry->destination_addr);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NDA_DST attribute: %m");
bool has_ndisc_address = false;
NDiscAddress *n;
- if (link_ipv6ll_enabled(link) &&
- in_addr_is_null(AF_INET6, (const union in_addr_union*) &link->ipv6ll_address))
- return (void) log_link_debug(link, "%s(): IPv6LL is not configured.", __func__);
+ if (link_ipv6ll_enabled(link) && !in6_addr_is_set(&link->ipv6ll_address))
+ return (void) log_link_debug(link, "%s(): IPv6LL is not configured yet.", __func__);
SET_FOREACH(n, link->ndisc_addresses)
if (!n->marked) {
if (link->radv) {
assert(link->radv);
- assert(in_addr_is_link_local(AF_INET6, (const union in_addr_union*)&link->ipv6ll_address) > 0);
+ assert(in6_addr_is_link_local(&link->ipv6ll_address));
log_link_debug(link, "Starting IPv6 Router Advertisements");
DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST,
DHCP6_CLIENT_START_MODE_SOLICIT)) {
assert(link->dhcp6_client);
- assert(in_addr_is_link_local(AF_INET6, (const union in_addr_union*)&link->ipv6ll_address) > 0);
+ assert(in6_addr_is_link_local(&link->ipv6ll_address));
r = dhcp6_request_address(link, link->network->dhcp6_without_ra == DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST);
if (r < 0 && r != -EBUSY)
if (r < 0)
return r;
- if (!in_addr_is_null(AF_INET6, (const union in_addr_union*) &link->ipv6ll_address)) {
+ if (in6_addr_is_set(&link->ipv6ll_address)) {
r = link_acquire_ipv6_conf(link);
if (r < 0)
return r;
break;
}
- if (IN6_IS_ADDR_UNSPECIFIED(&router)) {
+ if (in6_addr_is_null(&router)) {
_cleanup_free_ char *buf = NULL;
(void) in_addr_to_string(address->family, &address->in_addr, &buf);
_cleanup_free_ struct in6_addr *new_address = NULL;
if (j->address_generation_type == IPV6_TOKEN_ADDRESS_GENERATION_PREFIXSTABLE
- && (IN6_IS_ADDR_UNSPECIFIED(&j->prefix) || IN6_ARE_ADDR_EQUAL(&j->prefix, address))) {
+ && (in6_addr_is_null(&j->prefix) || IN6_ARE_ADDR_EQUAL(&j->prefix, address))) {
/* While this loop uses dad_counter and a retry limit as specified in RFC 7217, the loop
- does not actually attempt Duplicate Address Detection; the counter will be incremented
- only when the address generation algorithm produces an invalid address, and the loop
- may exit with an address which ends up being unusable due to duplication on the link.
- */
+ * does not actually attempt Duplicate Address Detection; the counter will be incremented
+ * only when the address generation algorithm produces an invalid address, and the loop
+ * may exit with an address which ends up being unusable due to duplication on the link. */
for (; j->dad_counter < DAD_CONFLICTS_IDGEN_RETRIES_RFC7217; j->dad_counter++) {
r = make_stableprivate_address(link, address, prefixlen, j->dad_counter, &new_address);
if (r < 0)
if (r < 0)
return log_link_error_errno(link, r, "Could not append NHA_OIF attribute: %m");
- if (in_addr_is_null(nexthop->family, &nexthop->gw) == 0) {
+ if (in_addr_is_set(nexthop->family, &nexthop->gw)) {
r = netlink_message_append_in_addr_union(req, NHA_GATEWAY, nexthop->family, &nexthop->gw);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NHA_GATEWAY attribute: %m");
return log_oom();
if (isempty(rvalue) &&
- in_addr_is_null(n->family, &n->gw) != 0) {
+ !in_addr_is_set(n->family, &n->gw)) {
/* Accept an empty string only when Gateway= is null or not specified. */
n->family = AF_UNSPEC;
TAKE_PTR(n);
return 0;
}
- if (in_addr_is_null(n->family, &n->gw) == 0 &&
+ if (in_addr_is_set(n->family, &n->gw) &&
((a == ADDRESS_FAMILY_IPV4 && n->family == AF_INET6) ||
(a == ADDRESS_FAMILY_IPV6 && n->family == AF_INET))) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
p = dns;
for (size_t i = 0; i < link->network->n_router_dns; i++)
- if (IN6_IS_ADDR_UNSPECIFIED(&link->network->router_dns[i])) {
- if (!IN6_IS_ADDR_UNSPECIFIED(&link->ipv6ll_address))
+ if (in6_addr_is_null(&link->network->router_dns[i])) {
+ if (in6_addr_is_set(&link->ipv6ll_address))
*(p++) = link->ipv6ll_address;
} else
*(p++) = link->network->router_dns[i];
_cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL,
*prefsrc = NULL, *table = NULL, *scope = NULL, *proto = NULL;
- if (!in_addr_is_null(route->family, &route->dst)) {
+ if (in_addr_is_set(route->family, &route->dst)) {
(void) in_addr_to_string(route->family, &route->dst, &dst);
(void) asprintf(&dst_prefixlen, "/%u", route->dst_prefixlen);
}
- if (!in_addr_is_null(route->family, &route->src))
+ if (in_addr_is_set(route->family, &route->src))
(void) in_addr_to_string(route->family, &route->src, &src);
- if (in_addr_is_null(route->gw_family, &route->gw) == 0)
+ if (in_addr_is_set(route->gw_family, &route->gw))
(void) in_addr_to_string(route->gw_family, &route->gw, &gw);
- if (!in_addr_is_null(route->family, &route->prefsrc))
+ if (in_addr_is_set(route->family, &route->prefsrc))
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
(void) route_scope_to_string_alloc(route->scope, &scope);
(void) manager_get_route_table_to_string(m, route->table, &table);
/* link may be NULL */
- if (in_addr_is_null(route->gw_family, &route->gw) == 0) {
+ if (in_addr_is_set(route->gw_family, &route->gw)) {
if (route->gw_family == route->family) {
r = netlink_message_append_in_addr_union(req, RTA_GATEWAY, route->gw_family, &route->gw);
if (r < 0)
return log_link_error_errno(link, r, "Could not set source prefix length: %m");
}
- if (in_addr_is_null(route->family, &route->prefsrc) == 0) {
+ if (in_addr_is_set(route->family, &route->prefsrc)) {
r = netlink_message_append_in_addr_union(req, RTA_PREFSRC, route->family, &route->prefsrc);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_PREFSRC attribute: %m");
if (rt->gateway_from_dhcp_or_ra)
continue;
- if ((in_addr_is_null(rt->gw_family, &rt->gw) != 0 && ordered_set_isempty(rt->multipath_routes)) != (phase == PHASE_NON_GATEWAY))
+ if ((!in_addr_is_set(rt->gw_family, &rt->gw) && ordered_set_isempty(rt->multipath_routes)) != (phase == PHASE_NON_GATEWAY))
continue;
r = route_configure(rt, link, route_handler, NULL);
route->priority = IP6_RT_PRIO_USER;
if (ordered_hashmap_isempty(network->addresses_by_section) &&
- in_addr_is_null(route->gw_family, &route->gw) == 0 &&
+ in_addr_is_set(route->gw_family, &route->gw) &&
route->gateway_onlink < 0) {
log_warning("%s: Gateway= without static address configured. "
"Enabling GatewayOnLink= option.",
/* link may be NULL. */
- if (in_addr_is_null(rule->family, &rule->from) == 0) {
+ if (in_addr_is_set(rule->family, &rule->from)) {
r = netlink_message_append_in_addr_union(m, FRA_SRC, rule->family, &rule->from);
if (r < 0)
return log_link_error_errno(link, r, "Could not append FRA_SRC attribute: %m");
return log_link_error_errno(link, r, "Could not set source prefix length: %m");
}
- if (in_addr_is_null(rule->family, &rule->to) == 0) {
+ if (in_addr_is_set(rule->family, &rule->to)) {
r = netlink_message_append_in_addr_union(m, FRA_DST, rule->family, &rule->to);
if (r < 0)
return log_link_error_errno(link, r, "Could not append FRA_DST attribute: %m");
assert_se((size = deserialize_in_addrs(&addresses, addresses_string)) >= 0);
assert_se(size == 3);
- assert_se(in_addr_equal(AF_INET, &a, (union in_addr_union *) &addresses[0]));
- assert_se(in_addr_equal(AF_INET, &b, (union in_addr_union *) &addresses[1]));
- assert_se(in_addr_equal(AF_INET, &c, (union in_addr_union *) &addresses[2]));
+ assert_se(in4_addr_equal(&a.in, &addresses[0]));
+ assert_se(in4_addr_equal(&b.in, &addresses[1]));
+ assert_se(in4_addr_equal(&c.in, &addresses[2]));
assert_se((size = deserialize_in6_addrs(&addresses6, addresses_string)) >= 0);
assert_se(size == 3);
- assert_se(in_addr_equal(AF_INET6, &d, (union in_addr_union *) &addresses6[0]));
- assert_se(in_addr_equal(AF_INET6, &e, (union in_addr_union *) &addresses6[1]));
- assert_se(in_addr_equal(AF_INET6, &f, (union in_addr_union *) &addresses6[2]));
+ assert_se(in6_addr_equal(&d.in6, &addresses6[0]));
+ assert_se(in6_addr_equal(&e.in6, &addresses6[1]));
+ assert_se(in6_addr_equal(&f.in6, &addresses6[2]));
}
static void test_deserialize_dhcp_routes(void) {
if (!l)
return 0;
- if (in_addr_is_null(af, exposed))
+ if (!in_addr_is_set(af, exposed))
return 0;
log_debug("Lost IP address.");
p->host_port,
&new_exposed,
p->container_port,
- in_addr_is_null(af, exposed) ? NULL : exposed);
+ in_addr_is_set(af, exposed) ? exposed : NULL);
if (r < 0)
log_warning_errno(r, "Failed to modify %s firewall: %m", af_to_name(af));
}
r_tuple->next = r_tuple_prev;
r_tuple->name = r_name;
r_tuple->family = a->family;
- r_tuple->scopeid = a->family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&a->address.in6) ? a->ifindex : 0;
+ r_tuple->scopeid = a->family == AF_INET6 && in6_addr_is_link_local(&a->address.in6) ? a->ifindex : 0;
memcpy(r_tuple->addr, &a->address, 16);
idx += ALIGN(sizeof(struct gaih_addrtuple));
assert(sizeof(in6) == FAMILY_ADDRESS_SIZE(AF_INET6));
memcpy(&in6, a, sizeof(struct in6_addr));
- return IN6_IS_ADDR_LINKLOCAL(&in6) ? ifindex : 0;
+ return in6_addr_is_link_local(&in6) ? ifindex : 0;
}
static int json_dispatch_ifindex(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
return in4_addr_is_link_local(&rr->a.in_addr);
if (rr->key->type == DNS_TYPE_AAAA)
- return IN6_IS_ADDR_LINKLOCAL(&rr->aaaa.in6_addr);
+ return in6_addr_is_link_local(&rr->aaaa.in6_addr);
return false;
}
* the LLMNR multicast addresses. See RFC 4795,
* section 2.5. */
- if (p->family == AF_INET && !in_addr_equal(AF_INET, &p->destination, (union in_addr_union*) &LLMNR_MULTICAST_IPV4_ADDRESS))
+ if (p->family == AF_INET && !in4_addr_equal(&p->destination.in, &LLMNR_MULTICAST_IPV4_ADDRESS))
return;
- if (p->family == AF_INET6 && !in_addr_equal(AF_INET6, &p->destination, (union in_addr_union*) &LLMNR_MULTICAST_IPV6_ADDRESS))
+ if (p->family == AF_INET6 && !in6_addr_equal(&p->destination.in6, &LLMNR_MULTICAST_IPV6_ADDRESS))
return;
}
return 0;
}
- r = in_addr_is_null(address.family, &address.address);
+ r = in_addr_data_is_null(&address);
if (r < 0) {
log_warning_errno(r, "/etc/hosts:%u: address '%s' is invalid, ignoring: %m", nr, address_str);
return 0;
/* Refuses the 0 IP addresses as well as 127.0.0.53 (which is our own DNS stub) */
- if (in_addr_is_null(family, sa))
+ if (!in_addr_is_set(family, sa))
return false;
if (family == AF_INET && sa->in.s_addr == htobe32(INADDR_DNS_STUB))