| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include <netinet/in.h> |
| 5 |
|
| 6 |
#include "dhcp-duid-internal.h" |
| 7 |
#include "in-addr-util.h" |
| 8 |
#include "networkd-forward.h" |
| 9 |
|
| 10 |
/* Special values for *_uplink_index. */ |
| 11 |
#define UPLINK_INDEX_AUTO 0 /* uplink will be selected automatically */ |
| 12 |
#define UPLINK_INDEX_NONE -1 /* uplink will not be selected automatically */ |
| 13 |
#define UPLINK_INDEX_SELF -2 /* the interface itself is uplink */ |
| 14 |
|
| 15 |
#define DHCP_ROUTE_METRIC 1024 |
| 16 |
#define IPV6RA_ROUTE_METRIC_HIGH 512 |
| 17 |
#define IPV6RA_ROUTE_METRIC_MEDIUM 1024 |
| 18 |
#define IPV6RA_ROUTE_METRIC_LOW 2048 |
| 19 |
#define DHCP6PD_ROUTE_METRIC 256 |
| 20 |
|
| 21 |
typedef enum DHCPOptionDataType { |
| 22 |
DHCP_OPTION_DATA_UINT8, |
| 23 |
DHCP_OPTION_DATA_UINT16, |
| 24 |
DHCP_OPTION_DATA_UINT32, |
| 25 |
DHCP_OPTION_DATA_STRING, |
| 26 |
DHCP_OPTION_DATA_IPV4ADDRESS, |
| 27 |
DHCP_OPTION_DATA_IPV6ADDRESS, |
| 28 |
_DHCP_OPTION_DATA_MAX, |
| 29 |
_DHCP_OPTION_DATA_INVALID, |
| 30 |
} DHCPOptionDataType; |
| 31 |
|
| 32 |
typedef struct DUID { |
| 33 |
/* Value of Type in [DHCP] section */ |
| 34 |
DUIDType type; |
| 35 |
|
| 36 |
uint8_t raw_data_len; |
| 37 |
uint8_t raw_data[MAX_DUID_DATA_LEN]; |
| 38 |
usec_t llt_time; |
| 39 |
bool set; |
| 40 |
} DUID; |
| 41 |
|
| 42 |
uint32_t link_get_dhcp4_route_table(Link *link); |
| 43 |
uint32_t link_get_ndisc_route_table(Link *link); |
| 44 |
uint32_t link_get_dhcp6_route_table(Link *link); |
| 45 |
|
| 46 |
bool link_dhcp_enabled(Link *link, int family); |
| 47 |
static inline bool link_dhcp4_enabled(Link *link) { |
| 48 |
return link_dhcp_enabled(link, AF_INET); |
| 49 |
} |
| 50 |
static inline bool link_dhcp6_enabled(Link *link) { |
| 51 |
return link_dhcp_enabled(link, AF_INET6); |
| 52 |
} |
| 53 |
|
| 54 |
void network_adjust_dhcp(Network *network); |
| 55 |
|
| 56 |
const DUID *link_get_duid(Link *link, int family); |
| 57 |
static inline const DUID *link_get_dhcp4_duid(Link *link) { |
| 58 |
return link_get_duid(link, AF_INET); |
| 59 |
} |
| 60 |
static inline const DUID *link_get_dhcp6_duid(Link *link) { |
| 61 |
return link_get_duid(link, AF_INET6); |
| 62 |
} |
| 63 |
|
| 64 |
int dhcp_configure_duid(Link *link, const DUID *duid); |
| 65 |
int manager_request_product_uuid(Manager *m); |
| 66 |
|
| 67 |
bool address_is_filtered(int family, const union in_addr_union *address, uint8_t prefixlen, Set *allow_list, Set *deny_list); |
| 68 |
static inline bool in4_address_is_filtered(const struct in_addr *address, Set *allow_list, Set *deny_list) { |
| 69 |
return address_is_filtered(AF_INET, &(union in_addr_union) { .in = *address }, 32, allow_list, deny_list); |
| 70 |
} |
| 71 |
static inline bool in6_prefix_is_filtered(const struct in6_addr *prefix, uint8_t prefixlen, Set *allow_list, Set *deny_list) { |
| 72 |
return address_is_filtered(AF_INET6, &(union in_addr_union) { .in6 = *prefix }, prefixlen, allow_list, deny_list); |
| 73 |
} |
| 74 |
|
| 75 |
int link_get_captive_portal(Link *link, const char **ret); |
| 76 |
|
| 77 |
DECLARE_STRING_TABLE_LOOKUP(dhcp_option_data_type, DHCPOptionDataType); |
| 78 |
|
| 79 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp); |
| 80 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric); |
| 81 |
CONFIG_PARSER_PROTOTYPE(config_parse_ndisc_route_metric); |
| 82 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_send_hostname); |
| 83 |
CONFIG_PARSER_PROTOTYPE(config_parse_iaid); |
| 84 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_or_ra_route_table); |
| 85 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp4_user_class); |
| 86 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_user_or_vendor_class); |
| 87 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_send_option); |
| 88 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_option); |
| 89 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_option_tlv); |
| 90 |
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_request_options); |
| 91 |
CONFIG_PARSER_PROTOTYPE(config_parse_duid_type); |
| 92 |
CONFIG_PARSER_PROTOTYPE(config_parse_manager_duid_type); |
| 93 |
CONFIG_PARSER_PROTOTYPE(config_parse_network_duid_type); |
| 94 |
CONFIG_PARSER_PROTOTYPE(config_parse_duid_rawdata); |
| 95 |
CONFIG_PARSER_PROTOTYPE(config_parse_manager_duid_rawdata); |
| 96 |
CONFIG_PARSER_PROTOTYPE(config_parse_network_duid_rawdata); |
| 97 |
CONFIG_PARSER_PROTOTYPE(config_parse_uplink); |