]>
Commit | Line | Data |
---|---|---|
091214b6 PF |
1 | /*** |
2 | This file is part of systemd. | |
3 | ||
4 | Copyright (C) 2017 Intel Corporation. All rights reserved. | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
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/>. | |
18 | ***/ | |
19 | ||
20 | #include <netinet/icmp6.h> | |
21 | #include <arpa/inet.h> | |
22 | ||
23 | #include "networkd-address.h" | |
24 | #include "networkd-radv.h" | |
25 | #include "sd-radv.h" | |
26 | ||
27 | int radv_configure(Link *link) { | |
28 | int r; | |
29 | Prefix *p; | |
30 | ||
31 | assert(link); | |
32 | assert(link->network); | |
33 | ||
34 | r = sd_radv_new(&link->radv); | |
35 | if (r < 0) | |
36 | return r; | |
37 | ||
38 | r = sd_radv_attach_event(link->radv, NULL, 0); | |
39 | if (r < 0) | |
40 | return r; | |
41 | ||
42 | r = sd_radv_set_mac(link->radv, &link->mac); | |
43 | if (r < 0) | |
44 | return r; | |
45 | ||
46 | r = sd_radv_set_ifindex(link->radv, link->ifindex); | |
47 | if (r < 0) | |
48 | return r; | |
49 | ||
50 | r = sd_radv_set_managed_information(link->radv, link->network->router_managed); | |
51 | if (r < 0) | |
52 | return r; | |
53 | ||
54 | r = sd_radv_set_other_information(link->radv, link->network->router_other_information); | |
55 | if (r < 0) | |
56 | return r; | |
57 | ||
58 | r = sd_radv_set_router_lifetime(link->radv, | |
59 | link->network->router_lifetime_usec); | |
60 | if (r < 0) | |
61 | return r; | |
62 | ||
63 | if (link->network->router_lifetime_usec > 0) { | |
64 | r = sd_radv_set_preference(link->radv, | |
65 | link->network->router_preference); | |
66 | if (r < 0) | |
67 | return r; | |
68 | } | |
69 | ||
70 | LIST_FOREACH(prefixes, p, link->network->static_prefixes) { | |
71 | r = sd_radv_add_prefix(link->radv, p->radv_prefix); | |
72 | if (r != -EEXIST && r < 0) | |
73 | return r; | |
74 | } | |
75 | ||
76 | return 0; | |
77 | } |