autogen definitions options;

copyright = {
    date        = "2004-2006";
    owner       = "Aaron Turner";
    type        = "bsd";
    author      = <<- EOText
Copyright 2004-2005 Aaron Turner

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

package         = "tcprewrite";
prog-name       = "tcprewrite";
prog-title      = "Rewrite the packets in a pcap file.";
long-opts;
gnu-usage;
help-value      = "H";
save-opts-value = "";
load-opts-value = "";
#include tcpedit/tcpedit_opts.def

detail		= <<- EOText
Tcprewrite is a tool to rewrite packets stored in @file{pcap(3)} file format, 
such as crated by tools such as @file{tcpdump(1)} and @file{ethereal(1)}.  
Once a pcap file has had it's packets rewritten, they can be replayed back 
out on the network using @file{tcpreplay(1)}.

tcprewrite currently supports the following DLT types:
    * DLT_C_HDLC
    * DLT_EN10MB
    * DLT_LINUX_SSL
    * DLT_RAW

The packet editing features of tcprewrite which distinguish between "client"
and "server" traffic requires a tcpprep(1) cache file.
EOText;

man-doc = <<- EOMan
.SH "SEE ALSO"
tcpdump(1), tcpprep(1), tcpreplay(1)
EOMan;


config-header   = "config.h";
include         = "#include \"defines.h\"\n"
                "#include \"common.h\"\n"
                "#include \"config.h\"\n"
                "#include \"tcprewrite.h\"\n"
                "#include \"mac.h\"\n"
				"#include <stdlib.h>\n"
				"#include <string.h>\n"
                "extern char pcap_version[];\n"
                "extern tcprewrite_opt_t options;\n";

homerc          = "$$/";


#ifndef TCPEDIT_DLT_DISABLE
flag = {
    name        = dlt;
    value       = L;
    arg-type    = number;
    arg-range   = "0->65535";
    max         = 1;
    descrip     = "Change DLT type for output pcap file";
    doc         = <<- EOText
By default, tcprewrite uses the same DLT (data link type) for the 
output pcap as the input pcap.  However, if you are changing the 
Layer 2 data with --dlink, then you probably also want to change the
DLT type stored in the pcap.  Common DLT types are:
@table @bullet
@item
@var{0}
No Layer 2 header (DLT_NULL)
@item
@var{1}
Ethernet (DLT_EN10MB)
@item
@var{10}
FDDI (DLT_FDDI)
@item
@var{12}
BSD Raw header (DLT_RAW)
@item
@var{104}
Cisco HDLC (DLT_C_HDLC)
@item
@var{113}
Linux SLL pseudo-header (DLT_LINUX_SLL)

For a full list of DLT types, see: src/common/dlt_names.h

EOText;
};

#endif



flag = {
    name        = dbug;
    value       = d;
    arg-type    = number;
    descrip     = "Enable debugging output";
    arg-range   = "0->5";
    arg-default = 0;
    max         = 1;
    immediate;
    doc         = <<- EOText
If configured with --enable-debug, then you can specify a verbosity 
level for debugging output.  Higher numbers increase verbosity.
EOText;
};


flag = {
    name        = infile;
    value       = i;
    arg-type    = string;
    descrip     = "Input pcap file to be processed";
    max         = 1;
    immediate;
    must-set;
    doc         = "";
};

flag = {
    name        = outfile;
    value       = o;
    arg-type    = string;
    descrip     = "Output pcap file";
    max         = 1;
    must-set;
    doc		    = "";
    /* options.outfile is set in post_args, because we need to make
     * sure that options.infile is processed first
     */
};

flag = {
    name        = cachefile;
    value       = c;
    arg-type    = string;
    max         = 1;
    descrip     = "Split traffic via tcpprep cache file";
    settable;
    flag-code   = <<- EOCachefile
    
    options.cache_packets = 
        read_cache(&options.cachedata, OPT_ARG(CACHEFILE), &options.comment);

EOCachefile;    
    doc         = <<- EOText
Use tcpprep cache file to split traffic based upon client/server relationships.
EOText;
};


/* Verbose decoding via tcpdump */

flag = {
    ifdef       = HAVE_TCPDUMP;
    name        = verbose;
    value       = v;
    max         = 1;
    immediate;
    descrip     = "Print decoded packets via tcpdump to STDOUT";
    settable;
    doc         = "";
};

flag = {
    ifdef       = HAVE_TCPDUMP;
    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 so that they are not interpreted
by tcprewrite.  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, "tcprewrite version: %s (build %s)", VERSION, svn_version());
#ifdef DEBUG
    fprintf(stderr, " (debug)");
#endif
    fprintf(stderr, "\n");
    fprintf(stderr, "Copyright 2001-2006 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
    fprintf(stderr, "Compiled against libpcap: %s\n", pcap_version);
#ifdef ENABLE_64BITS
    fprintf(stderr, "64 bit packet counters: enabled\n");
#else
    fprintf(stderr, "64 bit packet counters: 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         = "";
};
