Skip to content

Commit

Permalink
Bug #863: test update to diagnose TOS test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Jun 2, 2024
1 parent ff77374 commit e1f6a9f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/tcpedit/tcpedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,21 @@ tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr, u_char **pktdata
/* set TOS ? */
if (tcpedit->tos > -1) {
volatile uint16_t oldval = *((uint16_t *)ip_hdr);
volatile uint16_t newval;
volatile uint16_t oldcsum, newval;

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

View workflow job for this annotation

GitHub Actions / cpp-linter

src/tcpedit/tcpedit.c:186:13 [readability-isolate-declaration]

multiple declarations in a single statement reduces readability

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

View workflow job for this annotation

GitHub Actions / cpp-linter

src/tcpedit/tcpedit.c:186:31 [cppcoreguidelines-init-variables]

variable 'oldcsum' is not initialized

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

View workflow job for this annotation

GitHub Actions / cpp-linter

src/tcpedit/tcpedit.c:186:40 [cppcoreguidelines-init-variables]

variable 'newval' is not initialized

ip_hdr->ip_tos = tcpedit->tos;
newval = *((uint16_t *)ip_hdr);
// ip_hdr->ip_tos = tcpedit->tos;
// newval = *((uint16_t *)ip_hdr);
newval = htons(ntohs(*((uint16_t *)ip_hdr)) | (tcpedit->tos & 0xffff));
oldcsum = ip_hdr->ip_sum;
static uint32_t cnt;
csum_replace2(&ip_hdr->ip_sum, oldval, newval);
notice("tos %u: pkt=%u old/new: tos=0x%04x/0x%04x csum=0x%04x/0x%04x\n",
tcpedit->tos,
++cnt,
htons(oldval),
htons(newval),
htons(oldcsum),
htons(ip_hdr->ip_sum));
}

/* rewrite the TTL */
Expand Down

0 comments on commit e1f6a9f

Please sign in to comment.