summaryrefslogtreecommitdiff
path: root/trafgen_proto.h
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-12-18 11:52:49 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-12-21 16:57:53 +0100
commit647b7b76d63f8c847b17495e6ad24dc3b256899f (patch)
tree4d4d488a0f65118cdaf45f381277408b9797364a /trafgen_proto.h
parent44e97b2009dc2bee93f25684b274f458f50ea667 (diff)
trafgen: parser: Allow to set function at field offset
Extend proto field expression to: proto_field[{index}:{len}] = {func} which allows to specify function on the field offset via index and value length (default is 1 - 1 byte). This rule is optional. It was needed to keep of proto_field's copies in packet_dyn->fields instead of original fields which allows to scpecify different functions on the different parts of same field, also the copy of original proto_field allows to set custom length/pkt_offset which makes such field behave as virtual sub-field of the original one with different length/pkt_offset but point to the same piece of header. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_proto.h')
-rw-r--r--trafgen_proto.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/trafgen_proto.h b/trafgen_proto.h
index d4427e6..29d68db 100644
--- a/trafgen_proto.h
+++ b/trafgen_proto.h
@@ -66,7 +66,9 @@ struct proto_field_func {
uint32_t min;
uint32_t max;
int32_t inc;
+ uint16_t offset;
uint32_t val;
+ size_t len;
void (*update_field)(struct proto_field *field);
};
@@ -142,9 +144,6 @@ extern void proto_hdr_field_set_default_dev_ipv6(struct proto_hdr *hdr, uint32_t
extern void proto_field_dyn_apply(struct proto_field *field);
-extern void proto_hdr_field_func_add(struct proto_hdr *hdr, uint32_t fid,
- struct proto_field_func *func);
-
extern struct proto_field *proto_hdr_field_by_id(struct proto_hdr *hdr, uint32_t fid);
@@ -157,4 +156,7 @@ extern uint32_t proto_field_get_u32(struct proto_field *field);
extern void proto_field_set_be16(struct proto_field *field, uint16_t val);
extern void proto_field_set_be32(struct proto_field *field, uint32_t val);
+extern void proto_field_func_add(struct proto_field *field,
+ struct proto_field_func *func);
+
#endif /* TRAFGEN_PROTO_H */