mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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
This commit is contained in:
parent
934d0fcdd3
commit
130d096608
1 changed files with 3 additions and 1 deletions
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue