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