diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2016-08-13 02:11:10 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-09-21 09:50:06 +0200 |
commit | e7dd63060e448bf6667c92a3b774cec0feeff452 (patch) | |
tree | c00b4dfe777d74b60cf6c4f6141a45c0a3176f48 /trafgen_proto.h | |
parent | 6197f02044e2fe6689b52dad0a0c75bdc0eb185b (diff) |
trafgen: proto: Update field value at runtime
Add basic infrastructure for update proto field value at runtime by
dynamic field function.
Extended 'struct packet_dyn' with proto fields which has dynamically
changing values at runtime.
Added 'field_changed' callback for proto header which may be used for
check if csum updating is needed. This callback is called after field
was changed at runtime.
Added 'packet_update' callback to let proto header know when to apply
final proto header changes at runtime (e.g. - csum update).
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.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/trafgen_proto.h b/trafgen_proto.h index 9716aa2..6cdc51f 100644 --- a/trafgen_proto.h +++ b/trafgen_proto.h @@ -27,6 +27,7 @@ enum proto_layer { PROTO_L4, }; +struct proto_field; struct proto_hdr; struct proto_ops { @@ -35,7 +36,9 @@ struct proto_ops { void (*header_init)(struct proto_hdr *hdr); void (*header_finish)(struct proto_hdr *hdr); + void (*field_changed)(struct proto_field *field); void (*packet_finish)(struct proto_hdr *hdr); + void (*packet_update)(struct proto_hdr *hdr); void (*set_next_proto)(struct proto_hdr *hdr, enum proto_id pid); }; @@ -48,6 +51,10 @@ struct proto_hdr { size_t len; }; +struct proto_field_func { + void (*update_field)(struct proto_field *field); +}; + struct proto_field { uint32_t id; size_t len; @@ -56,6 +63,7 @@ struct proto_field { /* might be negative (e.g. VLAN TPID field) */ int16_t offset; + struct proto_field_func func; bool is_set; uint16_t pkt_offset; struct proto_hdr *hdr; @@ -67,6 +75,8 @@ extern void proto_ops_register(const struct proto_ops *ops); extern struct proto_hdr *proto_header_push(enum proto_id pid); extern void proto_header_finish(struct proto_hdr *hdr); extern void proto_packet_finish(void); +extern void proto_packet_update(uint32_t idx); + extern struct proto_hdr *proto_lower_default_add(struct proto_hdr *hdr, enum proto_id pid); @@ -113,4 +123,9 @@ extern void proto_field_set_default_dev_ipv4(struct proto_hdr *hdr, uint32_t fid extern void proto_field_set_dev_ipv6(struct proto_hdr *hdr, uint32_t fid); extern void proto_field_set_default_dev_ipv6(struct proto_hdr *hdr, uint32_t fid); +extern void proto_field_dyn_apply(struct proto_field *field); + +extern void proto_field_func_add(struct proto_hdr *hdr, uint32_t fid, + struct proto_field_func *func); + #endif /* TRAFGEN_PROTO_H */ |