tcpprep_opts.def 15 KB

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