summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/radv-internal.h
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2017-05-12 16:48:27 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2017-05-15 14:49:50 +0300
commit04473969ef07c953415d8ce7964f1e9664e96a6c (patch)
tree185362cb1e10c8813b2cc8e34c7a7a8a80f13f49 /src/libsystemd-network/radv-internal.h
parent5502d46f73ed3137c8324f1fb59c378cbd680285 (diff)
downloadsystemd-04473969ef07c953415d8ce7964f1e9664e96a6c.tar.gz
sd-radv: Add Router Advertisement prefix handling
Define Router Advertisement prefix structure. Add the Prefix Information ICMPv6 option defined in RFC 4861 to the prefix information structure, as it will simplify sending a Prefix Information option later on. In order to handle endianness correctly, the structure is redefined here instead of using the one in netinet/icmp6.h. Add functions to create and modify prefix information and set default values as defined in RFC 4861, Section 6.2.1.
Diffstat (limited to 'src/libsystemd-network/radv-internal.h')
-rw-r--r--src/libsystemd-network/radv-internal.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libsystemd-network/radv-internal.h b/src/libsystemd-network/radv-internal.h
new file mode 100644
index 0000000000..0f92c8b55c
--- /dev/null
+++ b/src/libsystemd-network/radv-internal.h
@@ -0,0 +1,48 @@
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright (C) 2017 Intel Corporation. All rights reserved.
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "sd-radv.h"
+
+#include "log.h"
+#include "list.h"
+#include "sparse-endian.h"
+
+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);
+};
+
+#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_warning_errno(error, fmt, ...) log_radv_full(LOG_WARNING, error, fmt, ##__VA_ARGS__)
+#define log_radv(fmt, ...) log_radv_errno(0, fmt, ##__VA_ARGS__)