MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ngs_newhook

Function ngs_newhook

freebsd/netgraph/ng_socket.c:816–834  ·  view source on GitHub ↗

* We allow any hook to be connected to the node. * There is no per-hook private information though. */

Source from the content-addressed store, hash-verified

814 * There is no per-hook private information though.
815 */
816static int
817ngs_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.

Callers

nothing calls this directly

Calls 3

mallocFunction · 0.85
ngs_rehashFunction · 0.85
hash32_strFunction · 0.85

Tested by

no test coverage detected