tcpprep_opts.def 14 KB

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