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