]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
74b2466e LP |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2014 Lennart Poettering | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
1716f6dc LP |
23 | #include <net/if.h> |
24 | ||
74b2466e LP |
25 | #include "in-addr-util.h" |
26 | #include "ratelimit.h" | |
af49ca27 | 27 | #include "resolve-util.h" |
74b2466e LP |
28 | |
29 | typedef struct Link Link; | |
30 | typedef struct LinkAddress LinkAddress; | |
31 | ||
623a4c97 | 32 | #include "resolved-dns-rr.h" |
07f264e4 | 33 | #include "resolved-dns-scope.h" |
a51c1048 LP |
34 | #include "resolved-dns-search-domain.h" |
35 | #include "resolved-dns-server.h" | |
39d8db04 | 36 | #include "resolved-manager.h" |
74b2466e | 37 | |
eed857b7 LP |
38 | #define LINK_SEARCH_DOMAINS_MAX 32 |
39 | #define LINK_DNS_SERVERS_MAX 32 | |
40 | ||
74b2466e LP |
41 | struct LinkAddress { |
42 | Link *link; | |
43 | ||
0dd25fb9 | 44 | int family; |
74b2466e LP |
45 | union in_addr_union in_addr; |
46 | ||
47 | unsigned char flags, scope; | |
48 | ||
623a4c97 LP |
49 | DnsResourceRecord *llmnr_address_rr; |
50 | DnsResourceRecord *llmnr_ptr_rr; | |
400cb36e DR |
51 | DnsResourceRecord *mdns_address_rr; |
52 | DnsResourceRecord *mdns_ptr_rr; | |
623a4c97 | 53 | |
74b2466e LP |
54 | LIST_FIELDS(LinkAddress, addresses); |
55 | }; | |
56 | ||
57 | struct Link { | |
58 | Manager *manager; | |
59 | ||
60 | int ifindex; | |
61 | unsigned flags; | |
62 | ||
63 | LIST_HEAD(LinkAddress, addresses); | |
bceaa99d | 64 | unsigned n_addresses; |
74b2466e | 65 | |
6073b6f2 | 66 | LIST_HEAD(DnsServer, dns_servers); |
74b2466e | 67 | DnsServer *current_dns_server; |
eed857b7 | 68 | unsigned n_dns_servers; |
74b2466e | 69 | |
a51c1048 | 70 | LIST_HEAD(DnsSearchDomain, search_domains); |
eed857b7 | 71 | unsigned n_search_domains; |
a51c1048 | 72 | |
af49ca27 LP |
73 | ResolveSupport llmnr_support; |
74 | ResolveSupport mdns_support; | |
ad6c0475 | 75 | DnssecMode dnssec_mode; |
8a516214 | 76 | Set *dnssec_negative_trust_anchors; |
19b50b5b | 77 | |
74b2466e | 78 | DnsScope *unicast_scope; |
1716f6dc LP |
79 | DnsScope *llmnr_ipv4_scope; |
80 | DnsScope *llmnr_ipv6_scope; | |
b4f1862d DM |
81 | DnsScope *mdns_ipv4_scope; |
82 | DnsScope *mdns_ipv6_scope; | |
74b2466e | 83 | |
97e5d693 LP |
84 | bool is_managed; |
85 | ||
1716f6dc | 86 | char name[IF_NAMESIZE]; |
e1c95994 | 87 | uint32_t mtu; |
6955a3ba | 88 | uint8_t operstate; |
943ef07c LP |
89 | |
90 | bool loaded; | |
91 | char *state_file; | |
59c0fd0e LP |
92 | |
93 | bool unicast_relevant; | |
74b2466e LP |
94 | }; |
95 | ||
96 | int link_new(Manager *m, Link **ret, int ifindex); | |
97 | Link *link_free(Link *l); | |
943ef07c LP |
98 | int link_process_rtnl(Link *l, sd_netlink_message *m); |
99 | int link_update(Link *l); | |
011696f7 | 100 | bool link_relevant(Link *l, int family, bool local_multicast); |
623a4c97 | 101 | LinkAddress* link_find_address(Link *l, int family, const union in_addr_union *in_addr); |
ec2c5e43 | 102 | void link_add_rrs(Link *l, bool force_remove); |
2c27fbca | 103 | |
97e5d693 LP |
104 | void link_flush_settings(Link *l); |
105 | void link_set_dnssec_mode(Link *l, DnssecMode mode); | |
106 | void link_allocate_scopes(Link *l); | |
107 | ||
2c27fbca | 108 | DnsServer* link_set_dns_server(Link *l, DnsServer *s); |
74b2466e LP |
109 | DnsServer* link_get_dns_server(Link *l); |
110 | void link_next_dns_server(Link *l); | |
111 | ||
c69fa7e3 LP |
112 | DnssecMode link_get_dnssec_mode(Link *l); |
113 | bool link_dnssec_supported(Link *l); | |
114 | ||
943ef07c LP |
115 | int link_save_user(Link *l); |
116 | int link_load_user(Link *l); | |
117 | void link_remove_user(Link *l); | |
118 | ||
623a4c97 | 119 | int link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr_union *in_addr); |
74b2466e | 120 | LinkAddress *link_address_free(LinkAddress *a); |
1c4baffc | 121 | int link_address_update_rtnl(LinkAddress *a, sd_netlink_message *m); |
011696f7 | 122 | bool link_address_relevant(LinkAddress *l, bool local_multicast); |
ec2c5e43 | 123 | void link_address_add_rrs(LinkAddress *a, bool force_remove); |
74b2466e LP |
124 | |
125 | DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free); |