forked from appneta/tcpreplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcpedit_types.h
154 lines (123 loc) · 3.79 KB
/
tcpedit_types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* $Id$ */
/*
* Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
* Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
*
* The Tcpreplay Suite of tools is free software: you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or with the authors permission any later version.
*
* The Tcpreplay Suite is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "defines.h"
#include "common.h"
#include "tcpr.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TCPEDIT_SOFT_ERROR -2
#define TCPEDIT_ERROR -1
#define TCPEDIT_OK 0
#define TCPEDIT_WARN 1
typedef enum { TCPEDIT_FIXLEN_OFF = 0, TCPEDIT_FIXLEN_PAD, TCPEDIT_FIXLEN_TRUNC, TCPEDIT_FIXLEN_DEL } tcpedit_fixlen;
typedef enum {
TCPEDIT_TTL_MODE_OFF = 0,
TCPEDIT_TTL_MODE_SET,
TCPEDIT_TTL_MODE_ADD,
TCPEDIT_TTL_MODE_SUB
} tcpedit_ttl_mode;
typedef enum { TCPEDIT_EDIT_BOTH = 0, TCPEDIT_EDIT_C2S, TCPEDIT_EDIT_S2C } tcpedit_direction;
typedef enum { BEFORE_PROCESS, AFTER_PROCESS } tcpedit_coder;
#define TCPEDIT_ERRSTR_LEN 1024
typedef struct {
COUNTER packetnum;
COUNTER total_bytes;
COUNTER pkts_edited;
int dlt1;
int dlt2;
char errstr[TCPEDIT_ERRSTR_LEN];
char warnstr[TCPEDIT_ERRSTR_LEN];
#ifdef FORCE_ALIGN
u_char *l3buff;
#endif
} tcpedit_runtime_t;
/*
* need to track some packet info at runtime
*/
typedef struct {
int l2len;
int l3len;
int datalen;
u_int8_t l4proto;
u_char *l4data;
u_int16_t sport, dport;
union {
u_int32_t ipv4;
struct tcpr_in6_addr ipv6;
} sip, dip;
} tcpedit_packet_t;
/*
* portmap data struct
*/
typedef struct tcpedit_portmap_s {
long from;
long to;
struct tcpedit_portmap_s *next;
} tcpedit_portmap_t;
/*
* all the arguments that the packet editing library supports
*/
typedef struct {
bool validated; /* have we run tcpedit_validate()? */
struct tcpeditdlt_s *dlt_ctx;
/* runtime variables, don't mess with these */
tcpedit_runtime_t runtime;
/* skip rewriting IP/MAC's which are broadcast or multicast? */
bool skip_broadcast;
/* pad or truncate packets */
tcpedit_fixlen fixlen;
tcpedit_direction editdir;
/* rewrite ip? */
bool rewrite_ip;
/* rewrite TCP seq/ack numbers? */
u_int32_t tcp_sequence_enable;
u_int32_t tcp_sequence_adjust;
/* fix IP/TCP/UDP checksums */
bool fixcsum;
/* remove ethernet FCS */
bool efcs;
tcpedit_ttl_mode ttl_mode;
u_int8_t ttl_value;
/* TOS/DiffServ/ECN, -1 is disabled, else copy value */
int tos;
/* IPv6 FlowLabel, -1 is disabled, else copy value */
int flowlabel;
/* IPv6 TClass, -1 is disabled, else copy value */
int tclass;
/* rewrite end-point IP addresses between cidrmap1 & cidrmap2 */
tcpr_cidrmap_t *cidrmap1; /* tcpprep cache data */
tcpr_cidrmap_t *cidrmap2;
/* src & dst IP mapping */
tcpr_cidrmap_t *srcipmap;
tcpr_cidrmap_t *dstipmap;
/* pseudo-randomize IP addresses using a seed */
uint32_t seed;
/* rewrite tcp/udp ports */
tcpedit_portmap_t *portmap;
int mtu; /* Deal with different MTU's */
bool mtu_truncate; /* Should we truncate frames > MTU? */
int maxpacket; /* L2 header + MTU */
uint32_t fuzz_seed;
uint32_t fuzz_factor;
} tcpedit_t;
#ifdef __cplusplus
}
#endif