FreeBSD/sys/dev/usb/misc/udbp.c
/*
 * Give our ok for a hook to be added...
 * If we are not running this might kick a device into life.
 * Possibly decode information out of the hook name.
 * Add the hook's private info to the hook structure.
 * (if we had some). In this example, we assume that there is a
 * an array of structs, called 'channel' in the private info,
 * one for each active channel. The private
 * pointer of each hook points to the appropriate UDBP_hookinfo struct
 * so that the source of an input packet is easily identified.
 */
Give our ok for a hook to be added
If we are not running this might kick a device into life.
Possibly decode information out of the hook name.
Add the hook's private info to the hook structure.
(if we had some). In this example, we assume that there is a
an array of structs, called 'channel' in the private info,
one for each active channel. The private
pointer of each hook points to the appropriate UDBP_hookinfo struct
so that the source of an input packet is easily identified.
Give our ok for a hook to be added If we are not running this might kick a device into life . Possibly decode information out of the hook name . Add the hook ' s private info to the hook structure . ( if we had some ) . In this example we assume that there is a an array of structs called ' channel ' in the private info one for each active channel . The private pointer of each hook points to the appropriate UDBP_hookinfo struct so that the source of an input packet is easily identified .
static int
ng_udbp_newhook(node_p node, hook_p hook, const char *name)
{
	struct udbp_softc *sc = NG_NODE_PRIVATE(node);
	int32_t error = 0;
	if (strcmp(name, NG_UDBP_HOOK_NAME)) {
		return (EINVAL);
	}
	mtx_lock(&sc->sc_mtx);
	if (sc->sc_hook != NULL) {
		error = EISCONN;
	} else {
		sc->sc_hook = hook;
		NG_HOOK_SET_PRIVATE(hook, NULL);
	}
	mtx_unlock(&sc->sc_mtx);
	return (error);
}
static int ng_udbp_newhook ( node_p node , hook_p hook , const char * name ) { struct udbp_softc * sc = NG_NODE_PRIVATE ( node ) ; int32_t error = 0 ; if ( strcmp ( name , NG_UDBP_HOOK_NAME ) ) { return ( EINVAL ) ; } mtx_lock ( & sc -> sc_mtx ) ; if ( sc -> sc_hook != NULL ) { error = EISCONN ; } else { sc -> sc_hook = hook ; NG_HOOK_SET_PRIVATE ( hook , NULL ) ; } mtx_unlock ( & sc -> sc_mtx ) ; return ( error ) ; }
Give our ok for a hook to be added...
Give our ok for a hook to be added ...