tcprewrite_opts.c 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcprewrite_opts.c)
  4. *
  5. * It has been AutoGen-ed Sunday August 26, 2007 at 01:08:03 PM PDT
  6. * From the definitions tcprewrite_opts.def
  7. * and the template file options
  8. *
  9. * Generated from AutoOpts 30:0:5 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. * tcprewrite 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. * tcprewrite copyright 2004-2007 Aaron Turner - all rights reserved
  23. *
  24. * tcprewrite 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. * tcprewrite 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 <limits.h>
  51. #include <stdio.h>
  52. #define OPTION_CODE_COMPILE 1
  53. #include "tcprewrite_opts.h"
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. tSCC zCopyright[] =
  58. "tcprewrite copyright (c) 2004-2007 Aaron Turner, all rights reserved";
  59. tSCC zCopyrightNotice[] =
  60. "tcprewrite is free software copyrighted by Aaron Turner.\n\n\
  61. Redistribution and use in source and binary forms, with or without\n\
  62. modification, are permitted provided that the following conditions\n\
  63. are met:\n\
  64. 1. Redistributions of source code must retain the above copyright\n\
  65. notice, this list of conditions and the following disclaimer.\n\
  66. 2. Redistributions in binary form must reproduce the above copyright\n\
  67. notice, this list of conditions and the following disclaimer in the\n\
  68. documentation and/or other materials provided with the distribution.\n\
  69. 3. Neither the name ``Aaron Turner'' nor the name of any other\n\
  70. contributor may be used to endorse or promote products derived\n\
  71. from this software without specific prior written permission.\n\n\
  72. tcprewrite IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS\n\
  73. OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n\
  74. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\
  75. ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS\n\
  76. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n\
  77. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n\
  78. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n\
  79. BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n\
  80. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n\
  81. OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\
  82. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
  83. extern tUsageProc optionUsage;
  84. /*
  85. * global included definitions
  86. */
  87. #include "defines.h"
  88. #include "common.h"
  89. #include "config.h"
  90. #include "tcprewrite.h"
  91. #include <stdlib.h>
  92. #include <string.h>
  93. extern tcprewrite_opt_t options;
  94. #ifndef NULL
  95. # define NULL 0
  96. #endif
  97. #ifndef EXIT_SUCCESS
  98. # define EXIT_SUCCESS 0
  99. #endif
  100. #ifndef EXIT_FAILURE
  101. # define EXIT_FAILURE 1
  102. #endif
  103. /*
  104. * Tcpedit option description:
  105. */
  106. tSCC zTcpeditText[] =
  107. "";
  108. #define TCPEDIT_FLAGS (OPTST_DOCUMENT | OPTST_NO_INIT)
  109. /*
  110. * Portmap option description:
  111. */
  112. tSCC zPortmapText[] =
  113. "Rewrite TCP/UDP ports";
  114. tSCC zPortmap_NAME[] = "PORTMAP";
  115. tSCC zPortmap_Name[] = "portmap";
  116. #define PORTMAP_FLAGS (OPTST_DISABLED \
  117. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  118. /*
  119. * Seed option description:
  120. */
  121. tSCC zSeedText[] =
  122. "Randomize src/dst IP addresses w/ given seed";
  123. tSCC zSeed_NAME[] = "SEED";
  124. tSCC zSeed_Name[] = "seed";
  125. #define SEED_FLAGS (OPTST_DISABLED \
  126. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  127. /*
  128. * Pnat option description with
  129. * "Must also have options" and "Incompatible options":
  130. */
  131. tSCC zPnatText[] =
  132. "Rewrite IP addresses using pseudo-NAT";
  133. tSCC zPnat_NAME[] = "PNAT";
  134. tSCC zPnat_Name[] = "pnat";
  135. static const int
  136. aPnatCantList[] = {
  137. INDEX_OPT_SRCIPMAP, NO_EQUIVALENT };
  138. #define PNAT_FLAGS (OPTST_DISABLED | OPTST_STACKED \
  139. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  140. /*
  141. * Srcipmap option description with
  142. * "Must also have options" and "Incompatible options":
  143. */
  144. tSCC zSrcipmapText[] =
  145. "Rewrite source IP addresses using pseudo-NAT";
  146. tSCC zSrcipmap_NAME[] = "SRCIPMAP";
  147. tSCC zSrcipmap_Name[] = "srcipmap";
  148. static const int
  149. aSrcipmapCantList[] = {
  150. INDEX_OPT_PNAT, NO_EQUIVALENT };
  151. #define SRCIPMAP_FLAGS (OPTST_DISABLED \
  152. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  153. /*
  154. * Dstipmap option description with
  155. * "Must also have options" and "Incompatible options":
  156. */
  157. tSCC zDstipmapText[] =
  158. "Rewrite destination IP addresses using pseudo-NAT";
  159. tSCC zDstipmap_NAME[] = "DSTIPMAP";
  160. tSCC zDstipmap_Name[] = "dstipmap";
  161. static const int
  162. aDstipmapCantList[] = {
  163. INDEX_OPT_PNAT, NO_EQUIVALENT };
  164. #define DSTIPMAP_FLAGS (OPTST_DISABLED \
  165. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  166. /*
  167. * Endpoints option description with
  168. * "Must also have options" and "Incompatible options":
  169. */
  170. #ifdef HAVE_CACHEFILE_SUPPORT
  171. tSCC zEndpointsText[] =
  172. "Rewrite IP addresses to be between two endpoints";
  173. tSCC zEndpoints_NAME[] = "ENDPOINTS";
  174. tSCC zEndpoints_Name[] = "endpoints";
  175. static const int
  176. aEndpointsMustList[] = {
  177. INDEX_OPT_CACHEFILE, NO_EQUIVALENT };
  178. #define ENDPOINTS_FLAGS (OPTST_DISABLED \
  179. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  180. #else /* disable Endpoints */
  181. #define VALUE_OPT_ENDPOINTS NO_EQUIVALENT
  182. #define ENDPOINTS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  183. #define aEndpointsMustList NULL
  184. #define zEndpointsText NULL
  185. #define zEndpoints_NAME NULL
  186. #define zEndpoints_Name NULL
  187. #endif /* HAVE_CACHEFILE_SUPPORT */
  188. /*
  189. * Skipbroadcast option description:
  190. */
  191. tSCC zSkipbroadcastText[] =
  192. "Skip rewriting broadcast/multicast IP's";
  193. tSCC zSkipbroadcast_NAME[] = "SKIPBROADCAST";
  194. tSCC zSkipbroadcast_Name[] = "skipbroadcast";
  195. #define SKIPBROADCAST_FLAGS (OPTST_DISABLED)
  196. /*
  197. * Fixcsum option description:
  198. */
  199. tSCC zFixcsumText[] =
  200. "Force recalculation of IP/TCP/UDP checksums";
  201. tSCC zFixcsum_NAME[] = "FIXCSUM";
  202. tSCC zFixcsum_Name[] = "fixcsum";
  203. #define FIXCSUM_FLAGS (OPTST_DISABLED)
  204. /*
  205. * Mtu option description:
  206. */
  207. tSCC zMtuText[] =
  208. "Override default MTU length (1500 bytes)";
  209. tSCC zMtu_NAME[] = "MTU";
  210. tSCC zMtu_Name[] = "mtu";
  211. #define MTU_FLAGS (OPTST_DISABLED \
  212. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  213. /*
  214. * Efcs option description:
  215. */
  216. tSCC zEfcsText[] =
  217. "Remove Ethernet checksums (FCS) from end of frames";
  218. tSCC zEfcs_NAME[] = "EFCS";
  219. tSCC zEfcs_Name[] = "efcs";
  220. #define EFCS_FLAGS (OPTST_DISABLED)
  221. /*
  222. * Fixlen option description:
  223. */
  224. tSCC zFixlenText[] =
  225. "Pad or truncate packet data to match header length";
  226. tSCC zFixlen_NAME[] = "FIXLEN";
  227. tSCC zFixlen_Name[] = "fixlen";
  228. #define FIXLEN_FLAGS (OPTST_DISABLED \
  229. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  230. /*
  231. * Skipl2broadcast option description:
  232. */
  233. tSCC zSkipl2broadcastText[] =
  234. "Skip rewriting broadcast/multicast Layer 2 addresses";
  235. tSCC zSkipl2broadcast_NAME[] = "SKIPL2BROADCAST";
  236. tSCC zSkipl2broadcast_Name[] = "skipl2broadcast";
  237. #define SKIPL2BROADCAST_FLAGS (OPTST_DISABLED)
  238. /*
  239. * Dlt option description:
  240. */
  241. tSCC zDltText[] =
  242. "Override output DLT encapsulation";
  243. tSCC zDlt_NAME[] = "DLT";
  244. tSCC zDlt_Name[] = "dlt";
  245. #define DLT_FLAGS (OPTST_DISABLED \
  246. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  247. /*
  248. * Enet_Dmac option description:
  249. */
  250. tSCC zEnet_DmacText[] =
  251. "Override destination ethernet MAC addresses";
  252. tSCC zEnet_Dmac_NAME[] = "ENET_DMAC";
  253. tSCC zEnet_Dmac_Name[] = "enet-dmac";
  254. #define ENET_DMAC_FLAGS (OPTST_DISABLED \
  255. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  256. /*
  257. * Enet_Smac option description:
  258. */
  259. tSCC zEnet_SmacText[] =
  260. "Override source ethernet MAC addresses";
  261. tSCC zEnet_Smac_NAME[] = "ENET_SMAC";
  262. tSCC zEnet_Smac_Name[] = "enet-smac";
  263. #define ENET_SMAC_FLAGS (OPTST_DISABLED \
  264. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  265. /*
  266. * Enet_Vlan option description:
  267. */
  268. tSCC zEnet_VlanText[] =
  269. "Specify ethernet 802.1q VLAN tag mode";
  270. tSCC zEnet_Vlan_NAME[] = "ENET_VLAN";
  271. tSCC zEnet_Vlan_Name[] = "enet-vlan";
  272. #define ENET_VLAN_FLAGS (OPTST_DISABLED \
  273. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  274. /*
  275. * Enet_Vlan_Tag option description with
  276. * "Must also have options" and "Incompatible options":
  277. */
  278. tSCC zEnet_Vlan_TagText[] =
  279. "Specify the new ethernet 802.1q VLAN tag value";
  280. tSCC zEnet_Vlan_Tag_NAME[] = "ENET_VLAN_TAG";
  281. tSCC zEnet_Vlan_Tag_Name[] = "enet-vlan-tag";
  282. static const int
  283. aEnet_Vlan_TagMustList[] = {
  284. INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
  285. #define ENET_VLAN_TAG_FLAGS (OPTST_DISABLED \
  286. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  287. /*
  288. * Enet_Vlan_Cfi option description with
  289. * "Must also have options" and "Incompatible options":
  290. */
  291. tSCC zEnet_Vlan_CfiText[] =
  292. "Specify the ethernet 802.1q VLAN CFI value";
  293. tSCC zEnet_Vlan_Cfi_NAME[] = "ENET_VLAN_CFI";
  294. tSCC zEnet_Vlan_Cfi_Name[] = "enet-vlan-cfi";
  295. static const int
  296. aEnet_Vlan_CfiMustList[] = {
  297. INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
  298. #define ENET_VLAN_CFI_FLAGS (OPTST_DISABLED \
  299. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  300. /*
  301. * Enet_Vlan_Pri option description with
  302. * "Must also have options" and "Incompatible options":
  303. */
  304. tSCC zEnet_Vlan_PriText[] =
  305. "Specify the ethernet 802.1q VLAN priority";
  306. tSCC zEnet_Vlan_Pri_NAME[] = "ENET_VLAN_PRI";
  307. tSCC zEnet_Vlan_Pri_Name[] = "enet-vlan-pri";
  308. static const int
  309. aEnet_Vlan_PriMustList[] = {
  310. INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
  311. #define ENET_VLAN_PRI_FLAGS (OPTST_DISABLED \
  312. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  313. /*
  314. * Hdlc_Control option description:
  315. */
  316. tSCC zHdlc_ControlText[] =
  317. "Specify HDLC control value";
  318. tSCC zHdlc_Control_NAME[] = "HDLC_CONTROL";
  319. tSCC zHdlc_Control_Name[] = "hdlc-control";
  320. #define HDLC_CONTROL_FLAGS (OPTST_DISABLED \
  321. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  322. /*
  323. * Hdlc_Address option description:
  324. */
  325. tSCC zHdlc_AddressText[] =
  326. "Specify HDLC address";
  327. tSCC zHdlc_Address_NAME[] = "HDLC_ADDRESS";
  328. tSCC zHdlc_Address_Name[] = "hdlc-address";
  329. #define HDLC_ADDRESS_FLAGS (OPTST_DISABLED \
  330. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  331. /*
  332. * User_Dlt option description:
  333. */
  334. tSCC zUser_DltText[] =
  335. "Set output file DLT type";
  336. tSCC zUser_Dlt_NAME[] = "USER_DLT";
  337. tSCC zUser_Dlt_Name[] = "user-dlt";
  338. #define USER_DLT_FLAGS (OPTST_DISABLED \
  339. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  340. /*
  341. * User_Dlink option description:
  342. */
  343. tSCC zUser_DlinkText[] =
  344. "Rewrite Data-Link layer with user specified data";
  345. tSCC zUser_Dlink_NAME[] = "USER_DLINK";
  346. tSCC zUser_Dlink_Name[] = "user-dlink";
  347. #define USER_DLINK_FLAGS (OPTST_DISABLED | OPTST_STACKED \
  348. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  349. /*
  350. * Dbug option description:
  351. */
  352. #ifdef DEBUG
  353. tSCC zDbugText[] =
  354. "Enable debugging output";
  355. tSCC zDbug_NAME[] = "DBUG";
  356. tSCC zDbug_Name[] = "dbug";
  357. #define zDbugDefaultArg ((char const*)0)
  358. #define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \
  359. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  360. #else /* disable Dbug */
  361. #define VALUE_OPT_DBUG NO_EQUIVALENT
  362. #define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  363. #define zDbugDefaultArg NULL
  364. #define zDbugText NULL
  365. #define zDbug_NAME NULL
  366. #define zDbug_Name NULL
  367. #endif /* DEBUG */
  368. /*
  369. * Infile option description:
  370. */
  371. tSCC zInfileText[] =
  372. "Input pcap file to be processed";
  373. tSCC zInfile_NAME[] = "INFILE";
  374. tSCC zInfile_Name[] = "infile";
  375. #define INFILE_FLAGS (OPTST_DISABLED | OPTST_MUST_SET | OPTST_IMM \
  376. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  377. /*
  378. * Outfile option description:
  379. */
  380. tSCC zOutfileText[] =
  381. "Output pcap file";
  382. tSCC zOutfile_NAME[] = "OUTFILE";
  383. tSCC zOutfile_Name[] = "outfile";
  384. #define OUTFILE_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \
  385. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  386. /*
  387. * Cachefile option description:
  388. */
  389. tSCC zCachefileText[] =
  390. "Split traffic via tcpprep cache file";
  391. tSCC zCachefile_NAME[] = "CACHEFILE";
  392. tSCC zCachefile_Name[] = "cachefile";
  393. #define CACHEFILE_FLAGS (OPTST_DISABLED \
  394. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  395. /*
  396. * Verbose option description:
  397. */
  398. #ifdef ENABLE_VERBOSE
  399. tSCC zVerboseText[] =
  400. "Print decoded packets via tcpdump to STDOUT";
  401. tSCC zVerbose_NAME[] = "VERBOSE";
  402. tSCC zVerbose_Name[] = "verbose";
  403. #define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM)
  404. #else /* disable Verbose */
  405. #define VALUE_OPT_VERBOSE NO_EQUIVALENT
  406. #define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  407. #define zVerboseText NULL
  408. #define zVerbose_NAME NULL
  409. #define zVerbose_Name NULL
  410. #endif /* ENABLE_VERBOSE */
  411. /*
  412. * Decode option description with
  413. * "Must also have options" and "Incompatible options":
  414. */
  415. #ifdef ENABLE_VERBOSE
  416. tSCC zDecodeText[] =
  417. "Arguments passed to tcpdump decoder";
  418. tSCC zDecode_NAME[] = "DECODE";
  419. tSCC zDecode_Name[] = "decode";
  420. static const int
  421. aDecodeMustList[] = {
  422. INDEX_OPT_VERBOSE, NO_EQUIVALENT };
  423. #define DECODE_FLAGS (OPTST_DISABLED \
  424. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  425. #else /* disable Decode */
  426. #define VALUE_OPT_DECODE NO_EQUIVALENT
  427. #define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  428. #define aDecodeMustList NULL
  429. #define zDecodeText NULL
  430. #define zDecode_NAME NULL
  431. #define zDecode_Name NULL
  432. #endif /* ENABLE_VERBOSE */
  433. /*
  434. * Skip_Soft_Errors option description:
  435. */
  436. tSCC zSkip_Soft_ErrorsText[] =
  437. "Skip writing packets with soft errors";
  438. tSCC zSkip_Soft_Errors_NAME[] = "SKIP_SOFT_ERRORS";
  439. tSCC zSkip_Soft_Errors_Name[] = "skip-soft-errors";
  440. #define SKIP_SOFT_ERRORS_FLAGS (OPTST_DISABLED)
  441. /*
  442. * Version option description:
  443. */
  444. tSCC zVersionText[] =
  445. "Print version information";
  446. tSCC zVersion_NAME[] = "VERSION";
  447. tSCC zVersion_Name[] = "version";
  448. #define VERSION_FLAGS (OPTST_DISABLED)
  449. /*
  450. * Less_Help option description:
  451. */
  452. tSCC zLess_HelpText[] =
  453. "Display less usage information and exit";
  454. tSCC zLess_Help_NAME[] = "LESS_HELP";
  455. tSCC zLess_Help_Name[] = "less-help";
  456. #define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM)
  457. /*
  458. * Help/More_Help option descriptions:
  459. */
  460. tSCC zHelpText[] = "Display usage information and exit";
  461. tSCC zHelp_Name[] = "help";
  462. tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
  463. tSCC zMore_Help_Name[] = "more-help";
  464. /*
  465. * Save/Load_Opts option description:
  466. */
  467. tSCC zSave_OptsText[] = "Save the option state to a config file";
  468. tSCC zSave_Opts_Name[] = "save-opts";
  469. tSCC zLoad_OptsText[] = "Load options from a config file";
  470. tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
  471. tSCC zNotLoad_Opts_Name[] = "no-load-opts";
  472. tSCC zNotLoad_Opts_Pfx[] = "no";
  473. #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
  474. /*
  475. * Declare option callback procedures
  476. */
  477. #ifdef DEBUG
  478. static tOptProc doOptDbug;
  479. #else /* not DEBUG */
  480. # define doOptDbug NULL
  481. #endif /* def/not DEBUG */
  482. extern tOptProc
  483. optionNumericVal, optionPagedUsage, optionStackArg;
  484. static tOptProc
  485. doOptCachefile, doOptEnet_Vlan_Cfi, doOptEnet_Vlan_Pri,
  486. doOptEnet_Vlan_Tag, doOptLess_Help, doOptMtu,
  487. doOptVersion, doUsageOpt;
  488. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  489. *
  490. * Define the Tcprewrite Option Descriptions.
  491. */
  492. static tOptDesc optDesc[ OPTION_CT ] = {
  493. { /* entry idx, value */ 0, 0,
  494. /* equiv idx, value */ 0, 0,
  495. /* equivalenced to */ NO_EQUIVALENT,
  496. /* min, max, act ct */ 0, 0, 0,
  497. /* opt state flags */ TCPEDIT_FLAGS, 0,
  498. /* last opt argumnt */ { NULL },
  499. /* arg list/cookie */ NULL,
  500. /* must/cannot opts */ NULL, NULL,
  501. /* option proc */ NULL,
  502. /* desc, NAME, name */ zTcpeditText, NULL, NULL,
  503. /* disablement strs */ NULL, NULL },
  504. { /* entry idx, value */ 1, VALUE_OPT_PORTMAP,
  505. /* equiv idx, value */ 1, VALUE_OPT_PORTMAP,
  506. /* equivalenced to */ NO_EQUIVALENT,
  507. /* min, max, act ct */ 0, 1, 0,
  508. /* opt state flags */ PORTMAP_FLAGS, 0,
  509. /* last opt argumnt */ { NULL },
  510. /* arg list/cookie */ NULL,
  511. /* must/cannot opts */ NULL, NULL,
  512. /* option proc */ NULL,
  513. /* desc, NAME, name */ zPortmapText, zPortmap_NAME, zPortmap_Name,
  514. /* disablement strs */ NULL, NULL },
  515. { /* entry idx, value */ 2, VALUE_OPT_SEED,
  516. /* equiv idx, value */ 2, VALUE_OPT_SEED,
  517. /* equivalenced to */ NO_EQUIVALENT,
  518. /* min, max, act ct */ 0, 1, 0,
  519. /* opt state flags */ SEED_FLAGS, 0,
  520. /* last opt argumnt */ { NULL },
  521. /* arg list/cookie */ NULL,
  522. /* must/cannot opts */ NULL, NULL,
  523. /* option proc */ optionNumericVal,
  524. /* desc, NAME, name */ zSeedText, zSeed_NAME, zSeed_Name,
  525. /* disablement strs */ NULL, NULL },
  526. { /* entry idx, value */ 3, VALUE_OPT_PNAT,
  527. /* equiv idx, value */ 3, VALUE_OPT_PNAT,
  528. /* equivalenced to */ NO_EQUIVALENT,
  529. /* min, max, act ct */ 0, 2, 0,
  530. /* opt state flags */ PNAT_FLAGS, 0,
  531. /* last opt argumnt */ { NULL },
  532. /* arg list/cookie */ NULL,
  533. /* must/cannot opts */ NULL, aPnatCantList,
  534. /* option proc */ optionStackArg,
  535. /* desc, NAME, name */ zPnatText, zPnat_NAME, zPnat_Name,
  536. /* disablement strs */ NULL, NULL },
  537. { /* entry idx, value */ 4, VALUE_OPT_SRCIPMAP,
  538. /* equiv idx, value */ 4, VALUE_OPT_SRCIPMAP,
  539. /* equivalenced to */ NO_EQUIVALENT,
  540. /* min, max, act ct */ 0, 1, 0,
  541. /* opt state flags */ SRCIPMAP_FLAGS, 0,
  542. /* last opt argumnt */ { NULL },
  543. /* arg list/cookie */ NULL,
  544. /* must/cannot opts */ NULL, aSrcipmapCantList,
  545. /* option proc */ NULL,
  546. /* desc, NAME, name */ zSrcipmapText, zSrcipmap_NAME, zSrcipmap_Name,
  547. /* disablement strs */ NULL, NULL },
  548. { /* entry idx, value */ 5, VALUE_OPT_DSTIPMAP,
  549. /* equiv idx, value */ 5, VALUE_OPT_DSTIPMAP,
  550. /* equivalenced to */ NO_EQUIVALENT,
  551. /* min, max, act ct */ 0, 1, 0,
  552. /* opt state flags */ DSTIPMAP_FLAGS, 0,
  553. /* last opt argumnt */ { NULL },
  554. /* arg list/cookie */ NULL,
  555. /* must/cannot opts */ NULL, aDstipmapCantList,
  556. /* option proc */ NULL,
  557. /* desc, NAME, name */ zDstipmapText, zDstipmap_NAME, zDstipmap_Name,
  558. /* disablement strs */ NULL, NULL },
  559. { /* entry idx, value */ 6, VALUE_OPT_ENDPOINTS,
  560. /* equiv idx, value */ 6, VALUE_OPT_ENDPOINTS,
  561. /* equivalenced to */ NO_EQUIVALENT,
  562. /* min, max, act ct */ 0, 1, 0,
  563. /* opt state flags */ ENDPOINTS_FLAGS, 0,
  564. /* last opt argumnt */ { NULL },
  565. /* arg list/cookie */ NULL,
  566. /* must/cannot opts */ aEndpointsMustList, NULL,
  567. /* option proc */ NULL,
  568. /* desc, NAME, name */ zEndpointsText, zEndpoints_NAME, zEndpoints_Name,
  569. /* disablement strs */ NULL, NULL },
  570. { /* entry idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
  571. /* equiv idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
  572. /* equivalenced to */ NO_EQUIVALENT,
  573. /* min, max, act ct */ 0, 1, 0,
  574. /* opt state flags */ SKIPBROADCAST_FLAGS, 0,
  575. /* last opt argumnt */ { NULL },
  576. /* arg list/cookie */ NULL,
  577. /* must/cannot opts */ NULL, NULL,
  578. /* option proc */ NULL,
  579. /* desc, NAME, name */ zSkipbroadcastText, zSkipbroadcast_NAME, zSkipbroadcast_Name,
  580. /* disablement strs */ NULL, NULL },
  581. { /* entry idx, value */ 8, VALUE_OPT_FIXCSUM,
  582. /* equiv idx, value */ 8, VALUE_OPT_FIXCSUM,
  583. /* equivalenced to */ NO_EQUIVALENT,
  584. /* min, max, act ct */ 0, 1, 0,
  585. /* opt state flags */ FIXCSUM_FLAGS, 0,
  586. /* last opt argumnt */ { NULL },
  587. /* arg list/cookie */ NULL,
  588. /* must/cannot opts */ NULL, NULL,
  589. /* option proc */ NULL,
  590. /* desc, NAME, name */ zFixcsumText, zFixcsum_NAME, zFixcsum_Name,
  591. /* disablement strs */ NULL, NULL },
  592. { /* entry idx, value */ 9, VALUE_OPT_MTU,
  593. /* equiv idx, value */ 9, VALUE_OPT_MTU,
  594. /* equivalenced to */ NO_EQUIVALENT,
  595. /* min, max, act ct */ 0, 1, 0,
  596. /* opt state flags */ MTU_FLAGS, 0,
  597. /* last opt argumnt */ { NULL },
  598. /* arg list/cookie */ NULL,
  599. /* must/cannot opts */ NULL, NULL,
  600. /* option proc */ doOptMtu,
  601. /* desc, NAME, name */ zMtuText, zMtu_NAME, zMtu_Name,
  602. /* disablement strs */ NULL, NULL },
  603. { /* entry idx, value */ 10, VALUE_OPT_EFCS,
  604. /* equiv idx, value */ 10, VALUE_OPT_EFCS,
  605. /* equivalenced to */ NO_EQUIVALENT,
  606. /* min, max, act ct */ 0, 1, 0,
  607. /* opt state flags */ EFCS_FLAGS, 0,
  608. /* last opt argumnt */ { NULL },
  609. /* arg list/cookie */ NULL,
  610. /* must/cannot opts */ NULL, NULL,
  611. /* option proc */ NULL,
  612. /* desc, NAME, name */ zEfcsText, zEfcs_NAME, zEfcs_Name,
  613. /* disablement strs */ NULL, NULL },
  614. { /* entry idx, value */ 11, VALUE_OPT_FIXLEN,
  615. /* equiv idx, value */ 11, VALUE_OPT_FIXLEN,
  616. /* equivalenced to */ NO_EQUIVALENT,
  617. /* min, max, act ct */ 0, 1, 0,
  618. /* opt state flags */ FIXLEN_FLAGS, 0,
  619. /* last opt argumnt */ { NULL },
  620. /* arg list/cookie */ NULL,
  621. /* must/cannot opts */ NULL, NULL,
  622. /* option proc */ NULL,
  623. /* desc, NAME, name */ zFixlenText, zFixlen_NAME, zFixlen_Name,
  624. /* disablement strs */ NULL, NULL },
  625. { /* entry idx, value */ 12, VALUE_OPT_SKIPL2BROADCAST,
  626. /* equiv idx, value */ 12, VALUE_OPT_SKIPL2BROADCAST,
  627. /* equivalenced to */ NO_EQUIVALENT,
  628. /* min, max, act ct */ 0, 1, 0,
  629. /* opt state flags */ SKIPL2BROADCAST_FLAGS, 0,
  630. /* last opt argumnt */ { NULL },
  631. /* arg list/cookie */ NULL,
  632. /* must/cannot opts */ NULL, NULL,
  633. /* option proc */ NULL,
  634. /* desc, NAME, name */ zSkipl2broadcastText, zSkipl2broadcast_NAME, zSkipl2broadcast_Name,
  635. /* disablement strs */ NULL, NULL },
  636. { /* entry idx, value */ 13, VALUE_OPT_DLT,
  637. /* equiv idx, value */ 13, VALUE_OPT_DLT,
  638. /* equivalenced to */ NO_EQUIVALENT,
  639. /* min, max, act ct */ 0, 1, 0,
  640. /* opt state flags */ DLT_FLAGS, 0,
  641. /* last opt argumnt */ { NULL },
  642. /* arg list/cookie */ NULL,
  643. /* must/cannot opts */ NULL, NULL,
  644. /* option proc */ NULL,
  645. /* desc, NAME, name */ zDltText, zDlt_NAME, zDlt_Name,
  646. /* disablement strs */ NULL, NULL },
  647. { /* entry idx, value */ 14, VALUE_OPT_ENET_DMAC,
  648. /* equiv idx, value */ 14, VALUE_OPT_ENET_DMAC,
  649. /* equivalenced to */ NO_EQUIVALENT,
  650. /* min, max, act ct */ 0, 1, 0,
  651. /* opt state flags */ ENET_DMAC_FLAGS, 0,
  652. /* last opt argumnt */ { NULL },
  653. /* arg list/cookie */ NULL,
  654. /* must/cannot opts */ NULL, NULL,
  655. /* option proc */ NULL,
  656. /* desc, NAME, name */ zEnet_DmacText, zEnet_Dmac_NAME, zEnet_Dmac_Name,
  657. /* disablement strs */ NULL, NULL },
  658. { /* entry idx, value */ 15, VALUE_OPT_ENET_SMAC,
  659. /* equiv idx, value */ 15, VALUE_OPT_ENET_SMAC,
  660. /* equivalenced to */ NO_EQUIVALENT,
  661. /* min, max, act ct */ 0, 1, 0,
  662. /* opt state flags */ ENET_SMAC_FLAGS, 0,
  663. /* last opt argumnt */ { NULL },
  664. /* arg list/cookie */ NULL,
  665. /* must/cannot opts */ NULL, NULL,
  666. /* option proc */ NULL,
  667. /* desc, NAME, name */ zEnet_SmacText, zEnet_Smac_NAME, zEnet_Smac_Name,
  668. /* disablement strs */ NULL, NULL },
  669. { /* entry idx, value */ 16, VALUE_OPT_ENET_VLAN,
  670. /* equiv idx, value */ 16, VALUE_OPT_ENET_VLAN,
  671. /* equivalenced to */ NO_EQUIVALENT,
  672. /* min, max, act ct */ 0, 1, 0,
  673. /* opt state flags */ ENET_VLAN_FLAGS, 0,
  674. /* last opt argumnt */ { NULL },
  675. /* arg list/cookie */ NULL,
  676. /* must/cannot opts */ NULL, NULL,
  677. /* option proc */ NULL,
  678. /* desc, NAME, name */ zEnet_VlanText, zEnet_Vlan_NAME, zEnet_Vlan_Name,
  679. /* disablement strs */ NULL, NULL },
  680. { /* entry idx, value */ 17, VALUE_OPT_ENET_VLAN_TAG,
  681. /* equiv idx, value */ 17, VALUE_OPT_ENET_VLAN_TAG,
  682. /* equivalenced to */ NO_EQUIVALENT,
  683. /* min, max, act ct */ 0, 1, 0,
  684. /* opt state flags */ ENET_VLAN_TAG_FLAGS, 0,
  685. /* last opt argumnt */ { NULL },
  686. /* arg list/cookie */ NULL,
  687. /* must/cannot opts */ aEnet_Vlan_TagMustList, NULL,
  688. /* option proc */ doOptEnet_Vlan_Tag,
  689. /* desc, NAME, name */ zEnet_Vlan_TagText, zEnet_Vlan_Tag_NAME, zEnet_Vlan_Tag_Name,
  690. /* disablement strs */ NULL, NULL },
  691. { /* entry idx, value */ 18, VALUE_OPT_ENET_VLAN_CFI,
  692. /* equiv idx, value */ 18, VALUE_OPT_ENET_VLAN_CFI,
  693. /* equivalenced to */ NO_EQUIVALENT,
  694. /* min, max, act ct */ 0, 1, 0,
  695. /* opt state flags */ ENET_VLAN_CFI_FLAGS, 0,
  696. /* last opt argumnt */ { NULL },
  697. /* arg list/cookie */ NULL,
  698. /* must/cannot opts */ aEnet_Vlan_CfiMustList, NULL,
  699. /* option proc */ doOptEnet_Vlan_Cfi,
  700. /* desc, NAME, name */ zEnet_Vlan_CfiText, zEnet_Vlan_Cfi_NAME, zEnet_Vlan_Cfi_Name,
  701. /* disablement strs */ NULL, NULL },
  702. { /* entry idx, value */ 19, VALUE_OPT_ENET_VLAN_PRI,
  703. /* equiv idx, value */ 19, VALUE_OPT_ENET_VLAN_PRI,
  704. /* equivalenced to */ NO_EQUIVALENT,
  705. /* min, max, act ct */ 0, 1, 0,
  706. /* opt state flags */ ENET_VLAN_PRI_FLAGS, 0,
  707. /* last opt argumnt */ { NULL },
  708. /* arg list/cookie */ NULL,
  709. /* must/cannot opts */ aEnet_Vlan_PriMustList, NULL,
  710. /* option proc */ doOptEnet_Vlan_Pri,
  711. /* desc, NAME, name */ zEnet_Vlan_PriText, zEnet_Vlan_Pri_NAME, zEnet_Vlan_Pri_Name,
  712. /* disablement strs */ NULL, NULL },
  713. { /* entry idx, value */ 20, VALUE_OPT_HDLC_CONTROL,
  714. /* equiv idx, value */ 20, VALUE_OPT_HDLC_CONTROL,
  715. /* equivalenced to */ NO_EQUIVALENT,
  716. /* min, max, act ct */ 0, 1, 0,
  717. /* opt state flags */ HDLC_CONTROL_FLAGS, 0,
  718. /* last opt argumnt */ { NULL },
  719. /* arg list/cookie */ NULL,
  720. /* must/cannot opts */ NULL, NULL,
  721. /* option proc */ optionNumericVal,
  722. /* desc, NAME, name */ zHdlc_ControlText, zHdlc_Control_NAME, zHdlc_Control_Name,
  723. /* disablement strs */ NULL, NULL },
  724. { /* entry idx, value */ 21, VALUE_OPT_HDLC_ADDRESS,
  725. /* equiv idx, value */ 21, VALUE_OPT_HDLC_ADDRESS,
  726. /* equivalenced to */ NO_EQUIVALENT,
  727. /* min, max, act ct */ 0, 1, 0,
  728. /* opt state flags */ HDLC_ADDRESS_FLAGS, 0,
  729. /* last opt argumnt */ { NULL },
  730. /* arg list/cookie */ NULL,
  731. /* must/cannot opts */ NULL, NULL,
  732. /* option proc */ optionNumericVal,
  733. /* desc, NAME, name */ zHdlc_AddressText, zHdlc_Address_NAME, zHdlc_Address_Name,
  734. /* disablement strs */ NULL, NULL },
  735. { /* entry idx, value */ 22, VALUE_OPT_USER_DLT,
  736. /* equiv idx, value */ 22, VALUE_OPT_USER_DLT,
  737. /* equivalenced to */ NO_EQUIVALENT,
  738. /* min, max, act ct */ 0, 1, 0,
  739. /* opt state flags */ USER_DLT_FLAGS, 0,
  740. /* last opt argumnt */ { NULL },
  741. /* arg list/cookie */ NULL,
  742. /* must/cannot opts */ NULL, NULL,
  743. /* option proc */ optionNumericVal,
  744. /* desc, NAME, name */ zUser_DltText, zUser_Dlt_NAME, zUser_Dlt_Name,
  745. /* disablement strs */ NULL, NULL },
  746. { /* entry idx, value */ 23, VALUE_OPT_USER_DLINK,
  747. /* equiv idx, value */ 23, VALUE_OPT_USER_DLINK,
  748. /* equivalenced to */ NO_EQUIVALENT,
  749. /* min, max, act ct */ 0, 2, 0,
  750. /* opt state flags */ USER_DLINK_FLAGS, 0,
  751. /* last opt argumnt */ { NULL },
  752. /* arg list/cookie */ NULL,
  753. /* must/cannot opts */ NULL, NULL,
  754. /* option proc */ optionStackArg,
  755. /* desc, NAME, name */ zUser_DlinkText, zUser_Dlink_NAME, zUser_Dlink_Name,
  756. /* disablement strs */ NULL, NULL },
  757. { /* entry idx, value */ 24, VALUE_OPT_DBUG,
  758. /* equiv idx, value */ 24, VALUE_OPT_DBUG,
  759. /* equivalenced to */ NO_EQUIVALENT,
  760. /* min, max, act ct */ 0, 1, 0,
  761. /* opt state flags */ DBUG_FLAGS, 0,
  762. /* last opt argumnt */ { zDbugDefaultArg },
  763. /* arg list/cookie */ NULL,
  764. /* must/cannot opts */ NULL, NULL,
  765. /* option proc */ doOptDbug,
  766. /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name,
  767. /* disablement strs */ NULL, NULL },
  768. { /* entry idx, value */ 25, VALUE_OPT_INFILE,
  769. /* equiv idx, value */ 25, VALUE_OPT_INFILE,
  770. /* equivalenced to */ NO_EQUIVALENT,
  771. /* min, max, act ct */ 1, 1, 0,
  772. /* opt state flags */ INFILE_FLAGS, 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 */ zInfileText, zInfile_NAME, zInfile_Name,
  778. /* disablement strs */ NULL, NULL },
  779. { /* entry idx, value */ 26, VALUE_OPT_OUTFILE,
  780. /* equiv idx, value */ 26, VALUE_OPT_OUTFILE,
  781. /* equivalenced to */ NO_EQUIVALENT,
  782. /* min, max, act ct */ 1, 1, 0,
  783. /* opt state flags */ OUTFILE_FLAGS, 0,
  784. /* last opt argumnt */ { NULL },
  785. /* arg list/cookie */ NULL,
  786. /* must/cannot opts */ NULL, NULL,
  787. /* option proc */ NULL,
  788. /* desc, NAME, name */ zOutfileText, zOutfile_NAME, zOutfile_Name,
  789. /* disablement strs */ NULL, NULL },
  790. { /* entry idx, value */ 27, VALUE_OPT_CACHEFILE,
  791. /* equiv idx, value */ 27, VALUE_OPT_CACHEFILE,
  792. /* equivalenced to */ NO_EQUIVALENT,
  793. /* min, max, act ct */ 0, 1, 0,
  794. /* opt state flags */ CACHEFILE_FLAGS, 0,
  795. /* last opt argumnt */ { NULL },
  796. /* arg list/cookie */ NULL,
  797. /* must/cannot opts */ NULL, NULL,
  798. /* option proc */ doOptCachefile,
  799. /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name,
  800. /* disablement strs */ NULL, NULL },
  801. { /* entry idx, value */ 28, VALUE_OPT_VERBOSE,
  802. /* equiv idx, value */ 28, VALUE_OPT_VERBOSE,
  803. /* equivalenced to */ NO_EQUIVALENT,
  804. /* min, max, act ct */ 0, 1, 0,
  805. /* opt state flags */ VERBOSE_FLAGS, 0,
  806. /* last opt argumnt */ { NULL },
  807. /* arg list/cookie */ NULL,
  808. /* must/cannot opts */ NULL, NULL,
  809. /* option proc */ NULL,
  810. /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name,
  811. /* disablement strs */ NULL, NULL },
  812. { /* entry idx, value */ 29, VALUE_OPT_DECODE,
  813. /* equiv idx, value */ 29, VALUE_OPT_DECODE,
  814. /* equivalenced to */ NO_EQUIVALENT,
  815. /* min, max, act ct */ 0, 1, 0,
  816. /* opt state flags */ DECODE_FLAGS, 0,
  817. /* last opt argumnt */ { NULL },
  818. /* arg list/cookie */ NULL,
  819. /* must/cannot opts */ aDecodeMustList, NULL,
  820. /* option proc */ NULL,
  821. /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name,
  822. /* disablement strs */ NULL, NULL },
  823. { /* entry idx, value */ 30, VALUE_OPT_SKIP_SOFT_ERRORS,
  824. /* equiv idx, value */ 30, VALUE_OPT_SKIP_SOFT_ERRORS,
  825. /* equivalenced to */ NO_EQUIVALENT,
  826. /* min, max, act ct */ 0, 1, 0,
  827. /* opt state flags */ SKIP_SOFT_ERRORS_FLAGS, 0,
  828. /* last opt argumnt */ { NULL },
  829. /* arg list/cookie */ NULL,
  830. /* must/cannot opts */ NULL, NULL,
  831. /* option proc */ NULL,
  832. /* desc, NAME, name */ zSkip_Soft_ErrorsText, zSkip_Soft_Errors_NAME, zSkip_Soft_Errors_Name,
  833. /* disablement strs */ NULL, NULL },
  834. { /* entry idx, value */ 31, VALUE_OPT_VERSION,
  835. /* equiv idx, value */ 31, VALUE_OPT_VERSION,
  836. /* equivalenced to */ NO_EQUIVALENT,
  837. /* min, max, act ct */ 0, 1, 0,
  838. /* opt state flags */ VERSION_FLAGS, 0,
  839. /* last opt argumnt */ { NULL },
  840. /* arg list/cookie */ NULL,
  841. /* must/cannot opts */ NULL, NULL,
  842. /* option proc */ doOptVersion,
  843. /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name,
  844. /* disablement strs */ NULL, NULL },
  845. { /* entry idx, value */ 32, VALUE_OPT_LESS_HELP,
  846. /* equiv idx, value */ 32, VALUE_OPT_LESS_HELP,
  847. /* equivalenced to */ NO_EQUIVALENT,
  848. /* min, max, act ct */ 0, 1, 0,
  849. /* opt state flags */ LESS_HELP_FLAGS, 0,
  850. /* last opt argumnt */ { NULL },
  851. /* arg list/cookie */ NULL,
  852. /* must/cannot opts */ NULL, NULL,
  853. /* option proc */ doOptLess_Help,
  854. /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name,
  855. /* disablement strs */ NULL, NULL },
  856. { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
  857. /* equiv idx value */ NO_EQUIVALENT, 0,
  858. /* equivalenced to */ NO_EQUIVALENT,
  859. /* min, max, act ct */ 0, 1, 0,
  860. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  861. /* last opt argumnt */ { NULL },
  862. /* arg list/cookie */ NULL,
  863. /* must/cannot opts */ NULL, NULL,
  864. /* option proc */ doUsageOpt,
  865. /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
  866. /* disablement strs */ NULL, NULL },
  867. { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
  868. /* equiv idx value */ NO_EQUIVALENT, 0,
  869. /* equivalenced to */ NO_EQUIVALENT,
  870. /* min, max, act ct */ 0, 1, 0,
  871. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  872. /* last opt argumnt */ { NULL },
  873. /* arg list/cookie */ NULL,
  874. /* must/cannot opts */ NULL, NULL,
  875. /* option proc */ optionPagedUsage,
  876. /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
  877. /* disablement strs */ NULL, NULL },
  878. { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
  879. /* equiv idx value */ NO_EQUIVALENT, 0,
  880. /* equivalenced to */ NO_EQUIVALENT,
  881. /* min, max, act ct */ 0, 1, 0,
  882. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  883. | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
  884. /* last opt argumnt */ { NULL },
  885. /* arg list/cookie */ NULL,
  886. /* must/cannot opts */ NULL, NULL,
  887. /* option proc */ NULL,
  888. /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
  889. /* disablement strs */ NULL, NULL },
  890. { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
  891. /* equiv idx value */ NO_EQUIVALENT, 0,
  892. /* equivalenced to */ NO_EQUIVALENT,
  893. /* min, max, act ct */ 0, NOLIMIT, 0,
  894. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
  895. | OPTST_DISABLE_IMM, 0,
  896. /* last opt argumnt */ { NULL },
  897. /* arg list/cookie */ NULL,
  898. /* must/cannot opts */ NULL, NULL,
  899. /* option proc */ optionLoadOpt,
  900. /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
  901. /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
  902. };
  903. tOptDesc * const tcpedit_tcpedit_optDesc_p = optDesc + 0;
  904. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  905. *
  906. * Define the Tcprewrite Option Environment
  907. */
  908. tSCC zPROGNAME[] = "TCPREWRITE";
  909. tSCC zUsageTitle[] =
  910. "tcprewrite (tcprewrite) - Rewrite the packets in a pcap file.\n\
  911. USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
  912. tSCC zRcName[] = ".tcprewriterc";
  913. tSCC* apzHomeList[] = {
  914. "$$/",
  915. NULL };
  916. #define zBugsAddr NULL
  917. #define zExplain NULL
  918. tSCC zDetail[] = "\n\
  919. Tcprewrite is a tool to rewrite packets stored in ``pcap(3)'' file format, \n\
  920. such as crated by tools such as ``tcpdump(1)'' and ``ethereal(1)''. \n\
  921. Once a pcap file has had it's packets rewritten, they can be replayed back \n\
  922. out on the network using ``tcpreplay(1)''.\n\n\
  923. tcprewrite currently supports reading the following DLT types:\n\n\n\
  924. ``DLT_C_HDLC'' aka Cisco HDLC\n\n\n\
  925. ``DLT_EN10MB'' aka Ethernet\n\n\n\
  926. ``DLT_LINUX_SLL'' aka Linux Cooked Socket\n\n\n\
  927. ``DLT_RAW'' aka RAW IP\n\n\n\
  928. ``DLT_NULL'' aka BSD Loopback\n\n\n\
  929. ``DLT_LOOP'' aka OpenBSD Loopback\n\n\n\
  930. ``DLT_IEEE802_11'' aka 802.11a/b/g\n\n\n\
  931. ``DLT_IEEE802_11_RADIO'' aka 802.11a/b/g with Radiotap headers\n\n\
  932. Please see the --dlt option for supported DLT types for writing.\n\n\
  933. The packet editing features of tcprewrite which distinguish between \"client\"\n\
  934. and \"server\" traffic requires a tcpprep(1) cache file.\n\n\
  935. For more details, please see the Tcpreplay Manual at:\n\
  936. http://tcpreplay.synfin.net/trac/wiki/manual\n";
  937. #define zFullVersion NULL
  938. /* extracted from /opt/local/share/autogen/optcode.tpl near line 428 */
  939. #if defined(ENABLE_NLS)
  940. # define OPTPROC_BASE OPTPROC_TRANSLATE
  941. static tOptionXlateProc translate_option_strings;
  942. #else
  943. # define OPTPROC_BASE OPTPROC_NONE
  944. # define translate_option_strings NULL
  945. #endif /* ENABLE_NLS */
  946. #define tcprewrite_full_usage NULL
  947. #define tcprewrite_short_usage NULL
  948. tOptions tcprewriteOptions = {
  949. OPTIONS_STRUCT_VERSION,
  950. 0, NULL, /* original argc + argv */
  951. ( OPTPROC_BASE
  952. + OPTPROC_ERRSTOP
  953. + OPTPROC_SHORTOPT
  954. + OPTPROC_LONGOPT
  955. + OPTPROC_NO_REQ_OPT
  956. + OPTPROC_NO_ARGS
  957. + OPTPROC_GNUUSAGE
  958. + OPTPROC_HAS_IMMED ),
  959. 0, NULL, /* current option index, current option */
  960. NULL, NULL, zPROGNAME,
  961. zRcName, zCopyright, zCopyrightNotice,
  962. zFullVersion, apzHomeList, zUsageTitle,
  963. zExplain, zDetail, optDesc,
  964. zBugsAddr, /* address to send bugs to */
  965. NULL, NULL, /* extensions/saved state */
  966. optionUsage, /* usage procedure */
  967. translate_option_strings, /* translation procedure */
  968. /*
  969. * Indexes to special options
  970. */
  971. { INDEX_OPT_MORE_HELP,
  972. INDEX_OPT_SAVE_OPTS,
  973. NO_EQUIVALENT /* index of '-#' option */,
  974. 9 /* index of default opt */
  975. },
  976. 37 /* full option count */, 33 /* user option count */,
  977. tcprewrite_full_usage, tcprewrite_short_usage
  978. };
  979. /*
  980. * Create the static procedure(s) declared above.
  981. */
  982. static void
  983. doUsageOpt(
  984. tOptions* pOptions,
  985. tOptDesc* pOptDesc )
  986. {
  987. USAGE( EXIT_SUCCESS );
  988. }
  989. /* * * * * * *
  990. *
  991. * For the mtu option.
  992. */
  993. static void
  994. doOptMtu(
  995. tOptions* pOptions,
  996. tOptDesc* pOptDesc )
  997. {
  998. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  999. { 1, MAXPACKET } };
  1000. int val;
  1001. int ix;
  1002. char const* pzIndent = "\t\t\t\t ";
  1003. extern FILE* option_usage_fp;
  1004. if (pOptDesc == NULL) /* usage is requesting range list
  1005. option_usage_fp has already been set */
  1006. goto emit_ranges;
  1007. val = atoi( pOptDesc->optArg.argString );
  1008. for (ix = 0; ix < 1; ix++) {
  1009. if (val < rng[ix].rmin)
  1010. continue; /* ranges need not be ordered. */
  1011. if (val == rng[ix].rmin)
  1012. goto valid_return;
  1013. if (rng[ix].rmax == INT_MIN)
  1014. continue;
  1015. if (val <= rng[ix].rmax)
  1016. goto valid_return;
  1017. }
  1018. option_usage_fp = stderr;
  1019. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1020. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1021. pzIndent = "\t";
  1022. emit_ranges:
  1023. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1024. pzIndent, rng[0].rmin, rng[0].rmax );
  1025. if (pOptDesc == NULL)
  1026. return;
  1027. USAGE( EXIT_FAILURE );
  1028. /* NOTREACHED */
  1029. return;
  1030. valid_return:
  1031. pOptDesc->optArg.argInt = val;
  1032. }
  1033. /* * * * * * *
  1034. *
  1035. * For the enet-vlan-tag option.
  1036. */
  1037. static void
  1038. doOptEnet_Vlan_Tag(
  1039. tOptions* pOptions,
  1040. tOptDesc* pOptDesc )
  1041. {
  1042. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1043. { 0, 4095 } };
  1044. int val;
  1045. int ix;
  1046. char const* pzIndent = "\t\t\t\t ";
  1047. extern FILE* option_usage_fp;
  1048. if (pOptDesc == NULL) /* usage is requesting range list
  1049. option_usage_fp has already been set */
  1050. goto emit_ranges;
  1051. val = atoi( pOptDesc->optArg.argString );
  1052. for (ix = 0; ix < 1; ix++) {
  1053. if (val < rng[ix].rmin)
  1054. continue; /* ranges need not be ordered. */
  1055. if (val == rng[ix].rmin)
  1056. goto valid_return;
  1057. if (rng[ix].rmax == INT_MIN)
  1058. continue;
  1059. if (val <= rng[ix].rmax)
  1060. goto valid_return;
  1061. }
  1062. option_usage_fp = stderr;
  1063. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1064. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1065. pzIndent = "\t";
  1066. emit_ranges:
  1067. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1068. pzIndent, rng[0].rmin, rng[0].rmax );
  1069. if (pOptDesc == NULL)
  1070. return;
  1071. USAGE( EXIT_FAILURE );
  1072. /* NOTREACHED */
  1073. return;
  1074. valid_return:
  1075. pOptDesc->optArg.argInt = val;
  1076. }
  1077. /* * * * * * *
  1078. *
  1079. * For the enet-vlan-cfi option.
  1080. */
  1081. static void
  1082. doOptEnet_Vlan_Cfi(
  1083. tOptions* pOptions,
  1084. tOptDesc* pOptDesc )
  1085. {
  1086. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1087. { 0, 1 } };
  1088. int val;
  1089. int ix;
  1090. char const* pzIndent = "\t\t\t\t ";
  1091. extern FILE* option_usage_fp;
  1092. if (pOptDesc == NULL) /* usage is requesting range list
  1093. option_usage_fp has already been set */
  1094. goto emit_ranges;
  1095. val = atoi( pOptDesc->optArg.argString );
  1096. for (ix = 0; ix < 1; ix++) {
  1097. if (val < rng[ix].rmin)
  1098. continue; /* ranges need not be ordered. */
  1099. if (val == rng[ix].rmin)
  1100. goto valid_return;
  1101. if (rng[ix].rmax == INT_MIN)
  1102. continue;
  1103. if (val <= rng[ix].rmax)
  1104. goto valid_return;
  1105. }
  1106. option_usage_fp = stderr;
  1107. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1108. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1109. pzIndent = "\t";
  1110. emit_ranges:
  1111. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1112. pzIndent, rng[0].rmin, rng[0].rmax );
  1113. if (pOptDesc == NULL)
  1114. return;
  1115. USAGE( EXIT_FAILURE );
  1116. /* NOTREACHED */
  1117. return;
  1118. valid_return:
  1119. pOptDesc->optArg.argInt = val;
  1120. }
  1121. /* * * * * * *
  1122. *
  1123. * For the enet-vlan-pri option.
  1124. */
  1125. static void
  1126. doOptEnet_Vlan_Pri(
  1127. tOptions* pOptions,
  1128. tOptDesc* pOptDesc )
  1129. {
  1130. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1131. { 0, 7 } };
  1132. int val;
  1133. int ix;
  1134. char const* pzIndent = "\t\t\t\t ";
  1135. extern FILE* option_usage_fp;
  1136. if (pOptDesc == NULL) /* usage is requesting range list
  1137. option_usage_fp has already been set */
  1138. goto emit_ranges;
  1139. val = atoi( pOptDesc->optArg.argString );
  1140. for (ix = 0; ix < 1; ix++) {
  1141. if (val < rng[ix].rmin)
  1142. continue; /* ranges need not be ordered. */
  1143. if (val == rng[ix].rmin)
  1144. goto valid_return;
  1145. if (rng[ix].rmax == INT_MIN)
  1146. continue;
  1147. if (val <= rng[ix].rmax)
  1148. goto valid_return;
  1149. }
  1150. option_usage_fp = stderr;
  1151. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1152. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1153. pzIndent = "\t";
  1154. emit_ranges:
  1155. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1156. pzIndent, rng[0].rmin, rng[0].rmax );
  1157. if (pOptDesc == NULL)
  1158. return;
  1159. USAGE( EXIT_FAILURE );
  1160. /* NOTREACHED */
  1161. return;
  1162. valid_return:
  1163. pOptDesc->optArg.argInt = val;
  1164. }
  1165. /* * * * * * *
  1166. *
  1167. * For the dbug option, when DEBUG is #define-d.
  1168. */
  1169. #ifdef DEBUG
  1170. static void
  1171. doOptDbug(
  1172. tOptions* pOptions,
  1173. tOptDesc* pOptDesc )
  1174. {
  1175. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1176. { 0, 5 } };
  1177. int val;
  1178. int ix;
  1179. char const* pzIndent = "\t\t\t\t ";
  1180. extern FILE* option_usage_fp;
  1181. if (pOptDesc == NULL) /* usage is requesting range list
  1182. option_usage_fp has already been set */
  1183. goto emit_ranges;
  1184. val = atoi( pOptDesc->optArg.argString );
  1185. for (ix = 0; ix < 1; ix++) {
  1186. if (val < rng[ix].rmin)
  1187. continue; /* ranges need not be ordered. */
  1188. if (val == rng[ix].rmin)
  1189. goto valid_return;
  1190. if (rng[ix].rmax == INT_MIN)
  1191. continue;
  1192. if (val <= rng[ix].rmax)
  1193. goto valid_return;
  1194. }
  1195. option_usage_fp = stderr;
  1196. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1197. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1198. pzIndent = "\t";
  1199. emit_ranges:
  1200. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1201. pzIndent, rng[0].rmin, rng[0].rmax );
  1202. if (pOptDesc == NULL)
  1203. return;
  1204. USAGE( EXIT_FAILURE );
  1205. /* NOTREACHED */
  1206. return;
  1207. valid_return:
  1208. pOptDesc->optArg.argInt = val;
  1209. }
  1210. #endif /* defined DEBUG */
  1211. /* * * * * * *
  1212. *
  1213. * For the cachefile option.
  1214. */
  1215. static void
  1216. doOptCachefile(
  1217. tOptions* pOptions,
  1218. tOptDesc* pOptDesc )
  1219. {
  1220. /* extracted from tcprewrite_opts.def, line 128 */
  1221. options.cache_packets =
  1222. read_cache(&options.cachedata, OPT_ARG(CACHEFILE), &options.comment);
  1223. }
  1224. /* * * * * * *
  1225. *
  1226. * For the version option.
  1227. */
  1228. static void
  1229. doOptVersion(
  1230. tOptions* pOptions,
  1231. tOptDesc* pOptDesc )
  1232. {
  1233. /* extracted from tcprewrite_opts.def, line 191 */
  1234. fprintf(stderr, "tcprewrite version: %s (build %s)", VERSION, svn_version());
  1235. #ifdef DEBUG
  1236. fprintf(stderr, " (debug)");
  1237. #endif
  1238. fprintf(stderr, "\n");
  1239. fprintf(stderr, "Copyright 2001-2007 by Aaron Turner <aturner at synfin dot net>\n");
  1240. fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION);
  1241. #ifdef HAVE_LIBNET
  1242. fprintf(stderr, "Compiled against libnet: %s\n", LIBNET_VERSION);
  1243. #else
  1244. fprintf(stderr, "Not compiled with libnet.\n");
  1245. #endif
  1246. #ifdef HAVE_WINPCAP
  1247. fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
  1248. #else
  1249. fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
  1250. #endif
  1251. #ifdef ENABLE_64BITS
  1252. fprintf(stderr, "64 bit packet counters: enabled\n");
  1253. #else
  1254. fprintf(stderr, "64 bit packet counters: disabled\n");
  1255. #endif
  1256. #ifdef ENABLE_VERBOSE
  1257. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  1258. #else
  1259. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  1260. #endif
  1261. exit(0);
  1262. }
  1263. /* * * * * * *
  1264. *
  1265. * For the less-help option.
  1266. */
  1267. static void
  1268. doOptLess_Help(
  1269. tOptions* pOptions,
  1270. tOptDesc* pOptDesc )
  1271. {
  1272. /* extracted from tcprewrite_opts.def, line 231 */
  1273. USAGE(EXIT_FAILURE);
  1274. }
  1275. /* extracted from /opt/local/share/autogen/optcode.tpl near line 537 */
  1276. #if ENABLE_NLS
  1277. #include <stdio.h>
  1278. #include <stdlib.h>
  1279. #include <string.h>
  1280. #include <unistd.h>
  1281. #include <autoopts/usage-txt.h>
  1282. static char* AO_gettext( char const* pz );
  1283. static void coerce_it(void** s);
  1284. static char*
  1285. AO_gettext( char const* pz )
  1286. {
  1287. char* pzRes;
  1288. if (pz == NULL)
  1289. return NULL;
  1290. pzRes = _(pz);
  1291. if (pzRes == pz)
  1292. return pzRes;
  1293. pzRes = strdup( pzRes );
  1294. if (pzRes == NULL) {
  1295. fputs( _("No memory for duping translated strings\n"), stderr );
  1296. exit( EXIT_FAILURE );
  1297. }
  1298. return pzRes;
  1299. }
  1300. static void coerce_it(void** s) { *s = AO_gettext(*s); }
  1301. #define COERSION(_f) \
  1302. coerce_it((void*)&(tcprewriteOptions._f))
  1303. /*
  1304. * This invokes the translation code (e.g. gettext(3)).
  1305. */
  1306. static void
  1307. translate_option_strings( void )
  1308. {
  1309. /*
  1310. * Guard against re-translation. It won't work. The strings will have
  1311. * been changed by the first pass through this code. One shot only.
  1312. */
  1313. if (option_usage_text.field_ct == 0)
  1314. return;
  1315. /*
  1316. * Do the translations. The first pointer follows the field count field.
  1317. * The field count field is the size of a pointer.
  1318. */
  1319. {
  1320. char** ppz = (char**)(void*)&(option_usage_text);
  1321. int ix = option_usage_text.field_ct;
  1322. do {
  1323. ppz++;
  1324. *ppz = AO_gettext(*ppz);
  1325. } while (--ix > 0);
  1326. }
  1327. option_usage_text.field_ct = 0;
  1328. {
  1329. tOptDesc* pOD = tcprewriteOptions.pOptDesc;
  1330. int ix = tcprewriteOptions.optCt;
  1331. for (;;) {
  1332. pOD->pzText = AO_gettext(pOD->pzText);
  1333. pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
  1334. pOD->pz_Name = AO_gettext(pOD->pz_Name);
  1335. pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
  1336. pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
  1337. if (--ix <= 0)
  1338. break;
  1339. pOD++;
  1340. }
  1341. }
  1342. COERSION(pzCopyright);
  1343. COERSION(pzCopyNotice);
  1344. COERSION(pzFullVersion);
  1345. COERSION(pzUsageTitle);
  1346. COERSION(pzExplain);
  1347. COERSION(pzDetail);
  1348. }
  1349. #endif /* ENABLE_NLS */
  1350. #ifdef __cplusplus
  1351. }
  1352. #endif
  1353. /* tcprewrite_opts.c ends here */