123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587 |
- /* -*- buffer-read-only: t -*- vi: set ro:
- *
- * DO NOT EDIT THIS FILE (tcprewrite_opts.c)
- *
- * It has been AutoGen-ed Thursday May 15, 2008 at 08:51:17 AM PDT
- * From the definitions tcprewrite_opts.def
- * and the template file options
- *
- * Generated from AutoOpts 30:0:5 templates.
- */
- /*
- * This file was produced by an AutoOpts template. AutoOpts is a
- * copyrighted work. This source file is not encumbered by AutoOpts
- * licensing, but is provided under the licensing terms chosen by the
- * tcprewrite author or copyright holder. AutoOpts is licensed under
- * the terms of the LGPL. The redistributable library (``libopts'') is
- * licensed under the terms of either the LGPL or, at the users discretion,
- * the BSD license. See the AutoOpts and/or libopts sources for details.
- *
- * This source file is copyrighted and licensed under the following terms:
- *
- * tcprewrite copyright 2004-2008 Aaron Turner - all rights reserved
- *
- * tcprewrite is free software copyrighted by Aaron Turner.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name ``Aaron Turner'' nor the name of any other
- * contributor may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * tcprewrite IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include <limits.h>
- #include <stdio.h>
- #define OPTION_CODE_COMPILE 1
- #include "tcprewrite_opts.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- tSCC zCopyright[] =
- "tcprewrite copyright (c) 2004-2008 Aaron Turner, all rights reserved";
- tSCC zCopyrightNotice[] =
- "tcprewrite is free software copyrighted by Aaron Turner.\n\n\
- Redistribution and use in source and binary forms, with or without\n\
- modification, are permitted provided that the following conditions\n\
- are met:\n\
- 1. Redistributions of source code must retain the above copyright\n\
- notice, this list of conditions and the following disclaimer.\n\
- 2. Redistributions in binary form must reproduce the above copyright\n\
- notice, this list of conditions and the following disclaimer in the\n\
- documentation and/or other materials provided with the distribution.\n\
- 3. Neither the name ``Aaron Turner'' nor the name of any other\n\
- contributor may be used to endorse or promote products derived\n\
- from this software without specific prior written permission.\n\n\
- tcprewrite IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS\n\
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n\
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\
- ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS\n\
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n\
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n\
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n\
- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n\
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n\
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
- extern tUsageProc optionUsage;
- /*
- * global included definitions
- */
- #include "defines.h"
- #include "common.h"
- #include "config.h"
- #include "tcprewrite.h"
- #include <stdlib.h>
- #include <string.h>
- extern tcprewrite_opt_t options;
- #ifndef NULL
- # define NULL 0
- #endif
- #ifndef EXIT_SUCCESS
- # define EXIT_SUCCESS 0
- #endif
- #ifndef EXIT_FAILURE
- # define EXIT_FAILURE 1
- #endif
- /*
- * Tcpedit option description:
- */
- tSCC zTcpeditText[] =
- "";
- #define TCPEDIT_FLAGS (OPTST_DOCUMENT | OPTST_NO_INIT)
- /*
- * Portmap option description:
- */
- tSCC zPortmapText[] =
- "Rewrite TCP/UDP ports";
- tSCC zPortmap_NAME[] = "PORTMAP";
- tSCC zPortmap_Name[] = "portmap";
- #define PORTMAP_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Seed option description:
- */
- tSCC zSeedText[] =
- "Randomize src/dst IP addresses w/ given seed";
- tSCC zSeed_NAME[] = "SEED";
- tSCC zSeed_Name[] = "seed";
- #define SEED_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * Pnat option description with
- * "Must also have options" and "Incompatible options":
- */
- tSCC zPnatText[] =
- "Rewrite IP addresses using pseudo-NAT";
- tSCC zPnat_NAME[] = "PNAT";
- tSCC zPnat_Name[] = "pnat";
- static const int
- aPnatCantList[] = {
- INDEX_OPT_SRCIPMAP, NO_EQUIVALENT };
- #define PNAT_FLAGS (OPTST_DISABLED | OPTST_STACKED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Srcipmap option description with
- * "Must also have options" and "Incompatible options":
- */
- tSCC zSrcipmapText[] =
- "Rewrite source IP addresses using pseudo-NAT";
- tSCC zSrcipmap_NAME[] = "SRCIPMAP";
- tSCC zSrcipmap_Name[] = "srcipmap";
- static const int
- aSrcipmapCantList[] = {
- INDEX_OPT_PNAT, NO_EQUIVALENT };
- #define SRCIPMAP_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Dstipmap option description with
- * "Must also have options" and "Incompatible options":
- */
- tSCC zDstipmapText[] =
- "Rewrite destination IP addresses using pseudo-NAT";
- tSCC zDstipmap_NAME[] = "DSTIPMAP";
- tSCC zDstipmap_Name[] = "dstipmap";
- static const int
- aDstipmapCantList[] = {
- INDEX_OPT_PNAT, NO_EQUIVALENT };
- #define DSTIPMAP_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Endpoints option description with
- * "Must also have options" and "Incompatible options":
- */
- #ifdef HAVE_CACHEFILE_SUPPORT
- tSCC zEndpointsText[] =
- "Rewrite IP addresses to be between two endpoints";
- tSCC zEndpoints_NAME[] = "ENDPOINTS";
- tSCC zEndpoints_Name[] = "endpoints";
- static const int
- aEndpointsMustList[] = {
- INDEX_OPT_CACHEFILE, NO_EQUIVALENT };
- #define ENDPOINTS_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- #else /* disable Endpoints */
- #define VALUE_OPT_ENDPOINTS NO_EQUIVALENT
- #define ENDPOINTS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
- #define aEndpointsMustList NULL
- #define zEndpointsText NULL
- #define zEndpoints_NAME NULL
- #define zEndpoints_Name NULL
- #endif /* HAVE_CACHEFILE_SUPPORT */
- /*
- * Skipbroadcast option description:
- */
- tSCC zSkipbroadcastText[] =
- "Skip rewriting broadcast/multicast IP's";
- tSCC zSkipbroadcast_NAME[] = "SKIPBROADCAST";
- tSCC zSkipbroadcast_Name[] = "skipbroadcast";
- #define SKIPBROADCAST_FLAGS (OPTST_DISABLED)
- /*
- * Fixcsum option description:
- */
- tSCC zFixcsumText[] =
- "Force recalculation of IP/TCP/UDP checksums";
- tSCC zFixcsum_NAME[] = "FIXCSUM";
- tSCC zFixcsum_Name[] = "fixcsum";
- #define FIXCSUM_FLAGS (OPTST_DISABLED)
- /*
- * Mtu option description:
- */
- tSCC zMtuText[] =
- "Override default MTU length (1500 bytes)";
- tSCC zMtu_NAME[] = "MTU";
- tSCC zMtu_Name[] = "mtu";
- #define MTU_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * Efcs option description:
- */
- tSCC zEfcsText[] =
- "Remove Ethernet checksums (FCS) from end of frames";
- tSCC zEfcs_NAME[] = "EFCS";
- tSCC zEfcs_Name[] = "efcs";
- #define EFCS_FLAGS (OPTST_DISABLED)
- /*
- * Ttl option description:
- */
- tSCC zTtlText[] =
- "Modify the IPv4 TTL";
- tSCC zTtl_NAME[] = "TTL";
- tSCC zTtl_Name[] = "ttl";
- #define TTL_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Fixlen option description:
- */
- tSCC zFixlenText[] =
- "Pad or truncate packet data to match header length";
- tSCC zFixlen_NAME[] = "FIXLEN";
- tSCC zFixlen_Name[] = "fixlen";
- #define FIXLEN_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Skipl2broadcast option description:
- */
- tSCC zSkipl2broadcastText[] =
- "Skip rewriting broadcast/multicast Layer 2 addresses";
- tSCC zSkipl2broadcast_NAME[] = "SKIPL2BROADCAST";
- tSCC zSkipl2broadcast_Name[] = "skipl2broadcast";
- #define SKIPL2BROADCAST_FLAGS (OPTST_DISABLED)
- /*
- * Dlt option description:
- */
- tSCC zDltText[] =
- "Override output DLT encapsulation";
- tSCC zDlt_NAME[] = "DLT";
- tSCC zDlt_Name[] = "dlt";
- #define DLT_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Enet_Dmac option description:
- */
- tSCC zEnet_DmacText[] =
- "Override destination ethernet MAC addresses";
- tSCC zEnet_Dmac_NAME[] = "ENET_DMAC";
- tSCC zEnet_Dmac_Name[] = "enet-dmac";
- #define ENET_DMAC_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Enet_Smac option description:
- */
- tSCC zEnet_SmacText[] =
- "Override source ethernet MAC addresses";
- tSCC zEnet_Smac_NAME[] = "ENET_SMAC";
- tSCC zEnet_Smac_Name[] = "enet-smac";
- #define ENET_SMAC_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Enet_Vlan option description:
- */
- tSCC zEnet_VlanText[] =
- "Specify ethernet 802.1q VLAN tag mode";
- tSCC zEnet_Vlan_NAME[] = "ENET_VLAN";
- tSCC zEnet_Vlan_Name[] = "enet-vlan";
- #define ENET_VLAN_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Enet_Vlan_Tag option description with
- * "Must also have options" and "Incompatible options":
- */
- tSCC zEnet_Vlan_TagText[] =
- "Specify the new ethernet 802.1q VLAN tag value";
- tSCC zEnet_Vlan_Tag_NAME[] = "ENET_VLAN_TAG";
- tSCC zEnet_Vlan_Tag_Name[] = "enet-vlan-tag";
- static const int
- aEnet_Vlan_TagMustList[] = {
- INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
- #define ENET_VLAN_TAG_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * Enet_Vlan_Cfi option description with
- * "Must also have options" and "Incompatible options":
- */
- tSCC zEnet_Vlan_CfiText[] =
- "Specify the ethernet 802.1q VLAN CFI value";
- tSCC zEnet_Vlan_Cfi_NAME[] = "ENET_VLAN_CFI";
- tSCC zEnet_Vlan_Cfi_Name[] = "enet-vlan-cfi";
- static const int
- aEnet_Vlan_CfiMustList[] = {
- INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
- #define ENET_VLAN_CFI_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * Enet_Vlan_Pri option description with
- * "Must also have options" and "Incompatible options":
- */
- tSCC zEnet_Vlan_PriText[] =
- "Specify the ethernet 802.1q VLAN priority";
- tSCC zEnet_Vlan_Pri_NAME[] = "ENET_VLAN_PRI";
- tSCC zEnet_Vlan_Pri_Name[] = "enet-vlan-pri";
- static const int
- aEnet_Vlan_PriMustList[] = {
- INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
- #define ENET_VLAN_PRI_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * Hdlc_Control option description:
- */
- tSCC zHdlc_ControlText[] =
- "Specify HDLC control value";
- tSCC zHdlc_Control_NAME[] = "HDLC_CONTROL";
- tSCC zHdlc_Control_Name[] = "hdlc-control";
- #define HDLC_CONTROL_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * Hdlc_Address option description:
- */
- tSCC zHdlc_AddressText[] =
- "Specify HDLC address";
- tSCC zHdlc_Address_NAME[] = "HDLC_ADDRESS";
- tSCC zHdlc_Address_Name[] = "hdlc-address";
- #define HDLC_ADDRESS_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * User_Dlt option description:
- */
- tSCC zUser_DltText[] =
- "Set output file DLT type";
- tSCC zUser_Dlt_NAME[] = "USER_DLT";
- tSCC zUser_Dlt_Name[] = "user-dlt";
- #define USER_DLT_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- /*
- * User_Dlink option description:
- */
- tSCC zUser_DlinkText[] =
- "Rewrite Data-Link layer with user specified data";
- tSCC zUser_Dlink_NAME[] = "USER_DLINK";
- tSCC zUser_Dlink_Name[] = "user-dlink";
- #define USER_DLINK_FLAGS (OPTST_DISABLED | OPTST_STACKED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Dbug option description:
- */
- #ifdef DEBUG
- tSCC zDbugText[] =
- "Enable debugging output";
- tSCC zDbug_NAME[] = "DBUG";
- tSCC zDbug_Name[] = "dbug";
- #define zDbugDefaultArg ((char const*)0)
- #define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
- #else /* disable Dbug */
- #define VALUE_OPT_DBUG NO_EQUIVALENT
- #define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
- #define zDbugDefaultArg NULL
- #define zDbugText NULL
- #define zDbug_NAME NULL
- #define zDbug_Name NULL
- #endif /* DEBUG */
- /*
- * Infile option description:
- */
- tSCC zInfileText[] =
- "Input pcap file to be processed";
- tSCC zInfile_NAME[] = "INFILE";
- tSCC zInfile_Name[] = "infile";
- #define INFILE_FLAGS (OPTST_DISABLED | OPTST_MUST_SET | OPTST_IMM \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Outfile option description:
- */
- tSCC zOutfileText[] =
- "Output pcap file";
- tSCC zOutfile_NAME[] = "OUTFILE";
- tSCC zOutfile_Name[] = "outfile";
- #define OUTFILE_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Cachefile option description:
- */
- tSCC zCachefileText[] =
- "Split traffic via tcpprep cache file";
- tSCC zCachefile_NAME[] = "CACHEFILE";
- tSCC zCachefile_Name[] = "cachefile";
- #define CACHEFILE_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- /*
- * Verbose option description:
- */
- #ifdef ENABLE_VERBOSE
- tSCC zVerboseText[] =
- "Print decoded packets via tcpdump to STDOUT";
- tSCC zVerbose_NAME[] = "VERBOSE";
- tSCC zVerbose_Name[] = "verbose";
- #define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM)
- #else /* disable Verbose */
- #define VALUE_OPT_VERBOSE NO_EQUIVALENT
- #define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
- #define zVerboseText NULL
- #define zVerbose_NAME NULL
- #define zVerbose_Name NULL
- #endif /* ENABLE_VERBOSE */
- /*
- * Decode option description with
- * "Must also have options" and "Incompatible options":
- */
- #ifdef ENABLE_VERBOSE
- tSCC zDecodeText[] =
- "Arguments passed to tcpdump decoder";
- tSCC zDecode_NAME[] = "DECODE";
- tSCC zDecode_Name[] = "decode";
- static const int
- aDecodeMustList[] = {
- INDEX_OPT_VERBOSE, NO_EQUIVALENT };
- #define DECODE_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- #else /* disable Decode */
- #define VALUE_OPT_DECODE NO_EQUIVALENT
- #define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
- #define aDecodeMustList NULL
- #define zDecodeText NULL
- #define zDecode_NAME NULL
- #define zDecode_Name NULL
- #endif /* ENABLE_VERBOSE */
- /*
- * Fragroute option description:
- */
- #ifdef ENABLE_FRAGROUTE
- tSCC zFragrouteText[] =
- "Parse fragroute configuration file";
- tSCC zFragroute_NAME[] = "FRAGROUTE";
- tSCC zFragroute_Name[] = "fragroute";
- #define FRAGROUTE_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- #else /* disable Fragroute */
- #define VALUE_OPT_FRAGROUTE NO_EQUIVALENT
- #define FRAGROUTE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
- #define zFragrouteText NULL
- #define zFragroute_NAME NULL
- #define zFragroute_Name NULL
- #endif /* ENABLE_FRAGROUTE */
- /*
- * Fragdir option description:
- */
- #ifdef ENABLE_FRAGROUTE
- tSCC zFragdirText[] =
- "Which flows to apply fragroute to: c2s, s2c, both";
- tSCC zFragdir_NAME[] = "FRAGDIR";
- tSCC zFragdir_Name[] = "fragdir";
- #define FRAGDIR_FLAGS (OPTST_DISABLED \
- | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
- #else /* disable Fragdir */
- #define VALUE_OPT_FRAGDIR NO_EQUIVALENT
- #define FRAGDIR_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
- #define zFragdirText NULL
- #define zFragdir_NAME NULL
- #define zFragdir_Name NULL
- #endif /* ENABLE_FRAGROUTE */
- /*
- * Skip_Soft_Errors option description:
- */
- tSCC zSkip_Soft_ErrorsText[] =
- "Skip writing packets with soft errors";
- tSCC zSkip_Soft_Errors_NAME[] = "SKIP_SOFT_ERRORS";
- tSCC zSkip_Soft_Errors_Name[] = "skip-soft-errors";
- #define SKIP_SOFT_ERRORS_FLAGS (OPTST_DISABLED)
- /*
- * Version option description:
- */
- tSCC zVersionText[] =
- "Print version information";
- tSCC zVersion_NAME[] = "VERSION";
- tSCC zVersion_Name[] = "version";
- #define VERSION_FLAGS (OPTST_DISABLED)
- /*
- * Less_Help option description:
- */
- tSCC zLess_HelpText[] =
- "Display less usage information and exit";
- tSCC zLess_Help_NAME[] = "LESS_HELP";
- tSCC zLess_Help_Name[] = "less-help";
- #define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM)
- /*
- * Help/More_Help option descriptions:
- */
- tSCC zHelpText[] = "Display usage information and exit";
- tSCC zHelp_Name[] = "help";
- tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
- tSCC zMore_Help_Name[] = "more-help";
- /*
- * Save/Load_Opts option description:
- */
- tSCC zSave_OptsText[] = "Save the option state to a config file";
- tSCC zSave_Opts_Name[] = "save-opts";
- tSCC zLoad_OptsText[] = "Load options from a config file";
- tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
- tSCC zNotLoad_Opts_Name[] = "no-load-opts";
- tSCC zNotLoad_Opts_Pfx[] = "no";
- #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
- /*
- * Declare option callback procedures
- */
- #ifdef DEBUG
- static tOptProc doOptDbug;
- #else /* not DEBUG */
- # define doOptDbug NULL
- #endif /* def/not DEBUG */
- extern tOptProc
- optionNumericVal, optionPagedUsage, optionStackArg;
- static tOptProc
- doOptCachefile, doOptEnet_Vlan_Cfi, doOptEnet_Vlan_Pri,
- doOptEnet_Vlan_Tag, doOptLess_Help, doOptMtu,
- doOptVersion, doUsageOpt;
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * Define the Tcprewrite Option Descriptions.
- */
- static tOptDesc optDesc[ OPTION_CT ] = {
- { /* entry idx, value */ 0, 0,
- /* equiv idx, value */ 0, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 0, 0,
- /* opt state flags */ TCPEDIT_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zTcpeditText, NULL, NULL,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 1, VALUE_OPT_PORTMAP,
- /* equiv idx, value */ 1, VALUE_OPT_PORTMAP,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ PORTMAP_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zPortmapText, zPortmap_NAME, zPortmap_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 2, VALUE_OPT_SEED,
- /* equiv idx, value */ 2, VALUE_OPT_SEED,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SEED_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionNumericVal,
- /* desc, NAME, name */ zSeedText, zSeed_NAME, zSeed_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 3, VALUE_OPT_PNAT,
- /* equiv idx, value */ 3, VALUE_OPT_PNAT,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 2, 0,
- /* opt state flags */ PNAT_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, aPnatCantList,
- /* option proc */ optionStackArg,
- /* desc, NAME, name */ zPnatText, zPnat_NAME, zPnat_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 4, VALUE_OPT_SRCIPMAP,
- /* equiv idx, value */ 4, VALUE_OPT_SRCIPMAP,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SRCIPMAP_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, aSrcipmapCantList,
- /* option proc */ NULL,
- /* desc, NAME, name */ zSrcipmapText, zSrcipmap_NAME, zSrcipmap_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 5, VALUE_OPT_DSTIPMAP,
- /* equiv idx, value */ 5, VALUE_OPT_DSTIPMAP,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ DSTIPMAP_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, aDstipmapCantList,
- /* option proc */ NULL,
- /* desc, NAME, name */ zDstipmapText, zDstipmap_NAME, zDstipmap_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 6, VALUE_OPT_ENDPOINTS,
- /* equiv idx, value */ 6, VALUE_OPT_ENDPOINTS,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ ENDPOINTS_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ aEndpointsMustList, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zEndpointsText, zEndpoints_NAME, zEndpoints_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
- /* equiv idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SKIPBROADCAST_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zSkipbroadcastText, zSkipbroadcast_NAME, zSkipbroadcast_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 8, VALUE_OPT_FIXCSUM,
- /* equiv idx, value */ 8, VALUE_OPT_FIXCSUM,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ FIXCSUM_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zFixcsumText, zFixcsum_NAME, zFixcsum_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 9, VALUE_OPT_MTU,
- /* equiv idx, value */ 9, VALUE_OPT_MTU,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ MTU_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doOptMtu,
- /* desc, NAME, name */ zMtuText, zMtu_NAME, zMtu_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 10, VALUE_OPT_EFCS,
- /* equiv idx, value */ 10, VALUE_OPT_EFCS,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ EFCS_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zEfcsText, zEfcs_NAME, zEfcs_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 11, VALUE_OPT_TTL,
- /* equiv idx, value */ 11, VALUE_OPT_TTL,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ TTL_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zTtlText, zTtl_NAME, zTtl_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 12, VALUE_OPT_FIXLEN,
- /* equiv idx, value */ 12, VALUE_OPT_FIXLEN,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ FIXLEN_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zFixlenText, zFixlen_NAME, zFixlen_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 13, VALUE_OPT_SKIPL2BROADCAST,
- /* equiv idx, value */ 13, VALUE_OPT_SKIPL2BROADCAST,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SKIPL2BROADCAST_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zSkipl2broadcastText, zSkipl2broadcast_NAME, zSkipl2broadcast_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 14, VALUE_OPT_DLT,
- /* equiv idx, value */ 14, VALUE_OPT_DLT,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ DLT_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zDltText, zDlt_NAME, zDlt_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 15, VALUE_OPT_ENET_DMAC,
- /* equiv idx, value */ 15, VALUE_OPT_ENET_DMAC,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ ENET_DMAC_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zEnet_DmacText, zEnet_Dmac_NAME, zEnet_Dmac_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 16, VALUE_OPT_ENET_SMAC,
- /* equiv idx, value */ 16, VALUE_OPT_ENET_SMAC,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ ENET_SMAC_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zEnet_SmacText, zEnet_Smac_NAME, zEnet_Smac_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 17, VALUE_OPT_ENET_VLAN,
- /* equiv idx, value */ 17, VALUE_OPT_ENET_VLAN,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ ENET_VLAN_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zEnet_VlanText, zEnet_Vlan_NAME, zEnet_Vlan_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 18, VALUE_OPT_ENET_VLAN_TAG,
- /* equiv idx, value */ 18, VALUE_OPT_ENET_VLAN_TAG,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ ENET_VLAN_TAG_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ aEnet_Vlan_TagMustList, NULL,
- /* option proc */ doOptEnet_Vlan_Tag,
- /* desc, NAME, name */ zEnet_Vlan_TagText, zEnet_Vlan_Tag_NAME, zEnet_Vlan_Tag_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 19, VALUE_OPT_ENET_VLAN_CFI,
- /* equiv idx, value */ 19, VALUE_OPT_ENET_VLAN_CFI,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ ENET_VLAN_CFI_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ aEnet_Vlan_CfiMustList, NULL,
- /* option proc */ doOptEnet_Vlan_Cfi,
- /* desc, NAME, name */ zEnet_Vlan_CfiText, zEnet_Vlan_Cfi_NAME, zEnet_Vlan_Cfi_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 20, VALUE_OPT_ENET_VLAN_PRI,
- /* equiv idx, value */ 20, VALUE_OPT_ENET_VLAN_PRI,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ ENET_VLAN_PRI_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ aEnet_Vlan_PriMustList, NULL,
- /* option proc */ doOptEnet_Vlan_Pri,
- /* desc, NAME, name */ zEnet_Vlan_PriText, zEnet_Vlan_Pri_NAME, zEnet_Vlan_Pri_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 21, VALUE_OPT_HDLC_CONTROL,
- /* equiv idx, value */ 21, VALUE_OPT_HDLC_CONTROL,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ HDLC_CONTROL_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionNumericVal,
- /* desc, NAME, name */ zHdlc_ControlText, zHdlc_Control_NAME, zHdlc_Control_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 22, VALUE_OPT_HDLC_ADDRESS,
- /* equiv idx, value */ 22, VALUE_OPT_HDLC_ADDRESS,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ HDLC_ADDRESS_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionNumericVal,
- /* desc, NAME, name */ zHdlc_AddressText, zHdlc_Address_NAME, zHdlc_Address_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 23, VALUE_OPT_USER_DLT,
- /* equiv idx, value */ 23, VALUE_OPT_USER_DLT,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ USER_DLT_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionNumericVal,
- /* desc, NAME, name */ zUser_DltText, zUser_Dlt_NAME, zUser_Dlt_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 24, VALUE_OPT_USER_DLINK,
- /* equiv idx, value */ 24, VALUE_OPT_USER_DLINK,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 2, 0,
- /* opt state flags */ USER_DLINK_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionStackArg,
- /* desc, NAME, name */ zUser_DlinkText, zUser_Dlink_NAME, zUser_Dlink_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 25, VALUE_OPT_DBUG,
- /* equiv idx, value */ 25, VALUE_OPT_DBUG,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ DBUG_FLAGS, 0,
- /* last opt argumnt */ { zDbugDefaultArg },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doOptDbug,
- /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 26, VALUE_OPT_INFILE,
- /* equiv idx, value */ 26, VALUE_OPT_INFILE,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 1, 1, 0,
- /* opt state flags */ INFILE_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zInfileText, zInfile_NAME, zInfile_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 27, VALUE_OPT_OUTFILE,
- /* equiv idx, value */ 27, VALUE_OPT_OUTFILE,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 1, 1, 0,
- /* opt state flags */ OUTFILE_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zOutfileText, zOutfile_NAME, zOutfile_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 28, VALUE_OPT_CACHEFILE,
- /* equiv idx, value */ 28, VALUE_OPT_CACHEFILE,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ CACHEFILE_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doOptCachefile,
- /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 29, VALUE_OPT_VERBOSE,
- /* equiv idx, value */ 29, VALUE_OPT_VERBOSE,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ VERBOSE_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 30, VALUE_OPT_DECODE,
- /* equiv idx, value */ 30, VALUE_OPT_DECODE,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ DECODE_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ aDecodeMustList, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 31, VALUE_OPT_FRAGROUTE,
- /* equiv idx, value */ 31, VALUE_OPT_FRAGROUTE,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ FRAGROUTE_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zFragrouteText, zFragroute_NAME, zFragroute_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 32, VALUE_OPT_FRAGDIR,
- /* equiv idx, value */ 32, VALUE_OPT_FRAGDIR,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ FRAGDIR_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zFragdirText, zFragdir_NAME, zFragdir_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 33, VALUE_OPT_SKIP_SOFT_ERRORS,
- /* equiv idx, value */ 33, VALUE_OPT_SKIP_SOFT_ERRORS,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ SKIP_SOFT_ERRORS_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zSkip_Soft_ErrorsText, zSkip_Soft_Errors_NAME, zSkip_Soft_Errors_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 34, VALUE_OPT_VERSION,
- /* equiv idx, value */ 34, VALUE_OPT_VERSION,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ VERSION_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doOptVersion,
- /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 35, VALUE_OPT_LESS_HELP,
- /* equiv idx, value */ 35, VALUE_OPT_LESS_HELP,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ LESS_HELP_FLAGS, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doOptLess_Help,
- /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
- /* equiv idx value */ NO_EQUIVALENT, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ doUsageOpt,
- /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
- /* equiv idx value */ NO_EQUIVALENT, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionPagedUsage,
- /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
- /* equiv idx value */ NO_EQUIVALENT, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, 1, 0,
- /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
- | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ NULL,
- /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
- /* disablement strs */ NULL, NULL },
- { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
- /* equiv idx value */ NO_EQUIVALENT, 0,
- /* equivalenced to */ NO_EQUIVALENT,
- /* min, max, act ct */ 0, NOLIMIT, 0,
- /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
- | OPTST_DISABLE_IMM, 0,
- /* last opt argumnt */ { NULL },
- /* arg list/cookie */ NULL,
- /* must/cannot opts */ NULL, NULL,
- /* option proc */ optionLoadOpt,
- /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
- /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
- };
- tOptDesc * const tcpedit_tcpedit_optDesc_p = optDesc + 0;
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *
- * Define the Tcprewrite Option Environment
- */
- tSCC zPROGNAME[] = "TCPREWRITE";
- tSCC zUsageTitle[] =
- "tcprewrite (tcprewrite) - Rewrite the packets in a pcap file.\n\
- USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
- tSCC zRcName[] = ".tcprewriterc";
- tSCC* apzHomeList[] = {
- "$$/",
- NULL };
- #define zBugsAddr NULL
- #define zExplain NULL
- tSCC zDetail[] = "\n\
- Tcprewrite is a tool to rewrite packets stored in ``pcap(3)'' file format, \n\
- such as crated by tools such as ``tcpdump(1)'' and ``ethereal(1)''. \n\
- Once a pcap file has had it's packets rewritten, they can be replayed back \n\
- out on the network using ``tcpreplay(1)''.\n\n\
- tcprewrite currently supports reading the following DLT types:\n\n\n\
- ``DLT_C_HDLC'' aka Cisco HDLC\n\n\n\
- ``DLT_EN10MB'' aka Ethernet\n\n\n\
- ``DLT_LINUX_SLL'' aka Linux Cooked Socket\n\n\n\
- ``DLT_RAW'' aka RAW IP\n\n\n\
- ``DLT_NULL'' aka BSD Loopback\n\n\n\
- ``DLT_LOOP'' aka OpenBSD Loopback\n\n\n\
- ``DLT_IEEE802_11'' aka 802.11a/b/g\n\n\n\
- ``DLT_IEEE802_11_RADIO'' aka 802.11a/b/g with Radiotap headers\n\n\
- Please see the --dlt option for supported DLT types for writing.\n\n\
- The packet editing features of tcprewrite which distinguish between \"client\"\n\
- and \"server\" traffic requires a tcpprep(1) cache file.\n\n\
- For more details, please see the Tcpreplay Manual at:\n\
- http://tcpreplay.synfin.net/trac/wiki/manual\n";
- #define zFullVersion NULL
- /* extracted from /opt/local/share/autogen/optcode.tpl near line 428 */
- #if defined(ENABLE_NLS)
- # define OPTPROC_BASE OPTPROC_TRANSLATE
- static tOptionXlateProc translate_option_strings;
- #else
- # define OPTPROC_BASE OPTPROC_NONE
- # define translate_option_strings NULL
- #endif /* ENABLE_NLS */
- #define tcprewrite_full_usage NULL
- #define tcprewrite_short_usage NULL
- tOptions tcprewriteOptions = {
- OPTIONS_STRUCT_VERSION,
- 0, NULL, /* original argc + argv */
- ( OPTPROC_BASE
- + OPTPROC_ERRSTOP
- + OPTPROC_SHORTOPT
- + OPTPROC_LONGOPT
- + OPTPROC_NO_REQ_OPT
- + OPTPROC_NO_ARGS
- + OPTPROC_GNUUSAGE
- + OPTPROC_HAS_IMMED ),
- 0, NULL, /* current option index, current option */
- NULL, NULL, zPROGNAME,
- zRcName, zCopyright, zCopyrightNotice,
- zFullVersion, apzHomeList, zUsageTitle,
- zExplain, zDetail, optDesc,
- zBugsAddr, /* address to send bugs to */
- NULL, NULL, /* extensions/saved state */
- optionUsage, /* usage procedure */
- translate_option_strings, /* translation procedure */
- /*
- * Indexes to special options
- */
- { INDEX_OPT_MORE_HELP,
- INDEX_OPT_SAVE_OPTS,
- NO_EQUIVALENT /* index of '-#' option */,
- 9 /* index of default opt */
- },
- 40 /* full option count */, 36 /* user option count */,
- tcprewrite_full_usage, tcprewrite_short_usage
- };
- /*
- * Create the static procedure(s) declared above.
- */
- static void
- doUsageOpt(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- USAGE( EXIT_SUCCESS );
- }
- /* * * * * * *
- *
- * For the mtu option.
- */
- static void
- doOptMtu(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- static const struct {const int rmin, rmax;} rng[ 1 ] = {
- { 1, MAXPACKET } };
- int val;
- int ix;
- char const* pzIndent = "\t\t\t\t ";
- extern FILE* option_usage_fp;
- if (pOptDesc == NULL) /* usage is requesting range list
- option_usage_fp has already been set */
- goto emit_ranges;
- val = atoi( pOptDesc->optArg.argString );
- for (ix = 0; ix < 1; ix++) {
- if (val < rng[ix].rmin)
- continue; /* ranges need not be ordered. */
- if (val == rng[ix].rmin)
- goto valid_return;
- if (rng[ix].rmax == INT_MIN)
- continue;
- if (val <= rng[ix].rmax)
- goto valid_return;
- }
- option_usage_fp = stderr;
- fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
- pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
- pzIndent = "\t";
- emit_ranges:
- fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
- pzIndent, rng[0].rmin, rng[0].rmax );
- if (pOptDesc == NULL)
- return;
- USAGE( EXIT_FAILURE );
- /* NOTREACHED */
- return;
- valid_return:
- pOptDesc->optArg.argInt = val;
- }
- /* * * * * * *
- *
- * For the enet-vlan-tag option.
- */
- static void
- doOptEnet_Vlan_Tag(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- static const struct {const int rmin, rmax;} rng[ 1 ] = {
- { 0, 4095 } };
- int val;
- int ix;
- char const* pzIndent = "\t\t\t\t ";
- extern FILE* option_usage_fp;
- if (pOptDesc == NULL) /* usage is requesting range list
- option_usage_fp has already been set */
- goto emit_ranges;
- val = atoi( pOptDesc->optArg.argString );
- for (ix = 0; ix < 1; ix++) {
- if (val < rng[ix].rmin)
- continue; /* ranges need not be ordered. */
- if (val == rng[ix].rmin)
- goto valid_return;
- if (rng[ix].rmax == INT_MIN)
- continue;
- if (val <= rng[ix].rmax)
- goto valid_return;
- }
- option_usage_fp = stderr;
- fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
- pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
- pzIndent = "\t";
- emit_ranges:
- fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
- pzIndent, rng[0].rmin, rng[0].rmax );
- if (pOptDesc == NULL)
- return;
- USAGE( EXIT_FAILURE );
- /* NOTREACHED */
- return;
- valid_return:
- pOptDesc->optArg.argInt = val;
- }
- /* * * * * * *
- *
- * For the enet-vlan-cfi option.
- */
- static void
- doOptEnet_Vlan_Cfi(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- static const struct {const int rmin, rmax;} rng[ 1 ] = {
- { 0, 1 } };
- int val;
- int ix;
- char const* pzIndent = "\t\t\t\t ";
- extern FILE* option_usage_fp;
- if (pOptDesc == NULL) /* usage is requesting range list
- option_usage_fp has already been set */
- goto emit_ranges;
- val = atoi( pOptDesc->optArg.argString );
- for (ix = 0; ix < 1; ix++) {
- if (val < rng[ix].rmin)
- continue; /* ranges need not be ordered. */
- if (val == rng[ix].rmin)
- goto valid_return;
- if (rng[ix].rmax == INT_MIN)
- continue;
- if (val <= rng[ix].rmax)
- goto valid_return;
- }
- option_usage_fp = stderr;
- fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
- pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
- pzIndent = "\t";
- emit_ranges:
- fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
- pzIndent, rng[0].rmin, rng[0].rmax );
- if (pOptDesc == NULL)
- return;
- USAGE( EXIT_FAILURE );
- /* NOTREACHED */
- return;
- valid_return:
- pOptDesc->optArg.argInt = val;
- }
- /* * * * * * *
- *
- * For the enet-vlan-pri option.
- */
- static void
- doOptEnet_Vlan_Pri(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- static const struct {const int rmin, rmax;} rng[ 1 ] = {
- { 0, 7 } };
- int val;
- int ix;
- char const* pzIndent = "\t\t\t\t ";
- extern FILE* option_usage_fp;
- if (pOptDesc == NULL) /* usage is requesting range list
- option_usage_fp has already been set */
- goto emit_ranges;
- val = atoi( pOptDesc->optArg.argString );
- for (ix = 0; ix < 1; ix++) {
- if (val < rng[ix].rmin)
- continue; /* ranges need not be ordered. */
- if (val == rng[ix].rmin)
- goto valid_return;
- if (rng[ix].rmax == INT_MIN)
- continue;
- if (val <= rng[ix].rmax)
- goto valid_return;
- }
- option_usage_fp = stderr;
- fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
- pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
- pzIndent = "\t";
- emit_ranges:
- fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
- pzIndent, rng[0].rmin, rng[0].rmax );
- if (pOptDesc == NULL)
- return;
- USAGE( EXIT_FAILURE );
- /* NOTREACHED */
- return;
- valid_return:
- pOptDesc->optArg.argInt = val;
- }
- /* * * * * * *
- *
- * For the dbug option, when DEBUG is #define-d.
- */
- #ifdef DEBUG
- static void
- doOptDbug(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- static const struct {const int rmin, rmax;} rng[ 1 ] = {
- { 0, 5 } };
- int val;
- int ix;
- char const* pzIndent = "\t\t\t\t ";
- extern FILE* option_usage_fp;
- if (pOptDesc == NULL) /* usage is requesting range list
- option_usage_fp has already been set */
- goto emit_ranges;
- val = atoi( pOptDesc->optArg.argString );
- for (ix = 0; ix < 1; ix++) {
- if (val < rng[ix].rmin)
- continue; /* ranges need not be ordered. */
- if (val == rng[ix].rmin)
- goto valid_return;
- if (rng[ix].rmax == INT_MIN)
- continue;
- if (val <= rng[ix].rmax)
- goto valid_return;
- }
- option_usage_fp = stderr;
- fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
- pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
- pzIndent = "\t";
- emit_ranges:
- fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
- pzIndent, rng[0].rmin, rng[0].rmax );
- if (pOptDesc == NULL)
- return;
- USAGE( EXIT_FAILURE );
- /* NOTREACHED */
- return;
- valid_return:
- pOptDesc->optArg.argInt = val;
- }
- #endif /* defined DEBUG */
- /* * * * * * *
- *
- * For the cachefile option.
- */
- static void
- doOptCachefile(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- /* extracted from tcprewrite_opts.def, line 128 */
-
- options.cache_packets =
- read_cache(&options.cachedata, OPT_ARG(CACHEFILE), &options.comment);
- }
- /* * * * * * *
- *
- * For the version option.
- */
- static void
- doOptVersion(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- /* extracted from tcprewrite_opts.def, line 217 */
-
- fprintf(stderr, "tcprewrite 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 ENABLE_FRAGROUTE
- fprintf(stderr, "Fragroute engine: enabled\n");
- #else
- fprintf(stderr, "Fragroute engine: disabled\n");
- #endif
- exit(0);
-
- }
- /* * * * * * *
- *
- * For the less-help option.
- */
- static void
- doOptLess_Help(
- tOptions* pOptions,
- tOptDesc* pOptDesc )
- {
- /* extracted from tcprewrite_opts.def, line 262 */
-
- USAGE(EXIT_FAILURE);
- }
- /* extracted from /opt/local/share/autogen/optcode.tpl near line 537 */
- #if ENABLE_NLS
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <autoopts/usage-txt.h>
- static char* AO_gettext( char const* pz );
- static void coerce_it(void** s);
- static char*
- AO_gettext( char const* pz )
- {
- char* pzRes;
- if (pz == NULL)
- return NULL;
- pzRes = _(pz);
- if (pzRes == pz)
- return pzRes;
- pzRes = strdup( pzRes );
- if (pzRes == NULL) {
- fputs( _("No memory for duping translated strings\n"), stderr );
- exit( EXIT_FAILURE );
- }
- return pzRes;
- }
- static void coerce_it(void** s) { *s = AO_gettext(*s); }
- #define COERSION(_f) \
- coerce_it((void*)&(tcprewriteOptions._f))
- /*
- * This invokes the translation code (e.g. gettext(3)).
- */
- static void
- translate_option_strings( void )
- {
- /*
- * Guard against re-translation. It won't work. The strings will have
- * been changed by the first pass through this code. One shot only.
- */
- if (option_usage_text.field_ct == 0)
- return;
- /*
- * Do the translations. The first pointer follows the field count field.
- * The field count field is the size of a pointer.
- */
- {
- char** ppz = (char**)(void*)&(option_usage_text);
- int ix = option_usage_text.field_ct;
- do {
- ppz++;
- *ppz = AO_gettext(*ppz);
- } while (--ix > 0);
- }
- option_usage_text.field_ct = 0;
- {
- tOptDesc* pOD = tcprewriteOptions.pOptDesc;
- int ix = tcprewriteOptions.optCt;
- for (;;) {
- pOD->pzText = AO_gettext(pOD->pzText);
- pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
- pOD->pz_Name = AO_gettext(pOD->pz_Name);
- pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
- pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
- if (--ix <= 0)
- break;
- pOD++;
- }
- }
- COERSION(pzCopyright);
- COERSION(pzCopyNotice);
- COERSION(pzFullVersion);
- COERSION(pzUsageTitle);
- COERSION(pzExplain);
- COERSION(pzDetail);
- }
- #endif /* ENABLE_NLS */
- #ifdef __cplusplus
- }
- #endif
- /* tcprewrite_opts.c ends here */
|