tcpprep_opts.def 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. autogen definitions options;
  2. copyright = {
  3. date = "2000 - 2007";
  4. owner = "Aaron Turner";
  5. type = "bsd";
  6. author = <<- EOText
  7. Copyright 2000-2007 Aaron Turner
  8. For support please use the tcpreplay-users@lists.sourceforge.net mailing list.
  9. The latest version of this software is always available from:
  10. http://tcpreplay.synfin.net/
  11. EOText;
  12. };
  13. package = "tcpprep";
  14. prog-name = "tcpprep";
  15. prog-title = "Create a tcpreplay cache cache file from a pcap file.";
  16. long-opts;
  17. gnu-usage;
  18. help-value = "H";
  19. save-opts-value = "";
  20. load-opts-value = "";
  21. config-header = "config.h";
  22. include = "#include \"defines.h\"\n"
  23. "#include \"common.h\"\n"
  24. "#include \"config.h\"\n"
  25. "#include \"tcpprep.h\"\n"
  26. "#include <stdlib.h>\n"
  27. "#include <string.h>\n"
  28. "extern tcpprep_opt_t options;\n";
  29. homerc = "$$/";
  30. explain = <<- EOExplain
  31. tcpprep is a @file{pcap(3)} file pre-processor which creates a cache
  32. file which provides "rules" for @file{tcprewrite(1)} and @file{tcpreplay(1)}
  33. on how to process and send packets.
  34. EOExplain;
  35. detail = <<- EODetail
  36. The basic operation of tcpreplay is to resend all packets from the
  37. input file(s) out a single file. Tcpprep processes a pcap file and
  38. applies a set of user-specified rules to create a cache file which
  39. tells tcpreplay wether or not to send each packet and which interface the
  40. packet should be sent out of.
  41. For more details, please see the Tcpreplay Manual at:
  42. http://tcpreplay.synfin.net/trac/wiki/manual
  43. EODetail;
  44. man-doc = <<- EOMan
  45. .SH "SEE ALSO"
  46. tcpdump(1), tcprewrite(1), tcpreplay(1)
  47. EOMan;
  48. flag = {
  49. ifdef = DEBUG;
  50. name = dbug;
  51. value = d;
  52. arg-type = number;
  53. max = 1;
  54. immediate;
  55. arg-range = "0->5";
  56. arg-default = 0;
  57. descrip = "Enable debugging output";
  58. doc = <<- EOText
  59. If configured with --enable-debug, then you can specify a verbosity
  60. level for debugging output. Higher numbers increase verbosity.
  61. EOText;
  62. };
  63. /* Modes: -a bridge/router/client/server, -c (cidr) */
  64. flag = {
  65. name = auto;
  66. value = a;
  67. descrip = "Auto-split mode";
  68. arg-type = string;
  69. max = 1;
  70. flags-cant = cidr;
  71. flags-cant = port;
  72. flags-cant = regex;
  73. flags-cant = mac;
  74. flag-code = <<- EOAuto
  75. options.mode = AUTO_MODE;
  76. if (strcmp(OPT_ARG(AUTO), "bridge") == 0) {
  77. options.automode = BRIDGE_MODE;
  78. }
  79. else if (strcmp(OPT_ARG(AUTO), "router") == 0) {
  80. options.automode = ROUTER_MODE;
  81. }
  82. else if (strcmp(OPT_ARG(AUTO), "client") == 0) {
  83. options.automode = CLIENT_MODE;
  84. }
  85. else if (strcmp(OPT_ARG(AUTO), "server") == 0) {
  86. options.automode = SERVER_MODE;
  87. }
  88. else {
  89. errx(1, "Invalid auto mode type: %s", OPT_ARG(AUTO));
  90. }
  91. EOAuto;
  92. doc = <<- EOText
  93. Tcpprep will try to automatically determine the primary function of hosts
  94. based on the traffic captured and classify each host as client or server.
  95. In order to do so, you must provide a hint to tcpprep as to how to search
  96. for clients and servers. Valid hints are:
  97. @table @bullet
  98. @item
  99. @var{bridge}
  100. Bridge mode processes each packet to try to determine if the sender is a
  101. client or server. Once all the packets are processed, the results are weighed
  102. according to the server/client ratio (@samp{--ratio}) and systems are assigned an
  103. interface. If tcpprep is unable to determine what role a system plays, tcpprep
  104. will abort.
  105. @item
  106. @var{router}
  107. Router mode works just like bridge mode, except that after weighing is done,
  108. systems which are undetermined are considered a server if they fall inside a
  109. network known to contain other servers. Router has a greater chance of
  110. successfully splitting clients and servers but is not 100% foolproof.
  111. @item
  112. @var{client}
  113. Client mode works just like bridge mode, except that unclassified systems are
  114. treated as clients. Client mode should always complete successfully.
  115. @item
  116. @var{server}
  117. Server mode works just like bridge mode, except that unclassified systems are
  118. treated as servers. Server mode should always complete successfully.
  119. @end table
  120. EOText;
  121. };
  122. flag = {
  123. name = cidr;
  124. value = c;
  125. descrip = "CIDR-split mode";
  126. arg-type = string;
  127. max = 1;
  128. flags-cant = auto;
  129. flags-cant = port;
  130. flags-cant = regex;
  131. flags-cant = mac;
  132. flag-code = <<- EOCidr
  133. char *cidr = safe_strdup(OPT_ARG(CIDR));
  134. options.mode = CIDR_MODE;
  135. if (!parse_cidr(&options.cidrdata, cidr, ","))
  136. errx(1, "Unable to parse CIDR map: %s", OPT_ARG(CIDR));
  137. free(cidr);
  138. EOCidr;
  139. doc = <<- EOText
  140. Specify a comma delimited list of CIDR netblocks to match against
  141. the source IP of each packet. Packets matching any of the CIDR's
  142. are classified as servers.
  143. EOText;
  144. };
  145. flag = {
  146. name = regex;
  147. value = r;
  148. descrip = "Regex-split mode";
  149. arg-type = string;
  150. max = 1;
  151. flags-cant = auto;
  152. flags-cant = port;
  153. flags-cant = cidr;
  154. flags-cant = mac;
  155. flag-code = <<- EORegex
  156. int regex_error;
  157. char ebuf[EBUF_SIZE];
  158. options.mode = REGEX_MODE;
  159. if ((regex_error = regcomp(&options.preg, OPT_ARG(REGEX),
  160. REG_EXTENDED|REG_NOSUB))) {
  161. regerror(regex_error, &options.preg, ebuf, EBUF_SIZE);
  162. errx(1, "Unable to compile regex: %s", ebuf);
  163. }
  164. EORegex;
  165. doc = <<- EOText
  166. Specify a regular expression to match against the source IP of each
  167. packet. Packets matching the regex are classified as servers.
  168. EOText;
  169. };
  170. flag = {
  171. name = port;
  172. value = p;
  173. descrip = "Port-split mode";
  174. max = 1;
  175. flags-cant = auto;
  176. flags-cant = regex;
  177. flags-cant = cidr;
  178. flags-cant = mac;
  179. flag-code = <<- EOPort
  180. options.mode = PORT_MODE;
  181. EOPort;
  182. doc = <<- EOText
  183. Specifies that TCP and UDP traffic should be classified as client
  184. or server based upon the destination port of the header.
  185. EOText;
  186. };
  187. flag = {
  188. name = mac;
  189. value = e;
  190. arg-type = string;
  191. max = 1;
  192. descrip = "Source MAC split mode";
  193. flags-cant = auto;
  194. flags-cant = regex;
  195. flags-cant = cidr;
  196. flags-cant = port;
  197. flag-code = <<- EOMac
  198. options.mode = MAC_MODE;
  199. options.maclist = safe_strdup(OPT_ARG(MAC));
  200. EOMac;
  201. doc = <<- EOText
  202. Specify a list of MAC addresses to match against the source MAC
  203. of each packet. Packets matching one of the values are classified
  204. as servers.
  205. EOText;
  206. };
  207. flag = {
  208. name = comment;
  209. value = C;
  210. arg-type = string;
  211. max = 1;
  212. descrip = "Embeded cache file comment";
  213. flag-code = <<- EOComment
  214. /* our comment_len is only 16bit - myargs[] */
  215. if (strlen(OPT_ARG(COMMENT)) > ((1 << 16) - 1 - MYARGS_LEN))
  216. errx(1, "Comment length %d is longer then max allowed (%d)",
  217. strlen(OPT_ARG(COMMENT)), (1 << 16) - 1 - MYARGS_LEN);
  218. /* save the comment */
  219. options.comment = (char *)safe_malloc(strlen(OPT_ARG(COMMENT)) + 1);
  220. strcpy(options.comment, OPT_ARG(COMMENT));
  221. EOComment;
  222. doc = <<- EOText
  223. Specify a comment to be imbedded within the output cache file and later
  224. viewed.
  225. EOText;
  226. };
  227. flag = {
  228. name = no-arg-comment;
  229. max = 1;
  230. descrip = "Do not embed any cache file comment";
  231. flag-code = <<- EOCode
  232. options.nocomment = 1;
  233. EOCode;
  234. doc = <<- EOText
  235. By default, tcpprep includes the arguments passed on the command line
  236. in the cache file comment (in addition to any user specified --comment).
  237. If for some reason you do not wish to include this, specify this option.
  238. EOText;
  239. };
  240. /* Include/Exclude */
  241. flag = {
  242. name = include;
  243. value = x;
  244. arg-type = string;
  245. max = 1;
  246. descrip = "Include only packets matching rule";
  247. flags-cant = exclude;
  248. flag-code = <<- EOInclude
  249. char *include;
  250. include = safe_strdup(OPT_ARG(INCLUDE));
  251. options.xX.mode = xX_MODE_INCLUDE;
  252. if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError)
  253. errx(1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE));
  254. free(include);
  255. EOInclude;
  256. doc = <<- EOText
  257. Override default of processing all packets stored in the capture file and only
  258. send/edit packets which match the provided rule. Rules can be one of:
  259. @table @bullet
  260. @item S:<CIDR1>,...
  261. - Source IP must match specified CIDR(s)
  262. @item D:<CIDR1>,...
  263. - Destination IP must match specified CIDR(s)
  264. @item B:<CIDR1>,...
  265. - Both source and destination IP must match specified CIDR(s)
  266. @item E:<CIDR1>,...
  267. - Either IP must match specified CIDR(s)
  268. @item P:<LIST>
  269. - Must be one of the listed packets where the list
  270. corresponds to the packet number in the capture file.
  271. @example
  272. -x P:1-5,9,15,72-
  273. @end example
  274. would process packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
  275. end of the file
  276. @item F:'<bpf>'
  277. - BPF filter. See the @file{tcpdump(8)} man page for syntax.
  278. @end table
  279. EOText;
  280. };
  281. flag = {
  282. name = exclude;
  283. value = X;
  284. arg-type = string;
  285. max = 1;
  286. descrip = "Exclude any packet matching this rule";
  287. flags-cant = include;
  288. flag-code = <<- EOExclude
  289. char *exclude;
  290. exclude = safe_strdup(OPT_ARG(EXCLUDE));
  291. options.xX.mode = xX_MODE_EXCLUDE;
  292. if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError)
  293. errx(1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE));
  294. free(exclude);
  295. EOExclude;
  296. doc = <<- EOText
  297. Override default of processing all packets stored in the capture file and only
  298. send/edit packets which do NOT match the provided rule. Rules can be one of:
  299. @table @bullet
  300. @item S:<CIDR1>,...
  301. - Source IP must not match specified CIDR(s)
  302. @item D:<CIDR1>,...
  303. - Destination IP must not match specified CIDR(s)
  304. @item B:<CIDR1>,...
  305. - Both source and destination IP must not match specified CIDR(s)
  306. @item E:<CIDR1>,...
  307. - Either IP must not match specified CIDR(s)
  308. @item P:<LIST>
  309. - Must not be one of the listed packets where the list
  310. corresponds to the packet number in the capture file.
  311. @example
  312. -x P:1-5,9,15,72-
  313. @end example
  314. would skip packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
  315. end of the file
  316. @end table
  317. EOText;
  318. };
  319. flag = {
  320. name = cachefile;
  321. value = o;
  322. arg-type = string;
  323. max = 1;
  324. descrip = "Output cache file";
  325. doc = "";
  326. };
  327. flag = {
  328. name = pcap;
  329. value = i;
  330. descrip = "Input pcap file to process";
  331. arg-type = string;
  332. max = 1;
  333. doc = "";
  334. };
  335. flag = {
  336. name = print-comment;
  337. value = P;
  338. arg-type = string;
  339. descrip = "Print embedded comment in the specified cache file";
  340. doc = "";
  341. };
  342. flag = {
  343. name = print-info;
  344. value = I;
  345. arg-type = string;
  346. descrip = "Print basic info from the specified cache file";
  347. doc = "";
  348. };
  349. flag = {
  350. name = print-stats;
  351. value = S;
  352. arg-type = string;
  353. descrip = "Print statistical information about the specified cache file";
  354. doc = "";
  355. };
  356. flag = {
  357. name = services;
  358. value = s;
  359. descrip = "Load services file for server ports";
  360. flags-must = port;
  361. arg-type = string;
  362. flag-code = <<- EOServices
  363. parse_services(OPT_ARG(SERVICES), &options.services);
  364. EOServices;
  365. };
  366. flag = {
  367. name = nonip;
  368. value = N;
  369. descrip = "Send non-IP traffic out server interface";
  370. flag-code = <<- EONonip
  371. options.nonip = DIR_SERVER;
  372. EONonip;
  373. doc = <<- EOText
  374. By default, non-IP traffic which can not be classified as client
  375. or server is classified as "client". Specifiying @samp{--nonip}
  376. will reclassify non-IP traffic as "server".
  377. EOText;
  378. };
  379. flag = {
  380. name = ratio;
  381. value = R;
  382. arg-type = string;
  383. max = 1;
  384. flags-must = auto;
  385. arg_default = "2.0";
  386. descrip = "Ratio of client to server packets";
  387. doc = <<- EOText
  388. Since a given host may have both client and server traffic being sent
  389. to/from it, tcpprep uses a ratio to weigh these packets. If you would
  390. like to override the default of 2:1 server to client packets required for
  391. a host to be classified as a server, specify it as a floating point value.
  392. EOText;
  393. };
  394. flag = {
  395. name = minmask;
  396. value = m;
  397. descrip = "Minimum network mask length in auto mode";
  398. flags-must = auto;
  399. max = 1;
  400. arg-type = number;
  401. arg-range = "0->32";
  402. arg_default = 30;
  403. doc = <<- EOText
  404. By default, auto modes use a minimum network mask length of 30 bits
  405. to build networks containing clients and servers. This allows you
  406. to override this value. Larger values will increase performance but
  407. may provide inaccurate results.
  408. EOText;
  409. };
  410. flag = {
  411. name = maxmask;
  412. value = M;
  413. descrip = "Maximum network mask length in auto mode";
  414. flags-must = auto;
  415. max = 1;
  416. arg-type = number;
  417. arg-range = "0->32";
  418. arg_default = 8;
  419. doc = <<- EOText
  420. By default, auto modes use a maximum network mask length of 8 bits
  421. to build networks containing clients and servers. This allows you
  422. to override this value. Larger values will decrease performance
  423. and accuracy but will provide greater chance of success.
  424. EOText;
  425. };
  426. flag = {
  427. ifdef = ENABLE_VERBOSE;
  428. name = verbose;
  429. value = v;
  430. max = 1;
  431. immediate;
  432. descrip = "Print decoded packets via tcpdump to STDOUT";
  433. settable;
  434. doc = "";
  435. };
  436. flag = {
  437. ifdef = ENABLE_VERBOSE;
  438. name = decode;
  439. flags-must = verbose;
  440. value = A;
  441. arg-type = string;
  442. max = 1;
  443. descrip = "Arguments passed to tcpdump decoder";
  444. doc = <<- EOText
  445. When enabling verbose mode (@samp{-v}) you may also specify one or
  446. more additional arguments to pass to @code{tcpdump} to modify
  447. the way packets are decoded. By default, -n and -l are used.
  448. Be sure to quote the arguments so that they are not interpreted
  449. by tcprewrite. The following arguments are valid:
  450. [ -aAeNqRStuvxX ]
  451. [ -E spi@ipaddr algo:secret,... ]
  452. [ -s snaplen ]
  453. EOText;
  454. };
  455. flag = {
  456. name = version;
  457. value = V;
  458. descrip = "Print version information";
  459. flag-code = <<- EOVersion
  460. fprintf(stderr, "tcpprep version: %s (build %s)", VERSION, svn_version());
  461. #ifdef DEBUG
  462. fprintf(stderr, " (debug)");
  463. #endif
  464. fprintf(stderr, "\n");
  465. fprintf(stderr, "Copyright 2001-2007 by Aaron Turner <aturner at synfin dot net>\n");
  466. fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION);
  467. #ifdef HAVE_LIBNET
  468. fprintf(stderr, "Compiled against libnet: %s\n", LIBNET_VERSION);
  469. #else
  470. fprintf(stderr, "Not compiled with libnet.\n");
  471. #endif
  472. #ifdef HAVE_WINPCAP
  473. fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
  474. #else
  475. fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
  476. #endif
  477. #ifdef ENABLE_64BITS
  478. fprintf(stderr, "64 bit packet counters: enabled\n");
  479. #else
  480. fprintf(stderr, "64 bit packet counters: disabled\n");
  481. #endif
  482. #ifdef ENABLE_VERBOSE
  483. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  484. #else
  485. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  486. #endif
  487. exit(0);
  488. EOVersion;
  489. doc = "";
  490. };
  491. flag = {
  492. name = less-help;
  493. value = "h";
  494. immediate;
  495. descrip = "Display less usage information and exit";
  496. flag-code = <<- EOHelp
  497. USAGE(EXIT_FAILURE);
  498. EOHelp;
  499. };