1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-08 08:58:27 +03:00

local-addresses: introduce has_local_address() helper function

It will be used later.
This commit is contained in:
Yu Watanabe 2024-01-19 22:33:36 +09:00
parent d10311f407
commit e5ee645344
2 changed files with 13 additions and 0 deletions

View File

@ -40,6 +40,17 @@ static int address_compare(const struct local_address *a, const struct local_add
return memcmp(&a->address, &b->address, FAMILY_ADDRESS_SIZE(a->family));
}
bool has_local_address(const struct local_address *addresses, size_t n_addresses, const struct local_address *needle) {
assert(addresses || n_addresses == 0);
assert(needle);
for (size_t i = 0; i < n_addresses; i++)
if (address_compare(addresses + i, needle) == 0)
return true;
return false;
}
static void suppress_duplicates(struct local_address *list, size_t *n_list) {
size_t old_size, new_size;

View File

@ -14,6 +14,8 @@ struct local_address {
union in_addr_union address;
};
bool has_local_address(const struct local_address *addresses, size_t n_addresses, const struct local_address *needle);
int local_addresses(sd_netlink *rtnl, int ifindex, int af, struct local_address **ret);
int local_gateways(sd_netlink *rtnl, int ifindex, int af, struct local_address **ret);