Deleted Added
full compact
if_tap.c (126188) if_tap.c (126796)
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 126188 2004-02-24 04:35:44Z bde $
34 * $FreeBSD: head/sys/net/if_tap.c 126796 2004-03-10 08:02:29Z 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>

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

213 extra = VMNET_DEV_MASK;
214 if (dev_stdclone(name, NULL, device_name, &unit) != 1)
215 return;
216 }
217
218 /* find any existing device, or allocate new unit number */
219 i = clone_create(&tapclones, &tap_cdevsw, &unit, dev, extra);
220 if (i) {
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>

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

213 extra = VMNET_DEV_MASK;
214 if (dev_stdclone(name, NULL, device_name, &unit) != 1)
215 return;
216 }
217
218 /* find any existing device, or allocate new unit number */
219 i = clone_create(&tapclones, &tap_cdevsw, &unit, dev, extra);
220 if (i) {
221 *dev = make_dev(&tap_cdevsw, unit2minor(unit) | extra,
221 *dev = make_dev(&tap_cdevsw, unit2minor(unit | extra),
222 UID_ROOT, GID_WHEEL, 0600, "%s%d", device_name, unit);
223 if (*dev != NULL)
224 (*dev)->si_flags |= SI_CHEAPCLONE;
225 }
226} /* tapclone */
227
228
229/*

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

242 char *name = NULL;
243
244 dev->si_flags &= ~SI_CHEAPCLONE;
245
246 /* allocate driver storage and create device */
247 MALLOC(tp, struct tap_softc *, sizeof(*tp), M_TAP, M_WAITOK | M_ZERO);
248 SLIST_INSERT_HEAD(&taphead, tp, tap_next);
249
222 UID_ROOT, GID_WHEEL, 0600, "%s%d", device_name, unit);
223 if (*dev != NULL)
224 (*dev)->si_flags |= SI_CHEAPCLONE;
225 }
226} /* tapclone */
227
228
229/*

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

242 char *name = NULL;
243
244 dev->si_flags &= ~SI_CHEAPCLONE;
245
246 /* allocate driver storage and create device */
247 MALLOC(tp, struct tap_softc *, sizeof(*tp), M_TAP, M_WAITOK | M_ZERO);
248 SLIST_INSERT_HEAD(&taphead, tp, tap_next);
249
250 unit = dev2unit(dev) & TAPMAXUNIT;
250 unit = dev2unit(dev);
251
252 /* select device: tap or vmnet */
251
252 /* select device: tap or vmnet */
253 if (minor(dev) & VMNET_DEV_MASK) {
253 if (unit & VMNET_DEV_MASK) {
254 name = VMNET;
255 tp->tap_flags |= TAP_VMNET;
256 } else
257 name = TAP;
258
254 name = VMNET;
255 tp->tap_flags |= TAP_VMNET;
256 } else
257 name = TAP;
258
259 unit &= TAPMAXUNIT;
260
259 TAPDEBUG("tapcreate(%s%d). minor = %#x\n", name, unit, minor(dev));
260
261 TAPDEBUG("tapcreate(%s%d). minor = %#x\n", name, unit, minor(dev));
262
261 if (!(dev->si_flags & SI_NAMED))
262 dev = make_dev(&tap_cdevsw, minor(dev), UID_ROOT, GID_WHEEL,
263 0600, "%s%d", name, unit);
264
265 /* generate fake MAC address: 00 bd xx xx xx unit_no */
266 macaddr_hi = htons(0x00bd);
267 bcopy(&macaddr_hi, &tp->arpcom.ac_enaddr[0], sizeof(short));
268 bcopy(&ticks, &tp->arpcom.ac_enaddr[2], sizeof(long));
269 tp->arpcom.ac_enaddr[5] = (u_char)unit;
270
271 /* fill the rest and attach interface */
272 ifp = &tp->tap_if;

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

301static int
302tapopen(dev, flag, mode, td)
303 dev_t dev;
304 int flag;
305 int mode;
306 struct thread *td;
307{
308 struct tap_softc *tp = NULL;
263 /* generate fake MAC address: 00 bd xx xx xx unit_no */
264 macaddr_hi = htons(0x00bd);
265 bcopy(&macaddr_hi, &tp->arpcom.ac_enaddr[0], sizeof(short));
266 bcopy(&ticks, &tp->arpcom.ac_enaddr[2], sizeof(long));
267 tp->arpcom.ac_enaddr[5] = (u_char)unit;
268
269 /* fill the rest and attach interface */
270 ifp = &tp->tap_if;

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

299static int
300tapopen(dev, flag, mode, td)
301 dev_t dev;
302 int flag;
303 int mode;
304 struct thread *td;
305{
306 struct tap_softc *tp = NULL;
309 int unit, error;
307 int error;
310
311 if ((error = suser(td)) != 0)
312 return (error);
313
308
309 if ((error = suser(td)) != 0)
310 return (error);
311
314 unit = dev2unit(dev) & TAPMAXUNIT;
312 if ((dev2unit(dev) & CLONE_UNITMASK) > TAPMAXUNIT)
313 return (ENXIO);
315
314
316
317 tp = dev->si_drv1;
318 if (tp == NULL) {
319 tapcreate(dev);
320 tp = dev->si_drv1;
321 }
322
323 KASSERT(!(tp->tap_flags & TAP_OPEN),
324 ("%s flags is out of sync", tp->tap_if.if_xname));

--- 497 unchanged lines hidden ---
315 tp = dev->si_drv1;
316 if (tp == NULL) {
317 tapcreate(dev);
318 tp = dev->si_drv1;
319 }
320
321 KASSERT(!(tp->tap_flags & TAP_OPEN),
322 ("%s flags is out of sync", tp->tap_if.if_xname));

--- 497 unchanged lines hidden ---