Add syntax for specify dynamic random function for proto field:
drnd() | drnd(min, max)
EXAMPLE:
{ udp(sport=drnd()) }
{ udp(sport=drnd(1000, 2000)) }
Signed-off-by: Vadim Kochan <[email protected]>
---
trafgen_parser.y | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 7872b7c..31868ac 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -75,6 +75,7 @@ enum field_expr_type_t {
FIELD_EXPR_IP4_ADDR,
FIELD_EXPR_IP6_ADDR,
FIELD_EXPR_INC,
+ FIELD_EXPR_RND,
};
struct proto_field_expr {
@@ -428,6 +429,7 @@ static void proto_field_expr_eval(void)
break;
case FIELD_EXPR_INC:
+ case FIELD_EXPR_RND:
if (field_expr.val.func.min > field_expr.val.func.max)
panic("dinc(): min(%u) can't be greater than max(%u)\n",
field_expr.val.func.min,
field_expr.val.func.max);
@@ -735,6 +737,13 @@ field_expr
field_expr.val.func.inc = $3;
field_expr.val.func.min = $5;
field_expr.val.func.max = $7; }
+ | K_DRND '(' ')' { field_expr.type = FIELD_EXPR_RND;
+ field_expr.val.func.type = PROTO_FIELD_FUNC_RND; }
+ | K_DRND '(' number delimiter number ')'
+ { field_expr.type = FIELD_EXPR_RND;
+ field_expr.val.func.type = PROTO_FIELD_FUNC_RND;
+ field_expr.val.func.min = $3;
+ field_expr.val.func.max = $5; }
;
eth_proto
--
2.6.3
--
You received this message because you are subscribed to the Google Groups
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.