* We allow any hook to be connected to the node. * There is no per-hook private information though. */
| 814 | * There is no per-hook private information though. |
| 815 | */ |
| 816 | static int |
| 817 | ngs_newhook(node_p node, hook_p hook, const char *name) |
| 818 | { |
| 819 | struct ngsock *const priv = NG_NODE_PRIVATE(node); |
| 820 | struct hookpriv *hp; |
| 821 | uint32_t h; |
| 822 | |
| 823 | hp = malloc(sizeof(*hp), M_NETGRAPH_SOCK, M_NOWAIT); |
| 824 | if (hp == NULL) |
| 825 | return (ENOMEM); |
| 826 | if (node->nd_numhooks * 2 > priv->hmask) |
| 827 | ngs_rehash(node); |
| 828 | hp->hook = hook; |
| 829 | h = hash32_str(name, HASHINIT) & priv->hmask; |
| 830 | LIST_INSERT_HEAD(&priv->hash[h], hp, next); |
| 831 | NG_HOOK_SET_PRIVATE(hook, hp); |
| 832 | |
| 833 | return (0); |
| 834 | } |
| 835 | |
| 836 | /* |
| 837 | * If only one hook, allow read(2) and write(2) to work. |
nothing calls this directly
no test coverage detected