forked from appneta/tcpreplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcpbridge_opts.def
413 lines (348 loc) · 11.2 KB
/
tcpbridge_opts.def
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
/* $Id$ */
/*
* Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
* Copyright (c) 2013-2018 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/>.
*/
autogen definitions options;
copyright = {
date = "2000-2018";
owner = "Aaron Turner and Fred Klassen";
eaddr = "[email protected]";
type = gpl;
author = <<- EOText
Copyright 2013-2018 Fred Klassen - AppNeta
Copyright 2000-2012 Aaron Turner
For support please use the [email protected] mailing list.
The latest version of this software is always available from:
http://tcpreplay.appneta.com/
EOText;
};
package = "tcpbridge";
prog-name = "tcpbridge";
prog-title = "Bridge network traffic across two interfaces";
long-opts;
gnu-usage;
help-value = "H";
save-opts-value = "";
load-opts-value = "";
config-header = "config.h";
include = "#include \"defines.h\"\n"
"#include \"tcpbridge.h\"\n"
"#include \"common.h\"\n"
"#include \"config.h\"\n"
"#include <stdlib.h>\n"
"#include <string.h>\n"
"#include <sys/types.h>\n"
"#include <unistd.h>\n"
"extern tcpbridge_opt_t options;\n";
#include tcpedit/tcpedit_opts.def
homerc = "$$/";
explain = <<- EOExplain
tcpbridge is a tool for selectively bridging network traffic across two interfaces
and optionally modifying the packets in between
EOExplain;
detail = <<- EODetail
The basic operation of tcpbridge is to be a network bridge between two
subnets. All packets received on one interface are sent via the other.
Optionally, packets can be edited in a variety of ways according to your needs.
For more details, please see the Tcpreplay Manual at:
http://tcpreplay.appneta.com
EODetail;
man-doc = <<- EOMan
.SH "SIGNALS"
tcpbridge understands the following signals:
@enumerate
@item @var{SIGUSR1}
Suspend tcpbridge
@item @var{SIGCONT}
Restart tcpbridge
@end enumerate
.SH "SEE ALSO"
tcpdump(1), tcpprep(1), tcprewrite(1), tcpreplay(1)
.SH "BUGS"
tcpbridge can only send packets as fast as your computer's interface,
processor and system bus will allow.
Connecting both interfaces to the same subnet may create a broadcast storm and
take down the network. Improper use of the packet editing functions may have
other undefined and possible negative consequences.
Some operating systems by default do not allow for forging source MAC
addresses. Please consult your operating system's documentation and the
tcpreplay FAQ if you experience this issue.
EOMan;
/*
* Debugging
*/
flag = {
ifdef = DEBUG;
name = dbug;
value = d;
arg-type = number;
max = 1;
immediate;
arg-range = "0->5";
arg-default = 0;
descrip = "Enable debugging output";
doc = <<- EOText
If configured with --enable-debug, then you can specify a verbosity
level for debugging output. Higher numbers increase verbosity.
EOText;
};
/*
* Outputs: -i, -I
*/
flag = {
name = intf1;
value = i;
arg-type = string;
max = 1;
must-set;
descrip = "Primary interface (listen in uni-directional mode)";
doc = "";
};
flag = {
name = intf2;
value = I;
arg-type = string;
max = 1;
descrip = "Secondary interface (send in uni-directional mode)";
doc = "";
};
flag = {
name = unidir;
value = u;
max = 1;
descrip = "Send and receive in only one direction";
doc = <<- EOText
Normally, tcpbridge will send and receive traffic in both directions
(bi-directionally). However, if you choose this option, traffic will
be sent uni-directionally.
EOText;
};
flag = {
ifdef = ENABLE_PCAP_FINDALLDEVS;
name = listnics;
descrip = "List available network interfaces and exit";
immediate;
doc = "";
flag-code = <<- EOFlag
interface_list_t *list = get_interface_list();
list_interfaces(list);
free(list);
exit(0);
EOFlag;
};
/*
* Select which packets to process
*/
flag = {
name = limit;
value = L;
arg-type = number;
max = 1;
arg-default = -1;
arg-range = "1->";
descrip = "Limit the number of packets to send";
doc = <<- EOText
By default, tcpbridge will send packets forever or until Ctrl-C. Alternatively,
you can specify a maximum number of packets to send.
EOText;
};
/*
* Windows users need to provide the MAC addresses of the interfaces
* so we can prevent looping (since winpcap doesn't have an API to query)
* the MAC address of the NIC's
*/
flag = {
name = mac;
value = M;
arg-type = string;
max = 2;
stack-arg;
descrip = "MAC addresses of local NIC's";
doc = <<- EOText
tcpbridge does not support detecting the MAC addresses of the local network
interfaces under Windows. Please specify both MAC addresses of the interfaces
used in the bridge: -M <intf1 mac> -M <intf2 mac>
EOText;
};
/* Include/Exclude */
flag = {
name = include;
value = x;
arg-type = string;
max = 1;
descrip = "Include only packets matching rule";
flags-cant = exclude;
flag-code = <<- EOInclude
char *include;
include = safe_strdup(OPT_ARG(INCLUDE));
options.xX.mode = xX_MODE_INCLUDE;
if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError)
errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE));
free(include);
EOInclude;
doc = <<- EOText
Override default of sending all packets stored in the capture file and only
send packets which match the provided rule. Rules can be one of:
@table @bullet
@item S:<CIDR1>,...
- Source IP must match specified CIDR(s)
@item D:<CIDR1>,...
- Destination IP must match specified CIDR(s)
@item B:<CIDR1>,...
- Both source and destination IP must match specified CIDR(s)
@item E:<CIDR1>,...
- Either IP must match specified CIDR(s)
@item P:<LIST>
- Must be one of the listed packets where the list
corresponds to the packet number in the capture file.
@example
--include=P:1-5,9,15,72-
@end example
would send packets 1 through 5, the 9th and 15th packet, and packets 72 until the
end of the file
@item F:'<bpf>'
- BPF filter. See the @file{tcpdump(8)} man page for syntax.
@end table
EOText;
};
flag = {
name = exclude;
value = X;
arg-type = string;
max = 1;
descrip = "Exclude any packet matching this rule";
flags-cant = include;
flag-code = <<- EOExclude
char *exclude;
exclude = safe_strdup(OPT_ARG(EXCLUDE));
options.xX.mode = xX_MODE_EXCLUDE;
if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError)
errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE));
free(exclude);
EOExclude;
doc = <<- EOText
Override default of sending all packets stored in the capture file and only
send packets which do not match the provided rule. Rules can be one of:
@table @bullet
@item S:<CIDR1>,...
- Source IP must not match specified CIDR(s)
@item D:<CIDR1>,...
- Destination IP must not match specified CIDR(s)
@item B:<CIDR1>,...
- Both source and destination IP must not match specified CIDR(s)
@item E:<CIDR1>,...
- Either IP must not match specified CIDR(s)
@item P:<LIST>
- Must not be one of the listed packets where the list
corresponds to the packet number in the capture file.
@example
--exclude=P:1-5,9,15,72-
@end example
would drop packets 1 through 5, the 9th and 15th packet, and packets 72 until the
end of the file
@end table
EOText;
};
flag = {
name = pid;
value = P;
descrip = "Print the PID of tcpbridge at startup";
flag-code = <<- EOPid
fprintf(stderr, "PID: %d\n", getpid());
EOPid;
doc = "";
};
/* Verbose decoding via tcpdump */
flag = {
ifdef = ENABLE_VERBOSE;
name = verbose;
value = v;
max = 1;
immediate;
descrip = "Print decoded packets via tcpdump to STDOUT";
settable;
doc = "";
};
flag = {
ifdef = ENABLE_VERBOSE;
name = decode;
flags-must = verbose;
value = A;
arg-type = string;
max = 1;
descrip = "Arguments passed to tcpdump decoder";
doc = <<- EOText
When enabling verbose mode (@var{-v}) you may also specify one or more
additional arguments to pass to @code{tcpdump} to modify the way packets
are decoded. By default, -n and -l are used. Be sure to
quote the arguments like: --verbose="-axxx" so that they are not interpreted
by tcpbridge. The following arguments are valid:
[ -aAeNqRStuvxX ]
[ -E spi@ipaddr algo:secret,... ]
[ -s snaplen ]
EOText;
};
flag = {
name = version;
value = V;
descrip = "Print version information";
flag-code = <<- EOVersion
fprintf(stderr, "tcpbridge version: %s (build %s)", VERSION, git_version());
#ifdef DEBUG
fprintf(stderr, " (debug)");
#endif
fprintf(stderr, "\n");
fprintf(stderr, "Copyright 2013-2018 by Fred Klassen <tcpreplay at appneta dot com> - AppNeta\n");
fprintf(stderr, "Copyright 2000-2012 by Aaron Turner <aturner at synfin dot net>\n");
fprintf(stderr, "The entire Tcpreplay Suite is licensed under the GPLv3\n");
#ifdef HAVE_LIBDNET
fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION);
#else
fprintf(stderr, "Not compiled with libdnet.\n");
#endif
#ifdef HAVE_WINPCAP
fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
#elif defined HAVE_PF_RING_PCAP
fprintf(stderr, "Compiled against PF_RING libpcap: %s\n", get_pcap_version());
#else
fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
#endif
#ifdef ENABLE_64BITS
fprintf(stderr, "64 bit packet counters: enabled\n");
#else
fprintf(stderr, "64 bit packet counters: disabled\n");
#endif
#ifdef ENABLE_VERBOSE
fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
#else
fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
#endif
fprintf(stderr, "Injection method: %s\n", sendpacket_get_method(NULL));
exit(0);
EOVersion;
doc = "";
};
flag = {
name = less-help;
value = "h";
immediate;
descrip = "Display less usage information and exit";
flag-code = <<- EOHelp
USAGE(EXIT_FAILURE);
EOHelp;
doc = "";
};