tcpreplay_opts.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  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 Sunday January 18, 2009 at 10:08:03 AM PST
  6. * From the definitions tcpreplay_opts.def
  7. * and the template file options
  8. *
  9. * Generated from AutoOpts 32:0: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 2000-2008 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-2008 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. * Cachefile option description:
  216. */
  217. tSCC zCachefileText[] =
  218. "Split traffic via a tcpprep cache file";
  219. tSCC zCachefile_NAME[] = "CACHEFILE";
  220. tSCC zCachefile_Name[] = "cachefile";
  221. #define CACHEFILE_FLAGS (OPTST_DISABLED \
  222. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  223. /*
  224. * Intf1 option description:
  225. */
  226. tSCC zIntf1Text[] =
  227. "Server/primary traffic output interface";
  228. tSCC zIntf1_NAME[] = "INTF1";
  229. tSCC zIntf1_Name[] = "intf1";
  230. #define INTF1_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \
  231. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  232. /*
  233. * Intf2 option description with
  234. * "Must also have options" and "Incompatible options":
  235. */
  236. tSCC zIntf2Text[] =
  237. "Client/secondary traffic output interface";
  238. tSCC zIntf2_NAME[] = "INTF2";
  239. tSCC zIntf2_Name[] = "intf2";
  240. static const int
  241. aIntf2MustList[] = {
  242. INDEX_OPT_CACHEFILE, NO_EQUIVALENT };
  243. #define INTF2_FLAGS (OPTST_DISABLED \
  244. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  245. /*
  246. * Listnics option description:
  247. */
  248. #ifdef ENABLE_PCAP_FINDALLDEVS
  249. tSCC zListnicsText[] =
  250. "List available network interfaces and exit";
  251. tSCC zListnics_NAME[] = "LISTNICS";
  252. tSCC zListnics_Name[] = "listnics";
  253. #define LISTNICS_FLAGS (OPTST_DISABLED | OPTST_IMM)
  254. #else /* disable Listnics */
  255. #define VALUE_OPT_LISTNICS NO_EQUIVALENT
  256. #define LISTNICS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  257. #define zListnicsText NULL
  258. #define zListnics_NAME NULL
  259. #define zListnics_Name NULL
  260. #endif /* ENABLE_PCAP_FINDALLDEVS */
  261. /*
  262. * Loop option description:
  263. */
  264. tSCC zLoopText[] =
  265. "Loop through the capture file X times";
  266. tSCC zLoop_NAME[] = "LOOP";
  267. tSCC zLoop_Name[] = "loop";
  268. #define zLoopDefaultArg ((char const*)1)
  269. #define LOOP_FLAGS (OPTST_DISABLED \
  270. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  271. /*
  272. * Pktlen option description:
  273. */
  274. tSCC zPktlenText[] =
  275. "Override the snaplen and use the actual packet len";
  276. tSCC zPktlen_NAME[] = "PKTLEN";
  277. tSCC zPktlen_Name[] = "pktlen";
  278. #define PKTLEN_FLAGS (OPTST_DISABLED)
  279. /*
  280. * Limit option description:
  281. */
  282. tSCC zLimitText[] =
  283. "Limit the number of packets to send";
  284. tSCC zLimit_NAME[] = "LIMIT";
  285. tSCC zLimit_Name[] = "limit";
  286. #define zLimitDefaultArg ((char const*)-1)
  287. #define LIMIT_FLAGS (OPTST_DISABLED \
  288. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  289. /*
  290. * Multiplier option description with
  291. * "Must also have options" and "Incompatible options":
  292. */
  293. tSCC zMultiplierText[] =
  294. "Modify replay speed to a given multiple";
  295. tSCC zMultiplier_NAME[] = "MULTIPLIER";
  296. tSCC zMultiplier_Name[] = "multiplier";
  297. static const int
  298. aMultiplierCantList[] = {
  299. INDEX_OPT_PPS,
  300. INDEX_OPT_MBPS,
  301. INDEX_OPT_ONEATATIME,
  302. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  303. #define MULTIPLIER_FLAGS (OPTST_DISABLED \
  304. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  305. /*
  306. * Pps option description with
  307. * "Must also have options" and "Incompatible options":
  308. */
  309. tSCC zPpsText[] =
  310. "Replay packets at a given packets/sec";
  311. tSCC zPps_NAME[] = "PPS";
  312. tSCC zPps_Name[] = "pps";
  313. static const int
  314. aPpsCantList[] = {
  315. INDEX_OPT_MULTIPLIER,
  316. INDEX_OPT_MBPS,
  317. INDEX_OPT_ONEATATIME,
  318. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  319. #define PPS_FLAGS (OPTST_DISABLED \
  320. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  321. /*
  322. * Mbps option description with
  323. * "Must also have options" and "Incompatible options":
  324. */
  325. tSCC zMbpsText[] =
  326. "Replay packets at a given Mbps";
  327. tSCC zMbps_NAME[] = "MBPS";
  328. tSCC zMbps_Name[] = "mbps";
  329. static const int
  330. aMbpsCantList[] = {
  331. INDEX_OPT_MULTIPLIER,
  332. INDEX_OPT_PPS,
  333. INDEX_OPT_ONEATATIME,
  334. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  335. #define MBPS_FLAGS (OPTST_DISABLED \
  336. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  337. /*
  338. * Topspeed option description with
  339. * "Must also have options" and "Incompatible options":
  340. */
  341. tSCC zTopspeedText[] =
  342. "Replay packets as fast as possible";
  343. tSCC zTopspeed_NAME[] = "TOPSPEED";
  344. tSCC zTopspeed_Name[] = "topspeed";
  345. static const int
  346. aTopspeedCantList[] = {
  347. INDEX_OPT_MBPS,
  348. INDEX_OPT_MULTIPLIER,
  349. INDEX_OPT_PPS,
  350. INDEX_OPT_ONEATATIME, NO_EQUIVALENT };
  351. #define TOPSPEED_FLAGS (OPTST_DISABLED)
  352. /*
  353. * Oneatatime option description with
  354. * "Must also have options" and "Incompatible options":
  355. */
  356. tSCC zOneatatimeText[] =
  357. "Replay one packet at a time for each user input";
  358. tSCC zOneatatime_NAME[] = "ONEATATIME";
  359. tSCC zOneatatime_Name[] = "oneatatime";
  360. static const int
  361. aOneatatimeCantList[] = {
  362. INDEX_OPT_MBPS,
  363. INDEX_OPT_PPS,
  364. INDEX_OPT_MULTIPLIER,
  365. INDEX_OPT_TOPSPEED, NO_EQUIVALENT };
  366. #define ONEATATIME_FLAGS (OPTST_DISABLED)
  367. /*
  368. * Pps_Multi option description with
  369. * "Must also have options" and "Incompatible options":
  370. */
  371. tSCC zPps_MultiText[] =
  372. "Number of packets to send for each time interval";
  373. tSCC zPps_Multi_NAME[] = "PPS_MULTI";
  374. tSCC zPps_Multi_Name[] = "pps-multi";
  375. #define zPps_MultiDefaultArg ((char const*)1)
  376. static const int
  377. aPps_MultiMustList[] = {
  378. INDEX_OPT_PPS, NO_EQUIVALENT };
  379. #define PPS_MULTI_FLAGS (OPTST_DISABLED \
  380. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  381. /*
  382. * Pid option description:
  383. */
  384. tSCC zPidText[] =
  385. "Print the PID of tcpreplay at startup";
  386. tSCC zPid_NAME[] = "PID";
  387. tSCC zPid_Name[] = "pid";
  388. #define PID_FLAGS (OPTST_DISABLED)
  389. /*
  390. * Version option description:
  391. */
  392. tSCC zVersionText[] =
  393. "Print version information";
  394. tSCC zVersion_NAME[] = "VERSION";
  395. tSCC zVersion_Name[] = "version";
  396. #define VERSION_FLAGS (OPTST_DISABLED)
  397. /*
  398. * Less_Help option description:
  399. */
  400. tSCC zLess_HelpText[] =
  401. "Display less usage information and exit";
  402. tSCC zLess_Help_NAME[] = "LESS_HELP";
  403. tSCC zLess_Help_Name[] = "less-help";
  404. #define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM)
  405. /*
  406. * Help/More_Help option descriptions:
  407. */
  408. tSCC zHelpText[] = "Display usage information and exit";
  409. tSCC zHelp_Name[] = "help";
  410. tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
  411. tSCC zMore_Help_Name[] = "more-help";
  412. tSCC zSave_OptsText[] = "Save the option state to a config file";
  413. tSCC zSave_Opts_Name[] = "save-opts";
  414. tSCC zLoad_OptsText[] = "Load options from a config file";
  415. tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
  416. tSCC zNotLoad_Opts_Name[] = "no-load-opts";
  417. tSCC zNotLoad_Opts_Pfx[] = "no";
  418. #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
  419. /*
  420. * Declare option callback procedures
  421. */
  422. #ifdef DEBUG
  423. static tOptProc doOptDbug;
  424. #else /* not DEBUG */
  425. # define doOptDbug NULL
  426. #endif /* def/not DEBUG */
  427. #ifdef ENABLE_PCAP_FINDALLDEVS
  428. static tOptProc doOptListnics;
  429. #else /* not ENABLE_PCAP_FINDALLDEVS */
  430. # define doOptListnics NULL
  431. #endif /* def/not ENABLE_PCAP_FINDALLDEVS */
  432. extern tOptProc
  433. optionNumericVal, optionPagedUsage;
  434. static tOptProc
  435. doOptLess_Help, doOptLimit, doOptLoop, doOptPid,
  436. doOptPps_Multi, doOptVersion, doUsageOpt;
  437. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  438. *
  439. * Define the Tcpreplay Option Descriptions.
  440. */
  441. static tOptDesc optDesc[ OPTION_CT ] = {
  442. { /* entry idx, value */ 0, VALUE_OPT_DBUG,
  443. /* equiv idx, value */ 0, VALUE_OPT_DBUG,
  444. /* equivalenced to */ NO_EQUIVALENT,
  445. /* min, max, act ct */ 0, 1, 0,
  446. /* opt state flags */ DBUG_FLAGS, 0,
  447. /* last opt argumnt */ { zDbugDefaultArg },
  448. /* arg list/cookie */ NULL,
  449. /* must/cannot opts */ NULL, NULL,
  450. /* option proc */ doOptDbug,
  451. /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name,
  452. /* disablement strs */ NULL, NULL },
  453. { /* entry idx, value */ 1, VALUE_OPT_QUIET,
  454. /* equiv idx, value */ 1, VALUE_OPT_QUIET,
  455. /* equivalenced to */ NO_EQUIVALENT,
  456. /* min, max, act ct */ 0, 1, 0,
  457. /* opt state flags */ QUIET_FLAGS, 0,
  458. /* last opt argumnt */ { NULL },
  459. /* arg list/cookie */ NULL,
  460. /* must/cannot opts */ NULL, NULL,
  461. /* option proc */ NULL,
  462. /* desc, NAME, name */ zQuietText, zQuiet_NAME, zQuiet_Name,
  463. /* disablement strs */ NULL, NULL },
  464. { /* entry idx, value */ 2, VALUE_OPT_TIMER,
  465. /* equiv idx, value */ 2, VALUE_OPT_TIMER,
  466. /* equivalenced to */ NO_EQUIVALENT,
  467. /* min, max, act ct */ 0, 1, 0,
  468. /* opt state flags */ TIMER_FLAGS, 0,
  469. /* last opt argumnt */ { zTimerDefaultArg },
  470. /* arg list/cookie */ NULL,
  471. /* must/cannot opts */ NULL, NULL,
  472. /* option proc */ NULL,
  473. /* desc, NAME, name */ zTimerText, zTimer_NAME, zTimer_Name,
  474. /* disablement strs */ NULL, NULL },
  475. { /* entry idx, value */ 3, VALUE_OPT_SLEEP_ACCEL,
  476. /* equiv idx, value */ 3, VALUE_OPT_SLEEP_ACCEL,
  477. /* equivalenced to */ NO_EQUIVALENT,
  478. /* min, max, act ct */ 0, 1, 0,
  479. /* opt state flags */ SLEEP_ACCEL_FLAGS, 0,
  480. /* last opt argumnt */ { zSleep_AccelDefaultArg },
  481. /* arg list/cookie */ NULL,
  482. /* must/cannot opts */ NULL, NULL,
  483. /* option proc */ optionNumericVal,
  484. /* desc, NAME, name */ zSleep_AccelText, zSleep_Accel_NAME, zSleep_Accel_Name,
  485. /* disablement strs */ NULL, NULL },
  486. { /* entry idx, value */ 4, VALUE_OPT_RDTSC_CLICKS,
  487. /* equiv idx, value */ 4, VALUE_OPT_RDTSC_CLICKS,
  488. /* equivalenced to */ NO_EQUIVALENT,
  489. /* min, max, act ct */ 0, 1, 0,
  490. /* opt state flags */ RDTSC_CLICKS_FLAGS, 0,
  491. /* last opt argumnt */ { zRdtsc_ClicksDefaultArg },
  492. /* arg list/cookie */ NULL,
  493. /* must/cannot opts */ NULL, NULL,
  494. /* option proc */ optionNumericVal,
  495. /* desc, NAME, name */ zRdtsc_ClicksText, zRdtsc_Clicks_NAME, zRdtsc_Clicks_Name,
  496. /* disablement strs */ NULL, NULL },
  497. { /* entry idx, value */ 5, VALUE_OPT_VERBOSE,
  498. /* equiv idx, value */ 5, VALUE_OPT_VERBOSE,
  499. /* equivalenced to */ NO_EQUIVALENT,
  500. /* min, max, act ct */ 0, 1, 0,
  501. /* opt state flags */ VERBOSE_FLAGS, 0,
  502. /* last opt argumnt */ { NULL },
  503. /* arg list/cookie */ NULL,
  504. /* must/cannot opts */ NULL, NULL,
  505. /* option proc */ NULL,
  506. /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name,
  507. /* disablement strs */ NULL, NULL },
  508. { /* entry idx, value */ 6, VALUE_OPT_DECODE,
  509. /* equiv idx, value */ 6, VALUE_OPT_DECODE,
  510. /* equivalenced to */ NO_EQUIVALENT,
  511. /* min, max, act ct */ 0, 1, 0,
  512. /* opt state flags */ DECODE_FLAGS, 0,
  513. /* last opt argumnt */ { NULL },
  514. /* arg list/cookie */ NULL,
  515. /* must/cannot opts */ aDecodeMustList, NULL,
  516. /* option proc */ NULL,
  517. /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name,
  518. /* disablement strs */ NULL, NULL },
  519. { /* entry idx, value */ 7, VALUE_OPT_ENABLE_FILE_CACHE,
  520. /* equiv idx, value */ 7, VALUE_OPT_ENABLE_FILE_CACHE,
  521. /* equivalenced to */ NO_EQUIVALENT,
  522. /* min, max, act ct */ 0, 1, 0,
  523. /* opt state flags */ ENABLE_FILE_CACHE_FLAGS, 0,
  524. /* last opt argumnt */ { NULL },
  525. /* arg list/cookie */ NULL,
  526. /* must/cannot opts */ aEnable_File_CacheMustList, NULL,
  527. /* option proc */ NULL,
  528. /* desc, NAME, name */ zEnable_File_CacheText, zEnable_File_Cache_NAME, zEnable_File_Cache_Name,
  529. /* disablement strs */ NULL, NULL },
  530. { /* entry idx, value */ 8, VALUE_OPT_CACHEFILE,
  531. /* equiv idx, value */ 8, VALUE_OPT_CACHEFILE,
  532. /* equivalenced to */ NO_EQUIVALENT,
  533. /* min, max, act ct */ 0, 1, 0,
  534. /* opt state flags */ CACHEFILE_FLAGS, 0,
  535. /* last opt argumnt */ { NULL },
  536. /* arg list/cookie */ NULL,
  537. /* must/cannot opts */ NULL, NULL,
  538. /* option proc */ NULL,
  539. /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name,
  540. /* disablement strs */ NULL, NULL },
  541. { /* entry idx, value */ 9, VALUE_OPT_INTF1,
  542. /* equiv idx, value */ 9, VALUE_OPT_INTF1,
  543. /* equivalenced to */ NO_EQUIVALENT,
  544. /* min, max, act ct */ 1, 1, 0,
  545. /* opt state flags */ INTF1_FLAGS, 0,
  546. /* last opt argumnt */ { NULL },
  547. /* arg list/cookie */ NULL,
  548. /* must/cannot opts */ NULL, NULL,
  549. /* option proc */ NULL,
  550. /* desc, NAME, name */ zIntf1Text, zIntf1_NAME, zIntf1_Name,
  551. /* disablement strs */ NULL, NULL },
  552. { /* entry idx, value */ 10, VALUE_OPT_INTF2,
  553. /* equiv idx, value */ 10, VALUE_OPT_INTF2,
  554. /* equivalenced to */ NO_EQUIVALENT,
  555. /* min, max, act ct */ 0, 1, 0,
  556. /* opt state flags */ INTF2_FLAGS, 0,
  557. /* last opt argumnt */ { NULL },
  558. /* arg list/cookie */ NULL,
  559. /* must/cannot opts */ aIntf2MustList, NULL,
  560. /* option proc */ NULL,
  561. /* desc, NAME, name */ zIntf2Text, zIntf2_NAME, zIntf2_Name,
  562. /* disablement strs */ NULL, NULL },
  563. { /* entry idx, value */ 11, VALUE_OPT_LISTNICS,
  564. /* equiv idx, value */ 11, VALUE_OPT_LISTNICS,
  565. /* equivalenced to */ NO_EQUIVALENT,
  566. /* min, max, act ct */ 0, 1, 0,
  567. /* opt state flags */ LISTNICS_FLAGS, 0,
  568. /* last opt argumnt */ { NULL },
  569. /* arg list/cookie */ NULL,
  570. /* must/cannot opts */ NULL, NULL,
  571. /* option proc */ doOptListnics,
  572. /* desc, NAME, name */ zListnicsText, zListnics_NAME, zListnics_Name,
  573. /* disablement strs */ NULL, NULL },
  574. { /* entry idx, value */ 12, VALUE_OPT_LOOP,
  575. /* equiv idx, value */ 12, VALUE_OPT_LOOP,
  576. /* equivalenced to */ NO_EQUIVALENT,
  577. /* min, max, act ct */ 0, 1, 0,
  578. /* opt state flags */ LOOP_FLAGS, 0,
  579. /* last opt argumnt */ { zLoopDefaultArg },
  580. /* arg list/cookie */ NULL,
  581. /* must/cannot opts */ NULL, NULL,
  582. /* option proc */ doOptLoop,
  583. /* desc, NAME, name */ zLoopText, zLoop_NAME, zLoop_Name,
  584. /* disablement strs */ NULL, NULL },
  585. { /* entry idx, value */ 13, VALUE_OPT_PKTLEN,
  586. /* equiv idx, value */ 13, VALUE_OPT_PKTLEN,
  587. /* equivalenced to */ NO_EQUIVALENT,
  588. /* min, max, act ct */ 0, 1, 0,
  589. /* opt state flags */ PKTLEN_FLAGS, 0,
  590. /* last opt argumnt */ { NULL },
  591. /* arg list/cookie */ NULL,
  592. /* must/cannot opts */ NULL, NULL,
  593. /* option proc */ NULL,
  594. /* desc, NAME, name */ zPktlenText, zPktlen_NAME, zPktlen_Name,
  595. /* disablement strs */ NULL, NULL },
  596. { /* entry idx, value */ 14, VALUE_OPT_LIMIT,
  597. /* equiv idx, value */ 14, VALUE_OPT_LIMIT,
  598. /* equivalenced to */ NO_EQUIVALENT,
  599. /* min, max, act ct */ 0, 1, 0,
  600. /* opt state flags */ LIMIT_FLAGS, 0,
  601. /* last opt argumnt */ { zLimitDefaultArg },
  602. /* arg list/cookie */ NULL,
  603. /* must/cannot opts */ NULL, NULL,
  604. /* option proc */ doOptLimit,
  605. /* desc, NAME, name */ zLimitText, zLimit_NAME, zLimit_Name,
  606. /* disablement strs */ NULL, NULL },
  607. { /* entry idx, value */ 15, VALUE_OPT_MULTIPLIER,
  608. /* equiv idx, value */ 15, VALUE_OPT_MULTIPLIER,
  609. /* equivalenced to */ NO_EQUIVALENT,
  610. /* min, max, act ct */ 0, 1, 0,
  611. /* opt state flags */ MULTIPLIER_FLAGS, 0,
  612. /* last opt argumnt */ { NULL },
  613. /* arg list/cookie */ NULL,
  614. /* must/cannot opts */ NULL, aMultiplierCantList,
  615. /* option proc */ NULL,
  616. /* desc, NAME, name */ zMultiplierText, zMultiplier_NAME, zMultiplier_Name,
  617. /* disablement strs */ NULL, NULL },
  618. { /* entry idx, value */ 16, VALUE_OPT_PPS,
  619. /* equiv idx, value */ 16, VALUE_OPT_PPS,
  620. /* equivalenced to */ NO_EQUIVALENT,
  621. /* min, max, act ct */ 0, 1, 0,
  622. /* opt state flags */ PPS_FLAGS, 0,
  623. /* last opt argumnt */ { NULL },
  624. /* arg list/cookie */ NULL,
  625. /* must/cannot opts */ NULL, aPpsCantList,
  626. /* option proc */ optionNumericVal,
  627. /* desc, NAME, name */ zPpsText, zPps_NAME, zPps_Name,
  628. /* disablement strs */ NULL, NULL },
  629. { /* entry idx, value */ 17, VALUE_OPT_MBPS,
  630. /* equiv idx, value */ 17, VALUE_OPT_MBPS,
  631. /* equivalenced to */ NO_EQUIVALENT,
  632. /* min, max, act ct */ 0, 1, 0,
  633. /* opt state flags */ MBPS_FLAGS, 0,
  634. /* last opt argumnt */ { NULL },
  635. /* arg list/cookie */ NULL,
  636. /* must/cannot opts */ NULL, aMbpsCantList,
  637. /* option proc */ NULL,
  638. /* desc, NAME, name */ zMbpsText, zMbps_NAME, zMbps_Name,
  639. /* disablement strs */ NULL, NULL },
  640. { /* entry idx, value */ 18, VALUE_OPT_TOPSPEED,
  641. /* equiv idx, value */ 18, VALUE_OPT_TOPSPEED,
  642. /* equivalenced to */ NO_EQUIVALENT,
  643. /* min, max, act ct */ 0, 1, 0,
  644. /* opt state flags */ TOPSPEED_FLAGS, 0,
  645. /* last opt argumnt */ { NULL },
  646. /* arg list/cookie */ NULL,
  647. /* must/cannot opts */ NULL, aTopspeedCantList,
  648. /* option proc */ NULL,
  649. /* desc, NAME, name */ zTopspeedText, zTopspeed_NAME, zTopspeed_Name,
  650. /* disablement strs */ NULL, NULL },
  651. { /* entry idx, value */ 19, VALUE_OPT_ONEATATIME,
  652. /* equiv idx, value */ 19, VALUE_OPT_ONEATATIME,
  653. /* equivalenced to */ NO_EQUIVALENT,
  654. /* min, max, act ct */ 0, 1, 0,
  655. /* opt state flags */ ONEATATIME_FLAGS, 0,
  656. /* last opt argumnt */ { NULL },
  657. /* arg list/cookie */ NULL,
  658. /* must/cannot opts */ NULL, aOneatatimeCantList,
  659. /* option proc */ NULL,
  660. /* desc, NAME, name */ zOneatatimeText, zOneatatime_NAME, zOneatatime_Name,
  661. /* disablement strs */ NULL, NULL },
  662. { /* entry idx, value */ 20, VALUE_OPT_PPS_MULTI,
  663. /* equiv idx, value */ 20, VALUE_OPT_PPS_MULTI,
  664. /* equivalenced to */ NO_EQUIVALENT,
  665. /* min, max, act ct */ 0, 1, 0,
  666. /* opt state flags */ PPS_MULTI_FLAGS, 0,
  667. /* last opt argumnt */ { zPps_MultiDefaultArg },
  668. /* arg list/cookie */ NULL,
  669. /* must/cannot opts */ aPps_MultiMustList, NULL,
  670. /* option proc */ doOptPps_Multi,
  671. /* desc, NAME, name */ zPps_MultiText, zPps_Multi_NAME, zPps_Multi_Name,
  672. /* disablement strs */ NULL, NULL },
  673. { /* entry idx, value */ 21, VALUE_OPT_PID,
  674. /* equiv idx, value */ 21, VALUE_OPT_PID,
  675. /* equivalenced to */ NO_EQUIVALENT,
  676. /* min, max, act ct */ 0, 1, 0,
  677. /* opt state flags */ PID_FLAGS, 0,
  678. /* last opt argumnt */ { NULL },
  679. /* arg list/cookie */ NULL,
  680. /* must/cannot opts */ NULL, NULL,
  681. /* option proc */ doOptPid,
  682. /* desc, NAME, name */ zPidText, zPid_NAME, zPid_Name,
  683. /* disablement strs */ NULL, NULL },
  684. { /* entry idx, value */ 22, VALUE_OPT_VERSION,
  685. /* equiv idx, value */ 22, VALUE_OPT_VERSION,
  686. /* equivalenced to */ NO_EQUIVALENT,
  687. /* min, max, act ct */ 0, 1, 0,
  688. /* opt state flags */ VERSION_FLAGS, 0,
  689. /* last opt argumnt */ { NULL },
  690. /* arg list/cookie */ NULL,
  691. /* must/cannot opts */ NULL, NULL,
  692. /* option proc */ doOptVersion,
  693. /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name,
  694. /* disablement strs */ NULL, NULL },
  695. { /* entry idx, value */ 23, VALUE_OPT_LESS_HELP,
  696. /* equiv idx, value */ 23, VALUE_OPT_LESS_HELP,
  697. /* equivalenced to */ NO_EQUIVALENT,
  698. /* min, max, act ct */ 0, 1, 0,
  699. /* opt state flags */ LESS_HELP_FLAGS, 0,
  700. /* last opt argumnt */ { NULL },
  701. /* arg list/cookie */ NULL,
  702. /* must/cannot opts */ NULL, NULL,
  703. /* option proc */ doOptLess_Help,
  704. /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name,
  705. /* disablement strs */ NULL, NULL },
  706. { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
  707. /* equiv idx value */ NO_EQUIVALENT, 0,
  708. /* equivalenced to */ NO_EQUIVALENT,
  709. /* min, max, act ct */ 0, 1, 0,
  710. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  711. /* last opt argumnt */ { NULL },
  712. /* arg list/cookie */ NULL,
  713. /* must/cannot opts */ NULL, NULL,
  714. /* option proc */ doUsageOpt,
  715. /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
  716. /* disablement strs */ NULL, NULL },
  717. { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
  718. /* equiv idx value */ NO_EQUIVALENT, 0,
  719. /* equivalenced to */ NO_EQUIVALENT,
  720. /* min, max, act ct */ 0, 1, 0,
  721. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  722. /* last opt argumnt */ { NULL },
  723. /* arg list/cookie */ NULL,
  724. /* must/cannot opts */ NULL, NULL,
  725. /* option proc */ optionPagedUsage,
  726. /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
  727. /* disablement strs */ NULL, NULL },
  728. { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
  729. /* equiv idx value */ NO_EQUIVALENT, 0,
  730. /* equivalenced to */ NO_EQUIVALENT,
  731. /* min, max, act ct */ 0, 1, 0,
  732. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  733. | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
  734. /* last opt argumnt */ { NULL },
  735. /* arg list/cookie */ NULL,
  736. /* must/cannot opts */ NULL, NULL,
  737. /* option proc */ NULL,
  738. /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
  739. /* disablement strs */ NULL, NULL },
  740. { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
  741. /* equiv idx value */ NO_EQUIVALENT, 0,
  742. /* equivalenced to */ NO_EQUIVALENT,
  743. /* min, max, act ct */ 0, NOLIMIT, 0,
  744. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  745. | OPTST_DISABLE_IMM, 0,
  746. /* last opt argumnt */ { NULL },
  747. /* arg list/cookie */ NULL,
  748. /* must/cannot opts */ NULL, NULL,
  749. /* option proc */ optionLoadOpt,
  750. /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
  751. /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
  752. };
  753. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  754. *
  755. * Define the Tcpreplay Option Environment
  756. */
  757. tSCC zPROGNAME[] = "TCPREPLAY";
  758. tSCC zUsageTitle[] =
  759. "tcpreplay (tcpreplay) - Replay network traffic stored in pcap files\n\
  760. USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... <pcap_file(s)>\n";
  761. tSCC zRcName[] = ".tcpreplayrc";
  762. tSCC* apzHomeList[] = {
  763. "$$/",
  764. NULL };
  765. #define zBugsAddr NULL
  766. tSCC zExplain[] = "\n\
  767. tcpreplay is a tool for replaying network traffic from files saved with\n\
  768. tcpdump or other tools which write pcap(3) files.\n";
  769. tSCC zDetail[] = "\n\
  770. The basic operation of tcpreplay is to resend all packets from the\n\
  771. input file(s) at the speed at which they were recorded, or a specified \n\
  772. data rate, up to as fast as the hardware is capable.\n\n\
  773. Optionally, the traffic can be split between two interfaces, written to\n\
  774. files, filtered and edited in various ways, providing the means to test\n\
  775. firewalls, NIDS and other network devices.\n\n\
  776. For more details, please see the Tcpreplay Manual at:\n\
  777. http://tcpreplay.synfin.net/trac/wiki/manual\n";
  778. #define zFullVersion NULL
  779. /* extracted from /usr/local/share/autogen/optcode.tpl near line 496 */
  780. #if defined(ENABLE_NLS)
  781. # define OPTPROC_BASE OPTPROC_TRANSLATE
  782. static tOptionXlateProc translate_option_strings;
  783. #else
  784. # define OPTPROC_BASE OPTPROC_NONE
  785. # define translate_option_strings NULL
  786. #endif /* ENABLE_NLS */
  787. #define tcpreplay_full_usage NULL
  788. #define tcpreplay_short_usage NULL
  789. tOptions tcpreplayOptions = {
  790. OPTIONS_STRUCT_VERSION,
  791. 0, NULL, /* original argc + argv */
  792. ( OPTPROC_BASE
  793. + OPTPROC_ERRSTOP
  794. + OPTPROC_SHORTOPT
  795. + OPTPROC_LONGOPT
  796. + OPTPROC_NO_REQ_OPT
  797. + OPTPROC_ARGS_REQ
  798. + OPTPROC_GNUUSAGE
  799. + OPTPROC_HAS_IMMED ),
  800. 0, NULL, /* current option index, current option */
  801. NULL, NULL, zPROGNAME,
  802. zRcName, zCopyright, zCopyrightNotice,
  803. zFullVersion, apzHomeList, zUsageTitle,
  804. zExplain, zDetail, optDesc,
  805. zBugsAddr, /* address to send bugs to */
  806. NULL, NULL, /* extensions/saved state */
  807. optionUsage, /* usage procedure */
  808. translate_option_strings, /* translation procedure */
  809. /*
  810. * Indexes to special options
  811. */
  812. { INDEX_OPT_MORE_HELP, /* more-help option index */
  813. INDEX_OPT_SAVE_OPTS, /* save option index */
  814. NO_EQUIVALENT, /* '-#' option index */
  815. NO_EQUIVALENT /* index of default opt */
  816. },
  817. 28 /* full option count */, 24 /* user option count */,
  818. tcpreplay_full_usage, tcpreplay_short_usage,
  819. NULL, NULL
  820. };
  821. /*
  822. * Create the static procedure(s) declared above.
  823. */
  824. static void
  825. doUsageOpt(
  826. tOptions* pOptions,
  827. tOptDesc* pOptDesc )
  828. {
  829. USAGE( EXIT_SUCCESS );
  830. }
  831. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  832. *
  833. * For the dbug option, when DEBUG is #define-d.
  834. */
  835. #ifdef DEBUG
  836. static void
  837. doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc)
  838. {
  839. static const struct {long const rmin, rmax;} rng[1] = {
  840. { 0, 5 } };
  841. long val;
  842. int ix;
  843. char * pzEnd;
  844. if (pOptions <= OPTPROC_EMIT_LIMIT)
  845. goto emit_ranges;
  846. errno = 0;
  847. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  848. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  849. goto bad_value;
  850. if (*pzEnd != '\0')
  851. goto bad_value;
  852. for (ix = 0; ix < 1; ix++) {
  853. if (val < rng[ix].rmin)
  854. continue; /* ranges need not be ordered. */
  855. if (val == rng[ix].rmin)
  856. goto valid_return;
  857. if (rng[ix].rmax == LONG_MIN)
  858. continue;
  859. if (val <= rng[ix].rmax)
  860. goto valid_return;
  861. }
  862. bad_value:
  863. option_usage_fp = stderr;
  864. emit_ranges:
  865. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  866. return;
  867. valid_return:
  868. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  869. free((void *)pOptDesc->optArg.argString);
  870. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  871. }
  872. pOptDesc->optArg.argInt = val;
  873. }
  874. #endif /* defined DEBUG */
  875. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  876. *
  877. * For the listnics option, when ENABLE_PCAP_FINDALLDEVS is #define-d.
  878. */
  879. #ifdef ENABLE_PCAP_FINDALLDEVS
  880. static void
  881. doOptListnics(tOptions* pOptions, tOptDesc* pOptDesc)
  882. {
  883. /* extracted from tcpreplay_opts.def, line 256 */
  884. interface_list_t *list = get_interface_list();
  885. list_interfaces(list);
  886. free(list);
  887. exit(0);
  888. }
  889. #endif /* defined ENABLE_PCAP_FINDALLDEVS */
  890. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  891. *
  892. * For the loop option.
  893. */
  894. static void
  895. doOptLoop(tOptions* pOptions, tOptDesc* pOptDesc)
  896. {
  897. static const struct {long const rmin, rmax;} rng[1] = {
  898. { 0, LONG_MAX } };
  899. long val;
  900. int ix;
  901. char * pzEnd;
  902. if (pOptions <= OPTPROC_EMIT_LIMIT)
  903. goto emit_ranges;
  904. errno = 0;
  905. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  906. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  907. goto bad_value;
  908. if (*pzEnd != '\0')
  909. goto bad_value;
  910. for (ix = 0; ix < 1; ix++) {
  911. if (val < rng[ix].rmin)
  912. continue; /* ranges need not be ordered. */
  913. if (val == rng[ix].rmin)
  914. goto valid_return;
  915. if (rng[ix].rmax == LONG_MIN)
  916. continue;
  917. if (val <= rng[ix].rmax)
  918. goto valid_return;
  919. }
  920. bad_value:
  921. option_usage_fp = stderr;
  922. emit_ranges:
  923. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  924. return;
  925. valid_return:
  926. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  927. free((void *)pOptDesc->optArg.argString);
  928. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  929. }
  930. pOptDesc->optArg.argInt = val;
  931. }
  932. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  933. *
  934. * For the limit option.
  935. */
  936. static void
  937. doOptLimit(tOptions* pOptions, tOptDesc* pOptDesc)
  938. {
  939. static const struct {long const rmin, rmax;} rng[1] = {
  940. { 1, LONG_MAX } };
  941. long val;
  942. int ix;
  943. char * pzEnd;
  944. if (pOptions <= OPTPROC_EMIT_LIMIT)
  945. goto emit_ranges;
  946. errno = 0;
  947. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  948. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  949. goto bad_value;
  950. if (*pzEnd != '\0')
  951. goto bad_value;
  952. for (ix = 0; ix < 1; ix++) {
  953. if (val < rng[ix].rmin)
  954. continue; /* ranges need not be ordered. */
  955. if (val == rng[ix].rmin)
  956. goto valid_return;
  957. if (rng[ix].rmax == LONG_MIN)
  958. continue;
  959. if (val <= rng[ix].rmax)
  960. goto valid_return;
  961. }
  962. bad_value:
  963. option_usage_fp = stderr;
  964. emit_ranges:
  965. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  966. return;
  967. valid_return:
  968. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  969. free((void *)pOptDesc->optArg.argString);
  970. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  971. }
  972. pOptDesc->optArg.argInt = val;
  973. }
  974. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  975. *
  976. * For the pps-multi option.
  977. */
  978. static void
  979. doOptPps_Multi(tOptions* pOptions, tOptDesc* pOptDesc)
  980. {
  981. static const struct {long const rmin, rmax;} rng[1] = {
  982. { 1, LONG_MAX } };
  983. long val;
  984. int ix;
  985. char * pzEnd;
  986. if (pOptions <= OPTPROC_EMIT_LIMIT)
  987. goto emit_ranges;
  988. errno = 0;
  989. val = strtol(pOptDesc->optArg.argString, &pzEnd, 0);
  990. if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0))
  991. goto bad_value;
  992. if (*pzEnd != '\0')
  993. goto bad_value;
  994. for (ix = 0; ix < 1; ix++) {
  995. if (val < rng[ix].rmin)
  996. continue; /* ranges need not be ordered. */
  997. if (val == rng[ix].rmin)
  998. goto valid_return;
  999. if (rng[ix].rmax == LONG_MIN)
  1000. continue;
  1001. if (val <= rng[ix].rmax)
  1002. goto valid_return;
  1003. }
  1004. bad_value:
  1005. option_usage_fp = stderr;
  1006. emit_ranges:
  1007. optionShowRange(pOptions, pOptDesc, (void *)rng, 1);
  1008. return;
  1009. valid_return:
  1010. if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) {
  1011. free((void *)pOptDesc->optArg.argString);
  1012. pOptDesc->fOptState &= ~OPTST_ALLOC_ARG;
  1013. }
  1014. pOptDesc->optArg.argInt = val;
  1015. }
  1016. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1017. *
  1018. * For the pid option.
  1019. */
  1020. static void
  1021. doOptPid(tOptions* pOptions, tOptDesc* pOptDesc)
  1022. {
  1023. /* extracted from tcpreplay_opts.def, line 406 */
  1024. fprintf(stderr, "PID: %hu\n", getpid());
  1025. }
  1026. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1027. *
  1028. * For the version option.
  1029. */
  1030. static void
  1031. doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc)
  1032. {
  1033. /* extracted from tcpreplay_opts.def, line 418 */
  1034. fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version());
  1035. #ifdef DEBUG
  1036. fprintf(stderr, " (debug)");
  1037. #endif
  1038. fprintf(stderr, "\n");
  1039. fprintf(stderr, "Copyright 2001-2009 by Aaron Turner <aturner at synfin dot net>\n");
  1040. fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION);
  1041. #ifdef HAVE_LIBDNET
  1042. fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION);
  1043. #else
  1044. fprintf(stderr, "Not compiled with libdnet.\n");
  1045. #endif
  1046. #ifdef HAVE_WINPCAP
  1047. fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
  1048. #else
  1049. fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
  1050. #endif
  1051. #ifdef ENABLE_64BITS
  1052. fprintf(stderr, "64 bit packet counters: enabled\n");
  1053. #else
  1054. fprintf(stderr, "64 bit packet counters: disabled\n");
  1055. #endif
  1056. #ifdef ENABLE_VERBOSE
  1057. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  1058. #else
  1059. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  1060. #endif
  1061. #ifdef TCPREPLAY_EDIT
  1062. fprintf(stderr, "Packet editing: enabled\n");
  1063. #else
  1064. fprintf(stderr, "Packet editing: disabled\n");
  1065. #endif
  1066. #ifdef ENABLE_FRAGROUTE
  1067. fprintf(stderr, "Fragroute engine: enabled\n");
  1068. #else
  1069. fprintf(stderr, "Fragroute engine: disabled\n");
  1070. #endif
  1071. fprintf(stderr, "Injection method: %s\n", sendpacket_get_method());
  1072. exit(0);
  1073. }
  1074. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1075. *
  1076. * For the less-help option.
  1077. */
  1078. static void
  1079. doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc)
  1080. {
  1081. /* extracted from tcpreplay_opts.def, line 469 */
  1082. USAGE(EXIT_FAILURE);
  1083. }
  1084. /* extracted from /usr/local/share/autogen/optcode.tpl near line 629 */
  1085. #if ENABLE_NLS
  1086. #include <stdio.h>
  1087. #include <stdlib.h>
  1088. #include <string.h>
  1089. #include <unistd.h>
  1090. #include <autoopts/usage-txt.h>
  1091. static char* AO_gettext( char const* pz );
  1092. static void coerce_it(void** s);
  1093. static char*
  1094. AO_gettext( char const* pz )
  1095. {
  1096. char* pzRes;
  1097. if (pz == NULL)
  1098. return NULL;
  1099. pzRes = _(pz);
  1100. if (pzRes == pz)
  1101. return pzRes;
  1102. pzRes = strdup( pzRes );
  1103. if (pzRes == NULL) {
  1104. fputs( _("No memory for duping translated strings\n"), stderr );
  1105. exit( EXIT_FAILURE );
  1106. }
  1107. return pzRes;
  1108. }
  1109. static void coerce_it(void** s) { *s = AO_gettext(*s); }
  1110. #define COERSION(_f) \
  1111. coerce_it((void*)&(tcpreplayOptions._f))
  1112. /*
  1113. * This invokes the translation code (e.g. gettext(3)).
  1114. */
  1115. static void
  1116. translate_option_strings( void )
  1117. {
  1118. /*
  1119. * Guard against re-translation. It won't work. The strings will have
  1120. * been changed by the first pass through this code. One shot only.
  1121. */
  1122. if (option_usage_text.field_ct != 0) {
  1123. /*
  1124. * Do the translations. The first pointer follows the field count
  1125. * field. The field count field is the size of a pointer.
  1126. */
  1127. tOptDesc* pOD = tcpreplayOptions.pOptDesc;
  1128. char** ppz = (char**)(void*)&(option_usage_text);
  1129. int ix = option_usage_text.field_ct;
  1130. do {
  1131. ppz++;
  1132. *ppz = AO_gettext(*ppz);
  1133. } while (--ix > 0);
  1134. COERSION(pzCopyright);
  1135. COERSION(pzCopyNotice);
  1136. COERSION(pzFullVersion);
  1137. COERSION(pzUsageTitle);
  1138. COERSION(pzExplain);
  1139. COERSION(pzDetail);
  1140. option_usage_text.field_ct = 0;
  1141. for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++)
  1142. coerce_it((void*)&(pOD->pzText));
  1143. }
  1144. if ((tcpreplayOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
  1145. tOptDesc* pOD = tcpreplayOptions.pOptDesc;
  1146. int ix;
  1147. for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++) {
  1148. coerce_it((void*)&(pOD->pz_Name));
  1149. coerce_it((void*)&(pOD->pz_DisableName));
  1150. coerce_it((void*)&(pOD->pz_DisablePfx));
  1151. }
  1152. /* prevent re-translation */
  1153. tcpreplayOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
  1154. }
  1155. }
  1156. #endif /* ENABLE_NLS */
  1157. #ifdef __cplusplus
  1158. }
  1159. #endif
  1160. /* tcpreplay_opts.c ends here */