2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
network: beef up ipv6 RA support considerably
This reworks sd-ndisc and networkd substantially to support IPv6 RA much more
comprehensively. Since the API is extended quite a bit networkd has been ported
over too, and the patch is not as straight-forward as one could wish. The
rework includes:
- Support for DNSSL, RDNSS and RA routing options in sd-ndisc and networkd. Two
new configuration options have been added to networkd to make this
configurable.
- sd-ndisc now exposes an sd_ndisc_router object that encapsulates a full RA
message, and has direct, friendly acessor functions for the singleton RA
properties, as well as an iterative interface to iterate through known and
unsupported options. The router object may either be retrieved from the wire,
or generated from raw data. In many ways the sd-ndisc API now matches the
sd-lldp API, except that no implicit database of seen data is kept. (Note
that sd-ndisc actually had a half-written, but unused implementaiton of such
a store, which is removed now.)
- sd-ndisc will now collect the reception timestamps of RA, which is useful to
make sd_ndisc_router fully descriptive of what it covers.
Fixes: #1079
2016-06-02 20:38:12 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/***
|
2018-06-12 17:15:23 +02:00
|
|
|
Copyright © 2014 Intel Corporation. All rights reserved.
|
network: beef up ipv6 RA support considerably
This reworks sd-ndisc and networkd substantially to support IPv6 RA much more
comprehensively. Since the API is extended quite a bit networkd has been ported
over too, and the patch is not as straight-forward as one could wish. The
rework includes:
- Support for DNSSL, RDNSS and RA routing options in sd-ndisc and networkd. Two
new configuration options have been added to networkd to make this
configurable.
- sd-ndisc now exposes an sd_ndisc_router object that encapsulates a full RA
message, and has direct, friendly acessor functions for the singleton RA
properties, as well as an iterative interface to iterate through known and
unsupported options. The router object may either be retrieved from the wire,
or generated from raw data. In many ways the sd-ndisc API now matches the
sd-lldp API, except that no implicit database of seen data is kept. (Note
that sd-ndisc actually had a half-written, but unused implementaiton of such
a store, which is removed now.)
- sd-ndisc will now collect the reception timestamps of RA, which is useful to
make sd_ndisc_router fully descriptive of what it covers.
Fixes: #1079
2016-06-02 20:38:12 +02:00
|
|
|
***/
|
|
|
|
|
|
|
|
#include "sd-ndisc.h"
|
|
|
|
|
|
|
|
#include "time-util.h"
|
|
|
|
|
|
|
|
struct sd_ndisc_router {
|
|
|
|
unsigned n_ref;
|
|
|
|
|
|
|
|
triple_timestamp timestamp;
|
|
|
|
struct in6_addr address;
|
|
|
|
|
|
|
|
/* The raw packet size. The data is appended to the object, accessible via NDIS_ROUTER_RAW() */
|
|
|
|
size_t raw_size;
|
|
|
|
|
|
|
|
/* The current read index for the iterative option interface */
|
|
|
|
size_t rindex;
|
|
|
|
|
|
|
|
uint64_t flags;
|
|
|
|
unsigned preference;
|
|
|
|
uint16_t lifetime;
|
|
|
|
|
|
|
|
uint8_t hop_limit;
|
|
|
|
uint32_t mtu;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void* NDISC_ROUTER_RAW(const sd_ndisc_router *rt) {
|
|
|
|
return (uint8_t*) rt + ALIGN(sizeof(sd_ndisc_router));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *NDISC_ROUTER_OPTION_DATA(const sd_ndisc_router *rt) {
|
|
|
|
return ((uint8_t*) NDISC_ROUTER_RAW(rt)) + rt->rindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint8_t NDISC_ROUTER_OPTION_TYPE(const sd_ndisc_router *rt) {
|
|
|
|
return ((uint8_t*) NDISC_ROUTER_OPTION_DATA(rt))[0];
|
|
|
|
}
|
|
|
|
static inline size_t NDISC_ROUTER_OPTION_LENGTH(const sd_ndisc_router *rt) {
|
|
|
|
return ((uint8_t*) NDISC_ROUTER_OPTION_DATA(rt))[1] * 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
sd_ndisc_router *ndisc_router_new(size_t raw_size);
|
|
|
|
int ndisc_router_parse(sd_ndisc_router *rt);
|