Skip to content

Commit

Permalink
Merge pull request #664 from appneta/Bug_#582_fixlen_option_fails_on_…
Browse files Browse the repository at this point in the history
…dlt_conversion

Bug #582 calculate L2 length based on exporter DLT
  • Loading branch information
fklassen authored Apr 29, 2021
2 parents 8f2cf1e + 0c418ff commit 4d304bd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- fix UNUSED macro declaration (#614)
- handle malformed and unsupported packets as soft errors (#613)
- compile failure on aarch64-linux-android (#612)
- tcprewrite --fixlen not working (#582)
- tcprewrite --fixlen not working on DLT conversion (#582)
- fix configure --without-libdnet (#567)
- ensure automake version is at least 1.15 (#553)
- with multiplier option only first file can be sent and hang (#472)
Expand Down
12 changes: 8 additions & 4 deletions src/tcpedit/dlt.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ dlt2mtu(tcpedit_t *tcpedit, int dlt)
* for it to be at all useful.
*/
int
layer2len(tcpedit_t *tcpedit)
layer2len(tcpedit_t *tcpedit, u_char *packet, uint32_t caplen)
{
assert(tcpedit);

return tcpedit->dlt_ctx->l2len;
assert(tcpedit);
assert(tcpedit->dlt_ctx);
assert(tcpedit->dlt_ctx->encoder);

return tcpedit->dlt_ctx->encoder->plugin_l2len(tcpedit->dlt_ctx,
packet,
caplen);
}

2 changes: 1 addition & 1 deletion src/tcpedit/dlt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
int dlt2layer2len(tcpedit_t *tcpedit, int dlt);
int dltrequires(tcpedit_t *tcpedit, int dlt);
int dlt2mtu(tcpedit_t *tcpedit, int dlt);
int layer2len(tcpedit_t *tcpedit);
int layer2len(tcpedit_t *tcpedit, u_char *packet, uint32_t caplen);

#endif /* _DLT_H_ */

Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/edit_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ untrunc_packet(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr,
return(0);
}

if ((l2len = layer2len(tcpedit)) < 0) {
if ((l2len = layer2len(tcpedit, packet, pkthdr->caplen)) < 0) {
tcpedit_seterr(tcpedit, "Non-sensical layer 2 length: %d", l2len);
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/plugins/dlt_en10mb/en10mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "en10mb.h"


static char _U_ dlt_name[] = "en10mb";
static char dlt_name[] = "en10mb";
static char dlt_prefix[] = "enet";
static uint16_t dlt_value = DLT_EN10MB;

Expand Down

0 comments on commit 4d304bd

Please sign in to comment.