]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
ca5ad760 YW |
2 | #pragma once |
3 | ||
cde74a65 YW |
4 | #include <netinet/in.h> |
5 | ||
ca5ad760 YW |
6 | #include "conf-parser.h" |
7 | #include "dhcp-identifier.h" | |
c995fa02 YW |
8 | #include "in-addr-util.h" |
9 | #include "set.h" | |
ca5ad760 YW |
10 | #include "time-util.h" |
11 | ||
12 | #define DHCP_ROUTE_METRIC 1024 | |
13 | ||
67c311ab | 14 | typedef struct Link Link; |
256c75fd | 15 | typedef struct Manager Manager; |
22d37e5d | 16 | typedef struct Network Network; |
67c311ab | 17 | |
ca5ad760 YW |
18 | typedef enum DHCPUseDomains { |
19 | DHCP_USE_DOMAINS_NO, | |
20 | DHCP_USE_DOMAINS_YES, | |
21 | DHCP_USE_DOMAINS_ROUTE, | |
22 | _DHCP_USE_DOMAINS_MAX, | |
2d93c20e | 23 | _DHCP_USE_DOMAINS_INVALID = -EINVAL, |
ca5ad760 YW |
24 | } DHCPUseDomains; |
25 | ||
2e5580a8 YW |
26 | typedef enum DHCPOptionDataType { |
27 | DHCP_OPTION_DATA_UINT8, | |
28 | DHCP_OPTION_DATA_UINT16, | |
29 | DHCP_OPTION_DATA_UINT32, | |
30 | DHCP_OPTION_DATA_STRING, | |
31 | DHCP_OPTION_DATA_IPV4ADDRESS, | |
e7d5fe17 | 32 | DHCP_OPTION_DATA_IPV6ADDRESS, |
2e5580a8 YW |
33 | _DHCP_OPTION_DATA_MAX, |
34 | _DHCP_OPTION_DATA_INVALID, | |
35 | } DHCPOptionDataType; | |
36 | ||
ca5ad760 YW |
37 | typedef struct DUID { |
38 | /* Value of Type in [DHCP] section */ | |
39 | DUIDType type; | |
40 | ||
41 | uint8_t raw_data_len; | |
42 | uint8_t raw_data[MAX_DUID_LEN]; | |
43 | usec_t llt_time; | |
4e26a5ba | 44 | bool set; |
ca5ad760 YW |
45 | } DUID; |
46 | ||
67c311ab YW |
47 | bool link_dhcp_enabled(Link *link, int family); |
48 | static inline bool link_dhcp4_enabled(Link *link) { | |
49 | return link_dhcp_enabled(link, AF_INET); | |
50 | } | |
51 | static inline bool link_dhcp6_enabled(Link *link) { | |
52 | return link_dhcp_enabled(link, AF_INET6); | |
53 | } | |
54 | ||
22d37e5d YW |
55 | void network_adjust_dhcp(Network *network); |
56 | ||
28f9667d YW |
57 | const DUID *link_get_duid(Link *link, int family); |
58 | static inline const DUID *link_get_dhcp4_duid(Link *link) { | |
4e26a5ba YW |
59 | return link_get_duid(link, AF_INET); |
60 | } | |
28f9667d | 61 | static inline const DUID *link_get_dhcp6_duid(Link *link) { |
4e26a5ba YW |
62 | return link_get_duid(link, AF_INET6); |
63 | } | |
64 | ||
28f9667d | 65 | int dhcp_configure_duid(Link *link, const DUID *duid); |
4e26a5ba | 66 | int manager_request_product_uuid(Manager *m); |
256c75fd | 67 | |
c995fa02 YW |
68 | bool address_is_filtered(int family, const union in_addr_union *address, uint8_t prefixlen, Set *allow_list, Set *deny_list); |
69 | static inline bool in4_address_is_filtered(const struct in_addr *address, Set *allow_list, Set *deny_list) { | |
70 | return address_is_filtered(AF_INET, &(union in_addr_union) { .in = *address }, 32, allow_list, deny_list); | |
71 | } | |
72 | static inline bool in6_prefix_is_filtered(const struct in6_addr *prefix, uint8_t prefixlen, Set *allow_list, Set *deny_list) { | |
73 | return address_is_filtered(AF_INET6, &(union in_addr_union) { .in6 = *prefix }, prefixlen, allow_list, deny_list); | |
74 | } | |
75 | ||
ca5ad760 YW |
76 | const char* dhcp_use_domains_to_string(DHCPUseDomains p) _const_; |
77 | DHCPUseDomains dhcp_use_domains_from_string(const char *s) _pure_; | |
78 | ||
2e5580a8 YW |
79 | const char *dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_; |
80 | DHCPOptionDataType dhcp_option_data_type_from_string(const char *d) _pure_; | |
81 | ||
ca5ad760 | 82 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp); |
967e6a64 | 83 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_or_ra_route_metric); |
4f7331a8 | 84 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_dns); |
ca5ad760 | 85 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_domains); |
4f7331a8 | 86 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_ntp); |
ca5ad760 YW |
87 | CONFIG_PARSER_PROTOTYPE(config_parse_iaid); |
88 | CONFIG_PARSER_PROTOTYPE(config_parse_section_route_table); | |
6fda02e1 | 89 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_user_or_vendor_class); |
0e96961d | 90 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_send_option); |
35f6a5cb | 91 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_request_options); |
cde74a65 | 92 | CONFIG_PARSER_PROTOTYPE(config_parse_duid_type); |
4e26a5ba YW |
93 | CONFIG_PARSER_PROTOTYPE(config_parse_manager_duid_type); |
94 | CONFIG_PARSER_PROTOTYPE(config_parse_network_duid_type); | |
cde74a65 | 95 | CONFIG_PARSER_PROTOTYPE(config_parse_duid_rawdata); |
4e26a5ba YW |
96 | CONFIG_PARSER_PROTOTYPE(config_parse_manager_duid_rawdata); |
97 | CONFIG_PARSER_PROTOTYPE(config_parse_network_duid_rawdata); | |
c995fa02 | 98 | CONFIG_PARSER_PROTOTYPE(config_parse_address_filter); |