resolved-link.h revision af49ca27ffd790d78dbbb465b978266dfd5c93da
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#pragma once
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen/***
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen This file is part of systemd.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Copyright 2014 Lennart Poettering
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is free software; you can redistribute it and/or modify it
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen under the terms of the GNU Lesser General Public License as published by
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen (at your option) any later version.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is distributed in the hope that it will be useful, but
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Lesser General Public License for more details.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen You should have received a copy of the GNU Lesser General Public License
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen***/
2a73e0d39a9bec82c3800071e375d27164727e71Tom Gundersen
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen#include <net/if.h>
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#include "in-addr-util.h"
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen#include "ratelimit.h"
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen#include "resolve-util.h"
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersentypedef struct Link Link;
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersentypedef struct LinkAddress LinkAddress;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#include "resolved-dns-rr.h"
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#include "resolved-dns-search-domain.h"
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#include "resolved-dns-server.h"
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen#include "resolved-manager.h"
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
daeb71a36a98834664e4d95773a3629b746f4db8Tom Gundersen#define LINK_SEARCH_DOMAINS_MAX 32
16b9b87aeee9353b5b8dae6089a69752422a5b09Tom Gundersen#define LINK_DNS_SERVERS_MAX 32
3aeb37bc4f32b5edc334f2ac7c5d3c7b0a121328Tom Gundersen
be32eb9b7fbcb22e4b648086d644135e38279633Tom Gundersenstruct LinkAddress {
9bf3b53533cdc9b95c921b71da755401f223f765Lennart Poettering Link *link;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen int family;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen union in_addr_union in_addr;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen unsigned char flags, scope;
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen DnsResourceRecord *llmnr_address_rr;
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen DnsResourceRecord *llmnr_ptr_rr;
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen
43b3a5ef61859f06cdbaf26765cab8e1adac4296Tom Gundersen LIST_FIELDS(LinkAddress, addresses);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen};
97f2d76d4f4dfab8b0629c09926a05a1e5621125Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenstruct Link {
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Manager *manager;
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen int ifindex;
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen unsigned flags;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen LIST_HEAD(LinkAddress, addresses);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen LIST_HEAD(DnsServer, dns_servers);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen DnsServer *current_dns_server;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen unsigned n_dns_servers;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen LIST_HEAD(DnsSearchDomain, search_domains);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen unsigned n_search_domains;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen ResolveSupport llmnr_support;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen ResolveSupport mdns_support;
977085794d2996320e345433403de75f662b0622Tom Gundersen
977085794d2996320e345433403de75f662b0622Tom Gundersen DnsScope *unicast_scope;
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen DnsScope *llmnr_ipv4_scope;
f61942250a43a123580d7bbe5d7873dc5118ed97Tom Gundersen DnsScope *llmnr_ipv6_scope;
9dc670ea766c711741f462b29572f2e5f8f3f6bcTom Gundersen DnsScope *mdns_ipv4_scope;
9dc670ea766c711741f462b29572f2e5f8f3f6bcTom Gundersen DnsScope *mdns_ipv6_scope;
9dc670ea766c711741f462b29572f2e5f8f3f6bcTom Gundersen
c50e28a38ccbdd1e1d1f082dd67bb3e74be4d459Dave Reisner char name[IF_NAMESIZE];
c50e28a38ccbdd1e1d1f082dd67bb3e74be4d459Dave Reisner uint32_t mtu;
c50e28a38ccbdd1e1d1f082dd67bb3e74be4d459Dave Reisner};
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenint link_new(Manager *m, Link **ret, int ifindex);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenLink *link_free(Link *l);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenint link_update_rtnl(Link *l, sd_netlink_message *m);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenint link_update_monitor(Link *l);
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersenbool link_relevant(Link *l, int family);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenLinkAddress* link_find_address(Link *l, int family, const union in_addr_union *in_addr);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenvoid link_add_rrs(Link *l, bool force_remove);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenDnsServer* link_set_dns_server(Link *l, DnsServer *s);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenDnsServer* link_get_dns_server(Link *l);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenvoid link_next_dns_server(Link *l);
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersen
5b9d4dc05560ddda89e48b6b39365824b15e1300Tom Gundersenint link_address_new(Link *l, LinkAddress **ret, int family, const union in_addr_union *in_addr);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom GundersenLinkAddress *link_address_free(LinkAddress *a);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenint link_address_update_rtnl(LinkAddress *a, sd_netlink_message *m);
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersenbool link_address_relevant(LinkAddress *l);
977085794d2996320e345433403de75f662b0622Tom Gundersenvoid link_address_add_rrs(LinkAddress *a, bool force_remove);
977085794d2996320e345433403de75f662b0622Tom Gundersen
977085794d2996320e345433403de75f662b0622Tom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
977085794d2996320e345433403de75f662b0622Tom Gundersen