]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/ndisc-router.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / libsystemd-network / ndisc-router.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
1e7a0e21
LP
2#pragma once
3
4/***
5 This file is part of systemd.
6
7 Copyright (C) 2014 Intel Corporation. All rights reserved.
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
23#include "sd-ndisc.h"
24
25#include "time-util.h"
26
27struct sd_ndisc_router {
28 unsigned n_ref;
29
30 triple_timestamp timestamp;
31 struct in6_addr address;
32
33 /* The raw packet size. The data is appended to the object, accessible via NDIS_ROUTER_RAW() */
34 size_t raw_size;
35
36 /* The current read index for the iterative option interface */
37 size_t rindex;
38
39 uint64_t flags;
40 unsigned preference;
41 uint16_t lifetime;
42
43 uint8_t hop_limit;
44 uint32_t mtu;
45};
46
47static inline void* NDISC_ROUTER_RAW(const sd_ndisc_router *rt) {
48 return (uint8_t*) rt + ALIGN(sizeof(sd_ndisc_router));
49}
50
51static inline void *NDISC_ROUTER_OPTION_DATA(const sd_ndisc_router *rt) {
52 return ((uint8_t*) NDISC_ROUTER_RAW(rt)) + rt->rindex;
53}
54
55static inline uint8_t NDISC_ROUTER_OPTION_TYPE(const sd_ndisc_router *rt) {
56 return ((uint8_t*) NDISC_ROUTER_OPTION_DATA(rt))[0];
57}
58static inline size_t NDISC_ROUTER_OPTION_LENGTH(const sd_ndisc_router *rt) {
59 return ((uint8_t*) NDISC_ROUTER_OPTION_DATA(rt))[1] * 8;
60}
61
62sd_ndisc_router *ndisc_router_new(size_t raw_size);
63int ndisc_router_parse(sd_ndisc_router *rt);