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 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) { |
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 |
250 unit = dev2unit(dev); |
251 252 /* select device: tap or vmnet */ |
253 if (unit & VMNET_DEV_MASK) { |
254 name = VMNET; 255 tp->tap_flags |= TAP_VMNET; 256 } else 257 name = TAP; 258 |
259 unit &= TAPMAXUNIT; 260 |
261 TAPDEBUG("tapcreate(%s%d). minor = %#x\n", name, unit, minor(dev)); 262 |
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; |
307 int error; |
308 309 if ((error = suser(td)) != 0) 310 return (error); 311 |
312 if ((dev2unit(dev) & CLONE_UNITMASK) > TAPMAXUNIT) 313 return (ENXIO); |
314 |
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 --- |