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

Function ngs_findhook

freebsd/netgraph/ng_socket.c:855–884  ·  view source on GitHub ↗

Look up hook by name */

Source from the content-addressed store, hash-verified

853
854/* Look up hook by name */
855static hook_p
856ngs_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.

Callers

nothing calls this directly

Calls 2

strcmpFunction · 0.85
hash32_strFunction · 0.85

Tested by

no test coverage detected