-rw-r--r-- | libopie2/opienet/opcap.cpp | 4 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 4 |
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 | |||
@@ -1262,52 +1262,50 @@ bool OPacketCapturer::open( const QString& name ) | |||
1262 | { | 1262 | { |
1263 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); | 1263 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); |
1264 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 1264 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | return true; | 1267 | return true; |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | 1270 | ||
1271 | bool OPacketCapturer::openDumpFile( const QString& filename ) | 1271 | bool OPacketCapturer::openDumpFile( const QString& filename ) |
1272 | { | 1272 | { |
1273 | pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); | 1273 | pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); |
1274 | if ( !dump ) | 1274 | if ( !dump ) |
1275 | { | 1275 | { |
1276 | owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl; | 1276 | owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl; |
1277 | return false; | 1277 | return false; |
1278 | } | 1278 | } |
1279 | odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl; | 1279 | odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl; |
1280 | _pcd = dump; | 1280 | _pcd = dump; |
1281 | 1281 | ||
1282 | return true; | 1282 | return true; |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | 1285 | ||
1286 | bool OPacketCapturer::open( const QFile& file ) | 1286 | bool OPacketCapturer::openCaptureFile( const QString& name ) |
1287 | { | 1287 | { |
1288 | QString name = file.name(); | ||
1289 | |||
1290 | if ( _open ) | 1288 | if ( _open ) |
1291 | { | 1289 | { |
1292 | close(); | 1290 | close(); |
1293 | if ( name == _name ) // ignore opening an already openend device | 1291 | if ( name == _name ) // ignore opening an already openend device |
1294 | { | 1292 | { |
1295 | return true; | 1293 | return true; |
1296 | } | 1294 | } |
1297 | else // close the last opened device | 1295 | else // close the last opened device |
1298 | { | 1296 | { |
1299 | close(); | 1297 | close(); |
1300 | } | 1298 | } |
1301 | } | 1299 | } |
1302 | 1300 | ||
1303 | _name = name; | 1301 | _name = name; |
1304 | 1302 | ||
1305 | pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); | 1303 | pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); |
1306 | 1304 | ||
1307 | if ( handle ) | 1305 | if ( handle ) |
1308 | { | 1306 | { |
1309 | odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl; | 1307 | odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl; |
1310 | _pch = handle; | 1308 | _pch = handle; |
1311 | _open = true; | 1309 | _open = true; |
1312 | 1310 | ||
1313 | // in case we have an application object, create a socket notifier | 1311 | // in case we have an application object, create a socket notifier |
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 | |||
@@ -642,51 +642,51 @@ class OPacketCapturer : public QObject | |||
642 | /** | 642 | /** |
643 | * Dump a packet to the output capture file. | 643 | * Dump a packet to the output capture file. |
644 | */ | 644 | */ |
645 | void dump( OPacket* ); | 645 | void dump( OPacket* ); |
646 | /** | 646 | /** |
647 | * @returns the file descriptor of the packet capturer. This is only useful, if | 647 | * @returns the file descriptor of the packet capturer. This is only useful, if |
648 | * not using the socket notifier, e.g. without an application object. | 648 | * not using the socket notifier, e.g. without an application object. |
649 | */ | 649 | */ |
650 | int fileno() const; | 650 | int fileno() const; |
651 | /** | 651 | /** |
652 | * @returns the next @ref OPacket from the packet capturer. | 652 | * @returns the next @ref OPacket from the packet capturer. |
653 | * @note If blocking mode is true then this call might block. | 653 | * @note If blocking mode is true then this call might block. |
654 | */ | 654 | */ |
655 | OPacket* next(); | 655 | OPacket* next(); |
656 | /** | 656 | /** |
657 | * @returns the next @ref OPacket from the packet capturer, if | 657 | * @returns the next @ref OPacket from the packet capturer, if |
658 | * one arrives within @a time milliseconds. | 658 | * one arrives within @a time milliseconds. |
659 | */ | 659 | */ |
660 | OPacket* next( int time ); | 660 | OPacket* next( int time ); |
661 | /** | 661 | /** |
662 | * Open the packet capturer to capture packets in live-mode from @a interface. | 662 | * Open the packet capturer to capture packets in live-mode from @a interface. |
663 | */ | 663 | */ |
664 | bool open( const QString& interface ); | 664 | bool open( const QString& interface ); |
665 | /** | 665 | /** |
666 | * Open the packet capturer to capture packets in offline-mode from @a file. | 666 | * Open the packet capturer to capture packets in offline-mode from @a filename. |
667 | */ | 667 | */ |
668 | bool open( const QFile& file ); | 668 | bool openCaptureFile( const QString& filename ); |
669 | /** | 669 | /** |
670 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() | 670 | * Open a prerecorded tcpdump compatible capture file for use with @ref dump() |
671 | */ | 671 | */ |
672 | bool openDumpFile( const QString& filename ); | 672 | bool openDumpFile( const QString& filename ); |
673 | /** | 673 | /** |
674 | * @returns true if the packet capturer is open | 674 | * @returns true if the packet capturer is open |
675 | */ | 675 | */ |
676 | bool isOpen() const; | 676 | bool isOpen() const; |
677 | /** | 677 | /** |
678 | * @returns the snapshot length of this packet capturer | 678 | * @returns the snapshot length of this packet capturer |
679 | */ | 679 | */ |
680 | int snapShot() const; | 680 | int snapShot() const; |
681 | /** | 681 | /** |
682 | * @returns true if the input capture file has a different byte-order | 682 | * @returns true if the input capture file has a different byte-order |
683 | * than the byte-order of the running system. | 683 | * than the byte-order of the running system. |
684 | */ | 684 | */ |
685 | bool swapped() const; | 685 | bool swapped() const; |
686 | /** | 686 | /** |
687 | * @returns the libpcap version string used to write the input capture file. | 687 | * @returns the libpcap version string used to write the input capture file. |
688 | */ | 688 | */ |
689 | QString version() const; | 689 | QString version() const; |
690 | /** | 690 | /** |
691 | * @returns the packet statistic database. | 691 | * @returns the packet statistic database. |
692 | * @see QMap | 692 | * @see QMap |