summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2004-02-23 15:59:05 (UTC)
committer mickeyl <mickeyl>2004-02-23 15:59:05 (UTC)
commit20b0e62e6c23cdaed9a30d6fad73431edc60be53 (patch) (unidiff)
treea179f858449e56b04883267c61141f163b4dfbac /libopie2
parent68c8d3eb878f9ba913c42368fbb253d7320c62be (diff)
downloadopie-20b0e62e6c23cdaed9a30d6fad73431edc60be53.zip
opie-20b0e62e6c23cdaed9a30d6fad73431edc60be53.tar.gz
opie-20b0e62e6c23cdaed9a30d6fad73431edc60be53.tar.bz2
addition to API: OWirelessNetworkInterface::signalStrength() [wip]
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp8
-rw-r--r--libopie2/opienet/onetwork.h20
2 files changed, 21 insertions, 7 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index d918193..16fa8ae 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -903,128 +903,136 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
903 903
904 // parse results 904 // parse results
905 905
906 int offset = 0; 906 int offset = 0;
907 struct iw_event* we = (struct iw_event*) &buffer[0]; 907 struct iw_event* we = (struct iw_event*) &buffer[0];
908 908
909 while ( offset < _iwr.u.data.length ) 909 while ( offset < _iwr.u.data.length )
910 { 910 {
911 //const char* cmd = *(*_ioctlmap)[we->cmd]; 911 //const char* cmd = *(*_ioctlmap)[we->cmd];
912 //if ( !cmd ) cmd = "<unknown>"; 912 //if ( !cmd ) cmd = "<unknown>";
913 odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; 913 odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl;
914 switch (we->cmd) 914 switch (we->cmd)
915 { 915 {
916 case SIOCGIWAP: 916 case SIOCGIWAP:
917 { 917 {
918 odebug << "SIOCGIWAP" << oendl; 918 odebug << "SIOCGIWAP" << oendl;
919 stations->append( new OStation() ); 919 stations->append( new OStation() );
920 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; 920 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
921 break; 921 break;
922 } 922 }
923 case SIOCGIWMODE: 923 case SIOCGIWMODE:
924 { 924 {
925 odebug << "SIOCGIWMODE" << oendl; 925 odebug << "SIOCGIWMODE" << oendl;
926 stations->last()->type = modeToString( we->u.mode ); 926 stations->last()->type = modeToString( we->u.mode );
927 break; 927 break;
928 } 928 }
929 case SIOCGIWFREQ: 929 case SIOCGIWFREQ:
930 { 930 {
931 odebug << "SIOCGIWFREQ" << oendl; 931 odebug << "SIOCGIWFREQ" << oendl;
932 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; 932 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
933 break; 933 break;
934 } 934 }
935 case SIOCGIWESSID: 935 case SIOCGIWESSID:
936 { 936 {
937 odebug << "SIOCGIWESSID" << oendl; 937 odebug << "SIOCGIWESSID" << oendl;
938 stations->last()->ssid = we->u.essid.pointer; 938 stations->last()->ssid = we->u.essid.pointer;
939 break; 939 break;
940 } 940 }
941 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; 941 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break;
942 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; 942 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break;
943 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ 943 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */
944 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ 944 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */
945 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ 945 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */
946 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ 946 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */
947 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ 947 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */
948 default: odebug << "unhandled event" << oendl; 948 default: odebug << "unhandled event" << oendl;
949 } 949 }
950 950
951 offset += we->len; 951 offset += we->len;
952 we = (struct iw_event*) &buffer[offset]; 952 we = (struct iw_event*) &buffer[offset];
953 } 953 }
954 return stations; 954 return stations;
955 955
956 return stations; 956 return stations;
957 957
958 } 958 }
959 else 959 else
960 { 960 {
961 odebug << " - no results (timeout) :(" << oendl; 961 odebug << " - no results (timeout) :(" << oendl;
962 return stations; 962 return stations;
963 } 963 }
964} 964}
965 965
966 966
967int OWirelessNetworkInterface::signalStrength() const
968{
969 int max = _range.max_qual.level;
970 odebug << "signalStrength(): max quality seems to be " << max << "dBM" << oendl;
971 return 50;
972}
973
974
967bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 975bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
968{ 976{
969 #ifndef NODEBUG 977 #ifndef NODEBUG
970 int result = ::ioctl( _sfd, call, &iwreq ); 978 int result = ::ioctl( _sfd, call, &iwreq );
971 979
972 if ( result == -1 ) 980 if ( result == -1 )
973 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 981 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
974 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; 982 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
975 else 983 else
976 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 984 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
977 << debugmapper->map( call ) << "' - Status: Ok." << oendl; 985 << debugmapper->map( call ) << "' - Status: Ok." << oendl;
978 986
979 return ( result != -1 ); 987 return ( result != -1 );
980 #else 988 #else
981 return ::ioctl( _sfd, call, &iwreq ) != -1; 989 return ::ioctl( _sfd, call, &iwreq ) != -1;
982 #endif 990 #endif
983} 991}
984 992
985 993
986bool OWirelessNetworkInterface::wioctl( int call ) const 994bool OWirelessNetworkInterface::wioctl( int call ) const
987{ 995{
988 strcpy( _iwr.ifr_name, name() ); 996 strcpy( _iwr.ifr_name, name() );
989 return wioctl( call, _iwr ); 997 return wioctl( call, _iwr );
990} 998}
991 999
992 1000
993/*====================================================================================== 1001/*======================================================================================
994 * OMonitoringInterface 1002 * OMonitoringInterface
995 *======================================================================================*/ 1003 *======================================================================================*/
996 1004
997OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1005OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
998 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 1006 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
999{ 1007{
1000} 1008}
1001 1009
1002 1010
1003OMonitoringInterface::~OMonitoringInterface() 1011OMonitoringInterface::~OMonitoringInterface()
1004{ 1012{
1005} 1013}
1006 1014
1007 1015
1008void OMonitoringInterface::setChannel( int c ) 1016void OMonitoringInterface::setChannel( int c )
1009{ 1017{
1010 // use standard WE channel switching protocol 1018 // use standard WE channel switching protocol
1011 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1019 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
1012 _if->_iwr.u.freq.m = c; 1020 _if->_iwr.u.freq.m = c;
1013 _if->_iwr.u.freq.e = 0; 1021 _if->_iwr.u.freq.e = 0;
1014 _if->wioctl( SIOCSIWFREQ ); 1022 _if->wioctl( SIOCSIWFREQ );
1015} 1023}
1016 1024
1017 1025
1018void OMonitoringInterface::setEnabled( bool b ) 1026void OMonitoringInterface::setEnabled( bool b )
1019{ 1027{
1020} 1028}
1021 1029
1022 1030
1023/*====================================================================================== 1031/*======================================================================================
1024 * OCiscoMonitoringInterface 1032 * OCiscoMonitoringInterface
1025 *======================================================================================*/ 1033 *======================================================================================*/
1026 1034
1027OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1035OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1028 :OMonitoringInterface( iface, prismHeader ) 1036 :OMonitoringInterface( iface, prismHeader )
1029{ 1037{
1030 iface->setMonitoring( this ); 1038 iface->setMonitoring( this );
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index bc9e299..9b8a0d4 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,480 +1,486 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer
4 =. 4 =. <mickey@Vanille.de>
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#ifndef ONETWORK_H 31#ifndef ONETWORK_H
32#define ONETWORK_H 32#define ONETWORK_H
33 33
34#include "wireless.h" 34#include "wireless.h"
35 35
36/* OPIE */ 36/* OPIE */
37 37
38#include <opie2/onetutils.h> 38#include <opie2/onetutils.h>
39#include <opie2/ostation.h> 39#include <opie2/ostation.h>
40 40
41/* QT */ 41/* QT */
42 42
43#include <qvaluelist.h> 43#include <qvaluelist.h>
44#include <qdict.h> 44#include <qdict.h>
45#include <qmap.h> 45#include <qmap.h>
46#include <qobject.h> 46#include <qobject.h>
47#include <qhostaddress.h> 47#include <qhostaddress.h>
48 48
49class ONetworkInterface; 49class ONetworkInterface;
50class OWirelessNetworkInterface; 50class OWirelessNetworkInterface;
51class OChannelHopper; 51class OChannelHopper;
52class OMonitoringInterface; 52class OMonitoringInterface;
53 53
54/*====================================================================================== 54/*======================================================================================
55 * ONetwork 55 * ONetwork
56 *======================================================================================*/ 56 *======================================================================================*/
57 57
58/** 58/**
59 * @brief A container class for all network interfaces 59 * @brief A container class for all network interfaces
60 * 60 *
61 * This class provides access to all available network interfaces of your computer. 61 * This class provides access to all available network interfaces of your computer.
62 * 62 *
63 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 63 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
64 */ 64 */
65class ONetwork : public QObject 65class ONetwork : public QObject
66{ 66{
67 Q_OBJECT 67 Q_OBJECT
68 68
69 public: 69 public:
70 typedef QDict<ONetworkInterface> InterfaceMap; 70 typedef QDict<ONetworkInterface> InterfaceMap;
71 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 71 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
72 72
73 public: 73 public:
74 /** 74 /**
75 * @returns the number of available interfaces 75 * @returns the number of available interfaces
76 */ 76 */
77 int count() const; 77 int count() const;
78 /** 78 /**
79 * @returns a pointer to the (one and only) @ref ONetwork instance. 79 * @returns a pointer to the (one and only) @ref ONetwork instance.
80 */ 80 */
81 static ONetwork* instance(); 81 static ONetwork* instance();
82 /** 82 /**
83 * @returns an iterator usable for iterating through all network interfaces. 83 * @returns an iterator usable for iterating through all network interfaces.
84 */ 84 */
85 InterfaceIterator iterator() const; 85 InterfaceIterator iterator() const;
86 /** 86 /**
87 * @returns true, if the @a interface supports the wireless extension protocol. 87 * @returns true, if the @a interface supports the wireless extension protocol.
88 */ 88 */
89 bool isWirelessInterface( const char* interface ) const; 89 bool isWirelessInterface( const char* interface ) const;
90 /** 90 /**
91 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 91 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
92 * @see ONetworkInterface 92 * @see ONetworkInterface
93 */ 93 */
94 ONetworkInterface* interface( const QString& interface ) const; 94 ONetworkInterface* interface( const QString& interface ) const;
95 /** 95 /**
96 * @internal Rebuild the internal interface database 96 * @internal Rebuild the internal interface database
97 * @note Sometimes it might be useful to call this from client code, 97 * @note Sometimes it might be useful to call this from client code,
98 * e.g. after issuing a cardctl insert 98 * e.g. after issuing a cardctl insert
99 */ 99 */
100 void synchronize(); 100 void synchronize();
101 /** 101 /**
102 * @returns the wireless extension version used at compile time. 102 * @returns the wireless extension version used at compile time.
103 **/ 103 **/
104 static short wirelessExtensionVersion(); 104 static short wirelessExtensionVersion();
105 105
106 protected: 106 protected:
107 ONetwork(); 107 ONetwork();
108 108
109 private: 109 private:
110 static ONetwork* _instance; 110 static ONetwork* _instance;
111 InterfaceMap _interfaces; 111 InterfaceMap _interfaces;
112}; 112};
113 113
114 114
115/*====================================================================================== 115/*======================================================================================
116 * ONetworkInterface 116 * ONetworkInterface
117 *======================================================================================*/ 117 *======================================================================================*/
118 118
119/** 119/**
120 * @brief A network interface wrapper. 120 * @brief A network interface wrapper.
121 * 121 *
122 * This class provides a wrapper for a network interface. All the cumbersume details of 122 * This class provides a wrapper for a network interface. All the cumbersume details of
123 * Linux ioctls are hidden under a convenient high-level interface. 123 * Linux ioctls are hidden under a convenient high-level interface.
124 * @warning Most of the setting methods contained in this class require the appropriate 124 * @warning Most of the setting methods contained in this class require the appropriate
125 * process permissions to work. 125 * process permissions to work.
126 * 126 *
127 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 127 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
128 */ 128 */
129class ONetworkInterface : public QObject 129class ONetworkInterface : public QObject
130{ 130{
131 friend class OMonitoringInterface; 131 friend class OMonitoringInterface;
132 friend class OCiscoMonitoringInterface; 132 friend class OCiscoMonitoringInterface;
133 friend class OWlanNGMonitoringInterface; 133 friend class OWlanNGMonitoringInterface;
134 friend class OHostAPMonitoringInterface; 134 friend class OHostAPMonitoringInterface;
135 friend class OOrinocoMonitoringInterface; 135 friend class OOrinocoMonitoringInterface;
136 136
137 public: 137 public:
138 /** 138 /**
139 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 139 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
140 * but access them via @ref ONetwork::interface(). 140 * but access them via @ref ONetwork::interface().
141 */ 141 */
142 ONetworkInterface( QObject* parent, const char* name ); 142 ONetworkInterface( QObject* parent, const char* name );
143 /** 143 /**
144 * Destructor. 144 * Destructor.
145 */ 145 */
146 virtual ~ONetworkInterface(); 146 virtual ~ONetworkInterface();
147 /** 147 /**
148 * Associates a @a monitoring interface with this network interface. 148 * Associates a @a monitoring interface with this network interface.
149 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 149 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
150 */ 150 */
151 void setMonitoring( OMonitoringInterface* monitoring ); 151 void setMonitoring( OMonitoringInterface* monitoring );
152 /** 152 /**
153 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 153 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
154 */ 154 */
155 OMonitoringInterface* monitoring() const; 155 OMonitoringInterface* monitoring() const;
156 /** 156 /**
157 * Setting an interface to promiscuous mode enables the device to receive 157 * Setting an interface to promiscuous mode enables the device to receive
158 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 158 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
159 */ 159 */
160 bool setPromiscuousMode( bool ); 160 bool setPromiscuousMode( bool );
161 /** 161 /**
162 * @returns true if the interface is set to promiscuous mode. 162 * @returns true if the interface is set to promiscuous mode.
163 */ 163 */
164 bool promiscuousMode() const; 164 bool promiscuousMode() const;
165 /** 165 /**
166 * Setting an interface to up enables it to receive packets. 166 * Setting an interface to up enables it to receive packets.
167 */ 167 */
168 bool setUp( bool ); 168 bool setUp( bool );
169 /** 169 /**
170 * @returns true if the interface is up. 170 * @returns true if the interface is up.
171 */ 171 */
172 bool isUp() const; 172 bool isUp() const;
173 /** 173 /**
174 * @returns true if the interface is a loopback interface. 174 * @returns true if the interface is a loopback interface.
175 */ 175 */
176 bool isLoopback() const; 176 bool isLoopback() const;
177 /** 177 /**
178 * @returns true if the interface is featuring supports the wireless extension protocol. 178 * @returns true if the interface is featuring supports the wireless extension protocol.
179 */ 179 */
180 bool isWireless() const; 180 bool isWireless() const;
181 /** 181 /**
182 * Associate the IP address @ addr with the interface. 182 * Associate the IP address @ addr with the interface.
183 */ 183 */
184 void setIPV4Address( const QHostAddress& addr ); 184 void setIPV4Address( const QHostAddress& addr );
185 /** 185 /**
186 * @returns the IPv4 address associated with the interface. 186 * @returns the IPv4 address associated with the interface.
187 */ 187 */
188 QString ipV4Address() const; //TODO: make this return an OHostAddress 188 QString ipV4Address() const; //TODO: make this return an OHostAddress
189 /** 189 /**
190 * Associate the MAC address @a addr with the interface. 190 * Associate the MAC address @a addr with the interface.
191 * @note It can be necessary to shut down the interface prior to calling this method. 191 * @note It can be necessary to shut down the interface prior to calling this method.
192 * @warning This is not supported by all drivers. 192 * @warning This is not supported by all drivers.
193 */ 193 */
194 void setMacAddress( const OMacAddress& addr ); 194 void setMacAddress( const OMacAddress& addr );
195 /** 195 /**
196 * @returns the MAC address associated with the interface. 196 * @returns the MAC address associated with the interface.
197 */ 197 */
198 OMacAddress macAddress() const; 198 OMacAddress macAddress() const;
199 /** 199 /**
200 * Associate the IPv4 @a netmask with the interface. 200 * Associate the IPv4 @a netmask with the interface.
201 */ 201 */
202 void setIPV4Netmask( const QHostAddress& netmask ); 202 void setIPV4Netmask( const QHostAddress& netmask );
203 /** 203 /**
204 * @returns the IPv4 netmask associated with the interface. 204 * @returns the IPv4 netmask associated with the interface.
205 */ 205 */
206 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 206 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
207 /** 207 /**
208 * @returns the data link type currently associated with the interface. 208 * @returns the data link type currently associated with the interface.
209 * @see #include <net/if_arp.h> for possible values. 209 * @see #include <net/if_arp.h> for possible values.
210 */ 210 */
211 int dataLinkType() const; 211 int dataLinkType() const;
212 212
213 protected: 213 protected:
214 const int _sfd; 214 const int _sfd;
215 mutable ifreq _ifr; 215 mutable ifreq _ifr;
216 OMonitoringInterface* _mon; 216 OMonitoringInterface* _mon;
217 217
218 protected: 218 protected:
219 struct ifreq& ifr() const; 219 struct ifreq& ifr() const;
220 virtual void init(); 220 virtual void init();
221 bool ioctl( int call ) const; 221 bool ioctl( int call ) const;
222 bool ioctl( int call, struct ifreq& ) const; 222 bool ioctl( int call, struct ifreq& ) const;
223}; 223};
224 224
225/*====================================================================================== 225/*======================================================================================
226 * OChannelHopper 226 * OChannelHopper
227 *======================================================================================*/ 227 *======================================================================================*/
228 228
229/** 229/**
230 * @brief A radio frequency channel hopper. 230 * @brief A radio frequency channel hopper.
231 * 231 *
232 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 232 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
233 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 233 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
234 * This is necessary when in monitoring mode and scanning for other devices, because 234 * This is necessary when in monitoring mode and scanning for other devices, because
235 * the radio frequency hardware can only detect packets sent on the same frequency. 235 * the radio frequency hardware can only detect packets sent on the same frequency.
236 * 236 *
237 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 237 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
238 */ 238 */
239class OChannelHopper : public QObject 239class OChannelHopper : public QObject
240{ 240{
241 Q_OBJECT 241 Q_OBJECT
242 242
243 public: 243 public:
244 /** 244 /**
245 * Constructor. 245 * Constructor.
246 */ 246 */
247 OChannelHopper( OWirelessNetworkInterface* ); 247 OChannelHopper( OWirelessNetworkInterface* );
248 /** 248 /**
249 * Destructor. 249 * Destructor.
250 */ 250 */
251 virtual ~OChannelHopper(); 251 virtual ~OChannelHopper();
252 /** 252 /**
253 * @returns true, if the channel hopper is hopping channels 253 * @returns true, if the channel hopper is hopping channels
254 */ 254 */
255 bool isActive() const; 255 bool isActive() const;
256 /** 256 /**
257 * @returns the last hopped channel 257 * @returns the last hopped channel
258 */ 258 */
259 int channel() const; 259 int channel() const;
260 /** 260 /**
261 * Set the channel hopping @a interval. 261 * Set the channel hopping @a interval.
262 * An interval of 0 deactivates the channel hopper. 262 * An interval of 0 deactivates the channel hopper.
263 */ 263 */
264 void setInterval( int interval ); 264 void setInterval( int interval );
265 /** 265 /**
266 * @returns the channel hopping interval 266 * @returns the channel hopping interval
267 */ 267 */
268 int interval() const; 268 int interval() const;
269 269
270 signals: 270 signals:
271 /** 271 /**
272 * This signal is emitted right after the channel hopper performed a hop 272 * This signal is emitted right after the channel hopper performed a hop
273 */ 273 */
274 void hopped( int ); 274 void hopped( int );
275 275
276 protected: 276 protected:
277 virtual void timerEvent( QTimerEvent* ); 277 virtual void timerEvent( QTimerEvent* );
278 278
279 private: 279 private:
280 OWirelessNetworkInterface* _iface; 280 OWirelessNetworkInterface* _iface;
281 int _interval; 281 int _interval;
282 int _tid; 282 int _tid;
283 QValueList<int> _channels; 283 QValueList<int> _channels;
284 QValueList<int>::Iterator _channel; 284 QValueList<int>::Iterator _channel;
285}; 285};
286 286
287 287
288/*====================================================================================== 288/*======================================================================================
289 * OWirelessNetworkInterface 289 * OWirelessNetworkInterface
290 *======================================================================================*/ 290 *======================================================================================*/
291 291
292/** 292/**
293 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 293 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
294 * 294 *
295 * This class provides a high-level encapsulation of the Linux wireless extension API. 295 * This class provides a high-level encapsulation of the Linux wireless extension API.
296 * 296 *
297 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 297 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
298 */ 298 */
299class OWirelessNetworkInterface : public ONetworkInterface 299class OWirelessNetworkInterface : public ONetworkInterface
300{ 300{
301 friend class OMonitoringInterface; 301 friend class OMonitoringInterface;
302 friend class OCiscoMonitoringInterface; 302 friend class OCiscoMonitoringInterface;
303 friend class OWlanNGMonitoringInterface; 303 friend class OWlanNGMonitoringInterface;
304 friend class OHostAPMonitoringInterface; 304 friend class OHostAPMonitoringInterface;
305 friend class OOrinocoMonitoringInterface; 305 friend class OOrinocoMonitoringInterface;
306 306
307 friend class OPrivateIOCTL; 307 friend class OPrivateIOCTL;
308 308
309 public: 309 public:
310 /** 310 /**
311 * Constructor. 311 * Constructor.
312 */ 312 */
313 OWirelessNetworkInterface( QObject* parent, const char* name ); 313 OWirelessNetworkInterface( QObject* parent, const char* name );
314 /** 314 /**
315 * Destructor. 315 * Destructor.
316 */ 316 */
317 virtual ~OWirelessNetworkInterface(); 317 virtual ~OWirelessNetworkInterface();
318 /** 318 /**
319 * Setting the @a channel of the interface changes the radio frequency (RF) 319 * Setting the @a channel of the interface changes the radio frequency (RF)
320 * of the corresponding wireless network device. 320 * of the corresponding wireless network device.
321 * @note Common channel range is within [1-14]. A value of 0 is not allowed. 321 * @note Common channel range is within [1-14]. A value of 0 is not allowed.
322 * @see channels() 322 * @see channels()
323 */ 323 */
324 virtual void setChannel( int channel ) const; 324 virtual void setChannel( int channel ) const;
325 /** 325 /**
326 * @returns the channel index of the current radio frequency. 326 * @returns the channel index of the current radio frequency.
327 */ 327 */
328 virtual int channel() const; 328 virtual int channel() const;
329 /** 329 /**
330 * @returns the current radio frequency (in MHz). 330 * @returns the current radio frequency (in MHz).
331 */ 331 */
332 virtual double frequency() const; 332 virtual double frequency() const;
333 /** 333 /**
334 * @returns the number of radio frequency channels for the 334 * @returns the number of radio frequency channels for the
335 * corresponding wireless network device. 335 * corresponding wireless network device.
336 * @note European devices usually have 14 channels, while American typically feature 11 channels. 336 * @note European devices usually have 14 channels, while American typically feature 11 channels.
337 */ 337 */
338 virtual int channels() const; 338 virtual int channels() const;
339 /** 339 /**
340 * Set the IEEE 802.11 operation @a mode. 340 * Set the IEEE 802.11 operation @a mode.
341 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master 341 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master
342 * @warning Not all drivers support the all modes. 342 * @warning Not all drivers support the all modes.
343 * @note You might have to change the SSID to get the operation mode change into effect. 343 * @note You might have to change the SSID to get the operation mode change into effect.
344 */ 344 */
345 virtual void setMode( const QString& mode ); 345 virtual void setMode( const QString& mode );
346 /** 346 /**
347 * @returns the current IEEE 802.11 operation mode. 347 * @returns the current IEEE 802.11 operation mode.
348 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown 348 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown
349 * 349 *
350 * @note: Important note concerning the 'monitor' mode: 350 * @note: Important note concerning the 'monitor' mode:
351 * Setting the monitor mode on a wireless network interface enables 351 * Setting the monitor mode on a wireless network interface enables
352 * listening to IEEE 802.11 data and management frames which normally 352 * listening to IEEE 802.11 data and management frames which normally
353 * are handled by the device firmware. This can be used to detect 353 * are handled by the device firmware. This can be used to detect
354 * other wireless network devices, e.g. Access Points or Ad-hoc stations. 354 * other wireless network devices, e.g. Access Points or Ad-hoc stations.
355 * @warning Standard wireless network drives don't support the monitor mode. 355 * @warning Standard wireless network drives don't support the monitor mode.
356 * @warning You need a patched driver for this to work. 356 * @warning You need a patched driver for this to work.
357 * @note Enabling the monitor mode is highly driver dependent and requires 357 * @note Enabling the monitor mode is highly driver dependent and requires
358 * the proper @ref OMonitoringInterface to be associated with the interface. 358 * the proper @ref OMonitoringInterface to be associated with the interface.
359 * @see OMonitoringInterface 359 * @see OMonitoringInterface
360 */ 360 */
361 virtual QString mode() const; 361 virtual QString mode() const;
362 /** 362 /**
363 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. 363 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping.
364 * @see OChannelHopper 364 * @see OChannelHopper
365 */ 365 */
366 virtual void setChannelHopping( int interval = 0 ); 366 virtual void setChannelHopping( int interval = 0 );
367 /** 367 /**
368 * @returns the channel hopping interval or 0, if channel hopping is disabled. 368 * @returns the channel hopping interval or 0, if channel hopping is disabled.
369 */ 369 */
370 virtual int channelHopping() const; 370 virtual int channelHopping() const;
371 /** 371 /**
372 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before 372 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before
373 */ 373 */
374 virtual OChannelHopper* channelHopper() const; 374 virtual OChannelHopper* channelHopper() const;
375 /** 375 /**
376 * Set the station @a nickname. 376 * Set the station @a nickname.
377 */ 377 */
378 virtual void setNickName( const QString& nickname ); 378 virtual void setNickName( const QString& nickname );
379 /** 379 /**
380 * @returns the current station nickname. 380 * @returns the current station nickname.
381 */ 381 */
382 virtual QString nickName() const; 382 virtual QString nickName() const;
383 /** 383 /**
384 * Invoke the private IOCTL @a command with a @number of parameters on the network interface. 384 * Invoke the private IOCTL @a command with a @number of parameters on the network interface.
385 * @see OPrivateIOCTL 385 * @see OPrivateIOCTL
386 */ 386 */
387 virtual void setPrivate( const QString& command, int number, ... ); 387 virtual void setPrivate( const QString& command, int number, ... );
388 /** 388 /**
389 * @returns true if the interface is featuring the private IOCTL @command. 389 * @returns true if the interface is featuring the private IOCTL @command.
390 */ 390 */
391 virtual bool hasPrivate( const QString& command ); 391 virtual bool hasPrivate( const QString& command );
392 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this 392 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this
393 /** 393 /**
394 * @returns true if the interface is associated to an access point 394 * @returns true if the interface is associated to an access point
395 * @note: This information is only valid if the interface is in managed mode. 395 * @note: This information is only valid if the interface is in managed mode.
396 */ 396 */
397 virtual bool isAssociated() const; 397 virtual bool isAssociated() const;
398 /** 398 /**
399 * @returns the MAC address of the Access Point if the device is in infrastructure mode. 399 * @returns the MAC address of the Access Point if the device is in infrastructure mode.
400 * @returns a (more or less random) cell ID address if the device is in adhoc mode. 400 * @returns a (more or less random) cell ID address if the device is in adhoc mode.
401 */ 401 */
402 virtual OMacAddress associatedAP() const; 402 virtual OMacAddress associatedAP() const;
403 /** 403 /**
404 * Set the @a ssid (Service Set ID) string. This is used to decide 404 * Set the @a ssid (Service Set ID) string. This is used to decide
405 * which network to associate with (use "any" to let the driver decide). 405 * which network to associate with (use "any" to let the driver decide).
406 */ 406 */
407 virtual void setSSID( const QString& ssid ); 407 virtual void setSSID( const QString& ssid );
408 /** 408 /**
409 * @returns the current SSID (Service Set ID). 409 * @returns the current SSID (Service Set ID).
410 */ 410 */
411 virtual QString SSID() const; 411 virtual QString SSID() const;
412 /** 412 /**
413 * Perform scanning the wireless network neighbourhood. 413 * Perform scanning the wireless network neighbourhood.
414 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! 414 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
415 */ 415 */
416 virtual OStationList* scanNetwork(); 416 virtual OStationList* scanNetwork();
417 /**
418 * @return signal strength to associated neighbour (in percent).
419 * In infrastructure mode, this is the signal strength of the Access Point.
420 * In other modes the result is driver dependent.
421 */
422 virtual int signalStrength() const;
417 /** @internal commit pending changes to the driver 423 /** @internal commit pending changes to the driver
418 * 424 *
419 */ 425 */
420 void commit() const; 426 void commit() const;
421 427
422 protected: 428 protected:
423 void buildInformation(); 429 void buildInformation();
424 void buildPrivateList(); 430 void buildPrivateList();
425 void dumpInformation() const; 431 void dumpInformation() const;
426 virtual void init(); 432 virtual void init();
427 struct iwreq& iwr() const; 433 struct iwreq& iwr() const;
428 bool wioctl( int call ) const; 434 bool wioctl( int call ) const;
429 bool wioctl( int call, struct iwreq& ) const; 435 bool wioctl( int call, struct iwreq& ) const;
430 436
431 protected: 437 protected:
432 mutable struct iwreq _iwr; 438 mutable struct iwreq _iwr;
433 QMap<int,int> _channels; 439 QMap<int,int> _channels;
434 struct iw_range _range; 440 struct iw_range _range;
435 441
436 private: 442 private:
437 OChannelHopper* _hopper; 443 OChannelHopper* _hopper;
438}; 444};
439 445
440 446
441/*====================================================================================== 447/*======================================================================================
442 * OMonitoringInterface 448 * OMonitoringInterface
443 *======================================================================================*/ 449 *======================================================================================*/
444 450
445 451
446class OMonitoringInterface 452class OMonitoringInterface
447{ 453{
448 public: 454 public:
449 OMonitoringInterface(); 455 OMonitoringInterface();
450 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 456 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
451 virtual ~OMonitoringInterface(); 457 virtual ~OMonitoringInterface();
452 458
453 public: 459 public:
454 virtual void setEnabled( bool ); 460 virtual void setEnabled( bool );
455 virtual void setChannel( int ); 461 virtual void setChannel( int );
456 462
457 virtual QString name() const = 0; 463 virtual QString name() const = 0;
458 464
459 protected: 465 protected:
460 OWirelessNetworkInterface* _if; 466 OWirelessNetworkInterface* _if;
461 bool _prismHeader; 467 bool _prismHeader;
462 468
463}; 469};
464 470
465 471
466/*====================================================================================== 472/*======================================================================================
467 * OCiscoMonitoring 473 * OCiscoMonitoring
468 *======================================================================================*/ 474 *======================================================================================*/
469 475
470 476
471class OCiscoMonitoringInterface : public OMonitoringInterface 477class OCiscoMonitoringInterface : public OMonitoringInterface
472{ 478{
473 public: 479 public:
474 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 480 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
475 virtual ~OCiscoMonitoringInterface(); 481 virtual ~OCiscoMonitoringInterface();
476 482
477 virtual void setEnabled( bool ); 483 virtual void setEnabled( bool );
478 virtual QString name() const; 484 virtual QString name() const;
479 virtual void setChannel( int ); 485 virtual void setChannel( int );
480 486