]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-util.h
codespell: fix spelling errors
[thirdparty/systemd.git] / src / network / networkd-util.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
fc2f9534
LP
2#pragma once
3
a2106925 4#include "conf-parser.h"
48315d3d 5#include "hash-funcs.h"
fc2f9534
LP
6#include "macro.h"
7
8typedef enum AddressFamilyBoolean {
9 /* This is a bitmask, though it usually doesn't feel that way! */
dffcf2b4
YW
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,
fc2f9534
LP
14 _ADDRESS_FAMILY_BOOLEAN_MAX,
15 _ADDRESS_FAMILY_BOOLEAN_INVALID = -1,
16} AddressFamilyBoolean;
17
48315d3d
YW
18typedef struct NetworkConfigSection {
19 unsigned line;
fcbf4cb7 20 bool invalid;
48315d3d
YW
21 char filename[];
22} NetworkConfigSection;
23
a2106925
LP
24CONFIG_PARSER_PROTOTYPE(config_parse_address_family_boolean);
25CONFIG_PARSER_PROTOTYPE(config_parse_address_family_boolean_with_kernel);
fc2f9534 26
fc2f9534
LP
27const char *address_family_boolean_to_string(AddressFamilyBoolean b) _const_;
28AddressFamilyBoolean address_family_boolean_from_string(const char *s) _const_;
f02ba163
DD
29
30int kernel_route_expiration_supported(void);
48315d3d
YW
31
32int network_config_section_new(const char *filename, unsigned line, NetworkConfigSection **s);
33void network_config_section_free(NetworkConfigSection *network);
34DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection*, network_config_section_free);
35extern const struct hash_ops network_config_hash_ops;
fcbf4cb7
YW
36
37static inline bool section_is_invalid(NetworkConfigSection *section) {
5238e957 38 /* If this returns false, then it does _not_ mean the section is valid. */
fcbf4cb7
YW
39
40 if (!section)
41 return false;
42
43 return section->invalid;
44}
45
46#define DEFINE_NETWORK_SECTION_FUNCTIONS(type, free_func) \
47 static inline void free_func##_or_set_invalid(type *p) { \
48 assert(p); \
49 \
50 if (p->section) \
51 p->section->invalid = true; \
52 else \
53 free_func(p); \
54 } \
55 DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func); \
56 DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func##_or_set_invalid);