Commit 130d0966 authored by OleksandrKvl's avatar OleksandrKvl Committed by Sebastian Dröge

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
parent 934d0fcd
Pipeline #44516 passed with stages
in 52 minutes and 39 seconds
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment