ring_tx: handle EINTR from sendto
[netsniff-ng-new.git] / trafgen_conf.h
blob8a6e4d613033a505bba7a7d0af6f841bcc0ba5bd
1 #ifndef TRAFGEN_CONF
2 #define TRAFGEN_CONF
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <sys/time.h>
7 #include <sys/types.h>
9 #include "trafgen_proto.h"
11 #define PROTO_MAX_LAYERS 16
13 #define TYPE_INC 0
14 #define TYPE_DEC 1
16 enum csum {
17 CSUM_IP,
18 CSUM_UDP,
19 CSUM_TCP,
20 CSUM_UDP6,
21 CSUM_TCP6,
22 CSUM_ICMP6,
25 struct counter {
26 int type, inc;
27 uint8_t min, max, val;
28 off_t off;
31 struct randomizer {
32 off_t off;
35 struct csum16 {
36 off_t off, from, to;
37 enum csum which;
40 struct packet {
41 uint32_t id;
42 uint8_t *payload;
43 size_t len;
44 struct proto_hdr *headers[PROTO_MAX_LAYERS];
45 size_t headers_count;
46 struct timespec tstamp;
47 bool is_created;
50 struct packet_dyn {
51 struct counter *cnt;
52 size_t clen;
53 struct randomizer *rnd;
54 size_t rlen;
55 struct csum16 *csum;
56 size_t slen;
57 struct proto_field **fields;
58 size_t flen;
61 static inline bool packet_dyn_has_elems(struct packet_dyn *p)
63 return (p->clen || p->rlen || p->slen);
66 static inline bool packet_dyn_has_only_csums(struct packet_dyn *p)
68 return (p->clen == 0 && p->rlen == 0 && p->slen);
71 static inline bool packet_dyn_has_fields(struct packet_dyn *p)
73 return p->flen;
76 extern void compile_packets_str(char *str, bool verbose, unsigned int cpu);
77 extern void compile_packets(char *file, bool verbose, unsigned int cpu,
78 bool invoke_cpp, char *const cpp_argv[]);
79 extern void cleanup_packets(void);
81 extern void set_fill(uint8_t val, size_t len);
83 extern struct packet *current_packet(void);
84 extern uint32_t current_packet_id(void);
85 extern struct packet *packet_get(uint32_t id);
86 extern struct packet *realloc_packet(void);
88 #endif /* TRAFGEN_CONF */