diff --git a/documentation/Configuration.md b/documentation/Configuration.md index 4b7fcb212..bb455e022 100644 --- a/documentation/Configuration.md +++ b/documentation/Configuration.md @@ -35,6 +35,12 @@ This technique, also called 'pinning', improves the determinism of the server by The `priority` setting allows to adjust the scheduling priority of the deamon processes. By default, the daemon uses a real-time optimized FIFO scheduling algorithm. +#### `name` *(integer)* + +By default the `name` of a S2SS instance is equalt to the hostname of the machine it is running on. +Some node types are using this name to identify themselves agains their remotes. +An example is the `ngsi` node type which adds a metadata attribute `source` to its updates. + ## Nodes The node section is a **directory** of nodes (clients) which are connected to the S2SS instance. diff --git a/server/etc/example.conf b/server/etc/example.conf index 804f81e40..0c13b8494 100644 --- a/server/etc/example.conf +++ b/server/etc/example.conf @@ -27,6 +27,9 @@ debug = 5; # The level of verbosity for debug messages stats = 3; # The interval in seconds to print path statistics. # A value of 0 disables the statistics. +name = "s2ss-acs" # The name of this S2SS instance. Might by used by node-types + # to identify themselves (default is the hostname). + ############ Dictionary of nodes ############ diff --git a/server/include/config.h b/server/include/config.h index 9dc96f0f9..0eac018c1 100644 --- a/server/include/config.h +++ b/server/include/config.h @@ -65,10 +65,11 @@ /** Global configuration */ struct settings { - int priority; /**< Process priority (lower is better) */ - int affinity; /**< Process affinity of the server and all created threads */ - int debug; /**< Debug log level */ - double stats; /**< Interval for path statistics. Set to 0 to disable themo disable them. */ + int priority; /**< Process priority (lower is better) */ + int affinity; /**< Process affinity of the server and all created threads */ + int debug; /**< Debug log level */ + double stats; /**< Interval for path statistics. Set to 0 to disable themo disable them. */ + const char *name; /**< Name of the S2SS instance */ }; #endif /* _CONFIG_H_ */ diff --git a/server/src/cfg.c b/server/src/cfg.c index 84c310d00..84d0785c1 100644 --- a/server/src/cfg.c +++ b/server/src/cfg.c @@ -8,6 +8,7 @@ #include #include +#include #include "utils.h" #include "list.h" @@ -87,6 +88,11 @@ 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; diff --git a/server/src/ngsi.c b/server/src/ngsi.c index ed4043dc7..8a9ec3b46 100644 --- a/server/src/ngsi.c +++ b/server/src/ngsi.c @@ -23,6 +23,8 @@ #include "ngsi.h" #include "utils.h" +extern struct settings settings; + static json_t * json_uuid() { char eid[37]; @@ -181,10 +183,10 @@ void ngsi_prepare_context(struct node *n, config_setting_t *mapping) /* Create Metadata for attribute */ json_t *metadatas = json_array(); - json_array_append_new(metadatas, json_pack("{ s: s, s: s, s: s }", - "name", "source", - "type", "string", - "value", "s2ss" + json_array_append_new(metadatas, json_pack("{ s: s, s: s, s: s+ }", + "name", "source", + "type", "string", + "value", "s2ss:", settings.name )); json_array_append_new(metadatas, json_pack("{ s: s, s: s, s: i }", "name", "index",