]>
Commit | Line | Data |
---|---|---|
a032b68d | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
d9dfd233 MP |
2 | #pragma once |
3 | ||
a10f5d05 | 4 | #include "sd-dhcp-lease.h" |
a032b68d | 5 | #include "sd-netlink.h" |
a10f5d05 | 6 | |
b012e921 | 7 | #include "conf-parser.h" |
a032b68d MB |
8 | #include "hashmap.h" |
9 | #include "log.h" | |
d9dfd233 | 10 | #include "macro.h" |
8b3d4ff0 | 11 | #include "network-util.h" |
a032b68d | 12 | #include "string-util.h" |
d9dfd233 | 13 | |
8b3d4ff0 | 14 | typedef struct Link Link; |
d9dfd233 | 15 | |
bb4f798a MB |
16 | typedef struct NetworkConfigSection { |
17 | unsigned line; | |
18 | bool invalid; | |
19 | char filename[]; | |
20 | } NetworkConfigSection; | |
21 | ||
c5fca32e MB |
22 | CONFIG_PARSER_PROTOTYPE(config_parse_link_local_address_family); |
23 | CONFIG_PARSER_PROTOTYPE(config_parse_address_family_with_kernel); | |
3a6ce677 | 24 | CONFIG_PARSER_PROTOTYPE(config_parse_ip_masquerade); |
d9dfd233 | 25 | |
c5fca32e MB |
26 | const char *address_family_to_string(AddressFamily b) _const_; |
27 | AddressFamily address_family_from_string(const char *s) _pure_; | |
f2dec872 | 28 | |
c5fca32e MB |
29 | AddressFamily link_local_address_family_from_string(const char *s) _pure_; |
30 | ||
31 | const char *routing_policy_rule_address_family_to_string(AddressFamily b) _const_; | |
32 | AddressFamily routing_policy_rule_address_family_from_string(const char *s) _pure_; | |
b012e921 | 33 | |
3a6ce677 BR |
34 | const char *nexthop_address_family_to_string(AddressFamily b) _const_; |
35 | AddressFamily nexthop_address_family_from_string(const char *s) _pure_; | |
36 | ||
46cdbd49 BR |
37 | const char *duplicate_address_detection_address_family_to_string(AddressFamily b) _const_; |
38 | AddressFamily duplicate_address_detection_address_family_from_string(const char *s) _pure_; | |
39 | ||
3a6ce677 BR |
40 | AddressFamily dhcp_deprecated_address_family_from_string(const char *s) _pure_; |
41 | ||
42 | const char *dhcp_lease_server_type_to_string(sd_dhcp_lease_server_type_t t) _const_; | |
43 | sd_dhcp_lease_server_type_t dhcp_lease_server_type_from_string(const char *s) _pure_; | |
a10f5d05 | 44 | |
b012e921 | 45 | int kernel_route_expiration_supported(void); |
bb4f798a | 46 | |
3a6ce677 BR |
47 | static inline NetworkConfigSection* network_config_section_free(NetworkConfigSection *cs) { |
48 | return mfree(cs); | |
49 | } | |
bb4f798a | 50 | DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection*, network_config_section_free); |
3a6ce677 BR |
51 | |
52 | int network_config_section_new(const char *filename, unsigned line, NetworkConfigSection **s); | |
bb4f798a | 53 | extern const struct hash_ops network_config_hash_ops; |
a032b68d | 54 | unsigned hashmap_find_free_section_line(Hashmap *hashmap); |
bb4f798a MB |
55 | |
56 | static inline bool section_is_invalid(NetworkConfigSection *section) { | |
f2dec872 | 57 | /* If this returns false, then it does _not_ mean the section is valid. */ |
bb4f798a MB |
58 | |
59 | if (!section) | |
60 | return false; | |
61 | ||
62 | return section->invalid; | |
63 | } | |
64 | ||
65 | #define DEFINE_NETWORK_SECTION_FUNCTIONS(type, free_func) \ | |
3a6ce677 | 66 | static inline type* free_func##_or_set_invalid(type *p) { \ |
bb4f798a MB |
67 | assert(p); \ |
68 | \ | |
69 | if (p->section) \ | |
70 | p->section->invalid = true; \ | |
71 | else \ | |
72 | free_func(p); \ | |
3a6ce677 | 73 | return NULL; \ |
bb4f798a MB |
74 | } \ |
75 | DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func); \ | |
76 | DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func##_or_set_invalid); | |
a032b68d | 77 | |
8b3d4ff0 MB |
78 | int log_link_message_full_errno(Link *link, sd_netlink_message *m, int level, int err, const char *msg); |
79 | #define log_link_message_error_errno(link, m, err, msg) log_link_message_full_errno(link, m, LOG_ERR, err, msg) | |
80 | #define log_link_message_warning_errno(link, m, err, msg) log_link_message_full_errno(link, m, LOG_WARNING, err, msg) | |
81 | #define log_link_message_notice_errno(link, m, err, msg) log_link_message_full_errno(link, m, LOG_NOTICE, err, msg) | |
82 | #define log_link_message_info_errno(link, m, err, msg) log_link_message_full_errno(link, m, LOG_INFO, err, msg) | |
83 | #define log_link_message_debug_errno(link, m, err, msg) log_link_message_full_errno(link, m, LOG_DEBUG, err, msg) | |
84 | #define log_message_full_errno(m, level, err, msg) log_link_message_full_errno(NULL, m, level, err, msg) | |
85 | #define log_message_error_errno(m, err, msg) log_message_full_errno(m, LOG_ERR, err, msg) | |
86 | #define log_message_warning_errno(m, err, msg) log_message_full_errno(m, LOG_WARNING, err, msg) | |
87 | #define log_message_notice_errno(m, err, msg) log_message_full_errno(m, LOG_NOTICE, err, msg) | |
88 | #define log_message_info_errno(m, err, msg) log_message_full_errno(m, LOG_INFO, err, msg) | |
89 | #define log_message_debug_errno(m, err, msg) log_message_full_errno(m, LOG_DEBUG, err, msg) |