FreeBSD/sys/net/if_tap.c
/*
 * tappoll
 *
 * the poll interface, this is only useful on reads
 * really. the write detect always returns true, write never blocks
 * anyway, it either accepts the packet or drops it
 */
tappoll
the poll interface, this is only useful on reads
really. the write detect always returns true, write never blocks
anyway, it either accepts the packet or drops it
tappoll the poll interface this is only useful on reads really . the write detect always returns true write never blocks anyway it either accepts the packet or drops it
static int
tappoll(struct cdev *dev, int events, struct thread *td)
{
	struct tap_softc	*tp = dev->si_drv1;
	struct ifnet		*ifp = tp->tap_ifp;
	int			 revents = 0;
	TAPDEBUG("%s polling, minor = %#x\n", 
		ifp->if_xname, dev2unit(dev));
	if (events & (POLLIN | POLLRDNORM)) {
		IFQ_LOCK(&ifp->if_snd);
		if (!IFQ_IS_EMPTY(&ifp->if_snd)) {
			TAPDEBUG("%s have data in queue. len = %d, " \
				"minor = %#x\n", ifp->if_xname,
				ifp->if_snd.ifq_len, dev2unit(dev));
			revents |= (events & (POLLIN | POLLRDNORM));
		} else {
			TAPDEBUG("%s waiting for data, minor = %#x\n",
				ifp->if_xname, dev2unit(dev));
			selrecord(td, &tp->tap_rsel);
		}
		IFQ_UNLOCK(&ifp->if_snd);
	}
	if (events & (POLLOUT | POLLWRNORM))
		revents |= (events & (POLLOUT | POLLWRNORM));
	return (revents);
}
static int tappoll ( struct cdev * dev , int events , struct thread * td ) { struct tap_softc * tp = dev -> si_drv1 ; struct ifnet * ifp = tp -> tap_ifp ; int revents = 0 ; TAPDEBUG ( " \n " , ifp -> if_xname , dev2unit ( dev ) ) ; if ( events & ( POLLIN | POLLRDNORM ) ) { IFQ_LOCK ( & ifp -> if_snd ) ; if ( ! IFQ_IS_EMPTY ( & ifp -> if_snd ) ) { TAPDEBUG ( " " " \n " , ifp -> if_xname , ifp -> if_snd . ifq_len , dev2unit ( dev ) ) ; revents |= ( events & ( POLLIN | POLLRDNORM ) ) ; } else { TAPDEBUG ( " \n " , ifp -> if_xname , dev2unit ( dev ) ) ; selrecord ( td , & tp -> tap_rsel ) ; } IFQ_UNLOCK ( & ifp -> if_snd ) ; } if ( events & ( POLLOUT | POLLWRNORM ) ) revents |= ( events & ( POLLOUT | POLLWRNORM ) ) ; return ( revents ) ; }
tappoll
 the poll interface, this is only useful on reads
 really.
tappoll the poll interface this is only useful on reads really .