trafgen: proto: Update field value at runtime
[netsniff-ng-new.git] / trafgen_conf.h
blob61da01266bc8e89cab64761b0524b61d01a5781f
1 #ifndef TRAFGEN_CONF
2 #define TRAFGEN_CONF
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <sys/types.h>
8 #include "trafgen_proto.h"
10 #define PROTO_MAX_LAYERS 16
12 #define TYPE_INC 0
13 #define TYPE_DEC 1
15 enum csum {
16 CSUM_IP,
17 CSUM_UDP,
18 CSUM_TCP,
19 CSUM_UDP6,
20 CSUM_TCP6,
23 struct counter {
24 int type;
25 uint8_t min, max, inc, val;
26 off_t off;
29 struct randomizer {
30 off_t off;
33 struct csum16 {
34 off_t off, from, to;
35 enum csum which;
38 struct packet {
39 uint8_t *payload;
40 size_t len;
41 struct proto_hdr *headers[PROTO_MAX_LAYERS];
42 size_t headers_count;
45 struct packet_dyn {
46 struct counter *cnt;
47 size_t clen;
48 struct randomizer *rnd;
49 size_t rlen;
50 struct csum16 *csum;
51 size_t slen;
52 struct proto_field **fields;
53 size_t flen;
56 static inline bool packet_dyn_has_elems(struct packet_dyn *p)
58 return (p->clen || p->rlen || p->slen);
61 static inline bool packet_dyn_has_only_csums(struct packet_dyn *p)
63 return (p->clen == 0 && p->rlen == 0 && p->slen);
66 static inline bool packet_dyn_has_fields(struct packet_dyn *p)
68 return p->flen;
71 extern void compile_packets_str(char *str, bool verbose, unsigned int cpu);
72 extern void compile_packets(char *file, bool verbose, unsigned int cpu,
73 bool invoke_cpp, char *const cpp_argv[]);
74 extern void cleanup_packets(void);
76 extern void set_fill(uint8_t val, size_t len);
78 extern struct packet *current_packet(void);
79 extern uint32_t current_packet_id(void);
80 extern struct packet *packet_get(uint32_t id);
82 #endif /* TRAFGEN_CONF */