summaryrefslogtreecommitdiff
path: root/libopie2/opienet/opcap.cpp
authormickeyl <mickeyl>2003-10-03 13:43:57 (UTC)
committer mickeyl <mickeyl>2003-10-03 13:43:57 (UTC)
commit9450f41ce6109fb9d22fca7b1c72c606fd37f5a7 (patch) (side-by-side diff)
treef88ab19eaaff43d8f72abe773d60e318e9a9e314 /libopie2/opienet/opcap.cpp
parent78b29c765dbe70faec614796a4d1421eaf0ec773 (diff)
downloadopie-9450f41ce6109fb9d22fca7b1c72c606fd37f5a7.zip
opie-9450f41ce6109fb9d22fca7b1c72c606fd37f5a7.tar.gz
opie-9450f41ce6109fb9d22fca7b1c72c606fd37f5a7.tar.bz2
add defines for UDP-based protocols
detect DHCP and link it into the packet chain
Diffstat (limited to 'libopie2/opienet/opcap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index cc8ce7f..f1f2b4b 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -36,16 +36,18 @@
#include <opie2/opcap.h>
/* QT */
#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
#include <qsocketnotifier.h>
#include <qobjectlist.h>
+#include "udp_ports.h"
+
/*======================================================================================
* OPacket
*======================================================================================*/
OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
:QObject( parent, "Generic" ), _hdr( header ), _data( data )
{
//qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
@@ -349,45 +351,56 @@ OMacAddress OARPPacket::targetMacAddress() const
*======================================================================================*/
OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
:QObject( parent, "UDP" ), _udphdr( data )
{
qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." );
+ qDebug( "fromPort = %d", fromPort() );
+ qDebug( " toPort = %d", toPort() );
+
+ // TODO: Make this a case or a hash if we know more udp protocols
+
+ if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC ||
+ toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC )
+ {
+ qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." );
+ new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this );
+ }
}
OUDPPacket::~OUDPPacket()
{
}
int OUDPPacket::fromPort() const
{
- return _udphdr->source;
+ return EXTRACT_16BITS( &_udphdr->source );
}
int OUDPPacket::toPort() const
{
- return _udphdr->dest;
+ return EXTRACT_16BITS( &_udphdr->dest );
}
int OUDPPacket::length() const
{
- return _udphdr->len;
+ return EXTRACT_16BITS( &_udphdr->len );
}
int OUDPPacket::checksum() const
{
- return _udphdr->check;
+ return EXTRACT_16BITS( &_udphdr->check );
}
/*======================================================================================
* ODHCPPacket
*======================================================================================*/
@@ -419,47 +432,47 @@ OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QOb
OTCPPacket::~OTCPPacket()
{
}
int OTCPPacket::fromPort() const
{
- return _tcphdr->source;
+ return EXTRACT_16BITS( &_tcphdr->source );
}
int OTCPPacket::toPort() const
{
- return _tcphdr->dest;
+ return EXTRACT_16BITS( &_tcphdr->dest );
}
int OTCPPacket::seq() const
{
- return _tcphdr->seq;
+ return EXTRACT_16BITS( &_tcphdr->seq );
}
int OTCPPacket::ack() const
{
- return _tcphdr->ack_seq;
+ return EXTRACT_16BITS( &_tcphdr->ack_seq );
}
int OTCPPacket::window() const
{
- return _tcphdr->window;
+ return EXTRACT_16BITS( &_tcphdr->window );
}
int OTCPPacket::checksum() const
{
- return _tcphdr->check;
+ return EXTRACT_16BITS( &_tcphdr->check );
}
/*======================================================================================
* OPrismHeaderPacket
*======================================================================================*/
OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )