1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Added a constant static value to each PDU indicating the corresponding PDU::PDUType flag.

This commit is contained in:
Matias Fontanini
2012-08-06 22:29:41 -03:00
parent 66dfcb746b
commit 4af3d3c697
17 changed files with 178 additions and 14 deletions

View File

@@ -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.
*/

View File

@@ -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.
*/

View File

@@ -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.
*/

View File

@@ -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

View File

@@ -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.
*

View File

@@ -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.
*/

View File

@@ -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.

View File

@@ -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 {

View File

@@ -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.

View File

@@ -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.
*/

View File

@@ -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.

View File

@@ -164,7 +164,8 @@ namespace Tins {
* If no PDU matches, 0 is returned.
* \param flag The flag which being searched.
*/
template<class T> T *find_inner_pdu(PDUType type) {
template<class T>
T *find_inner_pdu(PDUType type = T::pdu_flag) {
PDU *pdu = this;
while(pdu) {
if(pdu->pdu_type() == type)

View File

@@ -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.
*

View File

@@ -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

View File

@@ -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

View File

@@ -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.
*

View File

@@ -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.
*