1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include "conf-parser.h"
5 #include "hash-funcs.h"
8 typedef enum AddressFamily
{
9 /* This is a bitmask, though it usually doesn't feel that way! */
10 ADDRESS_FAMILY_NO
= 0,
11 ADDRESS_FAMILY_IPV4
= 1 << 0,
12 ADDRESS_FAMILY_IPV6
= 1 << 1,
13 ADDRESS_FAMILY_YES
= ADDRESS_FAMILY_IPV4
| ADDRESS_FAMILY_IPV6
,
14 ADDRESS_FAMILY_FALLBACK_IPV4
= 1 << 2,
15 ADDRESS_FAMILY_FALLBACK
= ADDRESS_FAMILY_FALLBACK_IPV4
| ADDRESS_FAMILY_IPV6
,
17 _ADDRESS_FAMILY_INVALID
= -1,
20 typedef struct NetworkConfigSection
{
24 } NetworkConfigSection
;
26 CONFIG_PARSER_PROTOTYPE(config_parse_link_local_address_family
);
27 CONFIG_PARSER_PROTOTYPE(config_parse_address_family_with_kernel
);
29 const char *address_family_to_string(AddressFamily b
) _const_
;
30 AddressFamily
address_family_from_string(const char *s
) _pure_
;
32 const char *link_local_address_family_to_string(AddressFamily b
) _const_
;
33 AddressFamily
link_local_address_family_from_string(const char *s
) _pure_
;
35 int kernel_route_expiration_supported(void);
37 int network_config_section_new(const char *filename
, unsigned line
, NetworkConfigSection
**s
);
38 void network_config_section_free(NetworkConfigSection
*network
);
39 DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection
*, network_config_section_free
);
40 extern const struct hash_ops network_config_hash_ops
;
42 static inline bool section_is_invalid(NetworkConfigSection
*section
) {
43 /* If this returns false, then it does _not_ mean the section is valid. */
48 return section
->invalid
;
51 #define DEFINE_NETWORK_SECTION_FUNCTIONS(type, free_func) \
52 static inline void free_func##_or_set_invalid(type *p) { \
56 p->section->invalid = true; \
60 DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func); \
61 DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func##_or_set_invalid);