]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
04473969 PF |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright (C) 2017 Intel Corporation. All rights reserved. | |
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 "sd-radv.h" | |
24 | ||
25 | #include "log.h" | |
26 | #include "list.h" | |
27 | #include "sparse-endian.h" | |
28 | ||
204fb681 PF |
29 | assert_cc(SD_RADV_DEFAULT_MIN_TIMEOUT_USEC <= SD_RADV_DEFAULT_MAX_TIMEOUT_USEC) |
30 | ||
31 | #define SD_RADV_MAX_INITIAL_RTR_ADVERT_INTERVAL_USEC (16*USEC_PER_SEC) | |
32 | #define SD_RADV_MAX_INITIAL_RTR_ADVERTISEMENTS 3 | |
33 | #define SD_RADV_MAX_FINAL_RTR_ADVERTISEMENTS 3 | |
34 | #define SD_RADV_MIN_DELAY_BETWEEN_RAS 3 | |
35 | #define SD_RADV_MAX_RA_DELAY_TIME_USEC (500*USEC_PER_MSEC) | |
36 | ||
e9c6da38 | 37 | #define SD_RADV_OPT_RDNSS 25 |
e965d6ab | 38 | #define SD_RADV_OPT_DNSSL 31 |
e9c6da38 | 39 | |
204f99d2 PF |
40 | enum RAdvState { |
41 | SD_RADV_STATE_IDLE = 0, | |
42 | SD_RADV_STATE_ADVERTISING = 1, | |
43 | }; | |
44 | typedef enum RAdvState RAdvState; | |
45 | ||
e9c6da38 PF |
46 | struct sd_radv_opt_dns { |
47 | uint8_t type; | |
48 | uint8_t length; | |
49 | uint16_t reserved; | |
50 | be32_t lifetime; | |
51 | } _packed_; | |
52 | ||
204f99d2 PF |
53 | struct sd_radv { |
54 | unsigned n_ref; | |
55 | RAdvState state; | |
56 | ||
57 | int ifindex; | |
58 | ||
59 | sd_event *event; | |
60 | int event_priority; | |
61 | ||
62 | struct ether_addr mac_addr; | |
63 | uint8_t hop_limit; | |
64 | uint8_t flags; | |
65 | uint32_t mtu; | |
66 | uint16_t lifetime; | |
67 | ||
77baf5ae | 68 | int fd; |
204fb681 | 69 | unsigned ra_sent; |
88d5a3db | 70 | sd_event_source *recv_event_source; |
204fb681 PF |
71 | sd_event_source *timeout_event_source; |
72 | ||
204f99d2 PF |
73 | unsigned n_prefixes; |
74 | LIST_HEAD(sd_radv_prefix, prefixes); | |
e9c6da38 PF |
75 | |
76 | size_t n_rdnss; | |
77 | struct sd_radv_opt_dns *rdnss; | |
e965d6ab | 78 | struct sd_radv_opt_dns *dnssl; |
204f99d2 PF |
79 | }; |
80 | ||
04473969 PF |
81 | struct sd_radv_prefix { |
82 | unsigned n_ref; | |
83 | ||
84 | struct { | |
85 | uint8_t type; | |
86 | uint8_t length; | |
87 | uint8_t prefixlen; | |
88 | uint8_t flags; | |
89 | be32_t valid_lifetime; | |
90 | be32_t preferred_lifetime; | |
91 | uint32_t reserved; | |
92 | struct in6_addr in6_addr; | |
93 | } _packed_ opt; | |
94 | ||
95 | LIST_FIELDS(struct sd_radv_prefix, prefix); | |
96 | }; | |
97 | ||
98 | #define log_radv_full(level, error, fmt, ...) log_internal(level, error, __FILE__, __LINE__, __func__, "RADV: " fmt, ##__VA_ARGS__) | |
99 | #define log_radv_errno(error, fmt, ...) log_radv_full(LOG_DEBUG, error, fmt, ##__VA_ARGS__) | |
100 | #define log_radv_warning_errno(error, fmt, ...) log_radv_full(LOG_WARNING, error, fmt, ##__VA_ARGS__) | |
101 | #define log_radv(fmt, ...) log_radv_errno(0, fmt, ##__VA_ARGS__) |