diff options
-rw-r--r-- | trafgen.c | 14 | ||||
-rw-r--r-- | trafgen_conf.h | 4 | ||||
-rw-r--r-- | trafgen_parser.y | 2 |
3 files changed, 5 insertions, 15 deletions
@@ -316,20 +316,10 @@ static void apply_counter(int id) struct counter *counter = &packet_dyn[id].cnt[j]; val = counter->val - counter->min; - - switch (counter->type) { - case TYPE_INC: - val = (val + counter->inc) % (counter->max - counter->min + 1); - break; - case TYPE_DEC: - val = (val - counter->inc) % (counter->min - counter->max + 1); - break; - default: - bug(); - } + val = (val + counter->inc) % (counter->max - counter->min + 1); counter->val = val + counter->min; - packets[id].payload[counter->off] = val; + packets[id].payload[counter->off] = counter->val; } } diff --git a/trafgen_conf.h b/trafgen_conf.h index a0bbe43..fcbbb17 100644 --- a/trafgen_conf.h +++ b/trafgen_conf.h @@ -22,8 +22,8 @@ enum csum { }; struct counter { - int type; - uint8_t min, max, inc, val; + int type, inc; + uint8_t min, max, val; off_t off; }; diff --git a/trafgen_parser.y b/trafgen_parser.y index a42dc30..4d83af6 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -147,7 +147,7 @@ static inline void __setup_new_counter(struct counter *c, uint8_t start, { c->min = start; c->max = stop; - c->inc = stepping; + c->inc = (type == TYPE_INC) ? stepping : -stepping; c->val = (type == TYPE_INC) ? start : stop; c->off = payload_last; c->type = type; |