summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp4
-rw-r--r--libopie2/opienet/opcap.h4
2 files changed, 3 insertions, 5 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 067d6b7..f8ebe6b 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1238,100 +1238,98 @@ bool OPacketCapturer::open( const QString& name )
else // close the last opened device
{
close();
}
}
_name = name;
// open libpcap
pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] );
if ( !handle )
{
owarn << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
return false;
}
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...
{
_sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
}
return true;
}
bool OPacketCapturer::openDumpFile( const QString& filename )
{
pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) );
if ( !dump )
{
owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl;
return false;
}
odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl;
_pcd = dump;
return true;
}
-bool OPacketCapturer::open( const QFile& file )
+bool OPacketCapturer::openCaptureFile( const QString& name )
{
- QString name = file.name();
-
if ( _open )
{
close();
if ( name == _name ) // ignore opening an already openend device
{
return true;
}
else // close the last opened device
{
close();
}
}
_name = name;
pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] );
if ( handle )
{
odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl;
_pch = handle;
_open = true;
// in case we have an application object, create a socket notifier
if ( qApp )
{
_sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
}
return true;
}
else
{
odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
return false;
}
}
bool OPacketCapturer::isOpen() const
{
return _open;
}
void OPacketCapturer::readyToReceive()
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 2dbe030..9e718d5 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -618,99 +618,99 @@ class OPacketCapturer : public QObject
*/
~OPacketCapturer();
/**
* Set the packet capturer to use blocking or non-blocking IO. This can be useful when
* not using the socket notifier, e.g. without an application object.
*/
void setBlocking( bool );
/**
* @returns true if the packet capturer uses blocking IO calls.
*/
bool blocking() const;
/**
* Close the packet capturer. This is automatically done in the destructor.
*/
void close();
/**
* Close the output capture file.
*/
void closeDumpFile();
/**
* @returns the data link type.
* @see <pcap.h> for possible values.
*/
int dataLink() const;
/**
* Dump a packet to the output capture file.
*/
void dump( OPacket* );
/**
* @returns the file descriptor of the packet capturer. This is only useful, if
* not using the socket notifier, e.g. without an application object.
*/
int fileno() const;
/**
* @returns the next @ref OPacket from the packet capturer.
* @note If blocking mode is true then this call might block.
*/
OPacket* next();
/**
* @returns the next @ref OPacket from the packet capturer, if
* one arrives within @a time milliseconds.
*/
OPacket* next( int time );
/**
* Open the packet capturer to capture packets in live-mode from @a interface.
*/
bool open( const QString& interface );
/**
- * Open the packet capturer to capture packets in offline-mode from @a file.
+ * Open the packet capturer to capture packets in offline-mode from @a filename.
*/
- bool open( const QFile& file );
+ bool openCaptureFile( const QString& filename );
/**
* Open a prerecorded tcpdump compatible capture file for use with @ref dump()
*/
bool openDumpFile( const QString& filename );
/**
* @returns true if the packet capturer is open
*/
bool isOpen() const;
/**
* @returns the snapshot length of this packet capturer
*/
int snapShot() const;
/**
* @returns true if the input capture file has a different byte-order
* than the byte-order of the running system.
*/
bool swapped() const;
/**
* @returns the libpcap version string used to write the input capture file.
*/
QString version() const;
/**
* @returns the packet statistic database.
* @see QMap
*/
const QMap<QString,int>& statistics() const;
/**
* Enable or disable the auto-delete option.
* If auto-delete is enabled, then the packet capturer will delete a packet right
* after it has been emit'ted. This is the default, which is useful if the packet
* capturer has the only reference to the packets. If you pass the packet for adding
* into a collection or do processing after the SLOT, the auto delete must be disabled.
*/
void setAutoDelete( bool enable );
/**
* @returns the auto-delete value.
*/
bool autoDelete() const;
signals:
/**
* This signal is emitted, when a packet has been received.
*/
void receivedPacket( Opie::Net::OPacket* );
protected slots:
void readyToReceive();