Deleted Added
full compact
ip_gre.c (147256) ip_gre.c (148613)
1/* $NetBSD: ip_gre.c,v 1.29 2003/09/05 23:02:43 itojun Exp $ */
1/* $NetBSD: ip_gre.c,v 1.29 2003/09/05 23:02:43 itojun Exp $ */
2/* $FreeBSD: head/sys/netinet/ip_gre.c 147256 2005-06-10 16:49:24Z brooks $ */
2/* $FreeBSD: head/sys/netinet/ip_gre.c 148613 2005-08-01 08:14:21Z bz $ */
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *
11 * IPv6-over-GRE contributed by Gert Doering <gert@greenie.muc.de>
12 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.

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

40/*
41 * deencapsulate tunneled packets and send them on
42 * output half is in net/if_gre.[ch]
43 * This currently handles IPPROTO_GRE, IPPROTO_MOBILE
44 */
45
46#include "opt_inet.h"
47#include "opt_atalk.h"
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.

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

42/*
43 * deencapsulate tunneled packets and send them on
44 * output half is in net/if_gre.[ch]
45 * This currently handles IPPROTO_GRE, IPPROTO_MOBILE
46 */
47
48#include "opt_inet.h"
49#include "opt_atalk.h"
50#include "opt_inet6.h"
48
49#include <sys/param.h>
50#include <sys/systm.h>
51#include <sys/mbuf.h>
52#include <sys/socket.h>
53#include <sys/socketvar.h>
54#include <sys/protosw.h>
55#include <sys/errno.h>

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

137 */
138static int
139gre_input2(struct mbuf *m ,int hlen, u_char proto)
140{
141 struct greip *gip;
142 int isr;
143 struct gre_softc *sc;
144 u_int16_t flags;
51
52#include <sys/param.h>
53#include <sys/systm.h>
54#include <sys/mbuf.h>
55#include <sys/socket.h>
56#include <sys/socketvar.h>
57#include <sys/protosw.h>
58#include <sys/errno.h>

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

140 */
141static int
142gre_input2(struct mbuf *m ,int hlen, u_char proto)
143{
144 struct greip *gip;
145 int isr;
146 struct gre_softc *sc;
147 u_int16_t flags;
148 u_int32_t af;
145
146 if ((sc = gre_lookup(m, proto)) == NULL) {
147 /* No matching tunnel or tunnel is down. */
148 return (0);
149 }
150
151 if (m->m_len < sizeof(*gip)) {
152 m = m_pullup(m, sizeof(*gip));

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

178
179 switch (ntohs(gip->gi_ptype)) { /* ethertypes */
180 case WCCP_PROTOCOL_TYPE:
181 if (sc->wccp_ver == WCCP_V2)
182 hlen += 4;
183 /* FALLTHROUGH */
184 case ETHERTYPE_IP: /* shouldn't need a schednetisr(), */
185 isr = NETISR_IP;/* as we are in ip_input */
149
150 if ((sc = gre_lookup(m, proto)) == NULL) {
151 /* No matching tunnel or tunnel is down. */
152 return (0);
153 }
154
155 if (m->m_len < sizeof(*gip)) {
156 m = m_pullup(m, sizeof(*gip));

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

182
183 switch (ntohs(gip->gi_ptype)) { /* ethertypes */
184 case WCCP_PROTOCOL_TYPE:
185 if (sc->wccp_ver == WCCP_V2)
186 hlen += 4;
187 /* FALLTHROUGH */
188 case ETHERTYPE_IP: /* shouldn't need a schednetisr(), */
189 isr = NETISR_IP;/* as we are in ip_input */
190 af = AF_INET;
186 break;
191 break;
192#ifdef INET6
193 case ETHERTYPE_IPV6:
194 isr = NETISR_IPV6;
195 af = AF_INET6;
196 break;
197#endif
187#ifdef NETATALK
188 case ETHERTYPE_ATALK:
189 isr = NETISR_ATALK1;
198#ifdef NETATALK
199 case ETHERTYPE_ATALK:
200 isr = NETISR_ATALK1;
201 af = AF_APPLETALK;
190 break;
191#endif
202 break;
203#endif
192 case ETHERTYPE_IPV6:
193 /* FALLTHROUGH */
194 default: /* others not yet supported */
195 return (0);
196 }
197 break;
198 default:
199 /* others not yet supported */
200 return (0);
201 }
202
203 if (hlen > m->m_pkthdr.len) {
204 m_freem(m);
205 return (EINVAL);
206 }
207 /* Unlike NetBSD, in FreeBSD m_adj() adjusts m->m_pkthdr.len as well */
208 m_adj(m, hlen);
209
210 if (GRE2IFP(sc)->if_bpf) {
204 default: /* others not yet supported */
205 return (0);
206 }
207 break;
208 default:
209 /* others not yet supported */
210 return (0);
211 }
212
213 if (hlen > m->m_pkthdr.len) {
214 m_freem(m);
215 return (EINVAL);
216 }
217 /* Unlike NetBSD, in FreeBSD m_adj() adjusts m->m_pkthdr.len as well */
218 m_adj(m, hlen);
219
220 if (GRE2IFP(sc)->if_bpf) {
211 u_int32_t af = AF_INET;
212 bpf_mtap2(GRE2IFP(sc)->if_bpf, &af, sizeof(af), m);
213 }
214
215 m->m_pkthdr.rcvif = GRE2IFP(sc);
216
217 netisr_dispatch(isr, m);
218
219 return (1); /* packet is done, no further processing needed */

--- 128 unchanged lines hidden ---
221 bpf_mtap2(GRE2IFP(sc)->if_bpf, &af, sizeof(af), m);
222 }
223
224 m->m_pkthdr.rcvif = GRE2IFP(sc);
225
226 netisr_dispatch(isr, m);
227
228 return (1); /* packet is done, no further processing needed */

--- 128 unchanged lines hidden ---