tcpreplay_opts.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcpreplay_opts.c)
  4. *
  5. * It has been AutoGen-ed April 4, 2010 at 05:59:18 PM by AutoGen 5.9.9
  6. * From the definitions tcpreplay_opts.def
  7. * and the template file options
  8. *
  9. * Generated from AutoOpts 32:2:7 templates.
  10. */
  11. /*
  12. * This file was produced by an AutoOpts template. AutoOpts is a
  13. * copyrighted work. This source file is not encumbered by AutoOpts
  14. * licensing, but is provided under the licensing terms chosen by the
  15. * tcpreplay author or copyright holder. AutoOpts is licensed under
  16. * the terms of the LGPL. The redistributable library (``libopts'') is
  17. * licensed under the terms of either the LGPL or, at the users discretion,
  18. * the BSD license. See the AutoOpts and/or libopts sources for details.
  19. *
  20. * This source file is copyrighted and licensed under the following terms:
  21. *
  22. * tcpreplay copyright (c) 2000-2010 Aaron Turner - all rights reserved
  23. *
  24. * tcpreplay is free software copyrighted by Aaron Turner.
  25. *
  26. * Redistribution and use in source and binary forms, with or without
  27. * modification, are permitted provided that the following conditions
  28. * are met:
  29. * 1. Redistributions of source code must retain the above copyright
  30. * notice, this list of conditions and the following disclaimer.
  31. * 2. Redistributions in binary form must reproduce the above copyright
  32. * notice, this list of conditions and the following disclaimer in the
  33. * documentation and/or other materials provided with the distribution.
  34. * 3. Neither the name ``Aaron Turner'' nor the name of any other
  35. * contributor may be used to endorse or promote products derived
  36. * from this software without specific prior written permission.
  37. *
  38. * tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS
  39. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  40. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  41. * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS
  42. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  43. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  44. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  45. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  46. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  47. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  48. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49. */
  50. #include <sys/types.h>
  51. #include <limits.h>
  52. #include <stdio.h>
  53. #include <stdlib.h>
  54. #include <errno.h>
  55. extern FILE * option_usage_fp;
  56. #define OPTION_CODE_COMPILE 1
  57. #include "tcpreplay_opts.h"
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. /* TRANSLATORS: choose the translation for option names wisely because you
  62. cannot ever change your mind. */
  63. tSCC zCopyright[] =
  64. "tcpreplay copyright (c) 2000-2010 Aaron Turner, all rights reserved";
  65. tSCC zCopyrightNotice[1458] =
  66. "tcpreplay is free software copyrighted by Aaron Turner.\n\n\
  67. Redistribution and use in source and binary forms, with or without\n\
  68. modification, are permitted provided that the following conditions are met: 1.\n\
  69. Redistributions of source code must retain the above copyright notice, this\n\
  70. list of conditions and the following disclaimer. 2. Redistributions in binary\n\
  71. form must reproduce the above copyright notice, this list of conditions and the\n\
  72. following disclaimer in the documentation and/or other materials provided with\n\
  73. the distribution. 3. Neither the name ``Aaron Turner'' nor the name of any\n\
  74. other contributor may be used to endorse or promote products derived from this\n\
  75. software without specific prior written permission.\n\n\
  76. tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS OR IMPLIED\n\
  77. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\
  78. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n\
  79. EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n\
  80. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n\
  81. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\
  82. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\
  83. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n\
  84. OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\
  85. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
  86. extern tUsageProc optionUsage;
  87. /*
  88. * global included definitions
  89. */
  90. #include "defines.h"
  91. #include "tcpreplay.h"
  92. #include "common.h"
  93. #include "config.h"
  94. #include <stdlib.h>
  95. #include <sys/types.h>
  96. #include <unistd.h>
  97. extern tcpreplay_opt_t options;
  98. #ifndef NULL
  99. # define NULL 0
  100. #endif
  101. #ifndef EXIT_SUCCESS
  102. # define EXIT_SUCCESS 0
  103. #endif
  104. #ifndef EXIT_FAILURE
  105. # define EXIT_FAILURE 1
  106. #endif
  107. /*
  108. * Dbug option description:
  109. */
  110. #ifdef DEBUG
  111. tSCC zDbugText[] =
  112. "Enable debugging output";
  113. tSCC zDbug_NAME[] = "DBUG";
  114. tSCC zDbug_Name[] = "dbug";
  115. #define zDbugDefaultArg ((char const*)0)
  116. #define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \
  117. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  118. #else /* disable Dbug */
  119. #define VALUE_OPT_DBUG NO_EQUIVALENT
  120. #define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  121. #define zDbugDefaultArg NULL
  122. #define zDbugText NULL
  123. #define zDbug_NAME NULL
  124. #define zDbug_Name NULL
  125. #endif /* DEBUG */
  126. /*
  127. * Quiet option description:
  128. */
  129. tSCC zQuietText[] =
  130. "Quiet mode";
  131. tSCC zQuiet_NAME[] = "QUIET";
  132. tSCC zQuiet_Name[] = "quiet";
  133. #define QUIET_FLAGS (OPTST_DISABLED)
  134. /*
  135. * Timer option description:
  136. */
  137. tSCC zTimerText[] =
  138. "Select packet timing mode: select, ioport, rdtsc, gtod, nano, abstime";
  139. tSCC zTimer_NAME[] = "TIMER";
  140. tSCC zTimer_Name[] = "timer";
  141. tSCC zTimerDefaultArg[] = "gtod";
  142. #define TIMER_FLAGS (OPTST_DISABLED \
  143. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  144. /*
  145. * Sleep_Accel option description:
  146. */
  147. tSCC zSleep_AccelText[] =
  148. "Reduce the amount of time to sleep by specified usec";
  149. tSCC zSleep_Accel_NAME[] = "SLEEP_ACCEL";
  150. tSCC zSleep_Accel_Name[] = "sleep-accel";
  151. #define zSleep_AccelDefaultArg ((char const*)0)
  152. #define SLEEP_ACCEL_FLAGS (OPTST_DISABLED \
  153. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  154. /*
  155. * Rdtsc_Clicks option description:
  156. */
  157. tSCC zRdtsc_ClicksText[] =
  158. "Specify the RDTSC clicks/usec";
  159. tSCC zRdtsc_Clicks_NAME[] = "RDTSC_CLICKS";
  160. tSCC zRdtsc_Clicks_Name[] = "rdtsc-clicks";
  161. #define zRdtsc_ClicksDefaultArg ((char const*)0)
  162. #define RDTSC_CLICKS_FLAGS (OPTST_DISABLED \
  163. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  164. /*
  165. * Verbose option description:
  166. */
  167. #ifdef ENABLE_VERBOSE
  168. tSCC zVerboseText[] =
  169. "Print decoded packets via tcpdump to STDOUT";
  170. tSCC zVerbose_NAME[] = "VERBOSE";
  171. tSCC zVerbose_Name[] = "verbose";
  172. #define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM)
  173. #else /* disable Verbose */
  174. #define VALUE_OPT_VERBOSE NO_EQUIVALENT
  175. #define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  176. #define zVerboseText NULL
  177. #define zVerbose_NAME NULL
  178. #define zVerbose_Name NULL
  179. #endif /* ENABLE_VERBOSE */
  180. /*
  181. * Decode option description with
  182. * "Must also have options" and "Incompatible options":
  183. */
  184. #ifdef ENABLE_VERBOSE
  185. tSCC zDecodeText[] =
  186. "Arguments passed to tcpdump decoder";
  187. tSCC zDecode_NAME[] = "DECODE";
  188. tSCC zDecode_Name[] = "decode";
  189. static const int
  190. aDecodeMustList[] = {
  191. INDEX_OPT_VERBOSE, NO_EQUIVALENT };
  192. #define DECODE_FLAGS (OPTST_DISABLED \
  193. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  194. #else /* disable Decode */
  195. #define VALUE_OPT_DECODE NO_EQUIVALENT
  196. #define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  197. #define aDecodeMustList NULL
  198. #define zDecodeText NULL
  199. #define zDecode_NAME NULL
  200. #define zDecode_Name NULL
  201. #endif /* ENABLE_VERBOSE */
  202. /*
  203. * Enable_File_Cache option description with
  204. * "Must also have options" and "Incompatible options":
  205. */
  206. tSCC zEnable_File_CacheText[] =
  207. "Enable caching of packets to internal memory";
  208. tSCC zEnable_File_Cache_NAME[] = "ENABLE_FILE_CACHE";
  209. tSCC zEnable_File_Cache_Name[] = "enable-file-cache";
  210. static const int
  211. aEnable_File_CacheMustList[] = {
  212. INDEX_OPT_LOOP, NO_EQUIVALENT };
  213. #define ENABLE_FILE_CACHE_FLAGS (OPTST_DISABLED)
  214. /*
  215. * Preload_Pcap option description:
  216. */
  217. tSCC zPreload_PcapText[] =
  218. "Preloads packets into RAM before sending";
  219. tSCC zPreload_Pcap_NAME[] = "PRELOAD_PCAP";
  220. tSCC zPreload_Pcap_Name[] = "preload-pcap";
  221. #define PRELOAD_PCAP_FLAGS (OPTST_DISABLED)
  222. /*
  223. * Cachefile option description:
  224. */
  225. tSCC zCachefileText[] =
  226. "Split traffic via a tcpprep cache file";
  227. tSCC zCachefile_NAME[] = "CACHEFILE";
  228. tSCC zCachefile_Name[] = "cachefile";
  229. #define CACHEFILE_FLAGS (OPTST_DISABLED \
  230. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  231. /*
  232. * Intf1 option description:
  233. */
  234. tSCC zIntf1Text[] =
  235. "Server/primary traffic output interface";
  236. tSCC zIntf1_NAME[] = "INTF1";
  237. tSCC zIntf1_Name[] = "intf1";
  238. #define INTF1_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \
  239. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  240. /*
  241. * Intf2 option description with
  242. * "Must also have options" and "Incompatible options":
  243. */
  244. tSCC zIntf2Text[] =
  245. "Client/secondary traffic output interface";
  246. tSCC zIntf2_NAME[] = "INTF2";
  247. tSCC zIntf2_Name[] = "intf2";
  248. static const int
  249. aIntf2MustList[] = {
  250. INDEX_OPT_CACHEFILE, NO_EQUIVALENT };
  251. #define INTF2_FLAGS (OPTST_DISABLED \
  252. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  253. /*
  254. * Listnics option description:
  255. */
  256. #ifdef ENABLE_PCAP_FINDALLDEVS
  257. tSCC zListnicsText[] =
  258. "List available network interfaces and exit";
  259. tSCC zListnics_NAME[] = "LISTNICS";
  260. tSCC zListnics_Name[] = "listnics";
  261. #define LISTNICS_FLAGS (OPTST_DISABLED | OPTST_IMM)
  262. #else /* disable Listnics */
  263. #define VALUE_OPT_LISTNICS NO_EQUIVALENT
  264. #define LISTNICS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  265. #define zListnicsText NULL
  266. #define zListnics_NAME NULL
  267. #define zListnics_Name NULL
  268. #endif /* ENABLE_PCAP_FINDALLDEVS */
  269. /*
  270. * Loop option description:
  271. */
  272. tSCC zLoopText[] =
  273. "Loop through the capture file X times";
  274. tSCC zLoop_NAME[] = "LOOP";
  275. tSCC zLoop_Name[] = "loop";
  276. #define zLoopDefaultArg ((char const*)1)
  277. #define LOOP_FLAGS (OPTST_DISABLED \
  278. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  279. /*
  280. * Pktlen option description:
  281. */
  282. tSCC zPktlenText[] =
  283. "Override the snaplen and use the actual packet len";
  284. tSCC zPktlen_NAME[] = "PKTLEN";
  285. tSCC zPktlen_Name[] = "pktlen";
  286. #define PKTLEN_FLAGS (OPTST_DISABLED)
  287. /*
  288. * Limit option description:
  289. */
  290. tSCC zLimitText[] =
  291. "Limit the number of packets to send";
  292. tSCC zLimit_NAME[] = "LIMIT";
  293. tSCC zLimit_Name[] = "limit";
  294. #define zLimitDefaultArg ((char const*)-1)
  295. #define LIMIT_FLAGS (OPTST_DISABLED \
  296. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  297. /*
  298. * Multiplier option description with
  299. * "Must also have options" and "Incompatible options":
  300. */
  301. tSCC zMultiplierText[] =
  302. "Modify replay speed to a given multiple";
  303. tSCC zMultiplier_NAME[] = "MULTIPLIER";
  304. tSCC zMultiplier_Name[] = "multiplier";
  305. static const int
  306. aMultiplierCantList[] = {
  307. INDEX_OPT_PPS,
  308. INDEX_OPT_MBPS,
  309. INDEX_OPT_ONEATATIME,
  310. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  311. #define MULTIPLIER_FLAGS (OPTST_DISABLED \
  312. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  313. /*
  314. * Pps option description with
  315. * "Must also have options" and "Incompatible options":
  316. */
  317. tSCC zPpsText[] =
  318. "Replay packets at a given packets/sec";
  319. tSCC zPps_NAME[] = "PPS";
  320. tSCC zPps_Name[] = "pps";
  321. static const int
  322. aPpsCantList[] = {
  323. INDEX_OPT_MULTIPLIER,
  324. INDEX_OPT_MBPS,
  325. INDEX_OPT_ONEATATIME,
  326. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  327. #define PPS_FLAGS (OPTST_DISABLED \
  328. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  329. /*
  330. * Mbps option description with
  331. * "Must also have options" and "Incompatible options":
  332. */
  333. tSCC zMbpsText[] =
  334. "Replay packets at a given Mbps";
  335. tSCC zMbps_NAME[] = "MBPS";
  336. tSCC zMbps_Name[] = "mbps";
  337. static const int
  338. aMbpsCantList[] = {
  339. INDEX_OPT_MULTIPLIER,
  340. INDEX_OPT_PPS,
  341. INDEX_OPT_ONEATATIME,
  342. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  343. #define MBPS_FLAGS (OPTST_DISABLED \
  344. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  345. /*
  346. * Topspeed option description with
  347. * "Must also have options" and "Incompatible options":
  348. */
  349. tSCC zTopspeedText[] =
  350. "Replay packets as fast as possible";
  351. tSCC zTopspeed_NAME[] = "TOPSPEED";
  352. tSCC zTopspeed_Name[] = "topspeed";
  353. static const int
  354. aTopspeedCantList[] = {
  355. INDEX_OPT_MBPS,
  356. INDEX_OPT_MULTIPLIER,
  357. INDEX_OPT_PPS,
  358. INDEX_OPT_ONEATATIME, NO_EQUIVALENT };
  359. #define TOPSPEED_FLAGS (OPTST_DISABLED)
  360. /*
  361. * Oneatatime option description with
  362. * "Must also have options" and "Incompatible options":
  363. */
  364. tSCC zOneatatimeText[] =
  365. "Replay one packet at a time for each user input";
  366. tSCC zOneatatime_NAME[] = "ONEATATIME";
  367. tSCC zOneatatime_Name[] = "oneatatime";
  368. static const int
  369. aOneatatimeCantList[] = {
  370. INDEX_OPT_MBPS,
  371. INDEX_OPT_PPS,
  372. INDEX_OPT_MULTIPLIER,
  373. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  374. #define ONEATATIME_FLAGS (OPTST_DISABLED)
  375. /*
  376. * Pps_Multi option description with
  377. * "Must also have options" and "Incompatible options":
  378. */
  379. tSCC zPps_MultiText[] =
  380. "Number of packets to send for each time interval";
  381. tSCC zPps_Multi_NAME[] = "PPS_MULTI";
  382. tSCC zPps_Multi_Name[] = "pps-multi";
  383. #define zPps_MultiDefaultArg ((char const*)1)
  384. static const int
  385. aPps_MultiMustList[] = {
  386. INDEX_OPT_PPS, NO_EQUIVALENT };
  387. #define PPS_MULTI_FLAGS (OPTST_DISABLED \
  388. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  389. /*
  390. * Pid option description:
  391. */
  392. tSCC zPidText[] =
  393. "Print the PID of tcpreplay at startup";
  394. tSCC zPid_NAME[] = "PID";
  395. tSCC zPid_Name[] = "pid";
  396. #define PID_FLAGS (OPTST_DISABLED)
  397. /*
  398. * Stats option description:
  399. */
  400. tSCC zStatsText[] =
  401. "Print statistics every X seconds";
  402. tSCC zStats_NAME[] = "STATS";
  403. tSCC zStats_Name[] = "stats";
  404. #define STATS_FLAGS (OPTST_DISABLED \
  405. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  406. /*
  407. * Version option description:
  408. */
  409. tSCC zVersionText[] =
  410. "Print version information";
  411. tSCC zVersion_NAME[] = "VERSION";
  412. tSCC zVersion_Name[] = "version";
  413. #define VERSION_FLAGS (OPTST_DISABLED)
  414. /*
  415. * Less_Help option description:
  416. */
  417. tSCC zLess_HelpText[] =
  418. "Display less usage information and exit";
  419. tSCC zLess_Help_NAME[] = "LESS_HELP";
  420. tSCC zLess_Help_Name[] = "less-help";
  421. #define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM)
  422. /*
  423. * Help/More_Help option descriptions:
  424. */
  425. tSCC zHelpText[] = "Display usage information and exit";
  426. tSCC zHelp_Name[] = "help";
  427. tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
  428. tSCC zMore_Help_Name[] = "more-help";
  429. tSCC zSave_OptsText[] = "Save the option state to a config file";
  430. tSCC zSave_Opts_Name[] = "save-opts";
  431. tSCC zLoad_OptsText[] = "Load options from a config file";
  432. tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
  433. tSCC zNotLoad_Opts_Name[] = "no-load-opts";
  434. tSCC zNotLoad_Opts_Pfx[] = "no";
  435. #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
  436. /*
  437. * Declare option callback procedures
  438. */
  439. #ifdef DEBUG
  440. static tOptProc doOptDbug;
  441. #else /* not DEBUG */
  442. # define doOptDbug NULL
  443. #endif /* def/not DEBUG */
  444. #ifdef ENABLE_PCAP_FINDALLDEVS
  445. static tOptProc doOptListnics;
  446. #else /* not ENABLE_PCAP_FINDALLDEVS */
  447. # define doOptListnics NULL
  448. #endif /* def/not ENABLE_PCAP_FINDALLDEVS */
  449. extern tOptProc
  450. optionNumericVal, optionPagedUsage;
  451. static tOptProc
  452. doOptLess_Help, doOptLimit, doOptLoop, doOptPid,
  453. doOptPps_Multi, doOptStats, doOptVersion, doUsageOpt;
  454. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  455. *
  456. * Define the Tcpreplay Option Descriptions.
  457. */
  458. static tOptDesc optDesc[ OPTION_CT ] = {
  459. { /* entry idx, value */ 0, VALUE_OPT_DBUG,
  460. /* equiv idx, value */ 0, VALUE_OPT_DBUG,
  461. /* equivalenced to */ NO_EQUIVALENT,
  462. /* min, max, act ct */ 0, 1, 0,
  463. /* opt state flags */ DBUG_FLAGS, 0,
  464. /* last opt argumnt */ { zDbugDefaultArg },
  465. /* arg list/cookie */ NULL,
  466. /* must/cannot opts */ NULL, NULL,
  467. /* option proc */ doOptDbug,
  468. /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name,
  469. /* disablement strs */ NULL, NULL },
  470. { /* entry idx, value */ 1, VALUE_OPT_QUIET,
  471. /* equiv idx, value */ 1, VALUE_OPT_QUIET,
  472. /* equivalenced to */ NO_EQUIVALENT,
  473. /* min, max, act ct */ 0, 1, 0,
  474. /* opt state flags */ QUIET_FLAGS, 0,
  475. /* last opt argumnt */ { NULL },
  476. /* arg list/cookie */ NULL,
  477. /* must/cannot opts */ NULL, NULL,
  478. /* option proc */ NULL,
  479. /* desc, NAME, name */ zQuietText, zQuiet_NAME, zQuiet_Name,
  480. /* disablement strs */ NULL, NULL },
  481. { /* entry idx, value */ 2, VALUE_OPT_TIMER,
  482. /* equiv idx, value */ 2, VALUE_OPT_TIMER,
  483. /* equivalenced to */ NO_EQUIVALENT,
  484. /* min, max, act ct */ 0, 1, 0,
  485. /* opt state flags */ TIMER_FLAGS, 0,
  486. /* last opt argumnt */ { zTimerDefaultArg },
  487. /* arg list/cookie */ NULL,
  488. /* must/cannot opts */ NULL, NULL,
  489. /* option proc */ NULL,
  490. /* desc, NAME, name */ zTimerText, zTimer_NAME, zTimer_Name,
  491. /* disablement strs */ NULL, NULL },
  492. { /* entry idx, value */ 3, VALUE_OPT_SLEEP_ACCEL,
  493. /* equiv idx, value */ 3, VALUE_OPT_SLEEP_ACCEL,
  494. /* equivalenced to */ NO_EQUIVALENT,
  495. /* min, max, act ct */ 0, 1, 0,
  496. /* opt state flags */ SLEEP_ACCEL_FLAGS, 0,
  497. /* last opt argumnt */ { zSleep_AccelDefaultArg },
  498. /* arg list/cookie */ NULL,
  499. /* must/cannot opts */ NULL, NULL,
  500. /* option proc */ optionNumericVal,
  501. /* desc, NAME, name */ zSleep_AccelText, zSleep_Accel_NAME, zSleep_Accel_Name,
  502. /* disablement strs */ NULL, NULL },
  503. { /* entry idx, value */ 4, VALUE_OPT_RDTSC_CLICKS,
  504. /* equiv idx, value */ 4, VALUE_OPT_RDTSC_CLICKS,
  505. /* equivalenced to */ NO_EQUIVALENT,
  506. /* min, max, act ct */ 0, 1, 0,
  507. /* opt state flags */ RDTSC_CLICKS_FLAGS, 0,
  508. /* last opt argumnt */ { zRdtsc_ClicksDefaultArg },
  509. /* arg list/cookie */ NULL,
  510. /* must/cannot opts */ NULL, NULL,
  511. /* option proc */ optionNumericVal,
  512. /* desc, NAME, name */ zRdtsc_ClicksText, zRdtsc_Clicks_NAME, zRdtsc_Clicks_Name,
  513. /* disablement strs */ NULL, NULL },
  514. { /* entry idx, value */ 5, VALUE_OPT_VERBOSE,
  515. /* equiv idx, value */ 5, VALUE_OPT_VERBOSE,
  516. /* equivalenced to */ NO_EQUIVALENT,
  517. /* min, max, act ct */ 0, 1, 0,
  518. /* opt state flags */ VERBOSE_FLAGS, 0,
  519. /* last opt argumnt */ { NULL },
  520. /* arg list/cookie */ NULL,
  521. /* must/cannot opts */ NULL, NULL,
  522. /* option proc */ NULL,
  523. /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name,
  524. /* disablement strs */ NULL, NULL },
  525. { /* entry idx, value */ 6, VALUE_OPT_DECODE,
  526. /* equiv idx, value */ 6, VALUE_OPT_DECODE,
  527. /* equivalenced to */ NO_EQUIVALENT,
  528. /* min, max, act ct */ 0, 1, 0,
  529. /* opt state flags */ DECODE_FLAGS, 0,
  530. /* last opt argumnt */ { NULL },
  531. /* arg list/cookie */ NULL,
  532. /* must/cannot opts */ aDecodeMustList, NULL,
  533. /* option proc */ NULL,
  534. /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name,
  535. /* disablement strs */ NULL, NULL },
  536. { /* entry idx, value */ 7, VALUE_OPT_ENABLE_FILE_CACHE,
  537. /* equiv idx, value */ 7, VALUE_OPT_ENABLE_FILE_CACHE,
  538. /* equivalenced to */ NO_EQUIVALENT,
  539. /* min, max, act ct */ 0, 1, 0,
  540. /* opt state flags */ ENABLE_FILE_CACHE_FLAGS, 0,
  541. /* last opt argumnt */ { NULL },
  542. /* arg list/cookie */ NULL,
  543. /* must/cannot opts */ aEnable_File_CacheMustList, NULL,
  544. /* option proc */ NULL,
  545. /* desc, NAME, name */ zEnable_File_CacheText, zEnable_File_Cache_NAME, zEnable_File_Cache_Name,
  546. /* disablement strs */ NULL, NULL },
  547. { /* entry idx, value */ 8, VALUE_OPT_PRELOAD_PCAP,
  548. /* equiv idx, value */ 8, VALUE_OPT_PRELOAD_PCAP,
  549. /* equivalenced to */ NO_EQUIVALENT,
  550. /* min, max, act ct */ 0, 1, 0,
  551. /* opt state flags */ PRELOAD_PCAP_FLAGS, 0,
  552. /* last opt argumnt */ { NULL },
  553. /* arg list/cookie */ NULL,
  554. /* must/cannot opts */ NULL, NULL,
  555. /* option proc */ NULL,
  556. /* desc, NAME, name */ zPreload_PcapText, zPreload_Pcap_NAME, zPreload_Pcap_Name,
  557. /* disablement strs */ NULL, NULL },
  558. { /* entry idx, value */ 9, VALUE_OPT_CACHEFILE,
  559. /* equiv idx, value */ 9, VALUE_OPT_CACHEFILE,
  560. /* equivalenced to */ NO_EQUIVALENT,
  561. /* min, max, act ct */ 0, 1, 0,
  562. /* opt state flags */ CACHEFILE_FLAGS, 0,
  563. /* last opt argumnt */ { NULL },
  564. /* arg list/cookie */ NULL,
  565. /* must/cannot opts */ NULL, NULL,
  566. /* option proc */ NULL,
  567. /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name,
  568. /* disablement strs */ NULL, NULL },
  569. { /* entry idx, value */ 10, VALUE_OPT_INTF1,
  570. /* equiv idx, value */ 10, VALUE_OPT_INTF1,
  571. /* equivalenced to */ NO_EQUIVALENT,
  572. /* min, max, act ct */ 1, 1, 0,
  573. /* opt state flags */ INTF1_FLAGS, 0,
  574. /* last opt argumnt */ { NULL },
  575. /* arg list/cookie */ NULL,
  576. /* must/cannot opts */ NULL, NULL,
  577. /* option proc */ NULL,
  578. /* desc, NAME, name */ zIntf1Text, zIntf1_NAME, zIntf1_Name,
  579. /* disablement strs */ NULL, NULL },
  580. { /* entry idx, value */ 11, VALUE_OPT_INTF2,
  581. /* equiv idx, value */ 11, VALUE_OPT_INTF2,
  582. /* equivalenced to */ NO_EQUIVALENT,
  583. /* min, max, act ct */ 0, 1, 0,
  584. /* opt state flags */ INTF2_FLAGS, 0,
  585. /* last opt argumnt */ { NULL },
  586. /* arg list/cookie */ NULL,
  587. /* must/cannot opts */ aIntf2MustList, NULL,
  588. /* option proc */ NULL,
  589. /* desc, NAME, name */ zIntf2Text, zIntf2_NAME, zIntf2_Name,
  590. /* disablement strs */ NULL, NULL },
  591. { /* entry idx, value */ 12, VALUE_OPT_LISTNICS,
  592. /* equiv idx, value */ 12, VALUE_OPT_LISTNICS,
  593. /* equivalenced to */ NO_EQUIVALENT,
  594. /* min, max, act ct */ 0, 1, 0,
  595. /* opt state flags */ LISTNICS_FLAGS, 0,
  596. /* last opt argumnt */ { NULL },
  597. /* arg list/cookie */ NULL,
  598. /* must/cannot opts */ NULL, NULL,
  599. /* option proc */ doOptListnics,
  600. /* desc, NAME, name */ zListnicsText, zListnics_NAME, zListnics_Name,
  601. /* disablement strs */ NULL, NULL },
  602. { /* entry idx, value */ 13, VALUE_OPT_LOOP,
  603. /* equiv idx, value */ 13, VALUE_OPT_LOOP,
  604. /* equivalenced to */ NO_EQUIVALENT,
  605. /* min, max, act ct */ 0, 1, 0,
  606. /* opt state flags */ LOOP_FLAGS, 0,
  607. /* last opt argumnt */ { zLoopDefaultArg },
  608. /* arg list/cookie */ NULL,
  609. /* must/cannot opts */ NULL, NULL,
  610. /* option proc */ doOptLoop,
  611. /* desc, NAME, name */ zLoopText, zLoop_NAME, zLoop_Name,
  612. /* disablement strs */ NULL, NULL },
  613. { /* entry idx, value */ 14, VALUE_OPT_PKTLEN,
  614. /* equiv idx, value */ 14, VALUE_OPT_PKTLEN,
  615. /* equivalenced to */ NO_EQUIVALENT,
  616. /* min, max, act ct */ 0, 1, 0,
  617. /* opt state flags */ PKTLEN_FLAGS, 0,
  618. /* last opt argumnt */ { NULL },
  619. /* arg list/cookie */ NULL,
  620. /* must/cannot opts */ NULL, NULL,
  621. /* option proc */ NULL,
  622. /* desc, NAME, name */ zPktlenText, zPktlen_NAME, zPktlen_Name,
  623. /* disablement strs */ NULL, NULL },
  624. { /* entry idx, value */ 15, VALUE_OPT_LIMIT,
  625. /* equiv idx, value */ 15, VALUE_OPT_LIMIT,
  626. /* equivalenced to */ NO_EQUIVALENT,
  627. /* min, max, act ct */ 0, 1, 0,
  628. /* opt state flags */ LIMIT_FLAGS, 0,
  629. /* last opt argumnt */ { zLimitDefaultArg },
  630. /* arg list/cookie */ NULL,
  631. /* must/cannot opts */ NULL, NULL,
  632. /* option proc */ doOptLimit,
  633. /* desc, NAME, name */ zLimitText, zLimit_NAME, zLimit_Name,
  634. /* disablement strs */ NULL, NULL },
  635. { /* entry idx, value */ 16, VALUE_OPT_MULTIPLIER,
  636. /* equiv idx, value */ 16, VALUE_OPT_MULTIPLIER,
  637. /* equivalenced to */ NO_EQUIVALENT,
  638. /* min, max, act ct */ 0, 1, 0,
  639. /* opt state flags */ MULTIPLIER_FLAGS, 0,
  640. /* last opt argumnt */ { NULL },
  641. /* arg list/cookie */ NULL,
  642. /* must/cannot opts */ NULL, aMultiplierCantList,
  643. /* option proc */ NULL,
  644. /* desc, NAME, name */ zMultiplierText, zMultiplier_NAME, zMultiplier_Name,
  645. /* disablement strs */ NULL, NULL },
  646. { /* entry idx, value */ 17, VALUE_OPT_PPS,
  647. /* equiv idx, value */ 17, VALUE_OPT_PPS,
  648. /* equivalenced to */ NO_EQUIVALENT,
  649. /* min, max, act ct */ 0, 1, 0,
  650. /* opt state flags */ PPS_FLAGS, 0,
  651. /* last opt argumnt */ { NULL },
  652. /* arg list/cookie */ NULL,
  653. /* must/cannot opts */ NULL, aPpsCantList,
  654. /* option proc */ optionNumericVal,
  655. /* desc, NAME, name */ zPpsText, zPps_NAME, zPps_Name,
  656. /* disablement strs */ NULL, NULL },
  657. { /* entry idx, value */ 18, VALUE_OPT_MBPS,
  658. /* equiv idx, value */ 18, VALUE_OPT_MBPS,
  659. /* equivalenced to */ NO_EQUIVALENT,
  660. /* min, max, act ct */ 0, 1, 0,
  661. /* opt state flags */ MBPS_FLAGS, 0,
  662. /* last opt argumnt */ { NULL },
  663. /* arg list/cookie */ NULL,
  664. /* must/cannot opts */ NULL, aMbpsCantList,
  665. /* option proc */ NULL,
  666. /* desc, NAME, name */ zMbpsText, zMbps_NAME, zMbps_Name,
  667. /* disablement strs */ NULL, NULL },
  668. { /* entry idx, value */ 19, VALUE_OPT_TOPSPEED,
  669. /* equiv idx, value */ 19, VALUE_OPT_TOPSPEED,
  670. /* equivalenced to */ NO_EQUIVALENT,
  671. /* min, max, act ct */ 0, 1, 0,
  672. /* opt state flags */ TOPSPEED_FLAGS, 0,
  673. /* last opt argumnt */ { NULL },
  674. /* arg list/cookie */ NULL,
  675. /* must/cannot opts */ NULL, aTopspeedCantList,
  676. /* option proc */ NULL,
  677. /* desc, NAME, name */ zTopspeedText, zTopspeed_NAME, zTopspeed_Name,
  678. /* disablement strs */ NULL, NULL },
  679. { /* entry idx, value */ 20, VALUE_OPT_ONEATATIME,
  680. /* equiv idx, value */ 20, VALUE_OPT_ONEATATIME,
  681. /* equivalenced to */ NO_EQUIVALENT,
  682. /* min, max, act ct */ 0, 1, 0,
  683. /* opt state flags */ ONEATATIME_FLAGS, 0,
  684. /* last opt argumnt */ { NULL },
  685. /* arg list/cookie */ NULL,
  686. /* must/cannot opts */ NULL, aOneatatimeCantList,
  687. /* option proc */ NULL,
  688. /* desc, NAME, name */ zOneatatimeText, zOneatatime_NAME, zOneatatime_Name,
  689. /* disablement strs */ NULL, NULL },
  690. { /* entry idx, value */ 21, VALUE_OPT_PPS_MULTI,
  691. /* equiv idx, value */ 21, VALUE_OPT_PPS_MULTI,
  692. /* equivalenced to */ NO_EQUIVALENT,
  693. /* min, max, act ct */ 0, 1, 0,
  694. /* opt state flags */ PPS_MULTI_FLAGS, 0,
  695. /* last opt argumnt */ { zPps_MultiDefaultArg },
  696. /* arg list/cookie */ NULL,
  697. /* must/cannot opts */ aPps_MultiMustList, NULL,
  698. /* option proc */ doOptPps_Multi,
  699. /* desc, NAME, name */ zPps_MultiText, zPps_Multi_NAME, zPps_Multi_Name,
  700. /* disablement strs */ NULL, NULL },
  701. { /* entry idx, value */ 22, VALUE_OPT_PID,
  702. /* equiv idx, value */ 22, VALUE_OPT_PID,
  703. /* equivalenced to */ NO_EQUIVALENT,
  704. /* min, max, act ct */ 0, 1, 0,
  705. /* opt state flags */ PID_FLAGS, 0,
  706. /* last opt argumnt */ { NULL },
  707. /* arg list/cookie */ NULL,
  708. /* must/cannot opts */ NULL, NULL,
  709. /* option proc */ doOptPid,
  710. /* desc, NAME, name */ zPidText, zPid_NAME, zPid_Name,
  711. /* disablement strs */ NULL, NULL },
  712. { /* entry idx, value */ 23, VALUE_OPT_STATS,
  713. /* equiv idx, value */ 23, VALUE_OPT_STATS,
  714. /* equivalenced to */ NO_EQUIVALENT,
  715. /* min, max, act ct */ 0, 1, 0,
  716. /* opt state flags */ STATS_FLAGS, 0,
  717. /* last opt argumnt */ { NULL },
  718. /* arg list/cookie */ NULL,
  719. /* must/cannot opts */ NULL, NULL,
  720. /* option proc */ doOptStats,
  721. /* desc, NAME, name */ zStatsText, zStats_NAME, zStats_Name,
  722. /* disablement strs */ NULL, NULL },
  723. { /* entry idx, value */ 24, VALUE_OPT_VERSION,
  724. /* equiv idx, value */ 24, VALUE_OPT_VERSION,
  725. /* equivalenced to */ NO_EQUIVALENT,
  726. /* min, max, act ct */ 0, 1, 0,
  727. /* opt state flags */ VERSION_FLAGS, 0,
  728. /* last opt argumnt */ { NULL },
  729. /* arg list/cookie */ NULL,
  730. /* must/cannot opts */ NULL, NULL,
  731. /* option proc */ doOptVersion,
  732. /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name,
  733. /* disablement strs */ NULL, NULL },
  734. { /* entry idx, value */ 25, VALUE_OPT_LESS_HELP,
  735. /* equiv idx, value */ 25, VALUE_OPT_LESS_HELP,
  736. /* equivalenced to */ NO_EQUIVALENT,
  737. /* min, max, act ct */ 0, 1, 0,
  738. /* opt state flags */ LESS_HELP_FLAGS, 0,
  739. /* last opt argumnt */ { NULL },
  740. /* arg list/cookie */ NULL,
  741. /* must/cannot opts */ NULL, NULL,
  742. /* option proc */ doOptLess_Help,
  743. /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name,
  744. /* disablement strs */ NULL, NULL },
  745. { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
  746. /* equiv idx value */ NO_EQUIVALENT, 0,
  747. /* equivalenced to */ NO_EQUIVALENT,
  748. /* min, max, act ct */ 0, 1, 0,
  749. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  750. /* last opt argumnt */ { NULL },
  751. /* arg list/cookie */ NULL,
  752. /* must/cannot opts */ NULL, NULL,
  753. /* option proc */ doUsageOpt,
  754. /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
  755. /* disablement strs */ NULL, NULL },
  756. { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
  757. /* equiv idx value */ NO_EQUIVALENT, 0,
  758. /* equivalenced to */ NO_EQUIVALENT,
  759. /* min, max, act ct */ 0, 1, 0,
  760. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  761. /* last opt argumnt */ { NULL },
  762. /* arg list/cookie */ NULL,
  763. /* must/cannot opts */ NULL, NULL,
  764. /* option proc */ optionPagedUsage,
  765. /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
  766. /* disablement strs */ NULL, NULL },
  767. { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
  768. /* equiv idx value */ NO_EQUIVALENT, 0,
  769. /* equivalenced to */ NO_EQUIVALENT,
  770. /* min, max, act ct */ 0, 1, 0,
  771. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  772. | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
  773. /* last opt argumnt */ { NULL },
  774. /* arg list/cookie */ NULL,
  775. /* must/cannot opts */ NULL, NULL,
  776. /* option proc */ NULL,
  777. /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
  778. /* disablement strs */ NULL, NULL },
  779. { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
  780. /* equiv idx value */ NO_EQUIVALENT, 0,
  781. /* equivalenced to */ NO_EQUIVALENT,
  782. /* min, max, act ct */ 0, NOLIMIT, 0,
  783. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  784. | OPTST_DISABLE_IMM, 0,
  785. /* last opt argumnt */ { NULL },
  786. /* arg list/cookie */ NULL,
  787. /* must/cannot opts */ NULL, NULL,
  788. /* option proc */ optionLoadOpt,
  789. /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
  790. /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
  791. };
  792. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  793. *
  794. * Define the Tcpreplay Option Environment
  795. */
  796. tSCC zPROGNAME[] = "TCPREPLAY";
  797. tSCC zUsageTitle[] =
  798. "tcpreplay (tcpreplay) - Replay network traffic stored in pcap files\n\
  799. USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... <pcap_file(s)>\n";
  800. tSCC zRcName[] = ".tcpreplayrc";
  801. tSCC* apzHomeList[] = {
  802. "$$/",
  803. NULL };
  804. #define zBugsAddr NULL
  805. tSCC zExplain[] = "\n\
  806. tcpreplay is a tool for replaying network traffic from files saved with\n\
  807. tcpdump or other tools which write pcap(3) files.\n";
  808. tSCC zDetail[] = "\n\
  809. The basic operation of tcpreplay is to resend all packets from the\n\
  810. input file(s) at the speed at which they were recorded, or a specified \n\
  811. data rate, up to as fast as the hardware is capable.\n\n\
  812. Optionally, the traffic can be split between two interfaces, written to\n\
  813. files, filtered and edited in various ways, providing the means to test\n\
  814. firewalls, NIDS and other network devices.\n\n\
  815. For more details, please see the Tcpreplay Manual at:\n\
  816. http://tcpreplay.synfin.net/trac/wiki/manual\n";
  817. #define zFullVersion NULL
  818. /* extracted from /usr/local/share/autogen/optcode.tpl near line 501 */
  819. #if defined(ENABLE_NLS)
  820. # define OPTPROC_BASE OPTPROC_TRANSLATE
  821. static tOptionXlateProc translate_option_strings;
  822. #else
  823. # define OPTPROC_BASE OPTPROC_NONE
  824. # define translate_option_strings NULL
  825. #endif /* ENABLE_NLS */
  826. #define tcpreplay_full_usage NULL
  827. #define tcpreplay_short_usage NULL
  828. tOptions tcpreplayOptions = {
  829. OPTIONS_STRUCT_VERSION,
  830. 0, NULL, /* original argc + argv */
  831. ( OPTPROC_BASE
  832. + OPTPROC_ERRSTOP
  833. + OPTPROC_SHORTOPT
  834. + OPTPROC_LONGOPT
  835. + OPTPROC_NO_REQ_OPT
  836. + OPTPROC_ARGS_REQ
  837. + OPTPROC_GNUUSAGE ),
  838. 0, NULL, /* current option index, current option */
  839. NULL, NULL, zPROGNAME,
  840. zRcName, zCopyright, zCopyrightNotice,
  841. zFullVersion, apzHomeList, zUsageTitle,
  842. zExplain, zDetail, optDesc,
  843. zBugsAddr, /* address to send bugs to */
  844. NULL, NULL, /* extensions/saved state */
  845. optionUsage, /* usage procedure */
  846. translate_option_strings, /* translation procedure */
  847. /*
  848. * Indexes to special options
  849. */
  850. { INDEX_OPT_MORE_HELP, /* more-help option index */
  851. INDEX_OPT_SAVE_OPTS, /* save option index */
  852. NO_EQUIVALENT, /* '-#' option index */
  853. NO_EQUIVALENT /* index of default opt */
  854. },
  855. 30 /* full option count */, 26 /* user option count */,
  856. tcpreplay_full_usage, tcpreplay_short_usage,
  857. NULL, NULL
  858. };
  859. /*
  860. * Create the static procedure(s) declared above.
  861. */
  862. static void
  863. doUsageOpt(
  864. tOptions* pOptions,
  865. tOptDesc* pOptDesc )
  866. {
  867. (void)pOptions;
  868. USAGE( EXIT_SUCCESS );
  869. }
  870. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  871. *
  872. * For the dbug option, when DEBUG is #define-d.
  873. */
  874. #ifdef DEBUG
  875. static void
  876. doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc)
  877. {
  878. static const struct {long const rmin, rmax;} rng[1] = {
  879. { 0, 5 } };
  880. long val;
  881. int ix;
  882. char * pzEnd;
  883. if (pOptions <= OPTPROC_EMIT_LIMIT)
  884. goto emit_ranges;
  885. errno = 0;
  886. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  887. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  888. goto bad_value;
  889. if (*pzEnd != '\0')
  890. goto bad_value;
  891. for (ix = 0; ix < 1; ix++) {
  892. if (val < rng[ix].rmin)
  893. continue; /* ranges need not be ordered. */
  894. if (val == rng[ix].rmin)
  895. goto valid_return;
  896. if (rng[ix].rmax == LONG_MIN)
  897. continue;
  898. if (val <= rng[ix].rmax)
  899. goto valid_return;
  900. }
  901. bad_value:
  902. option_usage_fp = stderr;
  903. emit_ranges:
  904. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  905. return;
  906. valid_return:
  907. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  908. free((void *)pOptDesc->optArg.argString);
  909. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  910. }
  911. pOptDesc->optArg.argInt = val;
  912. }
  913. #endif /* defined DEBUG */
  914. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  915. *
  916. * For the listnics option, when ENABLE_PCAP_FINDALLDEVS is #define-d.
  917. */
  918. #ifdef ENABLE_PCAP_FINDALLDEVS
  919. static void
  920. doOptListnics(tOptions* pOptions, tOptDesc* pOptDesc)
  921. {
  922. /* extracted from tcpreplay_opts.def, line 267 */
  923. interface_list_t *list = get_interface_list();
  924. list_interfaces(list);
  925. free(list);
  926. exit(0);
  927. }
  928. #endif /* defined ENABLE_PCAP_FINDALLDEVS */
  929. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  930. *
  931. * For the loop option.
  932. */
  933. static void
  934. doOptLoop(tOptions* pOptions, tOptDesc* pOptDesc)
  935. {
  936. static const struct {long const rmin, rmax;} rng[1] = {
  937. { 0, LONG_MAX } };
  938. long val;
  939. int ix;
  940. char * pzEnd;
  941. if (pOptions <= OPTPROC_EMIT_LIMIT)
  942. goto emit_ranges;
  943. errno = 0;
  944. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  945. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  946. goto bad_value;
  947. if (*pzEnd != '\0')
  948. goto bad_value;
  949. for (ix = 0; ix < 1; ix++) {
  950. if (val < rng[ix].rmin)
  951. continue; /* ranges need not be ordered. */
  952. if (val == rng[ix].rmin)
  953. goto valid_return;
  954. if (rng[ix].rmax == LONG_MIN)
  955. continue;
  956. if (val <= rng[ix].rmax)
  957. goto valid_return;
  958. }
  959. bad_value:
  960. option_usage_fp = stderr;
  961. emit_ranges:
  962. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  963. return;
  964. valid_return:
  965. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  966. free((void *)pOptDesc->optArg.argString);
  967. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  968. }
  969. pOptDesc->optArg.argInt = val;
  970. }
  971. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  972. *
  973. * For the limit option.
  974. */
  975. static void
  976. doOptLimit(tOptions* pOptions, tOptDesc* pOptDesc)
  977. {
  978. static const struct {long const rmin, rmax;} rng[1] = {
  979. { 1, LONG_MAX } };
  980. long val;
  981. int ix;
  982. char * pzEnd;
  983. if (pOptions <= OPTPROC_EMIT_LIMIT)
  984. goto emit_ranges;
  985. errno = 0;
  986. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  987. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  988. goto bad_value;
  989. if (*pzEnd != '\0')
  990. goto bad_value;
  991. for (ix = 0; ix < 1; ix++) {
  992. if (val < rng[ix].rmin)
  993. continue; /* ranges need not be ordered. */
  994. if (val == rng[ix].rmin)
  995. goto valid_return;
  996. if (rng[ix].rmax == LONG_MIN)
  997. continue;
  998. if (val <= rng[ix].rmax)
  999. goto valid_return;
  1000. }
  1001. bad_value:
  1002. option_usage_fp = stderr;
  1003. emit_ranges:
  1004. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  1005. return;
  1006. valid_return:
  1007. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  1008. free((void *)pOptDesc->optArg.argString);
  1009. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  1010. }
  1011. pOptDesc->optArg.argInt = val;
  1012. }
  1013. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1014. *
  1015. * For the pps-multi option.
  1016. */
  1017. static void
  1018. doOptPps_Multi(tOptions* pOptions, tOptDesc* pOptDesc)
  1019. {
  1020. static const struct {long const rmin, rmax;} rng[1] = {
  1021. { 1, LONG_MAX } };
  1022. long val;
  1023. int ix;
  1024. char * pzEnd;
  1025. if (pOptions <= OPTPROC_EMIT_LIMIT)
  1026. goto emit_ranges;
  1027. errno = 0;
  1028. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  1029. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  1030. goto bad_value;
  1031. if (*pzEnd != '\0')
  1032. goto bad_value;
  1033. for (ix = 0; ix < 1; ix++) {
  1034. if (val < rng[ix].rmin)
  1035. continue; /* ranges need not be ordered. */
  1036. if (val == rng[ix].rmin)
  1037. goto valid_return;
  1038. if (rng[ix].rmax == LONG_MIN)
  1039. continue;
  1040. if (val <= rng[ix].rmax)
  1041. goto valid_return;
  1042. }
  1043. bad_value:
  1044. option_usage_fp = stderr;
  1045. emit_ranges:
  1046. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  1047. return;
  1048. valid_return:
  1049. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  1050. free((void *)pOptDesc->optArg.argString);
  1051. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  1052. }
  1053. pOptDesc->optArg.argInt = val;
  1054. }
  1055. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1056. *
  1057. * For the pid option.
  1058. */
  1059. static void
  1060. doOptPid(tOptions* pOptions, tOptDesc* pOptDesc)
  1061. {
  1062. /* extracted from tcpreplay_opts.def, line 417 */
  1063. fprintf(stderr, "PID: %hu\n", getpid());
  1064. }
  1065. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1066. *
  1067. * For the stats option.
  1068. */
  1069. static void
  1070. doOptStats(tOptions* pOptions, tOptDesc* pOptDesc)
  1071. {
  1072. static const struct {long const rmin, rmax;} rng[1] = {
  1073. { 1, LONG_MAX } };
  1074. long val;
  1075. int ix;
  1076. char * pzEnd;
  1077. if (pOptions <= OPTPROC_EMIT_LIMIT)
  1078. goto emit_ranges;
  1079. errno = 0;
  1080. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  1081. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  1082. goto bad_value;
  1083. if (*pzEnd != '\0')
  1084. goto bad_value;
  1085. for (ix = 0; ix < 1; ix++) {
  1086. if (val < rng[ix].rmin)
  1087. continue; /* ranges need not be ordered. */
  1088. if (val == rng[ix].rmin)
  1089. goto valid_return;
  1090. if (rng[ix].rmax == LONG_MIN)
  1091. continue;
  1092. if (val <= rng[ix].rmax)
  1093. goto valid_return;
  1094. }
  1095. bad_value:
  1096. option_usage_fp = stderr;
  1097. emit_ranges:
  1098. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  1099. return;
  1100. valid_return:
  1101. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  1102. free((void *)pOptDesc->optArg.argString);
  1103. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  1104. }
  1105. pOptDesc->optArg.argInt = val;
  1106. }
  1107. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1108. *
  1109. * For the version option.
  1110. */
  1111. static void
  1112. doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc)
  1113. {
  1114. /* extracted from tcpreplay_opts.def, line 440 */
  1115. fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version());
  1116. #ifdef DEBUG
  1117. fprintf(stderr, " (debug)");
  1118. #endif
  1119. fprintf(stderr, "\n");
  1120. fprintf(stderr, "Copyright 2000-2010 by Aaron Turner <aturner at synfin dot net>\n");
  1121. fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION);
  1122. #ifdef HAVE_LIBDNET
  1123. fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION);
  1124. #else
  1125. fprintf(stderr, "Not compiled with libdnet.\n");
  1126. #endif
  1127. #ifdef HAVE_WINPCAP
  1128. fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
  1129. #else
  1130. fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
  1131. #endif
  1132. #ifdef ENABLE_64BITS
  1133. fprintf(stderr, "64 bit packet counters: enabled\n");
  1134. #else
  1135. fprintf(stderr, "64 bit packet counters: disabled\n");
  1136. #endif
  1137. #ifdef ENABLE_VERBOSE
  1138. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  1139. #else
  1140. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  1141. #endif
  1142. #ifdef TCPREPLAY_EDIT
  1143. fprintf(stderr, "Packet editing: enabled\n");
  1144. #else
  1145. fprintf(stderr, "Packet editing: disabled\n");
  1146. #endif
  1147. #ifdef ENABLE_FRAGROUTE
  1148. fprintf(stderr, "Fragroute engine: enabled\n");
  1149. #else
  1150. fprintf(stderr, "Fragroute engine: disabled\n");
  1151. #endif
  1152. fprintf(stderr, "Injection method: %s\n", sendpacket_get_method());
  1153. exit(0);
  1154. }
  1155. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1156. *
  1157. * For the less-help option.
  1158. */
  1159. static void
  1160. doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc)
  1161. {
  1162. /* extracted from tcpreplay_opts.def, line 491 */
  1163. USAGE(EXIT_FAILURE);
  1164. }
  1165. /* extracted from /usr/local/share/autogen/optcode.tpl near line 633 */
  1166. #if ENABLE_NLS
  1167. #include <stdio.h>
  1168. #include <stdlib.h>
  1169. #include <string.h>
  1170. #include <unistd.h>
  1171. #include <autoopts/usage-txt.h>
  1172. static char* AO_gettext( char const* pz );
  1173. static void coerce_it(void** s);
  1174. static char*
  1175. AO_gettext( char const* pz )
  1176. {
  1177. char* pzRes;
  1178. if (pz == NULL)
  1179. return NULL;
  1180. pzRes = _(pz);
  1181. if (pzRes == pz)
  1182. return pzRes;
  1183. pzRes = strdup( pzRes );
  1184. if (pzRes == NULL) {
  1185. fputs( _("No memory for duping translated strings\n"), stderr );
  1186. exit( EXIT_FAILURE );
  1187. }
  1188. return pzRes;
  1189. }
  1190. static void coerce_it(void** s) { *s = AO_gettext(*s); }
  1191. #define COERSION(_f) \
  1192. coerce_it((void*)&(tcpreplayOptions._f))
  1193. /*
  1194. * This invokes the translation code (e.g. gettext(3)).
  1195. */
  1196. static void
  1197. translate_option_strings( void )
  1198. {
  1199. /*
  1200. * Guard against re-translation. It won't work. The strings will have
  1201. * been changed by the first pass through this code. One shot only.
  1202. */
  1203. if (option_usage_text.field_ct != 0) {
  1204. /*
  1205. * Do the translations. The first pointer follows the field count
  1206. * field. The field count field is the size of a pointer.
  1207. */
  1208. tOptDesc* pOD = tcpreplayOptions.pOptDesc;
  1209. char** ppz = (char**)(void*)&(option_usage_text);
  1210. int ix = option_usage_text.field_ct;
  1211. do {
  1212. ppz++;
  1213. *ppz = AO_gettext(*ppz);
  1214. } while (--ix > 0);
  1215. COERSION(pzCopyright);
  1216. COERSION(pzCopyNotice);
  1217. COERSION(pzFullVersion);
  1218. COERSION(pzUsageTitle);
  1219. COERSION(pzExplain);
  1220. COERSION(pzDetail);
  1221. option_usage_text.field_ct = 0;
  1222. for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++)
  1223. coerce_it((void*)&(pOD->pzText));
  1224. }
  1225. if ((tcpreplayOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
  1226. tOptDesc* pOD = tcpreplayOptions.pOptDesc;
  1227. int ix;
  1228. for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++) {
  1229. coerce_it((void*)&(pOD->pz_Name));
  1230. coerce_it((void*)&(pOD->pz_DisableName));
  1231. coerce_it((void*)&(pOD->pz_DisablePfx));
  1232. }
  1233. /* prevent re-translation */
  1234. tcpreplayOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
  1235. }
  1236. }
  1237. #endif /* ENABLE_NLS */
  1238. #ifdef __cplusplus
  1239. }
  1240. #endif
  1241. /* tcpreplay_opts.c ends here */