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

Function ng_make_node

freebsd/netgraph/ng_base.c:594–634  ·  view source on GitHub ↗

* Instantiate a node of the requested type */

Source from the content-addressed store, hash-verified

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