1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 /*** 5 Copyright © 2017 Intel Corporation. All rights reserved. 6 ***/ 7 8 #include <inttypes.h> 9 #include <stdbool.h> 10 11 #include "sd-radv.h" 12 13 #include "in-addr-util.h" 14 #include "conf-parser.h" 15 #include "networkd-util.h" 16 17 typedef struct Link Link; 18 typedef struct Network Network; 19 20 typedef enum RADVPrefixDelegation { 21 RADV_PREFIX_DELEGATION_NONE = 0, 22 RADV_PREFIX_DELEGATION_STATIC = 1 << 0, 23 RADV_PREFIX_DELEGATION_DHCP6 = 1 << 1, 24 RADV_PREFIX_DELEGATION_BOTH = RADV_PREFIX_DELEGATION_STATIC | RADV_PREFIX_DELEGATION_DHCP6, 25 _RADV_PREFIX_DELEGATION_MAX, 26 _RADV_PREFIX_DELEGATION_INVALID = -EINVAL, 27 } RADVPrefixDelegation; 28 29 typedef struct Prefix { 30 Network *network; 31 ConfigSection *section; 32 33 struct in6_addr prefix; 34 uint8_t prefixlen; 35 usec_t preferred_lifetime; 36 usec_t valid_lifetime; 37 38 bool onlink; 39 bool address_auto_configuration; 40 41 bool assign; 42 uint32_t route_metric; 43 Set *tokens; 44 } Prefix; 45 46 typedef struct RoutePrefix { 47 Network *network; 48 ConfigSection *section; 49 50 struct in6_addr prefix; 51 uint8_t prefixlen; 52 usec_t lifetime; 53 } RoutePrefix; 54 55 Prefix *prefix_free(Prefix *prefix); 56 RoutePrefix *route_prefix_free(RoutePrefix *prefix); 57 58 void network_drop_invalid_prefixes(Network *network); 59 void network_drop_invalid_route_prefixes(Network *network); 60 void network_adjust_radv(Network *network); 61 62 int link_request_radv_addresses(Link *link); 63 64 bool link_radv_enabled(Link *link); 65 int radv_start(Link *link); 66 int radv_update_mac(Link *link); 67 int radv_add_prefix(Link *link, const struct in6_addr *prefix, uint8_t prefix_len, 68 usec_t lifetime_preferred_usec, usec_t lifetime_valid_usec); 69 70 int link_request_radv(Link *link); 71 72 const char* radv_prefix_delegation_to_string(RADVPrefixDelegation i) _const_; 73 RADVPrefixDelegation radv_prefix_delegation_from_string(const char *s) _pure_; 74 75 CONFIG_PARSER_PROTOTYPE(config_parse_router_prefix_delegation); 76 CONFIG_PARSER_PROTOTYPE(config_parse_router_lifetime); 77 CONFIG_PARSER_PROTOTYPE(config_parse_router_preference); 78 CONFIG_PARSER_PROTOTYPE(config_parse_prefix); 79 CONFIG_PARSER_PROTOTYPE(config_parse_prefix_boolean); 80 CONFIG_PARSER_PROTOTYPE(config_parse_prefix_lifetime); 81 CONFIG_PARSER_PROTOTYPE(config_parse_prefix_metric); 82 CONFIG_PARSER_PROTOTYPE(config_parse_prefix_token); 83 CONFIG_PARSER_PROTOTYPE(config_parse_radv_dns); 84 CONFIG_PARSER_PROTOTYPE(config_parse_radv_search_domains); 85 CONFIG_PARSER_PROTOTYPE(config_parse_route_prefix); 86 CONFIG_PARSER_PROTOTYPE(config_parse_route_prefix_lifetime); 87