if_stf.c revision 1.5.2.7 1 1.5.2.7 bouyer /* $NetBSD: if_stf.c,v 1.5.2.7 2001/03/12 13:31:48 bouyer Exp $ */
2 1.5.2.6 bouyer /* $KAME: if_stf.c,v 1.51 2001/01/22 07:27:16 itojun Exp $ */
3 1.5.2.2 bouyer
4 1.5.2.2 bouyer /*
5 1.5.2.2 bouyer * Copyright (C) 2000 WIDE Project.
6 1.5.2.2 bouyer * All rights reserved.
7 1.5.2.2 bouyer *
8 1.5.2.2 bouyer * Redistribution and use in source and binary forms, with or without
9 1.5.2.2 bouyer * modification, are permitted provided that the following conditions
10 1.5.2.2 bouyer * are met:
11 1.5.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
12 1.5.2.2 bouyer * notice, this list of conditions and the following disclaimer.
13 1.5.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
14 1.5.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
15 1.5.2.2 bouyer * documentation and/or other materials provided with the distribution.
16 1.5.2.2 bouyer * 3. Neither the name of the project nor the names of its contributors
17 1.5.2.2 bouyer * may be used to endorse or promote products derived from this software
18 1.5.2.2 bouyer * without specific prior written permission.
19 1.5.2.2 bouyer *
20 1.5.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 1.5.2.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 1.5.2.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 1.5.2.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 1.5.2.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 1.5.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 1.5.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 1.5.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 1.5.2.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 1.5.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 1.5.2.2 bouyer * SUCH DAMAGE.
31 1.5.2.2 bouyer */
32 1.5.2.2 bouyer
33 1.5.2.2 bouyer /*
34 1.5.2.7 bouyer * 6to4 interface, based on RFC3056.
35 1.5.2.2 bouyer *
36 1.5.2.2 bouyer * 6to4 interface is NOT capable of link-layer (I mean, IPv4) multicasting.
37 1.5.2.2 bouyer * There is no address mapping defined from IPv6 multicast address to IPv4
38 1.5.2.2 bouyer * address. Therefore, we do not have IFF_MULTICAST on the interface.
39 1.5.2.2 bouyer *
40 1.5.2.2 bouyer * Due to the lack of address mapping for link-local addresses, we cannot
41 1.5.2.2 bouyer * throw packets toward link-local addresses (fe80::x). Also, we cannot throw
42 1.5.2.2 bouyer * packets to link-local multicast addresses (ff02::x).
43 1.5.2.2 bouyer *
44 1.5.2.2 bouyer * Here are interesting symptoms due to the lack of link-local address:
45 1.5.2.2 bouyer *
46 1.5.2.2 bouyer * Unicast routing exchange:
47 1.5.2.2 bouyer * - RIPng: Impossible. Uses link-local multicast packet toward ff02::9,
48 1.5.2.2 bouyer * and link-local addresses as nexthop.
49 1.5.2.2 bouyer * - OSPFv6: Impossible. OSPFv6 assumes that there's link-local address
50 1.5.2.2 bouyer * assigned to the link, and makes use of them. Also, HELLO packets use
51 1.5.2.2 bouyer * link-local multicast addresses (ff02::5 and ff02::6).
52 1.5.2.2 bouyer * - BGP4+: Maybe. You can only use global address as nexthop, and global
53 1.5.2.2 bouyer * address as TCP endpoint address.
54 1.5.2.2 bouyer *
55 1.5.2.2 bouyer * Multicast routing protocols:
56 1.5.2.2 bouyer * - PIM: Hello packet cannot be used to discover adjacent PIM routers.
57 1.5.2.2 bouyer * Adjacent PIM routers must be configured manually (is it really spec-wise
58 1.5.2.2 bouyer * correct thing to do?).
59 1.5.2.2 bouyer *
60 1.5.2.2 bouyer * ICMPv6:
61 1.5.2.2 bouyer * - Redirects cannot be used due to the lack of link-local address.
62 1.5.2.2 bouyer *
63 1.5.2.7 bouyer * stf interface does not have, and will not need, a link-local address.
64 1.5.2.7 bouyer * It seems to have no real benefit and does not help the above symptoms much.
65 1.5.2.7 bouyer * Even if we assign link-locals to interface, we cannot really
66 1.5.2.7 bouyer * use link-local unicast/multicast on top of 6to4 cloud (since there's no
67 1.5.2.7 bouyer * encapsulation defined for link-local address), and the above analysis does
68 1.5.2.7 bouyer * not change. RFC3056 does not mandate the assignment of link-local address
69 1.5.2.7 bouyer * either.
70 1.5.2.2 bouyer *
71 1.5.2.2 bouyer * 6to4 interface has security issues. Refer to
72 1.5.2.2 bouyer * http://playground.iijlab.net/i-d/draft-itojun-ipv6-transition-abuse-00.txt
73 1.5.2.2 bouyer * for details. The code tries to filter out some of malicious packets.
74 1.5.2.2 bouyer * Note that there is no way to be 100% secure.
75 1.5.2.2 bouyer */
76 1.5.2.2 bouyer
77 1.5.2.2 bouyer #if defined(__FreeBSD__) && __FreeBSD__ >= 3
78 1.5.2.2 bouyer #include "opt_inet.h"
79 1.5.2.2 bouyer #include "opt_inet6.h"
80 1.5.2.2 bouyer #endif
81 1.5.2.2 bouyer #ifdef __NetBSD__
82 1.5.2.2 bouyer #include "opt_inet.h"
83 1.5.2.2 bouyer #endif
84 1.5.2.2 bouyer
85 1.5.2.2 bouyer #include <sys/param.h>
86 1.5.2.2 bouyer #include <sys/systm.h>
87 1.5.2.2 bouyer #include <sys/socket.h>
88 1.5.2.2 bouyer #include <sys/sockio.h>
89 1.5.2.2 bouyer #include <sys/mbuf.h>
90 1.5.2.2 bouyer #include <sys/errno.h>
91 1.5.2.2 bouyer #if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
92 1.5.2.2 bouyer #include <sys/ioctl.h>
93 1.5.2.2 bouyer #endif
94 1.5.2.2 bouyer #include <sys/protosw.h>
95 1.5.2.2 bouyer #ifdef __FreeBSD__
96 1.5.2.2 bouyer #include <sys/kernel.h>
97 1.5.2.2 bouyer #endif
98 1.5.2.2 bouyer #include <sys/queue.h>
99 1.5.2.6 bouyer #include <sys/syslog.h>
100 1.5.2.2 bouyer #include <machine/cpu.h>
101 1.5.2.2 bouyer
102 1.5.2.2 bouyer #if defined(__FreeBSD__) && __FreeBSD__ >= 3
103 1.5.2.2 bouyer #include <sys/malloc.h>
104 1.5.2.2 bouyer #endif
105 1.5.2.2 bouyer
106 1.5.2.2 bouyer #include <net/if.h>
107 1.5.2.2 bouyer #include <net/route.h>
108 1.5.2.2 bouyer #include <net/netisr.h>
109 1.5.2.2 bouyer #include <net/if_types.h>
110 1.5.2.2 bouyer #include <net/if_stf.h>
111 1.5.2.2 bouyer
112 1.5.2.2 bouyer #include <netinet/in.h>
113 1.5.2.2 bouyer #include <netinet/in_systm.h>
114 1.5.2.2 bouyer #include <netinet/ip.h>
115 1.5.2.2 bouyer #include <netinet/ip_var.h>
116 1.5.2.2 bouyer #include <netinet/in_var.h>
117 1.5.2.2 bouyer
118 1.5.2.2 bouyer #include <netinet/ip6.h>
119 1.5.2.2 bouyer #include <netinet6/ip6_var.h>
120 1.5.2.2 bouyer #include <netinet6/in6_gif.h>
121 1.5.2.2 bouyer #include <netinet6/in6_var.h>
122 1.5.2.2 bouyer #include <netinet/ip_ecn.h>
123 1.5.2.2 bouyer
124 1.5.2.2 bouyer #include <netinet/ip_encap.h>
125 1.5.2.2 bouyer
126 1.5.2.2 bouyer #include <machine/stdarg.h>
127 1.5.2.2 bouyer
128 1.5.2.2 bouyer #include <net/net_osdep.h>
129 1.5.2.2 bouyer
130 1.5.2.2 bouyer #if defined(__FreeBSD__) && __FreeBSD__ >= 4
131 1.5.2.2 bouyer #include "bpf.h"
132 1.5.2.2 bouyer #define NBPFILTER NBPF
133 1.5.2.2 bouyer #else
134 1.5.2.2 bouyer #include "bpfilter.h"
135 1.5.2.2 bouyer #endif
136 1.5.2.2 bouyer #include "stf.h"
137 1.5.2.2 bouyer #include "gif.h" /*XXX*/
138 1.5.2.2 bouyer
139 1.5.2.2 bouyer #if NBPFILTER > 0
140 1.5.2.2 bouyer #include <net/bpf.h>
141 1.5.2.2 bouyer #endif
142 1.5.2.2 bouyer
143 1.5.2.2 bouyer #if NGIF > 0
144 1.5.2.2 bouyer #include <net/if_gif.h>
145 1.5.2.2 bouyer #endif
146 1.5.2.2 bouyer
147 1.5.2.2 bouyer #if NSTF > 0
148 1.5.2.2 bouyer
149 1.5.2.2 bouyer #define IN6_IS_ADDR_6TO4(x) (ntohs((x)->s6_addr16[0]) == 0x2002)
150 1.5.2.2 bouyer #define GET_V4(x) ((struct in_addr *)(&(x)->s6_addr16[1]))
151 1.5.2.2 bouyer
152 1.5.2.2 bouyer struct stf_softc {
153 1.5.2.2 bouyer struct ifnet sc_if; /* common area */
154 1.5.2.2 bouyer union {
155 1.5.2.2 bouyer struct route __sc_ro4;
156 1.5.2.2 bouyer struct route_in6 __sc_ro6; /* just for safety */
157 1.5.2.2 bouyer } __sc_ro46;
158 1.5.2.2 bouyer #define sc_ro __sc_ro46.__sc_ro4
159 1.5.2.2 bouyer const struct encaptab *encap_cookie;
160 1.5.2.2 bouyer LIST_ENTRY(stf_softc) sc_list;
161 1.5.2.2 bouyer };
162 1.5.2.2 bouyer
163 1.5.2.2 bouyer LIST_HEAD(, stf_softc) stf_softc_list;
164 1.5.2.2 bouyer
165 1.5.2.2 bouyer int stf_clone_create __P((struct if_clone *, int));
166 1.5.2.2 bouyer void stf_clone_destroy __P((struct ifnet *));
167 1.5.2.2 bouyer
168 1.5.2.2 bouyer struct if_clone stf_cloner =
169 1.5.2.2 bouyer IF_CLONE_INITIALIZER("stf", stf_clone_create, stf_clone_destroy);
170 1.5.2.2 bouyer
171 1.5.2.2 bouyer #if NGIF > 0
172 1.5.2.2 bouyer extern int ip_gif_ttl; /*XXX*/
173 1.5.2.2 bouyer #else
174 1.5.2.2 bouyer static int ip_gif_ttl = 40; /*XXX*/
175 1.5.2.2 bouyer #endif
176 1.5.2.2 bouyer
177 1.5.2.2 bouyer extern struct protosw in_stf_protosw;
178 1.5.2.2 bouyer
179 1.5.2.2 bouyer #ifdef __FreeBSD__
180 1.5.2.2 bouyer void stfattach __P((void *));
181 1.5.2.2 bouyer #else
182 1.5.2.2 bouyer void stfattach __P((int));
183 1.5.2.2 bouyer #endif
184 1.5.2.2 bouyer static int stf_encapcheck __P((const struct mbuf *, int, int, void *));
185 1.5.2.2 bouyer static struct in6_ifaddr *stf_getsrcifa6 __P((struct ifnet *));
186 1.5.2.2 bouyer static int stf_output __P((struct ifnet *, struct mbuf *, struct sockaddr *,
187 1.5.2.2 bouyer struct rtentry *));
188 1.5.2.6 bouyer static int stf_checkaddr4 __P((struct stf_softc *, struct in_addr *,
189 1.5.2.6 bouyer struct ifnet *));
190 1.5.2.6 bouyer static int stf_checkaddr6 __P((struct stf_softc *, struct in6_addr *,
191 1.5.2.6 bouyer struct ifnet *));
192 1.5.2.2 bouyer static void stf_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *));
193 1.5.2.2 bouyer #if defined(__FreeBSD__) && __FreeBSD__ < 3
194 1.5.2.2 bouyer static int stf_ioctl __P((struct ifnet *, int, caddr_t));
195 1.5.2.2 bouyer #else
196 1.5.2.2 bouyer static int stf_ioctl __P((struct ifnet *, u_long, caddr_t));
197 1.5.2.2 bouyer #endif
198 1.5.2.2 bouyer
199 1.5.2.2 bouyer /* ARGSUSED */
200 1.5.2.2 bouyer void
201 1.5.2.2 bouyer stfattach(count)
202 1.5.2.2 bouyer int count;
203 1.5.2.2 bouyer {
204 1.5.2.2 bouyer
205 1.5.2.2 bouyer LIST_INIT(&stf_softc_list);
206 1.5.2.2 bouyer if_clone_attach(&stf_cloner);
207 1.5.2.2 bouyer }
208 1.5.2.2 bouyer
209 1.5.2.2 bouyer int
210 1.5.2.2 bouyer stf_clone_create(ifc, unit)
211 1.5.2.2 bouyer struct if_clone *ifc;
212 1.5.2.2 bouyer int unit;
213 1.5.2.2 bouyer {
214 1.5.2.2 bouyer struct stf_softc *sc;
215 1.5.2.2 bouyer
216 1.5.2.2 bouyer if (LIST_FIRST(&stf_softc_list) != NULL) {
217 1.5.2.2 bouyer /* Only one stf interface is allowed. */
218 1.5.2.2 bouyer return (EEXIST);
219 1.5.2.2 bouyer }
220 1.5.2.2 bouyer
221 1.5.2.2 bouyer sc = malloc(sizeof(struct stf_softc), M_DEVBUF, M_WAIT);
222 1.5.2.2 bouyer bzero(sc, sizeof(struct stf_softc));
223 1.5.2.2 bouyer
224 1.5.2.2 bouyer sprintf(sc->sc_if.if_xname, "%s%d", ifc->ifc_name, unit);
225 1.5.2.2 bouyer
226 1.5.2.2 bouyer sc->encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV6,
227 1.5.2.2 bouyer stf_encapcheck, &in_stf_protosw, sc);
228 1.5.2.2 bouyer if (sc->encap_cookie == NULL) {
229 1.5.2.2 bouyer printf("%s: unable to attach encap\n", if_name(&sc->sc_if));
230 1.5.2.2 bouyer free(sc, M_DEVBUF);
231 1.5.2.2 bouyer return (EIO); /* XXX */
232 1.5.2.2 bouyer }
233 1.5.2.2 bouyer
234 1.5.2.2 bouyer sc->sc_if.if_mtu = IPV6_MMTU;
235 1.5.2.2 bouyer sc->sc_if.if_flags = 0;
236 1.5.2.2 bouyer sc->sc_if.if_ioctl = stf_ioctl;
237 1.5.2.2 bouyer sc->sc_if.if_output = stf_output;
238 1.5.2.2 bouyer sc->sc_if.if_type = IFT_STF;
239 1.5.2.4 bouyer sc->sc_if.if_dlt = DLT_NULL;
240 1.5.2.2 bouyer #if defined(__FreeBSD__) && __FreeBSD__ >= 4
241 1.5.2.2 bouyer sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
242 1.5.2.2 bouyer #endif
243 1.5.2.2 bouyer if_attach(&sc->sc_if);
244 1.5.2.5 bouyer if_alloc_sadl(&sc->sc_if);
245 1.5.2.2 bouyer #if NBPFILTER > 0
246 1.5.2.2 bouyer bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int));
247 1.5.2.2 bouyer #endif
248 1.5.2.2 bouyer LIST_INSERT_HEAD(&stf_softc_list, sc, sc_list);
249 1.5.2.2 bouyer return (0);
250 1.5.2.2 bouyer }
251 1.5.2.2 bouyer
252 1.5.2.2 bouyer void
253 1.5.2.2 bouyer stf_clone_destroy(ifp)
254 1.5.2.2 bouyer struct ifnet *ifp;
255 1.5.2.2 bouyer {
256 1.5.2.2 bouyer struct stf_softc *sc = (void *) ifp;
257 1.5.2.2 bouyer
258 1.5.2.2 bouyer LIST_REMOVE(sc, sc_list);
259 1.5.2.2 bouyer encap_detach(sc->encap_cookie);
260 1.5.2.2 bouyer #if NBPFILTER > 0
261 1.5.2.2 bouyer bpfdetach(ifp);
262 1.5.2.2 bouyer #endif
263 1.5.2.2 bouyer if_detach(ifp);
264 1.5.2.2 bouyer free(sc, M_DEVBUF);
265 1.5.2.2 bouyer }
266 1.5.2.2 bouyer
267 1.5.2.2 bouyer #ifdef __FreeBSD__
268 1.5.2.2 bouyer PSEUDO_SET(stfattach, if_stf);
269 1.5.2.2 bouyer #endif
270 1.5.2.2 bouyer
271 1.5.2.2 bouyer static int
272 1.5.2.2 bouyer stf_encapcheck(m, off, proto, arg)
273 1.5.2.2 bouyer const struct mbuf *m;
274 1.5.2.2 bouyer int off;
275 1.5.2.2 bouyer int proto;
276 1.5.2.2 bouyer void *arg;
277 1.5.2.2 bouyer {
278 1.5.2.2 bouyer struct ip ip;
279 1.5.2.2 bouyer struct in6_ifaddr *ia6;
280 1.5.2.2 bouyer struct stf_softc *sc;
281 1.5.2.2 bouyer struct in_addr a, b;
282 1.5.2.2 bouyer
283 1.5.2.2 bouyer sc = (struct stf_softc *)arg;
284 1.5.2.2 bouyer if (sc == NULL)
285 1.5.2.2 bouyer return 0;
286 1.5.2.2 bouyer
287 1.5.2.2 bouyer if ((sc->sc_if.if_flags & IFF_UP) == 0)
288 1.5.2.2 bouyer return 0;
289 1.5.2.2 bouyer
290 1.5.2.2 bouyer if (proto != IPPROTO_IPV6)
291 1.5.2.2 bouyer return 0;
292 1.5.2.2 bouyer
293 1.5.2.2 bouyer /* LINTED const cast */
294 1.5.2.2 bouyer m_copydata((struct mbuf *)m, 0, sizeof(ip), (caddr_t)&ip);
295 1.5.2.2 bouyer
296 1.5.2.2 bouyer if (ip.ip_v != 4)
297 1.5.2.2 bouyer return 0;
298 1.5.2.2 bouyer
299 1.5.2.2 bouyer ia6 = stf_getsrcifa6(&sc->sc_if);
300 1.5.2.2 bouyer if (ia6 == NULL)
301 1.5.2.2 bouyer return 0;
302 1.5.2.2 bouyer
303 1.5.2.2 bouyer /*
304 1.5.2.2 bouyer * check if IPv4 dst matches the IPv4 address derived from the
305 1.5.2.2 bouyer * local 6to4 address.
306 1.5.2.2 bouyer * success on: dst = 10.1.1.1, ia6->ia_addr = 2002:0a01:0101:...
307 1.5.2.2 bouyer */
308 1.5.2.2 bouyer if (bcmp(GET_V4(&ia6->ia_addr.sin6_addr), &ip.ip_dst,
309 1.5.2.2 bouyer sizeof(ip.ip_dst)) != 0)
310 1.5.2.2 bouyer return 0;
311 1.5.2.2 bouyer
312 1.5.2.2 bouyer /*
313 1.5.2.2 bouyer * check if IPv4 src matches the IPv4 address derived from the
314 1.5.2.2 bouyer * local 6to4 address masked by prefixmask.
315 1.5.2.2 bouyer * success on: src = 10.1.1.1, ia6->ia_addr = 2002:0a00:.../24
316 1.5.2.2 bouyer * fail on: src = 10.1.1.1, ia6->ia_addr = 2002:0b00:.../24
317 1.5.2.2 bouyer */
318 1.5.2.2 bouyer bzero(&a, sizeof(a));
319 1.5.2.2 bouyer a.s_addr = GET_V4(&ia6->ia_addr.sin6_addr)->s_addr;
320 1.5.2.2 bouyer a.s_addr &= GET_V4(&ia6->ia_prefixmask.sin6_addr)->s_addr;
321 1.5.2.2 bouyer b = ip.ip_src;
322 1.5.2.2 bouyer b.s_addr &= GET_V4(&ia6->ia_prefixmask.sin6_addr)->s_addr;
323 1.5.2.2 bouyer if (a.s_addr != b.s_addr)
324 1.5.2.2 bouyer return 0;
325 1.5.2.2 bouyer
326 1.5.2.2 bouyer /* stf interface makes single side match only */
327 1.5.2.2 bouyer return 32;
328 1.5.2.2 bouyer }
329 1.5.2.2 bouyer
330 1.5.2.2 bouyer static struct in6_ifaddr *
331 1.5.2.2 bouyer stf_getsrcifa6(ifp)
332 1.5.2.2 bouyer struct ifnet *ifp;
333 1.5.2.2 bouyer {
334 1.5.2.2 bouyer struct ifaddr *ia;
335 1.5.2.2 bouyer struct in_ifaddr *ia4;
336 1.5.2.2 bouyer struct sockaddr_in6 *sin6;
337 1.5.2.2 bouyer struct in_addr in;
338 1.5.2.2 bouyer
339 1.5.2.2 bouyer #if defined(__bsdi__) || (defined(__FreeBSD__) && __FreeBSD__ < 3)
340 1.5.2.2 bouyer for (ia = ifp->if_addrlist; ia; ia = ia->ifa_next)
341 1.5.2.2 bouyer #else
342 1.5.2.2 bouyer for (ia = ifp->if_addrlist.tqh_first;
343 1.5.2.2 bouyer ia;
344 1.5.2.2 bouyer ia = ia->ifa_list.tqe_next)
345 1.5.2.2 bouyer #endif
346 1.5.2.2 bouyer {
347 1.5.2.2 bouyer if (ia->ifa_addr == NULL)
348 1.5.2.2 bouyer continue;
349 1.5.2.2 bouyer if (ia->ifa_addr->sa_family != AF_INET6)
350 1.5.2.2 bouyer continue;
351 1.5.2.2 bouyer sin6 = (struct sockaddr_in6 *)ia->ifa_addr;
352 1.5.2.2 bouyer if (!IN6_IS_ADDR_6TO4(&sin6->sin6_addr))
353 1.5.2.2 bouyer continue;
354 1.5.2.2 bouyer
355 1.5.2.2 bouyer bcopy(GET_V4(&sin6->sin6_addr), &in, sizeof(in));
356 1.5.2.2 bouyer #ifdef __NetBSD__
357 1.5.2.2 bouyer INADDR_TO_IA(in, ia4);
358 1.5.2.2 bouyer #else
359 1.5.2.2 bouyer #ifdef __OpenBSD__
360 1.5.2.2 bouyer for (ia4 = in_ifaddr.tqh_first;
361 1.5.2.2 bouyer ia4;
362 1.5.2.2 bouyer ia4 = ia4->ia_list.tqe_next)
363 1.5.2.2 bouyer #elif defined(__FreeBSD__) && __FreeBSD__ >= 3
364 1.5.2.2 bouyer for (ia4 = TAILQ_FIRST(&in_ifaddrhead);
365 1.5.2.2 bouyer ia4;
366 1.5.2.2 bouyer ia4 = TAILQ_NEXT(ia4, ia_link))
367 1.5.2.2 bouyer #else
368 1.5.2.2 bouyer for (ia4 = in_ifaddr; ia4 != NULL; ia4 = ia4->ia_next)
369 1.5.2.2 bouyer #endif
370 1.5.2.2 bouyer {
371 1.5.2.2 bouyer if (ia4->ia_addr.sin_addr.s_addr == in.s_addr)
372 1.5.2.2 bouyer break;
373 1.5.2.2 bouyer }
374 1.5.2.2 bouyer #endif
375 1.5.2.2 bouyer if (ia4 == NULL)
376 1.5.2.2 bouyer continue;
377 1.5.2.2 bouyer
378 1.5.2.2 bouyer return (struct in6_ifaddr *)ia;
379 1.5.2.2 bouyer }
380 1.5.2.2 bouyer
381 1.5.2.2 bouyer return NULL;
382 1.5.2.2 bouyer }
383 1.5.2.2 bouyer
384 1.5.2.2 bouyer static int
385 1.5.2.2 bouyer stf_output(ifp, m, dst, rt)
386 1.5.2.2 bouyer struct ifnet *ifp;
387 1.5.2.2 bouyer struct mbuf *m;
388 1.5.2.2 bouyer struct sockaddr *dst;
389 1.5.2.2 bouyer struct rtentry *rt;
390 1.5.2.2 bouyer {
391 1.5.2.2 bouyer struct stf_softc *sc;
392 1.5.2.2 bouyer struct sockaddr_in6 *dst6;
393 1.5.2.2 bouyer struct sockaddr_in *dst4;
394 1.5.2.2 bouyer u_int8_t tos;
395 1.5.2.2 bouyer struct ip *ip;
396 1.5.2.2 bouyer struct ip6_hdr *ip6;
397 1.5.2.2 bouyer struct in6_ifaddr *ia6;
398 1.5.2.2 bouyer
399 1.5.2.2 bouyer sc = (struct stf_softc*)ifp;
400 1.5.2.2 bouyer dst6 = (struct sockaddr_in6 *)dst;
401 1.5.2.2 bouyer
402 1.5.2.2 bouyer /* just in case */
403 1.5.2.2 bouyer if ((ifp->if_flags & IFF_UP) == 0) {
404 1.5.2.2 bouyer m_freem(m);
405 1.5.2.2 bouyer return ENETDOWN;
406 1.5.2.2 bouyer }
407 1.5.2.2 bouyer
408 1.5.2.2 bouyer /*
409 1.5.2.2 bouyer * If we don't have an ip4 address that match my inner ip6 address,
410 1.5.2.2 bouyer * we shouldn't generate output. Without this check, we'll end up
411 1.5.2.2 bouyer * using wrong IPv4 source.
412 1.5.2.2 bouyer */
413 1.5.2.2 bouyer ia6 = stf_getsrcifa6(ifp);
414 1.5.2.2 bouyer if (ia6 == NULL) {
415 1.5.2.2 bouyer m_freem(m);
416 1.5.2.2 bouyer return ENETDOWN;
417 1.5.2.2 bouyer }
418 1.5.2.2 bouyer
419 1.5.2.2 bouyer if (m->m_len < sizeof(*ip6)) {
420 1.5.2.2 bouyer m = m_pullup(m, sizeof(*ip6));
421 1.5.2.2 bouyer if (!m)
422 1.5.2.2 bouyer return ENOBUFS;
423 1.5.2.2 bouyer }
424 1.5.2.2 bouyer ip6 = mtod(m, struct ip6_hdr *);
425 1.5.2.2 bouyer tos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
426 1.5.2.2 bouyer
427 1.5.2.2 bouyer M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
428 1.5.2.2 bouyer if (m && m->m_len < sizeof(struct ip))
429 1.5.2.2 bouyer m = m_pullup(m, sizeof(struct ip));
430 1.5.2.2 bouyer if (m == NULL)
431 1.5.2.2 bouyer return ENOBUFS;
432 1.5.2.2 bouyer ip = mtod(m, struct ip *);
433 1.5.2.2 bouyer
434 1.5.2.2 bouyer bzero(ip, sizeof(*ip));
435 1.5.2.2 bouyer
436 1.5.2.2 bouyer bcopy(GET_V4(&((struct sockaddr_in6 *)&ia6->ia_addr)->sin6_addr),
437 1.5.2.2 bouyer &ip->ip_src, sizeof(ip->ip_src));
438 1.5.2.2 bouyer bcopy(GET_V4(&dst6->sin6_addr), &ip->ip_dst, sizeof(ip->ip_dst));
439 1.5.2.2 bouyer ip->ip_p = IPPROTO_IPV6;
440 1.5.2.2 bouyer ip->ip_ttl = ip_gif_ttl; /*XXX*/
441 1.5.2.2 bouyer ip->ip_len = m->m_pkthdr.len; /*host order*/
442 1.5.2.2 bouyer if (ifp->if_flags & IFF_LINK1)
443 1.5.2.2 bouyer ip_ecn_ingress(ECN_ALLOWED, &ip->ip_tos, &tos);
444 1.5.2.2 bouyer
445 1.5.2.2 bouyer dst4 = (struct sockaddr_in *)&sc->sc_ro.ro_dst;
446 1.5.2.2 bouyer if (dst4->sin_family != AF_INET ||
447 1.5.2.2 bouyer bcmp(&dst4->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)) != 0) {
448 1.5.2.2 bouyer /* cache route doesn't match */
449 1.5.2.2 bouyer dst4->sin_family = AF_INET;
450 1.5.2.2 bouyer dst4->sin_len = sizeof(struct sockaddr_in);
451 1.5.2.2 bouyer bcopy(&ip->ip_dst, &dst4->sin_addr, sizeof(dst4->sin_addr));
452 1.5.2.2 bouyer if (sc->sc_ro.ro_rt) {
453 1.5.2.2 bouyer RTFREE(sc->sc_ro.ro_rt);
454 1.5.2.2 bouyer sc->sc_ro.ro_rt = NULL;
455 1.5.2.2 bouyer }
456 1.5.2.2 bouyer }
457 1.5.2.2 bouyer
458 1.5.2.2 bouyer if (sc->sc_ro.ro_rt == NULL) {
459 1.5.2.2 bouyer rtalloc(&sc->sc_ro);
460 1.5.2.2 bouyer if (sc->sc_ro.ro_rt == NULL) {
461 1.5.2.2 bouyer m_freem(m);
462 1.5.2.2 bouyer return ENETUNREACH;
463 1.5.2.2 bouyer }
464 1.5.2.2 bouyer }
465 1.5.2.2 bouyer
466 1.5.2.2 bouyer #ifndef __OpenBSD__
467 1.5.2.2 bouyer return ip_output(m, NULL, &sc->sc_ro, 0, NULL);
468 1.5.2.2 bouyer #else
469 1.5.2.2 bouyer return ip_output(m, NULL, &sc->sc_ro, 0, NULL, NULL);
470 1.5.2.2 bouyer #endif
471 1.5.2.2 bouyer }
472 1.5.2.2 bouyer
473 1.5.2.2 bouyer static int
474 1.5.2.6 bouyer stf_checkaddr4(sc, in, inifp)
475 1.5.2.6 bouyer struct stf_softc *sc;
476 1.5.2.2 bouyer struct in_addr *in;
477 1.5.2.6 bouyer struct ifnet *inifp; /* incoming interface */
478 1.5.2.2 bouyer {
479 1.5.2.2 bouyer struct in_ifaddr *ia4;
480 1.5.2.2 bouyer
481 1.5.2.2 bouyer /*
482 1.5.2.2 bouyer * reject packets with the following address:
483 1.5.2.2 bouyer * 224.0.0.0/4 0.0.0.0/8 127.0.0.0/8 255.0.0.0/8
484 1.5.2.2 bouyer */
485 1.5.2.2 bouyer if (IN_MULTICAST(in->s_addr))
486 1.5.2.2 bouyer return -1;
487 1.5.2.2 bouyer switch ((ntohl(in->s_addr) & 0xff000000) >> 24) {
488 1.5.2.2 bouyer case 0: case 127: case 255:
489 1.5.2.2 bouyer return -1;
490 1.5.2.2 bouyer }
491 1.5.2.2 bouyer
492 1.5.2.2 bouyer /*
493 1.5.2.2 bouyer * reject packets with broadcast
494 1.5.2.2 bouyer */
495 1.5.2.2 bouyer #if defined(__OpenBSD__) || defined(__NetBSD__)
496 1.5.2.2 bouyer for (ia4 = in_ifaddr.tqh_first; ia4; ia4 = ia4->ia_list.tqe_next)
497 1.5.2.2 bouyer #elif defined(__FreeBSD__) && __FreeBSD__ >= 3
498 1.5.2.2 bouyer for (ia4 = TAILQ_FIRST(&in_ifaddrhead);
499 1.5.2.2 bouyer ia4;
500 1.5.2.2 bouyer ia4 = TAILQ_NEXT(ia4, ia_link))
501 1.5.2.2 bouyer #else
502 1.5.2.2 bouyer for (ia4 = in_ifaddr; ia4 != NULL; ia4 = ia4->ia_next)
503 1.5.2.2 bouyer #endif
504 1.5.2.2 bouyer {
505 1.5.2.2 bouyer if ((ia4->ia_ifa.ifa_ifp->if_flags & IFF_BROADCAST) == 0)
506 1.5.2.2 bouyer continue;
507 1.5.2.2 bouyer if (in->s_addr == ia4->ia_broadaddr.sin_addr.s_addr)
508 1.5.2.2 bouyer return -1;
509 1.5.2.2 bouyer }
510 1.5.2.2 bouyer
511 1.5.2.2 bouyer /*
512 1.5.2.2 bouyer * perform ingress filter
513 1.5.2.2 bouyer */
514 1.5.2.6 bouyer if (sc && (sc->sc_if.if_flags & IFF_LINK2) == 0 && inifp) {
515 1.5.2.2 bouyer struct sockaddr_in sin;
516 1.5.2.2 bouyer struct rtentry *rt;
517 1.5.2.2 bouyer
518 1.5.2.2 bouyer bzero(&sin, sizeof(sin));
519 1.5.2.2 bouyer sin.sin_family = AF_INET;
520 1.5.2.2 bouyer sin.sin_len = sizeof(struct sockaddr_in);
521 1.5.2.2 bouyer sin.sin_addr = *in;
522 1.5.2.2 bouyer #ifdef __FreeBSD__
523 1.5.2.2 bouyer rt = rtalloc1((struct sockaddr *)&sin, 0, 0UL);
524 1.5.2.2 bouyer #else
525 1.5.2.2 bouyer rt = rtalloc1((struct sockaddr *)&sin, 0);
526 1.5.2.2 bouyer #endif
527 1.5.2.6 bouyer if (!rt || rt->rt_ifp != inifp) {
528 1.5.2.6 bouyer #if 0
529 1.5.2.6 bouyer log(LOG_WARNING, "%s: packet from 0x%x dropped "
530 1.5.2.6 bouyer "due to ingress filter\n", if_name(&sc->sc_if),
531 1.5.2.6 bouyer (u_int32_t)ntohl(sin.sin_addr.s_addr));
532 1.5.2.6 bouyer #endif
533 1.5.2.6 bouyer if (rt)
534 1.5.2.6 bouyer rtfree(rt);
535 1.5.2.2 bouyer return -1;
536 1.5.2.2 bouyer }
537 1.5.2.2 bouyer rtfree(rt);
538 1.5.2.2 bouyer }
539 1.5.2.2 bouyer
540 1.5.2.2 bouyer return 0;
541 1.5.2.2 bouyer }
542 1.5.2.2 bouyer
543 1.5.2.2 bouyer static int
544 1.5.2.6 bouyer stf_checkaddr6(sc, in6, inifp)
545 1.5.2.6 bouyer struct stf_softc *sc;
546 1.5.2.2 bouyer struct in6_addr *in6;
547 1.5.2.6 bouyer struct ifnet *inifp; /* incoming interface */
548 1.5.2.2 bouyer {
549 1.5.2.2 bouyer /*
550 1.5.2.2 bouyer * check 6to4 addresses
551 1.5.2.2 bouyer */
552 1.5.2.2 bouyer if (IN6_IS_ADDR_6TO4(in6))
553 1.5.2.6 bouyer return stf_checkaddr4(sc, GET_V4(in6), inifp);
554 1.5.2.2 bouyer
555 1.5.2.2 bouyer /*
556 1.5.2.2 bouyer * reject anything that look suspicious. the test is implemented
557 1.5.2.2 bouyer * in ip6_input too, but we check here as well to
558 1.5.2.2 bouyer * (1) reject bad packets earlier, and
559 1.5.2.2 bouyer * (2) to be safe against future ip6_input change.
560 1.5.2.2 bouyer */
561 1.5.2.2 bouyer if (IN6_IS_ADDR_V4COMPAT(in6) || IN6_IS_ADDR_V4MAPPED(in6))
562 1.5.2.2 bouyer return -1;
563 1.5.2.2 bouyer
564 1.5.2.2 bouyer return 0;
565 1.5.2.2 bouyer }
566 1.5.2.2 bouyer
567 1.5.2.2 bouyer void
568 1.5.2.2 bouyer #if __STDC__
569 1.5.2.2 bouyer in_stf_input(struct mbuf *m, ...)
570 1.5.2.2 bouyer #else
571 1.5.2.2 bouyer in_stf_input(m, va_alist)
572 1.5.2.6 bouyer struct mbuf *m;
573 1.5.2.2 bouyer #endif
574 1.5.2.2 bouyer {
575 1.5.2.2 bouyer int off, proto;
576 1.5.2.2 bouyer struct stf_softc *sc;
577 1.5.2.2 bouyer struct ip *ip;
578 1.5.2.2 bouyer struct ip6_hdr *ip6;
579 1.5.2.2 bouyer u_int8_t otos, itos;
580 1.5.2.2 bouyer int s, isr;
581 1.5.2.2 bouyer struct ifqueue *ifq = NULL;
582 1.5.2.2 bouyer struct ifnet *ifp;
583 1.5.2.2 bouyer va_list ap;
584 1.5.2.2 bouyer
585 1.5.2.2 bouyer va_start(ap, m);
586 1.5.2.2 bouyer off = va_arg(ap, int);
587 1.5.2.2 bouyer proto = va_arg(ap, int);
588 1.5.2.2 bouyer va_end(ap);
589 1.5.2.2 bouyer
590 1.5.2.2 bouyer if (proto != IPPROTO_IPV6) {
591 1.5.2.2 bouyer m_freem(m);
592 1.5.2.2 bouyer return;
593 1.5.2.2 bouyer }
594 1.5.2.2 bouyer
595 1.5.2.2 bouyer ip = mtod(m, struct ip *);
596 1.5.2.2 bouyer
597 1.5.2.2 bouyer sc = (struct stf_softc *)encap_getarg(m);
598 1.5.2.2 bouyer
599 1.5.2.2 bouyer if (sc == NULL || (sc->sc_if.if_flags & IFF_UP) == 0) {
600 1.5.2.2 bouyer m_freem(m);
601 1.5.2.2 bouyer return;
602 1.5.2.2 bouyer }
603 1.5.2.2 bouyer
604 1.5.2.2 bouyer ifp = &sc->sc_if;
605 1.5.2.2 bouyer
606 1.5.2.2 bouyer /*
607 1.5.2.2 bouyer * perform sanity check against outer src/dst.
608 1.5.2.2 bouyer * for source, perform ingress filter as well.
609 1.5.2.2 bouyer */
610 1.5.2.6 bouyer if (stf_checkaddr4(sc, &ip->ip_dst, NULL) < 0 ||
611 1.5.2.6 bouyer stf_checkaddr4(sc, &ip->ip_src, m->m_pkthdr.rcvif) < 0) {
612 1.5.2.2 bouyer m_freem(m);
613 1.5.2.2 bouyer return;
614 1.5.2.2 bouyer }
615 1.5.2.2 bouyer
616 1.5.2.2 bouyer otos = ip->ip_tos;
617 1.5.2.2 bouyer m_adj(m, off);
618 1.5.2.2 bouyer
619 1.5.2.2 bouyer if (m->m_len < sizeof(*ip6)) {
620 1.5.2.2 bouyer m = m_pullup(m, sizeof(*ip6));
621 1.5.2.2 bouyer if (!m)
622 1.5.2.2 bouyer return;
623 1.5.2.2 bouyer }
624 1.5.2.2 bouyer ip6 = mtod(m, struct ip6_hdr *);
625 1.5.2.2 bouyer
626 1.5.2.2 bouyer /*
627 1.5.2.2 bouyer * perform sanity check against inner src/dst.
628 1.5.2.2 bouyer * for source, perform ingress filter as well.
629 1.5.2.2 bouyer */
630 1.5.2.6 bouyer if (stf_checkaddr6(sc, &ip6->ip6_dst, NULL) < 0 ||
631 1.5.2.6 bouyer stf_checkaddr6(sc, &ip6->ip6_src, m->m_pkthdr.rcvif) < 0) {
632 1.5.2.2 bouyer m_freem(m);
633 1.5.2.2 bouyer return;
634 1.5.2.2 bouyer }
635 1.5.2.2 bouyer
636 1.5.2.2 bouyer itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
637 1.5.2.2 bouyer if ((ifp->if_flags & IFF_LINK1) != 0)
638 1.5.2.2 bouyer ip_ecn_egress(ECN_ALLOWED, &otos, &itos);
639 1.5.2.2 bouyer ip6->ip6_flow &= ~htonl(0xff << 20);
640 1.5.2.2 bouyer ip6->ip6_flow |= htonl((u_int32_t)itos << 20);
641 1.5.2.2 bouyer
642 1.5.2.2 bouyer m->m_pkthdr.rcvif = ifp;
643 1.5.2.2 bouyer
644 1.5.2.2 bouyer #if NBPFILTER > 0
645 1.5.2.2 bouyer if (ifp->if_bpf) {
646 1.5.2.2 bouyer /*
647 1.5.2.2 bouyer * We need to prepend the address family as
648 1.5.2.2 bouyer * a four byte field. Cons up a dummy header
649 1.5.2.2 bouyer * to pacify bpf. This is safe because bpf
650 1.5.2.2 bouyer * will only read from the mbuf (i.e., it won't
651 1.5.2.2 bouyer * try to free it or keep a pointer a to it).
652 1.5.2.2 bouyer */
653 1.5.2.2 bouyer struct mbuf m0;
654 1.5.2.7 bouyer u_int32_t af = AF_INET6;
655 1.5.2.2 bouyer
656 1.5.2.2 bouyer m0.m_next = m;
657 1.5.2.2 bouyer m0.m_len = 4;
658 1.5.2.2 bouyer m0.m_data = (char *)⁡
659 1.5.2.2 bouyer
660 1.5.2.2 bouyer #ifdef HAVE_OLD_BPF
661 1.5.2.2 bouyer bpf_mtap(ifp, &m0);
662 1.5.2.2 bouyer #else
663 1.5.2.2 bouyer bpf_mtap(ifp->if_bpf, &m0);
664 1.5.2.2 bouyer #endif
665 1.5.2.2 bouyer }
666 1.5.2.2 bouyer #endif /*NBPFILTER > 0*/
667 1.5.2.2 bouyer
668 1.5.2.2 bouyer /*
669 1.5.2.2 bouyer * Put the packet to the network layer input queue according to the
670 1.5.2.2 bouyer * specified address family.
671 1.5.2.2 bouyer * See net/if_gif.c for possible issues with packet processing
672 1.5.2.2 bouyer * reorder due to extra queueing.
673 1.5.2.2 bouyer */
674 1.5.2.2 bouyer ifq = &ip6intrq;
675 1.5.2.2 bouyer isr = NETISR_IPV6;
676 1.5.2.2 bouyer
677 1.5.2.2 bouyer s = splimp();
678 1.5.2.2 bouyer if (IF_QFULL(ifq)) {
679 1.5.2.2 bouyer IF_DROP(ifq); /* update statistics */
680 1.5.2.2 bouyer m_freem(m);
681 1.5.2.2 bouyer splx(s);
682 1.5.2.2 bouyer return;
683 1.5.2.2 bouyer }
684 1.5.2.2 bouyer IF_ENQUEUE(ifq, m);
685 1.5.2.2 bouyer schednetisr(isr);
686 1.5.2.2 bouyer ifp->if_ipackets++;
687 1.5.2.2 bouyer ifp->if_ibytes += m->m_pkthdr.len;
688 1.5.2.2 bouyer splx(s);
689 1.5.2.2 bouyer }
690 1.5.2.2 bouyer
691 1.5.2.2 bouyer /* ARGSUSED */
692 1.5.2.2 bouyer static void
693 1.5.2.5 bouyer stf_rtrequest(cmd, rt, info)
694 1.5.2.2 bouyer int cmd;
695 1.5.2.2 bouyer struct rtentry *rt;
696 1.5.2.5 bouyer struct rt_addrinfo *info;
697 1.5.2.2 bouyer {
698 1.5.2.2 bouyer
699 1.5.2.2 bouyer if (rt)
700 1.5.2.2 bouyer rt->rt_rmx.rmx_mtu = IPV6_MMTU;
701 1.5.2.2 bouyer }
702 1.5.2.2 bouyer
703 1.5.2.2 bouyer static int
704 1.5.2.2 bouyer stf_ioctl(ifp, cmd, data)
705 1.5.2.2 bouyer struct ifnet *ifp;
706 1.5.2.2 bouyer #if defined(__FreeBSD__) && __FreeBSD__ < 3
707 1.5.2.2 bouyer int cmd;
708 1.5.2.2 bouyer #else
709 1.5.2.2 bouyer u_long cmd;
710 1.5.2.2 bouyer #endif
711 1.5.2.2 bouyer caddr_t data;
712 1.5.2.2 bouyer {
713 1.5.2.2 bouyer struct ifaddr *ifa;
714 1.5.2.2 bouyer struct ifreq *ifr;
715 1.5.2.2 bouyer struct sockaddr_in6 *sin6;
716 1.5.2.2 bouyer int error;
717 1.5.2.2 bouyer
718 1.5.2.2 bouyer error = 0;
719 1.5.2.2 bouyer switch (cmd) {
720 1.5.2.2 bouyer case SIOCSIFADDR:
721 1.5.2.2 bouyer ifa = (struct ifaddr *)data;
722 1.5.2.2 bouyer if (ifa == NULL || ifa->ifa_addr->sa_family != AF_INET6) {
723 1.5.2.2 bouyer error = EAFNOSUPPORT;
724 1.5.2.2 bouyer break;
725 1.5.2.2 bouyer }
726 1.5.2.2 bouyer sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
727 1.5.2.2 bouyer if (IN6_IS_ADDR_6TO4(&sin6->sin6_addr)) {
728 1.5.2.2 bouyer ifa->ifa_rtrequest = stf_rtrequest;
729 1.5.2.2 bouyer ifp->if_flags |= IFF_UP;
730 1.5.2.2 bouyer } else
731 1.5.2.2 bouyer error = EINVAL;
732 1.5.2.2 bouyer break;
733 1.5.2.2 bouyer
734 1.5.2.2 bouyer case SIOCADDMULTI:
735 1.5.2.2 bouyer case SIOCDELMULTI:
736 1.5.2.2 bouyer ifr = (struct ifreq *)data;
737 1.5.2.2 bouyer if (ifr && ifr->ifr_addr.sa_family == AF_INET6)
738 1.5.2.2 bouyer ;
739 1.5.2.2 bouyer else
740 1.5.2.2 bouyer error = EAFNOSUPPORT;
741 1.5.2.2 bouyer break;
742 1.5.2.2 bouyer
743 1.5.2.2 bouyer default:
744 1.5.2.2 bouyer error = EINVAL;
745 1.5.2.2 bouyer break;
746 1.5.2.2 bouyer }
747 1.5.2.2 bouyer
748 1.5.2.2 bouyer return error;
749 1.5.2.2 bouyer }
750 1.5.2.2 bouyer
751 1.5.2.2 bouyer #endif /* NSTF > 0 */
752