chiark / gitweb /
sd-netlink: introduce api for new NL type NLA_FLAG
[elogind.git] / src / systemd / sd-icmp6-nd.h
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
29 enum {
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,
35 };
36
37 typedef struct sd_icmp6_nd sd_icmp6_nd;
38
39 typedef void(*sd_icmp6_nd_callback_t)(sd_icmp6_nd *nd, int event,
40                                       void *userdata);
41
42 int sd_icmp6_nd_set_callback(sd_icmp6_nd *nd, sd_icmp6_nd_callback_t cb,
43                              void *userdata);
44 int sd_icmp6_nd_set_index(sd_icmp6_nd *nd, int interface_index);
45 int sd_icmp6_nd_set_mac(sd_icmp6_nd *nd, const struct ether_addr *mac_addr);
46
47 int sd_icmp6_nd_attach_event(sd_icmp6_nd *nd, sd_event *event, int priority);
48 int sd_icmp6_nd_detach_event(sd_icmp6_nd *nd);
49 sd_event *sd_icmp6_nd_get_event(sd_icmp6_nd *nd);
50
51 sd_icmp6_nd *sd_icmp6_nd_ref(sd_icmp6_nd *nd);
52 sd_icmp6_nd *sd_icmp6_nd_unref(sd_icmp6_nd *nd);
53 int sd_icmp6_nd_new(sd_icmp6_nd **ret);
54
55 int sd_icmp6_prefix_match(struct in6_addr *prefix, uint8_t prefixlen,
56                         struct in6_addr *addr);
57
58 int sd_icmp6_ra_get_mtu(sd_icmp6_nd *nd, uint32_t *mtu);
59 int sd_icmp6_ra_get_prefixlen(sd_icmp6_nd *nd, const struct in6_addr *addr,
60                         uint8_t *prefixlen);
61 int sd_icmp6_ra_get_expired_prefix(sd_icmp6_nd *nd, struct in6_addr **addr,
62                                 uint8_t *prefixlen);
63
64 int sd_icmp6_nd_stop(sd_icmp6_nd *nd);
65 int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd);
66
67 #define SD_ICMP6_ADDRESS_FORMAT_STR "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
68
69 #define SD_ICMP6_ADDRESS_FORMAT_VAL(address)   \
70         be16toh((address).s6_addr16[0]),        \
71         be16toh((address).s6_addr16[1]),        \
72         be16toh((address).s6_addr16[2]),        \
73         be16toh((address).s6_addr16[3]),        \
74         be16toh((address).s6_addr16[4]),        \
75         be16toh((address).s6_addr16[5]),        \
76         be16toh((address).s6_addr16[6]),        \
77         be16toh((address).s6_addr16[7])
78
79 #endif