Merge pull request #19533 from yuwata/network-queue
network: introduce queue to configure address, route, etc
This commit is contained in:
+14
-16
@@ -371,28 +371,26 @@ static inline void *ordered_hashmap_first_key(OrderedHashmap *h) {
|
||||
return _hashmap_first_key(HASHMAP_BASE(h), false);
|
||||
}
|
||||
|
||||
#define hashmap_clear_with_destructor(_s, _f) \
|
||||
#define hashmap_clear_with_destructor(h, f) \
|
||||
({ \
|
||||
Hashmap *_h = (h); \
|
||||
void *_item; \
|
||||
while ((_item = hashmap_steal_first(_s))) \
|
||||
_f(_item); \
|
||||
while ((_item = hashmap_steal_first(_h))) \
|
||||
f(_item); \
|
||||
_h; \
|
||||
})
|
||||
#define hashmap_free_with_destructor(_s, _f) \
|
||||
({ \
|
||||
hashmap_clear_with_destructor(_s, _f); \
|
||||
hashmap_free(_s); \
|
||||
})
|
||||
#define ordered_hashmap_clear_with_destructor(_s, _f) \
|
||||
#define hashmap_free_with_destructor(h, f) \
|
||||
hashmap_free(hashmap_clear_with_destructor(h, f))
|
||||
#define ordered_hashmap_clear_with_destructor(h, f) \
|
||||
({ \
|
||||
OrderedHashmap *_h = (h); \
|
||||
void *_item; \
|
||||
while ((_item = ordered_hashmap_steal_first(_s))) \
|
||||
_f(_item); \
|
||||
})
|
||||
#define ordered_hashmap_free_with_destructor(_s, _f) \
|
||||
({ \
|
||||
ordered_hashmap_clear_with_destructor(_s, _f); \
|
||||
ordered_hashmap_free(_s); \
|
||||
while ((_item = ordered_hashmap_steal_first(_h))) \
|
||||
f(_item); \
|
||||
_h; \
|
||||
})
|
||||
#define ordered_hashmap_free_with_destructor(h, f) \
|
||||
ordered_hashmap_free(ordered_hashmap_clear_with_destructor(h, f))
|
||||
|
||||
/* no hashmap_next */
|
||||
void* ordered_hashmap_next(OrderedHashmap *h, const void *key);
|
||||
|
||||
@@ -73,7 +73,13 @@ int in_addr_prefix_range(
|
||||
union in_addr_union *ret_start,
|
||||
union in_addr_union *ret_end);
|
||||
int in_addr_to_string(int family, const union in_addr_union *u, char **ret);
|
||||
static inline int in6_addr_to_string(const struct in6_addr *u, char **ret) {
|
||||
return in_addr_to_string(AF_INET6, (const union in_addr_union*) u, ret);
|
||||
}
|
||||
int in_addr_prefix_to_string(int family, const union in_addr_union *u, unsigned prefixlen, char **ret);
|
||||
static inline int in6_addr_prefix_to_string(const struct in6_addr *u, unsigned prefixlen, char **ret) {
|
||||
return in_addr_prefix_to_string(AF_INET6, (const union in_addr_union*) u, prefixlen, ret);
|
||||
}
|
||||
int in_addr_port_ifindex_name_to_string(int family, const union in_addr_union *u, uint16_t port, int ifindex, const char *server_name, char **ret);
|
||||
static inline int in_addr_ifindex_to_string(int family, const union in_addr_union *u, int ifindex, char **ret) {
|
||||
return in_addr_port_ifindex_name_to_string(family, u, 0, ifindex, NULL, ret);
|
||||
@@ -120,3 +126,10 @@ extern const struct hash_ops in_addr_data_hash_ops;
|
||||
extern const struct hash_ops in_addr_prefix_hash_ops;
|
||||
extern const struct hash_ops in_addr_prefix_hash_ops_free;
|
||||
extern const struct hash_ops in6_addr_hash_ops;
|
||||
|
||||
#define IPV4_ADDRESS_FMT_STR "%u.%u.%u.%u"
|
||||
#define IPV4_ADDRESS_FMT_VAL(address) \
|
||||
be32toh((address).s_addr) >> 24, \
|
||||
(be32toh((address).s_addr) >> 16) & 0xFFu, \
|
||||
(be32toh((address).s_addr) >> 8) & 0xFFu, \
|
||||
be32toh((address).s_addr) & 0xFFu
|
||||
|
||||
@@ -75,6 +75,17 @@ void ordered_set_print(FILE *f, const char *field, OrderedSet *s);
|
||||
#define ORDERED_SET_FOREACH(e, s) \
|
||||
_ORDERED_SET_FOREACH(e, s, UNIQ_T(i, UNIQ))
|
||||
|
||||
#define ordered_set_clear_with_destructor(s, f) \
|
||||
({ \
|
||||
OrderedSet *_s = (s); \
|
||||
void *_item; \
|
||||
while ((_item = ordered_set_steal_first(_s))) \
|
||||
f(_item); \
|
||||
_s; \
|
||||
})
|
||||
#define ordered_set_free_with_destructor(s, f) \
|
||||
ordered_set_free(ordered_set_clear_with_destructor(s, f))
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(OrderedSet*, ordered_set_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(OrderedSet*, ordered_set_free_free);
|
||||
|
||||
|
||||
+6
-7
@@ -95,17 +95,16 @@ static inline void *set_steal_first(Set *s) {
|
||||
return _hashmap_first_key_and_value(HASHMAP_BASE(s), true, NULL);
|
||||
}
|
||||
|
||||
#define set_clear_with_destructor(_s, _f) \
|
||||
#define set_clear_with_destructor(s, f) \
|
||||
({ \
|
||||
Set *_s = (s); \
|
||||
void *_item; \
|
||||
while ((_item = set_steal_first(_s))) \
|
||||
_f(_item); \
|
||||
})
|
||||
#define set_free_with_destructor(_s, _f) \
|
||||
({ \
|
||||
set_clear_with_destructor(_s, _f); \
|
||||
set_free(_s); \
|
||||
f(_item); \
|
||||
_s; \
|
||||
})
|
||||
#define set_free_with_destructor(s, f) \
|
||||
set_free(set_clear_with_destructor(s, f))
|
||||
|
||||
/* no set_steal_first_key */
|
||||
/* no set_first_key */
|
||||
|
||||
Reference in New Issue
Block a user