]>
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. | |
04473969 PF |
8 | ***/ |
9 | ||
10 | #include "sd-radv.h" | |
11 | ||
12 | #include "log.h" | |
13 | #include "list.h" | |
14 | #include "sparse-endian.h" | |
15 | ||
204fb681 PF |
16 | assert_cc(SD_RADV_DEFAULT_MIN_TIMEOUT_USEC <= SD_RADV_DEFAULT_MAX_TIMEOUT_USEC) |
17 | ||
18 | #define SD_RADV_MAX_INITIAL_RTR_ADVERT_INTERVAL_USEC (16*USEC_PER_SEC) | |
19 | #define SD_RADV_MAX_INITIAL_RTR_ADVERTISEMENTS 3 | |
20 | #define SD_RADV_MAX_FINAL_RTR_ADVERTISEMENTS 3 | |
21 | #define SD_RADV_MIN_DELAY_BETWEEN_RAS 3 | |
22 | #define SD_RADV_MAX_RA_DELAY_TIME_USEC (500*USEC_PER_MSEC) | |
23 | ||
e9c6da38 | 24 | #define SD_RADV_OPT_RDNSS 25 |
e965d6ab | 25 | #define SD_RADV_OPT_DNSSL 31 |
e9c6da38 | 26 | |
204f99d2 PF |
27 | enum RAdvState { |
28 | SD_RADV_STATE_IDLE = 0, | |
29 | SD_RADV_STATE_ADVERTISING = 1, | |
30 | }; | |
31 | typedef enum RAdvState RAdvState; | |
32 | ||
e9c6da38 PF |
33 | struct sd_radv_opt_dns { |
34 | uint8_t type; | |
35 | uint8_t length; | |
36 | uint16_t reserved; | |
37 | be32_t lifetime; | |
38 | } _packed_; | |
39 | ||
204f99d2 PF |
40 | struct sd_radv { |
41 | unsigned n_ref; | |
42 | RAdvState state; | |
43 | ||
44 | int ifindex; | |
45 | ||
46 | sd_event *event; | |
47 | int event_priority; | |
48 | ||
49 | struct ether_addr mac_addr; | |
50 | uint8_t hop_limit; | |
51 | uint8_t flags; | |
52 | uint32_t mtu; | |
53 | uint16_t lifetime; | |
54 | ||
77baf5ae | 55 | int fd; |
204fb681 | 56 | unsigned ra_sent; |
88d5a3db | 57 | sd_event_source *recv_event_source; |
204fb681 PF |
58 | sd_event_source *timeout_event_source; |
59 | ||
204f99d2 PF |
60 | unsigned n_prefixes; |
61 | LIST_HEAD(sd_radv_prefix, prefixes); | |
e9c6da38 PF |
62 | |
63 | size_t n_rdnss; | |
64 | struct sd_radv_opt_dns *rdnss; | |
e965d6ab | 65 | struct sd_radv_opt_dns *dnssl; |
204f99d2 PF |
66 | }; |
67 | ||
04473969 PF |
68 | struct sd_radv_prefix { |
69 | unsigned n_ref; | |
70 | ||
71 | struct { | |
72 | uint8_t type; | |
73 | uint8_t length; | |
74 | uint8_t prefixlen; | |
75 | uint8_t flags; | |
76 | be32_t valid_lifetime; | |
77 | be32_t preferred_lifetime; | |
78 | uint32_t reserved; | |
79 | struct in6_addr in6_addr; | |
80 | } _packed_ opt; | |
81 | ||
82 | LIST_FIELDS(struct sd_radv_prefix, prefix); | |
d601b566 PF |
83 | |
84 | usec_t valid_until; | |
85 | usec_t preferred_until; | |
04473969 PF |
86 | }; |
87 | ||
88 | #define log_radv_full(level, error, fmt, ...) log_internal(level, error, __FILE__, __LINE__, __func__, "RADV: " fmt, ##__VA_ARGS__) | |
89 | #define log_radv_errno(error, fmt, ...) log_radv_full(LOG_DEBUG, error, fmt, ##__VA_ARGS__) | |
90 | #define log_radv_warning_errno(error, fmt, ...) log_radv_full(LOG_WARNING, error, fmt, ##__VA_ARGS__) | |
91 | #define log_radv(fmt, ...) log_radv_errno(0, fmt, ##__VA_ARGS__) |