author | mickeyl <mickeyl> | 2003-10-28 16:38:55 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-28 16:38:55 (UTC) |
commit | 877bc5c756d94db71a745596dd7e48104a2ec9a1 (patch) (unidiff) | |
tree | df4de5f085b55e812488b0db2be1d66f63b67945 /libopie2 | |
parent | 1fed961e25a6afd4070d8873b431aba8342406c3 (diff) | |
download | opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.zip opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.tar.gz opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.tar.bz2 |
- remove deprecated setMonitorMode() API. Use setMode( "monitor" ) now.
- monitor mode now tries to use the standard IW_MODE_MONITOR first. If that
doesn't work, it falls back to using proprietary iwpriv commands
-rw-r--r-- | libopie2/examples/opiecore/odebugdemo/odebugdemo.pro | 3 | ||||
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 37 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 98 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 16 |
4 files changed, 103 insertions, 51 deletions
diff --git a/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro b/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro index c52cd02..aa37394 100644 --- a/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro +++ b/libopie2/examples/opiecore/odebugdemo/odebugdemo.pro | |||
@@ -9,3 +9,2 @@ TARGET = odebugdemo | |||
9 | 9 | ||
10 | MOC_DIR = moc | ||
11 | OBJECTS_DIR = obj | 10 | OBJECTS_DIR = obj |
@@ -19 +18,3 @@ contains( platform, x11 ) { | |||
19 | } | 18 | } |
19 | |||
20 | MOC_DIR = moc | ||
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index 21026e1..06b8b19 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -4,2 +4,4 @@ | |||
4 | 4 | ||
5 | #include <unistd.h> | ||
6 | |||
5 | int main( int argc, char** argv ) | 7 | int main( int argc, char** argv ) |
@@ -15,2 +17,3 @@ int main( int argc, char** argv ) | |||
15 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); | 17 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); |
18 | qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() ); | ||
16 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); | 19 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); |
@@ -30,5 +33,7 @@ int main( int argc, char** argv ) | |||
30 | //{ | 33 | //{ |
31 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); | 34 | //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); |
32 | //} | 35 | //} |
33 | 36 | ||
37 | /* | ||
38 | |||
34 | // nickname | 39 | // nickname |
@@ -41,2 +46,4 @@ int main( int argc, char** argv ) | |||
41 | 46 | ||
47 | /* | ||
48 | |||
42 | // operation mode | 49 | // operation mode |
@@ -59,2 +66,6 @@ int main( int argc, char** argv ) | |||
59 | 66 | ||
67 | */ | ||
68 | |||
69 | /* | ||
70 | |||
60 | // network scan | 71 | // network scan |
@@ -99,2 +110,26 @@ int main( int argc, char** argv ) | |||
99 | 110 | ||
111 | // monitor test | ||
112 | |||
113 | /* | ||
114 | |||
115 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
116 | iface->setMode( "monitor" ); | ||
117 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
118 | |||
119 | sleep( 1 ); */ | ||
120 | |||
121 | iface->setMode( "master" ); | ||
122 | |||
123 | //sleep( 1 ); | ||
124 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
125 | |||
126 | /*iface->setMode( "adhoc" ); | ||
127 | sleep( 1 ); | ||
128 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
129 | iface->setMode( "managed" ); | ||
130 | sleep( 1 ); | ||
131 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); | ||
132 | iface->setMode( "master" ); | ||
133 | sleep( 1 ); | ||
134 | qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );*/ | ||
100 | 135 | ||
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 50c6679..c329e9a 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -675,6 +675,5 @@ OChannelHopper* OWirelessNetworkInterface::channelHopper() const | |||
675 | 675 | ||
676 | void OWirelessNetworkInterface::setMode( const QString& mode ) | 676 | void OWirelessNetworkInterface::commit() const |
677 | { | 677 | { |
678 | _iwr.u.mode = stringToMode( mode ); | 678 | wioctl( SIOCSIWCOMMIT ); |
679 | wioctl( SIOCSIWMODE ); | ||
680 | } | 679 | } |
@@ -682,16 +681,26 @@ void OWirelessNetworkInterface::setMode( const QString& mode ) | |||
682 | 681 | ||
683 | QString OWirelessNetworkInterface::mode() const | 682 | void OWirelessNetworkInterface::setMode( const QString& newMode ) |
684 | { | 683 | { |
685 | if ( !wioctl( SIOCGIWMODE ) ) | 684 | #ifdef FINALIZE |
685 | QString currentMode = mode(); | ||
686 | if ( currentMode == newMode ) return; | ||
687 | #endif | ||
688 | |||
689 | qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) ); | ||
690 | |||
691 | _iwr.u.mode = stringToMode( newMode ); | ||
692 | |||
693 | if ( _iwr.u.mode != IW_MODE_MONITOR ) | ||
686 | { | 694 | { |
687 | return "<unknown>"; | 695 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! |
688 | } | 696 | _iwr.u.mode = stringToMode( newMode ); |
689 | return modeToString( _iwr.u.mode ); | 697 | wioctl( SIOCSIWMODE ); |
690 | } | ||
691 | 698 | ||
699 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) | ||
692 | 700 | ||
693 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 701 | if ( mode() == "monitor" ) |
694 | { | 702 | { |
703 | qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." ); | ||
695 | if ( _mon ) | 704 | if ( _mon ) |
696 | _mon->setEnabled( b ); | 705 | _mon->setEnabled( false ); |
697 | else | 706 | else |
@@ -700,11 +709,44 @@ void OWirelessNetworkInterface::setMonitorMode( bool b ) | |||
700 | 709 | ||
710 | } | ||
711 | else // special iwpriv fallback for monitor mode | ||
712 | { | ||
713 | if ( wioctl( SIOCSIWMODE ) ) | ||
714 | { | ||
715 | qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); | ||
716 | } | ||
717 | else | ||
718 | { | ||
719 | qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." ); | ||
720 | |||
721 | if ( _mon ) | ||
722 | _mon->setEnabled( true ); | ||
723 | else | ||
724 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | ||
725 | } | ||
726 | } | ||
727 | } | ||
728 | |||
701 | 729 | ||
702 | bool OWirelessNetworkInterface::monitorMode() const | 730 | QString OWirelessNetworkInterface::mode() const |
703 | { | 731 | { |
704 | qDebug( "dataLinkType = %d", dataLinkType() ); | 732 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
705 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); | 733 | |
706 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... | 734 | if ( !wioctl( SIOCGIWMODE ) ) |
707 | //FIXME: What is 119, by the way? | 735 | { |
736 | return "<unknown>"; | ||
708 | } | 737 | } |
709 | 738 | ||
739 | qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) ); | ||
740 | |||
741 | // legacy compatible monitor mode check | ||
742 | |||
743 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) | ||
744 | { | ||
745 | return "monitor"; | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | return modeToString( _iwr.u.mode ); | ||
750 | } | ||
751 | } | ||
710 | 752 | ||
@@ -971,8 +1013,2 @@ void OMonitoringInterface::setChannel( int c ) | |||
971 | 1013 | ||
972 | bool OMonitoringInterface::enabled() const | ||
973 | { | ||
974 | return _if->monitorMode(); | ||
975 | } | ||
976 | |||
977 | |||
978 | void OMonitoringInterface::setEnabled( bool b ) | 1014 | void OMonitoringInterface::setEnabled( bool b ) |
@@ -1094,11 +1130,2 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) | |||
1094 | { | 1130 | { |
1095 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | ||
1096 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | ||
1097 | |||
1098 | #if WIRELESS_EXT > 14 | ||
1099 | if ( b ) | ||
1100 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | ||
1101 | else | ||
1102 | _if->setMode( "managed" ); | ||
1103 | #else | ||
1104 | int monitorCode = _prismHeader ? 1 : 2; | 1131 | int monitorCode = _prismHeader ? 1 : 2; |
@@ -1112,3 +1139,2 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) | |||
1112 | } | 1139 | } |
1113 | #endif | ||
1114 | } | 1140 | } |
@@ -1151,9 +1177,2 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) | |||
1151 | 1177 | ||
1152 | #if 0 | ||
1153 | //#if WIRELESS_EXT > 14 | ||
1154 | if ( b ) | ||
1155 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | ||
1156 | else | ||
1157 | _if->setMode( "managed" ); | ||
1158 | #else | ||
1159 | if ( b ) | 1178 | if ( b ) |
@@ -1166,3 +1185,2 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) | |||
1166 | } | 1185 | } |
1167 | #endif | ||
1168 | } | 1186 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 0eb4542..eb6c86e 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -351,5 +351,4 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
351 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown | 351 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown |
352 | */ | 352 | * |
353 | virtual QString mode() const; | 353 | * @note: Important note concerning the 'monitor' mode: |
354 | /** | ||
355 | * Setting the monitor mode on a wireless network interface enables | 354 | * Setting the monitor mode on a wireless network interface enables |
@@ -364,7 +363,3 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
364 | */ | 363 | */ |
365 | virtual void setMonitorMode( bool ); //FIXME: ==> setMode( "monitor" ); Use IW_MONITOR first, if this doesn't work, then use iwpriv! | 364 | virtual QString mode() const; |
366 | /** | ||
367 | * @returns true if the device is listening in IEEE 802.11 monitor mode | ||
368 | */ | ||
369 | virtual bool monitorMode() const; //FIXME: ==> mode() | ||
370 | /** | 365 | /** |
@@ -424,2 +419,6 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
424 | virtual OStationList* scanNetwork(); | 419 | virtual OStationList* scanNetwork(); |
420 | /** @internal commit pending changes to the driver | ||
421 | * | ||
422 | */ | ||
423 | void commit() const; | ||
425 | 424 | ||
@@ -458,3 +457,2 @@ class OMonitoringInterface | |||
458 | virtual void setEnabled( bool ); | 457 | virtual void setEnabled( bool ); |
459 | virtual bool enabled() const; | ||
460 | virtual void setChannel( int ); | 458 | virtual void setChannel( int ); |