| 1 | autogen definitions options; |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | copyright = { |
|---|
| 5 | date = "2005-2008"; |
|---|
| 6 | owner = "Aaron Turner"; |
|---|
| 7 | type = "bsd"; |
|---|
| 8 | author = <<- EOText |
|---|
| 9 | Copyright 2000-2008 Aaron Turner |
|---|
| 10 | |
|---|
| 11 | For support please use the tcpreplay-users@lists.sourceforge.net mailing list. |
|---|
| 12 | |
|---|
| 13 | The latest version of this software is always available from: |
|---|
| 14 | http://tcpreplay.synfin.net/ |
|---|
| 15 | EOText; |
|---|
| 16 | }; |
|---|
| 17 | |
|---|
| 18 | package = "tcpbridge"; |
|---|
| 19 | prog-name = "tcpbridge"; |
|---|
| 20 | prog-title = "Bridge network traffic across two interfaces"; |
|---|
| 21 | long-opts; |
|---|
| 22 | gnu-usage; |
|---|
| 23 | help-value = "H"; |
|---|
| 24 | save-opts-value = ""; |
|---|
| 25 | load-opts-value = ""; |
|---|
| 26 | config-header = "config.h"; |
|---|
| 27 | |
|---|
| 28 | include = "#include \"defines.h\"\n" |
|---|
| 29 | "#include \"tcpbridge.h\"\n" |
|---|
| 30 | "#include \"common.h\"\n" |
|---|
| 31 | "#include \"config.h\"\n" |
|---|
| 32 | "#include <stdlib.h>\n" |
|---|
| 33 | "#include <string.h>\n" |
|---|
| 34 | "#include <sys/types.h>\n" |
|---|
| 35 | "#include <unistd.h>\n" |
|---|
| 36 | "extern tcpbridge_opt_t options;\n"; |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | #include tcpedit/tcpedit_opts.def |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | homerc = "$$/"; |
|---|
| 43 | |
|---|
| 44 | explain = <<- EOExplain |
|---|
| 45 | tcpbridge is a tool for selectively briding network traffic across two interfaces |
|---|
| 46 | and optionally modifying the packets in betweeen |
|---|
| 47 | EOExplain; |
|---|
| 48 | |
|---|
| 49 | detail = <<- EODetail |
|---|
| 50 | The basic operation of tcpbridge is to be a network bridge between two |
|---|
| 51 | subnets. All packets received on one interface are sent via the other. |
|---|
| 52 | |
|---|
| 53 | Optionally, packets can be edited in a variety of ways according to your needs. |
|---|
| 54 | |
|---|
| 55 | For more details, please see the Tcpreplay Manual at: |
|---|
| 56 | http://tcpreplay.synfin.net/trac/wiki/manual |
|---|
| 57 | EODetail; |
|---|
| 58 | |
|---|
| 59 | man-doc = <<- EOMan |
|---|
| 60 | .SH "SIGNALS" |
|---|
| 61 | tcpbridge understands the following signals: |
|---|
| 62 | @enumerate |
|---|
| 63 | @item @var{SIGUSR1} |
|---|
| 64 | Suspend tcpbridge |
|---|
| 65 | @item @var{SIGCONT} |
|---|
| 66 | Restart tcpbridge |
|---|
| 67 | @end enumerate |
|---|
| 68 | |
|---|
| 69 | .SH "SEE ALSO" |
|---|
| 70 | tcpdump(1), tcpprep(1), tcprewrite(1), tcpreplay(1) |
|---|
| 71 | |
|---|
| 72 | .SH "BUGS" |
|---|
| 73 | tcpbridge can only send packets as fast as your computer's interface, |
|---|
| 74 | processor and system bus will allow. |
|---|
| 75 | |
|---|
| 76 | Connecting both interfaces to the same subnet may create a broadcast storm and |
|---|
| 77 | take down the network. Improper use of the packet editing functions may have |
|---|
| 78 | other undefined and possible negative consequences. |
|---|
| 79 | |
|---|
| 80 | Some operating systems by default do not allow for forging source MAC |
|---|
| 81 | addresses. Please consult your operating system's documentation and the |
|---|
| 82 | tcpreplay FAQ if you experiance this issue. |
|---|
| 83 | EOMan; |
|---|
| 84 | |
|---|
| 85 | /* |
|---|
| 86 | * Debugging |
|---|
| 87 | */ |
|---|
| 88 | |
|---|
| 89 | flag = { |
|---|
| 90 | ifdef = DEBUG; |
|---|
| 91 | name = dbug; |
|---|
| 92 | value = d; |
|---|
| 93 | arg-type = number; |
|---|
| 94 | max = 1; |
|---|
| 95 | immediate; |
|---|
| 96 | arg-range = "0->5"; |
|---|
| 97 | arg-default = 0; |
|---|
| 98 | descrip = "Enable debugging output"; |
|---|
| 99 | doc = <<- EOText |
|---|
| 100 | If configured with --enable-debug, then you can specify a verbosity |
|---|
| 101 | level for debugging output. Higher numbers increase verbosity. |
|---|
| 102 | EOText; |
|---|
| 103 | }; |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | /* |
|---|
| 107 | * Outputs: -i, -I |
|---|
| 108 | */ |
|---|
| 109 | |
|---|
| 110 | flag = { |
|---|
| 111 | name = intf1; |
|---|
| 112 | value = i; |
|---|
| 113 | arg-type = string; |
|---|
| 114 | max = 1; |
|---|
| 115 | must-set; |
|---|
| 116 | descrip = "Primary interface (listen in uni-directional mode)"; |
|---|
| 117 | doc = ""; |
|---|
| 118 | }; |
|---|
| 119 | |
|---|
| 120 | flag = { |
|---|
| 121 | name = intf2; |
|---|
| 122 | value = I; |
|---|
| 123 | arg-type = string; |
|---|
| 124 | max = 1; |
|---|
| 125 | descrip = "Secondary interface (send in uni-directional mode)"; |
|---|
| 126 | doc = ""; |
|---|
| 127 | }; |
|---|
| 128 | |
|---|
| 129 | flag = { |
|---|
| 130 | name = unidir; |
|---|
| 131 | value = u; |
|---|
| 132 | max = 1; |
|---|
| 133 | descrip = "Send and receive in only one direction"; |
|---|
| 134 | doc = <<- EOText |
|---|
| 135 | Normally, tcpbridge will send and receive traffic in both directions |
|---|
| 136 | (bi-directionally). However, if you choose this option, traffic will |
|---|
| 137 | be sent uni-directionally. |
|---|
| 138 | EOText; |
|---|
| 139 | }; |
|---|
| 140 | |
|---|
| 141 | /* |
|---|
| 142 | * Select which packets to process |
|---|
| 143 | */ |
|---|
| 144 | |
|---|
| 145 | flag = { |
|---|
| 146 | name = limit; |
|---|
| 147 | value = L; |
|---|
| 148 | arg-type = number; |
|---|
| 149 | max = 1; |
|---|
| 150 | arg-default = -1; |
|---|
| 151 | arg-range = "1->"; |
|---|
| 152 | descrip = "Limit the number of packets to send"; |
|---|
| 153 | doc = <<- EOText |
|---|
| 154 | By default, tcpbridge will send packets forever or until Ctrl-C. Alternatively, |
|---|
| 155 | you can specify a maximum number of packets to send. |
|---|
| 156 | EOText; |
|---|
| 157 | }; |
|---|
| 158 | |
|---|
| 159 | /* |
|---|
| 160 | * Windows users need to provide the MAC addresses of the interfaces |
|---|
| 161 | * so we can prevent looping (since winpcap doesn't have an API to query) |
|---|
| 162 | * the MAC address of the NIC's |
|---|
| 163 | */ |
|---|
| 164 | flag = { |
|---|
| 165 | name = mac; |
|---|
| 166 | value = M; |
|---|
| 167 | arg-type = string; |
|---|
| 168 | max = 2; |
|---|
| 169 | stack-arg; |
|---|
| 170 | descrip = "MAC addresses of local NIC's"; |
|---|
| 171 | doc = <<- EOText |
|---|
| 172 | tcpbridge does not support detecting the MAC addresses of the local network |
|---|
| 173 | interfaces under Windows. Please specify both MAC addresses of the interfaces |
|---|
| 174 | used in the bridge: -M <intf1 mac> -M <intf2 mac> |
|---|
| 175 | EOText; |
|---|
| 176 | }; |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | /* Include/Exclude */ |
|---|
| 180 | flag = { |
|---|
| 181 | name = include; |
|---|
| 182 | value = x; |
|---|
| 183 | arg-type = string; |
|---|
| 184 | max = 1; |
|---|
| 185 | descrip = "Include only packets matching rule"; |
|---|
| 186 | flags-cant = exclude; |
|---|
| 187 | flag-code = <<- EOInclude |
|---|
| 188 | |
|---|
| 189 | char *include; |
|---|
| 190 | |
|---|
| 191 | include = safe_strdup(OPT_ARG(INCLUDE)); |
|---|
| 192 | options.xX.mode = xX_MODE_INCLUDE; |
|---|
| 193 | |
|---|
| 194 | if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError) |
|---|
| 195 | errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE)); |
|---|
| 196 | |
|---|
| 197 | free(include); |
|---|
| 198 | |
|---|
| 199 | EOInclude; |
|---|
| 200 | doc = <<- EOText |
|---|
| 201 | Override default of sending all packets stored in the capture file and only |
|---|
| 202 | send packets which match the provided rule. Rules can be one of: |
|---|
| 203 | |
|---|
| 204 | @table @bullet |
|---|
| 205 | @item S:<CIDR1>,... |
|---|
| 206 | - Source IP must match specified CIDR(s) |
|---|
| 207 | @item D:<CIDR1>,... |
|---|
| 208 | - Destination IP must match specified CIDR(s) |
|---|
| 209 | @item B:<CIDR1>,... |
|---|
| 210 | - Both source and destination IP must match specified CIDR(s) |
|---|
| 211 | @item E:<CIDR1>,... |
|---|
| 212 | - Either IP must match specified CIDR(s) |
|---|
| 213 | @item P:<LIST> |
|---|
| 214 | - Must be one of the listed packets where the list |
|---|
| 215 | corresponds to the packet number in the capture file. |
|---|
| 216 | @example |
|---|
| 217 | --include=P:1-5,9,15,72- |
|---|
| 218 | @end example |
|---|
| 219 | would send packets 1 thru 5, the 9th and 15th packet, and packets 72 until the |
|---|
| 220 | end of the file |
|---|
| 221 | @item F:'<bpf>' |
|---|
| 222 | - BPF filter. See the @file{tcpdump(8)} man page for syntax. |
|---|
| 223 | @end table |
|---|
| 224 | EOText; |
|---|
| 225 | }; |
|---|
| 226 | |
|---|
| 227 | flag = { |
|---|
| 228 | name = exclude; |
|---|
| 229 | value = X; |
|---|
| 230 | arg-type = string; |
|---|
| 231 | max = 1; |
|---|
| 232 | descrip = "Exclude any packet matching this rule"; |
|---|
| 233 | flags-cant = include; |
|---|
| 234 | flag-code = <<- EOExclude |
|---|
| 235 | |
|---|
| 236 | char *exclude; |
|---|
| 237 | |
|---|
| 238 | exclude = safe_strdup(OPT_ARG(EXCLUDE)); |
|---|
| 239 | options.xX.mode = xX_MODE_EXCLUDE; |
|---|
| 240 | |
|---|
| 241 | if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError) |
|---|
| 242 | errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE)); |
|---|
| 243 | |
|---|
| 244 | free(exclude); |
|---|
| 245 | |
|---|
| 246 | EOExclude; |
|---|
| 247 | doc = <<- EOText |
|---|
| 248 | Override default of sending all packets stored in the capture file and only |
|---|
| 249 | send packets which do not match the provided rule. Rules can be one of: |
|---|
| 250 | |
|---|
| 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 | --exclude=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 | |
|---|
| 272 | flag = { |
|---|
| 273 | name = pid; |
|---|
| 274 | value = P; |
|---|
| 275 | descrip = "Print the PID of tcpbridge at startup"; |
|---|
| 276 | flag-code = <<- EOPid |
|---|
| 277 | |
|---|
| 278 | fprintf(stderr, "PID: %hu\n", getpid()); |
|---|
| 279 | |
|---|
| 280 | EOPid; |
|---|
| 281 | doc = ""; |
|---|
| 282 | }; |
|---|
| 283 | |
|---|
| 284 | /* Verbose decoding via tcpdump */ |
|---|
| 285 | |
|---|
| 286 | flag = { |
|---|
| 287 | ifdef = ENABLE_VERBOSE; |
|---|
| 288 | name = verbose; |
|---|
| 289 | value = v; |
|---|
| 290 | max = 1; |
|---|
| 291 | immediate; |
|---|
| 292 | descrip = "Print decoded packets via tcpdump to STDOUT"; |
|---|
| 293 | settable; |
|---|
| 294 | doc = ""; |
|---|
| 295 | }; |
|---|
| 296 | |
|---|
| 297 | flag = { |
|---|
| 298 | ifdef = ENABLE_VERBOSE; |
|---|
| 299 | name = decode; |
|---|
| 300 | flags-must = verbose; |
|---|
| 301 | value = A; |
|---|
| 302 | arg-type = string; |
|---|
| 303 | max = 1; |
|---|
| 304 | descrip = "Arguments passed to tcpdump decoder"; |
|---|
| 305 | doc = <<- EOText |
|---|
| 306 | When enabling verbose mode (@var{-v}) you may also specify one or more |
|---|
| 307 | additional arguments to pass to @code{tcpdump} to modify the way packets |
|---|
| 308 | are decoded. By default, -n and -l are used. Be sure to |
|---|
| 309 | quote the arguments like: --verbose="-axxx" so that they are not interpreted |
|---|
| 310 | by tcpbridge. The following arguments are vaild: |
|---|
| 311 | [ -aAeNqRStuvxX ] |
|---|
| 312 | [ -E spi@ipaddr algo:secret,... ] |
|---|
| 313 | [ -s snaplen ] |
|---|
| 314 | EOText; |
|---|
| 315 | }; |
|---|
| 316 | |
|---|
| 317 | flag = { |
|---|
| 318 | name = version; |
|---|
| 319 | value = V; |
|---|
| 320 | descrip = "Print version information"; |
|---|
| 321 | flag-code = <<- EOVersion |
|---|
| 322 | |
|---|
| 323 | fprintf(stderr, "tcpbridge version: %s (build %s)", VERSION, svn_version()); |
|---|
| 324 | #ifdef DEBUG |
|---|
| 325 | fprintf(stderr, " (debug)"); |
|---|
| 326 | #endif |
|---|
| 327 | fprintf(stderr, "\n"); |
|---|
| 328 | fprintf(stderr, "Copyright 2001-2008 by Aaron Turner <aturner at synfin dot net>\n"); |
|---|
| 329 | #ifdef HAVE_LIBDNET |
|---|
| 330 | fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); |
|---|
| 331 | #else |
|---|
| 332 | fprintf(stderr, "Not compiled with libdnet.\n"); |
|---|
| 333 | #endif |
|---|
| 334 | #ifdef HAVE_WINPCAP |
|---|
| 335 | fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); |
|---|
| 336 | #else |
|---|
| 337 | fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); |
|---|
| 338 | #endif |
|---|
| 339 | #ifdef ENABLE_64BITS |
|---|
| 340 | fprintf(stderr, "64 bit packet counters: enabled\n"); |
|---|
| 341 | #else |
|---|
| 342 | fprintf(stderr, "64 bit packet counters: disabled\n"); |
|---|
| 343 | #endif |
|---|
| 344 | #ifdef ENABLE_VERBOSE |
|---|
| 345 | fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); |
|---|
| 346 | #else |
|---|
| 347 | fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); |
|---|
| 348 | #endif |
|---|
| 349 | exit(0); |
|---|
| 350 | |
|---|
| 351 | EOVersion; |
|---|
| 352 | doc = ""; |
|---|
| 353 | }; |
|---|
| 354 | |
|---|
| 355 | flag = { |
|---|
| 356 | name = less-help; |
|---|
| 357 | value = "h"; |
|---|
| 358 | immediate; |
|---|
| 359 | descrip = "Display less usage information and exit"; |
|---|
| 360 | flag-code = <<- EOHelp |
|---|
| 361 | |
|---|
| 362 | USAGE(EXIT_FAILURE); |
|---|
| 363 | |
|---|
| 364 | EOHelp; |
|---|
| 365 | doc = ""; |
|---|
| 366 | }; |
|---|