Deleted Added
full compact
if_gif.c (193511) if_gif.c (193664)
1/* $FreeBSD: head/sys/net/if_gif.c 193511 2009-06-05 14:55:22Z rwatson $ */
1/* $FreeBSD: head/sys/net/if_gif.c 193664 2009-06-07 23:00:40Z hrs $ */
2/* $KAME: if_gif.c,v 1.87 2001/10/19 08:50:27 itojun Exp $ */
3
4/*-
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

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

40#include <sys/mbuf.h>
41#include <sys/module.h>
42#include <sys/socket.h>
43#include <sys/sockio.h>
44#include <sys/errno.h>
45#include <sys/time.h>
46#include <sys/sysctl.h>
47#include <sys/syslog.h>
2/* $KAME: if_gif.c,v 1.87 2001/10/19 08:50:27 itojun Exp $ */
3
4/*-
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

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

40#include <sys/mbuf.h>
41#include <sys/module.h>
42#include <sys/socket.h>
43#include <sys/sockio.h>
44#include <sys/errno.h>
45#include <sys/time.h>
46#include <sys/sysctl.h>
47#include <sys/syslog.h>
48#include <sys/priv.h>
48#include <sys/proc.h>
49#include <sys/protosw.h>
50#include <sys/conf.h>
51#include <sys/vimage.h>
52#include <machine/cpu.h>
53
54#include <net/if.h>
55#include <net/if_clone.h>

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

193 }
194
195 GIF_LOCK_INIT(sc);
196
197 GIF2IFP(sc)->if_softc = sc;
198 if_initname(GIF2IFP(sc), ifc->ifc_name, unit);
199
200 sc->encap_cookie4 = sc->encap_cookie6 = NULL;
49#include <sys/proc.h>
50#include <sys/protosw.h>
51#include <sys/conf.h>
52#include <sys/vimage.h>
53#include <machine/cpu.h>
54
55#include <net/if.h>
56#include <net/if_clone.h>

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

194 }
195
196 GIF_LOCK_INIT(sc);
197
198 GIF2IFP(sc)->if_softc = sc;
199 if_initname(GIF2IFP(sc), ifc->ifc_name, unit);
200
201 sc->encap_cookie4 = sc->encap_cookie6 = NULL;
202 sc->gif_options = GIF_ACCEPT_REVETHIP;
201
202 GIF2IFP(sc)->if_addrlen = 0;
203 GIF2IFP(sc)->if_mtu = GIF_MTU;
204 GIF2IFP(sc)->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
205#if 0
206 /* turn off ingress filter */
207 GIF2IFP(sc)->if_flags |= IFF_LINK2;
208#endif

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

529
530void
531gif_input(m, af, ifp)
532 struct mbuf *m;
533 int af;
534 struct ifnet *ifp;
535{
536 int isr, n;
203
204 GIF2IFP(sc)->if_addrlen = 0;
205 GIF2IFP(sc)->if_mtu = GIF_MTU;
206 GIF2IFP(sc)->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
207#if 0
208 /* turn off ingress filter */
209 GIF2IFP(sc)->if_flags |= IFF_LINK2;
210#endif

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

531
532void
533gif_input(m, af, ifp)
534 struct mbuf *m;
535 int af;
536 struct ifnet *ifp;
537{
538 int isr, n;
539 struct gif_softc *sc = ifp->if_softc;
537 struct etherip_header *eip;
538 struct ether_header *eh;
539 struct ifnet *oldifp;
540
541 if (ifp == NULL) {
542 /* just in case */
543 m_freem(m);
544 return;

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

589 m = m_pullup(m, n);
590 if (m == NULL) {
591 ifp->if_ierrors++;
592 return;
593 }
594 }
595
596 eip = mtod(m, struct etherip_header *);
540 struct etherip_header *eip;
541 struct ether_header *eh;
542 struct ifnet *oldifp;
543
544 if (ifp == NULL) {
545 /* just in case */
546 m_freem(m);
547 return;

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

592 m = m_pullup(m, n);
593 if (m == NULL) {
594 ifp->if_ierrors++;
595 return;
596 }
597 }
598
599 eip = mtod(m, struct etherip_header *);
597 if (eip->eip_ver !=
598 (ETHERIP_VERSION & ETHERIP_VER_VERS_MASK)) {
599 /* discard unknown versions */
600 m_freem(m);
601 return;
600 /*
601 * GIF_ACCEPT_REVETHIP (enabled by default) intentionally
602 * accepts an EtherIP packet with revered version field in
603 * the header. This is a knob for backward compatibility
604 * with FreeBSD 7.2R or prior.
605 */
606 if (sc->gif_options & GIF_ACCEPT_REVETHIP) {
607 if (eip->eip_resvl != ETHERIP_VERSION
608 && eip->eip_ver != ETHERIP_VERSION) {
609 /* discard unknown versions */
610 m_freem(m);
611 return;
612 }
613 } else {
614 if (eip->eip_ver != ETHERIP_VERSION) {
615 /* discard unknown versions */
616 m_freem(m);
617 return;
618 }
602 }
603 m_adj(m, sizeof(struct etherip_header));
604
605 m->m_flags &= ~(M_BCAST|M_MCAST);
606 m->m_pkthdr.rcvif = ifp;
607
608 if (ifp->if_bridge) {
609 oldifp = ifp;

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

648gif_ioctl(ifp, cmd, data)
649 struct ifnet *ifp;
650 u_long cmd;
651 caddr_t data;
652{
653 struct gif_softc *sc = ifp->if_softc;
654 struct ifreq *ifr = (struct ifreq*)data;
655 int error = 0, size;
619 }
620 m_adj(m, sizeof(struct etherip_header));
621
622 m->m_flags &= ~(M_BCAST|M_MCAST);
623 m->m_pkthdr.rcvif = ifp;
624
625 if (ifp->if_bridge) {
626 oldifp = ifp;

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

665gif_ioctl(ifp, cmd, data)
666 struct ifnet *ifp;
667 u_long cmd;
668 caddr_t data;
669{
670 struct gif_softc *sc = ifp->if_softc;
671 struct ifreq *ifr = (struct ifreq*)data;
672 int error = 0, size;
673 u_int options;
656 struct sockaddr *dst, *src;
657#ifdef SIOCSIFMTU /* xxx */
658 u_long mtu;
659#endif
660
661 switch (cmd) {
662 case SIOCSIFADDR:
663 ifp->if_flags |= IFF_UP;

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

882 return EINVAL;
883 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len);
884 break;
885
886 case SIOCSIFFLAGS:
887 /* if_ioctl() takes care of it */
888 break;
889
674 struct sockaddr *dst, *src;
675#ifdef SIOCSIFMTU /* xxx */
676 u_long mtu;
677#endif
678
679 switch (cmd) {
680 case SIOCSIFADDR:
681 ifp->if_flags |= IFF_UP;

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

900 return EINVAL;
901 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len);
902 break;
903
904 case SIOCSIFFLAGS:
905 /* if_ioctl() takes care of it */
906 break;
907
908 case GIFGOPTS:
909 options = sc->gif_options;
910 error = copyout(&options, ifr->ifr_data,
911 sizeof(options));
912 break;
913
914 case GIFSOPTS:
915 if ((error = priv_check(curthread, PRIV_NET_GIF)) != 0)
916 break;
917 if ((error = copyin(&options, &sc->gif_options,
918 sizeof(sc->gif_options)))) {
919 if ((options | GIF_FULLOPTS) == GIF_FULLOPTS)
920 ifr->ifr_data = (caddr_t)options;
921 else
922 error = EINVAL;
923 }
924 break;
925
890 default:
891 error = EINVAL;
892 break;
893 }
894 bad:
895 return error;
896}
897

--- 140 unchanged lines hidden ---
926 default:
927 error = EINVAL;
928 break;
929 }
930 bad:
931 return error;
932}
933

--- 140 unchanged lines hidden ---