FreeBSD/sys/net/if_tap.c
/*
 * tapifioctl
 *
 * Process an ioctl request on network interface
 */
tapifioctl
Process an ioctl request on network interface
tapifioctl Process an ioctl request on network interface
static int
tapifioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct tap_softc	*tp = ifp->if_softc;
	struct ifreq		*ifr = (struct ifreq *)data;
	struct ifstat		*ifs = NULL;
	struct ifmediareq	*ifmr = NULL;
	int			 dummy, error = 0;
	switch (cmd) {
		case SIOCSIFFLAGS: 
		case SIOCADDMULTI:
		case SIOCDELMULTI:
			break;
		case SIOCGIFMEDIA:
			ifmr = (struct ifmediareq *)data;
			dummy = ifmr->ifm_count;
			ifmr->ifm_count = 1;
			ifmr->ifm_status = IFM_AVALID;
			ifmr->ifm_active = IFM_ETHER;
			if (tp->tap_flags & TAP_OPEN)
				ifmr->ifm_status |= IFM_ACTIVE;
			ifmr->ifm_current = ifmr->ifm_active;
			if (dummy >= 1) {
				int media = IFM_ETHER;
				error = copyout(&media, ifmr->ifm_ulist,
				    sizeof(int));
			}
			break;
		case SIOCSIFMTU:
			ifp->if_mtu = ifr->ifr_mtu;
			break;
		case SIOCGIFSTATUS:
			ifs = (struct ifstat *)data;
			mtx_lock(&tp->tap_mtx);
			if (tp->tap_pid != 0)
				snprintf(ifs->ascii, sizeof(ifs->ascii),
					"\tOpened by PID %d\n", tp->tap_pid);
			else
				ifs->ascii[0] = '\0';
			mtx_unlock(&tp->tap_mtx);
			break;
		default:
			error = ether_ioctl(ifp, cmd, data);
			break;
	}
	return (error);
}
static int tapifioctl ( struct ifnet * ifp , u_long cmd , caddr_t data ) { struct tap_softc * tp = ifp -> if_softc ; struct ifreq * ifr = ( struct ifreq * ) data ; struct ifstat * ifs = NULL ; struct ifmediareq * ifmr = NULL ; int dummy , error = 0 ; switch ( cmd ) { case SIOCSIFFLAGS : case SIOCADDMULTI : case SIOCDELMULTI : break ; case SIOCGIFMEDIA : ifmr = ( struct ifmediareq * ) data ; dummy = ifmr -> ifm_count ; ifmr -> ifm_count = 1 ; ifmr -> ifm_status = IFM_AVALID ; ifmr -> ifm_active = IFM_ETHER ; if ( tp -> tap_flags & TAP_OPEN ) ifmr -> ifm_status |= IFM_ACTIVE ; ifmr -> ifm_current = ifmr -> ifm_active ; if ( dummy >= 1 ) { int media = IFM_ETHER ; error = copyout ( & media , ifmr -> ifm_ulist , sizeof ( int ) ) ; } break ; case SIOCSIFMTU : ifp -> if_mtu = ifr -> ifr_mtu ; break ; case SIOCGIFSTATUS : ifs = ( struct ifstat * ) data ; mtx_lock ( & tp -> tap_mtx ) ; if ( tp -> tap_pid != 0 ) snprintf ( ifs -> ascii , sizeof ( ifs -> ascii ) , " \t \n " , tp -> tap_pid ) ; else ifs -> ascii [ 0 ] = ' \0 ' ; mtx_unlock ( & tp -> tap_mtx ) ; break ; default : error = ether_ioctl ( ifp , cmd , data ) ; break ; } return ( error ) ; }
tapifioctl
 Process an ioctl request on network interface
tapifioctl Process an ioctl request on network interface
/* XXX -- just like vmnet does */