summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opiecore/odebugdemo/odebugdemo.pro3
-rw-r--r--libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp37
-rw-r--r--libopie2/opienet/onetwork.cpp106
-rw-r--r--libopie2/opienet/onetwork.h16
4 files changed, 107 insertions, 55 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
@@ -6,9 +6,8 @@ INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lopiecore2 7LIBS += -lopiecore2
8TARGET = odebugdemo 8TARGET = odebugdemo
9 9
10MOC_DIR = moc
11OBJECTS_DIR = obj 10OBJECTS_DIR = obj
12 11
13!contains( platform, x11 ) { 12!contains( platform, x11 ) {
14 include ( $(OPIEDIR)/include.pro ) 13 include ( $(OPIEDIR)/include.pro )
@@ -16,4 +15,6 @@ OBJECTS_DIR = obj
16 15
17contains( platform, x11 ) { 16contains( platform, x11 ) {
18 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 17 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
19} 18}
19
20MOC_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
@@ -1,8 +1,10 @@
1#include <opie2/onetwork.h> 1#include <opie2/onetwork.h>
2#include <opie2/ostation.h> 2#include <opie2/ostation.h>
3#include <opie2/omanufacturerdb.h> 3#include <opie2/omanufacturerdb.h>
4 4
5#include <unistd.h>
6
5int main( int argc, char** argv ) 7int main( int argc, char** argv )
6{ 8{
7 qDebug( "OPIE Network Demo" ); 9 qDebug( "OPIE Network Demo" );
8 10
@@ -12,8 +14,9 @@ int main( int argc, char** argv )
12 14
13 while ( it.current() ) 15 while ( it.current() )
14 { 16 {
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() );
17 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); 20 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) );
18 qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); 21 qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() );
19 qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); 22 qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) );
@@ -27,19 +30,23 @@ int main( int argc, char** argv )
27 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); 30 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );
28 31
29 //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) 32 //if ( iface->mode() == OWirelessNetworkInterface::adhoc )
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
35 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); 40 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
36 iface->setNickName( "MyNickName" ); 41 iface->setNickName( "MyNickName" );
37 if ( iface->nickName() != "MyNickName" ) 42 if ( iface->nickName() != "MyNickName" )
38 qDebug( "DEMO: Warning! Can't change nickname" ); 43 qDebug( "DEMO: Warning! Can't change nickname" );
39 else 44 else
40 qDebug( "DEMO: Nickname change successful." ); 45 qDebug( "DEMO: Nickname change successful." );
41 46
47 /*
48
42 // operation mode 49 // operation mode
43 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); 50 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() );
44 iface->setMode( "adhoc" ); 51 iface->setMode( "adhoc" );
45 if ( iface->mode() != "adhoc" ) 52 if ( iface->mode() != "adhoc" )
@@ -56,8 +63,12 @@ int main( int argc, char** argv )
56 qDebug( "DEMO: RF channel change successful." ); 63 qDebug( "DEMO: RF channel change successful." );
57 64
58 iface->setMode( "managed" ); 65 iface->setMode( "managed" );
59 66
67 */
68
69 /*
70
60 // network scan 71 // network scan
61 72
62 OStationList* stations = iface->scanNetwork(); 73 OStationList* stations = iface->scanNetwork();
63 if ( stations ) 74 if ( stations )
@@ -96,8 +107,32 @@ int main( int argc, char** argv )
96 qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); 107 qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() );
97 108
98 */ 109 */
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
101 } 136 }
102 ++it; 137 ++it;
103 } 138 }
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
@@ -672,42 +672,84 @@ OChannelHopper* OWirelessNetworkInterface::channelHopper() const
672 return _hopper; 672 return _hopper;
673} 673}
674 674
675 675
676void OWirelessNetworkInterface::setMode( const QString& mode ) 676void OWirelessNetworkInterface::commit() const
677{ 677{
678 _iwr.u.mode = stringToMode( mode ); 678 wioctl( SIOCSIWCOMMIT );
679 wioctl( SIOCSIWMODE );
680} 679}
681 680
682 681
683QString OWirelessNetworkInterface::mode() const 682void 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!
696 _iwr.u.mode = stringToMode( newMode );
697 wioctl( SIOCSIWMODE );
698
699 // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now)
700
701 if ( mode() == "monitor" )
702 {
703 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." );
704 if ( _mon )
705 _mon->setEnabled( false );
706 else
707 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
708 }
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 }
688 } 726 }
689 return modeToString( _iwr.u.mode );
690} 727}
691 728
692 729
693void OWirelessNetworkInterface::setMonitorMode( bool b ) 730QString OWirelessNetworkInterface::mode() const
694{ 731{
695 if ( _mon ) 732 memset( &_iwr, 0, sizeof( struct iwreq ) );
696 _mon->setEnabled( b ); 733
697 else 734 if ( !wioctl( SIOCGIWMODE ) )
698 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 735 {
699} 736 return "<unknown>";
737 }
700 738
739 qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) );
701 740
702bool OWirelessNetworkInterface::monitorMode() const 741 // legacy compatible monitor mode check
703{
704 qDebug( "dataLinkType = %d", dataLinkType() );
705 return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 );
706 //FIXME: 802 is the header type for PRISM - Linux support for this is pending...
707 //FIXME: What is 119, by the way?
708}
709 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
711void OWirelessNetworkInterface::setNickName( const QString& nickname ) 753void OWirelessNetworkInterface::setNickName( const QString& nickname )
712{ 754{
713 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); 755 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname );
@@ -968,14 +1010,8 @@ void OMonitoringInterface::setChannel( int c )
968 _if->wioctl( SIOCSIWFREQ ); 1010 _if->wioctl( SIOCSIWFREQ );
969} 1011}
970 1012
971 1013
972bool OMonitoringInterface::enabled() const
973{
974 return _if->monitorMode();
975}
976
977
978void OMonitoringInterface::setEnabled( bool b ) 1014void OMonitoringInterface::setEnabled( bool b )
979{ 1015{
980} 1016}
981 1017
@@ -1091,17 +1127,8 @@ OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
1091} 1127}
1092 1128
1093void OHostAPMonitoringInterface::setEnabled( bool b ) 1129void 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;
1105 if ( b ) 1132 if ( b )
1106 { 1133 {
1107 _if->setPrivate( "monitor", 1, monitorCode ); 1134 _if->setPrivate( "monitor", 1, monitorCode );
@@ -1109,9 +1136,8 @@ void OHostAPMonitoringInterface::setEnabled( bool b )
1109 else 1136 else
1110 { 1137 {
1111 _if->setPrivate( "monitor", 1, 0 ); 1138 _if->setPrivate( "monitor", 1, 0 );
1112 } 1139 }
1113 #endif
1114} 1140}
1115 1141
1116 1142
1117QString OHostAPMonitoringInterface::name() const 1143QString OHostAPMonitoringInterface::name() const
@@ -1148,24 +1174,16 @@ void OOrinocoMonitoringInterface::setEnabled( bool b )
1148 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 1174 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
1149 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 1175 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
1150 // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported 1176 // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported
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 )
1160 { 1179 {
1161 setChannel( 1 ); 1180 setChannel( 1 );
1162 } 1181 }
1163 else 1182 else
1164 { 1183 {
1165 _if->setPrivate( "monitor", 2, 0, 0 ); 1184 _if->setPrivate( "monitor", 2, 0, 0 );
1166 } 1185 }
1167 #endif
1168} 1186}
1169 1187
1170 1188
1171QString OOrinocoMonitoringInterface::name() const 1189QString OOrinocoMonitoringInterface::name() const
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
@@ -348,11 +348,10 @@ class OWirelessNetworkInterface : public ONetworkInterface
348 virtual void setMode( const QString& mode ); 348 virtual void setMode( const QString& mode );
349 /** 349 /**
350 * @returns the current IEEE 802.11 operation mode. 350 * @returns the current IEEE 802.11 operation mode.
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
356 * listening to IEEE 802.11 data and management frames which normally 355 * listening to IEEE 802.11 data and management frames which normally
357 * are handled by the device firmware. This can be used to detect 356 * are handled by the device firmware. This can be used to detect
358 * other wireless network devices, e.g. Access Points or Ad-hoc stations. 357 * other wireless network devices, e.g. Access Points or Ad-hoc stations.
@@ -361,13 +360,9 @@ class OWirelessNetworkInterface : public ONetworkInterface
361 * @note Enabling the monitor mode is highly driver dependent and requires 360 * @note Enabling the monitor mode is highly driver dependent and requires
362 * the proper @ref OMonitoringInterface to be associated with the interface. 361 * the proper @ref OMonitoringInterface to be associated with the interface.
363 * @see OMonitoringInterface 362 * @see OMonitoringInterface
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 /**
371 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. 366 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping.
372 * @see OChannelHopper 367 * @see OChannelHopper
373 */ 368 */
@@ -421,8 +416,12 @@ class OWirelessNetworkInterface : public ONetworkInterface
421 * Perform scanning the wireless network neighbourhood. 416 * Perform scanning the wireless network neighbourhood.
422 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! 417 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
423 */ 418 */
424 virtual OStationList* scanNetwork(); 419 virtual OStationList* scanNetwork();
420 /** @internal commit pending changes to the driver
421 *
422 */
423 void commit() const;
425 424
426 protected: 425 protected:
427 void buildInformation(); 426 void buildInformation();
428 void buildPrivateList(); 427 void buildPrivateList();
@@ -455,9 +454,8 @@ class OMonitoringInterface
455 virtual ~OMonitoringInterface(); 454 virtual ~OMonitoringInterface();
456 455
457 public: 456 public:
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 );
461 459
462 virtual QString name() const = 0; 460 virtual QString name() const = 0;
463 461