FreeBSD/sys/dev/netmap/netmap_freebsd.c
/*
 * Intercept the rx routine in the standard device driver.
 * Second argument is non-zero to intercept, 0 to restore
 */
Intercept the rx routine in the standard device driver.
Second argument is non-zero to intercept, 0 to restore
Intercept the rx routine in the standard device driver . Second argument is non - zero to intercept 0 to restore
int
netmap_catch_rx(struct netmap_generic_adapter *gna, int intercept)
{
	struct netmap_adapter *na = &gna->up.up;
	struct ifnet *ifp = na->ifp;
	if (intercept) {
		if (gna->save_if_input) {
			D("cannot intercept again");
			return EINVAL; 
		}
		gna->save_if_input = ifp->if_input;
		ifp->if_input = generic_rx_handler;
	} else {
		if (!gna->save_if_input){
			D("cannot restore");
			return EINVAL;  
		}
		ifp->if_input = gna->save_if_input;
		gna->save_if_input = NULL;
	}
	return 0;
}
int netmap_catch_rx ( struct netmap_generic_adapter * gna , int intercept ) { struct netmap_adapter * na = & gna -> up . up ; struct ifnet * ifp = na -> ifp ; if ( intercept ) { if ( gna -> save_if_input ) { D ( " " ) ; return EINVAL ; } gna -> save_if_input = ifp -> if_input ; ifp -> if_input = generic_rx_handler ; } else { if ( ! gna -> save_if_input ) { D ( " " ) ; return EINVAL ; } ifp -> if_input = gna -> save_if_input ; gna -> save_if_input = NULL ; } return 0 ; }
Intercept the rx routine in the standard device driver.
Intercept the rx routine in the standard device driver .
/* already set */ /* not saved */