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 269699 2014-08-08 01:57:15Z kevlo $");
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#endif
88
89#include <machine/stdarg.h>
90
91#include <sys/kernel.h>
92#include <sys/malloc.h>
93static MALLOC_DEFINE(M_NETADDR, "encap_export_host", "Export host address structure");
94

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

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

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

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

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

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

--- 200 unchanged lines hidden ---