FreeBSD/sys/netgraph/atm/ng_atm.c
/*
 * A new hook is create that will be connected to the node.
 * Check, whether the name is one of the predefined ones.
 * If not, create a new entry into the vcc list.
 */
A new hook is create that will be connected to the node.
Check, whether the name is one of the predefined ones.
If not, create a new entry into the vcc list.
A new hook is create that will be connected to the node . Check whether the name is one of the predefined ones . If not create a new entry into the vcc list .
static int
ng_atm_newhook(node_p node, hook_p hook, const char *name)
{
	struct priv *priv = NG_NODE_PRIVATE(node);
	struct ngvcc *vcc;
	if (strcmp(name, "input") == 0) {
		priv->input = hook;
		NG_HOOK_SET_RCVDATA(hook, ng_atm_rcvdrop);
		return (0);
	}
	if (strcmp(name, "output") == 0) {
		priv->output = hook;
		NG_HOOK_SET_RCVDATA(hook, ng_atm_rcvdrop);
		return (0);
	}
	if (strcmp(name, "orphans") == 0) {
		priv->orphans = hook;
		NG_HOOK_SET_RCVDATA(hook, ng_atm_rcvdrop);
		return (0);
	}
	vcc = malloc(sizeof(*vcc), M_NETGRAPH, M_NOWAIT | M_ZERO);
	if (vcc == NULL)
		return (ENOMEM);
	vcc->hook = hook;
	NG_HOOK_SET_PRIVATE(hook, vcc);
	LIST_INSERT_HEAD(&priv->vccs, vcc, link);
	if (strcmp(name, "manage") == 0)
		priv->manage = hook;
	return (0);
}
static int ng_atm_newhook ( node_p node , hook_p hook , const char * name ) { struct priv * priv = NG_NODE_PRIVATE ( node ) ; struct ngvcc * vcc ; if ( strcmp ( name , " " ) == 0 ) { priv -> input = hook ; NG_HOOK_SET_RCVDATA ( hook , ng_atm_rcvdrop ) ; return ( 0 ) ; } if ( strcmp ( name , " " ) == 0 ) { priv -> output = hook ; NG_HOOK_SET_RCVDATA ( hook , ng_atm_rcvdrop ) ; return ( 0 ) ; } if ( strcmp ( name , " " ) == 0 ) { priv -> orphans = hook ; NG_HOOK_SET_RCVDATA ( hook , ng_atm_rcvdrop ) ; return ( 0 ) ; } vcc = malloc ( sizeof ( * vcc ) , M_NETGRAPH , M_NOWAIT | M_ZERO ) ; if ( vcc == NULL ) return ( ENOMEM ) ; vcc -> hook = hook ; NG_HOOK_SET_PRIVATE ( hook , vcc ) ; LIST_INSERT_HEAD ( & priv -> vccs , vcc , link ) ; if ( strcmp ( name , " " ) == 0 ) priv -> manage = hook ; return ( 0 ) ; }
A new hook is create that will be connected to the node.
A new hook is create that will be connected to the node .
/*
	 * Allocate a new entry
	 */