if_gre.c (248324) | if_gre.c (249925) |
---|---|
1/* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */ | 1/* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */ |
2/* $FreeBSD: head/sys/net/if_gre.c 248324 2013-03-15 12:55:30Z glebius $ */ | 2/* $FreeBSD: head/sys/net/if_gre.c 249925 2013-04-26 12:50:32Z glebius $ */ |
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 * --- 97 unchanged lines hidden (view full) --- 108 109struct gre_softc_head gre_softc_list; 110 111static int gre_clone_create(struct if_clone *, int, caddr_t); 112static void gre_clone_destroy(struct ifnet *); 113static struct if_clone *gre_cloner; 114 115static int gre_ioctl(struct ifnet *, u_long, caddr_t); | 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 * --- 97 unchanged lines hidden (view full) --- 108 109struct gre_softc_head gre_softc_list; 110 111static int gre_clone_create(struct if_clone *, int, caddr_t); 112static void gre_clone_destroy(struct ifnet *); 113static struct if_clone *gre_cloner; 114 115static int gre_ioctl(struct ifnet *, u_long, caddr_t); |
116static int gre_output(struct ifnet *, struct mbuf *, struct sockaddr *, 117 struct route *ro); | 116static int gre_output(struct ifnet *, struct mbuf *, 117 const struct sockaddr *, struct route *); |
118 119static int gre_compute_route(struct gre_softc *sc); 120 121static void greattach(void); 122 123#ifdef INET 124extern struct domain inetdomain; 125static const struct protosw in_gre_protosw = { --- 110 unchanged lines hidden (view full) --- 236 free(sc, M_GRE); 237} 238 239/* 240 * The output routine. Takes a packet and encapsulates it in the protocol 241 * given by sc->g_proto. See also RFC 1701 and RFC 2004 242 */ 243static int | 118 119static int gre_compute_route(struct gre_softc *sc); 120 121static void greattach(void); 122 123#ifdef INET 124extern struct domain inetdomain; 125static const struct protosw in_gre_protosw = { --- 110 unchanged lines hidden (view full) --- 236 free(sc, M_GRE); 237} 238 239/* 240 * The output routine. Takes a packet and encapsulates it in the protocol 241 * given by sc->g_proto. See also RFC 1701 and RFC 2004 242 */ 243static int |
244gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, | 244gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, |
245 struct route *ro) 246{ 247 int error = 0; 248 struct gre_softc *sc = ifp->if_softc; 249 struct greip *gh; 250 struct ip *ip; 251 struct m_tag *mtag; 252 struct mtag_gre_nesting *gt; --- 75 unchanged lines hidden (view full) --- 328 error = ENETDOWN; 329 goto end; 330 } 331 332 gh = NULL; 333 ip = NULL; 334 335 /* BPF writes need to be handled specially. */ | 245 struct route *ro) 246{ 247 int error = 0; 248 struct gre_softc *sc = ifp->if_softc; 249 struct greip *gh; 250 struct ip *ip; 251 struct m_tag *mtag; 252 struct mtag_gre_nesting *gt; --- 75 unchanged lines hidden (view full) --- 328 error = ENETDOWN; 329 goto end; 330 } 331 332 gh = NULL; 333 ip = NULL; 334 335 /* BPF writes need to be handled specially. */ |
336 if (dst->sa_family == AF_UNSPEC) { | 336 if (dst->sa_family == AF_UNSPEC) |
337 bcopy(dst->sa_data, &af, sizeof(af)); | 337 bcopy(dst->sa_data, &af, sizeof(af)); |
338 dst->sa_family = af; 339 } 340 341 if (bpf_peers_present(ifp->if_bpf)) { | 338 else |
342 af = dst->sa_family; | 339 af = dst->sa_family; |
340 341 if (bpf_peers_present(ifp->if_bpf)) |
|
343 bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); | 342 bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); |
344 } | |
345 346 m->m_flags &= ~(M_BCAST|M_MCAST); 347 348 if (sc->g_proto == IPPROTO_MOBILE) { | 343 344 m->m_flags &= ~(M_BCAST|M_MCAST); 345 346 if (sc->g_proto == IPPROTO_MOBILE) { |
349 if (dst->sa_family == AF_INET) { | 347 if (af == AF_INET) { |
350 struct mbuf *m0; 351 int msiz; 352 353 ip = mtod(m, struct ip *); 354 355 /* 356 * RFC2004 specifies that fragmented diagrams shouldn't 357 * be encapsulated. --- 54 unchanged lines hidden (view full) --- 412 ip->ip_len = htons(ntohs(ip->ip_len) + msiz); 413 } else { /* AF_INET */ 414 _IF_DROP(&ifp->if_snd); 415 m_freem(m); 416 error = EINVAL; 417 goto end; 418 } 419 } else if (sc->g_proto == IPPROTO_GRE) { | 348 struct mbuf *m0; 349 int msiz; 350 351 ip = mtod(m, struct ip *); 352 353 /* 354 * RFC2004 specifies that fragmented diagrams shouldn't 355 * be encapsulated. --- 54 unchanged lines hidden (view full) --- 410 ip->ip_len = htons(ntohs(ip->ip_len) + msiz); 411 } else { /* AF_INET */ 412 _IF_DROP(&ifp->if_snd); 413 m_freem(m); 414 error = EINVAL; 415 goto end; 416 } 417 } else if (sc->g_proto == IPPROTO_GRE) { |
420 switch (dst->sa_family) { | 418 switch (af) { |
421 case AF_INET: 422 ip = mtod(m, struct ip *); 423 gre_ip_tos = ip->ip_tos; 424 gre_ip_id = ip->ip_id; 425 if (sc->wccp_ver == WCCP_V2) { 426 extra = sizeof(uint32_t); 427 etype = WCCP_PROTOCOL_TYPE; 428 } else { --- 548 unchanged lines hidden --- | 419 case AF_INET: 420 ip = mtod(m, struct ip *); 421 gre_ip_tos = ip->ip_tos; 422 gre_ip_id = ip->ip_id; 423 if (sc->wccp_ver == WCCP_V2) { 424 extra = sizeof(uint32_t); 425 etype = WCCP_PROTOCOL_TYPE; 426 } else { --- 548 unchanged lines hidden --- |