efi - Add EFI run-time ABI support (2)
[dragonfly.git] / sys / netinet6 / route6.c
blob4c993b8d729fefc6ab550f07914efa09cf16f6d3
1 /* $FreeBSD: src/sys/netinet6/route6.c,v 1.1.2.5 2003/01/23 21:06:47 sam Exp $ */
2 /* $DragonFly: src/sys/netinet6/route6.c,v 1.10 2008/09/04 09:08:22 hasso Exp $ */
3 /* $KAME: route6.c,v 1.24 2001/03/14 03:07:05 itojun Exp $ */
5 /*
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
34 #include "opt_inet.h"
35 #include "opt_inet6.h"
37 #include <sys/param.h>
38 #include <sys/mbuf.h>
39 #include <sys/socket.h>
40 #include <sys/systm.h>
41 #include <sys/queue.h>
43 #include <net/if.h>
45 #include <netinet/in.h>
46 #include <netinet6/in6_var.h>
47 #include <netinet/ip6.h>
48 #include <netinet6/ip6_var.h>
50 #include <netinet/icmp6.h>
52 int
53 route6_input(struct mbuf **mp, int *offp, int proto) /* proto is unused */
55 struct ip6_hdr *ip6;
56 struct mbuf *m = *mp;
57 struct ip6_rthdr *rh;
58 int off = *offp, rhlen;
60 #ifndef PULLDOWN_TEST
61 IP6_EXTHDR_CHECK(m, off, sizeof(*rh), IPPROTO_DONE);
62 ip6 = mtod(m, struct ip6_hdr *);
63 rh = (struct ip6_rthdr *)((caddr_t)ip6 + off);
64 #else
65 ip6 = mtod(m, struct ip6_hdr *);
66 IP6_EXTHDR_GET(rh, struct ip6_rthdr *, m, off, sizeof(*rh));
67 if (rh == NULL) {
68 ip6stat.ip6s_tooshort++;
69 return IPPROTO_DONE;
71 #endif
73 switch (rh->ip6r_type) {
74 default:
75 /* unknown routing type */
76 if (rh->ip6r_segleft == 0) {
77 rhlen = (rh->ip6r_len + 1) << 3;
78 break; /* Final dst. Just ignore the header. */
80 ip6stat.ip6s_badoptions++;
81 icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
82 (caddr_t)&rh->ip6r_type - (caddr_t)ip6);
83 return (IPPROTO_DONE);
86 *offp += rhlen;
87 return (rh->ip6r_nxt);