summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-05 22:25:58 (UTC)
committer mickeyl <mickeyl>2003-05-05 22:25:58 (UTC)
commit3f8c29b3cbbb32864694fe9c95b43d1cb777360e (patch) (side-by-side diff)
treedd749f9d27bfb8c9ad02bea8545fecba33555a67
parent3b193b852133a82b5c1708b68a7e460c63629768 (diff)
downloadopie-3f8c29b3cbbb32864694fe9c95b43d1cb777360e.zip
opie-3f8c29b3cbbb32864694fe9c95b43d1cb777360e.tar.gz
opie-3f8c29b3cbbb32864694fe9c95b43d1cb777360e.tar.bz2
fix typos
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp2
-rw-r--r--libopie2/opienet/opcap.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
index 34d32d2..c49daa0 100644
--- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
+++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
@@ -10,193 +10,193 @@
#include <cstring>
//======================== Station help class ===============================
class Station
{
public:
Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {};
~Station() {};
QString type;
int channel;
bool wep;
int beacons;
};
QDict<Station> stations;
//======================== Application class ===============================
class Wellenreiter : public QApplication
{
Q_OBJECT
public:
Wellenreiter( int argc, char** argv ) : QApplication( argc, argv )
{
ONetwork* net = ONetwork::instance();
if ( argc < 3 )
{
printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] );
printf( "\n" );
printf( "Valid wireless interfaces (detected) are:\n" );
ONetwork::InterfaceIterator it = net->iterator();
while ( it.current() )
{
if ( it.current()->isWireless() )
{
printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(),
(const char*) it.current()->macAddress().toString(),
(const char*) it.current()->ipV4Address() );
}
++it;
}
exit( -1 );
}
printf( "****************************************************\n" );
printf( "* Wellenreiter mini edition 1.0 (C) 2003 M-M-M *\n" );
printf( "****************************************************\n" );
printf( "\n\n" );
QString interface( argv[1] );
QString driver( argv[2] );
printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver );
// sanity checks before downcasting
ONetworkInterface* iface = net->interface( interface );
if ( !iface )
{
printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface );
exit( -1 );
}
if ( !iface->isWireless() )
{
printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface );
exit( -1 );
}
// downcast should be safe now
wiface = (OWirelessNetworkInterface*) iface;
printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() );
// ifconfig +promisc the interface to receive all packets
if ( !wiface->promiscuousMode() )
{
printf( "Interface status is not promisc... switching to promisc... " );
wiface->setPromiscuousMode( true );
if ( !wiface->promiscuousMode() )
{
printf( "failed (%s). Exiting.\n", strerror( errno ) );
exit( -1 );
}
else
{
printf( "ok.\n" );
}
}
else
printf( "Interface status is already promisc - good.\n" );
// connect a monitoring strategy to the interface
if ( driver == "orinoco" )
- new OOrinocoMonitoringInterface( wiface );
+ new OOrinocoMonitoringInterface( wiface, false );
else
{
printf( "Unknown driver. Exiting\n" );
exit( -1 );
}
// enable monitoring mode
printf( "Enabling monitor mode...\n" );
//wiface->setMonitorMode( true );
// open a packet capturer
cap = new OPacketCapturer();
cap->open( interface );
if ( !cap->isOpen() )
{
printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) );
exit( -1 );
}
// set capturer to non-blocking mode
cap->setBlocking( false );
// start channel hopper
//wiface->setChannelHopping( 1000 );
// connect
connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
}
~Wellenreiter() {};
public slots:
void receivePacket(OPacket* p)
{
if (!p)
{
printf( "(empty packet received)\n" );
return;
}
OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" );
if ( beacon )
{
OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
QString essid = ssid ? ssid->ID() : "<unknown>";
if ( stations.find( essid ) )
stations[essid]->beacons++;
else
{
printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid );
stations.insert( essid, new Station( "unknown", wiface->channel(),
((OWaveLanPacket*) beacon->parent())->usesWep() ) );
}
return;
}
OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" );
if ( data )
{
OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
if ( wlan->fromDS() && !wlan->toDS() )
{
printf( "FromDS: '%s' -> '%s' via '%s'\n",
(const char*) wlan->macAddress3().toString(true),
(const char*) wlan->macAddress1().toString(true),
(const char*) wlan->macAddress2().toString(true) );
}
else
if ( !wlan->fromDS() && wlan->toDS() )
{
printf( "ToDS: '%s' -> '%s' via '%s'\n",
(const char*) wlan->macAddress2().toString(true),
(const char*) wlan->macAddress3().toString(true),
(const char*) wlan->macAddress1().toString(true) );
}
else
if ( wlan->fromDS() && wlan->toDS() )
{
printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n",
(const char*) wlan->macAddress4().toString(true),
(const char*) wlan->macAddress3().toString(true),
(const char*) wlan->macAddress1().toString(true),
(const char*) wlan->macAddress2().toString(true) );
}
else
{
printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n",
(const char*) wlan->macAddress2().toString(true),
(const char*) wlan->macAddress1().toString(true),
(const char*) wlan->macAddress3().toString(true) );
}
return;
}
}
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index f6d05ea..523be3e 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -713,193 +713,193 @@ OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const st
{
qDebug( "OWaveLanManagementTim()" );
}
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()" );
}
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()" );
}
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..." );
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
new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this );
}
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..." );
if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
{
qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) );
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 ) );
}
}
}
OLLCPacket::~OLLCPacket()
{
}
/*======================================================================================
* OWaveLanControlPacket
*======================================================================================*/
OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
- :QObject( parent, "802.11 Data" ), _header( data )
+ :QObject( parent, "802.11 Control" ), _header( data )
{
qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." );
//TODO: Implement this
}
OWaveLanControlPacket::~OWaveLanControlPacket()
{
}
/*======================================================================================
* OPacketCapturer
*======================================================================================*/
OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
:QObject( parent, name ), _name( QString::null ), _open( false ),
_pch( 0 ), _pcd( 0 ), _sn( 0 )
{
}
OPacketCapturer::~OPacketCapturer()
{
if ( _open )
{
qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." );
close();
}
}
void OPacketCapturer::setBlocking( bool b )
{
if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
{
qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." );
}
else
{
qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf );
}
}
bool OPacketCapturer::blocking() const
{
int b = pcap_getnonblock( _pch, _errbuf );
if ( b == -1 )
{
qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf );
return -1;
}
return !b;
}
void OPacketCapturer::close()
{
if ( _open )
{
if ( _sn )
{
_sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
delete _sn;
}
if ( _pcd )
{
pcap_dump_close( _pcd );
_pcd = 0;
}
pcap_close( _pch );
_open = false;
}
qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." );
qDebug( "--------------------------------------------------" );
for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
qDebug( "%s : %d", (const char*) it.key(), it.data() );
qDebug( "--------------------------------------------------" );
}
int OPacketCapturer::dataLink() const
{
return pcap_datalink( _pch );
}
int OPacketCapturer::fileno() const
{
if ( _open )
{
return pcap_fileno( _pch );
}