1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 04:11:35 +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) {