]>
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 | 6 | #include "conf-parser.h" |
97c3506d | 7 | #include "dhcp-duid-internal.h" |
c995fa02 YW |
8 | #include "in-addr-util.h" |
9 | #include "set.h" | |
ca5ad760 YW |
10 | #include "time-util.h" |
11 | ||
2cba2146 YW |
12 | /* Special values for *_uplink_index. */ |
13 | #define UPLINK_INDEX_AUTO 0 /* uplink will be selected automatically */ | |
14 | #define UPLINK_INDEX_NONE -1 /* uplink will not be selected automatically */ | |
dc5cae6c | 15 | #define UPLINK_INDEX_SELF -2 /* the interface itself is uplink */ |
2cba2146 | 16 | |
ca5ad760 | 17 | #define DHCP_ROUTE_METRIC 1024 |
6f812d28 YW |
18 | #define IPV6RA_ROUTE_METRIC_HIGH 512 |
19 | #define IPV6RA_ROUTE_METRIC_MEDIUM 1024 | |
20 | #define IPV6RA_ROUTE_METRIC_LOW 2048 | |
d0619f2c | 21 | #define DHCP6PD_ROUTE_METRIC 256 |
ca5ad760 | 22 | |
67c311ab | 23 | typedef struct Link Link; |
256c75fd | 24 | typedef struct Manager Manager; |
22d37e5d | 25 | typedef struct Network Network; |
67c311ab | 26 | |
2e5580a8 YW |
27 | typedef enum DHCPOptionDataType { |
28 | DHCP_OPTION_DATA_UINT8, | |
29 | DHCP_OPTION_DATA_UINT16, | |
30 | DHCP_OPTION_DATA_UINT32, | |
31 | DHCP_OPTION_DATA_STRING, | |
32 | DHCP_OPTION_DATA_IPV4ADDRESS, | |
e7d5fe17 | 33 | DHCP_OPTION_DATA_IPV6ADDRESS, |
2e5580a8 YW |
34 | _DHCP_OPTION_DATA_MAX, |
35 | _DHCP_OPTION_DATA_INVALID, | |
36 | } DHCPOptionDataType; | |
37 | ||
ca5ad760 YW |
38 | typedef struct DUID { |
39 | /* Value of Type in [DHCP] section */ | |
40 | DUIDType type; | |
41 | ||
42 | uint8_t raw_data_len; | |
92914960 | 43 | uint8_t raw_data[MAX_DUID_DATA_LEN]; |
ca5ad760 | 44 | usec_t llt_time; |
4e26a5ba | 45 | bool set; |
ca5ad760 YW |
46 | } DUID; |
47 | ||
e47bcb7d | 48 | uint32_t link_get_dhcp4_route_table(Link *link); |
52672db3 | 49 | uint32_t link_get_ndisc_route_table(Link *link); |
e47bcb7d | 50 | |
67c311ab YW |
51 | bool link_dhcp_enabled(Link *link, int family); |
52 | static inline bool link_dhcp4_enabled(Link *link) { | |
53 | return link_dhcp_enabled(link, AF_INET); | |
54 | } | |
55 | static inline bool link_dhcp6_enabled(Link *link) { | |
56 | return link_dhcp_enabled(link, AF_INET6); | |
57 | } | |
58 | ||
22d37e5d YW |
59 | void network_adjust_dhcp(Network *network); |
60 | ||
28f9667d YW |
61 | const DUID *link_get_duid(Link *link, int family); |
62 | static inline const DUID *link_get_dhcp4_duid(Link *link) { | |
4e26a5ba YW |
63 | return link_get_duid(link, AF_INET); |
64 | } | |
28f9667d | 65 | static inline const DUID *link_get_dhcp6_duid(Link *link) { |
4e26a5ba YW |
66 | return link_get_duid(link, AF_INET6); |
67 | } | |
68 | ||
28f9667d | 69 | int dhcp_configure_duid(Link *link, const DUID *duid); |
4e26a5ba | 70 | int manager_request_product_uuid(Manager *m); |
256c75fd | 71 | |
c995fa02 YW |
72 | bool address_is_filtered(int family, const union in_addr_union *address, uint8_t prefixlen, Set *allow_list, Set *deny_list); |
73 | static inline bool in4_address_is_filtered(const struct in_addr *address, Set *allow_list, Set *deny_list) { | |
74 | return address_is_filtered(AF_INET, &(union in_addr_union) { .in = *address }, 32, allow_list, deny_list); | |
75 | } | |
76 | static inline bool in6_prefix_is_filtered(const struct in6_addr *prefix, uint8_t prefixlen, Set *allow_list, Set *deny_list) { | |
77 | return address_is_filtered(AF_INET6, &(union in_addr_union) { .in6 = *prefix }, prefixlen, allow_list, deny_list); | |
78 | } | |
79 | ||
6341ea54 YW |
80 | int link_get_captive_portal(Link *link, const char **ret); |
81 | ||
2e5580a8 YW |
82 | const char *dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_; |
83 | DHCPOptionDataType dhcp_option_data_type_from_string(const char *d) _pure_; | |
84 | ||
ca5ad760 | 85 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp); |
6f812d28 | 86 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric); |
52672db3 | 87 | CONFIG_PARSER_PROTOTYPE(config_parse_ndisc_route_metric); |
b90480c8 | 88 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_send_hostname); |
ca5ad760 | 89 | CONFIG_PARSER_PROTOTYPE(config_parse_iaid); |
e47bcb7d | 90 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_or_ra_route_table); |
6fda02e1 | 91 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_user_or_vendor_class); |
0e96961d | 92 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_send_option); |
35f6a5cb | 93 | CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_request_options); |
cde74a65 | 94 | CONFIG_PARSER_PROTOTYPE(config_parse_duid_type); |
4e26a5ba YW |
95 | CONFIG_PARSER_PROTOTYPE(config_parse_manager_duid_type); |
96 | CONFIG_PARSER_PROTOTYPE(config_parse_network_duid_type); | |
cde74a65 | 97 | CONFIG_PARSER_PROTOTYPE(config_parse_duid_rawdata); |
4e26a5ba YW |
98 | CONFIG_PARSER_PROTOTYPE(config_parse_manager_duid_rawdata); |
99 | CONFIG_PARSER_PROTOTYPE(config_parse_network_duid_rawdata); | |
2cba2146 | 100 | CONFIG_PARSER_PROTOTYPE(config_parse_uplink); |