Skip to content

Commit 1c81f0e

Browse files
galastarclaude
andcommitted
docs: update CHANGELOG/CREDIT/CLAUDE.md for the getopt migration (#991)
- CHANGELOG: record the AutoOpts/libopts -> getopt_long + asciidoctor migration under Unreleased, flag the --load-opts/--save-opts and help-option removals as breaking, and note the standalone bug fixes that rode along with the PR. - CREDIT: add Gabriel Ganne. - CLAUDE.md: rewrite the Build and CLI-option sections, which described the deleted AutoOpts/.def machinery (out-of-tree configure flags, autogen dependency, libopts/ directory, *_opts.def workflow). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 781dc18 commit 1c81f0e

3 files changed

Lines changed: 40 additions & 17 deletions

File tree

CLAUDE.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Out-of-tree build (used by CI):
3434
```
3535
mkdir build && cd build
3636
../autogen.sh
37-
../configure --disable-local-libopts --enable-debug --enable-test-hexdump
37+
../configure --enable-debug --enable-test-hexdump
3838
make
3939
```
4040

@@ -47,8 +47,9 @@ Useful `./configure` flags when working on specific areas:
4747
OS-specific, e.g. `eth0` on Linux, `en0` on macOS — see `configure.ac`)
4848
- `--enable-test-hexdump` - hexdump the pcap on test failure
4949

50-
Requires `libpcap` (and `autogen`/AutoOpts to regenerate `*_opts.def` derived files). On Debian/Ubuntu:
51-
`apt install autogen libpcap-dev automake autoconf libtool`.
50+
Requires `libpcap`. `asciidoctor` (Ruby) is only needed to (re)generate the man pages from their
51+
`docs/*.adoc` sources — release tarballs ship prebuilt man pages. On Debian/Ubuntu:
52+
`apt install libpcap-dev automake autoconf libtool asciidoctor`.
5253

5354
## Tests
5455

@@ -96,26 +97,34 @@ Notes:
9697
packet headers belongs here, not in `tcprewrite.c` directly, since `tcpbridge` depends on the same logic.
9798
- `src/tcpedit/plugins/` - DLT (link-layer type) plugins (`dlt_en10mb`, `dlt_ieee80211`, `dlt_raw`,
9899
`dlt_linuxsll`, `dlt_hdlc`, `dlt_loop`, `dlt_null`, `dlt_pppserial`, `dlt_radiotap`, `dlt_jnpr_ether`,
99-
`dlt_user`, ...) — each implements the same interface (see `dlt_plugins.c`/`dlt_opts.def`) to translate
100+
`dlt_user`, ...) — each implements the same interface (see `dlt_plugins.c`) to translate
100101
a given link layer to/from Ethernet-equivalent processing. `dlt_template`/`dlt_template.sh` scaffold a
101102
new plugin. Adding a new DLT means adding a plugin here, not branching in generic code.
102103
- `src/fragroute/` - vendored/adapted fragroute packet-mangling modules (delay, drop, dup, IP/TCP option
103104
and fragmentation mangling, chaff, reordering) used for traffic-shaping tests.
104105
- `lib/` - small vendored utility code (`strlcpy`/`strlcat`, `queue.h`, `sll.h`, `tree.h`).
105-
- `libopts/` - GNU AutoOpts "tearoff" used to generate CLI parsing.
106106
- `test/` - fixtures and autotools test targets (see Tests section).
107-
- `docs/` - `HACKING` (contribution/coding-standard doc), `CHANGELOG`, `INSTALL`, `SECURITY.md`, plus a
108-
`Makefile.am` that renders the already-built man pages (generated into `src/` from the `*_opts.def`
109-
files, see below) to HTML for the website.
110-
111-
### CLI option definitions (`*_opts.def`)
112-
Each binary's command-line options are declared declaratively in an AutoOpts `.def` file
113-
(`src/tcpreplay_opts.def`, `src/tcpprep_opts.def`, `src/tcprewrite_opts.def`,
114-
`src/tcpedit/tcpedit_opts.def`, etc.), not hand-written `getopt` code. `autogen` (AutoGen, from the
115-
same project as AutoOpts) turns these into generated `*_opts.c`/`.h` and man pages at build time (see
116-
the `.def` dependency rules in `src/Makefile.am`). When adding/changing a CLI flag, edit the relevant
117-
`.def` file rather than the generated `_opts.c`. `tcprewrite`/`tcpbridge` include both their own opts
118-
file and `tcpedit/tcpedit_opts.def` since they expose libtcpedit's rewrite options directly.
107+
- `docs/` - `HACKING` (contribution/coding-standard doc), `CHANGELOG`, `INSTALL`, `SECURITY.md`, the
108+
`*.1.adoc` AsciiDoc man-page sources (see below), plus a `Makefile.am` that renders the man pages to
109+
HTML for the website with `asciidoctor`.
110+
111+
### CLI option parsing (`*_args.c`/`*_args.h`)
112+
Each binary parses its command line with hand-written `getopt_long(3)` code in a matching
113+
`src/<tool>_args.c`/`.h` pair (`tcpreplay_args.c`, `tcpprep_args.c`, `tcprewrite_args.c`, ...), with
114+
shared helpers in `src/common/args.c`. The headers expose AutoOpts-style accessor macros (`HAVE_OPT`,
115+
`OPT_ARG`, `OPT_VALUE_*`) so the consuming code (`*_api.c`, `send_packets.c`, the tcpedit tree) reads
116+
options the same way it did before the AutoOpts removal. The shared libtcpedit rewrite options
117+
(`--portmap`, `--enet-*`, DLT plugin options, ...) live in `src/tcpedit/tcpedit_args.c` and are pulled
118+
into `tcprewrite`, `tcpbridge`, and `tcpreplay-edit`'s option tables via
119+
`tcpedit_args_long_options()`/`tcpedit_args_handle()`; plugin code consumes them through the macros in
120+
`src/tcpedit/tcpedit_stub.h` (`tcpedit_optvals[]`). Option constraints (mutually exclusive flags,
121+
"requires" relationships) are enforced in each parser's `validate_constraints()`.
122+
123+
**Documentation is no longer generated from the option definitions.** Man pages are hand-maintained
124+
AsciiDoc in `docs/*.1.adoc` (shared tcpedit options in `docs/tcpedit_options.adoc`) and rendered with
125+
`asciidoctor` (see the rules in `src/Makefile.am`). When adding/changing a CLI flag you must update
126+
**three** places in tandem: the `*_args.c` option table + handler + `validate_constraints()`, the
127+
usage text in the same file's `print_usage()`, and the corresponding `docs/*.adoc` man-page source.
119128

120129
### Packet injection abstraction (`sendpacket_type_t`)
121130
`src/common/sendpacket.c`/`sendpacket.h` abstract over the many OS-specific ways to inject packets:

docs/CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
Unreleased
2+
- migrate command-line parsing from GNU AutoOpts/libopts to getopt_long(3); the vendored
3+
libopts tearoff and the *_opts.def files are removed, and man pages are now generated
4+
from AsciiDoc sources in docs/ with asciidoctor (maintainers only; release tarballs
5+
ship prebuilt man pages) (#895, #991)
6+
- BREAKING: the AutoOpts rc-file options --load-opts/--save-opts and --more-help are
7+
removed; --short-help/--long-help are replaced by -h/--less-help and -H/--help (#991)
8+
- fix use-after-free of the tcpedit error message on argument parsing failures in
9+
tcpreplay-edit and tcpbridge (#991)
10+
- tcpprep: require both -i (pcap) and -o (cachefile) instead of either one (#991)
211
- send_packets: fix miscalibrated overflow guards in calc_sleep_time() causing tcpreplay to stop
312
pacing (-M/-p) and blast remaining packets at full speed on long/high-count replays (#974, #989)
413
- sendpacket: bounded retry on EAGAIN/ENOBUFS to prevent endless retry loop / 100% CPU hang (#984, #986)

docs/CREDIT

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,8 @@ blaa <GitHub @blaa>
156156

157157
ABcoders <GitHub @AB-Coder96>
158158
- diagnosed and validated the calc_sleep_time() overflow, prototype fix (#989)
159+
160+
Gabriel Ganne <gabriel.ganne@gmail.com>
161+
- migrate command-line parsing from GNU AutoOpts/libopts to getopt_long(3) and
162+
man page generation to asciidoctor (#895, #991)
163+
- fix use-after-free of tcpedit error messages, tcpprep -i/-o requirement check

0 commit comments

Comments
 (0)