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
{
48 struct ether_addr mac_addr
;
56 sd_event_source
*recv_event_source
;
57 sd_event_source
*timeout_event_source
;
60 LIST_HEAD(sd_radv_prefix
, prefixes
);
62 unsigned n_route_prefixes
;
63 LIST_HEAD(sd_radv_route_prefix
, route_prefixes
);
66 struct sd_radv_opt_dns
*rdnss
;
67 struct sd_radv_opt_dns
*dnssl
;
70 #define radv_prefix_opt__contents { \
75 be32_t valid_lifetime; \
76 be32_t preferred_lifetime; \
78 struct in6_addr in6_addr; \
81 struct radv_prefix_opt radv_prefix_opt__contents
;
83 /* We need the opt substructure to be packed, because we use it in send(). But
84 * if we use _packed_, this means that the structure cannot be used directly in
85 * normal code in general, because the fields might not be properly aligned.
86 * But in this particular case, the structure is defined in a way that gives
87 * proper alignment, even without the explicit _packed_ attribute. To appease
88 * the compiler we use the "unpacked" structure, but we also verify that
89 * structure contains no holes, so offsets are the same when _packed_ is used.
91 struct radv_prefix_opt__packed radv_prefix_opt__contents _packed_
;
92 assert_cc(sizeof(struct radv_prefix_opt
) == sizeof(struct radv_prefix_opt__packed
));
94 struct sd_radv_prefix
{
97 struct radv_prefix_opt opt
;
99 LIST_FIELDS(struct sd_radv_prefix
, prefix
);
102 usec_t preferred_until
;
105 #define radv_route_prefix_opt__contents { \
109 uint8_t flags_reserved; \
111 struct in6_addr in6_addr; \
114 struct radv_route_prefix_opt radv_route_prefix_opt__contents
;
116 struct radv_route_prefix_opt__packed radv_route_prefix_opt__contents _packed_
;
117 assert_cc(sizeof(struct radv_route_prefix_opt
) == sizeof(struct radv_route_prefix_opt__packed
));
119 struct sd_radv_route_prefix
{
122 struct radv_route_prefix_opt opt
;
124 LIST_FIELDS(struct sd_radv_route_prefix
, prefix
);
127 #define log_radv_full(level, error, fmt, ...) log_internal(level, error, PROJECT_FILE, __LINE__, __func__, "RADV: " fmt, ##__VA_ARGS__)
128 #define log_radv_errno(error, fmt, ...) log_radv_full(LOG_DEBUG, error, fmt, ##__VA_ARGS__)
129 #define log_radv(fmt, ...) log_radv_errno(0, fmt, ##__VA_ARGS__)