summaryrefslogtreecommitdiff
path: root/trafgen.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-08-13 02:11:10 +0300
committerTobias Klauser <tklauser@distanz.ch>2016-09-21 09:50:06 +0200
commite7dd63060e448bf6667c92a3b774cec0feeff452 (patch)
treec00b4dfe777d74b60cf6c4f6141a45c0a3176f48 /trafgen.c
parent6197f02044e2fe6689b52dad0a0c75bdc0eb185b (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.c')
-rw-r--r--trafgen.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/trafgen.c b/trafgen.c
index b76b5d7..553dfa5 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -619,6 +619,15 @@ static inline void packet_apply_dyn_elements(int idx)
apply_randomizer(idx);
apply_csum16(idx);
}
+
+ if (packet_dyn_has_fields(&packet_dyn[idx])) {
+ uint32_t i;
+
+ for (i = 0; i < packet_dyn[idx].flen; i++)
+ proto_field_dyn_apply(packet_dyn[idx].fields[i]);
+
+ proto_packet_update(idx);
+ }
}
static void xmit_slowpath_or_die(struct ctx *ctx, unsigned int cpu, unsigned long orig_num)