From 208db0e4a3ceb21a65527d87198cf6f49c4b06dc Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Sat, 13 Aug 2016 02:11:11 +0300 Subject: trafgen: proto: Increment proto field at runtime Implement incrementing of proto field at runtime with min & max parameters, by default if the 'min' parameter is not specified then original value is used. For fields which len is greater than 4 - last 4 bytes are incremented as 4 byte value (this trick is used to increment MAC/IPv6 addresses). Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- trafgen_proto.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'trafgen_proto.h') diff --git a/trafgen_proto.h b/trafgen_proto.h index 6cdc51f..0a1c3de 100644 --- a/trafgen_proto.h +++ b/trafgen_proto.h @@ -51,7 +51,18 @@ struct proto_hdr { size_t len; }; +enum proto_field_func_t { + PROTO_FIELD_FUNC_INC = 1 << 0, + PROTO_FIELD_FUNC_MIN = 1 << 1, +}; + struct proto_field_func { + enum proto_field_func_t type; + uint32_t min; + uint32_t max; + int32_t inc; + uint32_t val; + void (*update_field)(struct proto_field *field); }; -- cgit v1.2.3-54-g00ecf