tcpbridge_opts.def 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. autogen definitions options;
  2. copyright = {
  3. date = "2005";
  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 = "tcpbridge";
  12. prog-name = "tcpbridge";
  13. prog-title = "Bridge network traffic across two interfaces";
  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 \"tcpbridge.h\"\n"
  22. "#include \"common.h\"\n"
  23. "#include \"mac.h\"\n"
  24. "extern char pcap_version[];\n"
  25. "extern tcpbridge_opt_t options;\n";
  26. homerc = "$$/";
  27. explain = <<- EOExplain
  28. tcpbridge is a tool for briding network traffic across two interfaces
  29. and optionally modifying the packets in betweeen
  30. EOExplain;
  31. detail = <<- EODetail
  32. The basic operation of tcpbridge is to be a network bridge between two
  33. subnets. All packets recieved on one interface are sent via the other.
  34. Optionally, packets can be edited in a variety of ways according to your needs.
  35. EODetail;
  36. man-doc = <<- EOMan
  37. .SH "SIGNALS"
  38. tcpbridge understands the following signals:
  39. @enumerate
  40. @item @var{SIGUSR1}
  41. Suspend tcpbridge
  42. @item @var{SIGCONT}
  43. Restart tcpbridge
  44. @end enumerate
  45. .SH "SEE ALSO"
  46. tcpdump(1), tcpprep(1), tcprewrite(1), tcpreplay(1)
  47. .SH "BUGS"
  48. tcpbridge can only send packets as fast as your computer's interface,
  49. processor and system bus will allow.
  50. Connecting both interfaces to the same subnet may create a broadcast storm and
  51. take down the network. Improper use of the packet editing functions may have
  52. other undefined and possible negative consequences.
  53. Some operating systems by default do not allow for forging source MAC
  54. addresses. Please consult your operating system's documentation and the
  55. tcpreplay FAQ if you experiance this issue.
  56. EOMan;
  57. flag = {
  58. name = dbug;
  59. value = d;
  60. arg-type = number;
  61. max = 1;
  62. immediate;
  63. arg-range = "0->5";
  64. arg-default = 0;
  65. descrip = "Enable debugging output";
  66. doc = <<- EOText
  67. If configured with --enable-debug, then you can specify a verbosity
  68. level for debugging output. Higher numbers increase verbosity.
  69. EOText;
  70. };
  71. /* Verbose decoding via tcpdump */
  72. flag = {
  73. ifdef = HAVE_TCPDUMP;
  74. name = verbose;
  75. value = v;
  76. max = 1;
  77. immediate;
  78. descrip = "Print decoded packets via tcpdump to STDOUT";
  79. settable;
  80. doc = "";
  81. };
  82. flag = {
  83. ifdef = HAVE_TCPDUMP;
  84. name = decode;
  85. flags-must = verbose;
  86. value = A;
  87. arg-type = string;
  88. max = 1;
  89. descrip = "Arguments passed to tcpdump decoder";
  90. doc = <<- EOText
  91. When enabling verbose mode (@var{-v}) you may also specify one or more
  92. additional arguments to pass to @code{tcpdump} to modify the way packets
  93. are decoded. By default, -n and -l are used. Be sure to
  94. quote the arguments like: -A "-axxx" so that they are not interpreted
  95. by tcpbridge. The following arguments are vaild:
  96. [ -aAeNqRStuvxX ]
  97. [ -E spi@ipaddr algo:secret,... ]
  98. [ -s snaplen ]
  99. EOText;
  100. };
  101. /*
  102. * Outputs: -i, -I
  103. */
  104. flag = {
  105. name = intf1;
  106. value = i;
  107. arg-type = string;
  108. max = 1;
  109. must-set;
  110. descrip = "Primary interface (listen in uni-directional mode)";
  111. doc = "";
  112. };
  113. flag = {
  114. name = intf2;
  115. value = I;
  116. arg-type = string;
  117. max = 1;
  118. descrip = "Secondary interface (send in uni-directional mode)";
  119. doc = "";
  120. };
  121. flag = {
  122. name = unidir;
  123. value = u;
  124. max = 1;
  125. descrip = "Send and receive in only one direction";
  126. doc = <<- EOText
  127. Normally, tcpbridge will send and receive traffic in both directions
  128. (bi-directionally). However, if you choose this option, traffic will
  129. be sent uni-directionally.
  130. EOText;
  131. };
  132. flag = {
  133. name = dmac;
  134. value = D;
  135. arg-type = string;
  136. max = 1;
  137. descrip = "Rewrite destination MAC addresses";
  138. flag-code = <<- EODmac
  139. int mask = 0;
  140. mask = dualmac2hex(OPT_ARG(DMAC), options.intf1_dmac, options.intf2_dmac,
  141. strlen(OPT_ARG(DMAC)));
  142. options.mac_mask ^= (mask << 2);
  143. EODmac;
  144. doc = <<- EOText
  145. Takes a pair of comma deliminated ethernet MAC addresses which
  146. will replace the destination MAC address of outbound packets.
  147. The first MAC address will be used for the server traffic
  148. and the optional second MAC address will be used for the client
  149. traffic.
  150. Example:
  151. @example
  152. --dmac 00:12:13:14:15:16,00:22:33:44:55:66
  153. @end example
  154. EOText;
  155. };
  156. flag = {
  157. name = smac;
  158. value = S;
  159. arg-type = string;
  160. max = 1;
  161. descrip = "Rewrite source MAC addresses";
  162. flag-code = <<- EOSmac
  163. int mask = 0;
  164. mask = dualmac2hex(OPT_ARG(SMAC), options.intf1_smac, options.intf2_smac,
  165. strlen(OPT_ARG(SMAC)));
  166. options.mac_mask ^= mask;
  167. EOSmac;
  168. doc = <<- EOText
  169. Takes a pair of comma deliminated ethernet MAC addresses which
  170. will replace the source MAC address of outbound packets.
  171. The first MAC address will be used for the server traffic
  172. and the optional second MAC address will be used for the client traffic.
  173. Example:
  174. @example
  175. --smac 00:12:13:14:15:16,00:22:33:44:55:66
  176. @end example
  177. EOText;
  178. };
  179. flag = {
  180. name = limit;
  181. value = l;
  182. arg-type = number;
  183. max = 1;
  184. arg-default = -1;
  185. arg-range = "0->";
  186. descrip = "Limit the number of packets to send";
  187. doc = <<- EOText
  188. By default, tcpbridge will send packets forever or until Ctrl-C. Alternatively,
  189. you can specify a maximum number of packets to send.
  190. EOText;
  191. };
  192. /* Include/Exclude */
  193. flag = {
  194. name = include;
  195. value = x;
  196. arg-type = string;
  197. max = 1;
  198. descrip = "Include only packets matching rule";
  199. flags-cant = exclude;
  200. flag-code = <<- EOInclude
  201. char *include;
  202. include = safe_strdup(OPT_ARG(INCLUDE));
  203. options.xX.mode = xX_MODE_INCLUDE;
  204. if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == 0)
  205. errx(1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE));
  206. free(include);
  207. EOInclude;
  208. doc = <<- EOText
  209. Override default of sending all packets stored in the capture file and only
  210. send packets which match the provided rule. Rules can be one of:
  211. @table @bullet
  212. @item S:<CIDR1>,...
  213. - Source IP must match specified CIDR(s)
  214. @item D:<CIDR1>,...
  215. - Destination IP must match specified CIDR(s)
  216. @item B:<CIDR1>,...
  217. - Both source and destination IP must match specified CIDR(s)
  218. @item E:<CIDR1>,...
  219. - Either IP must match specified CIDR(s)
  220. @item P:<LIST>
  221. - Must be one of the listed packets where the list
  222. corresponds to the packet number in the capture file.
  223. @example
  224. -x P:1-5,9,15,72-
  225. @end example
  226. would send packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
  227. end of the file
  228. @item F:'<bpf>'
  229. - BPF filter. See the @file{tcpdump(8)} man page for syntax.
  230. @end table
  231. EOText;
  232. };
  233. flag = {
  234. name = exclude;
  235. value = X;
  236. arg-type = string;
  237. max = 1;
  238. descrip = "Exclude any packet matching this rule";
  239. flags-cant = include;
  240. flag-code = <<- EOExclude
  241. char *exclude;
  242. exclude = safe_strdup(OPT_ARG(EXCLUDE));
  243. options.xX.mode = xX_MODE_EXCLUDE;
  244. if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == 0)
  245. errx(1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE));
  246. free(exclude);
  247. EOExclude;
  248. doc = <<- EOText
  249. Override default of sending all packets stored in the capture file and only
  250. send packets which do not match the provided rule. Rules can be one of:
  251. @table @bullet
  252. @item S:<CIDR1>,...
  253. - Source IP must not match specified CIDR(s)
  254. @item D:<CIDR1>,...
  255. - Destination IP must not match specified CIDR(s)
  256. @item B:<CIDR1>,...
  257. - Both source and destination IP must not match specified CIDR(s)
  258. @item E:<CIDR1>,...
  259. - Either IP must not match specified CIDR(s)
  260. @item P:<LIST>
  261. - Must not be one of the listed packets where the list
  262. corresponds to the packet number in the capture file.
  263. @example
  264. -x P:1-5,9,15,72-
  265. @end example
  266. would drop packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
  267. end of the file
  268. @end table
  269. EOText;
  270. };
  271. /* rewrite 802.1q vlan tags */
  272. flag = {
  273. name = vlan;
  274. value = T;
  275. max = 1;
  276. descrip = "Specify 802.1q VLAN tag mode";
  277. arg-type = string;
  278. flag-code = <<- EOVlan
  279. if (strcmp(OPT_ARG(VLAN), "add") == 0) {
  280. options.vlan = VLAN_ADD;
  281. } else if (strcmp(OPT_ARG(VLAN), "del") == 0) {
  282. options.vlan = VLAN_DEL;
  283. } else {
  284. errx(1, "Invalid vlan argument '%s'. Must be 'add' or 'del'", OPT_ARG(VLAN));
  285. }
  286. EOVlan;
  287. doc = <<- EOText
  288. Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3
  289. ethernet headers or remove the 802.1q VLAN tag information.
  290. @table @bullet
  291. @item
  292. @var{add}
  293. Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header
  294. @item
  295. @var{del}
  296. Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header
  297. EOText;
  298. };
  299. flag = {
  300. name = vlan_tag;
  301. value = t;
  302. max = 1;
  303. descrip = "Specify the new 802.1q VLAN tag value";
  304. arg-type = number;
  305. flags-must = vlan;
  306. arg-range = "0->4095"; /* VID's are 12bit unsigned int's */
  307. doc = "";
  308. };
  309. flag = {
  310. name = vlan_cfi;
  311. value = c;
  312. max = 1;
  313. descrip = "Specify the 802.1q VLAN CFI value";
  314. arg-type = number;
  315. flags-must = vlan;
  316. arg-range = "0->1"; /* one bit */
  317. doc = "";
  318. };
  319. flag = {
  320. name = vlan_pri;
  321. value = p;
  322. max = 1;
  323. descrip = "Specify the 802.1q VLAN priority";
  324. flags-must = vlan;
  325. arg-type = number;
  326. arg-range = "0->7"; /* one byte */
  327. doc = "";
  328. };
  329. flag = {
  330. name = pid;
  331. value = P;
  332. descrip = "Print the PID of tcpbridge at startup";
  333. flag-code = <<- EOPid
  334. fprintf(stderr, "PID: %hu\n", getpid());
  335. EOPid;
  336. doc = "";
  337. };
  338. flag = {
  339. name = version;
  340. value = V;
  341. descrip = "Print version information";
  342. flag-code = <<- EOVersion
  343. fprintf(stderr, "tcpbridge version: %s (build %s)", VERSION, svn_version());
  344. #ifdef DEBUG
  345. fprintf(stderr, " (debug)");
  346. #endif
  347. fprintf(stderr, "\n");
  348. fprintf(stderr, "Copyright 2001-2005 by Aaron Turner <aturner@pobox.com>\n");
  349. fprintf(stderr, "Compiled against libnet: %s\n", LIBNET_VERSION);
  350. fprintf(stderr, "Compiled against libpcap: %s\n", pcap_version);
  351. #ifdef ENABLE_64BITS
  352. fprintf(stderr, "64 bit packet counters: enabled\n");
  353. #else
  354. fprintf(stderr, "64 bit packet counters: disabled\n");
  355. #endif
  356. #ifdef HAVE_TCPDUMP
  357. fprintf(stderr, "Verbose printing via tcpdump: enabled\n");
  358. #else
  359. fprintf(stderr, "Verbose printing via tcpdump: disabled\n");
  360. #endif
  361. exit(0);
  362. EOVersion;
  363. doc = "";
  364. };
  365. flag = {
  366. name = less-help;
  367. value = "h";
  368. immediate;
  369. descrip = "Display less usage information and exit";
  370. flag-code = <<- EOHelp
  371. USAGE(EXIT_FAILURE);
  372. EOHelp;
  373. doc = "";
  374. };