1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-30 13:34:27 +01:00

Fixed PKTAP next layer interpretation.

This commit is contained in:
Matias Fontanini
2014-12-21 10:51:18 -08:00
parent a4c67e5acd
commit 65607b0eb5
6 changed files with 68 additions and 3 deletions

View File

@@ -27,6 +27,7 @@
*
*/
#include <pcap.h>
#include "internals.h"
#include "ip.h"
#include "ethernetII.h"
@@ -38,12 +39,16 @@
#include "udp.h"
#include "ipsec.h"
#include "icmp.h"
#include "loopback.h"
#include "sll.h"
#include "ppi.h"
#include "icmpv6.h"
#include "arp.h"
#include "eapol.h"
#include "rawpdu.h"
#include "dot1q.h"
#include "pppoe.h"
#include "exceptions.h"
#include "ip_address.h"
#include "ipv6_address.h"
#include "pdu_allocator.h"
@@ -134,6 +139,35 @@ Tins::PDU *pdu_from_flag(Constants::IP::e flag, const uint8_t *buffer,
return 0;
}
PDU *pdu_from_dlt_flag(int flag, const uint8_t *buffer,
uint32_t size, bool rawpdu_on_no_match)
{
switch (flag) {
case DLT_EN10MB:
return new EthernetII(buffer, size);
#ifdef HAVE_DOT11
case DLT_IEEE802_11_RADIO:
return new RadioTap(buffer, size);
case DLT_IEEE802_11:
return Dot11::from_bytes(buffer, size);
#else // HAVE_DOT11
case DLT_IEEE802_11_RADIO:
case DLT_IEEE802_11:
throw protocol_disabled();
#endif // HAVE_DOT11
case DLT_NULL:
return new Loopback(buffer, size);
case DLT_LINUX_SLL:
return new SLL(buffer, size);
case DLT_PPI:
return new PPI(buffer, size);
default:
return rawpdu_on_no_match ? new RawPDU(buffer, size) : 0;
};
}
Tins::PDU *pdu_from_flag(PDU::PDUType type, const uint8_t *buffer, uint32_t size)
{
switch(type) {

View File

@@ -49,8 +49,8 @@ PKTAP::PKTAP(const uint8_t* buffer, uint32_t total_sz)
total_sz -= header_length;
if (header_.next && total_sz > 0) {
inner_pdu(
Internals::pdu_from_flag(
(Constants::Ethernet::e)header_.dlt,
Internals::pdu_from_dlt_flag(
header_.dlt,
buffer,
total_sz
)

View File

@@ -162,7 +162,7 @@ PtrPacket BaseSniffer::next_packet() {
}
#ifdef DLT_PKTAP
else if (iface_type == DLT_PKTAP) {
handler = &sniff_loop_handler<PKTAP>();
handler = &sniff_loop_handler<PKTAP>;
}
#endif // DLT_PKTAP
else if(iface_type == DLT_NULL)