Lines Matching refs:hook

90 static void	ng_disconnect_hook(hook_p hook);
456 hook_p hook; in ng_cutlinks() local
466 while ((hook = LIST_FIRST(&node->hooks)) != NULL) in ng_cutlinks()
467 ng_destroy_hook(hook); in ng_cutlinks()
688 ng_unref_hook(hook_p hook) in ng_unref_hook() argument
691 if (--hook->refs == 0) in ng_unref_hook()
692 kfree(hook, M_NETGRAPH); in ng_unref_hook()
702 hook_p hook; in ng_add_hook() local
716 hook = kmalloc(sizeof(*hook), M_NETGRAPH, M_NOWAIT | M_ZERO); in ng_add_hook()
717 if (hook == NULL) { in ng_add_hook()
721 hook->refs = 1; in ng_add_hook()
722 hook->flags = HK_INVALID; in ng_add_hook()
723 hook->node = node; in ng_add_hook()
728 if ((error = (*node->type->newhook)(node, hook, name)) != 0) in ng_add_hook()
735 LIST_INSERT_HEAD(&node->hooks, hook, hooks); in ng_add_hook()
739 hook->name = kmalloc(strlen(name) + 1, M_NETGRAPH, M_NOWAIT); in ng_add_hook()
740 if (hook->name == NULL) { in ng_add_hook()
742 LIST_REMOVE(hook, hooks); in ng_add_hook()
745 hook->node = NULL; in ng_add_hook()
747 ng_unref_hook(hook); /* this frees the hook */ in ng_add_hook()
750 strcpy(hook->name, name); in ng_add_hook()
752 *hookp = hook; in ng_add_hook()
794 hook_p hook; in ng_findhook() local
798 LIST_FOREACH(hook, &node->hooks, hooks) { in ng_findhook()
799 if (hook->name != NULL in ng_findhook()
800 && strcmp(hook->name, name) == 0 in ng_findhook()
801 && (hook->flags & HK_INVALID) == 0) in ng_findhook()
802 return (hook); in ng_findhook()
815 ng_destroy_hook(hook_p hook) in ng_destroy_hook() argument
817 hook_p peer = hook->peer; in ng_destroy_hook()
819 hook->flags |= HK_INVALID; /* as soon as possible */ in ng_destroy_hook()
822 hook->peer = NULL; in ng_destroy_hook()
826 ng_disconnect_hook(hook); in ng_destroy_hook()
837 ng_disconnect_hook(hook_p hook) in ng_disconnect_hook() argument
839 node_p node = hook->node; in ng_disconnect_hook()
845 LIST_REMOVE(hook, hooks); in ng_disconnect_hook()
852 (*node->type->disconnect) (hook); in ng_disconnect_hook()
855 if (hook->name) in ng_disconnect_hook()
856 kfree(hook->name, M_NETGRAPH); in ng_disconnect_hook()
857 hook->node = NULL; /* may still be referenced elsewhere */ in ng_disconnect_hook()
858 ng_unref_hook(hook); in ng_disconnect_hook()
935 hook_p hook; in ng_mkpeer() local
939 if ((error = ng_add_hook(node, name, &hook))) in ng_mkpeer()
953 ng_destroy_hook(hook); in ng_mkpeer()
958 ng_destroy_hook(hook); in ng_mkpeer()
966 if ((error = ng_connect(hook, hook2))) in ng_mkpeer()
978 hook_p hook; in ng_con_nodes() local
981 if ((error = ng_add_hook(node, name, &hook))) in ng_con_nodes()
984 ng_destroy_hook(hook); in ng_con_nodes()
987 return (ng_connect(hook, hook2)); in ng_con_nodes()
1009 char *node, *path, *hook; in ng_path_parse() local
1053 for (hook = path, k = 0; path[k]; k++) in ng_path_parse()
1055 hook = NULL; in ng_path_parse()
1059 path = hook = NULL; in ng_path_parse()
1067 *hookp = hook; in ng_path_parse()
1118 hook_p hook; in ng_path2node() local
1138 hook = ng_findhook(node, segment); in ng_path2node()
1141 if (hook == NULL in ng_path2node()
1142 || hook->peer == NULL in ng_path2node()
1143 || (hook->flags & HK_INVALID) != 0) { in ng_path2node()
1149 node = hook->peer->node; in ng_path2node()
1307 hook_p hook; in ng_generic_msg() local
1314 if ((hook = ng_findhook(here, rmh->ourhook)) != NULL) in ng_generic_msg()
1315 ng_destroy_hook(hook); in ng_generic_msg()
1350 hook_p hook; in ng_generic_msg() local
1374 LIST_FOREACH(hook, &here->hooks, hooks) { in ng_generic_msg()
1382 if ((hook->flags & HK_INVALID) != 0) in ng_generic_msg()
1384 strlcpy(link->ourhook, hook->name, NG_HOOKSIZ); in ng_generic_msg()
1385 strlcpy(link->peerhook, hook->peer->name, NG_HOOKSIZ); in ng_generic_msg()
1386 if (hook->peer->node->name != NULL) in ng_generic_msg()
1388 hook->peer->node->name, NG_NODESIZ); in ng_generic_msg()
1390 hook->peer->node->type->name, NG_TYPESIZ); in ng_generic_msg()
1391 link->nodeinfo.id = ng_node2ID(hook->peer->node); in ng_generic_msg()
1392 link->nodeinfo.hooks = hook->peer->node->numhooks; in ng_generic_msg()
1678 ng_send_data(hook_p hook, struct mbuf *m, meta_p meta) in ng_send_data() argument
1684 if (hook && (hook->flags & HK_INVALID) == 0) { in ng_send_data()
1685 rcvdata = hook->peer->node->type->rcvdata; in ng_send_data()
1687 error = (*rcvdata)(hook->peer, m, meta); in ng_send_data()
1705 ng_send_dataq(hook_p hook, struct mbuf *m, meta_p meta) in ng_send_dataq() argument
1711 if (hook && (hook->flags & HK_INVALID) == 0) { in ng_send_dataq()
1712 rcvdataq = hook->peer->node->type->rcvdataq; in ng_send_dataq()
1714 error = (*rcvdataq)(hook->peer, m, meta); in ng_send_dataq()
1716 error = ng_send_data(hook, m, meta); in ng_send_dataq()
1926 ng_queue_data(hook_p hook, struct mbuf *m, meta_p meta) in ng_queue_data() argument
1930 if (hook == NULL) { in ng_queue_data()
1942 q->body.data.da_hook = hook; in ng_queue_data()
1946 hook->refs++; /* don't let it go away while on the queue */ in ng_queue_data()
2018 hook_p hook; in ngintr() local
2047 hook = ngq->body.data.da_hook; in ngintr()
2051 NG_SEND_DATAQ(error, hook, m, meta); in ngintr()
2052 ng_unref_hook(hook); in ngintr()