Look up hook by name */
| 853 | |
| 854 | /* Look up hook by name */ |
| 855 | static hook_p |
| 856 | ngs_findhook(node_p node, const char *name) |
| 857 | { |
| 858 | struct ngsock *priv = NG_NODE_PRIVATE(node); |
| 859 | struct hookpriv *hp; |
| 860 | uint32_t h; |
| 861 | |
| 862 | /* |
| 863 | * Microoptimisation for an ng_socket with |
| 864 | * a single hook, which is a common case. |
| 865 | */ |
| 866 | if (node->nd_numhooks == 1) { |
| 867 | hook_p hook; |
| 868 | |
| 869 | hook = LIST_FIRST(&node->nd_hooks); |
| 870 | |
| 871 | if (strcmp(NG_HOOK_NAME(hook), name) == 0) |
| 872 | return (hook); |
| 873 | else |
| 874 | return (NULL); |
| 875 | } |
| 876 | |
| 877 | h = hash32_str(name, HASHINIT) & priv->hmask; |
| 878 | |
| 879 | LIST_FOREACH(hp, &priv->hash[h], next) |
| 880 | if (strcmp(NG_HOOK_NAME(hp->hook), name) == 0) |
| 881 | return (hp->hook); |
| 882 | |
| 883 | return (NULL); |
| 884 | } |
| 885 | |
| 886 | /* |
| 887 | * Incoming messages get passed up to the control socket. |
nothing calls this directly
no test coverage detected