summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp128
-rw-r--r--libopie2/opienet/opcap.cpp163
-rw-r--r--libopie2/opienet/ostation.cpp7
3 files changed, 152 insertions, 146 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 6a9280f..d918193 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -29,12 +29,13 @@
*/
/* OPIE */
#include <opie2/onetwork.h>
#include <opie2/ostation.h>
+#include <opie2/odebug.h>
/* QT */
#include <qfile.h>
#include <qtextstream.h>
@@ -64,14 +65,14 @@ DebugMapper* debugmapper = new DebugMapper();
*======================================================================================*/
ONetwork* ONetwork::_instance = 0;
ONetwork::ONetwork()
{
- qDebug( "ONetwork::ONetwork()" );
- qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT );
+ odebug << "ONetwork::ONetwork()" << oendl;
+ odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
synchronize();
}
void ONetwork::synchronize()
{
// gather available interfaces by inspecting /proc/net/dev
@@ -82,28 +83,28 @@ void ONetwork::synchronize()
_interfaces.clear();
QString str;
QFile f( "/proc/net/dev" );
bool hasFile = f.open( IO_ReadOnly );
if ( !hasFile )
{
- qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
+ odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
return;
}
QTextStream s( &f );
s.readLine();
s.readLine();
while ( !s.atEnd() )
{
s >> str;
str.truncate( str.find( ':' ) );
- qDebug( "ONetwork: found interface '%s'", (const char*) str );
+ odebug << "ONetwork: found interface '" << str << "'" << oendl;
ONetworkInterface* iface;
if ( isWirelessInterface( str ) )
{
iface = new OWirelessNetworkInterface( this, (const char*) str );
- qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
+ odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
}
else
{
iface = new ONetworkInterface( this, (const char*) str );
}
_interfaces.insert( str, iface );
@@ -158,45 +159,47 @@ bool ONetwork::isWirelessInterface( const char* name ) const
*======================================================================================*/
ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
:QObject( parent, name ),
_sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
{
- qDebug( "ONetworkInterface::ONetworkInterface()" );
+ odebug << "ONetworkInterface::ONetworkInterface()" << oendl;
init();
}
struct ifreq& ONetworkInterface::ifr() const
{
return _ifr;
}
void ONetworkInterface::init()
{
- qDebug( "ONetworkInterface::init()" );
+ odebug << "ONetworkInterface::init()" << oendl;
memset( &_ifr, 0, sizeof( struct ifreq ) );
if ( _sfd == -1 )
{
- qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() );
+ odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl;
return;
}
}
bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
{
#ifndef NODEBUG
int result = ::ioctl( _sfd, call, &ifreq );
if ( result == -1 )
- qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
+ odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
+ << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
else
- qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
+ odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
+ << "' - Status: Ok." << oendl;
return ( result != -1 );
#else
return ::ioctl( _sfd, call, &ifreq ) != -1;
#endif
}
@@ -312,25 +315,25 @@ int ONetworkInterface::dataLinkType() const
}
void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
{
_mon = m;
- qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() );
+ odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl;
}
OMonitoringInterface* ONetworkInterface::monitoring() const
{
return _mon;
}
ONetworkInterface::~ONetworkInterface()
{
- qDebug( "ONetworkInterface::~ONetworkInterface()" );
+ odebug << "ONetworkInterface::~ONetworkInterface()" << oendl;
if ( _sfd != -1 ) ::close( _sfd );
}
bool ONetworkInterface::setPromiscuousMode( bool b )
{
@@ -401,14 +404,13 @@ int OChannelHopper::channel() const
void OChannelHopper::timerEvent( QTimerEvent* )
{
_iface->setChannel( *_channel );
emit( hopped( *_channel ) );
- qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'",
- *_channel, (const char*) _iface->name() );
+ odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl;
if ( ++_channel == _channels.end() ) _channel = _channels.begin();
}
void OChannelHopper::setInterval( int interval )
{
@@ -438,13 +440,13 @@ int OChannelHopper::interval() const
* OWirelessNetworkInterface
*======================================================================================*/
OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name )
:ONetworkInterface( parent, name ), _hopper( 0 )
{
- qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
+ odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl;
init();
}
OWirelessNetworkInterface::~OWirelessNetworkInterface()
{
@@ -456,13 +458,13 @@ struct iwreq& OWirelessNetworkInterface::iwr() const
return _iwr;
}
void OWirelessNetworkInterface::init()
{
- qDebug( "OWirelessNetworkInterface::init()" );
+ odebug << "OWirelessNetworkInterface::init()" << oendl;
memset( &_iwr, 0, sizeof( struct iwreq ) );
buildInformation();
buildPrivateList();
dumpInformation();
}
@@ -503,13 +505,13 @@ void OWirelessNetworkInterface::buildInformation()
wrq.u.data.pointer = (caddr_t) buffer;
wrq.u.data.length = sizeof( struct iw_range );
wrq.u.data.flags = 0;
if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 )
{
- qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) );
+ owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl;
_channels.insert( 2412, 1 ); // 2.412 GHz
_channels.insert( 2417, 2 ); // 2.417 GHz
_channels.insert( 2422, 3 ); // 2.422 GHz
_channels.insert( 2427, 4 ); // 2.427 GHz
_channels.insert( 2432, 5 ); // 2.432 GHz
_channels.insert( 2437, 6 ); // 2.437 GHz
@@ -527,66 +529,66 @@ void OWirelessNetworkInterface::buildInformation()
int max = 0;
for ( int r = sizeof( struct iw_range ); r < len; r++ )
if (buffer[r] != 0)
max = r;
if (max > 0)
{
- qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n"
- "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) );
+ owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name()
+ << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl;
}
// </check if the driver overwrites stuff>
struct iw_range range;
memcpy( &range, buffer, sizeof range );
- qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency );
+ odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl;
for ( int i = 0; i < range.num_frequency; ++i )
{
int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
_channels.insert( freq, i+1 );
}
}
memcpy( &_range, buffer, sizeof( struct iw_range ) );
- qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." );
+ odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl;
free(buffer);
}
void OWirelessNetworkInterface::buildPrivateList()
{
- qDebug( "OWirelessNetworkInterface::buildPrivateList()" );
+ odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl;
struct iw_priv_args priv[IW_MAX_PRIV_DEF];
_iwr.u.data.pointer = (char*) &priv;
_iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
_iwr.u.data.flags = 0;
if ( !wioctl( SIOCGIWPRIV ) )
{
- qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) );
+ owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information." << oendl;
return;
}
for ( int i = 0; i < _iwr.u.data.length; ++i )
{
new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
}
- qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." );
+ odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl;
}
void OWirelessNetworkInterface::dumpInformation() const
{
- qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" );
+ odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl;
qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 );
qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source );
- qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" );
+ odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl;
}
int OWirelessNetworkInterface::channel() const
{
//FIXME: When monitoring enabled, then use it
@@ -607,13 +609,13 @@ int OWirelessNetworkInterface::channel() const
void OWirelessNetworkInterface::setChannel( int c ) const
{
if ( !c )
{
- qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" );
+ oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl;
return;
}
if ( !_mon )
{
memset( &_iwr, 0, sizeof( struct iwreq ) );
@@ -678,13 +680,13 @@ void OWirelessNetworkInterface::setMode( const QString& newMode )
{
#ifdef FINALIZE
QString currentMode = mode();
if ( currentMode == newMode ) return;
#endif
- qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) );
+ odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl;
_iwr.u.mode = stringToMode( newMode );
if ( _iwr.u.mode != IW_MODE_MONITOR )
{
// IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP!
@@ -692,34 +694,34 @@ void OWirelessNetworkInterface::setMode( const QString& newMode )
wioctl( SIOCSIWMODE );
// special iwpriv fallback for monitor mode (check if we're really out of monitor mode now)
if ( mode() == "monitor" )
{
- qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." );
+ odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl;
if ( _mon )
_mon->setEnabled( false );
else
- qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
+ odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl;
}
}
else // special iwpriv fallback for monitor mode
{
if ( wioctl( SIOCSIWMODE ) )
{
- qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" );
+ odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl;
}
else
{
- qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." );
+ odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl;
if ( _mon )
_mon->setEnabled( true );
else
- qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
+ odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl;
}
}
}
QString OWirelessNetworkInterface::mode() const
@@ -728,13 +730,13 @@ QString OWirelessNetworkInterface::mode() const
if ( !wioctl( SIOCGIWMODE ) )
{
return "<unknown>";
}
- qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) );
+ odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl;
// legacy compatible monitor mode check
if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 )
{
return "monitor";
@@ -772,22 +774,24 @@ QString OWirelessNetworkInterface::nickName() const
void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
{
OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
if ( !priv )
{
- qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call );
+ owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name()
+ << "' does not support private ioctl '" << call << "'" << oendl;
return;
}
if ( priv->numberSetArgs() != numargs )
{
- qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs );
+ owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '"
+ << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl;
return;
}
- qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() );
+ odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl;
memset( &_iwr, 0, sizeof _iwr );
va_list argp;
va_start( argp, numargs );
for ( int i = 0; i < numargs; ++i )
{
priv->setParameter( i, va_arg( argp, int ) );
@@ -796,13 +800,13 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ..
priv->invoke();
}
void OWirelessNetworkInterface::getPrivate( const QString& call )
{
- qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
+ oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl;
}
bool OWirelessNetworkInterface::hasPrivate( const QString& call )
{
return child( (const char*) call );
@@ -843,13 +847,13 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
}
OStationList* stations = new OStationList();
int timeout = 1000000;
- qDebug( "ONetworkInterface::scanNetwork() - scan started." );
+ odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl;
bool results = false;
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 250000; // initial timeout ~ 250ms
char buffer[IW_SCAN_MAX_DATA];
@@ -866,13 +870,13 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
{
results = true;
continue;
}
else if ( errno == EAGAIN)
{
- qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." );
+ odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl;
#if 0
if ( qApp )
{
qApp->processEvents( 100 );
continue;
}
@@ -880,97 +884,101 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
tv.tv_sec = 0;
tv.tv_usec = 100000;
continue;
}
}
- qDebug( "ONetworkInterface::scanNetwork() - scan finished." );
+ odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl;
if ( results )
{
- qDebug( " - result length = %d", _iwr.u.data.length );
+ odebug << " - result length = " << _iwr.u.data.length << oendl;
if ( !_iwr.u.data.length )
{
- qDebug( " - no results (empty neighbourhood)" );
+ odebug << " - no results (empty neighbourhood)" << oendl;
return stations;
}
- qDebug( " - results are in!" );
+ odebug << " - results are in!" << oendl;
dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
// parse results
int offset = 0;
struct iw_event* we = (struct iw_event*) &buffer[0];
while ( offset < _iwr.u.data.length )
{
//const char* cmd = *(*_ioctlmap)[we->cmd];
//if ( !cmd ) cmd = "<unknown>";
- qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len );
+ odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl;
switch (we->cmd)
{
case SIOCGIWAP:
{
- qDebug( "SIOCGIWAP" );
+ odebug << "SIOCGIWAP" << oendl;
stations->append( new OStation() );
stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
break;
}
case SIOCGIWMODE:
{
- qDebug( "SIOCGIWMODE" );
+ odebug << "SIOCGIWMODE" << oendl;
stations->last()->type = modeToString( we->u.mode );
break;
}
case SIOCGIWFREQ:
{
- qDebug( "SIOCGIWFREQ" );
+ odebug << "SIOCGIWFREQ" << oendl;
stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
break;
}
case SIOCGIWESSID:
{
- qDebug( "SIOCGIWESSID" );
+ odebug << "SIOCGIWESSID" << oendl;
stations->last()->ssid = we->u.essid.pointer;
break;
}
- case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break;
- case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break;
- case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */
- case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */
- case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */
- case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */
- case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */
- default: qDebug( "unhandled event" );
+ case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break;
+ case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break;
+ case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */
+ case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */
+ case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */
+ case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */
+ case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */
+ default: odebug << "unhandled event" << oendl;
}
offset += we->len;
we = (struct iw_event*) &buffer[offset];
}
return stations;
return stations;
}
else
{
- qDebug( " - no results (timeout) :(" );
+ odebug << " - no results (timeout) :(" << oendl;
return stations;
}
}
bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
{
#ifndef NODEBUG
int result = ::ioctl( _sfd, call, &iwreq );
+
if ( result == -1 )
- qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
+ odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
+ << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
else
- qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
+ odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
+ << debugmapper->map( call ) << "' - Status: Ok." << oendl;
+
return ( result != -1 );
#else
return ::ioctl( _sfd, call, &iwreq ) != -1;
#endif
}
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 635224c..e9b3b2c 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -27,12 +27,13 @@
Boston, MA 02111-1307, USA.
*/
/* OPIE */
#include <opie2/opcap.h>
+#include <opie2/odebug.h>
/* QT */
#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
#include <qsocketnotifier.h>
#include <qobjectlist.h>
@@ -56,28 +57,28 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
_end = (unsigned char*) data + header.len;
//qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
switch ( datalink )
{
case DLT_EN10MB:
- qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" );
+ odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
new OEthernetPacket( _end, (const struct ether_header*) data, this );
break;
case DLT_IEEE802_11:
- qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" );
+ odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
break;
case DLT_PRISM_HEADER:
- qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" );
+ odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
break;
default:
- qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink );
+ owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl;
}
}
OPacket::~OPacket()
{
@@ -109,13 +110,13 @@ void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
}
void OPacket::dumpStructure( QObjectList* l )
{
QString packetString( "[ |" + _dumpStructure( l ) + " ]" );
- qDebug( "OPacket::dumpStructure: %s", (const char*) packetString );
+ odebug << "OPacket::dumpStructure: " << packetString << oendl;
}
QString OPacket::_dumpStructure( QObjectList* l )
{
if (!l) return QString::null;
@@ -183,26 +184,26 @@ int OPacket::len() const
*======================================================================================*/
OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent )
:QObject( parent, "Ethernet" ), _ether( data )
{
- qDebug( "Source = %s", (const char*) sourceAddress().toString() );
- qDebug( "Destination = %s", (const char*) destinationAddress().toString() );
+ odebug << "Source = " << sourceAddress().toString();
+ odebug << "Destination = " << destinationAddress().toString();
if ( sourceAddress() == OMacAddress::broadcast )
- qDebug( "Source is broadcast address" );
+ odebug << "Source is broadcast address" << oendl;
if ( destinationAddress() == OMacAddress::broadcast )
- qDebug( "Destination is broadcast address" );
+ odebug << "Destination is broadcast address" << oendl;
switch ( type() )
{
case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
- case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; }
- default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" );
+ case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; }
+ default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl;
}
}
OEthernetPacket::~OEthernetPacket()
@@ -232,25 +233,22 @@ int OEthernetPacket::type() const
*======================================================================================*/
OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
:QObject( parent, "IP" ), _iphdr( data )
{
- qDebug( "OIPPacket::OIPPacket(): decoding IP header..." );
+ odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl;
- //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) );
- //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) );
-
- qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() );
- qDebug( " toAddress: %s", (const char*) toIPAddress().toString() );
+ odebug << "FromAddress = " << fromIPAddress().toString();
+ odebug << " toAddress = " << toIPAddress().toString();
switch ( protocol() )
{
case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
- default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() );
+ default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl;
}
}
OIPPacket::~OIPPacket()
{
@@ -315,16 +313,16 @@ int OIPPacket::checksum() const
*======================================================================================*/
OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent )
:QObject( parent, "ARP" ), _arphdr( data )
{
- qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." );
- qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() );
- qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() );
- qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() );
+ odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl;
+ odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl;
+ odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl;
+ odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl;
}
OARPPacket::~OARPPacket()
{
}
@@ -376,22 +374,22 @@ 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() );
+ odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl;
+ odebug << "fromPort = " << fromPort() << oendl;
+ odebug << " toPort = " << toPort() << oendl;
// 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." );
+ odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl;
new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this );
}
}
OUDPPacket::~OUDPPacket()
@@ -429,43 +427,43 @@ int OUDPPacket::checksum() const
ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent )
:QObject( parent, "DHCP" ), _dhcphdr( data )
{
- qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." );
- qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" );
- qDebug( "clientAddress: %s", (const char*) clientAddress().toString() );
- qDebug( " yourAddress: %s", (const char*) yourAddress().toString() );
- qDebug( "serverAddress: %s", (const char*) serverAddress().toString() );
- qDebug( " relayAddress: %s", (const char*) relayAddress().toString() );
- qDebug( "parsing DHCP options..." );
+ odebug << "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." << oendl;
+ odebug << "DHCP opcode seems to be " << _dhcphdr->op << ": " << ( isRequest() ? "REQUEST" : "REPLY" ) << oendl;
+ odebug << "clientAddress = " << clientAddress().toString() << oendl;
+ odebug << " yourAddress = " << yourAddress().toString() << oendl;
+ odebug << "serverAddress = " << serverAddress().toString() << oendl;
+ odebug << " relayAddress = " << relayAddress().toString() << oendl;
+ odebug << "parsing DHCP options..." << oendl;
_type = 0;
const unsigned char* option = &_dhcphdr->options[4];
char tag = -1;
char len = -1;
while ( ( tag = *option++ ) != -1 /* end of option field */ )
{
len = *option++;
- qDebug( "recognized DHCP option #%d, length %d", tag, len );
+ odebug << "recognized DHCP option #" << tag << ", length " << len << oendl;
if ( tag == DHO_DHCP_MESSAGE_TYPE )
_type = *option;
option += len;
if ( option >= end )
{
- qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" );
+ owarn << "DHCP parsing ERROR: sanity check says the packet is at its end!" << oendl;
break;
}
}
- qDebug( "DHCP type seems to be '%s'", (const char*) type() );
+ odebug << "DHCP type seems to be << " << type() << oendl;
}
ODHCPPacket::~ODHCPPacket()
{
}
@@ -536,13 +534,13 @@ OMacAddress ODHCPPacket::clientMacAddress() const
OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
:QObject( parent, "TCP" ), _tcphdr( data )
{
- qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." );
+ odebug << "OTCPPacket::OTCPPacket(): decoding TCP header..." << oendl;
}
OTCPPacket::~OTCPPacket()
{
}
@@ -589,15 +587,15 @@ int OTCPPacket::checksum() const
OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )
:QObject( parent, "Prism" ), _header( data )
{
- qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." );
+ odebug << "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." << oendl;
- qDebug( "Signal Strength = %d", data->signal.data );
+ odebug << "Signal Strength = " << data->signal.data << oendl;
new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this );
}
OPrismHeaderPacket::~OPrismHeaderPacket()
{
@@ -615,29 +613,29 @@ unsigned int OPrismHeaderPacket::signalStrength() const
OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent )
:QObject( parent, "802.11" ), _wlanhdr( data )
{
- qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." );
- qDebug( "type: %0X", type() );
- qDebug( "subType: %0X", subType() );
- qDebug( "duration: %d", duration() );
- qDebug( "powermanagement: %d", usesPowerManagement() );
- qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" );
- qDebug( "MAC1: %s", (const char*) macAddress1().toString() );
- qDebug( "MAC2: %s", (const char*) macAddress2().toString() );
- qDebug( "MAC3: %s", (const char*) macAddress3().toString() );
- qDebug( "MAC4: %s", (const char*) macAddress4().toString() );
+ odebug << "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." << oendl;
+ odebug << "type = " << type() << oendl;
+ odebug << "subType = " << subType() << oendl;
+ odebug << "duration = " << duration() << oendl;
+ odebug << "powermanagement = " << usesPowerManagement() << oendl;
+ odebug << "payload is encrypted = " << ( usesWep() ? "yes" : "no" ) << oendl;
+ odebug << "MAC1 = " << macAddress1().toString() << oendl;
+ odebug << "MAC2 = " << macAddress2().toString() << oendl;
+ odebug << "MAC3 = " << macAddress3().toString() << oendl;
+ odebug << "MAC4 = " << macAddress4().toString() << oendl;
switch ( type() )
{
case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break;
case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break;
case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break;
- default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() );
+ default: odebug << "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type = " << type() << oendl;
}
}
OWaveLanPacket::~OWaveLanPacket()
{
}
@@ -720,14 +718,14 @@ bool OWaveLanPacket::usesWep() const
*======================================================================================*/
OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent )
:QObject( parent, "802.11 Management" ), _header( data ),
_body( (const struct ieee_802_11_mgmt_body*) (data+1) )
{
- qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." );
- qDebug( "Detected subtype is '%s'", (const char*) managementType() );
+ odebug << "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." << oendl;
+ odebug << "Detected subtype is " << managementType() << oendl;
// grab tagged values
const unsigned char* ptr = (const unsigned char*) (_body+1);
while (ptr < end)
{
switch ( *ptr )
@@ -820,13 +818,13 @@ bool OWaveLanManagementPacket::canPrivacy() const
* OWaveLanManagementSSID
*======================================================================================*/
OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent )
:QObject( parent, "802.11 SSID" ), _data( data )
{
- qDebug( "OWaveLanManagementSSID()" );
+ odebug << "OWaveLanManagementSSID()" << oendl;
}
OWaveLanManagementSSID::~OWaveLanManagementSSID()
{
}
@@ -847,13 +845,13 @@ QString OWaveLanManagementSSID::ID() const
* OWaveLanManagementRates
*======================================================================================*/
OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent )
:QObject( parent, "802.11 Rates" ), _data( data )
{
- qDebug( "OWaveLanManagementRates()" );
+ odebug << "OWaveLanManagementRates()" << oendl;
}
OWaveLanManagementRates::~OWaveLanManagementRates()
{
}
@@ -862,13 +860,13 @@ OWaveLanManagementRates::~OWaveLanManagementRates()
* OWaveLanManagementCF
*======================================================================================*/
OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent )
:QObject( parent, "802.11 CF" ), _data( data )
{
- qDebug( "OWaveLanManagementCF()" );
+ odebug << "OWaveLanManagementCF()" << oendl;
}
OWaveLanManagementCF::~OWaveLanManagementCF()
{
}
@@ -877,13 +875,13 @@ OWaveLanManagementCF::~OWaveLanManagementCF()
* OWaveLanManagementFH
*======================================================================================*/
OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent )
:QObject( parent, "802.11 FH" ), _data( data )
{
- qDebug( "OWaveLanManagementFH()" );
+ odebug << "OWaveLanManagementFH()" << oendl;
}
OWaveLanManagementFH::~OWaveLanManagementFH()
{
}
@@ -892,13 +890,13 @@ OWaveLanManagementFH::~OWaveLanManagementFH()
* OWaveLanManagementDS
*======================================================================================*/
OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent )
:QObject( parent, "802.11 DS" ), _data( data )
{
- qDebug( "OWaveLanManagementDS()" );
+ odebug << "OWaveLanManagementDS()" << oendl;
}
OWaveLanManagementDS::~OWaveLanManagementDS()
{
}
@@ -913,13 +911,13 @@ int OWaveLanManagementDS::channel() const
* OWaveLanManagementTim
*======================================================================================*/
OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent )
:QObject( parent, "802.11 Tim" ), _data( data )
{
- qDebug( "OWaveLanManagementTim()" );
+ odebug << "OWaveLanManagementTim()" << oendl;
}
OWaveLanManagementTim::~OWaveLanManagementTim()
{
}
@@ -928,13 +926,13 @@ OWaveLanManagementTim::~OWaveLanManagementTim()
* OWaveLanManagementIBSS
*======================================================================================*/
OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent )
:QObject( parent, "802.11 IBSS" ), _data( data )
{
- qDebug( "OWaveLanManagementIBSS()" );
+ odebug << "OWaveLanManagementIBSS()" << oendl;
}
OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
{
}
@@ -943,13 +941,13 @@ OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
* OWaveLanManagementChallenge
*======================================================================================*/
OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent )
:QObject( parent, "802.11 Challenge" ), _data( data )
{
- qDebug( "OWaveLanManagementChallenge()" );
+ odebug << "OWaveLanManagementChallenge()" << oendl;
}
OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
{
}
@@ -958,13 +956,13 @@ OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
* OWaveLanDataPacket
*======================================================================================*/
OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
:QObject( parent, "802.11 Data" ), _header( data )
{
- qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." );
+ odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl;
const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header );
#warning The next line works for most cases, but can not be correct generally!
if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address
@@ -981,25 +979,24 @@ OWaveLanDataPacket::~OWaveLanDataPacket()
* OLLCPacket
*======================================================================================*/
OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
:QObject( parent, "802.11 LLC" ), _header( data )
{
- qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." );
+ odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl;
if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
{
- qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) );
+ owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl;
switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
{
case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
- default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) );
+ default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl;
}
-
}
}
OLLCPacket::~OLLCPacket()
{
@@ -1010,13 +1007,13 @@ OLLCPacket::~OLLCPacket()
* OWaveLanControlPacket
*======================================================================================*/
OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
:QObject( parent, "802.11 Control" ), _header( data )
{
- qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." );
+ odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl;
//TODO: Implement this
}
OWaveLanControlPacket::~OWaveLanControlPacket()
{
@@ -1035,37 +1032,37 @@ OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
OPacketCapturer::~OPacketCapturer()
{
if ( _open )
{
- qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." );
+ odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl;
close();
}
}
void OPacketCapturer::setBlocking( bool b )
{
if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
{
- qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." );
+ odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl;
}
else
{
- qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf );
+ odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl;
}
}
bool OPacketCapturer::blocking() const
{
int b = pcap_getnonblock( _pch, _errbuf );
if ( b == -1 )
{
- qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf );
+ odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl;
return -1;
}
return !b;
}
@@ -1090,17 +1087,17 @@ void OPacketCapturer::close()
delete _sn;
}
closeDumpFile();
_open = false;
}
- qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." );
- qDebug( "--------------------------------------------------" );
+ odebug << "OPacketCapturer::close() --- dumping capturing statistics..." << oendl;
+ odebug << "--------------------------------------------------" << oendl;
for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
- qDebug( "%s : %d", (const char*) it.key(), it.data() );
- qDebug( "--------------------------------------------------" );
+ odebug << it.key() << " = " << it.data() << oendl;
+ odebug << "--------------------------------------------------" << oendl;
}
int OPacketCapturer::dataLink() const
{
@@ -1148,15 +1145,15 @@ OPacket* OPacketCapturer::next( int time )
}
OPacket* OPacketCapturer::next()
{
packetheaderstruct header;
- qDebug( "==> OPacketCapturer::next()" );
+ odebug << "==> OPacketCapturer::next()" << oendl;
const unsigned char* pdata = pcap_next( _pch, &header );
- qDebug( "<== OPacketCapturer::next()" );
+ odebug << "<== OPacketCapturer::next()" << oendl;
if ( pdata && header.len )
{
OPacket* p = new OPacket( dataLink(), header, pdata, 0 );
// packets shouldn't be inserted in the QObject child-parent hierarchy,
// because due to memory constraints they will be deleted as soon
@@ -1195,17 +1192,17 @@ bool OPacketCapturer::open( const QString& name )
// open libpcap
pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] );
if ( !handle )
{
- qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
+ owarn << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
return false;
}
- qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name );
+ odebug << "OPacketCapturer::open(): libpcap [" << name << "] opened successfully." << oendl;
_pch = handle;
_open = true;
_stats.clear();
// in case we have an application object, create a socket notifier
if ( qApp ) //TODO: I don't like this here...
@@ -1220,16 +1217,16 @@ bool OPacketCapturer::open( const QString& name )
bool OPacketCapturer::openDumpFile( const QString& filename )
{
pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) );
if ( !dump )
{
- qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf );
+ owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl;
return false;
}
- qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename );
+ odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl;
_pcd = dump;
return true;
}
@@ -1253,13 +1250,13 @@ bool OPacketCapturer::open( const QFile& file )
_name = name;
pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] );
if ( handle )
{
- qDebug( "OPacketCapturer::open(): libpcap opened successfully." );
+ odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl;
_pch = handle;
_open = true;
// in case we have an application object, create a socket notifier
if ( qApp )
{
@@ -1268,13 +1265,13 @@ bool OPacketCapturer::open( const QFile& file )
}
return true;
}
else
{
- qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
+ odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
return false;
}
}
@@ -1283,13 +1280,13 @@ bool OPacketCapturer::isOpen() const
return _open;
}
void OPacketCapturer::readyToReceive()
{
- qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" );
+ odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl;
OPacket* p = next();
emit receivedPacket( p );
// emit is synchronous - packet has been dealt with, now it's safe to delete
delete p;
}
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index c363f0c..8c989d8 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -26,38 +26,39 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/ostation.h>
+#include <opie2/odebug.h>
/*======================================================================================
* OStation
*======================================================================================*/
OStation::OStation()
{
- qDebug( "OStation::OStation()" );
+ odebug << "OStation::OStation()" << oendl;
type = "<unknown>";
macAddress = OMacAddress::unknown;
ssid = "<unknown>";
channel = 0;
apAddress = OMacAddress::unknown;
}
OStation::~OStation()
{
- qDebug( "OStation::~OStation()" );
+ odebug << "OStation::~OStation()" << oendl;
}
void OStation::dump()
{
- qDebug( "------- OStation::dump() ------------" );
+ odebug << "------- OStation::dump() ------------" << oendl;
qDebug( "type: %s", (const char*) type );
qDebug( "mac: %s", (const char*) macAddress.toString() );
qDebug( "ap: %s", (const char*) apAddress.toString() );
qDebug( "ip: %s", (const char*) ipAddress.toString() );
}