1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include "conf-parser.h"
5 #include "hash-funcs.h"
8 typedef enum AddressFamilyBoolean
{
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_BOOLEAN_MAX
,
15 _ADDRESS_FAMILY_BOOLEAN_INVALID
= -1,
16 } AddressFamilyBoolean
;
18 typedef struct NetworkConfigSection
{
22 } NetworkConfigSection
;
24 CONFIG_PARSER_PROTOTYPE(config_parse_address_family_boolean
);
25 CONFIG_PARSER_PROTOTYPE(config_parse_address_family_boolean_with_kernel
);
27 const char *address_family_boolean_to_string(AddressFamilyBoolean b
) _const_
;
28 AddressFamilyBoolean
address_family_boolean_from_string(const char *s
) _const_
;
30 int kernel_route_expiration_supported(void);
32 int network_config_section_new(const char *filename
, unsigned line
, NetworkConfigSection
**s
);
33 void network_config_section_free(NetworkConfigSection
*network
);
34 DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection
*, network_config_section_free
);
35 extern const struct hash_ops network_config_hash_ops
;
37 static inline bool section_is_invalid(NetworkConfigSection
*section
) {
38 /* If this returns false, then it does _not_ mean the section is valid. */
43 return section
->invalid
;
46 #define DEFINE_NETWORK_SECTION_FUNCTIONS(type, free_func) \
47 static inline void free_func##_or_set_invalid(type *p) { \
51 p->section->invalid = true; \
55 DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func); \
56 DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func##_or_set_invalid);