FreeBSD/Linux Kernel Cross Reference
sys/netinet6/nd6.h
1 /* $NetBSD: nd6.h,v 1.91 2020/09/11 15:03:33 roy Exp $ */
2 /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
3
4 /*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33 #ifndef _NETINET6_ND6_H_
34 #define _NETINET6_ND6_H_
35
36 #include <sys/queue.h>
37 #include <sys/callout.h>
38
39 #ifndef _KERNEL
40 /* Backwards compat */
41 #include <net/nd.h>
42 #define ND6_LLINFO_PURGE ND_LLINFO_PURGE
43 #define ND6_LLINFO_NOSTATE ND_LLINFO_NOSTATE
44 #define ND6_LLINFO_WAITDELETE ND_LLINFO_WAITDELETE
45 #define ND6_LLINFO_INCOMPLETE ND_LLINFO_INCOMPLETE
46 #define ND6_LLINFO_REACHABLE ND_LLINFO_REACHABLE
47 #define ND6_LLINFO_STALE ND_LLINFO_STALE
48 #define ND6_LLINFO_DELAY ND_LLINFO_DELAY
49 #define ND6_LLINFO_PROBE ND_LLINFO_PROBE
50 #endif
51
52 struct nd_ifinfo {
53 uint8_t chlim; /* CurHopLimit */
54 uint32_t basereachable; /* BaseReachableTime */
55 uint32_t retrans; /* Retrans Timer */
56 uint32_t flags; /* Flags */
57 };
58 #ifdef _KERNEL
59 struct nd_kifinfo {
60 uint8_t chlim; /* CurHopLimit */
61 uint32_t basereachable; /* BaseReachableTime */
62 uint32_t retrans; /* Retrans Timer */
63 uint32_t flags; /* Flags */
64 int recalctm; /* BaseReacable re-calculation timer */
65 uint32_t reachable; /* Reachable Time */
66 };
67 #endif
68
69 #define ND6_IFF_PERFORMNUD 0x01
70 /* 0x02 was ND6_IFF_ACCEPT_RTADV */
71 #define ND6_IFF_PREFER_SOURCE 0x04 /* XXX: not related to ND. */
72 #define ND6_IFF_IFDISABLED 0x08 /* IPv6 operation is disabled due to
73 * DAD failure. (XXX: not ND-specific)
74 */
75 /* 0x10 was ND6_IFF_OVERRIDE_RTADV */
76 #define ND6_IFF_AUTO_LINKLOCAL 0x20
77
78 #ifdef _KERNEL
79 #define ND_IFINFO(ifp) \
80 (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
81 #endif
82
83 struct in6_nbrinfo {
84 char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
85 struct in6_addr addr; /* IPv6 address of the neighbor */
86 long asked; /* number of queries already sent for this addr */
87 int isrouter; /* if it acts as a router */
88 int state; /* reachability state */
89 int expire; /* lifetime for NDP state transition */
90 };
91
92 struct in6_ndireq {
93 char ifname[IFNAMSIZ];
94 struct nd_ifinfo ndi;
95 };
96
97 /* protocol constants */
98 #define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
99 #define ND6_INFINITE_LIFETIME ((u_int32_t)~0)
100
101 #ifdef _KERNEL
102 #include <sys/mallocvar.h>
103 MALLOC_DECLARE(M_IP6NDP);
104
105 /* nd6.c */
106 extern int nd6_prune;
107 extern int nd6_useloopback;
108 extern int nd6_debug;
109
110 extern struct nd_domain nd6_nd_domain;
111
112 #define nd6log(level, fmt, args...) \
113 do { if (nd6_debug) log(level, "%s: " fmt, __func__, ##args);} while (0)
114
115 extern krwlock_t nd6_lock;
116
117 #define ND6_RLOCK() rw_enter(&nd6_lock, RW_READER)
118 #define ND6_WLOCK() rw_enter(&nd6_lock, RW_WRITER)
119 #define ND6_UNLOCK() rw_exit(&nd6_lock)
120 #define ND6_ASSERT_WLOCK() KASSERT(rw_write_held(&nd6_lock))
121 #define ND6_ASSERT_LOCK() KASSERT(rw_lock_held(&nd6_lock))
122
123 union nd_opts {
124 struct nd_opt_hdr *nd_opt_array[16]; /* max = ND_OPT_NONCE */
125 struct {
126 struct nd_opt_hdr *zero;
127 struct nd_opt_hdr *src_lladdr;
128 struct nd_opt_hdr *tgt_lladdr;
129 struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
130 struct nd_opt_rd_hdr *rh;
131 struct nd_opt_mtu *mtu;
132 struct nd_opt_hdr *__res6;
133 struct nd_opt_hdr *__res7;
134 struct nd_opt_hdr *__res8;
135 struct nd_opt_hdr *__res9;
136 struct nd_opt_hdr *__res10;
137 struct nd_opt_hdr *__res11;
138 struct nd_opt_hdr *__res12;
139 struct nd_opt_hdr *__res13;
140 struct nd_opt_nonce *nonce;
141 struct nd_opt_hdr *__res15;
142 struct nd_opt_hdr *search; /* multiple opts */
143 struct nd_opt_hdr *last; /* multiple opts */
144 int done;
145 struct nd_opt_prefix_info *pi_end;/* multiple opts, end */
146 } nd_opt_each;
147 };
148 #define nd_opts_src_lladdr nd_opt_each.src_lladdr
149 #define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr
150 #define nd_opts_pi nd_opt_each.pi_beg
151 #define nd_opts_pi_end nd_opt_each.pi_end
152 #define nd_opts_rh nd_opt_each.rh
153 #define nd_opts_mtu nd_opt_each.mtu
154 #define nd_opts_nonce nd_opt_each.nonce
155 #define nd_opts_search nd_opt_each.search
156 #define nd_opts_last nd_opt_each.last
157 #define nd_opts_done nd_opt_each.done
158
159 #include <net/if_llatbl.h>
160
161 /* XXX: need nd6_var.h?? */
162 /* nd6.c */
163 void nd6_init(void);
164 void nd6_nbr_init(void);
165 struct nd_kifinfo *nd6_ifattach(struct ifnet *);
166 void nd6_ifdetach(struct ifnet *, struct in6_ifextra *);
167 int nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *);
168 void nd6_option_init(void *, int, union nd_opts *);
169 int nd6_options(union nd_opts *);
170 struct llentry *nd6_lookup(const struct in6_addr *, const struct ifnet *, bool);
171 struct llentry *nd6_create(const struct in6_addr *, const struct ifnet *);
172 void nd6_purge(struct ifnet *, struct in6_ifextra *);
173 void nd6_nud_hint(struct rtentry *);
174 int nd6_resolve(struct ifnet *, const struct rtentry *, struct mbuf *,
175 const struct sockaddr *, uint8_t *, size_t);
176 void nd6_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
177 int nd6_ioctl(u_long, void *, struct ifnet *);
178 void nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
179 char *, int, int, int);
180 int nd6_sysctl(int, void *, size_t *, void *, size_t);
181 int nd6_need_cache(struct ifnet *);
182 void nd6_llinfo_release_pkts(struct llentry *, struct ifnet *);
183
184 /* nd6_nbr.c */
185 void nd6_na_input(struct mbuf *, int, int);
186 void nd6_na_output(struct ifnet *, const struct in6_addr *,
187 const struct in6_addr *, u_long, int, const struct sockaddr *);
188 void nd6_ns_input(struct mbuf *, int, int);
189 void nd6_ns_output(struct ifnet *, const struct in6_addr *,
190 const struct in6_addr *, const struct in6_addr *, const uint8_t *);
191 const void *nd6_ifptomac(const struct ifnet *);
192 void nd6_dad_start(struct ifaddr *, int);
193 void nd6_dad_stop(struct ifaddr *);
194
195 /* nd6_rtr.c */
196 void nd6_rtr_cache(struct mbuf *, int, int, int);
197
198 #endif /* _KERNEL */
199
200 #endif /* !_NETINET6_ND6_H_ */
Cache object: 072fd7e0f50db3369a8984039a5969c1
|