mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Merge tag 'v0.6.0' into develop
This commit is contained in:
commit
088194eb29
5 changed files with 49 additions and 25 deletions
|
@ -47,6 +47,7 @@ struct node
|
|||
char *_name; /**< Singleton: A string used to print to screen. */
|
||||
char *_name_long; /**< Singleton: A string used to print to screen. */
|
||||
|
||||
int no_builtin;
|
||||
int vectorize; /**< Number of messages to send / recv at once (scatter / gather) */
|
||||
int affinity; /**< CPU Affinity of this node */
|
||||
int samplelen; /**< The maximum number of values this node can receive. */
|
||||
|
|
|
@ -91,6 +91,7 @@ struct path {
|
|||
double rate; /**< A timeout for */
|
||||
int enabled; /**< Is this path enabled. */
|
||||
int reverse; /**< This path as a matching reverse path. */
|
||||
int no_builtin; /**< This path should not use built-in hooks by default. */
|
||||
int queuelen; /**< The queue length for each path_destination::queue */
|
||||
int samplelen; /**< Will be calculated based on path::sources.mappings */
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*********************************************************************************/
|
||||
|
||||
#include <jansson.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <netlink/route/qdisc/netem.h>
|
||||
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include <villas/kernel/kernel.h>
|
||||
#include <villas/utils.h>
|
||||
|
||||
static const double max_percent_value = 0xffffffff;
|
||||
|
||||
int tc_netem_parse(struct rtnl_qdisc **netem, json_t *cfg)
|
||||
{
|
||||
|
@ -74,11 +76,14 @@ int tc_netem_parse(struct rtnl_qdisc **netem, json_t *cfg)
|
|||
}
|
||||
|
||||
if (json_delay_correlation) {
|
||||
val = json_integer_value(json_delay_correlation);
|
||||
double dval = json_number_value(json_delay_correlation);
|
||||
|
||||
if (!json_is_real(json_delay_correlation))
|
||||
if (!json_is_number(json_delay_correlation) || dval < 0 || dval > 100)
|
||||
error("Setting 'correlation' must be a positive integer within the range [ 0, 100 ]");
|
||||
|
||||
unsigned *pval = (unsigned *) &val;
|
||||
*pval = (unsigned) rint((dval / 100.) * max_percent_value);
|
||||
|
||||
rtnl_netem_set_delay_correlation(ne, val);
|
||||
}
|
||||
else
|
||||
|
@ -114,29 +119,38 @@ int tc_netem_parse(struct rtnl_qdisc **netem, json_t *cfg)
|
|||
}
|
||||
|
||||
if (json_loss) {
|
||||
val = json_integer_value(json_loss);
|
||||
double dval = json_number_value(json_loss);
|
||||
|
||||
if (!json_is_integer(json_loss) || val < 0 || val > 100)
|
||||
if (!json_is_number(json_loss) || dval < 0 || dval > 100)
|
||||
error("Setting 'loss' must be a positive integer within the range [ 0, 100 ]");
|
||||
|
||||
unsigned *pval = (unsigned *) &val;
|
||||
*pval = (unsigned) rint((dval / 100.) * max_percent_value);
|
||||
|
||||
rtnl_netem_set_loss(ne, val);
|
||||
}
|
||||
|
||||
if (json_duplicate) {
|
||||
val = json_integer_value(json_duplicate);
|
||||
double dval = json_number_value(json_duplicate);
|
||||
|
||||
if (!json_is_integer(json_duplicate) || val < 0 || val > 100)
|
||||
if (!json_is_number(json_duplicate) || dval < 0 || dval > 100)
|
||||
error("Setting 'duplicate' must be a positive integer within the range [ 0, 100 ]");
|
||||
|
||||
unsigned *pval = (unsigned *) &val;
|
||||
*pval = (unsigned) rint((dval / 100.) * max_percent_value);
|
||||
|
||||
rtnl_netem_set_duplicate(ne, val);
|
||||
}
|
||||
|
||||
if (json_corruption) {
|
||||
val = json_integer_value(json_corruption);
|
||||
double dval = json_number_value(json_corruption);
|
||||
|
||||
if (!json_is_integer(json_corruption) || val < 0 || val > 100)
|
||||
if (!json_is_number(json_corruption) || dval < 0 || dval > 100)
|
||||
error("Setting 'corruption' must be a positive integer within the range [ 0, 100 ]");
|
||||
|
||||
unsigned *pval = (unsigned *) &val;
|
||||
*pval = (unsigned) rint((dval / 100.) * max_percent_value);
|
||||
|
||||
rtnl_netem_set_corruption_probability(ne, val);
|
||||
}
|
||||
|
||||
|
|
22
lib/node.c
22
lib/node.c
|
@ -50,6 +50,7 @@ int node_init(struct node *n, struct node_type *vt)
|
|||
|
||||
/* Default values */
|
||||
n->vectorize = 1;
|
||||
n->no_builtin = 0;
|
||||
n->samplelen = DEFAULT_SAMPLELEN;
|
||||
|
||||
list_push(&vt->instances, n);
|
||||
|
@ -57,16 +58,18 @@ int node_init(struct node *n, struct node_type *vt)
|
|||
#ifdef WITH_HOOKS
|
||||
/* Add internal hooks if they are not already in the list */
|
||||
list_init(&n->hooks);
|
||||
for (size_t i = 0; i < list_length(&plugins); i++) {
|
||||
struct plugin *q = (struct plugin *) list_at(&plugins, i);
|
||||
if (!n->no_builtin) {
|
||||
for (size_t i = 0; i < list_length(&plugins); i++) {
|
||||
struct plugin *q = (struct plugin *) list_at(&plugins, i);
|
||||
|
||||
if (q->type != PLUGIN_TYPE_HOOK)
|
||||
continue;
|
||||
if (q->type != PLUGIN_TYPE_HOOK)
|
||||
continue;
|
||||
|
||||
struct hook_type *vt = &q->hook;
|
||||
struct hook_type *vt = &q->hook;
|
||||
|
||||
if (!(vt->flags & HOOK_NODE) || !(vt->flags & HOOK_BUILTIN))
|
||||
continue;
|
||||
|
||||
if ((vt->flags & HOOK_NODE) && (vt->flags & HOOK_BUILTIN)) {
|
||||
int ret;
|
||||
struct hook *h = (struct hook *) alloc(sizeof(struct hook));
|
||||
|
||||
ret = hook_init(h, vt, NULL, n);
|
||||
|
@ -105,11 +108,12 @@ int node_parse(struct node *n, json_t *cfg, const char *name)
|
|||
|
||||
n->name = strdup(name);
|
||||
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: i, s?: i, s?: o }",
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: i, s?: i, s?: o, s?: b }",
|
||||
"type", &type,
|
||||
"vectorize", &n->vectorize,
|
||||
"samplelen", &n->samplelen,
|
||||
"hooks", &json_hooks
|
||||
"hooks", &json_hooks,
|
||||
"no_builtin", &n->no_builtin
|
||||
);
|
||||
if (ret)
|
||||
jerror(&err, "Failed to parse node '%s'", node_name(n));
|
||||
|
|
20
lib/path.c
20
lib/path.c
|
@ -257,16 +257,19 @@ int path_init(struct path *p)
|
|||
#ifdef WITH_HOOKS
|
||||
/* Add internal hooks if they are not already in the list */
|
||||
list_init(&p->hooks);
|
||||
for (size_t i = 0; i < list_length(&plugins); i++) {
|
||||
struct plugin *q = (struct plugin *) list_at(&plugins, i);
|
||||
if (!p->no_builtin) {
|
||||
int ret;
|
||||
|
||||
if (q->type != PLUGIN_TYPE_HOOK)
|
||||
continue;
|
||||
for (size_t i = 0; i < list_length(&plugins); i++) {
|
||||
struct plugin *q = (struct plugin *) list_at(&plugins, i);
|
||||
|
||||
struct hook_type *vt = &q->hook;
|
||||
if (q->type != PLUGIN_TYPE_HOOK)
|
||||
continue;
|
||||
|
||||
if ((vt->flags & HOOK_PATH) && (vt->flags & HOOK_BUILTIN)) {
|
||||
int ret;
|
||||
struct hook_type *vt = &q->hook;
|
||||
|
||||
if (!(vt->flags & HOOK_PATH) || !(vt->flags & HOOK_BUILTIN))
|
||||
continue;
|
||||
|
||||
struct hook *h = (struct hook *) alloc(sizeof(struct hook));
|
||||
|
||||
|
@ -394,12 +397,13 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes)
|
|||
list_init(&sources);
|
||||
list_init(&destinations);
|
||||
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{ s: o, s?: o, s?: o, s?: b, s?: b, s?: i, s?: s, s?: F, s?: o }",
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{ s: o, s?: o, s?: o, s?: b, s?: b, s?: b, s?: i, s?: s, s?: F, s?: o }",
|
||||
"in", &json_in,
|
||||
"out", &json_out,
|
||||
"hooks", &json_hooks,
|
||||
"reverse", &p->reverse,
|
||||
"enabled", &p->enabled,
|
||||
"no_builtin", &p->no_builtin,
|
||||
"queuelen", &p->queuelen,
|
||||
"mode", &mode,
|
||||
"rate", &p->rate,
|
||||
|
|
Loading…
Add table
Reference in a new issue