diff --git a/include/villas/node_type.h b/include/villas/node_type.h index cc4e35674..d0feab55f 100644 --- a/include/villas/node_type.h +++ b/include/villas/node_type.h @@ -17,6 +17,7 @@ /* Forward declarations */ struct node; +struct super_node; struct sample; /** C++ like vtable construct for node_types */ @@ -32,13 +33,10 @@ struct node_type { * * This callback is invoked once per node-type. * - * @param argc Number of arguments passed to the server executable (see main()). - * @param argv Array of arguments passed to the server executable (see main()). - * @param cfg Root libconfig object of global configuration file. * @retval 0 Success. Everything went well. * @retval <0 Error. Something went wrong. */ - int (*init)(int argc, char *argv[], config_setting_t *cfg); + int (*init)(struct super_node *sn); /** Global de-initialization per node type. * @@ -135,7 +133,7 @@ struct node_type { * * @see node_type::init */ -int node_type_start(struct node_type *vt, int argc, char *argv[], config_setting_t *cfg); +int node_type_start(struct node_type *vt, struct super_node *sn); /** De-initialize node type subsystems. * diff --git a/include/villas/nodes/fpga.h b/include/villas/nodes/fpga.h index 6c15c51ce..fecc3fbe0 100644 --- a/include/villas/nodes/fpga.h +++ b/include/villas/nodes/fpga.h @@ -38,7 +38,7 @@ struct fpga { }; /** @see node_vtable::init */ -int fpga_init(int argc, char *argv[], config_setting_t *cfg); +int fpga_init(struct super_node *sn); /** @see node_vtable::deinit */ int fpga_deinit(); diff --git a/include/villas/nodes/ngsi.h b/include/villas/nodes/ngsi.h index aedb2d1b0..3b8b2ac0f 100644 --- a/include/villas/nodes/ngsi.h +++ b/include/villas/nodes/ngsi.h @@ -52,7 +52,7 @@ struct ngsi { * * @see node_vtable::init */ -int ngsi_init(int argc, char *argv[], config_setting_t *cfg); +int ngsi_init(struct super_node *sn); /** Free global NGSI settings and unmaps shared memory regions. * diff --git a/include/villas/nodes/opal.h b/include/villas/nodes/opal.h index 4b07fb0d1..4effae1b1 100644 --- a/include/villas/nodes/opal.h +++ b/include/villas/nodes/opal.h @@ -42,7 +42,7 @@ struct opal { * * @see node_vtable::init */ -int opal_init(int argc, char *argv[], config_setting_t *cfg); +int opal_init(struct super_node *sn); /** Free global OPAL settings and unmaps shared memory regions. * diff --git a/include/villas/nodes/socket.h b/include/villas/nodes/socket.h index cc1db7628..0d95bd844 100644 --- a/include/villas/nodes/socket.h +++ b/include/villas/nodes/socket.h @@ -58,7 +58,7 @@ struct socket { /** @see node_vtable::init */ -int socket_init(int argc, char *argv[], config_setting_t *cfg); +int socket_init(struct super_node *sn); /** @see node_vtable::deinit */ int socket_deinit(); diff --git a/include/villas/nodes/websocket.h b/include/villas/nodes/websocket.h index 1d512eae9..79b63a722 100644 --- a/include/villas/nodes/websocket.h +++ b/include/villas/nodes/websocket.h @@ -64,7 +64,7 @@ struct websocket_destination { int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len); /** @see node_vtable::init */ -int websocket_init(int argc, char *argv[], config_setting_t *cfg); +int websocket_init(struct super_node *sn); /** @see node_vtable::deinit */ int websocket_deinit(); diff --git a/lib/node_type.c b/lib/node_type.c index f92d05bc2..b5a47401a 100644 --- a/lib/node_type.c +++ b/lib/node_type.c @@ -5,7 +5,6 @@ *********************************************************************************/ #include -#include #include "sample.h" #include "node.h" @@ -14,7 +13,7 @@ #include "config.h" #include "plugin.h" -int node_type_start(struct node_type *vt, int argc, char *argv[], config_setting_t *cfg) +int node_type_start(struct node_type *vt, struct super_node *sn) { int ret; @@ -23,7 +22,7 @@ int node_type_start(struct node_type *vt, int argc, char *argv[], config_setting info("Initializing " YEL("%s") " node type which is used by %zu nodes", plugin_name(vt), list_length(&vt->instances)); { INDENT - ret = vt->init ? vt->init(argc, argv, cfg) : 0; + ret = vt->init ? vt->init(sn) : 0; } if (ret == 0) diff --git a/lib/nodes/fpga.c b/lib/nodes/fpga.c index 5065814f1..88da3e7a3 100644 --- a/lib/nodes/fpga.c +++ b/lib/nodes/fpga.c @@ -30,20 +30,21 @@ void fpga_dump(struct fpga *f) fpga_card_dump(c); } -int fpga_init(int argc, char *argv[], config_setting_t *cfg) +int fpga_init(struct super_node *sn) { int ret; - config_setting_t *cfg_fpgas; + config_setting_t *cfg, *cfg_fpgas; ret = pci_init(&pci); if (ret) - cerror(cfg, "Failed to initialize PCI sub-system"); + error("Failed to initialize PCI sub-system"); ret = vfio_init(&vc); if (ret) - cerror(cfg, "Failed to initiliaze VFIO sub-system"); + error("Failed to initiliaze VFIO sub-system"); /* Parse FPGA configuration */ + cfg = config_root_setting(&sn->cfg); cfg_fpgas = config_setting_lookup(cfg, "fpgas"); if (!cfg_fpgas) cerror(cfg, "Config file is missing 'fpgas' section"); diff --git a/lib/nodes/ngsi.c b/lib/nodes/ngsi.c index 8dea91e6b..c8b12348d 100644 --- a/lib/nodes/ngsi.c +++ b/lib/nodes/ngsi.c @@ -368,8 +368,12 @@ out: json_decref(request); return ret; } -int ngsi_init(int argc, char *argv[], config_setting_t *cfg) +int ngsi_init(struct super_node *sn) { + config_setting_t *cfg; + + cfg = config_root_setting(&sn->cfg); + const char *tname; if (config_setting_lookup_string(cfg, "name", &tname)) { name = strdup(tname); diff --git a/lib/nodes/opal.c b/lib/nodes/opal.c index 3672b4dca..3e562996e 100644 --- a/lib/nodes/opal.c +++ b/lib/nodes/opal.c @@ -25,18 +25,18 @@ static Opal_GenAsyncParam_Ctrl params; /** String and Float parameters, provided static pthread_mutex_t lock; /** Big Global Lock for libOpalAsync API */ -int opal_init(int argc, char *argv[], config_setting_t *cfg) +int opal_init(struct super_node *sn) { int err; - if (argc != 4) + if (sn->cli.argc != 4) return -1; pthread_mutex_init(&lock, NULL); - async_shmem_name = argv[1]; - async_shmem_size = atoi(argv[2]); - print_shmem_name = argv[3]; + async_shmem_name = sn->cli.argv[1]; + async_shmem_size = atoi(sn->cli.argv[2]); + print_shmem_name = sn->cli.argv[3]; /* Enable the OpalPrint function. This prints to the OpalDisplay. */ err = OpalSystemCtrl_Register(print_shmem_name); diff --git a/lib/nodes/socket.c b/lib/nodes/socket.c index 678bc1be4..2b2c374a8 100644 --- a/lib/nodes/socket.c +++ b/lib/nodes/socket.c @@ -36,7 +36,7 @@ static struct plugin p; /* Private static storage */ struct list interfaces; -int socket_init(int argc, char *argv[], config_setting_t *cfg) +int socket_init(struct super_node *sn) { int ret; diff --git a/src/fpga.c b/src/fpga.c index 6850d08ec..e7bce9fe9 100644 --- a/src/fpga.c +++ b/src/fpga.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) memory_init(sn.hugepages); /* Initialize VILLASfpga card */ - ret = fpga_init(argc, argv, config_root_setting(&sn.cfg)); + ret = fpga_init(&sn); if (ret) error("Failed to initialize FPGA card"); diff --git a/src/pipe.c b/src/pipe.c index 3403397d1..2635b585c 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -231,7 +231,7 @@ int main(int argc, char *argv[]) if (reverse) node_reverse(node); - ret = node_type_start(node->_vt, argc, argv, config_root_setting(&sn.cfg)); + ret = node_type_start(node->_vt, &sn); if (ret) error("Failed to intialize node type: %s", node_name(node)); diff --git a/src/test-rtt.c b/src/test-rtt.c index 5a2a65414..09c3cc714 100644 --- a/src/test-rtt.c +++ b/src/test-rtt.c @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if (!node) error("There's no node with the name '%s'", argv[3]); - node_type_start(node->_vt, argc-3, argv+3, config_root_setting(&sn.cfg)); + node_type_start(node->_vt, &sn); node_start(node); /* Parse Arguments */