-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs in promote_packet() and demote_packet()
* libtrace_pcapfile_pkt_hdr_t, as used by pcapfile, is not the same as pcap_pkthdr_t, used by pcap. Notably, libtrace_pcapfile_pkt_hdr_t has a 32-bit timestamp and pcap_pkthdr_t uses timeval which varies in size depending on the platform. - Because of this promote_packet() actually adjusted the timestamp and not the caplen or wirelen. - Once demoted again the caplen was shorter than it should have been * Fix demote_packet() to decrease the wire length again - This is still missing for non-pcap types * Fix possible unaligned access in promote_packet (gcc warning) * Cache calls to trace_get_framing/capture_length, we really shouldn't be calling packet operations while modifying the packet, even though the values will come from the packet cache. I think fundamentally promote_packet() should be removed and replaced with storing the value in the packet's cache. promote_packet() is currently only used when setting the direction on a pcap: packet but not a pcapfile: packet. Related to issue #28. Modifying the packet payload when you set a direction on a packet is unexpected behaviour from a users perspective. Demote_packet() still seems to be needed for writing packets. But I think we should copy the packet, so the packet being written isn't modified.
- Loading branch information
Showing
2 changed files
with
32 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters