]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
3ad0c5d8 TG |
2 | #ifndef foosdndiscfoo |
3 | #define foosdndiscfoo | |
e3169126 PF |
4 | |
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright (C) 2014 Intel Corporation. All rights reserved. | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU Lesser General Public License as published by | |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Lesser General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU Lesser General Public License | |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
22 | ***/ | |
23 | ||
04c01369 | 24 | #include <inttypes.h> |
e3169126 | 25 | #include <net/ethernet.h> |
1e7a0e21 LP |
26 | #include <netinet/in.h> |
27 | #include <sys/types.h> | |
e3169126 PF |
28 | |
29 | #include "sd-event.h" | |
71d35b6b | 30 | |
04c01369 LP |
31 | #include "_sd-common.h" |
32 | ||
33 | _SD_BEGIN_DECLARATIONS; | |
e3169126 | 34 | |
1e7a0e21 LP |
35 | /* Neightbor Discovery Options, RFC 4861, Section 4.6 and |
36 | * https://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml#icmpv6-parameters-5 */ | |
e3169126 | 37 | enum { |
1e7a0e21 LP |
38 | SD_NDISC_OPTION_SOURCE_LL_ADDRESS = 1, |
39 | SD_NDISC_OPTION_TARGET_LL_ADDRESS = 2, | |
40 | SD_NDISC_OPTION_PREFIX_INFORMATION = 3, | |
41 | SD_NDISC_OPTION_MTU = 5, | |
42 | SD_NDISC_OPTION_ROUTE_INFORMATION = 24, | |
43 | SD_NDISC_OPTION_RDNSS = 25, | |
44 | SD_NDISC_OPTION_FLAGS_EXTENSION = 26, | |
45 | SD_NDISC_OPTION_DNSSL = 31, | |
46 | SD_NDISC_OPTION_CAPTIVE_PORTAL = 37, | |
47 | }; | |
48 | ||
49 | /* Route preference, RFC 4191, Section 2.1 */ | |
50 | enum { | |
51 | SD_NDISC_PREFERENCE_LOW = 3U, | |
52 | SD_NDISC_PREFERENCE_MEDIUM = 0U, | |
53 | SD_NDISC_PREFERENCE_HIGH = 1U, | |
e3169126 PF |
54 | }; |
55 | ||
4d7b83da | 56 | typedef struct sd_ndisc sd_ndisc; |
1e7a0e21 | 57 | typedef struct sd_ndisc_router sd_ndisc_router; |
e3169126 | 58 | |
1e7a0e21 LP |
59 | typedef enum sd_ndisc_event { |
60 | SD_NDISC_EVENT_TIMEOUT = 't', | |
61 | SD_NDISC_EVENT_ROUTER = 'r', | |
62 | } sd_ndisc_event; | |
e3169126 | 63 | |
1e7a0e21 | 64 | typedef void (*sd_ndisc_callback_t)(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata); |
e3169126 | 65 | |
1e7a0e21 | 66 | int sd_ndisc_new(sd_ndisc **ret); |
4d7b83da TG |
67 | sd_ndisc *sd_ndisc_ref(sd_ndisc *nd); |
68 | sd_ndisc *sd_ndisc_unref(sd_ndisc *nd); | |
d14b5bc6 | 69 | |
1e7a0e21 | 70 | int sd_ndisc_start(sd_ndisc *nd); |
4d7b83da | 71 | int sd_ndisc_stop(sd_ndisc *nd); |
e3169126 | 72 | |
1e7a0e21 LP |
73 | int sd_ndisc_attach_event(sd_ndisc *nd, sd_event *event, int64_t priority); |
74 | int sd_ndisc_detach_event(sd_ndisc *nd); | |
75 | sd_event *sd_ndisc_get_event(sd_ndisc *nd); | |
76 | ||
77 | int sd_ndisc_set_callback(sd_ndisc *nd, sd_ndisc_callback_t cb, void *userdata); | |
78 | int sd_ndisc_set_ifindex(sd_ndisc *nd, int interface_index); | |
79 | int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr); | |
d77bde34 | 80 | |
1e7a0e21 LP |
81 | int sd_ndisc_get_mtu(sd_ndisc *nd, uint32_t *ret); |
82 | int sd_ndisc_get_hop_limit(sd_ndisc *nd, uint8_t *ret); | |
83 | ||
84 | int sd_ndisc_router_from_raw(sd_ndisc_router **ret, const void *raw, size_t raw_size); | |
85 | sd_ndisc_router *sd_ndisc_router_ref(sd_ndisc_router *rt); | |
86 | sd_ndisc_router *sd_ndisc_router_unref(sd_ndisc_router *rt); | |
87 | ||
88 | int sd_ndisc_router_get_address(sd_ndisc_router *rt, struct in6_addr *ret_addr); | |
89 | int sd_ndisc_router_get_timestamp(sd_ndisc_router *rt, clockid_t clock, uint64_t *ret); | |
90 | int sd_ndisc_router_get_raw(sd_ndisc_router *rt, const void **ret, size_t *size); | |
91 | ||
92 | int sd_ndisc_router_get_hop_limit(sd_ndisc_router *rt, uint8_t *ret); | |
93 | int sd_ndisc_router_get_flags(sd_ndisc_router *rt, uint64_t *ret_flags); | |
94 | int sd_ndisc_router_get_preference(sd_ndisc_router *rt, unsigned *ret); | |
95 | int sd_ndisc_router_get_lifetime(sd_ndisc_router *rt, uint16_t *ret_lifetime); | |
96 | int sd_ndisc_router_get_mtu(sd_ndisc_router *rt, uint32_t *ret); | |
97 | ||
98 | /* Generic option access */ | |
99 | int sd_ndisc_router_option_rewind(sd_ndisc_router *rt); | |
100 | int sd_ndisc_router_option_next(sd_ndisc_router *rt); | |
101 | int sd_ndisc_router_option_get_type(sd_ndisc_router *rt, uint8_t *ret); | |
102 | int sd_ndisc_router_option_is_type(sd_ndisc_router *rt, uint8_t type); | |
103 | int sd_ndisc_router_option_get_raw(sd_ndisc_router *rt, const void **ret, size_t *size); | |
104 | ||
105 | /* Specific option access: SD_NDISC_OPTION_PREFIX_INFORMATION */ | |
106 | int sd_ndisc_router_prefix_get_valid_lifetime(sd_ndisc_router *rt, uint32_t *ret); | |
107 | int sd_ndisc_router_prefix_get_preferred_lifetime(sd_ndisc_router *rt, uint32_t *ret); | |
108 | int sd_ndisc_router_prefix_get_flags(sd_ndisc_router *rt, uint8_t *ret); | |
109 | int sd_ndisc_router_prefix_get_address(sd_ndisc_router *rt, struct in6_addr *ret_addr); | |
110 | int sd_ndisc_router_prefix_get_prefixlen(sd_ndisc_router *rt, unsigned *prefixlen); | |
111 | ||
112 | /* Specific option access: SD_NDISC_OPTION_ROUTE_INFORMATION */ | |
113 | int sd_ndisc_router_route_get_lifetime(sd_ndisc_router *rt, uint32_t *ret); | |
114 | int sd_ndisc_router_route_get_address(sd_ndisc_router *rt, struct in6_addr *ret_addr); | |
115 | int sd_ndisc_router_route_get_prefixlen(sd_ndisc_router *rt, unsigned *prefixlen); | |
116 | int sd_ndisc_router_route_get_preference(sd_ndisc_router *rt, unsigned *ret); | |
117 | ||
118 | /* Specific option access: SD_NDISC_OPTION_RDNSS */ | |
119 | int sd_ndisc_router_rdnss_get_addresses(sd_ndisc_router *rt, const struct in6_addr **ret); | |
120 | int sd_ndisc_router_rdnss_get_lifetime(sd_ndisc_router *rt, uint32_t *ret); | |
121 | ||
122 | /* Specific option access: SD_NDISC_OPTION_DNSSL */ | |
123 | int sd_ndisc_router_dnssl_get_domains(sd_ndisc_router *rt, char ***ret); | |
124 | int sd_ndisc_router_dnssl_get_lifetime(sd_ndisc_router *rt, uint32_t *ret); | |
d77bde34 | 125 | |
4afd3348 | 126 | _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc, sd_ndisc_unref); |
1e7a0e21 | 127 | _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_ndisc_router, sd_ndisc_router_unref); |
4afd3348 | 128 | |
04c01369 LP |
129 | _SD_END_DECLARATIONS; |
130 | ||
e3169126 | 131 | #endif |