summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp7
-rw-r--r--libopie2/opienet/opcap.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 313f5bb..9ed2b83 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -477,96 +477,103 @@ bool ODHCPPacket::isRequest() const
bool ODHCPPacket::isReply() const
{
return ( _dhcphdr->op == 02 );
}
QString ODHCPPacket::type() const
{
switch ( _type )
{
case 1: return "DISCOVER";
case 2: return "OFFER";
case 3: return "REQUEST";
case 4: return "DECLINE";
case 5: return "ACK";
case 6: return "NAK";
case 7: return "RELEASE";
case 8: return "INFORM";
default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>";
}
}
QHostAddress ODHCPPacket::clientAddress() const
{
return EXTRACT_32BITS( &_dhcphdr->ciaddr );
}
QHostAddress ODHCPPacket::yourAddress() const
{
return EXTRACT_32BITS( &_dhcphdr->yiaddr );
}
QHostAddress ODHCPPacket::serverAddress() const
{
return EXTRACT_32BITS( &_dhcphdr->siaddr );
}
QHostAddress ODHCPPacket::relayAddress() const
{
return EXTRACT_32BITS( &_dhcphdr->giaddr );
}
+
+OMacAddress ODHCPPacket::clientMacAddress() const
+{
+ return OMacAddress( _dhcphdr->chaddr );
+}
+
+
/*======================================================================================
* OTCPPacket
*======================================================================================*/
OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
:QObject( parent, "TCP" ), _tcphdr( data )
{
qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." );
}
OTCPPacket::~OTCPPacket()
{
}
int OTCPPacket::fromPort() const
{
return EXTRACT_16BITS( &_tcphdr->source );
}
int OTCPPacket::toPort() const
{
return EXTRACT_16BITS( &_tcphdr->dest );
}
int OTCPPacket::seq() const
{
return EXTRACT_16BITS( &_tcphdr->seq );
}
int OTCPPacket::ack() const
{
return EXTRACT_16BITS( &_tcphdr->ack_seq );
}
int OTCPPacket::window() const
{
return EXTRACT_16BITS( &_tcphdr->window );
}
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index f0d1d81..51f067a 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -464,96 +464,98 @@ class OARPPacket : public QObject
QHostAddress targetIPV4Address() const;
OMacAddress targetMacAddress() const;
//int type() const;
QString type() const;
private:
const struct myarphdr* _arphdr;
};
/*======================================================================================
* OUDPPacket
*======================================================================================*/
class OUDPPacket : public QObject
{
Q_OBJECT
public:
OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
virtual ~OUDPPacket();
int fromPort() const;
int toPort() const;
int length() const;
int checksum() const;
private:
const struct udphdr* _udphdr;
};
/*======================================================================================
* ODHCPPacket
*======================================================================================*/
class ODHCPPacket : public QObject
{
Q_OBJECT
public:
ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
virtual ~ODHCPPacket();
QHostAddress clientAddress() const;
QHostAddress yourAddress() const;
QHostAddress serverAddress() const;
QHostAddress relayAddress() const;
+ OMacAddress clientMacAddress() const;
+
bool isRequest() const;
bool isReply() const;
QString type() const;
private:
const struct dhcp_packet* _dhcphdr;
unsigned char _type;
};
/*======================================================================================
* OTCPPacket
*======================================================================================*/
class OTCPPacket : public QObject
{
Q_OBJECT
public:
OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
virtual ~OTCPPacket();
int fromPort() const;
int toPort() const;
int seq() const;
int ack() const;
int window() const;
int checksum() const;
private:
const struct tcphdr* _tcphdr;
};
/*======================================================================================
* OPacketCapturer
*======================================================================================*/
/**
* @brief A class based wrapper for network packet capturing.
*
* This class is the base of a high-level interface to the well known packet capturing
* library libpcap.
* @see http://tcpdump.org
*/
class OPacketCapturer : public QObject
{
Q_OBJECT