summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-28 16:38:55 (UTC)
committer mickeyl <mickeyl>2003-10-28 16:38:55 (UTC)
commit877bc5c756d94db71a745596dd7e48104a2ec9a1 (patch) (unidiff)
treedf4de5f085b55e812488b0db2be1d66f63b67945
parent1fed961e25a6afd4070d8873b431aba8342406c3 (diff)
downloadopie-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
Diffstat (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
@@ -1,19 +1,20 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on debug 2CONFIG = qt warn_on debug
3HEADERS = 3HEADERS =
4SOURCES = odebugdemo.cpp 4SOURCES = odebugdemo.cpp
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(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 )
15} 14}
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,107 +1,142 @@
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
9 ONetwork* net = ONetwork::instance(); 11 ONetwork* net = ONetwork::instance();
10 12
11 ONetwork::InterfaceIterator it = net->iterator(); 13 ONetwork::InterfaceIterator it = net->iterator();
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" ) );
20 qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); 23 qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) );
21 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); 24 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
22 if ( it.current()->isWireless() ) 25 if ( it.current()->isWireless() )
23 { 26 {
24 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); 27 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
25 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); 28 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
26 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); 29 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
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" )
46 qDebug( "DEMO: Warning! Can't change operation mode" ); 53 qDebug( "DEMO: Warning! Can't change operation mode" );
47 else 54 else
48 qDebug( "DEMO: Operation Mode change successful." ); 55 qDebug( "DEMO: Operation Mode change successful." );
49 56
50 // RF channel 57 // RF channel
51 qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); 58 qDebug( "DEMO: Current Channel is '%d'", iface->channel() );
52 iface->setChannel( 1 ); 59 iface->setChannel( 1 );
53 if ( iface->channel() != 1 ) 60 if ( iface->channel() != 1 )
54 qDebug( "DEMO: Warning! Can't change RF channel" ); 61 qDebug( "DEMO: Warning! Can't change RF channel" );
55 else 62 else
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 )
64 { 75 {
65 qDebug( "DEMO: # of stations around = %d", stations->count() ); 76 qDebug( "DEMO: # of stations around = %d", stations->count() );
66 OStation* station; 77 OStation* station;
67 for ( station = stations->first(); station != 0; station = stations->next() ) 78 for ( station = stations->first(); station != 0; station = stations->next() )
68 { 79 {
69 qDebug( "DEMO: station dump following..." ); 80 qDebug( "DEMO: station dump following..." );
70 station->dump(); 81 station->dump();
71 } 82 }
72 } 83 }
73 84
74 else 85 else
75 { 86 {
76 qDebug( "DEMO: Warning! Scan didn't work!" ); 87 qDebug( "DEMO: Warning! Scan didn't work!" );
77 } 88 }
78 89
79 /* 90 /*
80 91
81 // first some wrong calls to check if this is working 92 // first some wrong calls to check if this is working
82 iface->setPrivate( "seppel", 10 ); 93 iface->setPrivate( "seppel", 10 );
83 iface->setPrivate( "monitor", 0 ); 94 iface->setPrivate( "monitor", 0 );
84 95
85 // now the real deal 96 // now the real deal
86 iface->setPrivate( "monitor", 2, 2, 3 ); 97 iface->setPrivate( "monitor", 2, 2, 3 );
87 98
88 // trying to set hw address to 12:34:56:AB:CD:EF 99 // trying to set hw address to 12:34:56:AB:CD:EF
89 100
90 /* 101 /*
91 102
92 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); 103 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" );
93 iface->setUp( false ); 104 iface->setUp( false );
94 iface->setMacAddress( addr ); 105 iface->setMacAddress( addr );
95 iface->setUp( true ); 106 iface->setUp( true );
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 }
104 139
105 return 0; 140 return 0;
106 141
107} 142}
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
@@ -652,82 +652,124 @@ int OWirelessNetworkInterface::channels() const
652} 652}
653 653
654 654
655void OWirelessNetworkInterface::setChannelHopping( int interval ) 655void OWirelessNetworkInterface::setChannelHopping( int interval )
656{ 656{
657 if ( !_hopper ) _hopper = new OChannelHopper( this ); 657 if ( !_hopper ) _hopper = new OChannelHopper( this );
658 _hopper->setInterval( interval ); 658 _hopper->setInterval( interval );
659 //FIXME: When and by whom will the channel hopper be deleted? 659 //FIXME: When and by whom will the channel hopper be deleted?
660 //TODO: rely on QObject hierarchy 660 //TODO: rely on QObject hierarchy
661} 661}
662 662
663 663
664int OWirelessNetworkInterface::channelHopping() const 664int OWirelessNetworkInterface::channelHopping() const
665{ 665{
666 return _hopper->interval(); 666 return _hopper->interval();
667} 667}
668 668
669 669
670OChannelHopper* OWirelessNetworkInterface::channelHopper() const 670OChannelHopper* OWirelessNetworkInterface::channelHopper() const
671{ 671{
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 );
714 _iwr.u.essid.length = nickname.length(); 756 _iwr.u.essid.length = nickname.length();
715 wioctl( SIOCSIWNICKN ); 757 wioctl( SIOCSIWNICKN );
716} 758}
717 759
718 760
719QString OWirelessNetworkInterface::nickName() const 761QString OWirelessNetworkInterface::nickName() const
720{ 762{
721 char str[IW_ESSID_MAX_SIZE]; 763 char str[IW_ESSID_MAX_SIZE];
722 _iwr.u.data.pointer = &str[0]; 764 _iwr.u.data.pointer = &str[0];
723 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 765 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
724 if ( !wioctl( SIOCGIWNICKN ) ) 766 if ( !wioctl( SIOCGIWNICKN ) )
725 { 767 {
726 return "<unknown>"; 768 return "<unknown>";
727 } 769 }
728 else 770 else
729 { 771 {
730 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 772 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
731 return str; 773 return str;
732 } 774 }
733} 775}
@@ -948,54 +990,48 @@ bool OWirelessNetworkInterface::wioctl( int call ) const
948 * OMonitoringInterface 990 * OMonitoringInterface
949 *======================================================================================*/ 991 *======================================================================================*/
950 992
951OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 993OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
952 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 994 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
953{ 995{
954} 996}
955 997
956 998
957OMonitoringInterface::~OMonitoringInterface() 999OMonitoringInterface::~OMonitoringInterface()
958{ 1000{
959} 1001}
960 1002
961 1003
962void OMonitoringInterface::setChannel( int c ) 1004void OMonitoringInterface::setChannel( int c )
963{ 1005{
964 // use standard WE channel switching protocol 1006 // use standard WE channel switching protocol
965 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1007 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
966 _if->_iwr.u.freq.m = c; 1008 _if->_iwr.u.freq.m = c;
967 _if->_iwr.u.freq.e = 0; 1009 _if->_iwr.u.freq.e = 0;
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
982 1018
983/*====================================================================================== 1019/*======================================================================================
984 * OCiscoMonitoringInterface 1020 * OCiscoMonitoringInterface
985 *======================================================================================*/ 1021 *======================================================================================*/
986 1022
987OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1023OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
988 :OMonitoringInterface( iface, prismHeader ) 1024 :OMonitoringInterface( iface, prismHeader )
989{ 1025{
990 iface->setMonitoring( this ); 1026 iface->setMonitoring( this );
991} 1027}
992 1028
993 1029
994OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1030OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
995{ 1031{
996} 1032}
997 1033
998 1034
999void OCiscoMonitoringInterface::setEnabled( bool b ) 1035void OCiscoMonitoringInterface::setEnabled( bool b )
1000{ 1036{
1001 QString fname; 1037 QString fname;
@@ -1071,104 +1107,86 @@ void OWlanNGMonitoringInterface::setChannel( int c )
1071 QString prism = _prismHeader ? "true" : "false"; 1107 QString prism = _prismHeader ? "true" : "false";
1072 QString cmd; 1108 QString cmd;
1073 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1109 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1074 (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); 1110 (const char*) _if->name(), c, (const char*) enable, (const char*) prism );
1075 system( cmd ); 1111 system( cmd );
1076} 1112}
1077 1113
1078 1114
1079/*====================================================================================== 1115/*======================================================================================
1080 * OHostAPMonitoringInterface 1116 * OHostAPMonitoringInterface
1081 *======================================================================================*/ 1117 *======================================================================================*/
1082 1118
1083OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1119OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1084 :OMonitoringInterface( iface, prismHeader ) 1120 :OMonitoringInterface( iface, prismHeader )
1085{ 1121{
1086 iface->setMonitoring( this ); 1122 iface->setMonitoring( this );
1087} 1123}
1088 1124
1089OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 1125OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
1090{ 1126{
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 );
1108 } 1135 }
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
1118{ 1144{
1119 return "hostap"; 1145 return "hostap";
1120} 1146}
1121 1147
1122 1148
1123/*====================================================================================== 1149/*======================================================================================
1124 * OOrinocoNetworkInterface 1150 * OOrinocoNetworkInterface
1125 *======================================================================================*/ 1151 *======================================================================================*/
1126 1152
1127OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1153OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1128 :OMonitoringInterface( iface, prismHeader ) 1154 :OMonitoringInterface( iface, prismHeader )
1129{ 1155{
1130 iface->setMonitoring( this ); 1156 iface->setMonitoring( this );
1131} 1157}
1132 1158
1133 1159
1134OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 1160OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
1135{ 1161{
1136} 1162}
1137 1163
1138 1164
1139void OOrinocoMonitoringInterface::setChannel( int c ) 1165void OOrinocoMonitoringInterface::setChannel( int c )
1140{ 1166{
1141 int monitorCode = _prismHeader ? 1 : 2; 1167 int monitorCode = _prismHeader ? 1 : 2;
1142 _if->setPrivate( "monitor", 2, monitorCode, c ); 1168 _if->setPrivate( "monitor", 2, monitorCode, c );
1143} 1169}
1144 1170
1145 1171
1146void OOrinocoMonitoringInterface::setEnabled( bool b ) 1172void OOrinocoMonitoringInterface::setEnabled( bool b )
1147{ 1173{
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
1172{ 1190{
1173 return "orinoco"; 1191 return "orinoco";
1174} 1192}
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
@@ -328,66 +328,61 @@ class OWirelessNetworkInterface : public ONetworkInterface
328 /** 328 /**
329 * @returns the channel index of the current radio frequency. 329 * @returns the channel index of the current radio frequency.
330 */ 330 */
331 virtual int channel() const; 331 virtual int channel() const;
332 /** 332 /**
333 * @returns the current radio frequency (in MHz). 333 * @returns the current radio frequency (in MHz).
334 */ 334 */
335 virtual double frequency() const; 335 virtual double frequency() const;
336 /** 336 /**
337 * @returns the number of radio frequency channels for the 337 * @returns the number of radio frequency channels for the
338 * corresponding wireless network device. 338 * corresponding wireless network device.
339 * @note European devices usually have 14 channels, while American typically feature 11 channels. 339 * @note European devices usually have 14 channels, while American typically feature 11 channels.
340 */ 340 */
341 virtual int channels() const; 341 virtual int channels() const;
342 /** 342 /**
343 * Set the IEEE 802.11 operation @a mode. 343 * Set the IEEE 802.11 operation @a mode.
344 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master 344 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master
345 * @warning Not all drivers support the all modes. 345 * @warning Not all drivers support the all modes.
346 * @note You might have to change the SSID to get the operation mode change into effect. 346 * @note You might have to change the SSID to get the operation mode change into effect.
347 */ 347 */
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.
359 * @warning Standard wireless network drives don't support the monitor mode. 358 * @warning Standard wireless network drives don't support the monitor mode.
360 * @warning You need a patched driver for this to work. 359 * @warning You need a patched driver for this to work.
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 */
374 virtual void setChannelHopping( int interval = 0 ); 369 virtual void setChannelHopping( int interval = 0 );
375 /** 370 /**
376 * @returns the channel hopping interval or 0, if channel hopping is disabled. 371 * @returns the channel hopping interval or 0, if channel hopping is disabled.
377 */ 372 */
378 virtual int channelHopping() const; 373 virtual int channelHopping() const;
379 /** 374 /**
380 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before 375 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before
381 */ 376 */
382 virtual OChannelHopper* channelHopper() const; 377 virtual OChannelHopper* channelHopper() const;
383 /** 378 /**
384 * Set the station @a nickname. 379 * Set the station @a nickname.
385 */ 380 */
386 virtual void setNickName( const QString& nickname ); 381 virtual void setNickName( const QString& nickname );
387 /** 382 /**
388 * @returns the current station nickname. 383 * @returns the current station nickname.
389 */ 384 */
390 virtual QString nickName() const; 385 virtual QString nickName() const;
391 /** 386 /**
392 * Invoke the private IOCTL @a command with a @number of parameters on the network interface. 387 * Invoke the private IOCTL @a command with a @number of parameters on the network interface.
393 * @see OPrivateIOCTL 388 * @see OPrivateIOCTL
@@ -401,83 +396,86 @@ class OWirelessNetworkInterface : public ONetworkInterface
401 /** 396 /**
402 * @returns true if the interface is associated to an access point 397 * @returns true if the interface is associated to an access point
403 * @note: This information is only valid if the interface is in managed mode. 398 * @note: This information is only valid if the interface is in managed mode.
404 */ 399 */
405 virtual bool isAssociated() const; 400 virtual bool isAssociated() const;
406 /** 401 /**
407 * @returns the MAC address of the Access Point if the device is in infrastructure mode. 402 * @returns the MAC address of the Access Point if the device is in infrastructure mode.
408 * @returns a (more or less random) cell ID address if the device is in adhoc mode. 403 * @returns a (more or less random) cell ID address if the device is in adhoc mode.
409 */ 404 */
410 virtual OMacAddress associatedAP() const; 405 virtual OMacAddress associatedAP() const;
411 /** 406 /**
412 * Set the @a ssid (Service Set ID) string. This is used to decide 407 * Set the @a ssid (Service Set ID) string. This is used to decide
413 * which network to associate with (use "any" to let the driver decide). 408 * which network to associate with (use "any" to let the driver decide).
414 */ 409 */
415 virtual void setSSID( const QString& ssid ); 410 virtual void setSSID( const QString& ssid );
416 /** 411 /**
417 * @returns the current SSID (Service Set ID). 412 * @returns the current SSID (Service Set ID).
418 */ 413 */
419 virtual QString SSID() const; 414 virtual QString SSID() const;
420 /** 415 /**
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();
429 void dumpInformation() const; 428 void dumpInformation() const;
430 virtual void init(); 429 virtual void init();
431 struct iwreq& iwr() const; 430 struct iwreq& iwr() const;
432 bool wioctl( int call ) const; 431 bool wioctl( int call ) const;
433 bool wioctl( int call, struct iwreq& ) const; 432 bool wioctl( int call, struct iwreq& ) const;
434 433
435 protected: 434 protected:
436 mutable struct iwreq _iwr; 435 mutable struct iwreq _iwr;
437 QMap<int,int> _channels; 436 QMap<int,int> _channels;
438 struct iw_range _range; 437 struct iw_range _range;
439 438
440 private: 439 private:
441 OChannelHopper* _hopper; 440 OChannelHopper* _hopper;
442}; 441};
443 442
444 443
445/*====================================================================================== 444/*======================================================================================
446 * OMonitoringInterface 445 * OMonitoringInterface
447 *======================================================================================*/ 446 *======================================================================================*/
448 447
449 448
450class OMonitoringInterface 449class OMonitoringInterface
451{ 450{
452 public: 451 public:
453 OMonitoringInterface(); 452 OMonitoringInterface();
454 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 453 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
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
464 protected: 462 protected:
465 OWirelessNetworkInterface* _if; 463 OWirelessNetworkInterface* _if;
466 bool _prismHeader; 464 bool _prismHeader;
467 465
468}; 466};
469 467
470 468
471/*====================================================================================== 469/*======================================================================================
472 * OCiscoMonitoring 470 * OCiscoMonitoring
473 *======================================================================================*/ 471 *======================================================================================*/
474 472
475 473
476class OCiscoMonitoringInterface : public OMonitoringInterface 474class OCiscoMonitoringInterface : public OMonitoringInterface
477{ 475{
478 public: 476 public:
479 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 477 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
480 virtual ~OCiscoMonitoringInterface(); 478 virtual ~OCiscoMonitoringInterface();
481 479
482 virtual void setEnabled( bool ); 480 virtual void setEnabled( bool );
483 virtual QString name() const; 481 virtual QString name() const;