summaryrefslogtreecommitdiff
path: root/gst/pcapparse
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2014-10-09 04:11:00 -0400
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2014-10-09 12:46:10 -0400
commit684d0418969820f165978355104400167515b5c4 (patch)
tree6a9d50efb615f50b49910de256f9da68592ed429 /gst/pcapparse
parenta1ed73407610fd4c36a4cca4fb62469555e89a8a (diff)
downloadgstreamer-plugins-bad-684d0418969820f165978355104400167515b5c4.tar.gz
pcapparse: Add support for LINKTYPE_RAW
Also, strictly speaking, these numbers aren't DLT_*; they are LINKTYPE_* because libpcap translates from internal OS-specific DLT_ numbering to the portable LINKTYPE_ number space when writing files. https://bugzilla.gnome.org/show_bug.cgi?id=738206
Diffstat (limited to 'gst/pcapparse')
-rw-r--r--gst/pcapparse/gstpcapparse.c19
-rw-r--r--gst/pcapparse/gstpcapparse.h5
2 files changed, 17 insertions, 7 deletions
diff --git a/gst/pcapparse/gstpcapparse.c b/gst/pcapparse/gstpcapparse.c
index 069d75970..ade724d1a 100644
--- a/gst/pcapparse/gstpcapparse.c
+++ b/gst/pcapparse/gstpcapparse.c
@@ -360,20 +360,28 @@ gst_pcap_parse_scan_frame (GstPcapParse * self,
guint16 len;
switch (self->linktype) {
- case DLT_ETHER:
+ 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;
break;
- case DLT_SLL:
+ case LINKTYPE_SLL:
if (buf_size < SLL_HEADER_LEN + IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
return FALSE;
eth_type = GUINT16_FROM_BE (*((guint16 *) (buf + 14)));
buf_ip = buf + SLL_HEADER_LEN;
break;
+ case LINKTYPE_RAW:
+ if (buf_size < IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
+ return FALSE;
+
+ eth_type = 0x800; /* This is fine since IPv4/IPv6 is parse elsewhere */
+ buf_ip = buf;
+ break;
+
default:
return FALSE;
}
@@ -569,10 +577,11 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
goto out;
}
- if (linktype != DLT_ETHER && linktype != DLT_SLL) {
+ if (linktype != LINKTYPE_ETHER && linktype != LINKTYPE_SLL &&
+ linktype != LINKTYPE_RAW) {
GST_ELEMENT_ERROR (self, STREAM, WRONG_TYPE, (NULL),
- ("Only dumps of type Ethernet or Linux Coooked (SLL) understood,"
- " type %d unknown", linktype));
+ ("Only dumps of type Ethernet, raw IP or Linux Cooked (SLL) "
+ "understood; type %d unknown", linktype));
ret = GST_FLOW_ERROR;
goto out;
}
diff --git a/gst/pcapparse/gstpcapparse.h b/gst/pcapparse/gstpcapparse.h
index ef90ea2e7..2c9216f0a 100644
--- a/gst/pcapparse/gstpcapparse.h
+++ b/gst/pcapparse/gstpcapparse.h
@@ -47,8 +47,9 @@ typedef enum
typedef enum
{
- DLT_ETHER = 1,
- DLT_SLL = 113
+ LINKTYPE_ETHER = 1,
+ LINKTYPE_RAW = 101,
+ LINKTYPE_SLL = 113
} GstPcapParseLinktype;
/**