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

Function ng_name2noderef

freebsd/netgraph/ng_base.c:908–938  ·  view source on GitHub ↗

* Find a node by absolute name. The name should NOT end with ':' * The name "." means "this node" and "[xxx]" means "the node * with ID (ie, at address) xxx". * * Returns the node if found, else NULL. * Eventually should add something faster than a sequential search. * Note it acquires a reference on the node so you can be sure it's still * there. */

Source from the content-addressed store, hash-verified

906 * there.
907 */
908node_p
909ng_name2noderef(node_p here, const char *name)
910{
911 node_p node;
912 ng_ID_t temp;
913 int hash;
914
915 /* "." means "this node" */
916 if (strcmp(name, ".") == 0) {
917 NG_NODE_REF(here);
918 return(here);
919 }
920
921 /* Check for name-by-ID */
922 if ((temp = ng_decodeidname(name)) != 0) {
923 return (ng_ID2noderef(temp));
924 }
925
926 /* Find node by name. */
927 hash = hash32_str(name, HASHINIT) & V_ng_name_hmask;
928 NAMEHASH_RLOCK();
929 LIST_FOREACH(node, &V_ng_name_hash[hash], nd_nodes)
930 if (NG_NODE_IS_VALID(node) &&
931 (strcmp(NG_NODE_NAME(node), name) == 0)) {
932 NG_NODE_REF(node);
933 break;
934 }
935 NAMEHASH_RUNLOCK();
936
937 return (node);
938}
939
940/*
941 * Decode an ID name, eg. "[f03034de]". Returns 0 if the

Callers 2

ng_ether_attachFunction · 0.70
ng_path2noderefFunction · 0.70

Calls 4

strcmpFunction · 0.85
hash32_strFunction · 0.85
ng_decodeidnameFunction · 0.70
ng_ID2noderefFunction · 0.70

Tested by

no test coverage detected