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