Deleted Added
full compact
if_tun.c (64880) if_tun.c (65374)
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 64880 2000-08-20 21:34:39Z phk $
16 * $FreeBSD: head/sys/net/if_tun.c 65374 2000-09-02 19:17:34Z phk $
17 */
18
19#include "opt_inet.h"
17 */
18
19#include "opt_inet.h"
20#include "opt_devfs.h"
21
22#include <sys/param.h>
23#include <sys/proc.h>
24#include <sys/systm.h>
25#include <sys/mbuf.h>
26#include <sys/socket.h>
27#include <sys/filio.h>
28#include <sys/sockio.h>

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

46#include <netinet/in.h>
47#endif
48
49#include <net/bpf.h>
50
51#include <net/if_tunvar.h>
52#include <net/if_tun.h>
53
20
21#include <sys/param.h>
22#include <sys/proc.h>
23#include <sys/systm.h>
24#include <sys/mbuf.h>
25#include <sys/socket.h>
26#include <sys/filio.h>
27#include <sys/sockio.h>

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

45#include <netinet/in.h>
46#endif
47
48#include <net/bpf.h>
49
50#include <net/if_tunvar.h>
51#include <net/if_tun.h>
52
54#ifdef DEVFS
55#include <sys/eventhandler.h>
56#include <fs/devfs/devfs.h>
57#endif
58
59static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface");
60
61static void tunattach __P((void *));
62PSEUDO_SET(tunattach, if_tun);
63
64static void tuncreate __P((dev_t dev));
65
66#define TUNDEBUG if (tundebug) printf

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

92 /* name */ "tun",
93 /* maj */ CDEV_MAJOR,
94 /* dump */ nodump,
95 /* psize */ nopsize,
96 /* flags */ 0,
97 /* bmaj */ -1
98};
99
53static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface");
54
55static void tunattach __P((void *));
56PSEUDO_SET(tunattach, if_tun);
57
58static void tuncreate __P((dev_t dev));
59
60#define TUNDEBUG if (tundebug) printf

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

86 /* name */ "tun",
87 /* maj */ CDEV_MAJOR,
88 /* dump */ nodump,
89 /* psize */ nopsize,
90 /* flags */ 0,
91 /* bmaj */ -1
92};
93
100#ifdef DEVFS
101static void tun_clone __P((void *arg, char *name, int namelen, dev_t *dev));
102
103static void
104tun_clone(arg, name, namelen, dev)
105 void *arg;
106 char *name;
107 int namelen;
108 dev_t *dev;
109{
110 int u;
111
112 if (*dev != NODEV)
113 return;
94static void tun_clone __P((void *arg, char *name, int namelen, dev_t *dev));
95
96static void
97tun_clone(arg, name, namelen, dev)
98 void *arg;
99 char *name;
100 int namelen;
101 dev_t *dev;
102{
103 int u;
104
105 if (*dev != NODEV)
106 return;
114 if (devfs_stdclone(name, NULL, "tun", &u) != 1)
107 if (dev_stdclone(name, NULL, "tun", &u) != 1)
115 return;
116 /* XXX: minor encoding if u > 255 */
117 *dev = make_dev(&tun_cdevsw, u,
118 UID_UUCP, GID_DIALER, 0600, "tun%d", u);
119
120}
108 return;
109 /* XXX: minor encoding if u > 255 */
110 *dev = make_dev(&tun_cdevsw, u,
111 UID_UUCP, GID_DIALER, 0600, "tun%d", u);
112
113}
121#endif
122
123
124static void
125tunattach(dummy)
126 void *dummy;
127{
128
114
115static void
116tunattach(dummy)
117 void *dummy;
118{
119
129#ifdef DEVFS
130 EVENTHANDLER_REGISTER(devfs_clone, tun_clone, 0, 1000);
131#else
120 EVENTHANDLER_REGISTER(dev_clone, tun_clone, 0, 1000);
132 cdevsw_add(&tun_cdevsw);
121 cdevsw_add(&tun_cdevsw);
133#endif
134}
135
136static void
137tuncreate(dev)
138 dev_t dev;
139{
140 struct tun_softc *sc;
141 struct ifnet *ifp;

--- 614 unchanged lines hidden ---
122}
123
124static void
125tuncreate(dev)
126 dev_t dev;
127{
128 struct tun_softc *sc;
129 struct ifnet *ifp;

--- 614 unchanged lines hidden ---