2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2017-05-12 15:48:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/***
|
2018-06-12 17:15:23 +02:00
|
|
|
Copyright © 2017 Intel Corporation. All rights reserved.
|
2017-05-12 15:48:27 +02:00
|
|
|
***/
|
|
|
|
|
|
|
|
#include "sd-radv.h"
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "list.h"
|
|
|
|
#include "sparse-endian.h"
|
|
|
|
|
2017-05-12 15:48:34 +02:00
|
|
|
assert_cc(SD_RADV_DEFAULT_MIN_TIMEOUT_USEC <= SD_RADV_DEFAULT_MAX_TIMEOUT_USEC)
|
|
|
|
|
|
|
|
#define SD_RADV_MAX_INITIAL_RTR_ADVERT_INTERVAL_USEC (16*USEC_PER_SEC)
|
|
|
|
#define SD_RADV_MAX_INITIAL_RTR_ADVERTISEMENTS 3
|
|
|
|
#define SD_RADV_MAX_FINAL_RTR_ADVERTISEMENTS 3
|
|
|
|
#define SD_RADV_MIN_DELAY_BETWEEN_RAS 3
|
|
|
|
#define SD_RADV_MAX_RA_DELAY_TIME_USEC (500*USEC_PER_MSEC)
|
|
|
|
|
2017-08-14 11:53:11 +02:00
|
|
|
#define SD_RADV_OPT_RDNSS 25
|
2017-08-21 12:41:20 +02:00
|
|
|
#define SD_RADV_OPT_DNSSL 31
|
2017-08-14 11:53:11 +02:00
|
|
|
|
2017-05-12 15:48:31 +02:00
|
|
|
enum RAdvState {
|
|
|
|
SD_RADV_STATE_IDLE = 0,
|
|
|
|
SD_RADV_STATE_ADVERTISING = 1,
|
|
|
|
};
|
|
|
|
typedef enum RAdvState RAdvState;
|
|
|
|
|
2017-08-14 11:53:11 +02:00
|
|
|
struct sd_radv_opt_dns {
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t length;
|
|
|
|
uint16_t reserved;
|
|
|
|
be32_t lifetime;
|
|
|
|
} _packed_;
|
|
|
|
|
2017-05-12 15:48:31 +02:00
|
|
|
struct sd_radv {
|
|
|
|
unsigned n_ref;
|
|
|
|
RAdvState state;
|
|
|
|
|
|
|
|
int ifindex;
|
|
|
|
|
|
|
|
sd_event *event;
|
|
|
|
int event_priority;
|
|
|
|
|
|
|
|
struct ether_addr mac_addr;
|
|
|
|
uint8_t hop_limit;
|
|
|
|
uint8_t flags;
|
|
|
|
uint32_t mtu;
|
|
|
|
uint16_t lifetime;
|
|
|
|
|
2017-05-12 15:48:37 +02:00
|
|
|
int fd;
|
2017-05-12 15:48:34 +02:00
|
|
|
unsigned ra_sent;
|
2017-05-12 15:48:38 +02:00
|
|
|
sd_event_source *recv_event_source;
|
2017-05-12 15:48:34 +02:00
|
|
|
sd_event_source *timeout_event_source;
|
|
|
|
|
2017-05-12 15:48:31 +02:00
|
|
|
unsigned n_prefixes;
|
|
|
|
LIST_HEAD(sd_radv_prefix, prefixes);
|
2017-08-14 11:53:11 +02:00
|
|
|
|
|
|
|
size_t n_rdnss;
|
|
|
|
struct sd_radv_opt_dns *rdnss;
|
2017-08-21 12:41:20 +02:00
|
|
|
struct sd_radv_opt_dns *dnssl;
|
2017-05-12 15:48:31 +02:00
|
|
|
};
|
|
|
|
|
2017-05-12 15:48:27 +02:00
|
|
|
struct sd_radv_prefix {
|
|
|
|
unsigned n_ref;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t prefixlen;
|
|
|
|
uint8_t flags;
|
|
|
|
be32_t valid_lifetime;
|
|
|
|
be32_t preferred_lifetime;
|
|
|
|
uint32_t reserved;
|
|
|
|
struct in6_addr in6_addr;
|
|
|
|
} _packed_ opt;
|
|
|
|
|
|
|
|
LIST_FIELDS(struct sd_radv_prefix, prefix);
|
2018-01-04 14:11:55 +01:00
|
|
|
|
|
|
|
usec_t valid_until;
|
|
|
|
usec_t preferred_until;
|
2017-05-12 15:48:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define log_radv_full(level, error, fmt, ...) log_internal(level, error, __FILE__, __LINE__, __func__, "RADV: " fmt, ##__VA_ARGS__)
|
|
|
|
#define log_radv_errno(error, fmt, ...) log_radv_full(LOG_DEBUG, error, fmt, ##__VA_ARGS__)
|
|
|
|
#define log_radv(fmt, ...) log_radv_errno(0, fmt, ##__VA_ARGS__)
|