dump: recognize LINUX_SLL link-type
refs #3061
Change-Id: Idf50a70f17a1c9ffedbed5697ca11070d35e95a3
diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp
index d23bf9a..91d6827 100644
--- a/tools/dump/ndndump.cpp
+++ b/tools/dump/ndndump.cpp
@@ -50,6 +50,8 @@
} // namespace dump
} // namespace ndn
+#include <pcap/sll.h>
+
#include <boost/lexical_cast.hpp>
#include <iomanip>
@@ -139,7 +141,7 @@
}
m_dataLinkType = pcap_datalink(m_pcap);
- if (m_dataLinkType != DLT_EN10MB && m_dataLinkType != DLT_PPP) {
+ if (m_dataLinkType != DLT_EN10MB && m_dataLinkType != DLT_PPP && m_dataLinkType != DLT_LINUX_SLL) {
BOOST_THROW_EXCEPTION(Error("Unsupported pcap format (" + to_string(m_dataLinkType) + ")"));
}
@@ -297,6 +299,20 @@
break;
}
+ case DLT_LINUX_SLL: {
+ const sll_header* sllHeader = reinterpret_cast<const sll_header*>(payload);
+
+ if (payloadSize < SLL_HDR_LEN) {
+ std::cerr << "Invalid LINUX_SLL frame" << std::endl;
+ return -1;
+ }
+
+ frameType = ntohs(sllHeader->sll_protocol);
+ payloadSize -= SLL_HDR_LEN;
+ payload += SLL_HDR_LEN;
+
+ break;
+ }
}
return frameType;