1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 Copyright © 2017 Intel Corporation. All rights reserved.
12 #include "sparse-endian.h"
14 assert_cc(SD_RADV_DEFAULT_MIN_TIMEOUT_USEC
<= SD_RADV_DEFAULT_MAX_TIMEOUT_USEC
);
16 #define SD_RADV_MAX_INITIAL_RTR_ADVERT_INTERVAL_USEC (16*USEC_PER_SEC)
17 #define SD_RADV_MAX_INITIAL_RTR_ADVERTISEMENTS 3
18 #define SD_RADV_MAX_FINAL_RTR_ADVERTISEMENTS 3
19 #define SD_RADV_MIN_DELAY_BETWEEN_RAS 3
20 #define SD_RADV_MAX_RA_DELAY_TIME_USEC (500*USEC_PER_MSEC)
22 #define SD_RADV_OPT_ROUTE_INFORMATION 24
23 #define SD_RADV_OPT_RDNSS 25
24 #define SD_RADV_OPT_DNSSL 31
27 SD_RADV_STATE_IDLE
= 0,
28 SD_RADV_STATE_ADVERTISING
= 1,
30 typedef enum RAdvState RAdvState
;
32 struct sd_radv_opt_dns
{
49 struct ether_addr mac_addr
;
57 sd_event_source
*recv_event_source
;
58 sd_event_source
*timeout_event_source
;
61 LIST_HEAD(sd_radv_prefix
, prefixes
);
63 unsigned n_route_prefixes
;
64 LIST_HEAD(sd_radv_route_prefix
, route_prefixes
);
67 struct sd_radv_opt_dns
*rdnss
;
68 struct sd_radv_opt_dns
*dnssl
;
71 #define radv_prefix_opt__contents { \
76 be32_t valid_lifetime; \
77 be32_t preferred_lifetime; \
79 struct in6_addr in6_addr; \
82 struct radv_prefix_opt radv_prefix_opt__contents
;
84 /* We need the opt substructure to be packed, because we use it in send(). But
85 * if we use _packed_, this means that the structure cannot be used directly in
86 * normal code in general, because the fields might not be properly aligned.
87 * But in this particular case, the structure is defined in a way that gives
88 * proper alignment, even without the explicit _packed_ attribute. To appease
89 * the compiler we use the "unpacked" structure, but we also verify that
90 * structure contains no holes, so offsets are the same when _packed_ is used.
92 struct radv_prefix_opt__packed radv_prefix_opt__contents _packed_
;
93 assert_cc(sizeof(struct radv_prefix_opt
) == sizeof(struct radv_prefix_opt__packed
));
95 struct sd_radv_prefix
{
98 struct radv_prefix_opt opt
;
100 LIST_FIELDS(struct sd_radv_prefix
, prefix
);
103 usec_t preferred_until
;
106 #define radv_route_prefix_opt__contents { \
110 uint8_t flags_reserved; \
112 struct in6_addr in6_addr; \
115 struct radv_route_prefix_opt radv_route_prefix_opt__contents
;
117 struct radv_route_prefix_opt__packed radv_route_prefix_opt__contents _packed_
;
118 assert_cc(sizeof(struct radv_route_prefix_opt
) == sizeof(struct radv_route_prefix_opt__packed
));
120 struct sd_radv_route_prefix
{
123 struct radv_route_prefix_opt opt
;
125 LIST_FIELDS(struct sd_radv_route_prefix
, prefix
);
128 #define log_radv_errno(radv, error, fmt, ...) \
132 log_interface_full_errno( \
133 sd_radv_get_ifname(radv), \
134 LOG_DEBUG, _e, "RADV: " fmt, \
138 #define log_radv(radv, fmt, ...) \
139 log_radv_errno(radv, 0, fmt, ##__VA_ARGS__)