1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

changed signature of node type initialization

This commit is contained in:
Steffen Vogel 2015-12-11 12:35:32 +01:00
parent eddf3abe95
commit 3b91ba705f
14 changed files with 49 additions and 38 deletions

View file

@ -49,7 +49,7 @@ struct gtfpga {
typedef void(*log_cb_t)(char *, ...);
/** @see node_vtable::init */
int gtfpga_init(int argc, char * argv[], struct settings *set);
int gtfpga_init(int argc, char * argv[], config_setting_t *cfg);
/** @see node_vtable::deinit */
int gtfpga_deinit();

View file

@ -63,7 +63,7 @@ struct ngsi {
*
* @see node_vtable::init
*/
int ngsi_init(int argc, char *argv[], struct settings *set);
int ngsi_init(int argc, char *argv[], config_setting_t *cfg);
/** Free global NGSI settings and unmaps shared memory regions.
*

View file

@ -34,6 +34,9 @@ __attribute__((constructor)) static void __register() { \
extern struct list node_types;
/* Forward declarations */
struct config_setting_t *cfg;
/** C++ like vtable construct for node_types */
struct node_type {
const char *name; /**< The unique name of this node. This must be allways the first member! */
@ -48,11 +51,11 @@ struct 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 set Global settings.
* @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[], struct settings *set);
int (*init)(int argc, char * argv[], config_setting_t *cfg);
/** Global de-initialization per node type.
*
@ -181,7 +184,7 @@ struct node
*
* @see node_type::init
*/
int node_init(int argc, char *argv[], struct settings *set);
int node_init(int argc, char *argv[], config_setting_t *cfg);
/** De-initialize node type subsystems.
*

View file

@ -65,7 +65,7 @@ struct opal {
*
* @see node_vtable::init
*/
int opal_init(int argc, char *argv[], struct settings *set);
int opal_init(int argc, char *argv[], config_setting_t *cfg);
/** Free global OPAL settings and unmaps shared memory regions.
*

View file

@ -60,7 +60,7 @@ struct socket {
/** @see node_vtable::init */
int socket_init(int argc, char *argv[], struct settings *set);
int socket_init(int argc, char *argv[], config_setting_t *cfg);
/** @see node_vtable::deinit */
int socket_deinit();

View file

@ -36,7 +36,7 @@ struct websocket {
};
/** @see node_vtable::init */
int websocket_init(int argc, char * argv[], struct settings *set);
int websocket_init(int argc, char * argv[], config_setting_t *cfg);
/** @see node_vtable::deinit */
int websocket_deinit();

View file

@ -29,7 +29,7 @@ static void gtfpga_debug(char *msg, ...) {
va_end(ap);
}
int gtfpga_init(int argc, char * argv[], struct settings *set)
int gtfpga_init(int argc, char * argv[], config_setting_t *cfg)
{
if (check_root())
error("The gtfpga node-type requires superuser privileges!");

View file

@ -21,6 +21,7 @@
#include <jansson.h>
#include <math.h>
#include <pthread.h>
#include <unistd.h>
#include "ngsi.h"
#include "utils.h"
@ -409,10 +410,17 @@ out: json_decref(request);
return ret;
}
int ngsi_init(int argc, char *argv[], struct settings *set)
int ngsi_init(int argc, char *argv[], config_setting_t *cfg)
{
name = strdup(set->name);
const char *tname;
if (config_setting_lookup_string(cfg, "name", &tname)) {
name = strdup(tname);
}
else {
name = alloc(128); /** @todo missing free */
gethostname((char *) name, 128);
}
return curl_global_init(CURL_GLOBAL_ALL);
}

View file

@ -65,10 +65,14 @@ int socket_init(int argc, char * argv[], struct settings *set)
list_push(&i->sockets, s);
}
/** @todo Improve mapping of NIC IRQs per path */
int affinity;
if (!config_setting_lookup_int(cfg, "affinity", &affinity))
affinity = -1;
list_foreach(struct interface *i, &interfaces)
if_start(i, set->affinity);
if_start(i, affinity);
return 0;
}

View file

@ -14,9 +14,8 @@
#include <string.h>
#include <signal.h>
#include <libwebsockets.h>
#include <config.h>
#include <libconfig.h>
#include "websocket.h"
#include "timing.h"
@ -256,23 +255,26 @@ static void * server_thread(void *ctx)
return NULL;
}
int websocket_init(int argc, char * argv[], struct settings *set)
int websocket_init(int argc, char * argv[], config_setting_t *cfg)
{
config_setting_t *cfg_http;
lws_set_log_level((1 << LLL_COUNT) - 1, logger);
/* Parse global config */
/*
config_setting_lookup_string(cfg, "ssl_cert", &global.ssl_cert);
config_setting_lookup_string(cfg, "ssl_private_key", &global.ssl_private_key);
config_setting_lookup_string(cfg, "htdocs", &global.htdocs);
if (!config_setting_lookup_int(cfg, "port", &global.port))
port = 80;
*/
/* @todo Fake settings */
global.port = 8080;
global.htdocs = "/s2ss/contrib/websocket";
cfg_http = config_lookup_from(cfg, "http");
if (cfg_http) {
config_setting_lookup_string(cfg_http, "ssl_cert", &global.ssl_cert);
config_setting_lookup_string(cfg_http, "ssl_private_key", &global.ssl_private_key);
config_setting_lookup_string(cfg_http, "htdocs", &global.htdocs);
config_setting_lookup_int(cfg_http, "port", &global.port);
}
/* Default settings */
if (!global.port)
global.port = 80;
if (!global.htdocs)
global.htdocs = "/s2ss/contrib/websocket";
/* Initialize list of nodes */
list_init(&global.nodes, NULL);

View file

@ -8,7 +8,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "utils.h"
#include "list.h"
@ -77,11 +76,6 @@ int config_parse_global(config_setting_t *cfg, struct settings *set)
config_setting_lookup_int(cfg, "debug", &set->debug);
config_setting_lookup_float(cfg, "stats", &set->stats);
if (!config_setting_lookup_string(cfg, "name", &set->name)) {
set->name = alloc(128); /** @todo missing free */
gethostname((char *) set->name, 128);
}
log_setlevel(set->debug);
return 0;

View file

@ -158,7 +158,7 @@ int main(int argc, char *argv[])
if (!node)
error("Node '%s' does not exist!", argv[2]);
node_init(argc-optind, argv+optind, &settings);
node_init(argc-optind, argv+optind, config_root_setting(&config));
recv_pool = alloc(sizeof(struct msg) * node->combine);
send_pool = alloc(sizeof(struct msg) * node->combine);

View file

@ -153,7 +153,7 @@ int main(int argc, char *argv[])
config_parse(configfile, &config, &settings, &nodes, &paths);
info("Initialize node types");
node_init(argc, argv, &settings);
node_init(argc, argv, config_root_setting(&config));
info("Starting nodes");
list_foreach(struct node *n, &nodes) {

View file

@ -94,7 +94,7 @@ int main(int argc, char *argv[])
if (!node)
error("There's no node with the name '%s'", argv[3]);
node_init(argc-3, argv+3, &settings);
node_init(argc-3, argv+3, config_root_setting(&config));
node_start(node);
/* Parse Arguments */