flag = {
    name        = tcpedit;
    documentation;
    descrip     = "tcpedit - library to edit packets";
    lib-name    = tcpedit;
};

#ifndef TCPEDIT_MAC_DISABLE
flag = {
    name        = dmac;
    value       = D;
    arg-type    = string;
    max         = 1;
    descrip     = "Rewrite destination MAC addresses";
    doc         = <<- EOText
Takes a pair of comma deliminated ethernet MAC addresses which
will replace the destination MAC address of outbound packets.
The first MAC address will be used for the server traffic
and the optional second MAC address will be used for the client
traffic.

Example:
@example
--dmac 00:12:13:14:15:16,00:22:33:44:55:66
@end example
EOText;
};


flag = {
    name        = smac;
    value       = S;
    arg-type    = string;
    max         = 1;
    descrip     = "Rewrite source MAC addresses";
    doc         = <<- EOText
Takes a pair of comma deliminated ethernet MAC addresses which
will replace the source MAC address of outbound packets.
The first MAC address will be used for the server traffic
and the optional second MAC address will be used for the client traffic.

Example:
@example
--smac 00:12:13:14:15:16,00:22:33:44:55:66
@end example
EOText;
};

#endif

#ifndef TCPEDIT_PROTO_DISABLE
flag = {
	name		= proto;
	value		= P;
	arg-type	= number;
	max			= 1;
	descrip		= "Override L2 protocol type for DLT_RAW";
	arg-range	= "0->65535";
	doc			= <<- EOText
By default, pcap files encapsulated using DLT_RAW will have their protocol
set to ETHERTYPE_IP (0x0800). 
EOText;
};
#endif

#ifndef TCPEDIT_DLINK_DISABLE
flag = {
    name        = dlink;
    value       = l;
    arg-type    = string;
    max         = 2;
    stack-arg;
    descrip     = "Rewrite Data-Link layer with specified data";
    doc         = <<- EOText
Provide a series of comma deliminated hex values which will be
used to rewrite or create the Layer 2 header of the packets.
The first instance of this argument will rewrite both server
and client traffic, but if this argument is specified a second
time, it will be used for the client traffic.

Example:
@example
--dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00
@end example
EOText;
};
#endif

#ifndef TCPEDIT_PORTMAP_DISABLE
flag = {
    name        = portmap;
    value       = r;
    arg-type    = string;
    max         = 1;
    descrip     = "Rewrite TCP/UDP ports";
    doc         = <<- EOText
Specify a list of comma delimited port mappingings consisting of 
colon delimited port number pairs.  Each colon delimited port pair
consists of the port to match followed by the port number to rewrite.

Example:
@example
--portmap=80:8000,8080:80
@end example
EOText;
};
#endif

#ifndef TCPEDIT_SEED_DISABLE
flag = {
    name        = seed;
    value       = s;
    arg-type    = number;
    descrip     = "Randomize src/dst IP addresses w/ given seed";
    max         = 1;
    doc         = <<- EOText
Causes the source and destination IP addresses to be pseudo 
randomized but still maintain client/server relationships.
Since the randomization is deterministic based on the seed, 
you can reuse the same seed value to recreate the traffic.
EOText; 
};
#endif

#ifndef TCPEDIT_PNAT_DISABLE
flag = {
    name        = pnat;
    value       = N;
    arg-type    = string;
    max         = 2;
    stack-arg;
    descrip     = "Rewrite IP addresses using pseudo-NAT";
    doc         = <<- EOText
Takes a comma delimited series of colon delimited CIDR
netblock pairs.  Each netblock pair is evaluated in order against
the IP addresses.  If the IP address in the packet matches the
first netblock, it is rewriten using the second netblock as a
mask against the high order bits.

Example:
@example
--pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24
@end example
EOText; 
};
#endif

#ifndef TCPEDIT_ENDPOINTS_DISABLE
flag = {
    name        = endpoints;
    value       = e;
    arg-type    = string;
    max         = 1;
    descrip     = "Rewrite IP addresses to be between two endpoints";
    doc         = <<- EOText
Takes a pair of colon delimited IP addresses which will be used to rewrite
all traffic to appear to be between the two IP's.

Example:
@example
--endpoints=172.16.0.1:172.16.0.2
@end example
EOText;
};
#endif

#ifndef TCPEDIT_FIXCSUM_DISABLE
flag = {
    name        = fixcsum;
    value       = C;
    descrip     = "Force recalculation of IP/TCP/UDP checksums";
    doc         = <<- EOText
Causes each IP packet to have it's checksums recalcualted and
fixed.  Automatically enabled for packets modified with @samp{--seed}, 
@samp{--pnat}, @samp{--endpoints} or @samp{--fixlen}.
EOText;
};
#endif

#ifndef TCPEDIT_MTU_DISABLE
flag = {
    name        = mtu;
    value       = m;
    arg-type    = number;
    max         = 1;
    arg-range   = "1->MAXPACKET";
    default     = DEFAULT_MTU;
    descrip     = "Override default MTU length (1500 bytes)";
    doc         = <<- EOText
Override the default 1500 byte MTU size for determining the maximum padding length.
EOText;
};
#endif

#ifndef TCPEDIT_EFCS_DISABLE
flag = {
    name        = efcs;
    value       = E;
    descrip     = "Remove Ethernet checksums (FCS) from end of frames";
    doc         = <<- EOText
EOText;
};
#endif

#ifndef TCPEDIT_FIXLEN_DISABLE
flag = {
    name        = fixlen;
    value       = F;
    descrip     = "Pad or truncate packet data to match header length";
    max         = 1;
    arg-type    = string;
    doc         = <<- EOText
Packets may be truncated during capture if the snaplen is smaller then the
packet.  This option allows you to modify the packet to pad the packet back
out to the size stored in the IPv4 header or rewrite the IP header total length
to reflect the stored packet length.
@table @bullet
@item
@var{pad}
Truncated packets will be padded out so that the packet length matches the 
IPv4 total length
@item
@var{trunc}
Truncated packets will have their IPv4 total length field rewritten to match
the actual packet length
@item
@var{del}
Delete the packet
EOText;
};
#endif

#ifndef TCPEDIT_VLAN_DISABLE
/* rewrite 802.1q vlan tags */
flag = {
    name        = vlan;
    value       = T;
    max         = 1;
    descrip     = "Specify 802.1q VLAN tag mode";
    arg-type    = string;
    doc         = <<- EOText
Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3
ethernet headers or remove the 802.1q VLAN tag information.
@table @bullet
@item
@var{add}
Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header
@item
@var{del}
Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header
EOText;
};

flag = {
    name        = vlan_tag;
    value       = t;
    max         = 1;
    descrip     = "Specify the new 802.1q VLAN tag value";
    arg-type    = number;
    flags-must  = vlan;
    arg-range   = "0->4095"; /* VID's are 12bit unsigned int's */
    doc         = "";
};

flag = {
    name        = vlan_cfi;
    value       = f;
    max         = 1;
    descrip     = "Specify the 802.1q VLAN CFI value";
    arg-type    = number;
    flags-must  = vlan;
    arg-range   = "0->1"; /* one bit */
    doc         = "";
};

flag = {
    name        = vlan_pri;
    value       = p;
    max         = 1;
    descrip     = "Specify the 802.1q VLAN priority";
    flags-must  = vlan;
    arg-type    = number;
    arg-range   = "0->7"; /* one byte */
    doc         = "";
};
#endif
