* the cdevsw interface is now pretty minimal. */
| 1454 | * the cdevsw interface is now pretty minimal. |
| 1455 | */ |
| 1456 | static int |
| 1457 | tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, |
| 1458 | struct thread *td) |
| 1459 | { |
| 1460 | struct ifreq ifr, *ifrp; |
| 1461 | struct tuntap_softc *tp = dev->si_drv1; |
| 1462 | struct ifnet *ifp = TUN2IFP(tp); |
| 1463 | struct tuninfo *tunp; |
| 1464 | int error, iflags, ival; |
| 1465 | bool l2tun; |
| 1466 | |
| 1467 | l2tun = (tp->tun_flags & TUN_L2) != 0; |
| 1468 | if (l2tun) { |
| 1469 | /* tap specific ioctls */ |
| 1470 | switch(cmd) { |
| 1471 | /* VMware/VMnet port ioctl's */ |
| 1472 | #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ |
| 1473 | defined(COMPAT_FREEBSD4) |
| 1474 | case _IO('V', 0): |
| 1475 | ival = IOCPARM_IVAL(data); |
| 1476 | data = (caddr_t)&ival; |
| 1477 | /* FALLTHROUGH */ |
| 1478 | #endif |
| 1479 | case VMIO_SIOCSIFFLAGS: /* VMware/VMnet SIOCSIFFLAGS */ |
| 1480 | iflags = *(int *)data; |
| 1481 | iflags &= TUN_VMIO_FLAG_MASK; |
| 1482 | iflags &= ~IFF_CANTCHANGE; |
| 1483 | iflags |= IFF_UP; |
| 1484 | |
| 1485 | TUN_LOCK(tp); |
| 1486 | ifp->if_flags = iflags | |
| 1487 | (ifp->if_flags & IFF_CANTCHANGE); |
| 1488 | TUN_UNLOCK(tp); |
| 1489 | |
| 1490 | return (0); |
| 1491 | case SIOCGIFADDR: /* get MAC address of the remote side */ |
| 1492 | TUN_LOCK(tp); |
| 1493 | bcopy(&tp->tun_ether.octet, data, |
| 1494 | sizeof(tp->tun_ether.octet)); |
| 1495 | TUN_UNLOCK(tp); |
| 1496 | |
| 1497 | return (0); |
| 1498 | case SIOCSIFADDR: /* set MAC address of the remote side */ |
| 1499 | TUN_LOCK(tp); |
| 1500 | bcopy(data, &tp->tun_ether.octet, |
| 1501 | sizeof(tp->tun_ether.octet)); |
| 1502 | TUN_UNLOCK(tp); |
| 1503 | |
| 1504 | return (0); |
| 1505 | case TAPSVNETHDR: |
| 1506 | ival = *(int *)data; |
| 1507 | if (ival != 0 && |
| 1508 | ival != sizeof(struct virtio_net_hdr) && |
| 1509 | ival != sizeof(struct virtio_net_hdr_mrg_rxbuf)) { |
| 1510 | return (EINVAL); |
| 1511 | } |
| 1512 | TUN_LOCK(tp); |
| 1513 | tun_vnethdr_set(ifp, ival); |
nothing calls this directly
no test coverage detected