summaryrefslogtreecommitdiff
path: root/trafgen_parser.y
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2017-06-01 13:12:26 +0300
committerTobias Klauser <tklauser@distanz.ch>2017-06-02 09:15:17 +0200
commit906cb247a831e37665a19e2c6b41b7cfd4c6621b (patch)
tree41068841c4b503cc5c7724a4184093e1e0c08834 /trafgen_parser.y
parent83f11c231626f79433a021c526ffa1ac7521ae36 (diff)
trafgen: proto: Allow to set field with variable length
It is quite tricky to set field value with a variable length (i.e. DNS query name), to make it possible the field needs to be added to header with 'len=0' in that case there will be no any payload allocation, but only while setting the field value the packet will be appended with a real length bytes and after the field needs to be relocated to the right place. Also add 'len' parameter to *_set_bytes(...) functoins to have better control over it. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_parser.y')
-rw-r--r--trafgen_parser.y4
1 files changed, 2 insertions, 2 deletions
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 5a61a3f..b4eedea 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -433,11 +433,11 @@ static void proto_field_expr_eval(void)
else
panic("Invalid value length %zu, can be 1,2 or 4\n", field->len);
} else if (field_expr.type & FIELD_EXPR_MAC) {
- proto_field_set_bytes(field, field_expr.val.mac);
+ proto_field_set_bytes(field, field_expr.val.mac, 6);
} else if (field_expr.type & FIELD_EXPR_IP4_ADDR) {
proto_field_set_u32(field, field_expr.val.ip4_addr.s_addr);
} else if (field_expr.type & FIELD_EXPR_IP6_ADDR) {
- proto_field_set_bytes(field, (uint8_t *)&field_expr.val.ip6_addr.s6_addr);
+ proto_field_set_bytes(field, (uint8_t *)&field_expr.val.ip6_addr.s6_addr, 16);
} else if ((field_expr.type & FIELD_EXPR_INC) ||
(field_expr.type & FIELD_EXPR_RND)) {