autogen definitions options;


copyright = {
    date        = "2000-2008";
    owner       = "Aaron Turner";
    type        = "bsd";
    author      = <<- EOText
Copyright 2000-2008 Aaron Turner

For support please use the tcpreplay-users@lists.sourceforge.net mailing list.

The latest version of this software is always available from:
http://tcpreplay.synfin.net/
EOText;
};

package         = "tcpreplay";
prog-name       = "tcpreplay";
prog-title      = "Replay network traffic stored in pcap files";
long-opts;
gnu-usage;
help-value      = "H";
save-opts-value = "";
load-opts-value = "";
argument = "<pcap_file(s)>";


config-header   = "config.h";

include         = "#include \"defines.h\"\n"
                "#include \"tcpreplay.h\"\n"
                "#include \"common.h\"\n"
                "#include \"config.h\"\n"
				"#include <stdlib.h>\n"
				"#include <sys/types.h>\n"
				"#include <unistd.h>\n"
                "extern tcpreplay_opt_t options;\n";

homerc          = "$$/";

#ifdef TCPREPLAY_EDIT
#include tcpedit/tcpedit_opts.def
#endif

explain = <<- EOExplain
tcpreplay is a tool for replaying network traffic from files saved with
tcpdump or other tools which write pcap(3) files.
EOExplain;

detail = <<- EODetail
The basic operation of tcpreplay is to resend  all  packets  from  the
input file(s) at the speed at which they were recorded, or a specified 
data rate, up to as fast as the hardware is capable.

Optionally, the traffic can be split between two interfaces, written to
files, filtered and edited in various ways, providing the means to test
firewalls, NIDS and other network devices.

For more details, please see the Tcpreplay Manual at:
http://tcpreplay.synfin.net/trac/wiki/manual
EODetail;

man-doc = <<- EOMan
.SH "SIGNALS"
tcpreplay understands the following signals:
@enumerate
@item @var{SIGUSR1}
Suspend tcpreplay
@item @var{SIGCONT}
Restart tcpreplay
@end enumerate

.SH "SEE ALSO"
tcpreplay-edit(1), tcpdump(1), tcpprep(1), tcprewrite(1), libnet(3)

.SH "BUGS"
tcpreplay can only send packets as fast as your computer's interface,
processor, disk and system bus will allow.

Packet timing at high speeds is a black art and very OS/CPU dependent.  

Replaying captured traffic may simulate odd or broken conditions on your
network and cause all sorts of problems.

In most cases, you can not replay traffic back to/at a server.

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;


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;
};

flag = {
	name		= quiet;
	value		= q;
	descrip		= "Quiet mode";
	doc			= "Print nothing except the statistics at the end of the run";
};

flag = {
	name		= timer;
	value		= T;
	arg-default = "gtod";
	max			= 1;
	arg-type    = string;
	descrip		= "Select packet timing mode: select, ioport, rdtsc, gtod, nano, abstime";
	doc			= <<- EOText
Allows you to select the packet timing method to use:
@enumerate
@item nano
- Use nanosleep() API
@item select
- Use select() API
@item ioport
- Write to the i386 IO Port 0x80
@item rdtsc  
- Use the x86/x86_64/PPC RDTSC
@item gtod [default]
- Use a gettimeofday() loop
@item abstime
- Use OS X's AbsoluteTime API
@end enumerate

EOText;
};

flag = {
    name        = sleep-accel;
    arg-type    = number;
    arg-default = 0;
    descrip     = "Reduce the amount of time to sleep by specified usec";
    doc         = <<- EOText
Reduce the amount of time we would normally sleep between two packets by the 
specified number of usec.  This provides a "fuzz factor" to compensate for
running on a non-RTOS and other processes using CPU time.  Default is disabled.
EOText;
};

flag = {
    name        = rdtsc-clicks;
    max         = 1;
    arg-type    = number;
    arg-default = 0;
    descrip     = "Specify the RDTSC clicks/usec";
    doc         = <<- EOText
Override the calculated number of RDTSC clicks/usec which is often the speed of the 
CPU in Mhz.  Only useful if you specified @var{--timer=rdtsc}
EOText;
};

/* 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: -A "-axxx" so that they are not interpreted
by tcpreplay.   Please see the tcpdump(1) man page for a complete list of 
options.
EOText;
};

/* Cache files to internal memory */ 
flag = {
	name		= enable_file_cache;
	value		= K;
	flags-must	= loop;
	descrip		= "Enable caching of packets to internal memory";
	doc			= <<- EOText
Cache pcap file(s) the first time they are cached in RAM so that subsequent
loops don't incurr any disk I/O latency in order to increase performance.  Make 
sure you have enough free RAM to store the entire pcap file(s) in memory or the
system will swap and performance will suffer.
EOText;
};

/*
 * Output modifiers: -c
 */

flag = {
    name        = cachefile;
    value       = c;
    arg-type    = string;
    max         = 1;
    descrip     = "Split traffic via a tcpprep cache file";
    doc         = "";
};

/*
 * Outputs: -i, -I
 */

flag = {
    name        = intf1;
    value       = i;
    arg-type    = string;
    max         = 1;
    must-set;
    descrip     = "Server/primary traffic output interface";
    doc         = "";
};

flag = {
    name        = intf2;
    value       = I;
    arg-type    = string;
    max         = 1;
    flags-must  = cachefile;
    descrip     = "Client/secondary traffic output interface";
    doc         = "";
};
/*
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;
};
*/
/*
 * Limits and loops: -l
 */

flag = {
    name        = loop;
    value       = l;
    arg-type    = number;
    arg-range   = "0->";
    max         = 1;
    descrip     = "Loop through the capture file X times";
    arg-default = 1;
    doc         = "";
};

flag = {
    name        = pktlen;
    max         = 1;
    descrip     = "Override the snaplen and use the actual packet len";
    doc         = <<- EOText
By default, tcpreplay will send packets based on the size of the "snaplen"
stored in the pcap file which is usually the correct thing to do.  However,
occasionally, tools will store more bytes then told to.  By specifying this
option, tcpreplay will ignore the snaplen field and instead try to send
packets based on the original packet length.  Bad things may happen if
you specify this option.
EOText;
};

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, tcpreplay will send all the packets.  Alternatively, you can 
specify a maximum number of packets to send.  
EOText;
};

/*
 * Replay speed modifiers: -m, -p, -r, -R, -o
 */

/* note that this is really a float, but autoopts does not support float */
flag = {
    name        = multiplier;
    flags-cant  = pps;
    flags-cant  = mbps;
    flags-cant  = oneatatime;
    flags-cant  = topspeed;
    value       = x;
    arg-type    = string;
    max         = 1;
    descrip     = "Modify replay speed to a given multiple";
    doc         = <<- EOText
Specify a floating point value to modify the packet replay speed.
Examples:
@example
    2.0 will replay traffic at twice the speed captured
    0.7 will replay traffic at 70% the speed captured
@end example
EOText;
};

flag = {
    name        = pps;
    flags-cant  = multiplier;
    flags-cant  = mbps;
    flags-cant  = oneatatime;
    flags-cant  = topspeed;
    value       = p;
    arg-type    = number;
    max         = 1;
    descrip     = "Replay packets at a given packets/sec";
    doc         = "";
};

flag = {
    name        = mbps;
    flags-cant  = multiplier;
    flags-cant  = pps;
    flags-cant  = oneatatime;
    flags-cant  = topspeed;
    value       = M;
    arg-type    = string;
    max         = 1;
    descrip     = "Replay packets at a given Mbps";
    doc         = <<- EOText
Specify a floating point value for the Mbps rate that tcpreplay
should send packets at.
EOText;
};

flag = {
    name        = topspeed;
    flags-cant  = mbps;
    flags-cant  = multiplier;
    flags-cant  = pps;
    flags-cant  = oneatatime;
    value       = t;
    descrip     = "Replay packets as fast as possible";
    doc         = "";
};

flag = {
    name        = oneatatime;
    flags-cant  = mbps;
    flags-cant  = pps;
    flags-cant  = multiplier;
    flags-cant  = topspeed;
    value       = o;
    descrip     = "Replay one packet at a time for each user input";
    doc         = <<- EOText
Allows you to step through one or more packets at a time.
EOText;
};

flag = {
    name        = pid;
    value       = P;
    descrip     = "Print the PID of tcpreplay at startup";
    flag-code   = <<- EOPid
    
    fprintf(stderr, "PID: %hu\n", getpid());
    
EOPid;
    doc         = "";
};

flag = {
    name        = version;
    value       = V;
    descrip     = "Print version information";
    flag-code   = <<- EOVersion
    
    fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version());
#ifdef DEBUG
    fprintf(stderr, " (debug)");
#endif
    fprintf(stderr, "\n");
    fprintf(stderr, "Copyright 2001-2008 by Aaron Turner <aturner at synfin dot net>\n");
    fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION);
#ifdef HAVE_LIBNET
    fprintf(stderr, "Compiled against libnet: %s\n", LIBNET_VERSION);
#else
	fprintf(stderr, "Not compiled with libnet.\n");
#endif
#ifdef HAVE_WINPCAP
	fprintf(stderr, "Compiled against winpcap: %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
#ifdef TCPREPLAY_EDIT
    fprintf(stderr, "Packet editing: enabled\n");
#else
    fprintf(stderr, "Packet editing: disabled\n");
#endif
#ifdef ENABLE_FRAGROUTE
    fprintf(stderr, "Fragroute engine: enabled\n");
#else
    fprintf(stderr, "Fragroute engine: disabled\n");
#endif
    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         = "";
};
