Deleted Added
full compact
if_tun.c (56410) if_tun.c (56555)
1/* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */
2
3/*
4 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
5 * Nottingham University 1987.
6 *
7 * This source may be freely distributed, however I would be interested
8 * in any changes that are made.
9 *
10 * This driver takes packets off the IP i/f and hands them up to a
11 * user process to have its wicked way with. This driver has it's
12 * roots in a similar driver written by Phil Cockcroft (formerly) at
13 * UCL. This driver is based much more on read/write/poll mode of
14 * operation though.
15 *
1/* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */
2
3/*
4 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
5 * Nottingham University 1987.
6 *
7 * This source may be freely distributed, however I would be interested
8 * in any changes that are made.
9 *
10 * This driver takes packets off the IP i/f and hands them up to a
11 * user process to have its wicked way with. This driver has it's
12 * roots in a similar driver written by Phil Cockcroft (formerly) at
13 * UCL. This driver is based much more on read/write/poll mode of
14 * operation though.
15 *
16 * $FreeBSD: head/sys/net/if_tun.c 56410 2000-01-23 01:47:12Z brian $
16 * $FreeBSD: head/sys/net/if_tun.c 56555 2000-01-24 20:39:02Z brian $
17 */
18
19#include "opt_atalk.h"
17 */
18
19#include "opt_atalk.h"
20#include "opt_atm.h"
20#include "opt_inet.h"
21#include "opt_inet6.h"
22#include "opt_ipx.h"
21#include "opt_inet.h"
22#include "opt_inet6.h"
23#include "opt_ipx.h"
24#include "opt_natm.h"
23
24#include <sys/param.h>
25#include <sys/proc.h>
26#include <sys/systm.h>
27#include <sys/mbuf.h>
28#include <sys/socket.h>
29#include <sys/filio.h>
30#include <sys/sockio.h>

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

37#include <sys/conf.h>
38#include <sys/uio.h>
39#include <sys/vnode.h>
40#include <sys/malloc.h>
41
42#include <net/if.h>
43#include <net/netisr.h>
44#include <net/route.h>
25
26#include <sys/param.h>
27#include <sys/proc.h>
28#include <sys/systm.h>
29#include <sys/mbuf.h>
30#include <sys/socket.h>
31#include <sys/filio.h>
32#include <sys/sockio.h>

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

39#include <sys/conf.h>
40#include <sys/uio.h>
41#include <sys/vnode.h>
42#include <sys/malloc.h>
43
44#include <net/if.h>
45#include <net/netisr.h>
46#include <net/route.h>
47#include <net/intrq.h>
45
48
49#ifdef ATM_CORE
50#include <netatm/kern_include.h>
51#include <netatm/atm.h>
52#include <netatm/atm_var.h>
53#endif
54
46#ifdef INET
47#include <netinet/in.h>
48#include <netinet/in_var.h>
49#endif
50
51#ifdef INET6
52#include <netinet6/in6.h>
53#include <netinet6/in6_var.h>
54#endif
55
55#ifdef INET
56#include <netinet/in.h>
57#include <netinet/in_var.h>
58#endif
59
60#ifdef INET6
61#include <netinet6/in6.h>
62#include <netinet6/in6_var.h>
63#endif
64
56#ifdef NS
57/* This will never be defined by config(8), or for the if_tun module ! */
58#include <netns/ns.h>
59#include <netns/ns_if.h>
60#endif
61
62#ifdef IPX
63#include <netipx/ipx.h>
64#include <netipx/ipx_if.h>
65#endif
66
65#ifdef IPX
66#include <netipx/ipx.h>
67#include <netipx/ipx_if.h>
68#endif
69
70#ifdef NATM
71#include <netnatm/natm.h>
72#endif
73
67#ifdef NETATALK
68#include <netatalk/at.h>
69#include <netatalk/at_var.h>
70#endif
71
74#ifdef NETATALK
75#include <netatalk/at.h>
76#include <netatalk/at_var.h>
77#endif
78
79#ifdef NS
80/* This will never be defined by config(8), or for the if_tun module ! */
81#include <netns/ns.h>
82#include <netns/ns_if.h>
83#endif
84
72#include <net/bpf.h>
73
74#include <net/if_tunvar.h>
75#include <net/if_tun.h>
76
77static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface");
78
79static void tunattach __P((void *));

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

695 if (top->m_len < sizeof(family) &&
696 (top = m_pullup(top, sizeof(family))) == NULL)
697 return ENOBUFS;
698 family = ntohl(*mtod(top, u_int32_t *));
699 m_adj(top, sizeof(family));
700 } else
701 family = AF_INET;
702
85#include <net/bpf.h>
86
87#include <net/if_tunvar.h>
88#include <net/if_tun.h>
89
90static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface");
91
92static void tunattach __P((void *));

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

708 if (top->m_len < sizeof(family) &&
709 (top = m_pullup(top, sizeof(family))) == NULL)
710 return ENOBUFS;
711 family = ntohl(*mtod(top, u_int32_t *));
712 m_adj(top, sizeof(family));
713 } else
714 family = AF_INET;
715
716 q = NULL;
717 isr = 0;
718
703 switch (family) {
719 switch (family) {
720#ifdef ATM_CORE
721 case AF_ATM:
722 if (atmintrq_present) {
723 q = &atm_intrq;
724 isr = NETISR_ATM;
725 }
726 break;
727#endif
704#ifdef INET
705 case AF_INET:
728#ifdef INET
729 case AF_INET:
706 q = &ipintrq;
707 isr = NETISR_IP;
730 if (ipintrq_present) {
731 q = &ipintrq;
732 isr = NETISR_IP;
733 }
708 break;
709#endif
710#ifdef INET6
711 case AF_INET6:
734 break;
735#endif
736#ifdef INET6
737 case AF_INET6:
712 q = &ip6intrq;
713 isr = NETISR_IPV6;
738 if (ip6intrq_present) {
739 q = &ip6intrq;
740 isr = NETISR_IPV6;
741 }
714 break;
715#endif
742 break;
743#endif
716#ifdef NS
717 case AF_NS:
718 q = &nsintrq;
719 isr = NETISR_NS;
720 break;
721#endif
722#ifdef IPX
723 case AF_IPX:
744#ifdef IPX
745 case AF_IPX:
724 q = &ipxintrq;
725 isr = NETISR_IPX;
746 if (ipxintrq_present) {
747 q = &ipxintrq;
748 isr = NETISR_IPX;
749 }
726 break;
727#endif
750 break;
751#endif
752#ifdef NATM
753 case AF_NATM:
754 if (natmintrq_present) {
755 q = &natmintrq;
756 isr = NETISR_NATM;
757 }
758 break;
759#endif
728#ifdef NETATALK
729 case AF_APPLETALK:
760#ifdef NETATALK
761 case AF_APPLETALK:
730 q = &atintrq2;
731 isr = NETISR_ATALK;
762 if (atintrq2_present) {
763 q = &atintrq2;
764 isr = NETISR_ATALK;
765 }
732 break;
733#endif
766 break;
767#endif
734 default:
768#ifdef NS
769 case AF_NS:
770 if (nsintrq_present) {
771 q = &nsintrq;
772 isr = NETISR_NS;
773 }
774 break;
775#endif
776 }
777
778 if (!q) {
735 m_freem(top);
736 return EAFNOSUPPORT;
737 }
738
739 s = splimp();
740 if (IF_QFULL (q)) {
741 IF_DROP(q);
742 splx(s);

--- 49 unchanged lines hidden ---
779 m_freem(top);
780 return EAFNOSUPPORT;
781 }
782
783 s = splimp();
784 if (IF_QFULL (q)) {
785 IF_DROP(q);
786 splx(s);

--- 49 unchanged lines hidden ---