summaryrefslogtreecommitdiff
path: root/gst/pcapparse/gstpcapparse.c
diff options
context:
space:
mode:
authorAaron Boxer <boxerab@gmail.com>2017-08-03 11:16:20 -0400
committerSebastian Dröge <sebastian@centricular.com>2017-08-09 09:52:12 +0300
commit27c04cf912502e7b9ae5635b56d4349696a02f43 (patch)
treedecf7f16e1c296c9cb9dd952fe03f0345ab47e66 /gst/pcapparse/gstpcapparse.c
parent111921ae7031d54c40eb9beaed2eaf36b5865023 (diff)
downloadgstreamer-plugins-bad-27c04cf912502e7b9ae5635b56d4349696a02f43.tar.gz
pcapparse: support vlan 802.1q
https://bugzilla.gnome.org/show_bug.cgi?id=785778
Diffstat (limited to 'gst/pcapparse/gstpcapparse.c')
-rw-r--r--gst/pcapparse/gstpcapparse.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gst/pcapparse/gstpcapparse.c b/gst/pcapparse/gstpcapparse.c
index b1fa6c89f..89334f538 100644
--- a/gst/pcapparse/gstpcapparse.c
+++ b/gst/pcapparse/gstpcapparse.c
@@ -341,7 +341,9 @@ gst_pcap_parse_read_uint32 (GstPcapParse * self, const guint8 * p)
}
}
+#define ETH_MAC_ADDRESSES_LEN 12
#define ETH_HEADER_LEN 14
+#define ETH_VLAN_HEADER_LEN 4
#define SLL_HEADER_LEN 16
#define IP_HEADER_MIN_LEN 20
#define UDP_HEADER_LEN 8
@@ -371,9 +373,20 @@ gst_pcap_parse_scan_frame (GstPcapParse * self,
case LINKTYPE_ETHER:
if (buf_size < ETH_HEADER_LEN + IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
return FALSE;
-
- eth_type = GUINT16_FROM_BE (*((guint16 *) (buf + 12)));
- buf_ip = buf + ETH_HEADER_LEN;
+ eth_type = GUINT16_FROM_BE (*((guint16 *) (buf + ETH_MAC_ADDRESSES_LEN)));
+ /* check for vlan 802.1q header (4 bytes, with first two bytes equal to 0x8100) */
+ if (eth_type == 0x8100) {
+ if (buf_size <
+ ETH_HEADER_LEN + ETH_VLAN_HEADER_LEN + IP_HEADER_MIN_LEN +
+ UDP_HEADER_LEN)
+ return FALSE;
+ eth_type =
+ GUINT16_FROM_BE (*((guint16 *) (buf + ETH_MAC_ADDRESSES_LEN +
+ ETH_VLAN_HEADER_LEN)));
+ buf_ip = buf + ETH_HEADER_LEN + ETH_VLAN_HEADER_LEN;
+ } else {
+ buf_ip = buf + ETH_HEADER_LEN;
+ }
break;
case LINKTYPE_SLL:
if (buf_size < SLL_HEADER_LEN + IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
@@ -394,8 +407,12 @@ gst_pcap_parse_scan_frame (GstPcapParse * self,
return FALSE;
}
- if (eth_type != 0x800)
+ if (eth_type != 0x800) {
+ GST_ERROR_OBJECT (self,
+ "Link type %d: Ethernet type %d is not supported; only type 0x800",
+ (gint) self->linktype, (gint) eth_type);
return FALSE;
+ }
b = *buf_ip;
if (((b >> 4) & 0x0f) != 4)