tcpprep_opts.c 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328
  1. /* -*- buffer-read-only: t -*- vi: set ro:
  2. *
  3. * DO NOT EDIT THIS FILE (tcpprep_opts.c)
  4. *
  5. * It has been AutoGen-ed
  6. * From the definitions ../../src/tcpprep_opts.def
  7. * and the template file options
  8. *
  9. * Generated from AutoOpts 42:1:17 templates.
  10. *
  11. * AutoOpts is a copyrighted work. This source file is not encumbered
  12. * by AutoOpts licensing, but is provided under the licensing terms chosen
  13. * by the tcpprep author or copyright holder. AutoOpts is
  14. * licensed under the terms of the LGPL. The redistributable library
  15. * (``libopts'') is licensed under the terms of either the LGPL or, at the
  16. * users discretion, the BSD license. See the AutoOpts and/or libopts sources
  17. * for details.
  18. *
  19. * The tcpprep program is copyrighted and licensed
  20. * under the following terms:
  21. *
  22. * Copyright (C) 2000-2024 Aaron Turner and Fred Klassen, all rights reserved.
  23. * This is free software. It is licensed for use, modification and
  24. * redistribution under the terms of the GNU General Public License,
  25. * version 3 or later <http://gnu.org/licenses/gpl.html>
  26. *
  27. * tcpprep is free software: you can redistribute it and/or modify it
  28. * under the terms of the GNU General Public License as published by the
  29. * Free Software Foundation, either version 3 of the License, or
  30. * (at your option) any later version.
  31. *
  32. * tcpprep is distributed in the hope that it will be useful, but
  33. * WITHOUT ANY WARRANTY; without even the implied warranty of
  34. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  35. * See the GNU General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU General Public License along
  38. * with this program. If not, see <http://www.gnu.org/licenses/>.
  39. */
  40. #ifndef __doxygen__
  41. #define OPTION_CODE_COMPILE 1
  42. #include "tcpprep_opts.h"
  43. #include <sys/types.h>
  44. #include <sys/stat.h>
  45. #include <errno.h>
  46. #include <fcntl.h>
  47. #include <limits.h>
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50. #include <string.h>
  51. #include <unistd.h>
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. extern FILE * option_usage_fp;
  56. #define zCopyright (tcpprep_opt_strs+0)
  57. #define zLicenseDescrip (tcpprep_opt_strs+279)
  58. /*
  59. * global included definitions
  60. */
  61. #include "defines.h"
  62. #include "common.h"
  63. #include "config.h"
  64. #include "tcpprep.h"
  65. #include <stdlib.h>
  66. #include <string.h>
  67. #include "tcpprep_api.h"
  68. extern tcpprep_t *tcpprep;
  69. #ifndef NULL
  70. # define NULL 0
  71. #endif
  72. /**
  73. * static const strings for tcpprep options
  74. */
  75. static char const tcpprep_opt_strs[3149] =
  76. /* 0 */ "tcpprep (tcpprep)\n"
  77. "Copyright (C) 2000-2024 Aaron Turner and Fred Klassen, all rights reserved.\n"
  78. "This is free software. It is licensed for use, modification and\n"
  79. "redistribution under the terms of the GNU General Public License,\n"
  80. "version 3 or later <http://gnu.org/licenses/gpl.html>\n\0"
  81. /* 279 */ "tcpprep is free software: you can redistribute it and/or modify it under\n"
  82. "the terms of the GNU General Public License as published by the Free\n"
  83. "Software Foundation, either version 3 of the License, or (at your option)\n"
  84. "any later version.\n\n"
  85. "tcpprep is distributed in the hope that it will be useful, but WITHOUT ANY\n"
  86. "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n"
  87. "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n"
  88. "details.\n\n"
  89. "You should have received a copy of the GNU General Public License along\n"
  90. "with this program. If not, see <http://www.gnu.org/licenses/>.\n\0"
  91. /* 882 */ "Enable debugging output\0"
  92. /* 906 */ "DBUG\0"
  93. /* 911 */ "dbug\0"
  94. /* 916 */ "Auto-split mode\0"
  95. /* 932 */ "AUTO\0"
  96. /* 937 */ "auto\0"
  97. /* 942 */ "CIDR-split mode\0"
  98. /* 958 */ "CIDR\0"
  99. /* 963 */ "cidr\0"
  100. /* 968 */ "Regex-split mode\0"
  101. /* 985 */ "REGEX\0"
  102. /* 991 */ "regex\0"
  103. /* 997 */ "Port-split mode\0"
  104. /* 1013 */ "PORT\0"
  105. /* 1018 */ "port\0"
  106. /* 1023 */ "Source MAC split mode\0"
  107. /* 1045 */ "MAC\0"
  108. /* 1049 */ "mac\0"
  109. /* 1053 */ "Matches to be client instead of server\0"
  110. /* 1092 */ "REVERSE\0"
  111. /* 1100 */ "reverse\0"
  112. /* 1108 */ "Embedded cache file comment\0"
  113. /* 1136 */ "COMMENT\0"
  114. /* 1144 */ "comment\0"
  115. /* 1152 */ "Do not embed any cache file comment\0"
  116. /* 1188 */ "NO_ARG_COMMENT\0"
  117. /* 1203 */ "no-arg-comment\0"
  118. /* 1218 */ "Include only packets matching rule\0"
  119. /* 1253 */ "INCLUDE\0"
  120. /* 1261 */ "include\0"
  121. /* 1269 */ "Exclude any packet matching this rule\0"
  122. /* 1307 */ "EXCLUDE\0"
  123. /* 1315 */ "exclude\0"
  124. /* 1323 */ "Output cache file\0"
  125. /* 1341 */ "CACHEFILE\0"
  126. /* 1351 */ "cachefile\0"
  127. /* 1361 */ "Input pcap file to process\0"
  128. /* 1388 */ "PCAP\0"
  129. /* 1393 */ "pcap\0"
  130. /* 1398 */ "Print embedded comment in the specified cache file\0"
  131. /* 1449 */ "PRINT_COMMENT\0"
  132. /* 1463 */ "print-comment\0"
  133. /* 1477 */ "Print basic info from the specified cache file\0"
  134. /* 1524 */ "PRINT_INFO\0"
  135. /* 1535 */ "print-info\0"
  136. /* 1546 */ "Print statistical information about the specified cache file\0"
  137. /* 1607 */ "PRINT_STATS\0"
  138. /* 1619 */ "print-stats\0"
  139. /* 1631 */ "Load services file for server ports\0"
  140. /* 1667 */ "SERVICES\0"
  141. /* 1676 */ "services\0"
  142. /* 1685 */ "Send non-IP traffic out server interface\0"
  143. /* 1726 */ "NONIP\0"
  144. /* 1732 */ "nonip\0"
  145. /* 1738 */ "Ratio of client to server packets\0"
  146. /* 1772 */ "RATIO\0"
  147. /* 1778 */ "ratio\0"
  148. /* 1784 */ "2.0\0"
  149. /* 1788 */ "Minimum network mask length in auto mode\0"
  150. /* 1829 */ "MINMASK\0"
  151. /* 1837 */ "minmask\0"
  152. /* 1845 */ "Maximum network mask length in auto mode\0"
  153. /* 1886 */ "MAXMASK\0"
  154. /* 1894 */ "maxmask\0"
  155. /* 1902 */ "Print decoded packets via tcpdump to STDOUT\0"
  156. /* 1946 */ "VERBOSE\0"
  157. /* 1954 */ "verbose\0"
  158. /* 1962 */ "Arguments passed to tcpdump decoder\0"
  159. /* 1998 */ "DECODE\0"
  160. /* 2005 */ "decode\0"
  161. /* 2012 */ "Print version information\0"
  162. /* 2038 */ "VERSION\0"
  163. /* 2046 */ "version\0"
  164. /* 2054 */ "Display less usage information and exit\0"
  165. /* 2094 */ "LESS_HELP\0"
  166. /* 2104 */ "less-help\0"
  167. /* 2114 */ "suppress printing warning messages\0"
  168. /* 2149 */ "SUPPRESS_WARNINGS\0"
  169. /* 2167 */ "suppress-warnings\0"
  170. /* 2185 */ "display extended usage information and exit\0"
  171. /* 2229 */ "help\0"
  172. /* 2234 */ "extended usage information passed thru pager\0"
  173. /* 2279 */ "more-help\0"
  174. /* 2289 */ "save the option state to a config file\0"
  175. /* 2328 */ "save-opts\0"
  176. /* 2338 */ "load options from a config file\0"
  177. /* 2370 */ "LOAD_OPTS\0"
  178. /* 2380 */ "no-load-opts\0"
  179. /* 2393 */ "no\0"
  180. /* 2396 */ "TCPPREP\0"
  181. /* 2404 */ "tcpprep (tcpprep) - Create a tcpreplay cache cache file from a pcap file.\n"
  182. "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
  183. /* 2536 */ "$$/\0"
  184. /* 2540 */ ".tcppreprc\0"
  185. /* 2551 */ "tcpreplay-users@lists.sourceforge.net\0"
  186. /* 2589 */ "tcpprep is a 'pcap(3)' file pre-processor which creates a cache file which\n"
  187. "provides \"rules\" for 'tcprewrite(1)' and 'tcpreplay(1)' on how to process\n"
  188. "and send packets.\n\0"
  189. /* 2757 */ "The basic operation of tcpreplay is to resend all packets from the input\n"
  190. "file(s) out a single file. Tcpprep processes a pcap file and applies a set\n"
  191. "of user-specified rules to create a cache file which tells tcpreplay\n"
  192. "whether or not to send each packet and which interface the packet should be\n"
  193. "sent out of.\n\n"
  194. "For more details, please see the Tcpreplay Manual at:\n"
  195. "http://tcpreplay.appneta.com\n";
  196. /**
  197. * dbug option description:
  198. */
  199. #ifdef DEBUG
  200. /** Descriptive text for the dbug option */
  201. #define DBUG_DESC (tcpprep_opt_strs+882)
  202. /** Upper-cased name for the dbug option */
  203. #define DBUG_NAME (tcpprep_opt_strs+906)
  204. /** Name string for the dbug option */
  205. #define DBUG_name (tcpprep_opt_strs+911)
  206. /** The compiled in default value for the dbug option argument */
  207. #define DBUG_DFT_ARG ((char const*)0)
  208. /** Compiled in flag settings for the dbug option */
  209. #define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \
  210. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  211. #else /* disable dbug */
  212. #define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  213. #define DBUG_DFT_ARG NULL
  214. #define DBUG_NAME NULL
  215. #define DBUG_DESC NULL
  216. #define DBUG_name NULL
  217. #endif /* DEBUG */
  218. /**
  219. * auto option description with
  220. * "Must also have options" and "Incompatible options":
  221. */
  222. /** Descriptive text for the auto option */
  223. #define AUTO_DESC (tcpprep_opt_strs+916)
  224. /** Upper-cased name for the auto option */
  225. #define AUTO_NAME (tcpprep_opt_strs+932)
  226. /** Name string for the auto option */
  227. #define AUTO_name (tcpprep_opt_strs+937)
  228. /** Other options that appear in conjunction with the auto option */
  229. static int const aAutoCantList[] = {
  230. INDEX_OPT_CIDR,
  231. INDEX_OPT_PORT,
  232. INDEX_OPT_REGEX,
  233. INDEX_OPT_MAC, NO_EQUIVALENT };
  234. /** Compiled in flag settings for the auto option */
  235. #define AUTO_FLAGS (OPTST_DISABLED \
  236. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  237. /**
  238. * cidr option description with
  239. * "Must also have options" and "Incompatible options":
  240. */
  241. /** Descriptive text for the cidr option */
  242. #define CIDR_DESC (tcpprep_opt_strs+942)
  243. /** Upper-cased name for the cidr option */
  244. #define CIDR_NAME (tcpprep_opt_strs+958)
  245. /** Name string for the cidr option */
  246. #define CIDR_name (tcpprep_opt_strs+963)
  247. /** Other options that appear in conjunction with the cidr option */
  248. static int const aCidrCantList[] = {
  249. INDEX_OPT_AUTO,
  250. INDEX_OPT_PORT,
  251. INDEX_OPT_REGEX,
  252. INDEX_OPT_MAC, NO_EQUIVALENT };
  253. /** Compiled in flag settings for the cidr option */
  254. #define CIDR_FLAGS (OPTST_DISABLED \
  255. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  256. /**
  257. * regex option description with
  258. * "Must also have options" and "Incompatible options":
  259. */
  260. /** Descriptive text for the regex option */
  261. #define REGEX_DESC (tcpprep_opt_strs+968)
  262. /** Upper-cased name for the regex option */
  263. #define REGEX_NAME (tcpprep_opt_strs+985)
  264. /** Name string for the regex option */
  265. #define REGEX_name (tcpprep_opt_strs+991)
  266. /** Other options that appear in conjunction with the regex option */
  267. static int const aRegexCantList[] = {
  268. INDEX_OPT_AUTO,
  269. INDEX_OPT_PORT,
  270. INDEX_OPT_CIDR,
  271. INDEX_OPT_MAC, NO_EQUIVALENT };
  272. /** Compiled in flag settings for the regex option */
  273. #define REGEX_FLAGS (OPTST_DISABLED \
  274. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  275. /**
  276. * port option description with
  277. * "Must also have options" and "Incompatible options":
  278. */
  279. /** Descriptive text for the port option */
  280. #define PORT_DESC (tcpprep_opt_strs+997)
  281. /** Upper-cased name for the port option */
  282. #define PORT_NAME (tcpprep_opt_strs+1013)
  283. /** Name string for the port option */
  284. #define PORT_name (tcpprep_opt_strs+1018)
  285. /** Other options that appear in conjunction with the port option */
  286. static int const aPortCantList[] = {
  287. INDEX_OPT_AUTO,
  288. INDEX_OPT_REGEX,
  289. INDEX_OPT_CIDR,
  290. INDEX_OPT_MAC, NO_EQUIVALENT };
  291. /** Compiled in flag settings for the port option */
  292. #define PORT_FLAGS (OPTST_DISABLED)
  293. /**
  294. * mac option description with
  295. * "Must also have options" and "Incompatible options":
  296. */
  297. /** Descriptive text for the mac option */
  298. #define MAC_DESC (tcpprep_opt_strs+1023)
  299. /** Upper-cased name for the mac option */
  300. #define MAC_NAME (tcpprep_opt_strs+1045)
  301. /** Name string for the mac option */
  302. #define MAC_name (tcpprep_opt_strs+1049)
  303. /** Other options that appear in conjunction with the mac option */
  304. static int const aMacCantList[] = {
  305. INDEX_OPT_AUTO,
  306. INDEX_OPT_REGEX,
  307. INDEX_OPT_CIDR,
  308. INDEX_OPT_PORT, NO_EQUIVALENT };
  309. /** Compiled in flag settings for the mac option */
  310. #define MAC_FLAGS (OPTST_DISABLED \
  311. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  312. /**
  313. * reverse option description:
  314. */
  315. /** Descriptive text for the reverse option */
  316. #define REVERSE_DESC (tcpprep_opt_strs+1053)
  317. /** Upper-cased name for the reverse option */
  318. #define REVERSE_NAME (tcpprep_opt_strs+1092)
  319. /** Name string for the reverse option */
  320. #define REVERSE_name (tcpprep_opt_strs+1100)
  321. /** Compiled in flag settings for the reverse option */
  322. #define REVERSE_FLAGS (OPTST_DISABLED)
  323. /**
  324. * comment option description:
  325. */
  326. /** Descriptive text for the comment option */
  327. #define COMMENT_DESC (tcpprep_opt_strs+1108)
  328. /** Upper-cased name for the comment option */
  329. #define COMMENT_NAME (tcpprep_opt_strs+1136)
  330. /** Name string for the comment option */
  331. #define COMMENT_name (tcpprep_opt_strs+1144)
  332. /** Compiled in flag settings for the comment option */
  333. #define COMMENT_FLAGS (OPTST_DISABLED \
  334. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  335. /**
  336. * no-arg-comment option description:
  337. */
  338. /** Descriptive text for the no-arg-comment option */
  339. #define NO_ARG_COMMENT_DESC (tcpprep_opt_strs+1152)
  340. /** Upper-cased name for the no-arg-comment option */
  341. #define NO_ARG_COMMENT_NAME (tcpprep_opt_strs+1188)
  342. /** Name string for the no-arg-comment option */
  343. #define NO_ARG_COMMENT_name (tcpprep_opt_strs+1203)
  344. /** Compiled in flag settings for the no-arg-comment option */
  345. #define NO_ARG_COMMENT_FLAGS (OPTST_DISABLED)
  346. /**
  347. * include option description with
  348. * "Must also have options" and "Incompatible options":
  349. */
  350. /** Descriptive text for the include option */
  351. #define INCLUDE_DESC (tcpprep_opt_strs+1218)
  352. /** Upper-cased name for the include option */
  353. #define INCLUDE_NAME (tcpprep_opt_strs+1253)
  354. /** Name string for the include option */
  355. #define INCLUDE_name (tcpprep_opt_strs+1261)
  356. /** Other options that appear in conjunction with the include option */
  357. static int const aIncludeCantList[] = {
  358. INDEX_OPT_EXCLUDE, NO_EQUIVALENT };
  359. /** Compiled in flag settings for the include option */
  360. #define INCLUDE_FLAGS (OPTST_DISABLED \
  361. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  362. /**
  363. * exclude option description with
  364. * "Must also have options" and "Incompatible options":
  365. */
  366. /** Descriptive text for the exclude option */
  367. #define EXCLUDE_DESC (tcpprep_opt_strs+1269)
  368. /** Upper-cased name for the exclude option */
  369. #define EXCLUDE_NAME (tcpprep_opt_strs+1307)
  370. /** Name string for the exclude option */
  371. #define EXCLUDE_name (tcpprep_opt_strs+1315)
  372. /** Other options that appear in conjunction with the exclude option */
  373. static int const aExcludeCantList[] = {
  374. INDEX_OPT_INCLUDE, NO_EQUIVALENT };
  375. /** Compiled in flag settings for the exclude option */
  376. #define EXCLUDE_FLAGS (OPTST_DISABLED \
  377. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  378. /**
  379. * cachefile option description:
  380. */
  381. /** Descriptive text for the cachefile option */
  382. #define CACHEFILE_DESC (tcpprep_opt_strs+1323)
  383. /** Upper-cased name for the cachefile option */
  384. #define CACHEFILE_NAME (tcpprep_opt_strs+1341)
  385. /** Name string for the cachefile option */
  386. #define CACHEFILE_name (tcpprep_opt_strs+1351)
  387. /** Compiled in flag settings for the cachefile option */
  388. #define CACHEFILE_FLAGS (OPTST_DISABLED \
  389. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  390. /**
  391. * pcap option description:
  392. */
  393. /** Descriptive text for the pcap option */
  394. #define PCAP_DESC (tcpprep_opt_strs+1361)
  395. /** Upper-cased name for the pcap option */
  396. #define PCAP_NAME (tcpprep_opt_strs+1388)
  397. /** Name string for the pcap option */
  398. #define PCAP_name (tcpprep_opt_strs+1393)
  399. /** Compiled in flag settings for the pcap option */
  400. #define PCAP_FLAGS (OPTST_DISABLED \
  401. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  402. /**
  403. * print-comment option description:
  404. */
  405. /** Descriptive text for the print-comment option */
  406. #define PRINT_COMMENT_DESC (tcpprep_opt_strs+1398)
  407. /** Upper-cased name for the print-comment option */
  408. #define PRINT_COMMENT_NAME (tcpprep_opt_strs+1449)
  409. /** Name string for the print-comment option */
  410. #define PRINT_COMMENT_name (tcpprep_opt_strs+1463)
  411. /** Compiled in flag settings for the print-comment option */
  412. #define PRINT_COMMENT_FLAGS (OPTST_DISABLED \
  413. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  414. /**
  415. * print-info option description:
  416. */
  417. /** Descriptive text for the print-info option */
  418. #define PRINT_INFO_DESC (tcpprep_opt_strs+1477)
  419. /** Upper-cased name for the print-info option */
  420. #define PRINT_INFO_NAME (tcpprep_opt_strs+1524)
  421. /** Name string for the print-info option */
  422. #define PRINT_INFO_name (tcpprep_opt_strs+1535)
  423. /** Compiled in flag settings for the print-info option */
  424. #define PRINT_INFO_FLAGS (OPTST_DISABLED \
  425. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  426. /**
  427. * print-stats option description:
  428. */
  429. /** Descriptive text for the print-stats option */
  430. #define PRINT_STATS_DESC (tcpprep_opt_strs+1546)
  431. /** Upper-cased name for the print-stats option */
  432. #define PRINT_STATS_NAME (tcpprep_opt_strs+1607)
  433. /** Name string for the print-stats option */
  434. #define PRINT_STATS_name (tcpprep_opt_strs+1619)
  435. /** Compiled in flag settings for the print-stats option */
  436. #define PRINT_STATS_FLAGS (OPTST_DISABLED \
  437. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  438. /**
  439. * services option description with
  440. * "Must also have options" and "Incompatible options":
  441. */
  442. /** Descriptive text for the services option */
  443. #define SERVICES_DESC (tcpprep_opt_strs+1631)
  444. /** Upper-cased name for the services option */
  445. #define SERVICES_NAME (tcpprep_opt_strs+1667)
  446. /** Name string for the services option */
  447. #define SERVICES_name (tcpprep_opt_strs+1676)
  448. /** Other options that are required by the services option */
  449. static int const aServicesMustList[] = {
  450. INDEX_OPT_PORT, NO_EQUIVALENT };
  451. /** Compiled in flag settings for the services option */
  452. #define SERVICES_FLAGS (OPTST_DISABLED \
  453. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  454. /**
  455. * nonip option description:
  456. */
  457. /** Descriptive text for the nonip option */
  458. #define NONIP_DESC (tcpprep_opt_strs+1685)
  459. /** Upper-cased name for the nonip option */
  460. #define NONIP_NAME (tcpprep_opt_strs+1726)
  461. /** Name string for the nonip option */
  462. #define NONIP_name (tcpprep_opt_strs+1732)
  463. /** Compiled in flag settings for the nonip option */
  464. #define NONIP_FLAGS (OPTST_DISABLED)
  465. /**
  466. * ratio option description with
  467. * "Must also have options" and "Incompatible options":
  468. */
  469. /** Descriptive text for the ratio option */
  470. #define RATIO_DESC (tcpprep_opt_strs+1738)
  471. /** Upper-cased name for the ratio option */
  472. #define RATIO_NAME (tcpprep_opt_strs+1772)
  473. /** Name string for the ratio option */
  474. #define RATIO_name (tcpprep_opt_strs+1778)
  475. /** The compiled in default value for the ratio option argument */
  476. #define RATIO_DFT_ARG (tcpprep_opt_strs+1784)
  477. /** Other options that are required by the ratio option */
  478. static int const aRatioMustList[] = {
  479. INDEX_OPT_AUTO, NO_EQUIVALENT };
  480. /** Compiled in flag settings for the ratio option */
  481. #define RATIO_FLAGS (OPTST_DISABLED \
  482. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  483. /**
  484. * minmask option description with
  485. * "Must also have options" and "Incompatible options":
  486. */
  487. /** Descriptive text for the minmask option */
  488. #define MINMASK_DESC (tcpprep_opt_strs+1788)
  489. /** Upper-cased name for the minmask option */
  490. #define MINMASK_NAME (tcpprep_opt_strs+1829)
  491. /** Name string for the minmask option */
  492. #define MINMASK_name (tcpprep_opt_strs+1837)
  493. /** The compiled in default value for the minmask option argument */
  494. #define MINMASK_DFT_ARG ((char const*)30)
  495. /** Other options that are required by the minmask option */
  496. static int const aMinmaskMustList[] = {
  497. INDEX_OPT_AUTO, NO_EQUIVALENT };
  498. /** Compiled in flag settings for the minmask option */
  499. #define MINMASK_FLAGS (OPTST_DISABLED \
  500. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  501. /**
  502. * maxmask option description with
  503. * "Must also have options" and "Incompatible options":
  504. */
  505. /** Descriptive text for the maxmask option */
  506. #define MAXMASK_DESC (tcpprep_opt_strs+1845)
  507. /** Upper-cased name for the maxmask option */
  508. #define MAXMASK_NAME (tcpprep_opt_strs+1886)
  509. /** Name string for the maxmask option */
  510. #define MAXMASK_name (tcpprep_opt_strs+1894)
  511. /** The compiled in default value for the maxmask option argument */
  512. #define MAXMASK_DFT_ARG ((char const*)8)
  513. /** Other options that are required by the maxmask option */
  514. static int const aMaxmaskMustList[] = {
  515. INDEX_OPT_AUTO, NO_EQUIVALENT };
  516. /** Compiled in flag settings for the maxmask option */
  517. #define MAXMASK_FLAGS (OPTST_DISABLED \
  518. | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
  519. /**
  520. * verbose option description:
  521. */
  522. #ifdef ENABLE_VERBOSE
  523. /** Descriptive text for the verbose option */
  524. #define VERBOSE_DESC (tcpprep_opt_strs+1902)
  525. /** Upper-cased name for the verbose option */
  526. #define VERBOSE_NAME (tcpprep_opt_strs+1946)
  527. /** Name string for the verbose option */
  528. #define VERBOSE_name (tcpprep_opt_strs+1954)
  529. /** Compiled in flag settings for the verbose option */
  530. #define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM)
  531. #else /* disable verbose */
  532. #define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  533. #define VERBOSE_NAME NULL
  534. #define VERBOSE_DESC NULL
  535. #define VERBOSE_name NULL
  536. #endif /* ENABLE_VERBOSE */
  537. /**
  538. * decode option description with
  539. * "Must also have options" and "Incompatible options":
  540. */
  541. #ifdef ENABLE_VERBOSE
  542. /** Descriptive text for the decode option */
  543. #define DECODE_DESC (tcpprep_opt_strs+1962)
  544. /** Upper-cased name for the decode option */
  545. #define DECODE_NAME (tcpprep_opt_strs+1998)
  546. /** Name string for the decode option */
  547. #define DECODE_name (tcpprep_opt_strs+2005)
  548. /** Other options that are required by the decode option */
  549. static int const aDecodeMustList[] = {
  550. INDEX_OPT_VERBOSE, NO_EQUIVALENT };
  551. /** Compiled in flag settings for the decode option */
  552. #define DECODE_FLAGS (OPTST_DISABLED \
  553. | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
  554. #else /* disable decode */
  555. #define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  556. #define aDecodeMustList NULL
  557. #define DECODE_NAME NULL
  558. #define DECODE_DESC NULL
  559. #define DECODE_name NULL
  560. #endif /* ENABLE_VERBOSE */
  561. /**
  562. * version option description:
  563. */
  564. /** Descriptive text for the version option */
  565. #define VERSION_DESC (tcpprep_opt_strs+2012)
  566. /** Upper-cased name for the version option */
  567. #define VERSION_NAME (tcpprep_opt_strs+2038)
  568. /** Name string for the version option */
  569. #define VERSION_name (tcpprep_opt_strs+2046)
  570. /** Compiled in flag settings for the version option */
  571. #define VERSION_FLAGS (OPTST_DISABLED)
  572. /**
  573. * less-help option description:
  574. */
  575. /** Descriptive text for the less-help option */
  576. #define LESS_HELP_DESC (tcpprep_opt_strs+2054)
  577. /** Upper-cased name for the less-help option */
  578. #define LESS_HELP_NAME (tcpprep_opt_strs+2094)
  579. /** Name string for the less-help option */
  580. #define LESS_HELP_name (tcpprep_opt_strs+2104)
  581. /** Compiled in flag settings for the less-help option */
  582. #define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM)
  583. /**
  584. * suppress-warnings option description:
  585. */
  586. /** Descriptive text for the suppress-warnings option */
  587. #define SUPPRESS_WARNINGS_DESC (tcpprep_opt_strs+2114)
  588. /** Upper-cased name for the suppress-warnings option */
  589. #define SUPPRESS_WARNINGS_NAME (tcpprep_opt_strs+2149)
  590. /** Name string for the suppress-warnings option */
  591. #define SUPPRESS_WARNINGS_name (tcpprep_opt_strs+2167)
  592. /** Compiled in flag settings for the suppress-warnings option */
  593. #define SUPPRESS_WARNINGS_FLAGS (OPTST_DISABLED | OPTST_IMM)
  594. /*
  595. * Help/More_Help option descriptions:
  596. */
  597. #define HELP_DESC (tcpprep_opt_strs+2185)
  598. #define HELP_name (tcpprep_opt_strs+2229)
  599. #ifdef HAVE_WORKING_FORK
  600. #define MORE_HELP_DESC (tcpprep_opt_strs+2234)
  601. #define MORE_HELP_name (tcpprep_opt_strs+2279)
  602. #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
  603. #else
  604. #define MORE_HELP_DESC HELP_DESC
  605. #define MORE_HELP_name HELP_name
  606. #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
  607. #endif
  608. #define SAVE_OPTS_DESC (tcpprep_opt_strs+2289)
  609. #define SAVE_OPTS_name (tcpprep_opt_strs+2328)
  610. #define LOAD_OPTS_DESC (tcpprep_opt_strs+2338)
  611. #define LOAD_OPTS_NAME (tcpprep_opt_strs+2370)
  612. #define NO_LOAD_OPTS_name (tcpprep_opt_strs+2380)
  613. #define LOAD_OPTS_pfx (tcpprep_opt_strs+2393)
  614. #define LOAD_OPTS_name (NO_LOAD_OPTS_name + 3)
  615. /**
  616. * Declare option callback procedures
  617. */
  618. #ifdef DEBUG
  619. static tOptProc doOptDbug;
  620. #else /* not DEBUG */
  621. # define doOptDbug NULL
  622. #endif /* def/not DEBUG */
  623. extern tOptProc
  624. optionBooleanVal, optionNestedVal, optionNumericVal,
  625. optionPagedUsage, optionPrintVersion, optionResetOpt,
  626. optionStackArg, optionTimeDate, optionTimeVal,
  627. optionUnstackArg, optionVendorOption;
  628. static tOptProc
  629. doOptAuto, doOptCidr, doOptComment,
  630. doOptExclude, doOptInclude, doOptLess_Help,
  631. doOptMac, doOptMaxmask, doOptMinmask,
  632. doOptNo_Arg_Comment, doOptNonip, doOptPort,
  633. doOptRegex, doOptServices, doOptVersion,
  634. doUsageOpt;
  635. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  636. /**
  637. * Define the tcpprep Option Descriptions.
  638. * This is an array of OPTION_CT entries, one for each
  639. * option that the tcpprep program responds to.
  640. */
  641. static tOptDesc optDesc[OPTION_CT] = {
  642. { /* entry idx, value */ 0, VALUE_OPT_DBUG,
  643. /* equiv idx, value */ 0, VALUE_OPT_DBUG,
  644. /* equivalenced to */ NO_EQUIVALENT,
  645. /* min, max, act ct */ 0, 1, 0,
  646. /* opt state flags */ DBUG_FLAGS, 0,
  647. /* last opt argumnt */ { DBUG_DFT_ARG },
  648. /* arg list/cookie */ NULL,
  649. /* must/cannot opts */ NULL, NULL,
  650. /* option proc */ doOptDbug,
  651. /* desc, NAME, name */ DBUG_DESC, DBUG_NAME, DBUG_name,
  652. /* disablement strs */ NULL, NULL },
  653. { /* entry idx, value */ 1, VALUE_OPT_AUTO,
  654. /* equiv idx, value */ 1, VALUE_OPT_AUTO,
  655. /* equivalenced to */ NO_EQUIVALENT,
  656. /* min, max, act ct */ 0, 1, 0,
  657. /* opt state flags */ AUTO_FLAGS, 0,
  658. /* last opt argumnt */ { NULL }, /* --auto */
  659. /* arg list/cookie */ NULL,
  660. /* must/cannot opts */ NULL, aAutoCantList,
  661. /* option proc */ doOptAuto,
  662. /* desc, NAME, name */ AUTO_DESC, AUTO_NAME, AUTO_name,
  663. /* disablement strs */ NULL, NULL },
  664. { /* entry idx, value */ 2, VALUE_OPT_CIDR,
  665. /* equiv idx, value */ 2, VALUE_OPT_CIDR,
  666. /* equivalenced to */ NO_EQUIVALENT,
  667. /* min, max, act ct */ 0, 1, 0,
  668. /* opt state flags */ CIDR_FLAGS, 0,
  669. /* last opt argumnt */ { NULL }, /* --cidr */
  670. /* arg list/cookie */ NULL,
  671. /* must/cannot opts */ NULL, aCidrCantList,
  672. /* option proc */ doOptCidr,
  673. /* desc, NAME, name */ CIDR_DESC, CIDR_NAME, CIDR_name,
  674. /* disablement strs */ NULL, NULL },
  675. { /* entry idx, value */ 3, VALUE_OPT_REGEX,
  676. /* equiv idx, value */ 3, VALUE_OPT_REGEX,
  677. /* equivalenced to */ NO_EQUIVALENT,
  678. /* min, max, act ct */ 0, 1, 0,
  679. /* opt state flags */ REGEX_FLAGS, 0,
  680. /* last opt argumnt */ { NULL }, /* --regex */
  681. /* arg list/cookie */ NULL,
  682. /* must/cannot opts */ NULL, aRegexCantList,
  683. /* option proc */ doOptRegex,
  684. /* desc, NAME, name */ REGEX_DESC, REGEX_NAME, REGEX_name,
  685. /* disablement strs */ NULL, NULL },
  686. { /* entry idx, value */ 4, VALUE_OPT_PORT,
  687. /* equiv idx, value */ 4, VALUE_OPT_PORT,
  688. /* equivalenced to */ NO_EQUIVALENT,
  689. /* min, max, act ct */ 0, 1, 0,
  690. /* opt state flags */ PORT_FLAGS, 0,
  691. /* last opt argumnt */ { NULL }, /* --port */
  692. /* arg list/cookie */ NULL,
  693. /* must/cannot opts */ NULL, aPortCantList,
  694. /* option proc */ doOptPort,
  695. /* desc, NAME, name */ PORT_DESC, PORT_NAME, PORT_name,
  696. /* disablement strs */ NULL, NULL },
  697. { /* entry idx, value */ 5, VALUE_OPT_MAC,
  698. /* equiv idx, value */ 5, VALUE_OPT_MAC,
  699. /* equivalenced to */ NO_EQUIVALENT,
  700. /* min, max, act ct */ 0, 1, 0,
  701. /* opt state flags */ MAC_FLAGS, 0,
  702. /* last opt argumnt */ { NULL }, /* --mac */
  703. /* arg list/cookie */ NULL,
  704. /* must/cannot opts */ NULL, aMacCantList,
  705. /* option proc */ doOptMac,
  706. /* desc, NAME, name */ MAC_DESC, MAC_NAME, MAC_name,
  707. /* disablement strs */ NULL, NULL },
  708. { /* entry idx, value */ 6, VALUE_OPT_REVERSE,
  709. /* equiv idx, value */ 6, VALUE_OPT_REVERSE,
  710. /* equivalenced to */ NO_EQUIVALENT,
  711. /* min, max, act ct */ 0, 1, 0,
  712. /* opt state flags */ REVERSE_FLAGS, 0,
  713. /* last opt argumnt */ { NULL }, /* --reverse */
  714. /* arg list/cookie */ NULL,
  715. /* must/cannot opts */ NULL, NULL,
  716. /* option proc */ NULL,
  717. /* desc, NAME, name */ REVERSE_DESC, REVERSE_NAME, REVERSE_name,
  718. /* disablement strs */ NULL, NULL },
  719. { /* entry idx, value */ 7, VALUE_OPT_COMMENT,
  720. /* equiv idx, value */ 7, VALUE_OPT_COMMENT,
  721. /* equivalenced to */ NO_EQUIVALENT,
  722. /* min, max, act ct */ 0, 1, 0,
  723. /* opt state flags */ COMMENT_FLAGS, 0,
  724. /* last opt argumnt */ { NULL }, /* --comment */
  725. /* arg list/cookie */ NULL,
  726. /* must/cannot opts */ NULL, NULL,
  727. /* option proc */ doOptComment,
  728. /* desc, NAME, name */ COMMENT_DESC, COMMENT_NAME, COMMENT_name,
  729. /* disablement strs */ NULL, NULL },
  730. { /* entry idx, value */ 8, VALUE_OPT_NO_ARG_COMMENT,
  731. /* equiv idx, value */ 8, VALUE_OPT_NO_ARG_COMMENT,
  732. /* equivalenced to */ NO_EQUIVALENT,
  733. /* min, max, act ct */ 0, 1, 0,
  734. /* opt state flags */ NO_ARG_COMMENT_FLAGS, 0,
  735. /* last opt argumnt */ { NULL }, /* --no-arg-comment */
  736. /* arg list/cookie */ NULL,
  737. /* must/cannot opts */ NULL, NULL,
  738. /* option proc */ doOptNo_Arg_Comment,
  739. /* desc, NAME, name */ NO_ARG_COMMENT_DESC, NO_ARG_COMMENT_NAME, NO_ARG_COMMENT_name,
  740. /* disablement strs */ NULL, NULL },
  741. { /* entry idx, value */ 9, VALUE_OPT_INCLUDE,
  742. /* equiv idx, value */ 9, VALUE_OPT_INCLUDE,
  743. /* equivalenced to */ NO_EQUIVALENT,
  744. /* min, max, act ct */ 0, 1, 0,
  745. /* opt state flags */ INCLUDE_FLAGS, 0,
  746. /* last opt argumnt */ { NULL }, /* --include */
  747. /* arg list/cookie */ NULL,
  748. /* must/cannot opts */ NULL, aIncludeCantList,
  749. /* option proc */ doOptInclude,
  750. /* desc, NAME, name */ INCLUDE_DESC, INCLUDE_NAME, INCLUDE_name,
  751. /* disablement strs */ NULL, NULL },
  752. { /* entry idx, value */ 10, VALUE_OPT_EXCLUDE,
  753. /* equiv idx, value */ 10, VALUE_OPT_EXCLUDE,
  754. /* equivalenced to */ NO_EQUIVALENT,
  755. /* min, max, act ct */ 0, 1, 0,
  756. /* opt state flags */ EXCLUDE_FLAGS, 0,
  757. /* last opt argumnt */ { NULL }, /* --exclude */
  758. /* arg list/cookie */ NULL,
  759. /* must/cannot opts */ NULL, aExcludeCantList,
  760. /* option proc */ doOptExclude,
  761. /* desc, NAME, name */ EXCLUDE_DESC, EXCLUDE_NAME, EXCLUDE_name,
  762. /* disablement strs */ NULL, NULL },
  763. { /* entry idx, value */ 11, VALUE_OPT_CACHEFILE,
  764. /* equiv idx, value */ 11, VALUE_OPT_CACHEFILE,
  765. /* equivalenced to */ NO_EQUIVALENT,
  766. /* min, max, act ct */ 0, 1, 0,
  767. /* opt state flags */ CACHEFILE_FLAGS, 0,
  768. /* last opt argumnt */ { NULL }, /* --cachefile */
  769. /* arg list/cookie */ NULL,
  770. /* must/cannot opts */ NULL, NULL,
  771. /* option proc */ NULL,
  772. /* desc, NAME, name */ CACHEFILE_DESC, CACHEFILE_NAME, CACHEFILE_name,
  773. /* disablement strs */ NULL, NULL },
  774. { /* entry idx, value */ 12, VALUE_OPT_PCAP,
  775. /* equiv idx, value */ 12, VALUE_OPT_PCAP,
  776. /* equivalenced to */ NO_EQUIVALENT,
  777. /* min, max, act ct */ 0, 1, 0,
  778. /* opt state flags */ PCAP_FLAGS, 0,
  779. /* last opt argumnt */ { NULL }, /* --pcap */
  780. /* arg list/cookie */ NULL,
  781. /* must/cannot opts */ NULL, NULL,
  782. /* option proc */ NULL,
  783. /* desc, NAME, name */ PCAP_DESC, PCAP_NAME, PCAP_name,
  784. /* disablement strs */ NULL, NULL },
  785. { /* entry idx, value */ 13, VALUE_OPT_PRINT_COMMENT,
  786. /* equiv idx, value */ 13, VALUE_OPT_PRINT_COMMENT,
  787. /* equivalenced to */ NO_EQUIVALENT,
  788. /* min, max, act ct */ 0, 1, 0,
  789. /* opt state flags */ PRINT_COMMENT_FLAGS, 0,
  790. /* last opt argumnt */ { NULL }, /* --print-comment */
  791. /* arg list/cookie */ NULL,
  792. /* must/cannot opts */ NULL, NULL,
  793. /* option proc */ NULL,
  794. /* desc, NAME, name */ PRINT_COMMENT_DESC, PRINT_COMMENT_NAME, PRINT_COMMENT_name,
  795. /* disablement strs */ NULL, NULL },
  796. { /* entry idx, value */ 14, VALUE_OPT_PRINT_INFO,
  797. /* equiv idx, value */ 14, VALUE_OPT_PRINT_INFO,
  798. /* equivalenced to */ NO_EQUIVALENT,
  799. /* min, max, act ct */ 0, 1, 0,
  800. /* opt state flags */ PRINT_INFO_FLAGS, 0,
  801. /* last opt argumnt */ { NULL }, /* --print-info */
  802. /* arg list/cookie */ NULL,
  803. /* must/cannot opts */ NULL, NULL,
  804. /* option proc */ NULL,
  805. /* desc, NAME, name */ PRINT_INFO_DESC, PRINT_INFO_NAME, PRINT_INFO_name,
  806. /* disablement strs */ NULL, NULL },
  807. { /* entry idx, value */ 15, VALUE_OPT_PRINT_STATS,
  808. /* equiv idx, value */ 15, VALUE_OPT_PRINT_STATS,
  809. /* equivalenced to */ NO_EQUIVALENT,
  810. /* min, max, act ct */ 0, 1, 0,
  811. /* opt state flags */ PRINT_STATS_FLAGS, 0,
  812. /* last opt argumnt */ { NULL }, /* --print-stats */
  813. /* arg list/cookie */ NULL,
  814. /* must/cannot opts */ NULL, NULL,
  815. /* option proc */ NULL,
  816. /* desc, NAME, name */ PRINT_STATS_DESC, PRINT_STATS_NAME, PRINT_STATS_name,
  817. /* disablement strs */ NULL, NULL },
  818. { /* entry idx, value */ 16, VALUE_OPT_SERVICES,
  819. /* equiv idx, value */ 16, VALUE_OPT_SERVICES,
  820. /* equivalenced to */ NO_EQUIVALENT,
  821. /* min, max, act ct */ 0, 1, 0,
  822. /* opt state flags */ SERVICES_FLAGS, 0,
  823. /* last opt argumnt */ { NULL }, /* --services */
  824. /* arg list/cookie */ NULL,
  825. /* must/cannot opts */ aServicesMustList, NULL,
  826. /* option proc */ doOptServices,
  827. /* desc, NAME, name */ SERVICES_DESC, SERVICES_NAME, SERVICES_name,
  828. /* disablement strs */ NULL, NULL },
  829. { /* entry idx, value */ 17, VALUE_OPT_NONIP,
  830. /* equiv idx, value */ 17, VALUE_OPT_NONIP,
  831. /* equivalenced to */ NO_EQUIVALENT,
  832. /* min, max, act ct */ 0, 1, 0,
  833. /* opt state flags */ NONIP_FLAGS, 0,
  834. /* last opt argumnt */ { NULL }, /* --nonip */
  835. /* arg list/cookie */ NULL,
  836. /* must/cannot opts */ NULL, NULL,
  837. /* option proc */ doOptNonip,
  838. /* desc, NAME, name */ NONIP_DESC, NONIP_NAME, NONIP_name,
  839. /* disablement strs */ NULL, NULL },
  840. { /* entry idx, value */ 18, VALUE_OPT_RATIO,
  841. /* equiv idx, value */ 18, VALUE_OPT_RATIO,
  842. /* equivalenced to */ NO_EQUIVALENT,
  843. /* min, max, act ct */ 0, 1, 0,
  844. /* opt state flags */ RATIO_FLAGS, 0,
  845. /* last opt argumnt */ { RATIO_DFT_ARG },
  846. /* arg list/cookie */ NULL,
  847. /* must/cannot opts */ aRatioMustList, NULL,
  848. /* option proc */ NULL,
  849. /* desc, NAME, name */ RATIO_DESC, RATIO_NAME, RATIO_name,
  850. /* disablement strs */ NULL, NULL },
  851. { /* entry idx, value */ 19, VALUE_OPT_MINMASK,
  852. /* equiv idx, value */ 19, VALUE_OPT_MINMASK,
  853. /* equivalenced to */ NO_EQUIVALENT,
  854. /* min, max, act ct */ 0, 1, 0,
  855. /* opt state flags */ MINMASK_FLAGS, 0,
  856. /* last opt argumnt */ { MINMASK_DFT_ARG },
  857. /* arg list/cookie */ NULL,
  858. /* must/cannot opts */ aMinmaskMustList, NULL,
  859. /* option proc */ doOptMinmask,
  860. /* desc, NAME, name */ MINMASK_DESC, MINMASK_NAME, MINMASK_name,
  861. /* disablement strs */ NULL, NULL },
  862. { /* entry idx, value */ 20, VALUE_OPT_MAXMASK,
  863. /* equiv idx, value */ 20, VALUE_OPT_MAXMASK,
  864. /* equivalenced to */ NO_EQUIVALENT,
  865. /* min, max, act ct */ 0, 1, 0,
  866. /* opt state flags */ MAXMASK_FLAGS, 0,
  867. /* last opt argumnt */ { MAXMASK_DFT_ARG },
  868. /* arg list/cookie */ NULL,
  869. /* must/cannot opts */ aMaxmaskMustList, NULL,
  870. /* option proc */ doOptMaxmask,
  871. /* desc, NAME, name */ MAXMASK_DESC, MAXMASK_NAME, MAXMASK_name,
  872. /* disablement strs */ NULL, NULL },
  873. { /* entry idx, value */ 21, VALUE_OPT_VERBOSE,
  874. /* equiv idx, value */ 21, VALUE_OPT_VERBOSE,
  875. /* equivalenced to */ NO_EQUIVALENT,
  876. /* min, max, act ct */ 0, 1, 0,
  877. /* opt state flags */ VERBOSE_FLAGS, 0,
  878. /* last opt argumnt */ { NULL }, /* --verbose */
  879. /* arg list/cookie */ NULL,
  880. /* must/cannot opts */ NULL, NULL,
  881. /* option proc */ NULL,
  882. /* desc, NAME, name */ VERBOSE_DESC, VERBOSE_NAME, VERBOSE_name,
  883. /* disablement strs */ NULL, NULL },
  884. { /* entry idx, value */ 22, VALUE_OPT_DECODE,
  885. /* equiv idx, value */ 22, VALUE_OPT_DECODE,
  886. /* equivalenced to */ NO_EQUIVALENT,
  887. /* min, max, act ct */ 0, 1, 0,
  888. /* opt state flags */ DECODE_FLAGS, 0,
  889. /* last opt argumnt */ { NULL }, /* --decode */
  890. /* arg list/cookie */ NULL,
  891. /* must/cannot opts */ aDecodeMustList, NULL,
  892. /* option proc */ NULL,
  893. /* desc, NAME, name */ DECODE_DESC, DECODE_NAME, DECODE_name,
  894. /* disablement strs */ NULL, NULL },
  895. { /* entry idx, value */ 23, VALUE_OPT_VERSION,
  896. /* equiv idx, value */ 23, VALUE_OPT_VERSION,
  897. /* equivalenced to */ NO_EQUIVALENT,
  898. /* min, max, act ct */ 0, 1, 0,
  899. /* opt state flags */ VERSION_FLAGS, 0,
  900. /* last opt argumnt */ { NULL }, /* --version */
  901. /* arg list/cookie */ NULL,
  902. /* must/cannot opts */ NULL, NULL,
  903. /* option proc */ doOptVersion,
  904. /* desc, NAME, name */ VERSION_DESC, VERSION_NAME, VERSION_name,
  905. /* disablement strs */ NULL, NULL },
  906. { /* entry idx, value */ 24, VALUE_OPT_LESS_HELP,
  907. /* equiv idx, value */ 24, VALUE_OPT_LESS_HELP,
  908. /* equivalenced to */ NO_EQUIVALENT,
  909. /* min, max, act ct */ 0, 1, 0,
  910. /* opt state flags */ LESS_HELP_FLAGS, 0,
  911. /* last opt argumnt */ { NULL }, /* --less-help */
  912. /* arg list/cookie */ NULL,
  913. /* must/cannot opts */ NULL, NULL,
  914. /* option proc */ doOptLess_Help,
  915. /* desc, NAME, name */ LESS_HELP_DESC, LESS_HELP_NAME, LESS_HELP_name,
  916. /* disablement strs */ NULL, NULL },
  917. { /* entry idx, value */ 25, VALUE_OPT_SUPPRESS_WARNINGS,
  918. /* equiv idx, value */ 25, VALUE_OPT_SUPPRESS_WARNINGS,
  919. /* equivalenced to */ NO_EQUIVALENT,
  920. /* min, max, act ct */ 0, 1, 0,
  921. /* opt state flags */ SUPPRESS_WARNINGS_FLAGS, 0,
  922. /* last opt argumnt */ { NULL }, /* --suppress-warnings */
  923. /* arg list/cookie */ NULL,
  924. /* must/cannot opts */ NULL, NULL,
  925. /* option proc */ NULL,
  926. /* desc, NAME, name */ SUPPRESS_WARNINGS_DESC, SUPPRESS_WARNINGS_NAME, SUPPRESS_WARNINGS_name,
  927. /* disablement strs */ NULL, NULL },
  928. { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
  929. /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_HELP,
  930. /* equivalenced to */ NO_EQUIVALENT,
  931. /* min, max, act ct */ 0, 1, 0,
  932. /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
  933. /* last opt argumnt */ { NULL },
  934. /* arg list/cookie */ NULL,
  935. /* must/cannot opts */ NULL, NULL,
  936. /* option proc */ doUsageOpt,
  937. /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
  938. /* disablement strs */ NULL, NULL },
  939. { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
  940. /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
  941. /* equivalenced to */ NO_EQUIVALENT,
  942. /* min, max, act ct */ 0, 1, 0,
  943. /* opt state flags */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
  944. /* last opt argumnt */ { NULL },
  945. /* arg list/cookie */ NULL,
  946. /* must/cannot opts */ NULL, NULL,
  947. /* option proc */ optionPagedUsage,
  948. /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
  949. /* disablement strs */ NULL, NULL },
  950. { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
  951. /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_SAVE_OPTS,
  952. /* equivalenced to */ NO_EQUIVALENT,
  953. /* min, max, act ct */ 0, 1, 0,
  954. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  955. | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, AOUSE_SAVE_OPTS,
  956. /* last opt argumnt */ { NULL },
  957. /* arg list/cookie */ NULL,
  958. /* must/cannot opts */ NULL, NULL,
  959. /* option proc */ NULL,
  960. /* desc, NAME, name */ SAVE_OPTS_DESC, NULL, SAVE_OPTS_name,
  961. /* disablement strs */ NULL, NULL },
  962. { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
  963. /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_LOAD_OPTS,
  964. /* equivalenced to */ NO_EQUIVALENT,
  965. /* min, max, act ct */ 0, NOLIMIT, 0,
  966. /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
  967. | OPTST_DISABLE_IMM, AOUSE_LOAD_OPTS,
  968. /* last opt argumnt */ { NULL },
  969. /* arg list/cookie */ NULL,
  970. /* must/cannot opts */ NULL, NULL,
  971. /* option proc */ optionLoadOpt,
  972. /* desc, NAME, name */ LOAD_OPTS_DESC, LOAD_OPTS_NAME, LOAD_OPTS_name,
  973. /* disablement strs */ NO_LOAD_OPTS_name, LOAD_OPTS_pfx }
  974. };
  975. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  976. /** Reference to the upper cased version of tcpprep. */
  977. #define zPROGNAME (tcpprep_opt_strs+2396)
  978. /** Reference to the title line for tcpprep usage. */
  979. #define zUsageTitle (tcpprep_opt_strs+2404)
  980. /** tcpprep configuration file name. */
  981. #define zRcName (tcpprep_opt_strs+2540)
  982. /** Directories to search for tcpprep config files. */
  983. static char const * const apzHomeList[2] = {
  984. tcpprep_opt_strs+2536,
  985. NULL };
  986. /** The tcpprep program bug email address. */
  987. #define zBugsAddr (tcpprep_opt_strs+2551)
  988. /** Clarification/explanation of what tcpprep does. */
  989. #define zExplain (tcpprep_opt_strs+2589)
  990. /** Extra detail explaining what tcpprep does. */
  991. #define zDetail (tcpprep_opt_strs+2757)
  992. /** The full version string for tcpprep. */
  993. #define zFullVersion (NULL)
  994. /* extracted from optcode.tlib near line 342 */
  995. #if defined(ENABLE_NLS)
  996. # define OPTPROC_BASE OPTPROC_TRANSLATE
  997. static tOptionXlateProc translate_option_strings;
  998. #else
  999. # define OPTPROC_BASE OPTPROC_NONE
  1000. # define translate_option_strings NULL
  1001. #endif /* ENABLE_NLS */
  1002. #define tcpprep_full_usage (NULL)
  1003. #define tcpprep_short_usage (NULL)
  1004. #endif /* not defined __doxygen__ */
  1005. /*
  1006. * Create the static procedure(s) declared above.
  1007. */
  1008. /**
  1009. * The callout function that invokes the optionUsage function.
  1010. *
  1011. * @param[in] opts the AutoOpts option description structure
  1012. * @param[in] od the descriptor for the "help" (usage) option.
  1013. * @noreturn
  1014. */
  1015. static void
  1016. doUsageOpt(tOptions * opts, tOptDesc * od)
  1017. {
  1018. int ex_code;
  1019. ex_code = TCPPREP_EXIT_SUCCESS;
  1020. optionUsage(&tcpprepOptions, ex_code);
  1021. /* NOTREACHED */
  1022. exit(TCPPREP_EXIT_FAILURE);
  1023. (void)opts;
  1024. (void)od;
  1025. }
  1026. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1027. /**
  1028. * Code to handle the dbug option, when DEBUG is #define-d.
  1029. * If configured with --enable-debug, then you can specify a verbosity
  1030. * level for debugging output. Higher numbers increase verbosity.
  1031. * @param[in] pOptions the tcpprep options data structure
  1032. * @param[in,out] pOptDesc the option descriptor for this option.
  1033. */
  1034. #ifdef DEBUG
  1035. static void
  1036. doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc)
  1037. {
  1038. static struct {long rmin, rmax;} const rng[1] = {
  1039. { 0, 5 } };
  1040. int ix;
  1041. if (pOptions <= OPTPROC_EMIT_LIMIT)
  1042. goto emit_ranges;
  1043. optionNumericVal(pOptions, pOptDesc);
  1044. for (ix = 0; ix < 1; ix++) {
  1045. if (pOptDesc->optArg.argInt < rng[ix].rmin)
  1046. continue; /* ranges need not be ordered. */
  1047. if (pOptDesc->optArg.argInt == rng[ix].rmin)
  1048. return;
  1049. if (rng[ix].rmax == LONG_MIN)
  1050. continue;
  1051. if (pOptDesc->optArg.argInt <= rng[ix].rmax)
  1052. return;
  1053. }
  1054. option_usage_fp = stderr;
  1055. emit_ranges:
  1056. optionShowRange(pOptions, pOptDesc, VOIDP(rng), 1);
  1057. }
  1058. #endif /* defined DEBUG */
  1059. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1060. /**
  1061. * Code to handle the auto option.
  1062. * Tcpprep will try to automatically determine the primary function of hosts
  1063. * based on the traffic captured and classify each host as client or server.
  1064. * In order to do so, you must provide a hint to tcpprep as to how to search
  1065. * for clients and servers. Valid hints are:
  1066. *
  1067. * @table @bullet
  1068. * @item
  1069. * @var{bridge}
  1070. * Bridge mode processes each packet to try to determine if the sender is a
  1071. * client or server. Once all the packets are processed, the results are weighed
  1072. * according to the server/client ratio (@samp{--ratio}) and systems are assigned an
  1073. * interface. If tcpprep is unable to determine what role a system plays, tcpprep
  1074. * will abort.
  1075. * @item
  1076. * @var{router}
  1077. * Router mode works just like bridge mode, except that after weighing is done,
  1078. * systems which are undetermined are considered a server if they fall inside a
  1079. * network known to contain other servers. Router has a greater chance of
  1080. * successfully splitting clients and servers but is not 100% foolproof.
  1081. * @item
  1082. * @var{client}
  1083. * Client mode works just like bridge mode, except that unclassified systems are
  1084. * treated as clients. Client mode should always complete successfully.
  1085. * @item
  1086. * @var{server}
  1087. * Server mode works just like bridge mode, except that unclassified systems are
  1088. * treated as servers. Server mode should always complete successfully.
  1089. * @item
  1090. * @var{first}
  1091. * First mode works by looking at the first time each IP is seen in the SRC and DST
  1092. * fields in the IP header. If the host is first seen in the SRC field, it is a
  1093. * client and if it's first seen in the DST field, it is marked as a server. This
  1094. * effectively replicates the processing of the tomahawk test tool. First
  1095. * mode should always complete successfully.
  1096. * @end table
  1097. * @param[in] pOptions the tcpprep options data structure
  1098. * @param[in,out] pOptDesc the option descriptor for this option.
  1099. */
  1100. static void
  1101. doOptAuto(tOptions* pOptions, tOptDesc* pOptDesc)
  1102. {
  1103. /*
  1104. * Be sure the flag-code[0] handles special values for the options pointer
  1105. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1106. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1107. * reset its state.
  1108. */
  1109. /* extracted from tcpprep_opts.def, line 113 */
  1110. tcpprep->options->mode = AUTO_MODE;
  1111. if (strcmp(OPT_ARG(AUTO), "bridge") == 0) {
  1112. tcpprep->options->automode = BRIDGE_MODE;
  1113. }
  1114. else if (strcmp(OPT_ARG(AUTO), "router") == 0) {
  1115. tcpprep->options->automode = ROUTER_MODE;
  1116. }
  1117. else if (strcmp(OPT_ARG(AUTO), "client") == 0) {
  1118. tcpprep->options->automode = CLIENT_MODE;
  1119. }
  1120. else if (strcmp(OPT_ARG(AUTO), "server") == 0) {
  1121. tcpprep->options->automode = SERVER_MODE;
  1122. }
  1123. else if (strcmp(OPT_ARG(AUTO), "first") == 0) {
  1124. tcpprep->options->automode = FIRST_MODE;
  1125. }
  1126. else {
  1127. errx(-1, "Invalid auto mode type: %s", OPT_ARG(AUTO));
  1128. }
  1129. (void)pOptDesc;
  1130. (void)pOptions;
  1131. }
  1132. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1133. /**
  1134. * Code to handle the cidr option.
  1135. * Specify a comma delimited list of CIDR netblocks to match against
  1136. * the source IP of each packet. Packets matching any of the CIDR's
  1137. * are classified as servers.
  1138. *
  1139. * IPv4 Example:
  1140. * @example
  1141. * --cidr=192.168.0.0/16,172.16.0.0/12,10.0.0.0/8
  1142. * @end example
  1143. * IPv6 Example:
  1144. * @example
  1145. * --cidr=[::ffff:0:0/96],[fe80::/16]
  1146. * @end example
  1147. * @param[in] pOptions the tcpprep options data structure
  1148. * @param[in,out] pOptDesc the option descriptor for this option.
  1149. */
  1150. static void
  1151. doOptCidr(tOptions* pOptions, tOptDesc* pOptDesc)
  1152. {
  1153. /*
  1154. * Be sure the flag-code[0] handles special values for the options pointer
  1155. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1156. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1157. * reset its state.
  1158. */
  1159. /* extracted from tcpprep_opts.def, line 185 */
  1160. char *cidr = safe_strdup(OPT_ARG(CIDR));
  1161. tcpprep->options->mode = CIDR_MODE;
  1162. if (!parse_cidr(&tcpprep->options->cidrdata, cidr, ","))
  1163. errx(-1, "Unable to parse CIDR map: %s", OPT_ARG(CIDR));
  1164. free(cidr);
  1165. (void)pOptDesc;
  1166. (void)pOptions;
  1167. }
  1168. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1169. /**
  1170. * Code to handle the regex option.
  1171. * Specify a regular expression to match against the source IP of each
  1172. * packet. Packets matching the regex are classified as servers.
  1173. * @param[in] pOptions the tcpprep options data structure
  1174. * @param[in,out] pOptDesc the option descriptor for this option.
  1175. */
  1176. static void
  1177. doOptRegex(tOptions* pOptions, tOptDesc* pOptDesc)
  1178. {
  1179. /*
  1180. * Be sure the flag-code[0] handles special values for the options pointer
  1181. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1182. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1183. * reset its state.
  1184. */
  1185. /* extracted from tcpprep_opts.def, line 220 */
  1186. int regex_error;
  1187. char ebuf[EBUF_SIZE];
  1188. tcpprep->options->mode = REGEX_MODE;
  1189. if ((regex_error = regcomp(&tcpprep->options->preg, OPT_ARG(REGEX),
  1190. REG_EXTENDED|REG_NOSUB))) {
  1191. regerror(regex_error, &tcpprep->options->preg, ebuf, EBUF_SIZE);
  1192. errx(-1, "Unable to compile regex: %s", ebuf);
  1193. }
  1194. (void)pOptDesc;
  1195. (void)pOptions;
  1196. }
  1197. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1198. /**
  1199. * Code to handle the port option.
  1200. * Specifies that TCP and UDP traffic over IPv4 and IPv6 should be classified
  1201. * as client or server based upon the destination port of the header.
  1202. * @param[in] pOptions the tcpprep options data structure
  1203. * @param[in,out] pOptDesc the option descriptor for this option.
  1204. */
  1205. static void
  1206. doOptPort(tOptions* pOptions, tOptDesc* pOptDesc)
  1207. {
  1208. /*
  1209. * Be sure the flag-code[0] handles special values for the options pointer
  1210. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1211. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1212. * reset its state.
  1213. */
  1214. /* extracted from tcpprep_opts.def, line 248 */
  1215. tcpprep->options->mode = PORT_MODE;
  1216. (void)pOptDesc;
  1217. (void)pOptions;
  1218. }
  1219. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1220. /**
  1221. * Code to handle the mac option.
  1222. * Specify a list of MAC addresses to match against the source MAC
  1223. * of each packet. Packets matching one of the values are classified
  1224. * as servers.
  1225. * @param[in] pOptions the tcpprep options data structure
  1226. * @param[in,out] pOptDesc the option descriptor for this option.
  1227. */
  1228. static void
  1229. doOptMac(tOptions* pOptions, tOptDesc* pOptDesc)
  1230. {
  1231. /*
  1232. * Be sure the flag-code[0] handles special values for the options pointer
  1233. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1234. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1235. * reset its state.
  1236. */
  1237. /* extracted from tcpprep_opts.def, line 269 */
  1238. tcpprep->options->mode = MAC_MODE;
  1239. tcpprep->options->maclist = safe_strdup(OPT_ARG(MAC));
  1240. (void)pOptDesc;
  1241. (void)pOptions;
  1242. }
  1243. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1244. /**
  1245. * Code to handle the comment option.
  1246. * Specify a comment to be imbedded within the output cache file and later
  1247. * viewed.
  1248. * @param[in] pOptions the tcpprep options data structure
  1249. * @param[in,out] pOptDesc the option descriptor for this option.
  1250. */
  1251. static void
  1252. doOptComment(tOptions* pOptions, tOptDesc* pOptDesc)
  1253. {
  1254. /*
  1255. * Be sure the flag-code[0] handles special values for the options pointer
  1256. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1257. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1258. * reset its state.
  1259. */
  1260. /* extracted from tcpprep_opts.def, line 300 */
  1261. /* our comment_len is only 16bit - myargs[] */
  1262. if (strlen(OPT_ARG(COMMENT)) > ((1 << 16) - 1 - MYARGS_LEN))
  1263. errx(-1, "Comment length %zu is longer then max allowed (%d)",
  1264. strlen(OPT_ARG(COMMENT)), (1 << 16) - 1 - MYARGS_LEN);
  1265. /* save the comment */
  1266. tcpprep->options->comment = (char *)safe_malloc(strlen(OPT_ARG(COMMENT)) + 1);
  1267. strcpy(tcpprep->options->comment, OPT_ARG(COMMENT));
  1268. (void)pOptDesc;
  1269. (void)pOptions;
  1270. }
  1271. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1272. /**
  1273. * Code to handle the no-arg-comment option.
  1274. * By default, tcpprep includes the arguments passed on the command line
  1275. * in the cache file comment (in addition to any user specified --comment).
  1276. * If for some reason you do not wish to include this, specify this option.
  1277. * @param[in] pOptions the tcpprep options data structure
  1278. * @param[in,out] pOptDesc the option descriptor for this option.
  1279. */
  1280. static void
  1281. doOptNo_Arg_Comment(tOptions* pOptions, tOptDesc* pOptDesc)
  1282. {
  1283. /*
  1284. * Be sure the flag-code[0] handles special values for the options pointer
  1285. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1286. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1287. * reset its state.
  1288. */
  1289. /* extracted from tcpprep_opts.def, line 322 */
  1290. tcpprep->options->nocomment = 1;
  1291. (void)pOptDesc;
  1292. (void)pOptions;
  1293. }
  1294. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1295. /**
  1296. * Code to handle the include option.
  1297. * Override default of processing all packets stored in the capture file and only
  1298. * send/edit packets which match the provided rule. Rules can be one of:
  1299. *
  1300. * @table @bullet
  1301. * @item S:<CIDR1>,...
  1302. * - Source IP must match specified IPv4/v6 CIDR(s)
  1303. * @item D:<CIDR1>,...
  1304. * - Destination IP must match specified IPv4/v6 CIDR(s)
  1305. * @item B:<CIDR1>,...
  1306. * - Both source and destination IP must match specified IPv4/v6 CIDR(s)
  1307. * @item E:<CIDR1>,...
  1308. * - Either IP must match specified IPv4/v6 CIDR(s)
  1309. * @item P:<LIST>
  1310. * - Must be one of the listed packets where the list
  1311. * corresponds to the packet number in the capture file.
  1312. * @example
  1313. * -x P:1-5,9,15,72-
  1314. * @end example
  1315. * would process packets 1 through 5, the 9th and 15th packet, and packets 72 until the
  1316. * end of the file
  1317. * @item F:'<bpf>'
  1318. * - BPF filter. See the @file{tcpdump(8)} man page for syntax.
  1319. * @end table
  1320. * @param[in] pOptions the tcpprep options data structure
  1321. * @param[in,out] pOptDesc the option descriptor for this option.
  1322. */
  1323. static void
  1324. doOptInclude(tOptions* pOptions, tOptDesc* pOptDesc)
  1325. {
  1326. /*
  1327. * Be sure the flag-code[0] handles special values for the options pointer
  1328. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1329. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1330. * reset its state.
  1331. */
  1332. /* extracted from tcpprep_opts.def, line 342 */
  1333. char *include;
  1334. include = safe_strdup(OPT_ARG(INCLUDE));
  1335. tcpprep->options->xX.mode = xX_MODE_INCLUDE;
  1336. if ((tcpprep->options->xX.mode = parse_xX_str(&tcpprep->options->xX, include, &tcpprep->options->bpf)) == xXError)
  1337. errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE));
  1338. free(include);
  1339. (void)pOptDesc;
  1340. (void)pOptions;
  1341. }
  1342. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1343. /**
  1344. * Code to handle the exclude option.
  1345. * Override default of processing all packets stored in the capture file and only
  1346. * send/edit packets which do NOT match the provided rule. Rules can be one of:
  1347. *
  1348. * @table @bullet
  1349. * @item S:<CIDR1>,...
  1350. * - Source IP must not match specified IPv4/v6 CIDR(s)
  1351. * @item D:<CIDR1>,...
  1352. * - Destination IP must not match specified IPv4/v6 CIDR(s)
  1353. * @item B:<CIDR1>,...
  1354. * - Both source and destination IP must not match specified IPv4/v6 CIDR(s)
  1355. * @item E:<CIDR1>,...
  1356. * - Either IP must not match specified IPv4/v6 CIDR(s)
  1357. * @item P:<LIST>
  1358. * - Must not be one of the listed packets where the list
  1359. * corresponds to the packet number in the capture file.
  1360. * @example
  1361. * -x P:1-5,9,15,72-
  1362. * @end example
  1363. * would skip packets 1 through 5, the 9th and 15th packet, and packets 72 until the
  1364. * end of the file
  1365. * @end table
  1366. * @param[in] pOptions the tcpprep options data structure
  1367. * @param[in,out] pOptDesc the option descriptor for this option.
  1368. */
  1369. static void
  1370. doOptExclude(tOptions* pOptions, tOptDesc* pOptDesc)
  1371. {
  1372. /*
  1373. * Be sure the flag-code[0] handles special values for the options pointer
  1374. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1375. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1376. * reset its state.
  1377. */
  1378. /* extracted from tcpprep_opts.def, line 389 */
  1379. char *exclude;
  1380. exclude = safe_strdup(OPT_ARG(EXCLUDE));
  1381. tcpprep->options->xX.mode = xX_MODE_EXCLUDE;
  1382. if ((tcpprep->options->xX.mode = parse_xX_str(&tcpprep->options->xX, exclude, &tcpprep->options->bpf)) == xXError)
  1383. errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE));
  1384. free(exclude);
  1385. (void)pOptDesc;
  1386. (void)pOptions;
  1387. }
  1388. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1389. /**
  1390. * Code to handle the services option.
  1391. * Uses a list of ports used by servers in the same format as of /etc/services:
  1392. * <service_name> <port>/<protocol> # comment
  1393. *
  1394. * Example:
  1395. * http 80/tcp
  1396. * @param[in] pOptions the tcpprep options data structure
  1397. * @param[in,out] pOptDesc the option descriptor for this option.
  1398. */
  1399. static void
  1400. doOptServices(tOptions* pOptions, tOptDesc* pOptDesc)
  1401. {
  1402. /*
  1403. * Be sure the flag-code[0] handles special values for the options pointer
  1404. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1405. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1406. * reset its state.
  1407. */
  1408. /* extracted from tcpprep_opts.def, line 486 */
  1409. parse_services(OPT_ARG(SERVICES), &tcpprep->options->services);
  1410. (void)pOptDesc;
  1411. (void)pOptions;
  1412. }
  1413. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1414. /**
  1415. * Code to handle the nonip option.
  1416. * By default, non-IP traffic which can not be classified as client
  1417. * or server is classified as "client". Specifying @samp{--nonip}
  1418. * will reclassify non-IP traffic as "server". Note that the meaning
  1419. * of this flag is reversed if @samp{--reverse} is used.
  1420. * @param[in] pOptions the tcpprep options data structure
  1421. * @param[in,out] pOptDesc the option descriptor for this option.
  1422. */
  1423. static void
  1424. doOptNonip(tOptions* pOptions, tOptDesc* pOptDesc)
  1425. {
  1426. /*
  1427. * Be sure the flag-code[0] handles special values for the options pointer
  1428. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1429. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1430. * reset its state.
  1431. */
  1432. /* extracted from tcpprep_opts.def, line 497 */
  1433. tcpprep->options->nonip = DIR_SERVER;
  1434. (void)pOptDesc;
  1435. (void)pOptions;
  1436. }
  1437. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1438. /**
  1439. * Code to handle the minmask option.
  1440. * By default, auto modes use a minimum network mask length of 30 bits
  1441. * to build networks containing clients and servers. This allows you
  1442. * to override this value. Larger values will increase performance but
  1443. * may provide inaccurate results.
  1444. * @param[in] pOptions the tcpprep options data structure
  1445. * @param[in,out] pOptDesc the option descriptor for this option.
  1446. */
  1447. static void
  1448. doOptMinmask(tOptions* pOptions, tOptDesc* pOptDesc)
  1449. {
  1450. static struct {long rmin, rmax;} const rng[1] = {
  1451. { 0, 32 } };
  1452. int ix;
  1453. if (pOptions <= OPTPROC_EMIT_LIMIT)
  1454. goto emit_ranges;
  1455. optionNumericVal(pOptions, pOptDesc);
  1456. for (ix = 0; ix < 1; ix++) {
  1457. if (pOptDesc->optArg.argInt < rng[ix].rmin)
  1458. continue; /* ranges need not be ordered. */
  1459. if (pOptDesc->optArg.argInt == rng[ix].rmin)
  1460. return;
  1461. if (rng[ix].rmax == LONG_MIN)
  1462. continue;
  1463. if (pOptDesc->optArg.argInt <= rng[ix].rmax)
  1464. return;
  1465. }
  1466. option_usage_fp = stderr;
  1467. emit_ranges:
  1468. optionShowRange(pOptions, pOptDesc, VOIDP(rng), 1);
  1469. }
  1470. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1471. /**
  1472. * Code to handle the maxmask option.
  1473. * By default, auto modes use a maximum network mask length of 8 bits
  1474. * to build networks containing clients and servers. This allows you
  1475. * to override this value. Larger values will decrease performance
  1476. * and accuracy but will provide greater chance of success.
  1477. * @param[in] pOptions the tcpprep options data structure
  1478. * @param[in,out] pOptDesc the option descriptor for this option.
  1479. */
  1480. static void
  1481. doOptMaxmask(tOptions* pOptions, tOptDesc* pOptDesc)
  1482. {
  1483. static struct {long rmin, rmax;} const rng[1] = {
  1484. { 0, 32 } };
  1485. int ix;
  1486. if (pOptions <= OPTPROC_EMIT_LIMIT)
  1487. goto emit_ranges;
  1488. optionNumericVal(pOptions, pOptDesc);
  1489. for (ix = 0; ix < 1; ix++) {
  1490. if (pOptDesc->optArg.argInt < rng[ix].rmin)
  1491. continue; /* ranges need not be ordered. */
  1492. if (pOptDesc->optArg.argInt == rng[ix].rmin)
  1493. return;
  1494. if (rng[ix].rmax == LONG_MIN)
  1495. continue;
  1496. if (pOptDesc->optArg.argInt <= rng[ix].rmax)
  1497. return;
  1498. }
  1499. option_usage_fp = stderr;
  1500. emit_ranges:
  1501. optionShowRange(pOptions, pOptDesc, VOIDP(rng), 1);
  1502. }
  1503. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1504. /**
  1505. * Code to handle the version option.
  1506. *
  1507. * @param[in] pOptions the tcpprep options data structure
  1508. * @param[in,out] pOptDesc the option descriptor for this option.
  1509. */
  1510. static void
  1511. doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc)
  1512. {
  1513. /*
  1514. * Be sure the flag-code[0] handles special values for the options pointer
  1515. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1516. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1517. * reset its state.
  1518. */
  1519. /* extracted from tcpprep_opts.def, line 598 */
  1520. fprintf(stderr, "tcpprep version: %s (build %s)", VERSION, git_version());
  1521. #ifdef DEBUG
  1522. fprintf(stderr, " (debug)");
  1523. #endif
  1524. fprintf(stderr, "\n");
  1525. fprintf(stderr, "Copyright 2013-2024 by Fred Klassen <tcpreplay at appneta dot com> - AppNeta\n");
  1526. fprintf(stderr, "Copyright 2000-2012 by Aaron Turner <aturner at synfin dot net>\n");
  1527. fprintf(stderr, "The entire Tcpreplay Suite is licensed under the GPLv3\n");
  1528. fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION);
  1529. #ifdef HAVE_LIBDNET
  1530. fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION);
  1531. #else
  1532. fprintf(stderr, "Not compiled with libdnet.\n");
  1533. #endif
  1534. #ifdef HAVE_WINPCAP
  1535. fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
  1536. #elif defined HAVE_PF_RING_PCAP
  1537. fprintf(stderr, "Compiled against PF_RING libpcap: %s\n", get_pcap_version());
  1538. #else
  1539. fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
  1540. #endif
  1541. #ifdef ENABLE_64BITS
  1542. fprintf(stderr, "64 bit packet counters: enabled\n");
  1543. #else
  1544. fprintf(stderr, "64 bit packet counters: disabled\n");
  1545. #endif
  1546. #ifdef ENABLE_VERBOSE
  1547. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  1548. #else
  1549. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  1550. #endif
  1551. exit(0);
  1552. (void)pOptDesc;
  1553. (void)pOptions;
  1554. }
  1555. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1556. /**
  1557. * Code to handle the less-help option.
  1558. *
  1559. * @param[in] pOptions the tcpprep options data structure
  1560. * @param[in,out] pOptDesc the option descriptor for this option.
  1561. */
  1562. static void
  1563. doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc)
  1564. {
  1565. /*
  1566. * Be sure the flag-code[0] handles special values for the options pointer
  1567. * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
  1568. * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
  1569. * reset its state.
  1570. */
  1571. /* extracted from tcpprep_opts.def, line 642 */
  1572. USAGE(EXIT_FAILURE);
  1573. (void)pOptDesc;
  1574. (void)pOptions;
  1575. }
  1576. /* extracted from optmain.tlib near line 1250 */
  1577. /**
  1578. * The directory containing the data associated with tcpprep.
  1579. */
  1580. #ifndef PKGDATADIR
  1581. # define PKGDATADIR ""
  1582. #endif
  1583. /**
  1584. * Information about the person or institution that packaged tcpprep
  1585. * for the current distribution.
  1586. */
  1587. #ifndef WITH_PACKAGER
  1588. # define tcpprep_packager_info NULL
  1589. #else
  1590. /** Packager information for tcpprep. */
  1591. static char const tcpprep_packager_info[] =
  1592. "Packaged by " WITH_PACKAGER
  1593. # ifdef WITH_PACKAGER_VERSION
  1594. " ("WITH_PACKAGER_VERSION")"
  1595. # endif
  1596. # ifdef WITH_PACKAGER_BUG_REPORTS
  1597. "\nReport tcpprep bugs to " WITH_PACKAGER_BUG_REPORTS
  1598. # endif
  1599. "\n";
  1600. #endif
  1601. #ifndef __doxygen__
  1602. #endif /* __doxygen__ */
  1603. /**
  1604. * The option definitions for tcpprep. The one structure that
  1605. * binds them all.
  1606. */
  1607. tOptions tcpprepOptions = {
  1608. OPTIONS_STRUCT_VERSION,
  1609. 0, NULL, /* original argc + argv */
  1610. ( OPTPROC_BASE
  1611. + OPTPROC_ERRSTOP
  1612. + OPTPROC_SHORTOPT
  1613. + OPTPROC_LONGOPT
  1614. + OPTPROC_NO_REQ_OPT
  1615. + OPTPROC_NO_ARGS
  1616. + OPTPROC_GNUUSAGE ),
  1617. 0, NULL, /* current option index, current option */
  1618. NULL, NULL, zPROGNAME,
  1619. zRcName, zCopyright, zLicenseDescrip,
  1620. zFullVersion, apzHomeList, zUsageTitle,
  1621. zExplain, zDetail, optDesc,
  1622. zBugsAddr, /* address to send bugs to */
  1623. NULL, NULL, /* extensions/saved state */
  1624. optionUsage, /* usage procedure */
  1625. translate_option_strings, /* translation procedure */
  1626. /*
  1627. * Indexes to special options
  1628. */
  1629. { INDEX_OPT_MORE_HELP, /* more-help option index */
  1630. INDEX_OPT_SAVE_OPTS, /* save option index */
  1631. NO_EQUIVALENT, /* '-#' option index */
  1632. NO_EQUIVALENT /* index of default opt */
  1633. },
  1634. 30 /* full option count */, 26 /* user option count */,
  1635. tcpprep_full_usage, tcpprep_short_usage,
  1636. NULL, NULL,
  1637. PKGDATADIR, tcpprep_packager_info
  1638. };
  1639. #if ENABLE_NLS
  1640. /**
  1641. * This code is designed to translate translatable option text for the
  1642. * tcpprep program. These translations happen upon entry
  1643. * to optionProcess().
  1644. */
  1645. #include <stdio.h>
  1646. #include <stdlib.h>
  1647. #include <string.h>
  1648. #include <unistd.h>
  1649. #ifdef HAVE_DCGETTEXT
  1650. # include <gettext.h>
  1651. #endif
  1652. #include <autoopts/usage-txt.h>
  1653. static char * AO_gettext(char const * pz);
  1654. static void coerce_it(void ** s);
  1655. /**
  1656. * AutoGen specific wrapper function for gettext. It relies on the macro _()
  1657. * to convert from English to the target language, then strdup-duplicates the
  1658. * result string. It tries the "libopts" domain first, then whatever has been
  1659. * set via the \a textdomain(3) call.
  1660. *
  1661. * @param[in] pz the input text used as a lookup key.
  1662. * @returns the translated text (if there is one),
  1663. * or the original text (if not).
  1664. */
  1665. static char *
  1666. AO_gettext(char const * pz)
  1667. {
  1668. char * res;
  1669. if (pz == NULL)
  1670. return NULL;
  1671. #ifdef HAVE_DCGETTEXT
  1672. /*
  1673. * While processing the option_xlateable_txt data, try to use the
  1674. * "libopts" domain. Once we switch to the option descriptor data,
  1675. * do *not* use that domain.
  1676. */
  1677. if (option_xlateable_txt.field_ct != 0) {
  1678. res = dgettext("libopts", pz);
  1679. if (res == pz)
  1680. res = (char *)VOIDP(_(pz));
  1681. } else
  1682. res = (char *)VOIDP(_(pz));
  1683. #else
  1684. res = (char *)VOIDP(_(pz));
  1685. #endif
  1686. if (res == pz)
  1687. return res;
  1688. res = strdup(res);
  1689. if (res == NULL) {
  1690. fputs(_("No memory for duping translated strings\n"), stderr);
  1691. exit(TCPPREP_EXIT_FAILURE);
  1692. }
  1693. return res;
  1694. }
  1695. /**
  1696. * All the pointers we use are marked "* const", but they are stored in
  1697. * writable memory. Coerce the mutability and set the pointer.
  1698. */
  1699. static void coerce_it(void ** s) { *s = AO_gettext(*s);
  1700. }
  1701. /**
  1702. * Translate all the translatable strings in the tcpprepOptions
  1703. * structure defined above. This is done only once.
  1704. */
  1705. static void
  1706. translate_option_strings(void)
  1707. {
  1708. tOptions * const opts = &tcpprepOptions;
  1709. /*
  1710. * Guard against re-translation. It won't work. The strings will have
  1711. * been changed by the first pass through this code. One shot only.
  1712. */
  1713. if (option_xlateable_txt.field_ct != 0) {
  1714. /*
  1715. * Do the translations. The first pointer follows the field count
  1716. * field. The field count field is the size of a pointer.
  1717. */
  1718. char ** ppz = (char**)VOIDP(&(option_xlateable_txt));
  1719. int ix = option_xlateable_txt.field_ct;
  1720. do {
  1721. ppz++; /* skip over field_ct */
  1722. *ppz = AO_gettext(*ppz);
  1723. } while (--ix > 0);
  1724. /* prevent re-translation and disable "libopts" domain lookup */
  1725. option_xlateable_txt.field_ct = 0;
  1726. coerce_it(VOIDP(&(opts->pzCopyright)));
  1727. coerce_it(VOIDP(&(opts->pzCopyNotice)));
  1728. coerce_it(VOIDP(&(opts->pzFullVersion)));
  1729. coerce_it(VOIDP(&(opts->pzUsageTitle)));
  1730. coerce_it(VOIDP(&(opts->pzExplain)));
  1731. coerce_it(VOIDP(&(opts->pzDetail)));
  1732. {
  1733. tOptDesc * od = opts->pOptDesc;
  1734. for (ix = opts->optCt; ix > 0; ix--, od++)
  1735. coerce_it(VOIDP(&(od->pzText)));
  1736. }
  1737. }
  1738. }
  1739. #endif /* ENABLE_NLS */
  1740. #ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
  1741. /** I18N function strictly for xgettext. Do not compile. */
  1742. static void bogus_function(void) {
  1743. /* TRANSLATORS:
  1744. The following dummy function was crated solely so that xgettext can
  1745. extract the correct strings. These strings are actually referenced
  1746. by a field name in the tcpprepOptions structure noted in the
  1747. comments below. The literal text is defined in tcpprep_opt_strs.
  1748. NOTE: the strings below are segmented with respect to the source string
  1749. tcpprep_opt_strs. The strings above are handed off for translation
  1750. at run time a paragraph at a time. Consequently, they are presented here
  1751. for translation a paragraph at a time.
  1752. ALSO: often the description for an option will reference another option
  1753. by name. These are set off with apostrophe quotes (I hope). Do not
  1754. translate option names.
  1755. */
  1756. /* referenced via tcpprepOptions.pzCopyright */
  1757. puts(_("tcpprep (tcpprep)\n\
  1758. Copyright (C) 2000-2024 Aaron Turner and Fred Klassen, all rights reserved.\n\
  1759. This is free software. It is licensed for use, modification and\n\
  1760. redistribution under the terms of the GNU General Public License,\n\
  1761. version 3 or later <http://gnu.org/licenses/gpl.html>\n"));
  1762. /* referenced via tcpprepOptions.pzCopyNotice */
  1763. puts(_("tcpprep is free software: you can redistribute it and/or modify it under\n\
  1764. the terms of the GNU General Public License as published by the Free\n\
  1765. Software Foundation, either version 3 of the License, or (at your option)\n\
  1766. any later version.\n\n"));
  1767. puts(_("tcpprep is distributed in the hope that it will be useful, but WITHOUT ANY\n\
  1768. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n\
  1769. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n\
  1770. details.\n\n"));
  1771. puts(_("You should have received a copy of the GNU General Public License along\n\
  1772. with this program. If not, see <http://www.gnu.org/licenses/>.\n"));
  1773. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1774. puts(_("Enable debugging output"));
  1775. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1776. puts(_("Auto-split mode"));
  1777. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1778. puts(_("CIDR-split mode"));
  1779. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1780. puts(_("Regex-split mode"));
  1781. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1782. puts(_("Port-split mode"));
  1783. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1784. puts(_("Source MAC split mode"));
  1785. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1786. puts(_("Matches to be client instead of server"));
  1787. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1788. puts(_("Embedded cache file comment"));
  1789. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1790. puts(_("Do not embed any cache file comment"));
  1791. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1792. puts(_("Include only packets matching rule"));
  1793. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1794. puts(_("Exclude any packet matching this rule"));
  1795. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1796. puts(_("Output cache file"));
  1797. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1798. puts(_("Input pcap file to process"));
  1799. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1800. puts(_("Print embedded comment in the specified cache file"));
  1801. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1802. puts(_("Print basic info from the specified cache file"));
  1803. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1804. puts(_("Print statistical information about the specified cache file"));
  1805. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1806. puts(_("Load services file for server ports"));
  1807. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1808. puts(_("Send non-IP traffic out server interface"));
  1809. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1810. puts(_("Ratio of client to server packets"));
  1811. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1812. puts(_("Minimum network mask length in auto mode"));
  1813. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1814. puts(_("Maximum network mask length in auto mode"));
  1815. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1816. puts(_("Print decoded packets via tcpdump to STDOUT"));
  1817. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1818. puts(_("Arguments passed to tcpdump decoder"));
  1819. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1820. puts(_("Print version information"));
  1821. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1822. puts(_("Display less usage information and exit"));
  1823. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1824. puts(_("suppress printing warning messages"));
  1825. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1826. puts(_("display extended usage information and exit"));
  1827. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1828. puts(_("extended usage information passed thru pager"));
  1829. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1830. puts(_("save the option state to a config file"));
  1831. /* referenced via tcpprepOptions.pOptDesc->pzText */
  1832. puts(_("load options from a config file"));
  1833. /* referenced via tcpprepOptions.pzUsageTitle */
  1834. puts(_("tcpprep (tcpprep) - Create a tcpreplay cache cache file from a pcap file.\n\
  1835. Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
  1836. /* referenced via tcpprepOptions.pzExplain */
  1837. puts(_("tcpprep is a 'pcap(3)' file pre-processor which creates a cache file which\n\
  1838. provides \"rules\" for 'tcprewrite(1)' and 'tcpreplay(1)' on how to process\n\
  1839. and send packets.\n"));
  1840. /* referenced via tcpprepOptions.pzDetail */
  1841. puts(_("The basic operation of tcpreplay is to resend all packets from the input\n\
  1842. file(s) out a single file. Tcpprep processes a pcap file and applies a set\n\
  1843. of user-specified rules to create a cache file which tells tcpreplay\n\
  1844. whether or not to send each packet and which interface the packet should be\n\
  1845. sent out of.\n\n"));
  1846. puts(_("For more details, please see the Tcpreplay Manual at:\n\
  1847. http://tcpreplay.appneta.com\n"));
  1848. /* referenced via tcpprepOptions.pzFullUsage */
  1849. puts(_("<<<NOT-FOUND>>>"));
  1850. /* referenced via tcpprepOptions.pzShortUsage */
  1851. puts(_("<<<NOT-FOUND>>>"));
  1852. /* LIBOPTS-MESSAGES: */
  1853. #line 67 "../autoopts.c"
  1854. puts(_("allocation of %d bytes failed\n"));
  1855. #line 89 "../autoopts.c"
  1856. puts(_("allocation of %d bytes failed\n"));
  1857. #line 48 "../init.c"
  1858. puts(_("AutoOpts function called without option descriptor\n"));
  1859. #line 81 "../init.c"
  1860. puts(_("\tThis exceeds the compiled library version: "));
  1861. #line 79 "../init.c"
  1862. puts(_("Automated Options Processing Error!\n"
  1863. "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
  1864. #line 78 "../autoopts.c"
  1865. puts(_("realloc of %d bytes at 0x%p failed\n"));
  1866. #line 83 "../init.c"
  1867. puts(_("\tThis is less than the minimum library version: "));
  1868. #line 121 "../version.c"
  1869. puts(_("Automated Options version %s\n"
  1870. "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n"));
  1871. #line 49 "../makeshell.c"
  1872. puts(_("(AutoOpts bug): %s.\n"));
  1873. #line 90 "../reset.c"
  1874. puts(_("optionResetOpt() called, but reset-option not configured"));
  1875. #line 241 "../usage.c"
  1876. puts(_("could not locate the 'help' option"));
  1877. #line 330 "../autoopts.c"
  1878. puts(_("optionProcess() was called with invalid data"));
  1879. #line 697 "../usage.c"
  1880. puts(_("invalid argument type specified"));
  1881. #line 568 "../find.c"
  1882. puts(_("defaulted to option with optional arg"));
  1883. #line 76 "../alias.c"
  1884. puts(_("aliasing option is out of range."));
  1885. #line 210 "../enum.c"
  1886. puts(_("%s error: the keyword '%s' is ambiguous for %s\n"));
  1887. #line 78 "../find.c"
  1888. puts(_(" The following options match:\n"));
  1889. #line 263 "../find.c"
  1890. puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
  1891. #line 161 "../check.c"
  1892. puts(_("%s: Command line arguments required\n"));
  1893. #line 43 "../alias.c"
  1894. puts(_("%d %s%s options allowed\n"));
  1895. #line 56 "../makeshell.c"
  1896. puts(_("%s error %d (%s) calling %s for '%s'\n"));
  1897. #line 268 "../makeshell.c"
  1898. puts(_("interprocess pipe"));
  1899. #line 171 "../version.c"
  1900. puts(_("error: version option argument '%c' invalid. Use:\n"
  1901. "\t'v' - version only\n"
  1902. "\t'c' - version and copyright\n"
  1903. "\t'n' - version and full copyright notice\n"));
  1904. #line 58 "../check.c"
  1905. puts(_("%s error: the '%s' and '%s' options conflict\n"));
  1906. #line 187 "../find.c"
  1907. puts(_("%s: The '%s' option has been disabled."));
  1908. #line 400 "../find.c"
  1909. puts(_("%s: The '%s' option has been disabled."));
  1910. #line 38 "../alias.c"
  1911. puts(_("-equivalence"));
  1912. #line 439 "../find.c"
  1913. puts(_("%s: illegal option -- %c\n"));
  1914. #line 110 "../reset.c"
  1915. puts(_("%s: illegal option -- %c\n"));
  1916. #line 241 "../find.c"
  1917. puts(_("%s: illegal option -- %s\n"));
  1918. #line 740 "../find.c"
  1919. puts(_("%s: illegal option -- %s\n"));
  1920. #line 118 "../reset.c"
  1921. puts(_("%s: illegal option -- %s\n"));
  1922. #line 305 "../find.c"
  1923. puts(_("%s: unknown vendor extension option -- %s\n"));
  1924. #line 135 "../enum.c"
  1925. puts(_(" or an integer from %d through %d\n"));
  1926. #line 145 "../enum.c"
  1927. puts(_(" or an integer from %d through %d\n"));
  1928. #line 696 "../usage.c"
  1929. puts(_("%s error: invalid option descriptor for %s\n"));
  1930. #line 1030 "../usage.c"
  1931. puts(_("%s error: invalid option descriptor for %s\n"));
  1932. #line 355 "../find.c"
  1933. puts(_("%s: invalid option name: %s\n"));
  1934. #line 497 "../find.c"
  1935. puts(_("%s: The '%s' option requires an argument.\n"));
  1936. #line 150 "../autoopts.c"
  1937. puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
  1938. "\t'%s' and '%s'."));
  1939. #line 94 "../check.c"
  1940. puts(_("%s error: The %s option is required\n"));
  1941. #line 602 "../find.c"
  1942. puts(_("%s: The '%s' option cannot have an argument.\n"));
  1943. #line 151 "../check.c"
  1944. puts(_("%s: Command line arguments are not allowed.\n"));
  1945. #line 568 "../save.c"
  1946. puts(_("error %d (%s) creating %s\n"));
  1947. #line 210 "../enum.c"
  1948. puts(_("%s error: '%s' does not match any %s keywords.\n"));
  1949. #line 93 "../reset.c"
  1950. puts(_("%s error: The '%s' option requires an argument.\n"));
  1951. #line 122 "../save.c"
  1952. puts(_("error %d (%s) stat-ing %s\n"));
  1953. #line 175 "../save.c"
  1954. puts(_("error %d (%s) stat-ing %s\n"));
  1955. #line 143 "../restore.c"
  1956. puts(_("%s error: no saved option state\n"));
  1957. #line 225 "../autoopts.c"
  1958. puts(_("'%s' is not a command line option.\n"));
  1959. #line 113 "../time.c"
  1960. puts(_("%s error: '%s' is not a recognizable date/time.\n"));
  1961. #line 50 "../time.c"
  1962. puts(_("%s error: '%s' is not a recognizable time duration.\n"));
  1963. #line 92 "../check.c"
  1964. puts(_("%s error: The %s option must appear %d times.\n"));
  1965. #line 165 "../numeric.c"
  1966. puts(_("%s error: '%s' is not a recognizable number.\n"));
  1967. #line 176 "../enum.c"
  1968. puts(_("%s error: %s exceeds %s keyword count\n"));
  1969. #line 279 "../usage.c"
  1970. puts(_("Try '%s %s' for more information.\n"));
  1971. #line 45 "../alias.c"
  1972. puts(_("one %s%s option allowed\n"));
  1973. #line 170 "../makeshell.c"
  1974. puts(_("standard output"));
  1975. #line 905 "../makeshell.c"
  1976. puts(_("standard output"));
  1977. #line 223 "../usage.c"
  1978. puts(_("standard output"));
  1979. #line 364 "../usage.c"
  1980. puts(_("standard output"));
  1981. #line 574 "../usage.c"
  1982. puts(_("standard output"));
  1983. #line 178 "../version.c"
  1984. puts(_("standard output"));
  1985. #line 223 "../usage.c"
  1986. puts(_("standard error"));
  1987. #line 364 "../usage.c"
  1988. puts(_("standard error"));
  1989. #line 574 "../usage.c"
  1990. puts(_("standard error"));
  1991. #line 178 "../version.c"
  1992. puts(_("standard error"));
  1993. #line 170 "../makeshell.c"
  1994. puts(_("write"));
  1995. #line 905 "../makeshell.c"
  1996. puts(_("write"));
  1997. #line 222 "../usage.c"
  1998. puts(_("write"));
  1999. #line 363 "../usage.c"
  2000. puts(_("write"));
  2001. #line 573 "../usage.c"
  2002. puts(_("write"));
  2003. #line 177 "../version.c"
  2004. puts(_("write"));
  2005. #line 60 "../numeric.c"
  2006. puts(_("%s error: %s option value %ld is out of range.\n"));
  2007. #line 44 "../check.c"
  2008. puts(_("%s error: %s option requires the %s option\n"));
  2009. #line 121 "../save.c"
  2010. puts(_("%s warning: cannot save options - %s not regular file\n"));
  2011. #line 174 "../save.c"
  2012. puts(_("%s warning: cannot save options - %s not regular file\n"));
  2013. #line 193 "../save.c"
  2014. puts(_("%s warning: cannot save options - %s not regular file\n"));
  2015. #line 567 "../save.c"
  2016. puts(_("%s warning: cannot save options - %s not regular file\n"));
  2017. /* END-LIBOPTS-MESSAGES */
  2018. /* USAGE-TEXT: */
  2019. #line 822 "../usage.c"
  2020. puts(_("\t\t\t\t- an alternate for '%s'\n"));
  2021. #line 1097 "../usage.c"
  2022. puts(_("Version, usage and configuration options:"));
  2023. #line 873 "../usage.c"
  2024. puts(_("\t\t\t\t- default option for unnamed options\n"));
  2025. #line 786 "../usage.c"
  2026. puts(_("\t\t\t\t- disabled as '--%s'\n"));
  2027. #line 1066 "../usage.c"
  2028. puts(_(" --- %-14s %s\n"));
  2029. #line 1064 "../usage.c"
  2030. puts(_("This option has been disabled"));
  2031. #line 813 "../usage.c"
  2032. puts(_("\t\t\t\t- enabled by default\n"));
  2033. #line 40 "../alias.c"
  2034. puts(_("%s error: only "));
  2035. #line 1143 "../usage.c"
  2036. puts(_(" - examining environment variables named %s_*\n"));
  2037. #line 168 "../file.c"
  2038. puts(_("\t\t\t\t- file must not pre-exist\n"));
  2039. #line 172 "../file.c"
  2040. puts(_("\t\t\t\t- file must pre-exist\n"));
  2041. #line 329 "../usage.c"
  2042. puts(_("Options are specified by doubled hyphens and their name or by a single\n"
  2043. "hyphen and the flag character.\n"));
  2044. #line 882 "../makeshell.c"
  2045. puts(_("\n"
  2046. "= = = = = = = =\n\n"
  2047. "This incarnation of genshell will produce\n"
  2048. "a shell script to parse the options for %s:\n\n"));
  2049. #line 142 "../enum.c"
  2050. puts(_(" or an integer mask with any of the lower %d bits set\n"));
  2051. #line 846 "../usage.c"
  2052. puts(_("\t\t\t\t- is a set membership option\n"));
  2053. #line 867 "../usage.c"
  2054. puts(_("\t\t\t\t- must appear between %d and %d times\n"));
  2055. #line 331 "../usage.c"
  2056. puts(_("Options are specified by single or double hyphens and their name.\n"));
  2057. #line 853 "../usage.c"
  2058. puts(_("\t\t\t\t- may appear multiple times\n"));
  2059. #line 840 "../usage.c"
  2060. puts(_("\t\t\t\t- may not be preset\n"));
  2061. #line 1258 "../usage.c"
  2062. puts(_(" Arg Option-Name Description\n"));
  2063. #line 1194 "../usage.c"
  2064. puts(_(" Flg Arg Option-Name Description\n"));
  2065. #line 1252 "../usage.c"
  2066. puts(_(" Flg Arg Option-Name Description\n"));
  2067. #line 1253 "../usage.c"
  2068. puts(_(" %3s %s"));
  2069. #line 1259 "../usage.c"
  2070. puts(_(" %3s %s"));
  2071. #line 336 "../usage.c"
  2072. puts(_("The '-#<number>' option may omit the hash char\n"));
  2073. #line 332 "../usage.c"
  2074. puts(_("All arguments are named options.\n"));
  2075. #line 920 "../usage.c"
  2076. puts(_(" - reading file %s"));
  2077. #line 358 "../usage.c"
  2078. puts(_("\n"
  2079. "Please send bug reports to: <%s>\n"));
  2080. #line 100 "../version.c"
  2081. puts(_("\n"
  2082. "Please send bug reports to: <%s>\n"));
  2083. #line 129 "../version.c"
  2084. puts(_("\n"
  2085. "Please send bug reports to: <%s>\n"));
  2086. #line 852 "../usage.c"
  2087. puts(_("\t\t\t\t- may NOT appear - preset only\n"));
  2088. #line 893 "../usage.c"
  2089. puts(_("\n"
  2090. "The following option preset mechanisms are supported:\n"));
  2091. #line 1141 "../usage.c"
  2092. puts(_("\n"
  2093. "The following option preset mechanisms are supported:\n"));
  2094. #line 631 "../usage.c"
  2095. puts(_("prohibits these options:\n"));
  2096. #line 626 "../usage.c"
  2097. puts(_("prohibits the option '%s'\n"));
  2098. #line 81 "../numeric.c"
  2099. puts(_("%s%ld to %ld"));
  2100. #line 79 "../numeric.c"
  2101. puts(_("%sgreater than or equal to %ld"));
  2102. #line 75 "../numeric.c"
  2103. puts(_("%s%ld exactly"));
  2104. #line 68 "../numeric.c"
  2105. puts(_("%sit must lie in one of the ranges:\n"));
  2106. #line 68 "../numeric.c"
  2107. puts(_("%sit must be in the range:\n"));
  2108. #line 88 "../numeric.c"
  2109. puts(_(", or\n"));
  2110. #line 66 "../numeric.c"
  2111. puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
  2112. #line 77 "../numeric.c"
  2113. puts(_("%sless than or equal to %ld"));
  2114. #line 339 "../usage.c"
  2115. puts(_("Operands and options may be intermixed. They will be reordered.\n"));
  2116. #line 601 "../usage.c"
  2117. puts(_("requires the option '%s'\n"));
  2118. #line 604 "../usage.c"
  2119. puts(_("requires these options:\n"));
  2120. #line 1270 "../usage.c"
  2121. puts(_(" Arg Option-Name Req? Description\n"));
  2122. #line 1264 "../usage.c"
  2123. puts(_(" Flg Arg Option-Name Req? Description\n"));
  2124. #line 143 "../enum.c"
  2125. puts(_("or you may use a numeric representation. Preceding these with a '!'\n"
  2126. "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
  2127. "will set them all. Multiple entries may be passed as an option\n"
  2128. "argument list.\n"));
  2129. #line 859 "../usage.c"
  2130. puts(_("\t\t\t\t- may appear up to %d times\n"));
  2131. #line 52 "../enum.c"
  2132. puts(_("The valid \"%s\" option keywords are:\n"));
  2133. #line 1101 "../usage.c"
  2134. puts(_("The next option supports vendor supported extra options:"));
  2135. #line 722 "../usage.c"
  2136. puts(_("These additional options are:"));
  2137. /* END-USAGE-TEXT */
  2138. }
  2139. #endif /* uncompilable code */
  2140. #ifdef __cplusplus
  2141. }
  2142. #endif
  2143. /* tcpprep_opts.c ends here */