1/* $NetBSD: ip_gre.c,v 1.29 2003/09/05 23:02:43 itojun Exp $ */ |
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 * |
11 * IPv6-over-GRE contributed by Gert Doering <gert@greenie.muc.de> 12 * |
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" |
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; |
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; |
191 break; |
192#ifdef INET6 193 case ETHERTYPE_IPV6: 194 isr = NETISR_IPV6; 195 af = AF_INET6; 196 break; 197#endif |
198#ifdef NETATALK 199 case ETHERTYPE_ATALK: 200 isr = NETISR_ATALK1; |
201 af = AF_APPLETALK; |
202 break; 203#endif |
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) { |
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 --- |