]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-ndisc.h
Merge pull request #1359 from jengelh/ue
[thirdparty/systemd.git] / src / systemd / sd-ndisc.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foosdndiscfoo
4 #define foosdndiscfoo
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 <inttypes.h>
26 #include <net/ethernet.h>
27
28 #include "sd-event.h"
29
30 #include "_sd-common.h"
31
32 _SD_BEGIN_DECLARATIONS;
33
34 enum {
35 SD_NDISC_EVENT_STOP = 0,
36 SD_NDISC_EVENT_TIMEOUT = 1,
37 };
38
39 typedef struct sd_ndisc sd_ndisc;
40
41 typedef void(*sd_ndisc_router_callback_t)(sd_ndisc *nd, uint8_t flags, const struct in6_addr *gateway, unsigned lifetime, int pref, void *userdata);
42 typedef void(*sd_ndisc_prefix_onlink_callback_t)(sd_ndisc *nd, const struct in6_addr *prefix, unsigned prefixlen,
43 unsigned lifetime, void *userdata);
44 typedef void(*sd_ndisc_prefix_autonomous_callback_t)(sd_ndisc *nd, const struct in6_addr *prefix, unsigned prefixlen,
45 unsigned lifetime_prefered, unsigned lifetime_valid, void *userdata);
46 typedef void(*sd_ndisc_callback_t)(sd_ndisc *nd, int event, void *userdata);
47
48 int sd_ndisc_set_callback(sd_ndisc *nd,
49 sd_ndisc_router_callback_t rcb,
50 sd_ndisc_prefix_onlink_callback_t plcb,
51 sd_ndisc_prefix_autonomous_callback_t pacb,
52 sd_ndisc_callback_t cb,
53 void *userdata);
54 int sd_ndisc_set_index(sd_ndisc *nd, int interface_index);
55 int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr);
56
57 int sd_ndisc_attach_event(sd_ndisc *nd, sd_event *event, int priority);
58 int sd_ndisc_detach_event(sd_ndisc *nd);
59 sd_event *sd_ndisc_get_event(sd_ndisc *nd);
60
61 sd_ndisc *sd_ndisc_ref(sd_ndisc *nd);
62 sd_ndisc *sd_ndisc_unref(sd_ndisc *nd);
63 int sd_ndisc_new(sd_ndisc **ret);
64
65 int sd_ndisc_get_mtu(sd_ndisc *nd, uint32_t *mtu);
66
67 int sd_ndisc_stop(sd_ndisc *nd);
68 int sd_ndisc_router_discovery_start(sd_ndisc *nd);
69
70 #define SD_NDISC_ADDRESS_FORMAT_STR "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
71
72 #define SD_NDISC_ADDRESS_FORMAT_VAL(address) \
73 be16toh((address).s6_addr16[0]), \
74 be16toh((address).s6_addr16[1]), \
75 be16toh((address).s6_addr16[2]), \
76 be16toh((address).s6_addr16[3]), \
77 be16toh((address).s6_addr16[4]), \
78 be16toh((address).s6_addr16[5]), \
79 be16toh((address).s6_addr16[6]), \
80 be16toh((address).s6_addr16[7])
81
82 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc, sd_ndisc_unref);
83
84 _SD_END_DECLARATIONS;
85
86 #endif