]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-icmp6-nd.h
sd-icmp6-nd: Parse ICMPv6 prefix information
[thirdparty/systemd.git] / src / systemd / sd-icmp6-nd.h
CommitLineData
e3169126
PF
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#ifndef foosdicmp6ndfoo
4#define foosdicmp6ndfoo
5
6/***
7 This file is part of systemd.
8
9 Copyright (C) 2014 Intel Corporation. All rights reserved.
10
11 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 2.1 of the License, or
14 (at your option) any later version.
15
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23***/
24
25#include <net/ethernet.h>
26
27#include "sd-event.h"
28
29enum {
d77bde34
PF
30 ICMP6_EVENT_ROUTER_ADVERTISMENT_NONE = 0,
31 ICMP6_EVENT_ROUTER_ADVERTISMENT_TIMEOUT = 1,
32 ICMP6_EVENT_ROUTER_ADVERTISMENT_OTHER = 2,
33 ICMP6_EVENT_ROUTER_ADVERTISMENT_MANAGED = 3,
34 ICMP6_EVENT_ROUTER_ADVERTISMENT_PREFIX_EXPIRED = 4,
e3169126
PF
35};
36
37typedef struct sd_icmp6_nd sd_icmp6_nd;
38
39typedef void(*sd_icmp6_nd_callback_t)(sd_icmp6_nd *nd, int event,
40 void *userdata);
41
42int sd_icmp6_nd_set_callback(sd_icmp6_nd *nd, sd_icmp6_nd_callback_t cb,
43 void *userdata);
44int sd_icmp6_nd_set_index(sd_icmp6_nd *nd, int interface_index);
45int sd_icmp6_nd_set_mac(sd_icmp6_nd *nd, const struct ether_addr *mac_addr);
46
47int sd_icmp6_nd_attach_event(sd_icmp6_nd *nd, sd_event *event, int priority);
48int sd_icmp6_nd_detach_event(sd_icmp6_nd *nd);
49sd_event *sd_icmp6_nd_get_event(sd_icmp6_nd *nd);
50
51sd_icmp6_nd *sd_icmp6_nd_ref(sd_icmp6_nd *nd);
52sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd);
53int sd_icmp6_nd_new(sd_icmp6_nd **ret);
54
d77bde34
PF
55int sd_icmp6_prefix_match(struct in6_addr *prefix, uint8_t prefixlen,
56 struct in6_addr *addr);
57
d14b5bc6 58int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu);
d77bde34
PF
59int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr,
60 uint8_t *prefixlen);
d14b5bc6 61
836cf090 62int sd_icmp6_nd_stop(sd_icmp6_nd *nd);
e3169126
PF
63int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd);
64
d77bde34
PF
65#define SD_ICMP6_ADDRESS_FORMAT_STR "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
66
67#define SD_ICMP6_ADDRESS_FORMAT_VAL(address) \
68 be16toh((address).s6_addr16[0]), \
69 be16toh((address).s6_addr16[1]), \
70 be16toh((address).s6_addr16[2]), \
71 be16toh((address).s6_addr16[3]), \
72 be16toh((address).s6_addr16[4]), \
73 be16toh((address).s6_addr16[5]), \
74 be16toh((address).s6_addr16[6]), \
75 be16toh((address).s6_addr16[7])
76
e3169126 77#endif