diff options
author | Xavier Simonart <simonartxavier@gmail.com> | 2021-09-11 18:33:25 +0000 |
---|---|---|
committer | Xavier Simonart <simonartxavier@gmail.com> | 2021-09-11 18:44:33 +0000 |
commit | 8793304de2a9ec5035f632152b580ee6113b56f6 (patch) | |
tree | 303178f063acf33fa9e41e88b33187a6186875ef /VNFs/DPPD-PROX/prox_args.c | |
parent | 5815cd749e9c23422e4d04bf00920e493efa4be8 (diff) |
Basic support for ranges in generator
This commit add initial support for ranges.
Ranges can now be specified using an offset and a range, in a similar
way as random. e.g.:
range=2-16001
range_offset=28
The two previous lines will range the src IP address from x.x.0.2 to
x.x.3e.81 in an IPv4 packet.
The range option will write as many bytes as the bytes needed for
the max (2 bytes in the example above), up to 4 bytes.
Runtime, the generator will iterate through the range in a linear way,
starting from the min.
No check are done whether range overlap themselves or whether they
overlap with randoms.
As of now, no support for command line or script option.
Signed-off-by: Xavier Simonart <simonartxavier@gmail.com>
Change-Id: I98a1757998955f48631a5929bd7534481975eedc
Diffstat (limited to 'VNFs/DPPD-PROX/prox_args.c')
-rw-r--r-- | VNFs/DPPD-PROX/prox_args.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/VNFs/DPPD-PROX/prox_args.c b/VNFs/DPPD-PROX/prox_args.c index 9b76a43c..d8c41021 100644 --- a/VNFs/DPPD-PROX/prox_args.c +++ b/VNFs/DPPD-PROX/prox_args.c @@ -1019,6 +1019,18 @@ static int get_core_cfg(unsigned sindex, char *str, void *data) if (STR_EQ(str, "random")) { return parse_str(targ->rand_str[targ->n_rand_str++], pkey, sizeof(targ->rand_str[0])); } + if (STR_EQ(str, "range")) { + int rc = parse_range(&targ->range[targ->n_ranges].min, &targ->range[targ->n_ranges].max, pkey); + targ->n_ranges++; + return rc; + } + if (STR_EQ(str, "range_offset")) { + if (targ->n_ranges == 0) { + set_errf("No range defined previously (use range=...)"); + return -1; + } + return parse_int(&targ->range[targ->n_ranges - 1].offset, pkey); + } if (STR_EQ(str, "rand_offset")) { if (targ->n_rand_str == 0) { set_errf("No random defined previously (use random=...)"); |