trafgen: ipv4: Do not use user-provided 'ihl' field to calculate csum
[netsniff-ng-new.git] / trafgen_conf.h
blob50b437bb2c6c4ecc88336e697b6ee07b4fe8baca
1 #ifndef TRAFGEN_CONF
2 #define TRAFGEN_CONF
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <sys/types.h>
8 #define TYPE_INC 0
9 #define TYPE_DEC 1
11 enum csum {
12 CSUM_IP,
13 CSUM_UDP,
14 CSUM_TCP,
15 CSUM_UDP6,
16 CSUM_TCP6,
19 struct counter {
20 int type;
21 uint8_t min, max, inc, val;
22 off_t off;
25 struct randomizer {
26 off_t off;
29 struct csum16 {
30 off_t off, from, to;
31 enum csum which;
34 struct packet {
35 uint8_t *payload;
36 size_t len;
39 struct packet_dyn {
40 struct counter *cnt;
41 size_t clen;
42 struct randomizer *rnd;
43 size_t rlen;
44 struct csum16 *csum;
45 size_t slen;
48 static inline bool packet_dyn_has_elems(struct packet_dyn *p)
50 return (p->clen || p->rlen || p->slen);
53 static inline bool packet_dyn_has_only_csums(struct packet_dyn *p)
55 return (p->clen == 0 && p->rlen == 0 && p->slen);
58 extern void compile_packets_str(char *str, bool verbose, unsigned int cpu);
59 extern void compile_packets(char *file, bool verbose, unsigned int cpu,
60 bool invoke_cpp, char *const cpp_argv[]);
61 extern void cleanup_packets(void);
63 extern void set_fill(uint8_t val, size_t len);
65 extern struct packet *current_packet(void);
67 #endif /* TRAFGEN_CONF */