mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-27 03:21:32 +03:00
in-addr-util: introduce in_addr_data_hash_ops_free and expose its compare and hash functions
Preparation for later commits.
This commit is contained in:
parent
0f17886390
commit
4596c83658
@ -921,7 +921,7 @@ int in_addr_prefix_from_string_auto_internal(
|
||||
|
||||
}
|
||||
|
||||
static void in_addr_data_hash_func(const struct in_addr_data *a, struct siphash *state) {
|
||||
void in_addr_data_hash_func(const struct in_addr_data *a, struct siphash *state) {
|
||||
assert(a);
|
||||
assert(state);
|
||||
|
||||
@ -929,7 +929,7 @@ static void in_addr_data_hash_func(const struct in_addr_data *a, struct siphash
|
||||
siphash24_compress(&a->address, FAMILY_ADDRESS_SIZE(a->family), state);
|
||||
}
|
||||
|
||||
static int in_addr_data_compare_func(const struct in_addr_data *x, const struct in_addr_data *y) {
|
||||
int in_addr_data_compare_func(const struct in_addr_data *x, const struct in_addr_data *y) {
|
||||
int r;
|
||||
|
||||
assert(x);
|
||||
@ -942,7 +942,18 @@ static int in_addr_data_compare_func(const struct in_addr_data *x, const struct
|
||||
return memcmp(&x->address, &y->address, FAMILY_ADDRESS_SIZE(x->family));
|
||||
}
|
||||
|
||||
DEFINE_HASH_OPS(in_addr_data_hash_ops, struct in_addr_data, in_addr_data_hash_func, in_addr_data_compare_func);
|
||||
DEFINE_HASH_OPS(
|
||||
in_addr_data_hash_ops,
|
||||
struct in_addr_data,
|
||||
in_addr_data_hash_func,
|
||||
in_addr_data_compare_func);
|
||||
|
||||
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
|
||||
in_addr_data_hash_ops_free,
|
||||
struct in_addr_data,
|
||||
in_addr_data_hash_func,
|
||||
in_addr_data_compare_func,
|
||||
free);
|
||||
|
||||
void in6_addr_hash_func(const struct in6_addr *addr, struct siphash *state) {
|
||||
assert(addr);
|
||||
@ -958,7 +969,12 @@ int in6_addr_compare_func(const struct in6_addr *a, const struct in6_addr *b) {
|
||||
return memcmp(a, b, sizeof(*a));
|
||||
}
|
||||
|
||||
DEFINE_HASH_OPS(in6_addr_hash_ops, struct in6_addr, in6_addr_hash_func, in6_addr_compare_func);
|
||||
DEFINE_HASH_OPS(
|
||||
in6_addr_hash_ops,
|
||||
struct in6_addr,
|
||||
in6_addr_hash_func,
|
||||
in6_addr_compare_func);
|
||||
|
||||
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
|
||||
in6_addr_hash_ops_free,
|
||||
struct in6_addr,
|
||||
|
@ -177,10 +177,13 @@ static inline size_t FAMILY_ADDRESS_SIZE(int family) {
|
||||
* See also oss-fuzz#11344. */
|
||||
#define IN_ADDR_NULL ((union in_addr_union) { .in6 = {} })
|
||||
|
||||
void in_addr_data_hash_func(const struct in_addr_data *a, struct siphash *state);
|
||||
int in_addr_data_compare_func(const struct in_addr_data *x, const struct in_addr_data *y);
|
||||
void in6_addr_hash_func(const struct in6_addr *addr, struct siphash *state);
|
||||
int in6_addr_compare_func(const struct in6_addr *a, const struct in6_addr *b);
|
||||
|
||||
extern const struct hash_ops in_addr_data_hash_ops;
|
||||
extern const struct hash_ops in_addr_data_hash_ops_free;
|
||||
extern const struct hash_ops in6_addr_hash_ops;
|
||||
extern const struct hash_ops in6_addr_hash_ops_free;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user