]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-link.h
261e34bfe23c5e2428a6c27280a4b21d3838d2d7
[thirdparty/systemd.git] / src / resolve / resolved-link.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
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
23 #include <net/if.h>
24
25 #include "in-addr-util.h"
26 #include "ratelimit.h"
27 #include "resolve-util.h"
28
29 typedef struct Link Link;
30 typedef struct LinkAddress LinkAddress;
31
32 #include "resolved-dns-rr.h"
33 #include "resolved-dns-scope.h"
34 #include "resolved-dns-search-domain.h"
35 #include "resolved-dns-server.h"
36 #include "resolved-manager.h"
37
38 #define LINK_SEARCH_DOMAINS_MAX 32
39 #define LINK_DNS_SERVERS_MAX 32
40
41 struct LinkAddress {
42 Link *link;
43
44 int family;
45 union in_addr_union in_addr;
46
47 unsigned char flags, scope;
48
49 DnsResourceRecord *llmnr_address_rr;
50 DnsResourceRecord *llmnr_ptr_rr;
51 DnsResourceRecord *mdns_address_rr;
52 DnsResourceRecord *mdns_ptr_rr;
53
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);
64 unsigned n_addresses;
65
66 LIST_HEAD(DnsServer, dns_servers);
67 DnsServer *current_dns_server;
68 unsigned n_dns_servers;
69
70 LIST_HEAD(DnsSearchDomain, search_domains);
71 unsigned n_search_domains;
72
73 ResolveSupport llmnr_support;
74 ResolveSupport mdns_support;
75 DnssecMode dnssec_mode;
76 Set *dnssec_negative_trust_anchors;
77
78 DnsScope *unicast_scope;
79 DnsScope *llmnr_ipv4_scope;
80 DnsScope *llmnr_ipv6_scope;
81 DnsScope *mdns_ipv4_scope;
82 DnsScope *mdns_ipv6_scope;
83
84 bool is_managed;
85
86 char name[IF_NAMESIZE];
87 uint32_t mtu;
88 uint8_t operstate;
89
90 bool loaded;
91 char *state_file;
92
93 bool unicast_relevant;
94 };
95
96 int link_new(Manager *m, Link **ret, int ifindex);
97 Link *link_free(Link *l);
98 int link_process_rtnl(Link *l, sd_netlink_message *m);
99 int link_update(Link *l);
100 bool link_relevant(Link *l, int family, bool local_multicast);
101 LinkAddress* link_find_address(Link *l, int family, const union in_addr_union *in_addr);
102 void link_add_rrs(Link *l, bool force_remove);
103
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
108 DnsServer* link_set_dns_server(Link *l, DnsServer *s);
109 DnsServer* link_get_dns_server(Link *l);
110 void link_next_dns_server(Link *l);
111
112 DnssecMode link_get_dnssec_mode(Link *l);
113 bool link_dnssec_supported(Link *l);
114
115 int link_save_user(Link *l);
116 int link_load_user(Link *l);
117 void link_remove_user(Link *l);
118
119 int link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr_union *in_addr);
120 LinkAddress *link_address_free(LinkAddress *a);
121 int link_address_update_rtnl(LinkAddress *a, sd_netlink_message *m);
122 bool link_address_relevant(LinkAddress *l, bool local_multicast);
123 void link_address_add_rrs(LinkAddress *a, bool force_remove);
124
125 DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);