Skip to content

Commit 653c9e1

Browse files
authored
Merge pull request #67 from koumajos/add_raw_format
Add DLT_RAW format of PCAP
2 parents 1efaeb0 + f04a9f2 commit 653c9e1

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

input/parser.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,14 @@ void parse_packet(parser_opt_t *opt, struct timeval ts, const uint8_t *data, uin
617617
#ifdef WITH_PCAP
618618
if (opt->datalink == DLT_EN10MB) {
619619
data_offset = parse_eth_hdr(data, caplen, pkt);
620-
} else {
621-
data_offset = parse_sll(data, caplen, pkt);
620+
} else if (opt->datalink == DLT_LINUX_SLL) {
621+
data_offset = parse_sll(data, caplen, pkt);
622+
} else if (opt->datalink == DLT_RAW) {
623+
if ((data[0] & 0xF0) == 0x40) {
624+
pkt->ethertype = ETH_P_IP;
625+
} else if ((data[0] & 0xF0) == 0x60) {
626+
pkt->ethertype = ETH_P_IPV6;
627+
}
622628
}
623629
#else
624630
data_offset = parse_eth_hdr(data, caplen, pkt);

input/parser.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@
5050
#define DLT_EN10MB 1
5151
#endif
5252

53+
#ifndef DLT_LINUX_SLL
54+
#define DLT_LINUX_SLL 113
55+
#endif
56+
57+
#ifndef DLT_RAW
58+
#define DLT_RAW 12
59+
#endif
60+
5361
#ifndef ETH_P_8021AD
5462
#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN*/
5563
#endif

input/pcap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ void PcapReader::open_ifc(const std::string &ifc)
185185

186186
void PcapReader::check_datalink(int datalink)
187187
{
188-
if (m_datalink != DLT_EN10MB && m_datalink != DLT_LINUX_SLL) {
188+
if (m_datalink != DLT_EN10MB && m_datalink != DLT_LINUX_SLL && m_datalink != DLT_RAW) {
189189
close();
190-
throw PluginError("unsupported link type detected, supported types are DLT_EN10MB and DLT_LINUX_SLL");
190+
throw PluginError("unsupported link type detected, supported types are DLT_EN10MB and DLT_LINUX_SLL and DLT_RAW");
191191
}
192192
}
193193

0 commit comments

Comments
 (0)