tcpbridge_opts.c 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcpbridge_opts.c)
  4. *
  5. * It has been AutoGen-ed Thursday May 15, 2008 at 08:51:18 AM PDT
  6. * From the definitions tcpbridge_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. * tcpbridge 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. * tcpbridge copyright 2005-2008 Aaron Turner - all rights reserved
  23. *
  24. * tcpbridge 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. * tcpbridge 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 "tcpbridge_opts.h"
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. tSCC zCopyright[] =
  58. "tcpbridge copyright (c) 2005-2008 Aaron Turner, all rights reserved";
  59. tSCC zCopyrightNotice[] =
  60. "tcpbridge 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. tcpbridge 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 "tcpbridge.h"
  89. #include "common.h"
  90. #include "config.h"
  91. #include <stdlib.h>
  92. #include <string.h>
  93. #include <sys/types.h>
  94. #include <unistd.h>
  95. extern tcpbridge_opt_t options;
  96. #ifndef NULL
  97. # define NULL 0
  98. #endif
  99. #ifndef EXIT_SUCCESS
  100. # define EXIT_SUCCESS 0
  101. #endif
  102. #ifndef EXIT_FAILURE
  103. # define EXIT_FAILURE 1
  104. #endif
  105. /*
  106. * Tcpedit option description:
  107. */
  108. tSCC zTcpeditText[] =
  109. "";
  110. #define TCPEDIT_FLAGS (OPTST_DOCUMENT | OPTST_NO_INIT)
  111. /*
  112. * Portmap option description:
  113. */
  114. tSCC zPortmapText[] =
  115. "Rewrite TCP/UDP ports";
  116. tSCC zPortmap_NAME[] = "PORTMAP";
  117. tSCC zPortmap_Name[] = "portmap";
  118. #define PORTMAP_FLAGS (OPTST_DISABLED \
  119. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  120. /*
  121. * Seed option description:
  122. */
  123. tSCC zSeedText[] =
  124. "Randomize src/dst IP addresses w/ given seed";
  125. tSCC zSeed_NAME[] = "SEED";
  126. tSCC zSeed_Name[] = "seed";
  127. #define SEED_FLAGS (OPTST_DISABLED \
  128. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  129. /*
  130. * Pnat option description with
  131. * "Must also have options" and "Incompatible options":
  132. */
  133. tSCC zPnatText[] =
  134. "Rewrite IP addresses using pseudo-NAT";
  135. tSCC zPnat_NAME[] = "PNAT";
  136. tSCC zPnat_Name[] = "pnat";
  137. static const int
  138. aPnatCantList[] = {
  139. INDEX_OPT_SRCIPMAP, NO_EQUIVALENT };
  140. #define PNAT_FLAGS (OPTST_DISABLED | OPTST_STACKED \
  141. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  142. /*
  143. * Srcipmap option description with
  144. * "Must also have options" and "Incompatible options":
  145. */
  146. tSCC zSrcipmapText[] =
  147. "Rewrite source IP addresses using pseudo-NAT";
  148. tSCC zSrcipmap_NAME[] = "SRCIPMAP";
  149. tSCC zSrcipmap_Name[] = "srcipmap";
  150. static const int
  151. aSrcipmapCantList[] = {
  152. INDEX_OPT_PNAT, NO_EQUIVALENT };
  153. #define SRCIPMAP_FLAGS (OPTST_DISABLED \
  154. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  155. /*
  156. * Dstipmap option description with
  157. * "Must also have options" and "Incompatible options":
  158. */
  159. tSCC zDstipmapText[] =
  160. "Rewrite destination IP addresses using pseudo-NAT";
  161. tSCC zDstipmap_NAME[] = "DSTIPMAP";
  162. tSCC zDstipmap_Name[] = "dstipmap";
  163. static const int
  164. aDstipmapCantList[] = {
  165. INDEX_OPT_PNAT, NO_EQUIVALENT };
  166. #define DSTIPMAP_FLAGS (OPTST_DISABLED \
  167. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  168. /*
  169. * Endpoints option description with
  170. * "Must also have options" and "Incompatible options":
  171. */
  172. #ifdef HAVE_CACHEFILE_SUPPORT
  173. tSCC zEndpointsText[] =
  174. "Rewrite IP addresses to be between two endpoints";
  175. tSCC zEndpoints_NAME[] = "ENDPOINTS";
  176. tSCC zEndpoints_Name[] = "endpoints";
  177. static const int
  178. aEndpointsMustList[] = {
  179. INDEX_OPT_CACHEFILE, NO_EQUIVALENT };
  180. #define ENDPOINTS_FLAGS (OPTST_DISABLED \
  181. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  182. #else /* disable Endpoints */
  183. #define VALUE_OPT_ENDPOINTS NO_EQUIVALENT
  184. #define ENDPOINTS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  185. #define aEndpointsMustList NULL
  186. #define zEndpointsText NULL
  187. #define zEndpoints_NAME NULL
  188. #define zEndpoints_Name NULL
  189. #endif /* HAVE_CACHEFILE_SUPPORT */
  190. /*
  191. * Skipbroadcast option description:
  192. */
  193. tSCC zSkipbroadcastText[] =
  194. "Skip rewriting broadcast/multicast IP's";
  195. tSCC zSkipbroadcast_NAME[] = "SKIPBROADCAST";
  196. tSCC zSkipbroadcast_Name[] = "skipbroadcast";
  197. #define SKIPBROADCAST_FLAGS (OPTST_DISABLED)
  198. /*
  199. * Fixcsum option description:
  200. */
  201. tSCC zFixcsumText[] =
  202. "Force recalculation of IP/TCP/UDP checksums";
  203. tSCC zFixcsum_NAME[] = "FIXCSUM";
  204. tSCC zFixcsum_Name[] = "fixcsum";
  205. #define FIXCSUM_FLAGS (OPTST_DISABLED)
  206. /*
  207. * Mtu option description:
  208. */
  209. tSCC zMtuText[] =
  210. "Override default MTU length (1500 bytes)";
  211. tSCC zMtu_NAME[] = "MTU";
  212. tSCC zMtu_Name[] = "mtu";
  213. #define MTU_FLAGS (OPTST_DISABLED \
  214. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  215. /*
  216. * Efcs option description:
  217. */
  218. tSCC zEfcsText[] =
  219. "Remove Ethernet checksums (FCS) from end of frames";
  220. tSCC zEfcs_NAME[] = "EFCS";
  221. tSCC zEfcs_Name[] = "efcs";
  222. #define EFCS_FLAGS (OPTST_DISABLED)
  223. /*
  224. * Ttl option description:
  225. */
  226. tSCC zTtlText[] =
  227. "Modify the IPv4 TTL";
  228. tSCC zTtl_NAME[] = "TTL";
  229. tSCC zTtl_Name[] = "ttl";
  230. #define TTL_FLAGS (OPTST_DISABLED \
  231. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  232. /*
  233. * Fixlen option description:
  234. */
  235. tSCC zFixlenText[] =
  236. "Pad or truncate packet data to match header length";
  237. tSCC zFixlen_NAME[] = "FIXLEN";
  238. tSCC zFixlen_Name[] = "fixlen";
  239. #define FIXLEN_FLAGS (OPTST_DISABLED \
  240. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  241. /*
  242. * Skipl2broadcast option description:
  243. */
  244. tSCC zSkipl2broadcastText[] =
  245. "Skip rewriting broadcast/multicast Layer 2 addresses";
  246. tSCC zSkipl2broadcast_NAME[] = "SKIPL2BROADCAST";
  247. tSCC zSkipl2broadcast_Name[] = "skipl2broadcast";
  248. #define SKIPL2BROADCAST_FLAGS (OPTST_DISABLED)
  249. /*
  250. * Dlt option description:
  251. */
  252. tSCC zDltText[] =
  253. "Override output DLT encapsulation";
  254. tSCC zDlt_NAME[] = "DLT";
  255. tSCC zDlt_Name[] = "dlt";
  256. #define DLT_FLAGS (OPTST_DISABLED \
  257. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  258. /*
  259. * Enet_Dmac option description:
  260. */
  261. tSCC zEnet_DmacText[] =
  262. "Override destination ethernet MAC addresses";
  263. tSCC zEnet_Dmac_NAME[] = "ENET_DMAC";
  264. tSCC zEnet_Dmac_Name[] = "enet-dmac";
  265. #define ENET_DMAC_FLAGS (OPTST_DISABLED \
  266. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  267. /*
  268. * Enet_Smac option description:
  269. */
  270. tSCC zEnet_SmacText[] =
  271. "Override source ethernet MAC addresses";
  272. tSCC zEnet_Smac_NAME[] = "ENET_SMAC";
  273. tSCC zEnet_Smac_Name[] = "enet-smac";
  274. #define ENET_SMAC_FLAGS (OPTST_DISABLED \
  275. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  276. /*
  277. * Enet_Vlan option description:
  278. */
  279. tSCC zEnet_VlanText[] =
  280. "Specify ethernet 802.1q VLAN tag mode";
  281. tSCC zEnet_Vlan_NAME[] = "ENET_VLAN";
  282. tSCC zEnet_Vlan_Name[] = "enet-vlan";
  283. #define ENET_VLAN_FLAGS (OPTST_DISABLED \
  284. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  285. /*
  286. * Enet_Vlan_Tag option description with
  287. * "Must also have options" and "Incompatible options":
  288. */
  289. tSCC zEnet_Vlan_TagText[] =
  290. "Specify the new ethernet 802.1q VLAN tag value";
  291. tSCC zEnet_Vlan_Tag_NAME[] = "ENET_VLAN_TAG";
  292. tSCC zEnet_Vlan_Tag_Name[] = "enet-vlan-tag";
  293. static const int
  294. aEnet_Vlan_TagMustList[] = {
  295. INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
  296. #define ENET_VLAN_TAG_FLAGS (OPTST_DISABLED \
  297. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  298. /*
  299. * Enet_Vlan_Cfi option description with
  300. * "Must also have options" and "Incompatible options":
  301. */
  302. tSCC zEnet_Vlan_CfiText[] =
  303. "Specify the ethernet 802.1q VLAN CFI value";
  304. tSCC zEnet_Vlan_Cfi_NAME[] = "ENET_VLAN_CFI";
  305. tSCC zEnet_Vlan_Cfi_Name[] = "enet-vlan-cfi";
  306. static const int
  307. aEnet_Vlan_CfiMustList[] = {
  308. INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
  309. #define ENET_VLAN_CFI_FLAGS (OPTST_DISABLED \
  310. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  311. /*
  312. * Enet_Vlan_Pri option description with
  313. * "Must also have options" and "Incompatible options":
  314. */
  315. tSCC zEnet_Vlan_PriText[] =
  316. "Specify the ethernet 802.1q VLAN priority";
  317. tSCC zEnet_Vlan_Pri_NAME[] = "ENET_VLAN_PRI";
  318. tSCC zEnet_Vlan_Pri_Name[] = "enet-vlan-pri";
  319. static const int
  320. aEnet_Vlan_PriMustList[] = {
  321. INDEX_OPT_ENET_VLAN, NO_EQUIVALENT };
  322. #define ENET_VLAN_PRI_FLAGS (OPTST_DISABLED \
  323. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  324. /*
  325. * Hdlc_Control option description:
  326. */
  327. tSCC zHdlc_ControlText[] =
  328. "Specify HDLC control value";
  329. tSCC zHdlc_Control_NAME[] = "HDLC_CONTROL";
  330. tSCC zHdlc_Control_Name[] = "hdlc-control";
  331. #define HDLC_CONTROL_FLAGS (OPTST_DISABLED \
  332. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  333. /*
  334. * Hdlc_Address option description:
  335. */
  336. tSCC zHdlc_AddressText[] =
  337. "Specify HDLC address";
  338. tSCC zHdlc_Address_NAME[] = "HDLC_ADDRESS";
  339. tSCC zHdlc_Address_Name[] = "hdlc-address";
  340. #define HDLC_ADDRESS_FLAGS (OPTST_DISABLED \
  341. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  342. /*
  343. * User_Dlt option description:
  344. */
  345. tSCC zUser_DltText[] =
  346. "Set output file DLT type";
  347. tSCC zUser_Dlt_NAME[] = "USER_DLT";
  348. tSCC zUser_Dlt_Name[] = "user-dlt";
  349. #define USER_DLT_FLAGS (OPTST_DISABLED \
  350. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  351. /*
  352. * User_Dlink option description:
  353. */
  354. tSCC zUser_DlinkText[] =
  355. "Rewrite Data-Link layer with user specified data";
  356. tSCC zUser_Dlink_NAME[] = "USER_DLINK";
  357. tSCC zUser_Dlink_Name[] = "user-dlink";
  358. #define USER_DLINK_FLAGS (OPTST_DISABLED | OPTST_STACKED \
  359. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  360. /*
  361. * Dbug option description:
  362. */
  363. #ifdef DEBUG
  364. tSCC zDbugText[] =
  365. "Enable debugging output";
  366. tSCC zDbug_NAME[] = "DBUG";
  367. tSCC zDbug_Name[] = "dbug";
  368. #define zDbugDefaultArg ((char const*)0)
  369. #define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \
  370. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  371. #else /* disable Dbug */
  372. #define VALUE_OPT_DBUG NO_EQUIVALENT
  373. #define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  374. #define zDbugDefaultArg NULL
  375. #define zDbugText NULL
  376. #define zDbug_NAME NULL
  377. #define zDbug_Name NULL
  378. #endif /* DEBUG */
  379. /*
  380. * Intf1 option description:
  381. */
  382. tSCC zIntf1Text[] =
  383. "Primary interface (listen in uni-directional mode)";
  384. tSCC zIntf1_NAME[] = "INTF1";
  385. tSCC zIntf1_Name[] = "intf1";
  386. #define INTF1_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \
  387. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  388. /*
  389. * Intf2 option description:
  390. */
  391. tSCC zIntf2Text[] =
  392. "Secondary interface (send in uni-directional mode)";
  393. tSCC zIntf2_NAME[] = "INTF2";
  394. tSCC zIntf2_Name[] = "intf2";
  395. #define INTF2_FLAGS (OPTST_DISABLED \
  396. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  397. /*
  398. * Unidir option description:
  399. */
  400. tSCC zUnidirText[] =
  401. "Send and receive in only one direction";
  402. tSCC zUnidir_NAME[] = "UNIDIR";
  403. tSCC zUnidir_Name[] = "unidir";
  404. #define UNIDIR_FLAGS (OPTST_DISABLED)
  405. /*
  406. * Limit option description:
  407. */
  408. tSCC zLimitText[] =
  409. "Limit the number of packets to send";
  410. tSCC zLimit_NAME[] = "LIMIT";
  411. tSCC zLimit_Name[] = "limit";
  412. #define zLimitDefaultArg ((char const*)-1)
  413. #define LIMIT_FLAGS (OPTST_DISABLED \
  414. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  415. /*
  416. * Include option description with
  417. * "Must also have options" and "Incompatible options":
  418. */
  419. tSCC zIncludeText[] =
  420. "Include only packets matching rule";
  421. tSCC zInclude_NAME[] = "INCLUDE";
  422. tSCC zInclude_Name[] = "include";
  423. static const int
  424. aIncludeCantList[] = {
  425. INDEX_OPT_EXCLUDE, NO_EQUIVALENT };
  426. #define INCLUDE_FLAGS (OPTST_DISABLED \
  427. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  428. /*
  429. * Exclude option description with
  430. * "Must also have options" and "Incompatible options":
  431. */
  432. tSCC zExcludeText[] =
  433. "Exclude any packet matching this rule";
  434. tSCC zExclude_NAME[] = "EXCLUDE";
  435. tSCC zExclude_Name[] = "exclude";
  436. static const int
  437. aExcludeCantList[] = {
  438. INDEX_OPT_INCLUDE, NO_EQUIVALENT };
  439. #define EXCLUDE_FLAGS (OPTST_DISABLED \
  440. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  441. /*
  442. * Pid option description:
  443. */
  444. tSCC zPidText[] =
  445. "Print the PID of tcpbridge at startup";
  446. tSCC zPid_NAME[] = "PID";
  447. tSCC zPid_Name[] = "pid";
  448. #define PID_FLAGS (OPTST_DISABLED)
  449. /*
  450. * Verbose option description:
  451. */
  452. #ifdef ENABLE_VERBOSE
  453. tSCC zVerboseText[] =
  454. "Print decoded packets via tcpdump to STDOUT";
  455. tSCC zVerbose_NAME[] = "VERBOSE";
  456. tSCC zVerbose_Name[] = "verbose";
  457. #define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM)
  458. #else /* disable Verbose */
  459. #define VALUE_OPT_VERBOSE NO_EQUIVALENT
  460. #define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  461. #define zVerboseText NULL
  462. #define zVerbose_NAME NULL
  463. #define zVerbose_Name NULL
  464. #endif /* ENABLE_VERBOSE */
  465. /*
  466. * Decode option description with
  467. * "Must also have options" and "Incompatible options":
  468. */
  469. #ifdef ENABLE_VERBOSE
  470. tSCC zDecodeText[] =
  471. "Arguments passed to tcpdump decoder";
  472. tSCC zDecode_NAME[] = "DECODE";
  473. tSCC zDecode_Name[] = "decode";
  474. static const int
  475. aDecodeMustList[] = {
  476. INDEX_OPT_VERBOSE, NO_EQUIVALENT };
  477. #define DECODE_FLAGS (OPTST_DISABLED \
  478. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  479. #else /* disable Decode */
  480. #define VALUE_OPT_DECODE NO_EQUIVALENT
  481. #define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  482. #define aDecodeMustList NULL
  483. #define zDecodeText NULL
  484. #define zDecode_NAME NULL
  485. #define zDecode_Name NULL
  486. #endif /* ENABLE_VERBOSE */
  487. /*
  488. * Version option description:
  489. */
  490. tSCC zVersionText[] =
  491. "Print version information";
  492. tSCC zVersion_NAME[] = "VERSION";
  493. tSCC zVersion_Name[] = "version";
  494. #define VERSION_FLAGS (OPTST_DISABLED)
  495. /*
  496. * Less_Help option description:
  497. */
  498. tSCC zLess_HelpText[] =
  499. "Display less usage information and exit";
  500. tSCC zLess_Help_NAME[] = "LESS_HELP";
  501. tSCC zLess_Help_Name[] = "less-help";
  502. #define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM)
  503. /*
  504. * Help/More_Help option descriptions:
  505. */
  506. tSCC zHelpText[] = "Display usage information and exit";
  507. tSCC zHelp_Name[] = "help";
  508. tSCC zMore_HelpText[] = "Extended usage information passed thru pager";
  509. tSCC zMore_Help_Name[] = "more-help";
  510. /*
  511. * Save/Load_Opts option description:
  512. */
  513. tSCC zSave_OptsText[] = "Save the option state to a config file";
  514. tSCC zSave_Opts_Name[] = "save-opts";
  515. tSCC zLoad_OptsText[] = "Load options from a config file";
  516. tSCC zLoad_Opts_NAME[] = "LOAD_OPTS";
  517. tSCC zNotLoad_Opts_Name[] = "no-load-opts";
  518. tSCC zNotLoad_Opts_Pfx[] = "no";
  519. #define zLoad_Opts_Name (zNotLoad_Opts_Name + 3)
  520. /*
  521. * Declare option callback procedures
  522. */
  523. #ifdef DEBUG
  524. static tOptProc doOptDbug;
  525. #else /* not DEBUG */
  526. # define doOptDbug NULL
  527. #endif /* def/not DEBUG */
  528. extern tOptProc
  529. optionNumericVal, optionPagedUsage, optionStackArg;
  530. static tOptProc
  531. doOptEnet_Vlan_Cfi, doOptEnet_Vlan_Pri, doOptEnet_Vlan_Tag,
  532. doOptExclude, doOptInclude, doOptLess_Help,
  533. doOptLimit, doOptMtu, doOptPid,
  534. doOptVersion, doUsageOpt;
  535. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  536. *
  537. * Define the Tcpbridge Option Descriptions.
  538. */
  539. static tOptDesc optDesc[ OPTION_CT ] = {
  540. { /* entry idx, value */ 0, 0,
  541. /* equiv idx, value */ 0, 0,
  542. /* equivalenced to */ NO_EQUIVALENT,
  543. /* min, max, act ct */ 0, 0, 0,
  544. /* opt state flags */ TCPEDIT_FLAGS, 0,
  545. /* last opt argumnt */ { NULL },
  546. /* arg list/cookie */ NULL,
  547. /* must/cannot opts */ NULL, NULL,
  548. /* option proc */ NULL,
  549. /* desc, NAME, name */ zTcpeditText, NULL, NULL,
  550. /* disablement strs */ NULL, NULL },
  551. { /* entry idx, value */ 1, VALUE_OPT_PORTMAP,
  552. /* equiv idx, value */ 1, VALUE_OPT_PORTMAP,
  553. /* equivalenced to */ NO_EQUIVALENT,
  554. /* min, max, act ct */ 0, 1, 0,
  555. /* opt state flags */ PORTMAP_FLAGS, 0,
  556. /* last opt argumnt */ { NULL },
  557. /* arg list/cookie */ NULL,
  558. /* must/cannot opts */ NULL, NULL,
  559. /* option proc */ NULL,
  560. /* desc, NAME, name */ zPortmapText, zPortmap_NAME, zPortmap_Name,
  561. /* disablement strs */ NULL, NULL },
  562. { /* entry idx, value */ 2, VALUE_OPT_SEED,
  563. /* equiv idx, value */ 2, VALUE_OPT_SEED,
  564. /* equivalenced to */ NO_EQUIVALENT,
  565. /* min, max, act ct */ 0, 1, 0,
  566. /* opt state flags */ SEED_FLAGS, 0,
  567. /* last opt argumnt */ { NULL },
  568. /* arg list/cookie */ NULL,
  569. /* must/cannot opts */ NULL, NULL,
  570. /* option proc */ optionNumericVal,
  571. /* desc, NAME, name */ zSeedText, zSeed_NAME, zSeed_Name,
  572. /* disablement strs */ NULL, NULL },
  573. { /* entry idx, value */ 3, VALUE_OPT_PNAT,
  574. /* equiv idx, value */ 3, VALUE_OPT_PNAT,
  575. /* equivalenced to */ NO_EQUIVALENT,
  576. /* min, max, act ct */ 0, 2, 0,
  577. /* opt state flags */ PNAT_FLAGS, 0,
  578. /* last opt argumnt */ { NULL },
  579. /* arg list/cookie */ NULL,
  580. /* must/cannot opts */ NULL, aPnatCantList,
  581. /* option proc */ optionStackArg,
  582. /* desc, NAME, name */ zPnatText, zPnat_NAME, zPnat_Name,
  583. /* disablement strs */ NULL, NULL },
  584. { /* entry idx, value */ 4, VALUE_OPT_SRCIPMAP,
  585. /* equiv idx, value */ 4, VALUE_OPT_SRCIPMAP,
  586. /* equivalenced to */ NO_EQUIVALENT,
  587. /* min, max, act ct */ 0, 1, 0,
  588. /* opt state flags */ SRCIPMAP_FLAGS, 0,
  589. /* last opt argumnt */ { NULL },
  590. /* arg list/cookie */ NULL,
  591. /* must/cannot opts */ NULL, aSrcipmapCantList,
  592. /* option proc */ NULL,
  593. /* desc, NAME, name */ zSrcipmapText, zSrcipmap_NAME, zSrcipmap_Name,
  594. /* disablement strs */ NULL, NULL },
  595. { /* entry idx, value */ 5, VALUE_OPT_DSTIPMAP,
  596. /* equiv idx, value */ 5, VALUE_OPT_DSTIPMAP,
  597. /* equivalenced to */ NO_EQUIVALENT,
  598. /* min, max, act ct */ 0, 1, 0,
  599. /* opt state flags */ DSTIPMAP_FLAGS, 0,
  600. /* last opt argumnt */ { NULL },
  601. /* arg list/cookie */ NULL,
  602. /* must/cannot opts */ NULL, aDstipmapCantList,
  603. /* option proc */ NULL,
  604. /* desc, NAME, name */ zDstipmapText, zDstipmap_NAME, zDstipmap_Name,
  605. /* disablement strs */ NULL, NULL },
  606. { /* entry idx, value */ 6, VALUE_OPT_ENDPOINTS,
  607. /* equiv idx, value */ 6, VALUE_OPT_ENDPOINTS,
  608. /* equivalenced to */ NO_EQUIVALENT,
  609. /* min, max, act ct */ 0, 1, 0,
  610. /* opt state flags */ ENDPOINTS_FLAGS, 0,
  611. /* last opt argumnt */ { NULL },
  612. /* arg list/cookie */ NULL,
  613. /* must/cannot opts */ aEndpointsMustList, NULL,
  614. /* option proc */ NULL,
  615. /* desc, NAME, name */ zEndpointsText, zEndpoints_NAME, zEndpoints_Name,
  616. /* disablement strs */ NULL, NULL },
  617. { /* entry idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
  618. /* equiv idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
  619. /* equivalenced to */ NO_EQUIVALENT,
  620. /* min, max, act ct */ 0, 1, 0,
  621. /* opt state flags */ SKIPBROADCAST_FLAGS, 0,
  622. /* last opt argumnt */ { NULL },
  623. /* arg list/cookie */ NULL,
  624. /* must/cannot opts */ NULL, NULL,
  625. /* option proc */ NULL,
  626. /* desc, NAME, name */ zSkipbroadcastText, zSkipbroadcast_NAME, zSkipbroadcast_Name,
  627. /* disablement strs */ NULL, NULL },
  628. { /* entry idx, value */ 8, VALUE_OPT_FIXCSUM,
  629. /* equiv idx, value */ 8, VALUE_OPT_FIXCSUM,
  630. /* equivalenced to */ NO_EQUIVALENT,
  631. /* min, max, act ct */ 0, 1, 0,
  632. /* opt state flags */ FIXCSUM_FLAGS, 0,
  633. /* last opt argumnt */ { NULL },
  634. /* arg list/cookie */ NULL,
  635. /* must/cannot opts */ NULL, NULL,
  636. /* option proc */ NULL,
  637. /* desc, NAME, name */ zFixcsumText, zFixcsum_NAME, zFixcsum_Name,
  638. /* disablement strs */ NULL, NULL },
  639. { /* entry idx, value */ 9, VALUE_OPT_MTU,
  640. /* equiv idx, value */ 9, VALUE_OPT_MTU,
  641. /* equivalenced to */ NO_EQUIVALENT,
  642. /* min, max, act ct */ 0, 1, 0,
  643. /* opt state flags */ MTU_FLAGS, 0,
  644. /* last opt argumnt */ { NULL },
  645. /* arg list/cookie */ NULL,
  646. /* must/cannot opts */ NULL, NULL,
  647. /* option proc */ doOptMtu,
  648. /* desc, NAME, name */ zMtuText, zMtu_NAME, zMtu_Name,
  649. /* disablement strs */ NULL, NULL },
  650. { /* entry idx, value */ 10, VALUE_OPT_EFCS,
  651. /* equiv idx, value */ 10, VALUE_OPT_EFCS,
  652. /* equivalenced to */ NO_EQUIVALENT,
  653. /* min, max, act ct */ 0, 1, 0,
  654. /* opt state flags */ EFCS_FLAGS, 0,
  655. /* last opt argumnt */ { NULL },
  656. /* arg list/cookie */ NULL,
  657. /* must/cannot opts */ NULL, NULL,
  658. /* option proc */ NULL,
  659. /* desc, NAME, name */ zEfcsText, zEfcs_NAME, zEfcs_Name,
  660. /* disablement strs */ NULL, NULL },
  661. { /* entry idx, value */ 11, VALUE_OPT_TTL,
  662. /* equiv idx, value */ 11, VALUE_OPT_TTL,
  663. /* equivalenced to */ NO_EQUIVALENT,
  664. /* min, max, act ct */ 0, 1, 0,
  665. /* opt state flags */ TTL_FLAGS, 0,
  666. /* last opt argumnt */ { NULL },
  667. /* arg list/cookie */ NULL,
  668. /* must/cannot opts */ NULL, NULL,
  669. /* option proc */ NULL,
  670. /* desc, NAME, name */ zTtlText, zTtl_NAME, zTtl_Name,
  671. /* disablement strs */ NULL, NULL },
  672. { /* entry idx, value */ 12, VALUE_OPT_FIXLEN,
  673. /* equiv idx, value */ 12, VALUE_OPT_FIXLEN,
  674. /* equivalenced to */ NO_EQUIVALENT,
  675. /* min, max, act ct */ 0, 1, 0,
  676. /* opt state flags */ FIXLEN_FLAGS, 0,
  677. /* last opt argumnt */ { NULL },
  678. /* arg list/cookie */ NULL,
  679. /* must/cannot opts */ NULL, NULL,
  680. /* option proc */ NULL,
  681. /* desc, NAME, name */ zFixlenText, zFixlen_NAME, zFixlen_Name,
  682. /* disablement strs */ NULL, NULL },
  683. { /* entry idx, value */ 13, VALUE_OPT_SKIPL2BROADCAST,
  684. /* equiv idx, value */ 13, VALUE_OPT_SKIPL2BROADCAST,
  685. /* equivalenced to */ NO_EQUIVALENT,
  686. /* min, max, act ct */ 0, 1, 0,
  687. /* opt state flags */ SKIPL2BROADCAST_FLAGS, 0,
  688. /* last opt argumnt */ { NULL },
  689. /* arg list/cookie */ NULL,
  690. /* must/cannot opts */ NULL, NULL,
  691. /* option proc */ NULL,
  692. /* desc, NAME, name */ zSkipl2broadcastText, zSkipl2broadcast_NAME, zSkipl2broadcast_Name,
  693. /* disablement strs */ NULL, NULL },
  694. { /* entry idx, value */ 14, VALUE_OPT_DLT,
  695. /* equiv idx, value */ 14, VALUE_OPT_DLT,
  696. /* equivalenced to */ NO_EQUIVALENT,
  697. /* min, max, act ct */ 0, 1, 0,
  698. /* opt state flags */ DLT_FLAGS, 0,
  699. /* last opt argumnt */ { NULL },
  700. /* arg list/cookie */ NULL,
  701. /* must/cannot opts */ NULL, NULL,
  702. /* option proc */ NULL,
  703. /* desc, NAME, name */ zDltText, zDlt_NAME, zDlt_Name,
  704. /* disablement strs */ NULL, NULL },
  705. { /* entry idx, value */ 15, VALUE_OPT_ENET_DMAC,
  706. /* equiv idx, value */ 15, VALUE_OPT_ENET_DMAC,
  707. /* equivalenced to */ NO_EQUIVALENT,
  708. /* min, max, act ct */ 0, 1, 0,
  709. /* opt state flags */ ENET_DMAC_FLAGS, 0,
  710. /* last opt argumnt */ { NULL },
  711. /* arg list/cookie */ NULL,
  712. /* must/cannot opts */ NULL, NULL,
  713. /* option proc */ NULL,
  714. /* desc, NAME, name */ zEnet_DmacText, zEnet_Dmac_NAME, zEnet_Dmac_Name,
  715. /* disablement strs */ NULL, NULL },
  716. { /* entry idx, value */ 16, VALUE_OPT_ENET_SMAC,
  717. /* equiv idx, value */ 16, VALUE_OPT_ENET_SMAC,
  718. /* equivalenced to */ NO_EQUIVALENT,
  719. /* min, max, act ct */ 0, 1, 0,
  720. /* opt state flags */ ENET_SMAC_FLAGS, 0,
  721. /* last opt argumnt */ { NULL },
  722. /* arg list/cookie */ NULL,
  723. /* must/cannot opts */ NULL, NULL,
  724. /* option proc */ NULL,
  725. /* desc, NAME, name */ zEnet_SmacText, zEnet_Smac_NAME, zEnet_Smac_Name,
  726. /* disablement strs */ NULL, NULL },
  727. { /* entry idx, value */ 17, VALUE_OPT_ENET_VLAN,
  728. /* equiv idx, value */ 17, VALUE_OPT_ENET_VLAN,
  729. /* equivalenced to */ NO_EQUIVALENT,
  730. /* min, max, act ct */ 0, 1, 0,
  731. /* opt state flags */ ENET_VLAN_FLAGS, 0,
  732. /* last opt argumnt */ { NULL },
  733. /* arg list/cookie */ NULL,
  734. /* must/cannot opts */ NULL, NULL,
  735. /* option proc */ NULL,
  736. /* desc, NAME, name */ zEnet_VlanText, zEnet_Vlan_NAME, zEnet_Vlan_Name,
  737. /* disablement strs */ NULL, NULL },
  738. { /* entry idx, value */ 18, VALUE_OPT_ENET_VLAN_TAG,
  739. /* equiv idx, value */ 18, VALUE_OPT_ENET_VLAN_TAG,
  740. /* equivalenced to */ NO_EQUIVALENT,
  741. /* min, max, act ct */ 0, 1, 0,
  742. /* opt state flags */ ENET_VLAN_TAG_FLAGS, 0,
  743. /* last opt argumnt */ { NULL },
  744. /* arg list/cookie */ NULL,
  745. /* must/cannot opts */ aEnet_Vlan_TagMustList, NULL,
  746. /* option proc */ doOptEnet_Vlan_Tag,
  747. /* desc, NAME, name */ zEnet_Vlan_TagText, zEnet_Vlan_Tag_NAME, zEnet_Vlan_Tag_Name,
  748. /* disablement strs */ NULL, NULL },
  749. { /* entry idx, value */ 19, VALUE_OPT_ENET_VLAN_CFI,
  750. /* equiv idx, value */ 19, VALUE_OPT_ENET_VLAN_CFI,
  751. /* equivalenced to */ NO_EQUIVALENT,
  752. /* min, max, act ct */ 0, 1, 0,
  753. /* opt state flags */ ENET_VLAN_CFI_FLAGS, 0,
  754. /* last opt argumnt */ { NULL },
  755. /* arg list/cookie */ NULL,
  756. /* must/cannot opts */ aEnet_Vlan_CfiMustList, NULL,
  757. /* option proc */ doOptEnet_Vlan_Cfi,
  758. /* desc, NAME, name */ zEnet_Vlan_CfiText, zEnet_Vlan_Cfi_NAME, zEnet_Vlan_Cfi_Name,
  759. /* disablement strs */ NULL, NULL },
  760. { /* entry idx, value */ 20, VALUE_OPT_ENET_VLAN_PRI,
  761. /* equiv idx, value */ 20, VALUE_OPT_ENET_VLAN_PRI,
  762. /* equivalenced to */ NO_EQUIVALENT,
  763. /* min, max, act ct */ 0, 1, 0,
  764. /* opt state flags */ ENET_VLAN_PRI_FLAGS, 0,
  765. /* last opt argumnt */ { NULL },
  766. /* arg list/cookie */ NULL,
  767. /* must/cannot opts */ aEnet_Vlan_PriMustList, NULL,
  768. /* option proc */ doOptEnet_Vlan_Pri,
  769. /* desc, NAME, name */ zEnet_Vlan_PriText, zEnet_Vlan_Pri_NAME, zEnet_Vlan_Pri_Name,
  770. /* disablement strs */ NULL, NULL },
  771. { /* entry idx, value */ 21, VALUE_OPT_HDLC_CONTROL,
  772. /* equiv idx, value */ 21, VALUE_OPT_HDLC_CONTROL,
  773. /* equivalenced to */ NO_EQUIVALENT,
  774. /* min, max, act ct */ 0, 1, 0,
  775. /* opt state flags */ HDLC_CONTROL_FLAGS, 0,
  776. /* last opt argumnt */ { NULL },
  777. /* arg list/cookie */ NULL,
  778. /* must/cannot opts */ NULL, NULL,
  779. /* option proc */ optionNumericVal,
  780. /* desc, NAME, name */ zHdlc_ControlText, zHdlc_Control_NAME, zHdlc_Control_Name,
  781. /* disablement strs */ NULL, NULL },
  782. { /* entry idx, value */ 22, VALUE_OPT_HDLC_ADDRESS,
  783. /* equiv idx, value */ 22, VALUE_OPT_HDLC_ADDRESS,
  784. /* equivalenced to */ NO_EQUIVALENT,
  785. /* min, max, act ct */ 0, 1, 0,
  786. /* opt state flags */ HDLC_ADDRESS_FLAGS, 0,
  787. /* last opt argumnt */ { NULL },
  788. /* arg list/cookie */ NULL,
  789. /* must/cannot opts */ NULL, NULL,
  790. /* option proc */ optionNumericVal,
  791. /* desc, NAME, name */ zHdlc_AddressText, zHdlc_Address_NAME, zHdlc_Address_Name,
  792. /* disablement strs */ NULL, NULL },
  793. { /* entry idx, value */ 23, VALUE_OPT_USER_DLT,
  794. /* equiv idx, value */ 23, VALUE_OPT_USER_DLT,
  795. /* equivalenced to */ NO_EQUIVALENT,
  796. /* min, max, act ct */ 0, 1, 0,
  797. /* opt state flags */ USER_DLT_FLAGS, 0,
  798. /* last opt argumnt */ { NULL },
  799. /* arg list/cookie */ NULL,
  800. /* must/cannot opts */ NULL, NULL,
  801. /* option proc */ optionNumericVal,
  802. /* desc, NAME, name */ zUser_DltText, zUser_Dlt_NAME, zUser_Dlt_Name,
  803. /* disablement strs */ NULL, NULL },
  804. { /* entry idx, value */ 24, VALUE_OPT_USER_DLINK,
  805. /* equiv idx, value */ 24, VALUE_OPT_USER_DLINK,
  806. /* equivalenced to */ NO_EQUIVALENT,
  807. /* min, max, act ct */ 0, 2, 0,
  808. /* opt state flags */ USER_DLINK_FLAGS, 0,
  809. /* last opt argumnt */ { NULL },
  810. /* arg list/cookie */ NULL,
  811. /* must/cannot opts */ NULL, NULL,
  812. /* option proc */ optionStackArg,
  813. /* desc, NAME, name */ zUser_DlinkText, zUser_Dlink_NAME, zUser_Dlink_Name,
  814. /* disablement strs */ NULL, NULL },
  815. { /* entry idx, value */ 25, VALUE_OPT_DBUG,
  816. /* equiv idx, value */ 25, VALUE_OPT_DBUG,
  817. /* equivalenced to */ NO_EQUIVALENT,
  818. /* min, max, act ct */ 0, 1, 0,
  819. /* opt state flags */ DBUG_FLAGS, 0,
  820. /* last opt argumnt */ { zDbugDefaultArg },
  821. /* arg list/cookie */ NULL,
  822. /* must/cannot opts */ NULL, NULL,
  823. /* option proc */ doOptDbug,
  824. /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name,
  825. /* disablement strs */ NULL, NULL },
  826. { /* entry idx, value */ 26, VALUE_OPT_INTF1,
  827. /* equiv idx, value */ 26, VALUE_OPT_INTF1,
  828. /* equivalenced to */ NO_EQUIVALENT,
  829. /* min, max, act ct */ 1, 1, 0,
  830. /* opt state flags */ INTF1_FLAGS, 0,
  831. /* last opt argumnt */ { NULL },
  832. /* arg list/cookie */ NULL,
  833. /* must/cannot opts */ NULL, NULL,
  834. /* option proc */ NULL,
  835. /* desc, NAME, name */ zIntf1Text, zIntf1_NAME, zIntf1_Name,
  836. /* disablement strs */ NULL, NULL },
  837. { /* entry idx, value */ 27, VALUE_OPT_INTF2,
  838. /* equiv idx, value */ 27, VALUE_OPT_INTF2,
  839. /* equivalenced to */ NO_EQUIVALENT,
  840. /* min, max, act ct */ 0, 1, 0,
  841. /* opt state flags */ INTF2_FLAGS, 0,
  842. /* last opt argumnt */ { NULL },
  843. /* arg list/cookie */ NULL,
  844. /* must/cannot opts */ NULL, NULL,
  845. /* option proc */ NULL,
  846. /* desc, NAME, name */ zIntf2Text, zIntf2_NAME, zIntf2_Name,
  847. /* disablement strs */ NULL, NULL },
  848. { /* entry idx, value */ 28, VALUE_OPT_UNIDIR,
  849. /* equiv idx, value */ 28, VALUE_OPT_UNIDIR,
  850. /* equivalenced to */ NO_EQUIVALENT,
  851. /* min, max, act ct */ 0, 1, 0,
  852. /* opt state flags */ UNIDIR_FLAGS, 0,
  853. /* last opt argumnt */ { NULL },
  854. /* arg list/cookie */ NULL,
  855. /* must/cannot opts */ NULL, NULL,
  856. /* option proc */ NULL,
  857. /* desc, NAME, name */ zUnidirText, zUnidir_NAME, zUnidir_Name,
  858. /* disablement strs */ NULL, NULL },
  859. { /* entry idx, value */ 29, VALUE_OPT_LIMIT,
  860. /* equiv idx, value */ 29, VALUE_OPT_LIMIT,
  861. /* equivalenced to */ NO_EQUIVALENT,
  862. /* min, max, act ct */ 0, 1, 0,
  863. /* opt state flags */ LIMIT_FLAGS, 0,
  864. /* last opt argumnt */ { zLimitDefaultArg },
  865. /* arg list/cookie */ NULL,
  866. /* must/cannot opts */ NULL, NULL,
  867. /* option proc */ doOptLimit,
  868. /* desc, NAME, name */ zLimitText, zLimit_NAME, zLimit_Name,
  869. /* disablement strs */ NULL, NULL },
  870. { /* entry idx, value */ 30, VALUE_OPT_INCLUDE,
  871. /* equiv idx, value */ 30, VALUE_OPT_INCLUDE,
  872. /* equivalenced to */ NO_EQUIVALENT,
  873. /* min, max, act ct */ 0, 1, 0,
  874. /* opt state flags */ INCLUDE_FLAGS, 0,
  875. /* last opt argumnt */ { NULL },
  876. /* arg list/cookie */ NULL,
  877. /* must/cannot opts */ NULL, aIncludeCantList,
  878. /* option proc */ doOptInclude,
  879. /* desc, NAME, name */ zIncludeText, zInclude_NAME, zInclude_Name,
  880. /* disablement strs */ NULL, NULL },
  881. { /* entry idx, value */ 31, VALUE_OPT_EXCLUDE,
  882. /* equiv idx, value */ 31, VALUE_OPT_EXCLUDE,
  883. /* equivalenced to */ NO_EQUIVALENT,
  884. /* min, max, act ct */ 0, 1, 0,
  885. /* opt state flags */ EXCLUDE_FLAGS, 0,
  886. /* last opt argumnt */ { NULL },
  887. /* arg list/cookie */ NULL,
  888. /* must/cannot opts */ NULL, aExcludeCantList,
  889. /* option proc */ doOptExclude,
  890. /* desc, NAME, name */ zExcludeText, zExclude_NAME, zExclude_Name,
  891. /* disablement strs */ NULL, NULL },
  892. { /* entry idx, value */ 32, VALUE_OPT_PID,
  893. /* equiv idx, value */ 32, VALUE_OPT_PID,
  894. /* equivalenced to */ NO_EQUIVALENT,
  895. /* min, max, act ct */ 0, 1, 0,
  896. /* opt state flags */ PID_FLAGS, 0,
  897. /* last opt argumnt */ { NULL },
  898. /* arg list/cookie */ NULL,
  899. /* must/cannot opts */ NULL, NULL,
  900. /* option proc */ doOptPid,
  901. /* desc, NAME, name */ zPidText, zPid_NAME, zPid_Name,
  902. /* disablement strs */ NULL, NULL },
  903. { /* entry idx, value */ 33, VALUE_OPT_VERBOSE,
  904. /* equiv idx, value */ 33, VALUE_OPT_VERBOSE,
  905. /* equivalenced to */ NO_EQUIVALENT,
  906. /* min, max, act ct */ 0, 1, 0,
  907. /* opt state flags */ VERBOSE_FLAGS, 0,
  908. /* last opt argumnt */ { NULL },
  909. /* arg list/cookie */ NULL,
  910. /* must/cannot opts */ NULL, NULL,
  911. /* option proc */ NULL,
  912. /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name,
  913. /* disablement strs */ NULL, NULL },
  914. { /* entry idx, value */ 34, VALUE_OPT_DECODE,
  915. /* equiv idx, value */ 34, VALUE_OPT_DECODE,
  916. /* equivalenced to */ NO_EQUIVALENT,
  917. /* min, max, act ct */ 0, 1, 0,
  918. /* opt state flags */ DECODE_FLAGS, 0,
  919. /* last opt argumnt */ { NULL },
  920. /* arg list/cookie */ NULL,
  921. /* must/cannot opts */ aDecodeMustList, NULL,
  922. /* option proc */ NULL,
  923. /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name,
  924. /* disablement strs */ NULL, NULL },
  925. { /* entry idx, value */ 35, VALUE_OPT_VERSION,
  926. /* equiv idx, value */ 35, VALUE_OPT_VERSION,
  927. /* equivalenced to */ NO_EQUIVALENT,
  928. /* min, max, act ct */ 0, 1, 0,
  929. /* opt state flags */ VERSION_FLAGS, 0,
  930. /* last opt argumnt */ { NULL },
  931. /* arg list/cookie */ NULL,
  932. /* must/cannot opts */ NULL, NULL,
  933. /* option proc */ doOptVersion,
  934. /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name,
  935. /* disablement strs */ NULL, NULL },
  936. { /* entry idx, value */ 36, VALUE_OPT_LESS_HELP,
  937. /* equiv idx, value */ 36, VALUE_OPT_LESS_HELP,
  938. /* equivalenced to */ NO_EQUIVALENT,
  939. /* min, max, act ct */ 0, 1, 0,
  940. /* opt state flags */ LESS_HELP_FLAGS, 0,
  941. /* last opt argumnt */ { NULL },
  942. /* arg list/cookie */ NULL,
  943. /* must/cannot opts */ NULL, NULL,
  944. /* option proc */ doOptLess_Help,
  945. /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name,
  946. /* disablement strs */ NULL, NULL },
  947. { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
  948. /* equiv idx value */ NO_EQUIVALENT, 0,
  949. /* equivalenced to */ NO_EQUIVALENT,
  950. /* min, max, act ct */ 0, 1, 0,
  951. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  952. /* last opt argumnt */ { NULL },
  953. /* arg list/cookie */ NULL,
  954. /* must/cannot opts */ NULL, NULL,
  955. /* option proc */ doUsageOpt,
  956. /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
  957. /* disablement strs */ NULL, NULL },
  958. { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
  959. /* equiv idx value */ NO_EQUIVALENT, 0,
  960. /* equivalenced to */ NO_EQUIVALENT,
  961. /* min, max, act ct */ 0, 1, 0,
  962. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0,
  963. /* last opt argumnt */ { NULL },
  964. /* arg list/cookie */ NULL,
  965. /* must/cannot opts */ NULL, NULL,
  966. /* option proc */ optionPagedUsage,
  967. /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
  968. /* disablement strs */ NULL, NULL },
  969. { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
  970. /* equiv idx value */ NO_EQUIVALENT, 0,
  971. /* equivalenced to */ NO_EQUIVALENT,
  972. /* min, max, act ct */ 0, 1, 0,
  973. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  974. | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
  975. /* last opt argumnt */ { NULL },
  976. /* arg list/cookie */ NULL,
  977. /* must/cannot opts */ NULL, NULL,
  978. /* option proc */ NULL,
  979. /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
  980. /* disablement strs */ NULL, NULL },
  981. { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
  982. /* equiv idx value */ NO_EQUIVALENT, 0,
  983. /* equivalenced to */ NO_EQUIVALENT,
  984. /* min, max, act ct */ 0, NOLIMIT, 0,
  985. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
  986. | OPTST_DISABLE_IMM, 0,
  987. /* last opt argumnt */ { NULL },
  988. /* arg list/cookie */ NULL,
  989. /* must/cannot opts */ NULL, NULL,
  990. /* option proc */ optionLoadOpt,
  991. /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
  992. /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
  993. };
  994. tOptDesc * const tcpedit_tcpedit_optDesc_p = optDesc + 0;
  995. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  996. *
  997. * Define the Tcpbridge Option Environment
  998. */
  999. tSCC zPROGNAME[] = "TCPBRIDGE";
  1000. tSCC zUsageTitle[] =
  1001. "tcpbridge (tcpbridge) - Bridge network traffic across two interfaces\n\
  1002. USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
  1003. tSCC zRcName[] = ".tcpbridgerc";
  1004. tSCC* apzHomeList[] = {
  1005. "$$/",
  1006. NULL };
  1007. #define zBugsAddr NULL
  1008. tSCC zExplain[] = "\n\
  1009. tcpbridge is a tool for selectively briding network traffic across two interfaces\n\
  1010. and optionally modifying the packets in betweeen\n";
  1011. tSCC zDetail[] = "\n\
  1012. The basic operation of tcpbridge is to be a network bridge between two\n\
  1013. subnets. All packets received on one interface are sent via the other.\n\n\
  1014. Optionally, packets can be edited in a variety of ways according to your needs.\n\n\
  1015. For more details, please see the Tcpreplay Manual at:\n\
  1016. http://tcpreplay.synfin.net/trac/wiki/manual\n";
  1017. #define zFullVersion NULL
  1018. /* extracted from /opt/local/share/autogen/optcode.tpl near line 428 */
  1019. #if defined(ENABLE_NLS)
  1020. # define OPTPROC_BASE OPTPROC_TRANSLATE
  1021. static tOptionXlateProc translate_option_strings;
  1022. #else
  1023. # define OPTPROC_BASE OPTPROC_NONE
  1024. # define translate_option_strings NULL
  1025. #endif /* ENABLE_NLS */
  1026. #define tcpbridge_full_usage NULL
  1027. #define tcpbridge_short_usage NULL
  1028. tOptions tcpbridgeOptions = {
  1029. OPTIONS_STRUCT_VERSION,
  1030. 0, NULL, /* original argc + argv */
  1031. ( OPTPROC_BASE
  1032. + OPTPROC_ERRSTOP
  1033. + OPTPROC_SHORTOPT
  1034. + OPTPROC_LONGOPT
  1035. + OPTPROC_NO_REQ_OPT
  1036. + OPTPROC_NO_ARGS
  1037. + OPTPROC_GNUUSAGE
  1038. + OPTPROC_HAS_IMMED ),
  1039. 0, NULL, /* current option index, current option */
  1040. NULL, NULL, zPROGNAME,
  1041. zRcName, zCopyright, zCopyrightNotice,
  1042. zFullVersion, apzHomeList, zUsageTitle,
  1043. zExplain, zDetail, optDesc,
  1044. zBugsAddr, /* address to send bugs to */
  1045. NULL, NULL, /* extensions/saved state */
  1046. optionUsage, /* usage procedure */
  1047. translate_option_strings, /* translation procedure */
  1048. /*
  1049. * Indexes to special options
  1050. */
  1051. { INDEX_OPT_MORE_HELP,
  1052. INDEX_OPT_SAVE_OPTS,
  1053. NO_EQUIVALENT /* index of '-#' option */,
  1054. 9 /* index of default opt */
  1055. },
  1056. 41 /* full option count */, 37 /* user option count */,
  1057. tcpbridge_full_usage, tcpbridge_short_usage
  1058. };
  1059. /*
  1060. * Create the static procedure(s) declared above.
  1061. */
  1062. static void
  1063. doUsageOpt(
  1064. tOptions* pOptions,
  1065. tOptDesc* pOptDesc )
  1066. {
  1067. USAGE( EXIT_SUCCESS );
  1068. }
  1069. /* * * * * * *
  1070. *
  1071. * For the mtu option.
  1072. */
  1073. static void
  1074. doOptMtu(
  1075. tOptions* pOptions,
  1076. tOptDesc* pOptDesc )
  1077. {
  1078. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1079. { 1, MAXPACKET } };
  1080. int val;
  1081. int ix;
  1082. char const* pzIndent = "\t\t\t\t ";
  1083. extern FILE* option_usage_fp;
  1084. if (pOptDesc == NULL) /* usage is requesting range list
  1085. option_usage_fp has already been set */
  1086. goto emit_ranges;
  1087. val = atoi( pOptDesc->optArg.argString );
  1088. for (ix = 0; ix < 1; ix++) {
  1089. if (val < rng[ix].rmin)
  1090. continue; /* ranges need not be ordered. */
  1091. if (val == rng[ix].rmin)
  1092. goto valid_return;
  1093. if (rng[ix].rmax == INT_MIN)
  1094. continue;
  1095. if (val <= rng[ix].rmax)
  1096. goto valid_return;
  1097. }
  1098. option_usage_fp = stderr;
  1099. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1100. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1101. pzIndent = "\t";
  1102. emit_ranges:
  1103. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1104. pzIndent, rng[0].rmin, rng[0].rmax );
  1105. if (pOptDesc == NULL)
  1106. return;
  1107. USAGE( EXIT_FAILURE );
  1108. /* NOTREACHED */
  1109. return;
  1110. valid_return:
  1111. pOptDesc->optArg.argInt = val;
  1112. }
  1113. /* * * * * * *
  1114. *
  1115. * For the enet-vlan-tag option.
  1116. */
  1117. static void
  1118. doOptEnet_Vlan_Tag(
  1119. tOptions* pOptions,
  1120. tOptDesc* pOptDesc )
  1121. {
  1122. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1123. { 0, 4095 } };
  1124. int val;
  1125. int ix;
  1126. char const* pzIndent = "\t\t\t\t ";
  1127. extern FILE* option_usage_fp;
  1128. if (pOptDesc == NULL) /* usage is requesting range list
  1129. option_usage_fp has already been set */
  1130. goto emit_ranges;
  1131. val = atoi( pOptDesc->optArg.argString );
  1132. for (ix = 0; ix < 1; ix++) {
  1133. if (val < rng[ix].rmin)
  1134. continue; /* ranges need not be ordered. */
  1135. if (val == rng[ix].rmin)
  1136. goto valid_return;
  1137. if (rng[ix].rmax == INT_MIN)
  1138. continue;
  1139. if (val <= rng[ix].rmax)
  1140. goto valid_return;
  1141. }
  1142. option_usage_fp = stderr;
  1143. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1144. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1145. pzIndent = "\t";
  1146. emit_ranges:
  1147. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1148. pzIndent, rng[0].rmin, rng[0].rmax );
  1149. if (pOptDesc == NULL)
  1150. return;
  1151. USAGE( EXIT_FAILURE );
  1152. /* NOTREACHED */
  1153. return;
  1154. valid_return:
  1155. pOptDesc->optArg.argInt = val;
  1156. }
  1157. /* * * * * * *
  1158. *
  1159. * For the enet-vlan-cfi option.
  1160. */
  1161. static void
  1162. doOptEnet_Vlan_Cfi(
  1163. tOptions* pOptions,
  1164. tOptDesc* pOptDesc )
  1165. {
  1166. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1167. { 0, 1 } };
  1168. int val;
  1169. int ix;
  1170. char const* pzIndent = "\t\t\t\t ";
  1171. extern FILE* option_usage_fp;
  1172. if (pOptDesc == NULL) /* usage is requesting range list
  1173. option_usage_fp has already been set */
  1174. goto emit_ranges;
  1175. val = atoi( pOptDesc->optArg.argString );
  1176. for (ix = 0; ix < 1; ix++) {
  1177. if (val < rng[ix].rmin)
  1178. continue; /* ranges need not be ordered. */
  1179. if (val == rng[ix].rmin)
  1180. goto valid_return;
  1181. if (rng[ix].rmax == INT_MIN)
  1182. continue;
  1183. if (val <= rng[ix].rmax)
  1184. goto valid_return;
  1185. }
  1186. option_usage_fp = stderr;
  1187. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1188. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1189. pzIndent = "\t";
  1190. emit_ranges:
  1191. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1192. pzIndent, rng[0].rmin, rng[0].rmax );
  1193. if (pOptDesc == NULL)
  1194. return;
  1195. USAGE( EXIT_FAILURE );
  1196. /* NOTREACHED */
  1197. return;
  1198. valid_return:
  1199. pOptDesc->optArg.argInt = val;
  1200. }
  1201. /* * * * * * *
  1202. *
  1203. * For the enet-vlan-pri option.
  1204. */
  1205. static void
  1206. doOptEnet_Vlan_Pri(
  1207. tOptions* pOptions,
  1208. tOptDesc* pOptDesc )
  1209. {
  1210. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1211. { 0, 7 } };
  1212. int val;
  1213. int ix;
  1214. char const* pzIndent = "\t\t\t\t ";
  1215. extern FILE* option_usage_fp;
  1216. if (pOptDesc == NULL) /* usage is requesting range list
  1217. option_usage_fp has already been set */
  1218. goto emit_ranges;
  1219. val = atoi( pOptDesc->optArg.argString );
  1220. for (ix = 0; ix < 1; ix++) {
  1221. if (val < rng[ix].rmin)
  1222. continue; /* ranges need not be ordered. */
  1223. if (val == rng[ix].rmin)
  1224. goto valid_return;
  1225. if (rng[ix].rmax == INT_MIN)
  1226. continue;
  1227. if (val <= rng[ix].rmax)
  1228. goto valid_return;
  1229. }
  1230. option_usage_fp = stderr;
  1231. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1232. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1233. pzIndent = "\t";
  1234. emit_ranges:
  1235. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1236. pzIndent, rng[0].rmin, rng[0].rmax );
  1237. if (pOptDesc == NULL)
  1238. return;
  1239. USAGE( EXIT_FAILURE );
  1240. /* NOTREACHED */
  1241. return;
  1242. valid_return:
  1243. pOptDesc->optArg.argInt = val;
  1244. }
  1245. /* * * * * * *
  1246. *
  1247. * For the dbug option, when DEBUG is #define-d.
  1248. */
  1249. #ifdef DEBUG
  1250. static void
  1251. doOptDbug(
  1252. tOptions* pOptions,
  1253. tOptDesc* pOptDesc )
  1254. {
  1255. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1256. { 0, 5 } };
  1257. int val;
  1258. int ix;
  1259. char const* pzIndent = "\t\t\t\t ";
  1260. extern FILE* option_usage_fp;
  1261. if (pOptDesc == NULL) /* usage is requesting range list
  1262. option_usage_fp has already been set */
  1263. goto emit_ranges;
  1264. val = atoi( pOptDesc->optArg.argString );
  1265. for (ix = 0; ix < 1; ix++) {
  1266. if (val < rng[ix].rmin)
  1267. continue; /* ranges need not be ordered. */
  1268. if (val == rng[ix].rmin)
  1269. goto valid_return;
  1270. if (rng[ix].rmax == INT_MIN)
  1271. continue;
  1272. if (val <= rng[ix].rmax)
  1273. goto valid_return;
  1274. }
  1275. option_usage_fp = stderr;
  1276. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1277. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1278. pzIndent = "\t";
  1279. emit_ranges:
  1280. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1281. pzIndent, rng[0].rmin, rng[0].rmax );
  1282. if (pOptDesc == NULL)
  1283. return;
  1284. USAGE( EXIT_FAILURE );
  1285. /* NOTREACHED */
  1286. return;
  1287. valid_return:
  1288. pOptDesc->optArg.argInt = val;
  1289. }
  1290. #endif /* defined DEBUG */
  1291. /* * * * * * *
  1292. *
  1293. * For the limit option.
  1294. */
  1295. static void
  1296. doOptLimit(
  1297. tOptions* pOptions,
  1298. tOptDesc* pOptDesc )
  1299. {
  1300. static const struct {const int rmin, rmax;} rng[ 1 ] = {
  1301. { 1, INT_MAX } };
  1302. int val;
  1303. int ix;
  1304. char const* pzIndent = "\t\t\t\t ";
  1305. extern FILE* option_usage_fp;
  1306. if (pOptDesc == NULL) /* usage is requesting range list
  1307. option_usage_fp has already been set */
  1308. goto emit_ranges;
  1309. val = atoi( pOptDesc->optArg.argString );
  1310. for (ix = 0; ix < 1; ix++) {
  1311. if (val < rng[ix].rmin)
  1312. continue; /* ranges need not be ordered. */
  1313. if (val == rng[ix].rmin)
  1314. goto valid_return;
  1315. if (rng[ix].rmax == INT_MIN)
  1316. continue;
  1317. if (val <= rng[ix].rmax)
  1318. goto valid_return;
  1319. }
  1320. option_usage_fp = stderr;
  1321. fprintf(stderr, _("%s error: %s option value ``%s''is out of range.\n"),
  1322. pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
  1323. pzIndent = "\t";
  1324. emit_ranges:
  1325. fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
  1326. pzIndent, rng[0].rmin, rng[0].rmax );
  1327. if (pOptDesc == NULL)
  1328. return;
  1329. USAGE( EXIT_FAILURE );
  1330. /* NOTREACHED */
  1331. return;
  1332. valid_return:
  1333. pOptDesc->optArg.argInt = val;
  1334. }
  1335. /* * * * * * *
  1336. *
  1337. * For the include option.
  1338. */
  1339. static void
  1340. doOptInclude(
  1341. tOptions* pOptions,
  1342. tOptDesc* pOptDesc )
  1343. {
  1344. /* extracted from tcpbridge_opts.def, line 169 */
  1345. char *include;
  1346. include = safe_strdup(OPT_ARG(INCLUDE));
  1347. options.xX.mode = xX_MODE_INCLUDE;
  1348. if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError)
  1349. errx(1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE));
  1350. free(include);
  1351. }
  1352. /* * * * * * *
  1353. *
  1354. * For the exclude option.
  1355. */
  1356. static void
  1357. doOptExclude(
  1358. tOptions* pOptions,
  1359. tOptDesc* pOptDesc )
  1360. {
  1361. /* extracted from tcpbridge_opts.def, line 216 */
  1362. char *exclude;
  1363. exclude = safe_strdup(OPT_ARG(EXCLUDE));
  1364. options.xX.mode = xX_MODE_EXCLUDE;
  1365. if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError)
  1366. errx(1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE));
  1367. free(exclude);
  1368. }
  1369. /* * * * * * *
  1370. *
  1371. * For the pid option.
  1372. */
  1373. static void
  1374. doOptPid(
  1375. tOptions* pOptions,
  1376. tOptDesc* pOptDesc )
  1377. {
  1378. /* extracted from tcpbridge_opts.def, line 258 */
  1379. fprintf(stderr, "PID: %hu\n", getpid());
  1380. }
  1381. /* * * * * * *
  1382. *
  1383. * For the version option.
  1384. */
  1385. static void
  1386. doOptVersion(
  1387. tOptions* pOptions,
  1388. tOptDesc* pOptDesc )
  1389. {
  1390. /* extracted from tcpbridge_opts.def, line 303 */
  1391. fprintf(stderr, "tcpbridge version: %s (build %s)", VERSION, svn_version());
  1392. #ifdef DEBUG
  1393. fprintf(stderr, " (debug)");
  1394. #endif
  1395. fprintf(stderr, "\n");
  1396. fprintf(stderr, "Copyright 2001-2008 by Aaron Turner <aturner at synfin dot net>\n");
  1397. #ifdef HAVE_LIBNET
  1398. fprintf(stderr, "Compiled against libnet: %s\n", LIBNET_VERSION);
  1399. #else
  1400. fprintf(stderr, "Not compiled with libnet.\n");
  1401. #endif
  1402. #ifdef HAVE_WINPCAP
  1403. fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
  1404. #else
  1405. fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
  1406. #endif
  1407. #ifdef ENABLE_64BITS
  1408. fprintf(stderr, "64 bit packet counters: enabled\n");
  1409. #else
  1410. fprintf(stderr, "64 bit packet counters: disabled\n");
  1411. #endif
  1412. #ifdef ENABLE_VERBOSE
  1413. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  1414. #else
  1415. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  1416. #endif
  1417. exit(0);
  1418. }
  1419. /* * * * * * *
  1420. *
  1421. * For the less-help option.
  1422. */
  1423. static void
  1424. doOptLess_Help(
  1425. tOptions* pOptions,
  1426. tOptDesc* pOptDesc )
  1427. {
  1428. /* extracted from tcpbridge_opts.def, line 342 */
  1429. USAGE(EXIT_FAILURE);
  1430. }
  1431. /* extracted from /opt/local/share/autogen/optcode.tpl near line 537 */
  1432. #if ENABLE_NLS
  1433. #include <stdio.h>
  1434. #include <stdlib.h>
  1435. #include <string.h>
  1436. #include <unistd.h>
  1437. #include <autoopts/usage-txt.h>
  1438. static char* AO_gettext( char const* pz );
  1439. static void coerce_it(void** s);
  1440. static char*
  1441. AO_gettext( char const* pz )
  1442. {
  1443. char* pzRes;
  1444. if (pz == NULL)
  1445. return NULL;
  1446. pzRes = _(pz);
  1447. if (pzRes == pz)
  1448. return pzRes;
  1449. pzRes = strdup( pzRes );
  1450. if (pzRes == NULL) {
  1451. fputs( _("No memory for duping translated strings\n"), stderr );
  1452. exit( EXIT_FAILURE );
  1453. }
  1454. return pzRes;
  1455. }
  1456. static void coerce_it(void** s) { *s = AO_gettext(*s); }
  1457. #define COERSION(_f) \
  1458. coerce_it((void*)&(tcpbridgeOptions._f))
  1459. /*
  1460. * This invokes the translation code (e.g. gettext(3)).
  1461. */
  1462. static void
  1463. translate_option_strings( void )
  1464. {
  1465. /*
  1466. * Guard against re-translation. It won't work. The strings will have
  1467. * been changed by the first pass through this code. One shot only.
  1468. */
  1469. if (option_usage_text.field_ct == 0)
  1470. return;
  1471. /*
  1472. * Do the translations. The first pointer follows the field count field.
  1473. * The field count field is the size of a pointer.
  1474. */
  1475. {
  1476. char** ppz = (char**)(void*)&(option_usage_text);
  1477. int ix = option_usage_text.field_ct;
  1478. do {
  1479. ppz++;
  1480. *ppz = AO_gettext(*ppz);
  1481. } while (--ix > 0);
  1482. }
  1483. option_usage_text.field_ct = 0;
  1484. {
  1485. tOptDesc* pOD = tcpbridgeOptions.pOptDesc;
  1486. int ix = tcpbridgeOptions.optCt;
  1487. for (;;) {
  1488. pOD->pzText = AO_gettext(pOD->pzText);
  1489. pOD->pz_NAME = AO_gettext(pOD->pz_NAME);
  1490. pOD->pz_Name = AO_gettext(pOD->pz_Name);
  1491. pOD->pz_DisableName = AO_gettext(pOD->pz_DisableName);
  1492. pOD->pz_DisablePfx = AO_gettext(pOD->pz_DisablePfx);
  1493. if (--ix <= 0)
  1494. break;
  1495. pOD++;
  1496. }
  1497. }
  1498. COERSION(pzCopyright);
  1499. COERSION(pzCopyNotice);
  1500. COERSION(pzFullVersion);
  1501. COERSION(pzUsageTitle);
  1502. COERSION(pzExplain);
  1503. COERSION(pzDetail);
  1504. }
  1505. #endif /* ENABLE_NLS */
  1506. #ifdef __cplusplus
  1507. }
  1508. #endif
  1509. /* tcpbridge_opts.c ends here */