Deleted Added
sdiff udiff text old ( 201145 ) new ( 269699 )
full compact
1/* $KAME: ip_encap.c,v 1.41 2001/03/15 08:35:08 itojun Exp $ */
2
3/*-
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 43 unchanged lines hidden (view full) ---

52 * AH/ESP/IPComp header right after outer IP header.
53 *
54 * So, clearly good old protosw does not work for protocol #4 and #41.
55 * The code will let you match protocol via src/dst address pair.
56 */
57/* XXX is M_NETADDR correct? */
58
59#include <sys/cdefs.h>
60__FBSDID("$FreeBSD: head/sys/netinet/ip_encap.c 201145 2009-12-28 22:56:30Z antoine $");
61
62#include "opt_mrouting.h"
63#include "opt_inet.h"
64#include "opt_inet6.h"
65
66#include <sys/param.h>
67#include <sys/systm.h>
68#include <sys/socket.h>

--- 10 unchanged lines hidden (view full) ---

79#include <netinet/in_systm.h>
80#include <netinet/ip.h>
81#include <netinet/ip_var.h>
82#include <netinet/ip_encap.h>
83
84#ifdef INET6
85#include <netinet/ip6.h>
86#include <netinet6/ip6_var.h>
87#include <netinet6/ip6protosw.h>
88#endif
89
90#include <machine/stdarg.h>
91
92#include <sys/kernel.h>
93#include <sys/malloc.h>
94static MALLOC_DEFINE(M_NETADDR, "encap_export_host", "Export host address structure");
95

--- 14 unchanged lines hidden (view full) ---

110 * it's referenced by KAME pieces in netinet6.
111 */
112void
113encap_init(void)
114{
115}
116
117#ifdef INET
118void
119encap4_input(struct mbuf *m, int off)
120{
121 struct ip *ip;
122 int proto;
123 struct sockaddr_in s, d;
124 const struct protosw *psw;
125 struct encaptab *ep, *match;
126 int prio, matchprio;
127
128 ip = mtod(m, struct ip *);
129 proto = ip->ip_p;
130
131 bzero(&s, sizeof(s));
132 s.sin_family = AF_INET;
133 s.sin_len = sizeof(struct sockaddr_in);
134 s.sin_addr = ip->ip_src;
135 bzero(&d, sizeof(d));
136 d.sin_family = AF_INET;
137 d.sin_len = sizeof(struct sockaddr_in);

--- 45 unchanged lines hidden (view full) ---

183 }
184 mtx_unlock(&encapmtx);
185
186 if (match) {
187 /* found a match, "match" has the best one */
188 psw = match->psw;
189 if (psw && psw->pr_input) {
190 encap_fillarg(m, match);
191 (*psw->pr_input)(m, off);
192 } else
193 m_freem(m);
194 return;
195 }
196
197 /* last resort: inject to raw socket */
198 rip_input(m, off);
199}
200#endif
201
202#ifdef INET6
203int
204encap6_input(struct mbuf **mp, int *offp, int proto)
205{
206 struct mbuf *m = *mp;
207 struct ip6_hdr *ip6;
208 struct sockaddr_in6 s, d;
209 const struct ip6protosw *psw;
210 struct encaptab *ep, *match;
211 int prio, matchprio;
212
213 ip6 = mtod(m, struct ip6_hdr *);
214
215 bzero(&s, sizeof(s));
216 s.sin6_family = AF_INET6;
217 s.sin6_len = sizeof(struct sockaddr_in6);

--- 29 unchanged lines hidden (view full) ---

247 matchprio = prio;
248 match = ep;
249 }
250 }
251 mtx_unlock(&encapmtx);
252
253 if (match) {
254 /* found a match */
255 psw = (const struct ip6protosw *)match->psw;
256 if (psw && psw->pr_input) {
257 encap_fillarg(m, match);
258 return (*psw->pr_input)(mp, offp, proto);
259 } else {
260 m_freem(m);
261 return IPPROTO_DONE;
262 }
263 }

--- 200 unchanged lines hidden ---