MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ng_make_node

Function ng_make_node

lib/ff_ng_base.c:598–638  ·  view source on GitHub ↗

* Instantiate a node of the requested type */

Source from the content-addressed store, hash-verified

596 * Instantiate a node of the requested type
597 */
598int
599ng_make_node(const char *typename, node_p *nodepp)
600{
601 struct ng_type *type;
602 int error;
603
604 /* Check that the type makes sense */
605 if (typename == NULL) {
606 TRAP_ERROR();
607 return (EINVAL);
608 }
609
610 /* Locate the node type. If we fail we return. Do not try to load
611 * module.
612 */
613 if ((type = ng_findtype(typename)) == NULL)
614 return (ENXIO);
615
616 /*
617 * If we have a constructor, then make the node and
618 * call the constructor to do type specific initialisation.
619 */
620 if (type->constructor != NULL) {
621 if ((error = ng_make_node_common(type, nodepp)) == 0) {
622 if ((error = ((*type->constructor)(*nodepp))) != 0) {
623 NG_NODE_UNREF(*nodepp);
624 }
625 }
626 } else {
627 /*
628 * Node has no constructor. We cannot ask for one
629 * to be made. It must be brought into existence by
630 * some external agency. The external agency should
631 * call ng_make_node_common() directly to get the
632 * netgraph part initialised.
633 */
634 TRAP_ERROR();
635 error = EINVAL;
636 }
637 return (error);
638}
639
640/*
641 * Generic node creation. Called by node initialisation for externally

Callers 1

ng_mkpeerFunction · 0.70

Calls 2

ng_findtypeFunction · 0.70
ng_make_node_commonFunction · 0.70

Tested by

no test coverage detected