summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 93176c0..067d6b7 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -2,3 +2,3 @@
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
@@ -30,5 +30,8 @@
30 30
31#include "udp_ports.h"
32#include "opcap.h"
33
31/* OPIE */ 34/* OPIE */
32#include <opie2/opcap.h>
33#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36using namespace Opie::Core;
34 37
@@ -39,11 +42,8 @@
39 42
40/* SYSTEM */ 43/* STD */
41#include <sys/time.h> 44#include <sys/time.h>
42#include <sys/types.h> 45#include <sys/types.h>
46#include <assert.h>
43#include <unistd.h> 47#include <unistd.h>
44 48#include <string.h>
45/* LOCAL */
46#include "udp_ports.h"
47
48using namespace Opie::Core;
49 49
@@ -57,10 +57,12 @@ namespace Net {
57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 57OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
58 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 58 :QObject( parent, "Generic" ), _hdr( header ), _data( 0 )
59{ 59{
60 //FIXME: Copy the data structure here, because it isn't persistent. Check that.
61
62 qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
63 60
64 _end = (unsigned char*) data + header.len; 61 _data = new unsigned char[sizeof data];
65 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 62 assert( _data );
63 memcpy( const_cast<unsigned char*>(_data), data, sizeof data );
64 // We have to copy the data structure here, because the 'data' pointer handed by libpcap
65 // points to an internal region which is reused by lipcap.
66 odebug << "OPacket: Length = " << header.len << ", Caplen = " << header.caplen << oendl;
67 _end = (unsigned char*) _data + header.len;
66 68
@@ -70,3 +72,3 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
70 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl; 72 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
71 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 73 new OEthernetPacket( _end, (const struct ether_header*) _data, this );
72 break; 74 break;
@@ -75,3 +77,3 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
75 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl; 77 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
76 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 78 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) _data, this );
77 break; 79 break;
@@ -80,3 +82,3 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
80 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl; 82 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
81 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 83 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) _data, this );
82 break; 84 break;
@@ -91,3 +93,4 @@ OPacket::~OPacket()
91{ 93{
92 qDebug( "OPacket::~OPacket( %s )", name() ); 94 odebug << "~OPacket( " << name() << " )" << oendl;
95 delete _data;
93} 96}