]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-radv.c
2 This file is part of systemd.
4 Copyright (C) 2017 Intel Corporation. All rights reserved.
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 #include <netinet/icmp6.h>
21 #include <arpa/inet.h>
23 #include "networkd-address.h"
24 #include "networkd-radv.h"
27 int radv_configure(Link
*link
) {
32 assert(link
->network
);
34 r
= sd_radv_new(&link
->radv
);
38 r
= sd_radv_attach_event(link
->radv
, NULL
, 0);
42 r
= sd_radv_set_mac(link
->radv
, &link
->mac
);
46 r
= sd_radv_set_ifindex(link
->radv
, link
->ifindex
);
50 r
= sd_radv_set_managed_information(link
->radv
, link
->network
->router_managed
);
54 r
= sd_radv_set_other_information(link
->radv
, link
->network
->router_other_information
);
58 /* a value of 0xffffffff represents infinity, 0x0 means this host is
60 r
= sd_radv_set_router_lifetime(link
->radv
,
61 DIV_ROUND_UP(link
->network
->router_lifetime_usec
, USEC_PER_SEC
));
65 if (link
->network
->router_lifetime_usec
> 0) {
66 r
= sd_radv_set_preference(link
->radv
,
67 link
->network
->router_preference
);
72 LIST_FOREACH(prefixes
, p
, link
->network
->static_prefixes
) {
73 r
= sd_radv_add_prefix(link
->radv
, p
->radv_prefix
);
74 if (r
!= -EEXIST
&& r
< 0)
78 if (link
->network
->router_dns
) {
79 r
= sd_radv_set_rdnss(link
->radv
,
80 DIV_ROUND_UP(link
->network
->router_dns_lifetime_usec
,
82 link
->network
->router_dns
,
83 link
->network
->n_router_dns
);
88 if (link
->network
->router_search_domains
) {
89 r
= sd_radv_set_dnssl(link
->radv
,
90 DIV_ROUND_UP(link
->network
->router_dns_lifetime_usec
,
92 link
->network
->router_search_domains
);