Deleted Added
full compact
if_tap.c (69781) if_tap.c (71602)
1/*
2 * Copyright (C) 1999-2000 by Maksim Yevmenkin <m_evmenkin@yahoo.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * BASED ON:
27 * -------------------------------------------------------------------------
28 *
29 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
30 * Nottingham University 1987.
31 */
32
33/*
1/*
2 * Copyright (C) 1999-2000 by Maksim Yevmenkin <m_evmenkin@yahoo.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

26 * BASED ON:
27 * -------------------------------------------------------------------------
28 *
29 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
30 * Nottingham University 1987.
31 */
32
33/*
34 * $FreeBSD: head/sys/net/if_tap.c 69781 2000-12-08 21:51:06Z dwmalone $
34 * $FreeBSD: head/sys/net/if_tap.c 71602 2001-01-24 20:59:34Z phk $
35 * $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $
36 */
37
38#include "opt_inet.h"
39
40#include <sys/param.h>
41#include <sys/conf.h>
42#include <sys/filedesc.h>

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

74#define TAP "tap"
75#define VMNET "vmnet"
76#define VMNET_DEV_MASK 0x00010000
77
78/* module */
79static int tapmodevent __P((module_t, int, void *));
80
81/* device */
35 * $Id: if_tap.c,v 0.21 2000/07/23 21:46:02 max Exp $
36 */
37
38#include "opt_inet.h"
39
40#include <sys/param.h>
41#include <sys/conf.h>
42#include <sys/filedesc.h>

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

74#define TAP "tap"
75#define VMNET "vmnet"
76#define VMNET_DEV_MASK 0x00010000
77
78/* module */
79static int tapmodevent __P((module_t, int, void *));
80
81/* device */
82static void tapclone __P((void *, char *, int, dev_t *));
82static void tapcreate __P((dev_t));
83
84/* network interface */
85static void tapifstart __P((struct ifnet *));
86static int tapifioctl __P((struct ifnet *, u_long, caddr_t));
87static void tapifinit __P((void *));
88
89/* character device */

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

126 * module event handler
127 */
128static int
129tapmodevent(mod, type, data)
130 module_t mod;
131 int type;
132 void *data;
133{
83static void tapcreate __P((dev_t));
84
85/* network interface */
86static void tapifstart __P((struct ifnet *));
87static int tapifioctl __P((struct ifnet *, u_long, caddr_t));
88static void tapifinit __P((void *));
89
90/* character device */

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

127 * module event handler
128 */
129static int
130tapmodevent(mod, type, data)
131 module_t mod;
132 int type;
133 void *data;
134{
134 static int attached = 0;
135 struct ifnet *ifp = NULL;
136 int unit, s;
135 static int attached = 0;
136 static eventhandler_tag eh_tag = NULL;
137
138 switch (type) {
139 case MOD_LOAD:
140 if (attached)
141 return (EEXIST);
142
137
138 switch (type) {
139 case MOD_LOAD:
140 if (attached)
141 return (EEXIST);
142
143 eh_tag = EVENTHANDLER_REGISTER(dev_clone, tapclone, 0, 1000);
143 cdevsw_add(&tap_cdevsw);
144 attached = 1;
145 break;
146
144 cdevsw_add(&tap_cdevsw);
145 attached = 1;
146 break;
147
147 case MOD_UNLOAD:
148 case MOD_UNLOAD: {
149 int unit;
150
148 if (taprefcnt > 0)
149 return (EBUSY);
150
151 if (taprefcnt > 0)
152 return (EBUSY);
153
154 EVENTHANDLER_DEREGISTER(dev_clone, eh_tag);
151 cdevsw_remove(&tap_cdevsw);
152
153 unit = 0;
154 while (unit <= taplastunit) {
155 cdevsw_remove(&tap_cdevsw);
156
157 unit = 0;
158 while (unit <= taplastunit) {
159 int s;
160 struct ifnet *ifp = NULL;
161
155 s = splimp();
156 TAILQ_FOREACH(ifp, &ifnet, if_link)
157 if ((strcmp(ifp->if_name, TAP) == 0) ||
158 (strcmp(ifp->if_name, VMNET) == 0))
159 if (ifp->if_unit == unit)
160 break;
161 splx(s);
162

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

174 destroy_dev(tp->tap_dev);
175 FREE(tp, M_TAP);
176 }
177 else
178 unit ++;
179 }
180
181 attached = 0;
162 s = splimp();
163 TAILQ_FOREACH(ifp, &ifnet, if_link)
164 if ((strcmp(ifp->if_name, TAP) == 0) ||
165 (strcmp(ifp->if_name, VMNET) == 0))
166 if (ifp->if_unit == unit)
167 break;
168 splx(s);
169

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

181 destroy_dev(tp->tap_dev);
182 FREE(tp, M_TAP);
183 }
184 else
185 unit ++;
186 }
187
188 attached = 0;
182 break;
189 } break;
183
184 default:
185 return (EOPNOTSUPP);
186 }
187
188 return (0);
189} /* tapmodevent */
190
191
192/*
190
191 default:
192 return (EOPNOTSUPP);
193 }
194
195 return (0);
196} /* tapmodevent */
197
198
199/*
200 * DEVFS handler
201 *
202 * We need to support two kind of devices - tap and vmnet
203 */
204static void
205tapclone(arg, name, namelen, dev)
206 void *arg;
207 char *name;
208 int namelen;
209 dev_t *dev;
210{
211 int unit, minor;
212 char *device_name = NULL;
213
214 if (*dev != NODEV)
215 return;
216
217 device_name = TAP;
218 if (dev_stdclone(name, NULL, device_name, &unit) != 1) {
219 device_name = VMNET;
220
221 if (dev_stdclone(name, NULL, device_name, &unit) != 1)
222 return;
223
224 minor = (unit | VMNET_DEV_MASK);
225 }
226 else
227 minor = unit;
228
229 *dev = make_dev(&tap_cdevsw, minor, UID_ROOT, GID_WHEEL, 0600, "%s%d",
230 device_name, unit);
231} /* tapclone */
232
233
234/*
193 * tapcreate
194 *
195 * to create interface
196 */
197static void
198tapcreate(dev)
199 dev_t dev;
200{

--- 623 unchanged lines hidden ---
235 * tapcreate
236 *
237 * to create interface
238 */
239static void
240tapcreate(dev)
241 dev_t dev;
242{

--- 623 unchanged lines hidden ---