diff options
author | OleksandrKvl <oleksandrdvl@gmail.com> | 2019-06-24 18:39:35 +0300 |
---|---|---|
committer | Sebastian Dröge <slomo@coaxion.net> | 2019-06-24 15:55:38 +0000 |
commit | 130d096608723dcee48b23f92081687c37c4ff34 (patch) | |
tree | d466e04196e7a5f06ed486eaf3c07c2b6e090a20 /gst/pcapparse | |
parent | 934d0fcdd3ad61ad990ee651bf7bde4e1bbbfa2e (diff) | |
download | gstreamer-plugins-bad-130d096608723dcee48b23f92081687c37c4ff34.tar.gz |
pcapparse: Fix handling of TCP payload length
The length of the TCP payload is the IP plus TCP header length
subtracted from the IP datagram length specified in the IP header.
Prior to this, the size was calculated incorrectly, considering
all data after TCP header as a payload till the end of a packet.
Fixes #995
Diffstat (limited to 'gst/pcapparse')
-rw-r--r-- | gst/pcapparse/gstpcapparse.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gst/pcapparse/gstpcapparse.c b/gst/pcapparse/gstpcapparse.c index 0670407b7..3ea656b2f 100644 --- a/gst/pcapparse/gstpcapparse.c +++ b/gst/pcapparse/gstpcapparse.c @@ -374,6 +374,7 @@ gst_pcap_parse_scan_frame (GstPcapParse * self, guint16 src_port; guint16 dst_port; guint16 len; + guint16 ip_packet_len; switch (self->linktype) { case LINKTYPE_ETHER: @@ -448,6 +449,7 @@ gst_pcap_parse_scan_frame (GstPcapParse * self, ip_src_addr = *((guint32 *) (buf_ip + 12)); ip_dst_addr = *((guint32 *) (buf_ip + 16)); buf_proto = buf_ip + ip_header_size; + ip_packet_len = GUINT16_FROM_BE (*(guint16 *) (buf_ip + 2)); /* ok for tcp and udp */ src_port = GUINT16_FROM_BE (*((guint16 *) (buf_proto + 0))); @@ -470,7 +472,7 @@ gst_pcap_parse_scan_frame (GstPcapParse * self, /* all remaining data following tcp header is payload */ *payload = buf_proto + len; - *payload_size = self->cur_packet_size - (buf_proto - buf) - len; + *payload_size = ip_packet_len - ip_header_size - len; } /* but still filter as configured */ |