Skip to content

Commit

Permalink
Bug #844 PR# 846: --fixhdrlen option
Browse files Browse the repository at this point in the history
added to control action on packet length changes

Verification

```
~/git/tcpreplay/build Bug_703_844_PR_846_optionally_fix_pkt_hdr_len* ⇡
❯ src/tcprewrite --cachefile=pcaps/pcap.cache \
    --infile=pcaps/cap-original-packet-3.pcap \
    --outfile=pcaps/cap-4.5.0-packet-out.pcap \
    --endpoints=10.200.1.1:10.200.1.2
Warning in ../../src/tcprewrite.c:post_args() line 231:
pcaps/cap-original-packet-3.pcap was captured using a snaplen of 1514 bytes.  This may mean you have truncated packets.
~/git/tcpreplay/build Bug_703_844_PR_846_optionally_fix_pkt_hdr_len* ⇡
❯ diff pcaps/cap-4.4.0-packet-3.pcap pcaps/cap-4.5.0-packet-out.pcap
~/git/tcpreplay/build Bug_703_844_PR_846_optionally_fix_pkt_hdr_len* ⇡
❯
```
  • Loading branch information
fklassen committed Jun 1, 2024
1 parent b4148e7 commit 859728b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
06/01/2024 Version 4.5.0-beta1
- --fixhdrlen option added to control action on packet length changes (#846)
- incorrect checksum for certain IPv4 packets - fixed by #846 (#844)
- add check for IPv6 extension header length (#827 #842)
- add check for empty CIDR (#824 #843)
- GitHub template for pull requests (#839)
Expand Down
3 changes: 2 additions & 1 deletion docs/CREDIT
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ GithHub @plangarbalint

Chuck Cottrill <GitHub @ChuckCottrill>
- handle IPv6 fragment extensions

- --fixhdrlen option
- bug fixes

Martin 'JaMa' Jansa <GitHub @shr-project>
- configure.ac: unify search dirs for pcap and add lib32
2 changes: 0 additions & 2 deletions src/tcpedit/parse_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ tcpedit_post_args(tcpedit_t *tcpedit)
/* --fixhdrlen */
if (HAVE_OPT(FIXHDRLEN))
tcpedit->fixhdrlen = true;
else
tcpedit->fixhdrlen = false;

/* --efcs */
if (HAVE_OPT(EFCS))
Expand Down
3 changes: 1 addition & 2 deletions src/tcpedit/tcpedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr, u_char **pktdata
/* ensure IP header length is correct */
int changed = 0;
if (ip_hdr != NULL) {

Check warning on line 323 in src/tcpedit/tcpedit.c

View workflow job for this annotation

GitHub Actions / cpp-linter

src/tcpedit/tcpedit.c:323:29 [bugprone-branch-clone]

repeated branch in conditional chain
fix_ipv4_length(*pkthdr, ip_hdr, l2len);
changed = 1;
changed = fix_ipv4_length(*pkthdr, ip_hdr, l2len);
} else if (ip6_hdr != NULL) {
changed = fix_ipv6_length(*pkthdr, ip6_hdr, l2len);
}
Expand Down
5 changes: 2 additions & 3 deletions src/tcpedit/tcpedit_opts.def
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,12 @@ EOText;

flag = {
name = fixhdrlen;
// value = C;
descrip = "fix IP/TCP header len";
descrip = "Alter IP/TCP header len to match packet length";
doc = <<- EOText
By default, tcpreplay will send packets with the original packet length,
However, you may want the packet length revised to minimum packet size.
Using this option, tcpreplay will rewrite (fix) the packet length,
and recalculate checksums.
and recalculate checksums when packet length changes.
Caution: undesired packet changes may occur when this option is specified.
EOText;
};
Expand Down

0 comments on commit 859728b

Please sign in to comment.