diff --git a/include/arp.h b/include/arp.h index 40c6470..5cab63d 100644 --- a/include/arp.h +++ b/include/arp.h @@ -37,6 +37,11 @@ namespace Tins { */ class ARP : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::ARP; + /** * \brief Enum which indicates the type of ARP packet. */ diff --git a/include/bootp.h b/include/bootp.h index 196f4fc..7e1bb93 100644 --- a/include/bootp.h +++ b/include/bootp.h @@ -37,6 +37,11 @@ namespace Tins { class BootP : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::BOOTP; + /** * \brief Enum which contains the different opcodes BootP messages. */ diff --git a/include/dhcp.h b/include/dhcp.h index e4daba3..2828395 100644 --- a/include/dhcp.h +++ b/include/dhcp.h @@ -38,6 +38,11 @@ namespace Tins { */ class DHCP : public BootP { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DHCP; + /** * \brief DHCP flags. */ diff --git a/include/dns.h b/include/dns.h index 7f2e494..76187ae 100644 --- a/include/dns.h +++ b/include/dns.h @@ -34,6 +34,11 @@ namespace Tins { class DNS : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DNS; + enum QRType { QUERY = 0, RESPONSE = 1 diff --git a/include/dot11.h b/include/dot11.h index 6df8891..2f2af58 100644 --- a/include/dot11.h +++ b/include/dot11.h @@ -37,6 +37,11 @@ namespace Tins { */ class Dot11 : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11; + /** * \brief Broadcast hardware address. */ @@ -658,8 +663,11 @@ namespace Tins { * \brief Abstract class that englobes all Management frames in the 802.11 protocol. */ class Dot11ManagementFrame : public Dot11 { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_MANAGEMENT; enum ReasonCodes { UNSPECIFIED = 1, @@ -1283,8 +1291,11 @@ namespace Tins { * */ class Dot11Beacon : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_BEACON; /** * \brief Default constructor for the beacon frame. @@ -1685,8 +1696,11 @@ namespace Tins { * */ class Dot11AssocRequest : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_ASSOC_REQ; /** * \brief Default constructor for the Association Request frame. @@ -1840,8 +1854,11 @@ namespace Tins { * */ class Dot11AssocResponse : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_ASSOC_RESP; /** * \brief Default constructor for the Association Response frame. @@ -1984,8 +2001,11 @@ namespace Tins { * */ class Dot11ReAssocRequest : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_REASSOC_REQ; /** * \brief Default constructor for the ReAssociation Request frame. @@ -2154,8 +2174,11 @@ namespace Tins { * */ class Dot11ReAssocResponse : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_REASSOC_RESP; /** * \brief Default constructor for the ReAssociation Response frame. @@ -2298,8 +2321,11 @@ namespace Tins { * */ class Dot11Authentication : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_AUTH; /** * \brief Default constructor for the Authentication frame. @@ -2427,8 +2453,11 @@ namespace Tins { * */ class Dot11Deauthentication : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_DEAUTH; /** * \brief Default constructor for the Deauthentication frame. @@ -2517,8 +2546,11 @@ namespace Tins { * */ class Dot11ProbeRequest : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_PROBE_REQ; /** * \brief Default constructor for the Probe Request frame. @@ -2606,8 +2638,11 @@ namespace Tins { * */ class Dot11ProbeResponse : public Dot11ManagementFrame { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_PROBE_RESP; /** * \brief Default constructor for the Probe Response frame. @@ -2886,6 +2921,11 @@ namespace Tins { class Dot11Data : public Dot11 { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_DATA; + /** * \brief Constructor which creates a Dot11Data object from a buffer and adds all identifiable * PDUs found in the buffer as children of this one. @@ -3020,8 +3060,11 @@ namespace Tins { }; class Dot11QoSData : public Dot11Data { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_QOS_DATA; /** * \brief Constructor for creating a 802.11 QoS Data PDU @@ -3134,6 +3177,11 @@ namespace Tins { */ class Dot11Control : public Dot11 { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_CONTROL; + /** * \brief Constructor for creating a 802.11 control frame PDU * @@ -3275,6 +3323,11 @@ namespace Tins { class Dot11RTS : public Dot11ControlTA { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_RTS; + /** * \brief Constructor for creating a 802.11 RTS frame PDU * @@ -3345,6 +3398,11 @@ namespace Tins { class Dot11PSPoll : public Dot11ControlTA { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_PS_POLL; + /** * \brief Constructor for creating a 802.11 PS-Poll frame PDU * @@ -3415,6 +3473,11 @@ namespace Tins { class Dot11CFEnd : public Dot11ControlTA { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_CF_END; + /** * \brief Constructor for creating a 802.11 CF-End frame PDU * @@ -3485,6 +3548,11 @@ namespace Tins { class Dot11EndCFAck : public Dot11ControlTA { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_END_CF_ACK; + /** * \brief Constructor for creating a 802.11 End-CF-Ack frame PDU * @@ -3552,6 +3620,11 @@ namespace Tins { class Dot11Ack : public Dot11Control { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_ACK; + /** * \brief Constructor for creating a 802.11 Ack frame PDU * @@ -3623,6 +3696,11 @@ namespace Tins { */ class Dot11BlockAckRequest : public Dot11ControlTA { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_BLOCK_ACK_REQ; + /** * \brief Constructor for creating a 802.11 Block Ack request frame PDU * @@ -3745,6 +3823,11 @@ namespace Tins { */ class Dot11BlockAck : public Dot11ControlTA { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::DOT11_BLOCK_ACK; + /** * \brief Constructor for creating a 802.11 Block Ack frame PDU. * diff --git a/include/eapol.h b/include/eapol.h index 0b89e40..794344f 100644 --- a/include/eapol.h +++ b/include/eapol.h @@ -40,6 +40,11 @@ namespace Tins { */ class EAPOL : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::EAPOL; + enum EAPOLTYPE { RC4 = 1, RSN, @@ -164,6 +169,11 @@ namespace Tins { */ class RC4EAPOL : public EAPOL { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::RC4EAPOL; + /** * \brief Creates an instance of RC4EAPOL */ @@ -339,6 +349,11 @@ namespace Tins { */ class RSNEAPOL : public EAPOL { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::RSNEAPOL; + /** * \brief Creates an instance of RSNEAPOL. */ diff --git a/include/ethernetII.h b/include/ethernetII.h index ebb784f..40a81ec 100644 --- a/include/ethernetII.h +++ b/include/ethernetII.h @@ -34,8 +34,11 @@ namespace Tins { * \brief Class representing an Ethernet II PDU. */ class EthernetII : public PDU { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::ETHERNET_II; /** * \brief Represents the ethernetII broadcast address. diff --git a/include/icmp.h b/include/icmp.h index 5746bdb..bf06ddd 100644 --- a/include/icmp.h +++ b/include/icmp.h @@ -35,6 +35,11 @@ namespace Tins { */ class ICMP : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::ICMP; + /** \brief ICMP flags */ enum Flags { diff --git a/include/ieee802-3.h b/include/ieee802-3.h index b09c045..50ef53f 100644 --- a/include/ieee802-3.h +++ b/include/ieee802-3.h @@ -34,8 +34,11 @@ namespace Tins { * \brief Class representing an Ethernet II PDU. */ class IEEE802_3 : public PDU { - public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::IEEE802_3; /** * \brief Represents the IEEE802_3 broadcast address. diff --git a/include/ip.h b/include/ip.h index 9ba7305..8537c49 100644 --- a/include/ip.h +++ b/include/ip.h @@ -43,6 +43,11 @@ namespace Tins { */ class IP : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::IP; + /** * \brief IP address size. */ diff --git a/include/llc.h b/include/llc.h index 3ff4e8b..8a88fc4 100644 --- a/include/llc.h +++ b/include/llc.h @@ -37,6 +37,10 @@ namespace Tins { */ class LLC : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::LLC; /** * \brief Represents the LLC global DSAP address. diff --git a/include/pdu.h b/include/pdu.h index f89c723..a3e1750 100644 --- a/include/pdu.h +++ b/include/pdu.h @@ -164,7 +164,8 @@ namespace Tins { * If no PDU matches, 0 is returned. * \param flag The flag which being searched. */ - template T *find_inner_pdu(PDUType type) { + template + T *find_inner_pdu(PDUType type = T::pdu_flag) { PDU *pdu = this; while(pdu) { if(pdu->pdu_type() == type) diff --git a/include/radiotap.h b/include/radiotap.h index 4949796..75ff49e 100644 --- a/include/radiotap.h +++ b/include/radiotap.h @@ -37,6 +37,11 @@ namespace Tins { */ class RadioTap : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::RADIOTAP; + /** * \brief Enumeration of the different channel type flags. * diff --git a/include/rawpdu.h b/include/rawpdu.h index ec44db6..7e361a2 100644 --- a/include/rawpdu.h +++ b/include/rawpdu.h @@ -35,6 +35,11 @@ namespace Tins { */ class RawPDU : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::RAW; + /** \brief Creates an instance of RawPDU. * * The payload is copied, therefore the original payload's memory diff --git a/include/snap.h b/include/snap.h index 56d100d..95d588a 100644 --- a/include/snap.h +++ b/include/snap.h @@ -37,6 +37,11 @@ namespace Tins { */ class SNAP : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::SNAP; + /** * \brief Creates an instance of SNAP * This constructor sets the dsap and ssap fields to 0xaa, and diff --git a/include/tcp.h b/include/tcp.h index 456534d..4b97498 100644 --- a/include/tcp.h +++ b/include/tcp.h @@ -44,6 +44,11 @@ namespace Tins { class TCP : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::TCP; + /** * \brief TCP flags enum. * diff --git a/include/udp.h b/include/udp.h index b5f15ab..ff13912 100644 --- a/include/udp.h +++ b/include/udp.h @@ -35,6 +35,11 @@ namespace Tins { */ class UDP : public PDU { public: + /** + * \brief This PDU's flag. + */ + static const PDU::PDUType pdu_flag = PDU::UDP; + /** * \brief UDP constructor. *