tcpprep_opts.def 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. autogen definitions options;
  2. copyright = {
  3. date = "2000-2010";
  4. owner = "Aaron Turner";
  5. type = "bsd";
  6. author = <<- EOText
  7. Copyright 2000-2010 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 if (strcmp(OPT_ARG(AUTO), "first") == 0) {
  89. options.automode = FIRST_MODE;
  90. }
  91. else {
  92. errx(-1, "Invalid auto mode type: %s", OPT_ARG(AUTO));
  93. }
  94. EOAuto;
  95. doc = <<- EOText
  96. Tcpprep will try to automatically determine the primary function of hosts
  97. based on the traffic captured and classify each host as client or server.
  98. In order to do so, you must provide a hint to tcpprep as to how to search
  99. for clients and servers. Valid hints are:
  100. @table @bullet
  101. @item
  102. @var{bridge}
  103. Bridge mode processes each packet to try to determine if the sender is a
  104. client or server. Once all the packets are processed, the results are weighed
  105. according to the server/client ratio (@samp{--ratio}) and systems are assigned an
  106. interface. If tcpprep is unable to determine what role a system plays, tcpprep
  107. will abort.
  108. @item
  109. @var{router}
  110. Router mode works just like bridge mode, except that after weighing is done,
  111. systems which are undetermined are considered a server if they fall inside a
  112. network known to contain other servers. Router has a greater chance of
  113. successfully splitting clients and servers but is not 100% foolproof.
  114. @item
  115. @var{client}
  116. Client mode works just like bridge mode, except that unclassified systems are
  117. treated as clients. Client mode should always complete successfully.
  118. @item
  119. @var{server}
  120. Server mode works just like bridge mode, except that unclassified systems are
  121. treated as servers. Server mode should always complete successfully.
  122. @item
  123. @var{first}
  124. First mode works by looking at the first time each IP is seen in the SRC and DST
  125. fields in the IP header. If the host is first seen in the SRC field, it is a
  126. client and if it's first seen in the DST field, it is marked as a server. This
  127. effectively replicates the processing of the tomahawk test tool. First
  128. mode should always complete successfully.
  129. @end table
  130. EOText;
  131. };
  132. flag = {
  133. name = cidr;
  134. value = c;
  135. descrip = "CIDR-split mode";
  136. arg-type = string;
  137. max = 1;
  138. flags-cant = auto;
  139. flags-cant = port;
  140. flags-cant = regex;
  141. flags-cant = mac;
  142. flag-code = <<- EOCidr
  143. char *cidr = safe_strdup(OPT_ARG(CIDR));
  144. options.mode = CIDR_MODE;
  145. if (!parse_cidr(&options.cidrdata, cidr, ","))
  146. errx(-1, "Unable to parse CIDR map: %s", OPT_ARG(CIDR));
  147. free(cidr);
  148. EOCidr;
  149. doc = <<- EOText
  150. Specify a comma delimited list of CIDR netblocks to match against
  151. the source IP of each packet. Packets matching any of the CIDR's
  152. are classified as servers.
  153. IPv4 Example:
  154. @example
  155. --cidr=192.168.0.0/16,172.16.0.0/12,10.0.0.0/8
  156. @end example
  157. IPv6 Example:
  158. @example
  159. --cidr=[::ffff:0:0/96],[fe80::/16]
  160. @end example
  161. EOText;
  162. };
  163. flag = {
  164. name = regex;
  165. value = r;
  166. descrip = "Regex-split mode";
  167. arg-type = string;
  168. max = 1;
  169. flags-cant = auto;
  170. flags-cant = port;
  171. flags-cant = cidr;
  172. flags-cant = mac;
  173. flag-code = <<- EORegex
  174. int regex_error;
  175. char ebuf[EBUF_SIZE];
  176. options.mode = REGEX_MODE;
  177. if ((regex_error = regcomp(&options.preg, OPT_ARG(REGEX),
  178. REG_EXTENDED|REG_NOSUB))) {
  179. regerror(regex_error, &options.preg, ebuf, EBUF_SIZE);
  180. errx(-1, "Unable to compile regex: %s", ebuf);
  181. }
  182. EORegex;
  183. doc = <<- EOText
  184. Specify a regular expression to match against the source IP of each
  185. packet. Packets matching the regex are classified as servers.
  186. EOText;
  187. };
  188. flag = {
  189. name = port;
  190. value = p;
  191. descrip = "Port-split mode";
  192. max = 1;
  193. flags-cant = auto;
  194. flags-cant = regex;
  195. flags-cant = cidr;
  196. flags-cant = mac;
  197. flag-code = <<- EOPort
  198. options.mode = PORT_MODE;
  199. EOPort;
  200. doc = <<- EOText
  201. Specifies that TCP and UDP traffic over IPv4 and IPv6 should be classified
  202. as client or server based upon the destination port of the header.
  203. EOText;
  204. };
  205. flag = {
  206. name = mac;
  207. value = e;
  208. arg-type = string;
  209. max = 1;
  210. descrip = "Source MAC split mode";
  211. flags-cant = auto;
  212. flags-cant = regex;
  213. flags-cant = cidr;
  214. flags-cant = port;
  215. flag-code = <<- EOMac
  216. options.mode = MAC_MODE;
  217. options.maclist = safe_strdup(OPT_ARG(MAC));
  218. EOMac;
  219. doc = <<- EOText
  220. Specify a list of MAC addresses to match against the source MAC
  221. of each packet. Packets matching one of the values are classified
  222. as servers.
  223. EOText;
  224. };
  225. flag = {
  226. name = reverse;
  227. max = 1;
  228. descrip = "Matches to be client instead of server";
  229. doc = <<- EOText
  230. Normally the @samp{--mac}, @samp{--regex} and @samp{--cidr} flags specify are used to specify
  231. the servers and non-IP packets are classified as clients. By using @samp{--reverse}, these
  232. features are reversed so that the flags specify clients and non-IP packets are classified as
  233. servers.
  234. EOText;
  235. };
  236. flag = {
  237. name = comment;
  238. value = C;
  239. arg-type = string;
  240. max = 1;
  241. descrip = "Embeded cache file comment";
  242. flag-code = <<- EOComment
  243. /* our comment_len is only 16bit - myargs[] */
  244. if (strlen(OPT_ARG(COMMENT)) > ((1 << 16) - 1 - MYARGS_LEN))
  245. errx(-1, "Comment length %zu is longer then max allowed (%d)",
  246. strlen(OPT_ARG(COMMENT)), (1 << 16) - 1 - MYARGS_LEN);
  247. /* save the comment */
  248. options.comment = (char *)safe_malloc(strlen(OPT_ARG(COMMENT)) + 1);
  249. strcpy(options.comment, OPT_ARG(COMMENT));
  250. EOComment;
  251. doc = <<- EOText
  252. Specify a comment to be imbedded within the output cache file and later
  253. viewed.
  254. EOText;
  255. };
  256. flag = {
  257. name = no-arg-comment;
  258. max = 1;
  259. descrip = "Do not embed any cache file comment";
  260. flag-code = <<- EOCode
  261. options.nocomment = 1;
  262. EOCode;
  263. doc = <<- EOText
  264. By default, tcpprep includes the arguments passed on the command line
  265. in the cache file comment (in addition to any user specified --comment).
  266. If for some reason you do not wish to include this, specify this option.
  267. EOText;
  268. };
  269. /* Include/Exclude */
  270. flag = {
  271. name = include;
  272. value = x;
  273. arg-type = string;
  274. max = 1;
  275. descrip = "Include only packets matching rule";
  276. flags-cant = exclude;
  277. flag-code = <<- EOInclude
  278. char *include;
  279. include = safe_strdup(OPT_ARG(INCLUDE));
  280. options.xX.mode = xX_MODE_INCLUDE;
  281. if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError)
  282. errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE));
  283. free(include);
  284. EOInclude;
  285. doc = <<- EOText
  286. Override default of processing all packets stored in the capture file and only
  287. send/edit packets which match the provided rule. Rules can be one of:
  288. @table @bullet
  289. @item S:<CIDR1>,...
  290. - Source IP must match specified IPv4/v6 CIDR(s)
  291. @item D:<CIDR1>,...
  292. - Destination IP must match specified IPv4/v6 CIDR(s)
  293. @item B:<CIDR1>,...
  294. - Both source and destination IP must match specified IPv4/v6 CIDR(s)
  295. @item E:<CIDR1>,...
  296. - Either IP must match specified IPv4/v6 CIDR(s)
  297. @item P:<LIST>
  298. - Must be one of the listed packets where the list
  299. corresponds to the packet number in the capture file.
  300. @example
  301. -x P:1-5,9,15,72-
  302. @end example
  303. would process packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
  304. end of the file
  305. @item F:'<bpf>'
  306. - BPF filter. See the @file{tcpdump(8)} man page for syntax.
  307. @end table
  308. EOText;
  309. };
  310. flag = {
  311. name = exclude;
  312. value = X;
  313. arg-type = string;
  314. max = 1;
  315. descrip = "Exclude any packet matching this rule";
  316. flags-cant = include;
  317. flag-code = <<- EOExclude
  318. char *exclude;
  319. exclude = safe_strdup(OPT_ARG(EXCLUDE));
  320. options.xX.mode = xX_MODE_EXCLUDE;
  321. if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError)
  322. errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE));
  323. free(exclude);
  324. EOExclude;
  325. doc = <<- EOText
  326. Override default of processing all packets stored in the capture file and only
  327. send/edit packets which do NOT match the provided rule. Rules can be one of:
  328. @table @bullet
  329. @item S:<CIDR1>,...
  330. - Source IP must not match specified IPv4/v6 CIDR(s)
  331. @item D:<CIDR1>,...
  332. - Destination IP must not match specified IPv4/v6 CIDR(s)
  333. @item B:<CIDR1>,...
  334. - Both source and destination IP must not match specified IPv4/v6 CIDR(s)
  335. @item E:<CIDR1>,...
  336. - Either IP must not match specified IPv4/v6 CIDR(s)
  337. @item P:<LIST>
  338. - Must not be one of the listed packets where the list
  339. corresponds to the packet number in the capture file.
  340. @example
  341. -x P:1-5,9,15,72-
  342. @end example
  343. would skip packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
  344. end of the file
  345. @end table
  346. EOText;
  347. };
  348. flag = {
  349. name = cachefile;
  350. value = o;
  351. arg-type = string;
  352. max = 1;
  353. descrip = "Output cache file";
  354. doc = "";
  355. };
  356. flag = {
  357. name = pcap;
  358. value = i;
  359. descrip = "Input pcap file to process";
  360. arg-type = string;
  361. max = 1;
  362. doc = "";
  363. };
  364. flag = {
  365. name = print-comment;
  366. value = P;
  367. arg-type = string;
  368. descrip = "Print embedded comment in the specified cache file";
  369. max = 1;
  370. doc = "";
  371. };
  372. flag = {
  373. name = print-info;
  374. value = I;
  375. arg-type = string;
  376. descrip = "Print basic info from the specified cache file";
  377. max = 1;
  378. doc = "";
  379. };
  380. flag = {
  381. name = print-stats;
  382. value = S;
  383. arg-type = string;
  384. descrip = "Print statistical information about the specified cache file";
  385. max = 1;
  386. doc = "";
  387. };
  388. flag = {
  389. name = services;
  390. value = s;
  391. descrip = "Load services file for server ports";
  392. flags-must = port;
  393. max = 1;
  394. arg-type = string;
  395. doc = <<- EOText
  396. Uses a list of ports used by servers in the same format as of /etc/services:
  397. <service_name> <port>/<protocol> # comment
  398. Example:
  399. http 80/tcp
  400. EOText;
  401. flag-code = <<- EOServices
  402. parse_services(OPT_ARG(SERVICES), &options.services);
  403. EOServices;
  404. };
  405. flag = {
  406. name = nonip;
  407. value = N;
  408. descrip = "Send non-IP traffic out server interface";
  409. max = 1;
  410. flag-code = <<- EONonip
  411. options.nonip = DIR_SERVER;
  412. EONonip;
  413. doc = <<- EOText
  414. By default, non-IP traffic which can not be classified as client
  415. or server is classified as "client". Specifiying @samp{--nonip}
  416. will reclassify non-IP traffic as "server". Note that the meaning
  417. of this flag is reversed if @samp{--reverse} is used.
  418. EOText;
  419. };
  420. flag = {
  421. name = ratio;
  422. value = R;
  423. arg-type = string;
  424. max = 1;
  425. flags-must = auto;
  426. arg_default = "2.0";
  427. descrip = "Ratio of client to server packets";
  428. doc = <<- EOText
  429. Since a given host may have both client and server traffic being sent
  430. to/from it, tcpprep uses a ratio to weigh these packets. If you would
  431. like to override the default of 2:1 server to client packets required for
  432. a host to be classified as a server, specify it as a floating point value.
  433. EOText;
  434. };
  435. flag = {
  436. name = minmask;
  437. value = m;
  438. descrip = "Minimum network mask length in auto mode";
  439. flags-must = auto;
  440. max = 1;
  441. arg-type = number;
  442. arg-range = "0->32";
  443. arg_default = 30;
  444. doc = <<- EOText
  445. By default, auto modes use a minimum network mask length of 30 bits
  446. to build networks containing clients and servers. This allows you
  447. to override this value. Larger values will increase performance but
  448. may provide inaccurate results.
  449. EOText;
  450. };
  451. flag = {
  452. name = maxmask;
  453. value = M;
  454. descrip = "Maximum network mask length in auto mode";
  455. flags-must = auto;
  456. max = 1;
  457. arg-type = number;
  458. arg-range = "0->32";
  459. arg_default = 8;
  460. doc = <<- EOText
  461. By default, auto modes use a maximum network mask length of 8 bits
  462. to build networks containing clients and servers. This allows you
  463. to override this value. Larger values will decrease performance
  464. and accuracy but will provide greater chance of success.
  465. EOText;
  466. };
  467. flag = {
  468. ifdef = ENABLE_VERBOSE;
  469. name = verbose;
  470. value = v;
  471. max = 1;
  472. immediate;
  473. descrip = "Print decoded packets via tcpdump to STDOUT";
  474. settable;
  475. doc = "";
  476. };
  477. flag = {
  478. ifdef = ENABLE_VERBOSE;
  479. name = decode;
  480. flags-must = verbose;
  481. value = A;
  482. arg-type = string;
  483. max = 1;
  484. descrip = "Arguments passed to tcpdump decoder";
  485. doc = <<- EOText
  486. When enabling verbose mode (@samp{-v}) you may also specify one or
  487. more additional arguments to pass to @code{tcpdump} to modify
  488. the way packets are decoded. By default, -n and -l are used.
  489. Be sure to quote the arguments so that they are not interpreted
  490. by tcprewrite. The following arguments are valid:
  491. [ -aAeNqRStuvxX ]
  492. [ -E spi@ipaddr algo:secret,... ]
  493. [ -s snaplen ]
  494. EOText;
  495. };
  496. flag = {
  497. name = version;
  498. value = V;
  499. descrip = "Print version information";
  500. flag-code = <<- EOVersion
  501. fprintf(stderr, "tcpprep version: %s (build %s)", VERSION, svn_version());
  502. #ifdef DEBUG
  503. fprintf(stderr, " (debug)");
  504. #endif
  505. fprintf(stderr, "\n");
  506. fprintf(stderr, "Copyright 2000-2010 by Aaron Turner <aturner at synfin dot net>\n");
  507. fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION);
  508. #ifdef HAVE_LIBDNET
  509. fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION);
  510. #else
  511. fprintf(stderr, "Not compiled with libdnet.\n");
  512. #endif
  513. #ifdef HAVE_WINPCAP
  514. fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version());
  515. #else
  516. fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version());
  517. #endif
  518. #ifdef ENABLE_64BITS
  519. fprintf(stderr, "64 bit packet counters: enabled\n");
  520. #else
  521. fprintf(stderr, "64 bit packet counters: disabled\n");
  522. #endif
  523. #ifdef ENABLE_VERBOSE
  524. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  525. #else
  526. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  527. #endif
  528. exit(0);
  529. EOVersion;
  530. doc = "";
  531. };
  532. flag = {
  533. name = less-help;
  534. value = "h";
  535. immediate;
  536. descrip = "Display less usage information and exit";
  537. flag-code = <<- EOHelp
  538. USAGE(EXIT_FAILURE);
  539. EOHelp;
  540. };