mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-05 05:52:37 +00:00
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
This commit is contained in:
parent
a1ed734076
commit
684d041896
2 changed files with 17 additions and 7 deletions
|
@ -360,20 +360,28 @@ gst_pcap_parse_scan_frame (GstPcapParse * self,
|
||||||
guint16 len;
|
guint16 len;
|
||||||
|
|
||||||
switch (self->linktype) {
|
switch (self->linktype) {
|
||||||
case DLT_ETHER:
|
case LINKTYPE_ETHER:
|
||||||
if (buf_size < ETH_HEADER_LEN + IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
|
if (buf_size < ETH_HEADER_LEN + IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
eth_type = GUINT16_FROM_BE (*((guint16 *) (buf + 12)));
|
eth_type = GUINT16_FROM_BE (*((guint16 *) (buf + 12)));
|
||||||
buf_ip = buf + ETH_HEADER_LEN;
|
buf_ip = buf + ETH_HEADER_LEN;
|
||||||
break;
|
break;
|
||||||
case DLT_SLL:
|
case LINKTYPE_SLL:
|
||||||
if (buf_size < SLL_HEADER_LEN + IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
|
if (buf_size < SLL_HEADER_LEN + IP_HEADER_MIN_LEN + UDP_HEADER_LEN)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
eth_type = GUINT16_FROM_BE (*((guint16 *) (buf + 14)));
|
eth_type = GUINT16_FROM_BE (*((guint16 *) (buf + 14)));
|
||||||
buf_ip = buf + SLL_HEADER_LEN;
|
buf_ip = buf + SLL_HEADER_LEN;
|
||||||
break;
|
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:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -569,10 +577,11 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
goto out;
|
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),
|
GST_ELEMENT_ERROR (self, STREAM, WRONG_TYPE, (NULL),
|
||||||
("Only dumps of type Ethernet or Linux Coooked (SLL) understood,"
|
("Only dumps of type Ethernet, raw IP or Linux Cooked (SLL) "
|
||||||
" type %d unknown", linktype));
|
"understood; type %d unknown", linktype));
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,9 @@ typedef enum
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
DLT_ETHER = 1,
|
LINKTYPE_ETHER = 1,
|
||||||
DLT_SLL = 113
|
LINKTYPE_RAW = 101,
|
||||||
|
LINKTYPE_SLL = 113
|
||||||
} GstPcapParseLinktype;
|
} GstPcapParseLinktype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue