Implemented 'dinc' and 'drnd' functions to be used for proto fields, and generate values at runtime. Parsing of proto field values for unified to make extending of field functions more easier w/o copy/paste similar rules for each proto field. Instead of that the field_expr struct is used to keep specified field and value which might be a func in the following form:
<proto>(<field>=<func>()) Fields which has dynamic functions are stored in packet_dyn structure and generated after each packet run. After fields are updated the L3/L4 headers updates its csum if it is needed. Changed field lookup logic to make field set/get operations a little bit faster by using field id as index in the array, as usually fields are defined regarding its index. Example: { eth(sa=11:22:33:44:55:66, sa=dinc()), udp(sp=drnd(), dp=drnd()) } v2: 1) Removed cast to (struct proto_field **) in proto_field_func_setup(...) when add dynamic field to packet_dyn. 2) Fixed order or parameters of dinc(min, max, step) to look like low level dinc function. 3) Replace ~0 by UINT32_MAX. 4) Calculate new random value in field_rnd_func(...) in 'for' body instead of increment statement. 5) Assign 'val' variable on declaration in field_inc_func(...). 6) Simplify & fix value incrementing between specified interval in field_inc(...). 7) Use local 'max, val, min, inc' variables instead of pointers in field_inc(...). 8) Add separate commit to add new proto_upper_header(...) function. 9) Add separate commit to use index for get lower/upper header 10) Add new commit to simplify Jasper's UDP example with proto functions. v3: 1) Add new commit to introduce logic for update proto fields at runtime. 2) Use size_t for fields_count in packet_dyn struct. 3) Get rid of "!!" in packet_dyn_has_fields(...) function. 4) Change "unsigned int" to uint32_t 5) Change signature of (* field_changed) callback in proto_ops struct to pass struct proto_field * only. 6) Check first on is_csum_valid in ipv4_csum_update(...) function. 7) Add missed is_csum_valid check in icmpv6_csum_update(...) function. 8) Fixed missed 'field_expr' rule for icmpv4 field 9) Rebased on "proto ops" changes Vadim Kochan (15): trafgen: proto: Update field value at runtime trafgen: proto: Increment proto field at runtime trafgen: proto: Randomize proto field at runtime trafgen: ipv4: Update csum at runtime if needed trafgen: icmpv4: Update csum at runtime if needed trafgen: icmpv6: Update csum at runtime if needed trafgen: proto: Improve to find lower header by index trafgen: proto: Introduce proto_upper_header() function trafgen: udp: Update csum at runtime if needed trafgen: tcp: Update csum at runtime if it needed trafgen: parser: Unify proto field value parsing trafgen: parser: Add support of 'dinc' function for proto fields trafgen: parser: Add 'drnd()' function for proto fields trafgen: man: Add description for 'dinc' and 'drnd' field functions trafgen: man: Simplify example of Jasper's UDP packet by proto functions trafgen.8 | 49 ++++++- trafgen.c | 9 ++ trafgen_conf.h | 7 + trafgen_l3.c | 51 ++++++- trafgen_l4.c | 107 ++++++++++---- trafgen_parser.y | 423 ++++++++++++++++++++++++++++++++++++------------------- trafgen_proto.c | 150 ++++++++++++++++++-- trafgen_proto.h | 32 +++++ 8 files changed, 631 insertions(+), 197 deletions(-) -- 2.9.2 -- You received this message because you are subscribed to the Google Groups "netsniff-ng" group. To unsubscribe from this group and stop receiving emails from it, send an email to netsniff-ng+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.