summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-04-18 21:40:04 (UTC)
committer mickeyl <mickeyl>2005-04-18 21:40:04 (UTC)
commit9e685cedc4425dd5ae60170e3f59a899c9e2bf36 (patch) (unidiff)
tree72e1eca8468cfde65f2cfa9446be4f08a1a9e19a /libopie2
parent3d5e5c098ccb686588380bc1f220beafbc5a6d76 (diff)
downloadopie-9e685cedc4425dd5ae60170e3f59a899c9e2bf36.zip
opie-9e685cedc4425dd5ae60170e3f59a899c9e2bf36.tar.gz
opie-9e685cedc4425dd5ae60170e3f59a899c9e2bf36.tar.bz2
- improve scan function using the wireless extensions.
- fix bug in setSSID(). Major parts of this patch are courtesy Skyhusker - thanks!
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.h25
-rw-r--r--libopie2/opienet/onetwork.cpp203
-rw-r--r--libopie2/opienet/onetwork.h8
-rw-r--r--libopie2/opienet/opienet.pro2
-rw-r--r--libopie2/opienet/ostation.h5
5 files changed, 212 insertions, 31 deletions
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index f1d34a0..32f5355 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -1,196 +1,215 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
13     ._= =}       : 12     ._= =}       :
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29 28
30*/ 29*/
31 30
32#ifndef ONETUTILS_H 31#ifndef ONETUTILS_H
33#define ONETUTILS_H 32#define ONETUTILS_H
34 33
35#include <qdict.h> 34#include <qdict.h>
36#include <qmap.h> 35#include <qmap.h>
37#include <qstring.h> 36#include <qstring.h>
38#include <qhostaddress.h> 37#include <qhostaddress.h>
39#include <qobject.h> 38#include <qobject.h>
40 39
41#include <sys/types.h> 40#include <sys/types.h>
42 41
43struct ifreq; 42struct ifreq;
44 43
45namespace Opie { 44namespace Opie {
46namespace Net { 45namespace Net {
47 46
48class OWirelessNetworkInterface; 47class OWirelessNetworkInterface;
49 48
50/*====================================================================================== 49/*======================================================================================
51 * OMacAddress 50 * OMacAddress
52 *======================================================================================*/ 51 *======================================================================================*/
53 52
54class OMacAddress 53class OMacAddress
55{ 54{
56 public: 55 public:
57 // QString c'tor? -zecke 56 // QString c'tor? -zecke
58 OMacAddress(); 57 OMacAddress();
59 OMacAddress( unsigned char* ); 58 OMacAddress( unsigned char* );
60 OMacAddress( const unsigned char* ); 59 OMacAddress( const unsigned char* );
61 OMacAddress( struct ifreq& ); 60 OMacAddress( struct ifreq& );
62 ~OMacAddress(); 61 ~OMacAddress();
63 62
64 QString manufacturer() const; 63 QString manufacturer() const;
65 QString toString( bool substitute = false ) const; 64 QString toString( bool substitute = false ) const;
66 const unsigned char* native() const; 65 const unsigned char* native() const;
67 66
68 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? 67 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
69 static OMacAddress fromString( const QString& ); 68 static OMacAddress fromString( const QString& );
70 69
71 public: 70 public:
72 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff 71 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
73 static const OMacAddress& unknown; // 44:44:44:44:44:44 72 static const OMacAddress& unknown; // 44:44:44:44:44:44
74 73
75 private: 74 private:
76 unsigned char _bytes[6]; 75 unsigned char _bytes[6];
77 76
78 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 77 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 class Private; 78 class Private;
80 Private *d; 79 Private *d;
81 80
82}; 81};
83 82
84bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 83bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
85 84
86 85
87/*====================================================================================== 86/*======================================================================================
88 * OHostAddress 87 * OHostAddress
89 *======================================================================================*/ 88 *======================================================================================*/
90 89
91class OHostAddress : public QHostAddress 90class OHostAddress : public QHostAddress
92{ 91{
93 /*public: 92 /*public:
94 OHostAddress(); 93 OHostAddress();
95 ~OHostAddress(); 94 ~OHostAddress();
96 */ 95 */
97 private: 96 private:
98 class Private; 97 class Private;
99 Private *d; 98 Private *d;
100}; 99};
101 100
102 101
103/*====================================================================================== 102/*======================================================================================
104 * OPrivateIOCTL 103 * OPrivateIOCTL
105 *======================================================================================*/ 104 *======================================================================================*/
106 105
107class OPrivateIOCTL : public QObject 106class OPrivateIOCTL : public QObject
108{ 107{
109 public: 108 public:
110 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); 109 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
111 ~OPrivateIOCTL(); 110 ~OPrivateIOCTL();
112 111
113 int numberGetArgs() const; 112 int numberGetArgs() const;
114 int typeGetArgs() const; 113 int typeGetArgs() const;
115 int numberSetArgs() const; 114 int numberSetArgs() const;
116 int typeSetArgs() const; 115 int typeSetArgs() const;
117 116
118 // FIXME return int? as ::ioctl does? -zecke 117 // FIXME return int? as ::ioctl does? -zecke
119 void invoke() const; 118 void invoke() const;
120 void setParameter( int, u_int32_t ); 119 void setParameter( int, u_int32_t );
121 120
122 private: 121 private:
123 u_int32_t _ioctl; 122 u_int32_t _ioctl;
124 u_int16_t _getargs; 123 u_int16_t _getargs;
125 u_int16_t _setargs; 124 u_int16_t _setargs;
126 125
127 class Private; 126 class Private;
128 Private *d; 127 Private *d;
129}; 128};
130 129
131 /*====================================================================================== 130 /*======================================================================================
132 * Miscellaneous 131 * Miscellaneous
133 *======================================================================================*/ 132 *======================================================================================*/
134 133
135namespace Internal { 134namespace Internal {
136void dumpBytes( const unsigned char* data, int num ); 135void dumpBytes( const unsigned char* data, int num );
137QString modeToString( int ); 136QString modeToString( int );
138int stringToMode( const QString& ); 137int stringToMode( const QString& );
139} 138}
140} 139}
141} 140}
142 141
143#define IW_PRIV_TYPE_MASK 0x7000 142#define IW_PRIV_TYPE_MASK 0x7000
144#define IW_PRIV_TYPE_NONE 0x0000 143#define IW_PRIV_TYPE_NONE 0x0000
145#define IW_PRIV_TYPE_BYTE 0x1000 144#define IW_PRIV_TYPE_BYTE 0x1000
146#define IW_PRIV_TYPE_CHAR 0x2000 145#define IW_PRIV_TYPE_CHAR 0x2000
147#define IW_PRIV_TYPE_INT 0x4000 146#define IW_PRIV_TYPE_INT 0x4000
148#define IW_PRIV_TYPE_FLOAT 0x5000 147#define IW_PRIV_TYPE_FLOAT 0x5000
149#define IW_PRIV_TYPE_ADDR 0x6000 148#define IW_PRIV_TYPE_ADDR 0x6000
150#define IW_PRIV_SIZE_FIXED 0x0800 149#define IW_PRIV_SIZE_FIXED 0x0800
151#define IW_PRIV_SIZE_MASK 0x07FF 150#define IW_PRIV_SIZE_MASK 0x07FF
152 151
152#define IW_HEADER_TYPE_NULL 0 /* Not available */
153#define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */
154#define IW_HEADER_TYPE_UINT 4 /* __u32 */
155#define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */
156#define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */
157#define IW_HEADER_TYPE_POINT 8 /* struct iw_point */
158#define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */
159#define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */
160
161#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
162 (char *) NULL)
163
153#ifndef ARPHRD_IEEE80211 164#ifndef ARPHRD_IEEE80211
154#define ARPHRD_IEEE80211 801 165#define ARPHRD_IEEE80211 801
155#endif 166#endif
156#ifndef ARPHRD_IEEE80211_PRISM 167#ifndef ARPHRD_IEEE80211_PRISM
157#define ARPHRD_IEEE80211_PRISM 802 168#define ARPHRD_IEEE80211_PRISM 802
158#endif 169#endif
159 170
171/* Wireless Extension Scanning Stuff */
172struct iw_stream_descr
173{
174 char * end; /* End of the stream */
175 char * current; /* Current event in stream of events */
176 char * value; /* Current value in event */
177};
178
160 179
161/* Network to host order macros */ 180/* Network to host order macros */
162 181
163#ifdef LBL_ALIGN 182#ifdef LBL_ALIGN
164#define EXTRACT_16BITS(p) \ 183#define EXTRACT_16BITS(p) \
165 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ 184 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
166 (u_int16_t)*((const u_int8_t *)(p) + 1))) 185 (u_int16_t)*((const u_int8_t *)(p) + 1)))
167#define EXTRACT_32BITS(p) \ 186#define EXTRACT_32BITS(p) \
168 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ 187 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
169 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ 188 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
170 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ 189 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
171 (u_int32_t)*((const u_int8_t *)(p) + 3))) 190 (u_int32_t)*((const u_int8_t *)(p) + 3)))
172#else 191#else
173#define EXTRACT_16BITS(p) \ 192#define EXTRACT_16BITS(p) \
174 ((u_int16_t)ntohs(*(const u_int16_t *)(p))) 193 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
175#define EXTRACT_32BITS(p) \ 194#define EXTRACT_32BITS(p) \
176 ((u_int32_t)ntohl(*(const u_int32_t *)(p))) 195 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
177#endif 196#endif
178 197
179#define EXTRACT_24BITS(p) \ 198#define EXTRACT_24BITS(p) \
180 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ 199 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
181 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 200 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
182 (u_int32_t)*((const u_int8_t *)(p) + 2))) 201 (u_int32_t)*((const u_int8_t *)(p) + 2)))
183 202
184/* Little endian protocol host order macros */ 203/* Little endian protocol host order macros */
185#define EXTRACT_LE_8BITS(p) (*(p)) 204#define EXTRACT_LE_8BITS(p) (*(p))
186#define EXTRACT_LE_16BITS(p) \ 205#define EXTRACT_LE_16BITS(p) \
187 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ 206 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
188 (u_int16_t)*((const u_int8_t *)(p) + 0))) 207 (u_int16_t)*((const u_int8_t *)(p) + 0)))
189#define EXTRACT_LE_32BITS(p) \ 208#define EXTRACT_LE_32BITS(p) \
190 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ 209 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
191 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ 210 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
192 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 211 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
193 (u_int32_t)*((const u_int8_t *)(p) + 0))) 212 (u_int32_t)*((const u_int8_t *)(p) + 0)))
194 213
195#endif // ONETUTILS_H 214#endif // ONETUTILS_H
196 215
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index ae1865d..546be9e 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,189 +1,188 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer 3              Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. <mickey@Vanille.de> 4 =.
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; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
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/* OPIE */ 31/* OPIE */
32 32
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/ostation.h> 34#include <opie2/ostation.h>
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37/* QT */ 37/* QT */
38 38
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41 41
42/* UNIX */ 42/* UNIX */
43 43
44#include <assert.h> 44#include <assert.h>
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <errno.h> 46#include <errno.h>
47#include <string.h> 47#include <string.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h> 54#include <linux/sockios.h>
55#include <net/if_arp.h> 55#include <net/if_arp.h>
56#include <stdarg.h> 56#include <stdarg.h>
57 57
58#ifndef NODEBUG 58#ifndef NODEBUG
59#include <opie2/odebugmapper.h> 59#include <opie2/odebugmapper.h>
60 60
61
62using namespace Opie::Core; 61using namespace Opie::Core;
63using namespace Opie::Net::Internal; 62using namespace Opie::Net::Internal;
64DebugMapper* debugmapper = new DebugMapper(); 63DebugMapper* debugmapper = new DebugMapper();
65#endif 64#endif
66 65
67/*====================================================================================== 66/*======================================================================================
68 * ONetwork 67 * ONetwork
69 *======================================================================================*/ 68 *======================================================================================*/
70 69
71namespace Opie { 70namespace Opie {
72namespace Net { 71namespace Net {
73ONetwork* ONetwork::_instance = 0; 72ONetwork* ONetwork::_instance = 0;
74 73
75ONetwork::ONetwork() 74ONetwork::ONetwork()
76{ 75{
77 odebug << "ONetwork::ONetwork()" << oendl; 76 odebug << "ONetwork::ONetwork()" << oendl;
78 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; 77 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
79 synchronize(); 78 synchronize();
80} 79}
81 80
82void ONetwork::synchronize() 81void ONetwork::synchronize()
83{ 82{
84 // gather available interfaces by inspecting /proc/net/dev 83 // gather available interfaces by inspecting /proc/net/dev
85 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 84 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
86 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 85 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
87 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 86 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
88 87
89 _interfaces.clear(); 88 _interfaces.clear();
90 QString str; 89 QString str;
91 QFile f( "/proc/net/dev" ); 90 QFile f( "/proc/net/dev" );
92 bool hasFile = f.open( IO_ReadOnly ); 91 bool hasFile = f.open( IO_ReadOnly );
93 if ( !hasFile ) 92 if ( !hasFile )
94 { 93 {
95 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; 94 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
96 return; 95 return;
97 } 96 }
98 QTextStream s( &f ); 97 QTextStream s( &f );
99 s.readLine(); 98 s.readLine();
100 s.readLine(); 99 s.readLine();
101 while ( !s.atEnd() ) 100 while ( !s.atEnd() )
102 { 101 {
103 s >> str; 102 s >> str;
104 str.truncate( str.find( ':' ) ); 103 str.truncate( str.find( ':' ) );
105 odebug << "ONetwork: found interface '" << str << "'" << oendl; 104 odebug << "ONetwork: found interface '" << str << "'" << oendl;
106 ONetworkInterface* iface = 0; 105 ONetworkInterface* iface = 0;
107 if ( isWirelessInterface( str ) ) 106 if ( isWirelessInterface( str ) )
108 { 107 {
109 iface = new OWirelessNetworkInterface( this, (const char*) str ); 108 iface = new OWirelessNetworkInterface( this, (const char*) str );
110 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; 109 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
111 } 110 }
112 else 111 else
113 { 112 {
114 iface = new ONetworkInterface( this, (const char*) str ); 113 iface = new ONetworkInterface( this, (const char*) str );
115 } 114 }
116 _interfaces.insert( str, iface ); 115 _interfaces.insert( str, iface );
117 s.readLine(); 116 s.readLine();
118 } 117 }
119} 118}
120 119
121 120
122short ONetwork::wirelessExtensionCompileVersion() 121short ONetwork::wirelessExtensionCompileVersion()
123{ 122{
124 return WIRELESS_EXT; 123 return WIRELESS_EXT;
125} 124}
126 125
127 126
128int ONetwork::count() const 127int ONetwork::count() const
129{ 128{
130 return _interfaces.count(); 129 return _interfaces.count();
131} 130}
132 131
133 132
134ONetworkInterface* ONetwork::interface( const QString& iface ) const 133ONetworkInterface* ONetwork::interface( const QString& iface ) const
135{ 134{
136 return _interfaces[iface]; 135 return _interfaces[iface];
137} 136}
138 137
139 138
140ONetwork* ONetwork::instance() 139ONetwork* ONetwork::instance()
141{ 140{
142 if ( !_instance ) _instance = new ONetwork(); 141 if ( !_instance ) _instance = new ONetwork();
143 return _instance; 142 return _instance;
144} 143}
145 144
146 145
147ONetwork::InterfaceIterator ONetwork::iterator() const 146ONetwork::InterfaceIterator ONetwork::iterator() const
148{ 147{
149 return ONetwork::InterfaceIterator( _interfaces ); 148 return ONetwork::InterfaceIterator( _interfaces );
150} 149}
151 150
152 151
153bool ONetwork::isPresent( const char* name ) const 152bool ONetwork::isPresent( const char* name ) const
154{ 153{
155 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 154 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
156 struct ifreq ifr; 155 struct ifreq ifr;
157 memset( &ifr, 0, sizeof( struct ifreq ) ); 156 memset( &ifr, 0, sizeof( struct ifreq ) );
158 strcpy( (char*) &ifr.ifr_name, name ); 157 strcpy( (char*) &ifr.ifr_name, name );
159 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); 158 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
160 return result != -1; 159 return result != -1;
161} 160}
162 161
163 162
164bool ONetwork::isWirelessInterface( const char* name ) const 163bool ONetwork::isWirelessInterface( const char* name ) const
165{ 164{
166 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 165 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
167 struct iwreq iwr; 166 struct iwreq iwr;
168 memset( &iwr, 0, sizeof( struct iwreq ) ); 167 memset( &iwr, 0, sizeof( struct iwreq ) );
169 strcpy( (char*) &iwr.ifr_name, name ); 168 strcpy( (char*) &iwr.ifr_name, name );
170 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 169 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
171 return result != -1; 170 return result != -1;
172} 171}
173 172
174/*====================================================================================== 173/*======================================================================================
175 * ONetworkInterface 174 * ONetworkInterface
176 *======================================================================================*/ 175 *======================================================================================*/
177 176
178ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) 177ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
179 :QObject( parent, name ), 178 :QObject( parent, name ),
180 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 179 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
181{ 180{
182 odebug << "ONetworkInterface::ONetworkInterface()" << oendl; 181 odebug << "ONetworkInterface::ONetworkInterface()" << oendl;
183 init(); 182 init();
184} 183}
185 184
186 185
187struct ifreq& ONetworkInterface::ifr() const 186struct ifreq& ONetworkInterface::ifr() const
188{ 187{
189 return _ifr; 188 return _ifr;
@@ -740,385 +739,547 @@ void OWirelessNetworkInterface::setMode( const QString& newMode )
740 } 739 }
741 else // special iwpriv fallback for monitor mode 740 else // special iwpriv fallback for monitor mode
742 { 741 {
743 if ( wioctl( SIOCSIWMODE ) ) 742 if ( wioctl( SIOCSIWMODE ) )
744 { 743 {
745 odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; 744 odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl;
746 } 745 }
747 else 746 else
748 { 747 {
749 odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; 748 odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl;
750 749
751 if ( _mon ) 750 if ( _mon )
752 _mon->setEnabled( true ); 751 _mon->setEnabled( true );
753 else 752 else
754 odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; 753 odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl;
755 } 754 }
756 } 755 }
757} 756}
758 757
759 758
760QString OWirelessNetworkInterface::mode() const 759QString OWirelessNetworkInterface::mode() const
761{ 760{
762 memset( &_iwr, 0, sizeof( struct iwreq ) ); 761 memset( &_iwr, 0, sizeof( struct iwreq ) );
763 762
764 if ( !wioctl( SIOCGIWMODE ) ) 763 if ( !wioctl( SIOCGIWMODE ) )
765 { 764 {
766 return "<unknown>"; 765 return "<unknown>";
767 } 766 }
768 767
769 odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; 768 odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl;
770 769
771 // legacy compatible monitor mode check 770 // legacy compatible monitor mode check
772 771
773 if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) 772 if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 )
774 { 773 {
775 return "monitor"; 774 return "monitor";
776 } 775 }
777 else 776 else
778 { 777 {
779 return modeToString( _iwr.u.mode ); 778 return modeToString( _iwr.u.mode );
780 } 779 }
781} 780}
782 781
783void OWirelessNetworkInterface::setNickName( const QString& nickname ) 782void OWirelessNetworkInterface::setNickName( const QString& nickname )
784{ 783{
785 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); 784 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname );
786 _iwr.u.essid.length = nickname.length(); 785 _iwr.u.essid.length = nickname.length();
787 wioctl( SIOCSIWNICKN ); 786 wioctl( SIOCSIWNICKN );
788} 787}
789 788
790 789
791QString OWirelessNetworkInterface::nickName() const 790QString OWirelessNetworkInterface::nickName() const
792{ 791{
793 char str[IW_ESSID_MAX_SIZE]; 792 char str[IW_ESSID_MAX_SIZE];
794 _iwr.u.data.pointer = &str[0]; 793 _iwr.u.data.pointer = &str[0];
795 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 794 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
796 if ( !wioctl( SIOCGIWNICKN ) ) 795 if ( !wioctl( SIOCGIWNICKN ) )
797 { 796 {
798 return "<unknown>"; 797 return "<unknown>";
799 } 798 }
800 else 799 else
801 { 800 {
802 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 801 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
803 return str; 802 return str;
804 } 803 }
805} 804}
806 805
807 806
808void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) 807void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
809{ 808{
810 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 809 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
811 if ( !priv ) 810 if ( !priv )
812 { 811 {
813 owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() 812 owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name()
814 << "' does not support private ioctl '" << call << "'" << oendl; 813 << "' does not support private ioctl '" << call << "'" << oendl;
815 return; 814 return;
816 } 815 }
817 if ( priv->numberSetArgs() != numargs ) 816 if ( priv->numberSetArgs() != numargs )
818 { 817 {
819 owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" 818 owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '"
820 << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; 819 << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl;
821 return; 820 return;
822 } 821 }
823 822
824 odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; 823 odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl;
825 memset( &_iwr, 0, sizeof _iwr ); 824 memset( &_iwr, 0, sizeof _iwr );
826 va_list argp; 825 va_list argp;
827 va_start( argp, numargs ); 826 va_start( argp, numargs );
828 for ( int i = 0; i < numargs; ++i ) 827 for ( int i = 0; i < numargs; ++i )
829 { 828 {
830 priv->setParameter( i, va_arg( argp, int ) ); 829 priv->setParameter( i, va_arg( argp, int ) );
831 } 830 }
832 va_end( argp ); 831 va_end( argp );
833 priv->invoke(); 832 priv->invoke();
834} 833}
835 834
836 835
837void OWirelessNetworkInterface::getPrivate( const QString& ) 836void OWirelessNetworkInterface::getPrivate( const QString& )
838{ 837{
839 oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; 838 oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl;
840} 839}
841 840
842 841
843bool OWirelessNetworkInterface::hasPrivate( const QString& call ) 842bool OWirelessNetworkInterface::hasPrivate( const QString& call )
844{ 843{
845 return child( call.local8Bit() ); 844 return child( call.local8Bit() );
846} 845}
847 846
848 847
849QString OWirelessNetworkInterface::SSID() const 848QString OWirelessNetworkInterface::SSID() const
850{ 849{
851 char str[IW_ESSID_MAX_SIZE]; 850 char str[IW_ESSID_MAX_SIZE];
852 _iwr.u.essid.pointer = &str[0]; 851 _iwr.u.essid.pointer = &str[0];
853 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 852 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
854 if ( !wioctl( SIOCGIWESSID ) ) 853 if ( !wioctl( SIOCGIWESSID ) )
855 { 854 {
856 return "<unknown>"; 855 return "<unknown>";
857 } 856 }
858 else 857 else
859 { 858 {
860 return str; 859 return str;
861 } 860 }
862} 861}
863 862
864 863
865void OWirelessNetworkInterface::setSSID( const QString& ssid ) 864void OWirelessNetworkInterface::setSSID( const QString& ssid )
866{ 865{
867 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 866 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
868 _iwr.u.essid.length = ssid.length(); 867 _iwr.u.essid.length = ssid.length()+1; // zero byte
869 wioctl( SIOCSIWESSID ); 868 wioctl( SIOCSIWESSID );
870} 869}
871 870
872 871
873OStationList* OWirelessNetworkInterface::scanNetwork() 872OStationList* OWirelessNetworkInterface::scanNetwork()
874{ 873{
875 _iwr.u.param.flags = IW_SCAN_DEFAULT; 874 _iwr.u.param.flags = IW_SCAN_DEFAULT;
876 _iwr.u.param.value = 0; 875 _iwr.u.param.value = 0;
877 if ( !wioctl( SIOCSIWSCAN ) ) 876 if ( !wioctl( SIOCSIWSCAN ) )
878 { 877 {
879 return 0; 878 return 0;
880 } 879 }
881 880
882 OStationList* stations = new OStationList(); 881 OStationList* stations = new OStationList();
883 882
884 int timeout = 1000000; 883 int timeout = 10000000;
885 884
886 odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; 885 odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl;
887 886
888 bool results = false; 887 bool results = false;
889 struct timeval tv; 888 struct timeval tv;
890 tv.tv_sec = 0; 889 tv.tv_sec = 0;
891 tv.tv_usec = 250000; // initial timeout ~ 250ms 890 tv.tv_usec = 250000; // initial timeout ~ 250ms
892 char buffer[IW_SCAN_MAX_DATA]; 891 char buffer[IW_SCAN_MAX_DATA];
893 892
894 while ( !results && timeout > 0 ) 893 while ( !results && timeout > 0 )
895 { 894 {
896 timeout -= tv.tv_usec; 895 timeout -= tv.tv_usec;
897 select( 0, 0, 0, 0, &tv ); 896 select( 0, 0, 0, 0, &tv );
898 897
899 _iwr.u.data.pointer = &buffer[0]; 898 _iwr.u.data.pointer = &buffer[0];
900 _iwr.u.data.flags = 0; 899 _iwr.u.data.flags = 0;
901 _iwr.u.data.length = sizeof buffer; 900 _iwr.u.data.length = sizeof buffer;
902 if ( wioctl( SIOCGIWSCAN ) ) 901 if ( wioctl( SIOCGIWSCAN ) )
903 { 902 {
904 results = true; 903 results = true;
905 continue; 904 continue;
906 } 905 }
907 else if ( errno == EAGAIN) 906 else if ( errno == EAGAIN)
908 { 907 {
909 odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; 908 odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl;
910 #if 0 909 #if 0
911 if ( qApp ) 910 if ( qApp )
912 { 911 {
913 qApp->processEvents( 100 ); 912 qApp->processEvents( 100 );
914 continue; 913 continue;
915 } 914 }
916 #endif 915 #endif
917 tv.tv_sec = 0; 916 tv.tv_sec = 0;
918 tv.tv_usec = 100000; 917 tv.tv_usec = 100000;
919 continue; 918 continue;
920 } 919 }
921 } 920 }
922 921
923 odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; 922 odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl;
924 923
925 if ( results ) 924 if ( results )
926 { 925 {
927 odebug << " - result length = " << _iwr.u.data.length << oendl; 926 odebug << " - result length = " << _iwr.u.data.length << oendl;
928 if ( !_iwr.u.data.length ) 927 if ( !_iwr.u.data.length )
929 { 928 {
930 odebug << " - no results (empty neighbourhood)" << oendl; 929 odebug << " - no results (empty neighbourhood)" << oendl;
931 return stations; 930 return stations;
932 } 931 }
933 932
934 odebug << " - results are in!" << oendl; 933 odebug << " - results are in!" << oendl;
935 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); 934 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
936 935
937 // parse results 936 // parse results
937 struct iw_event iwe;
938 struct iw_stream_descr stream;
939 unsigned int cmd_index, event_type, event_len;
940 char *pointer;
941
942 const char standard_ioctl_hdr[] = {
943 IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */
944 IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */
945 IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */
946 IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */
947 IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */
948 IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */
949 IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */
950 IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */
951 IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */
952 IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */
953 IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */
954 IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */
955 IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */
956 IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */
957 IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */
958 IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */
959 IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */
960 IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */
961 IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */
962 IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */
963 IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */
964 IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */
965 IW_HEADER_TYPE_NULL, /* -- hole -- */
966 IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */
967 IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */
968 IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */
969 IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */
970 IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */
971 IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */
972 IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */
973 IW_HEADER_TYPE_NULL, /* -- hole -- */
974 IW_HEADER_TYPE_NULL, /* -- hole -- */
975 IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */
976 IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */
977 IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */
978 IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */
979 IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */
980 IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */
981 IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */
982 IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */
983 IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */
984 IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */
985 IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */
986 IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */
987 IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */
988 IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */
989 };
990
991 const char standard_event_hdr[] = {
992 IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */
993 IW_HEADER_TYPE_QUAL, /* IWEVQUAL */
994 IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */
995 IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */
996 IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */
997 IW_HEADER_TYPE_POINT, /* IWEVGENIE */
998 IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */
999 IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */
1000 IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */
1001 IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */
1002 };
1003
1004
1005 const int event_type_size[] = {
1006 IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */
1007 0,
1008 IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */
1009 0,
1010 IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */
1011 IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */
1012 IW_EV_ADDR_LEN, /* IW_HEADER_TYPE_ADDR */
1013 0,
1014 IW_EV_POINT_LEN, /* Without variable payload */
1015 IW_EV_PARAM_LEN, /* IW_HEADER_TYPE_PARAM */
1016 IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */
1017 };
1018
1019
1020 //Initialize the stream
1021 memset( &stream, 0, sizeof(struct iw_stream_descr) );
1022 stream.current = buffer;
1023 stream.end = buffer + _iwr.u.data.length;
1024
1025 do
1026 {
1027 if ((stream.current + IW_EV_LCP_LEN) > stream.end)
1028 break;
1029 memcpy((char *) &iwe, stream.current, IW_EV_LCP_LEN);
938 1030
939 int offset = 0; 1031 if (iwe.len <= IW_EV_LCP_LEN) //If yes, it is an invalid event
940 struct iw_event* we = (struct iw_event*) &buffer[0]; 1032 break;
1033 if (iwe.cmd <= SIOCIWLAST) {
1034 cmd_index = iwe.cmd - SIOCIWFIRST;
941 1035
942 while ( offset < _iwr.u.data.length ) 1036 if(cmd_index < sizeof(standard_ioctl_hdr))
943 { 1037 event_type = standard_ioctl_hdr[cmd_index];
944 //const char* cmd = *(*_ioctlmap)[we->cmd]; 1038 }
945 //if ( !cmd ) cmd = "<unknown>"; 1039 else {
1040 cmd_index = iwe.cmd - IWEVFIRST;
1041
1042 if(cmd_index < sizeof(standard_event_hdr))
1043 event_type = standard_event_hdr[cmd_index];
1044 }
1045
1046 /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */
1047 event_len = event_type_size[event_type];
1048
1049 /* Fixup for later version of WE */
1050 if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT))
1051 event_len -= IW_EV_POINT_OFF;
1052
1053 /* Check if we know about this event */
1054 if(event_len <= IW_EV_LCP_LEN) {
1055 /* Skip to next event */
1056 stream.current += iwe.len;
1057 continue;
1058 }
1059
1060 event_len -= IW_EV_LCP_LEN;
1061
1062 /* Set pointer on data */
1063 if(stream.value != NULL)
1064 pointer = stream.value; /* Next value in event */
1065 else
1066 pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */
1067
1068 if((pointer + event_len) > stream.end) {
1069 /* Go to next event */
1070 stream.current += iwe.len;
1071 break;
1072 }
1073
1074 /* Fixup for later version of WE */
1075 if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT))
1076 memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len);
1077 else
1078 memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len);
1079
1080 /* Skip event in the stream */
1081 pointer += event_len;
1082
1083 /* Special processing for iw_point events */
1084 if(event_type == IW_HEADER_TYPE_POINT) {
1085 /* Check the length of the payload */
1086
1087 if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0)
1088 /* Set pointer on variable part (warning : non aligned) */
1089 iwe.u.data.pointer = pointer;
1090 else
1091 /* No data */
1092 iwe.u.data.pointer = NULL;
1093 /* Go to next event */
1094 stream.current += iwe.len;
1095 }
1096
1097 else {
1098 /* Is there more value in the event ? */
1099 if((pointer + event_len) <= (stream.current + iwe.len))
1100 /* Go to next value */
1101 stream.value = pointer;
1102 else {
1103 /* Go to next event */
1104 stream.value = NULL;
1105 stream.current += iwe.len;
1106 }
1107 }
1108
1109 struct iw_event *we = &iwe;
1110 //------
946 odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; 1111 odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl;
947 switch (we->cmd) 1112 switch (we->cmd)
948 { 1113 {
949 case SIOCGIWAP: 1114 case SIOCGIWAP:
950 { 1115 {
951 odebug << "SIOCGIWAP" << oendl; 1116 odebug << "SIOCGIWAP" << oendl;
952 stations->append( new OStation() ); 1117 stations->append( new OStation() );
953 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; 1118 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
954 break; 1119 break;
955 } 1120 }
956 case SIOCGIWMODE: 1121 case SIOCGIWMODE:
957 { 1122 {
958 odebug << "SIOCGIWMODE" << oendl; 1123 odebug << "SIOCGIWMODE" << oendl;
959 stations->last()->type = modeToString( we->u.mode ); 1124 stations->last()->type = modeToString( we->u.mode );
960 break; 1125 break;
961 } 1126 }
962 case SIOCGIWFREQ: 1127 case SIOCGIWFREQ:
963 { 1128 {
964 odebug << "SIOCGIWFREQ" << oendl; 1129 odebug << "SIOCGIWFREQ" << oendl;
965 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; 1130 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
966 break; 1131 break;
967 } 1132 }
968 case SIOCGIWESSID: 1133 case SIOCGIWESSID:
969 { 1134 {
970 odebug << "SIOCGIWESSID" << oendl; 1135 odebug << "SIOCGIWESSID" << oendl;
971 stations->last()->ssid = static_cast<const char*>( we->u.essid.pointer ); 1136 we->u.essid.length = '\0'; // make sure it is zero terminated
1137 stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer);
1138 odebug << "ESSID: " << stations->last()->ssid << oendl;
972 break; 1139 break;
973 } 1140 }
974 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; 1141 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break;
975 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; 1142 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break;
976 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ 1143 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */
977 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ 1144 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */
978 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ 1145 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */
979 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ 1146 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */
980 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ 1147 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */
981 default: odebug << "unhandled event" << oendl; 1148 default: odebug << "unhandled event" << oendl;
982 } 1149 }
983 1150
984 offset += we->len; 1151 } while (true);
985 we = (struct iw_event*) &buffer[offset];
986 }
987 return stations;
988
989 return stations;
990
991 } 1152 }
992 else 1153 else
993 { 1154 {
994 odebug << " - no results (timeout) :(" << oendl; 1155 odebug << " - no results (timeout) :(" << oendl;
995 return stations;
996 } 1156 }
1157 return stations;
997} 1158}
998 1159
999 1160
1000int OWirelessNetworkInterface::signalStrength() const 1161int OWirelessNetworkInterface::signalStrength() const
1001{ 1162{
1002 iw_statistics stat; 1163 iw_statistics stat;
1003 ::memset( &stat, 0, sizeof stat ); 1164 ::memset( &stat, 0, sizeof stat );
1004 _iwr.u.data.pointer = (char*) &stat; 1165 _iwr.u.data.pointer = (char*) &stat;
1005 _iwr.u.data.flags = 0; 1166 _iwr.u.data.flags = 0;
1006 _iwr.u.data.length = sizeof stat; 1167 _iwr.u.data.length = sizeof stat;
1007 1168
1008 if ( !wioctl( SIOCGIWSTATS ) ) 1169 if ( !wioctl( SIOCGIWSTATS ) )
1009 { 1170 {
1010 return -1; 1171 return -1;
1011 } 1172 }
1012 1173
1013 int max = _range.max_qual.qual; 1174 int max = _range.max_qual.qual;
1014 int cur = stat.qual.qual; 1175 int cur = stat.qual.qual;
1015// int lev = stat.qual.level; //FIXME: Do something with them? 1176// int lev = stat.qual.level; //FIXME: Do something with them?
1016// int noi = stat.qual.noise; //FIXME: Do something with them? 1177// int noi = stat.qual.noise; //FIXME: Do something with them?
1017 1178
1018 1179
1019 return max != 0 ? cur*100/max: -1; 1180 return max != 0 ? cur*100/max: -1;
1020} 1181}
1021 1182
1022 1183
1023bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 1184bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
1024{ 1185{
1025 #ifndef NODEBUG 1186 #ifndef NODEBUG
1026 int result = ::ioctl( _sfd, call, &iwreq ); 1187 int result = ::ioctl( _sfd, call, &iwreq );
1027 1188
1028 if ( result == -1 ) 1189 if ( result == -1 )
1029 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 1190 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
1030 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; 1191 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
1031 else 1192 else
1032 odebug << "ONetworkInterface::wioctl (" << name() << ") call '" 1193 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
1033 << debugmapper->map( call ) << "' - Status: Ok." << oendl; 1194 << debugmapper->map( call ) << "' - Status: Ok." << oendl;
1034 1195
1035 return ( result != -1 ); 1196 return ( result != -1 );
1036 #else 1197 #else
1037 return ::ioctl( _sfd, call, &iwreq ) != -1; 1198 return ::ioctl( _sfd, call, &iwreq ) != -1;
1038 #endif 1199 #endif
1039} 1200}
1040 1201
1041 1202
1042bool OWirelessNetworkInterface::wioctl( int call ) const 1203bool OWirelessNetworkInterface::wioctl( int call ) const
1043{ 1204{
1044 strcpy( _iwr.ifr_name, name() ); 1205 strcpy( _iwr.ifr_name, name() );
1045 return wioctl( call, _iwr ); 1206 return wioctl( call, _iwr );
1046} 1207}
1047 1208
1048 1209
1049/*====================================================================================== 1210/*======================================================================================
1050 * OMonitoringInterface 1211 * OMonitoringInterface
1051 *======================================================================================*/ 1212 *======================================================================================*/
1052 1213
1053OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1214OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1054 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 1215 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
1055{ 1216{
1056} 1217}
1057 1218
1058 1219
1059OMonitoringInterface::~OMonitoringInterface() 1220OMonitoringInterface::~OMonitoringInterface()
1060{ 1221{
1061} 1222}
1062 1223
1063 1224
1064void OMonitoringInterface::setChannel( int c ) 1225void OMonitoringInterface::setChannel( int c )
1065{ 1226{
1066 // use standard WE channel switching protocol 1227 // use standard WE channel switching protocol
1067 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1228 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
1068 _if->_iwr.u.freq.m = c; 1229 _if->_iwr.u.freq.m = c;
1069 _if->_iwr.u.freq.e = 0; 1230 _if->_iwr.u.freq.e = 0;
1070 _if->wioctl( SIOCSIWFREQ ); 1231 _if->wioctl( SIOCSIWFREQ );
1071} 1232}
1072 1233
1073 1234
1074void OMonitoringInterface::setEnabled( bool ) 1235void OMonitoringInterface::setEnabled( bool )
1075{ 1236{
1076} 1237}
1077 1238
1078 1239
1079/*====================================================================================== 1240/*======================================================================================
1080 * OCiscoMonitoringInterface 1241 * OCiscoMonitoringInterface
1081 *======================================================================================*/ 1242 *======================================================================================*/
1082 1243
1083OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1244OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1084 :OMonitoringInterface( iface, prismHeader ) 1245 :OMonitoringInterface( iface, prismHeader )
1085{ 1246{
1086 iface->setMonitoring( this ); 1247 iface->setMonitoring( this );
1087} 1248}
1088 1249
1089 1250
1090OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1251OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
1091{ 1252{
1092} 1253}
1093 1254
1094 1255
1095void OCiscoMonitoringInterface::setEnabled( bool /*b*/ ) 1256void OCiscoMonitoringInterface::setEnabled( bool /*b*/ )
1096{ 1257{
1097 QString fname; 1258 QString fname;
1098 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 1259 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
1099 QFile f( fname ); 1260 QFile f( fname );
1100 if ( !f.exists() ) return; 1261 if ( !f.exists() ) return;
1101 1262
1102 if ( f.open( IO_WriteOnly ) ) 1263 if ( f.open( IO_WriteOnly ) )
1103 { 1264 {
1104 QTextStream s( &f ); 1265 QTextStream s( &f );
1105 s << "Mode: r"; 1266 s << "Mode: r";
1106 s << "Mode: y"; 1267 s << "Mode: y";
1107 s << "XmitPower: 1"; 1268 s << "XmitPower: 1";
1108 } 1269 }
1109 1270
1110 // flushing and closing will be done automatically when f goes out of scope 1271 // flushing and closing will be done automatically when f goes out of scope
1111} 1272}
1112 1273
1113 1274
1114QString OCiscoMonitoringInterface::name() const 1275QString OCiscoMonitoringInterface::name() const
1115{ 1276{
1116 return "cisco"; 1277 return "cisco";
1117} 1278}
1118 1279
1119 1280
1120void OCiscoMonitoringInterface::setChannel( int ) 1281void OCiscoMonitoringInterface::setChannel( int )
1121{ 1282{
1122 // cisco devices automatically switch channels when in monitor mode 1283 // cisco devices automatically switch channels when in monitor mode
1123} 1284}
1124 1285
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index be4bb46..4d9912d 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,174 +1,174 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer 3              Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. <mickey@Vanille.de> 4 =.
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; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
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/* OPIE */ 34/* OPIE */
35#include <opie2/onetutils.h> 35#include <opie2/onetutils.h>
36#include <opie2/ostation.h> 36#include <opie2/ostation.h>
37 37
38/* QT */ 38/* QT */
39#include <qvaluelist.h> 39#include <qvaluelist.h>
40#include <qdict.h> 40#include <qdict.h>
41#include <qmap.h> 41#include <qmap.h>
42#include <qobject.h> 42#include <qobject.h>
43#include <qhostaddress.h> 43#include <qhostaddress.h>
44 44
45/* STD */ 45/* STD */
46// hacky workaround until we have a user space wireless.h 46// hacky workarounds until we have a true user space wireless.h
47#include <net/if.h> 47#include <net/if.h>
48#define _LINUX_IF_H 48#define _LINUX_IF_H
49#include <linux/wireless.h> 49#include <linux/wireless.h>
50#ifndef IW_MAX_PRIV_DEF 50#ifndef IW_MAX_PRIV_DEF
51#define IW_MAX_PRIV_DEF 128 51#define IW_MAX_PRIV_DEF 128
52#endif 52#endif
53 53
54namespace Opie { 54namespace Opie {
55namespace Net { 55namespace Net {
56class ONetworkInterface; 56class ONetworkInterface;
57class OWirelessNetworkInterface; 57class OWirelessNetworkInterface;
58class OChannelHopper; 58class OChannelHopper;
59class OMonitoringInterface; 59class OMonitoringInterface;
60 60
61/*====================================================================================== 61/*======================================================================================
62 * ONetwork 62 * ONetwork
63 *======================================================================================*/ 63 *======================================================================================*/
64 64
65/** 65/**
66 * @brief A container class for all network interfaces 66 * @brief A container class for all network interfaces
67 * 67 *
68 * This class provides access to all available network interfaces of your computer. 68 * This class provides access to all available network interfaces of your computer.
69 * 69 *
70 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 70 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
71 */ 71 */
72class ONetwork : public QObject 72class ONetwork : public QObject
73{ 73{
74 Q_OBJECT 74 Q_OBJECT
75 75
76 public: 76 public:
77 typedef QDict<ONetworkInterface> InterfaceMap; 77 typedef QDict<ONetworkInterface> InterfaceMap;
78 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 78 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
79 79
80 public: 80 public:
81 /** 81 /**
82 * @returns the number of available interfaces 82 * @returns the number of available interfaces
83 */ 83 */
84 int count() const; 84 int count() const;
85 /** 85 /**
86 * @returns a pointer to the (one and only) @ref ONetwork instance. 86 * @returns a pointer to the (one and only) @ref ONetwork instance.
87 */ 87 */
88 static ONetwork* instance(); 88 static ONetwork* instance();
89 /** 89 /**
90 * @returns an iterator usable for iterating through all network interfaces. 90 * @returns an iterator usable for iterating through all network interfaces.
91 */ 91 */
92 InterfaceIterator iterator() const; 92 InterfaceIterator iterator() const;
93 /** 93 /**
94 * @returns true, if the @a interface is present. 94 * @returns true, if the @a interface is present.
95 */ 95 */
96 bool isPresent( const char* interface ) const; 96 bool isPresent( const char* interface ) const;
97 /** 97 /**
98 * @returns true, if the @a interface supports the wireless extension protocol. 98 * @returns true, if the @a interface supports the wireless extension protocol.
99 */ 99 */
100 bool isWirelessInterface( const char* interface ) const; 100 bool isWirelessInterface( const char* interface ) const;
101 /** 101 /**
102 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 102 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
103 * @see ONetworkInterface 103 * @see ONetworkInterface
104 */ 104 */
105 ONetworkInterface* interface( const QString& interface ) const; 105 ONetworkInterface* interface( const QString& interface ) const;
106 /** 106 /**
107 * @internal Rebuild the internal interface database 107 * @internal Rebuild the internal interface database
108 * @note Sometimes it might be useful to call this from client code, 108 * @note Sometimes it might be useful to call this from client code,
109 * e.g. after issuing a cardctl insert 109 * e.g. after issuing a cardctl insert
110 */ 110 */
111 void synchronize(); 111 void synchronize();
112 /** 112 /**
113 * @returns the wireless extension version used at compile time. 113 * @returns the wireless extension version used at compile time.
114 **/ 114 **/
115 static short wirelessExtensionCompileVersion(); 115 static short wirelessExtensionCompileVersion();
116 116
117 protected: 117 protected:
118 ONetwork(); 118 ONetwork();
119 119
120 private: 120 private:
121 static ONetwork* _instance; 121 static ONetwork* _instance;
122 InterfaceMap _interfaces; 122 InterfaceMap _interfaces;
123 class Private; 123 class Private;
124 Private *d; 124 Private *d;
125}; 125};
126 126
127 127
128/*====================================================================================== 128/*======================================================================================
129 * ONetworkInterface 129 * ONetworkInterface
130 *======================================================================================*/ 130 *======================================================================================*/
131 131
132/** 132/**
133 * @brief A network interface wrapper. 133 * @brief A network interface wrapper.
134 * 134 *
135 * This class provides a wrapper for a network interface. All the cumbersume details of 135 * This class provides a wrapper for a network interface. All the cumbersume details of
136 * Linux ioctls are hidden under a convenient high-level interface. 136 * Linux ioctls are hidden under a convenient high-level interface.
137 * @warning Most of the setting methods contained in this class require the appropriate 137 * @warning Most of the setting methods contained in this class require the appropriate
138 * process permissions to work. 138 * process permissions to work.
139 * 139 *
140 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 140 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
141 */ 141 */
142class ONetworkInterface : public QObject 142class ONetworkInterface : public QObject
143{ 143{
144 friend class OMonitoringInterface; 144 friend class OMonitoringInterface;
145 friend class OCiscoMonitoringInterface; 145 friend class OCiscoMonitoringInterface;
146 friend class OWlanNGMonitoringInterface; 146 friend class OWlanNGMonitoringInterface;
147 friend class OHostAPMonitoringInterface; 147 friend class OHostAPMonitoringInterface;
148 friend class OOrinocoMonitoringInterface; 148 friend class OOrinocoMonitoringInterface;
149 149
150 public: 150 public:
151 /** 151 /**
152 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 152 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
153 * but access them via @ref ONetwork::interface(). 153 * but access them via @ref ONetwork::interface().
154 */ 154 */
155 ONetworkInterface( QObject* parent, const char* name ); 155 ONetworkInterface( QObject* parent, const char* name );
156 /** 156 /**
157 * Destructor. 157 * Destructor.
158 */ 158 */
159 virtual ~ONetworkInterface(); 159 virtual ~ONetworkInterface();
160 /** 160 /**
161 * Associates a @a monitoring interface with this network interface. 161 * Associates a @a monitoring interface with this network interface.
162 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 162 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
163 */ 163 */
164 void setMonitoring( OMonitoringInterface* monitoring ); 164 void setMonitoring( OMonitoringInterface* monitoring );
165 /** 165 /**
166 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 166 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
167 */ 167 */
168 OMonitoringInterface* monitoring() const; 168 OMonitoringInterface* monitoring() const;
169 /** 169 /**
170 * Setting an interface to promiscuous mode enables the device to receive 170 * Setting an interface to promiscuous mode enables the device to receive
171 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 171 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
172 */ 172 */
173 bool setPromiscuousMode( bool ); 173 bool setPromiscuousMode( bool );
174 /** 174 /**
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro
index 98fa175..a10a949 100644
--- a/libopie2/opienet/opienet.pro
+++ b/libopie2/opienet/opienet.pro
@@ -1,40 +1,40 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = 802_11_user.h \ 4HEADERS = 802_11_user.h \
5 dhcp.h \ 5 dhcp.h \
6 udp_ports.h \ 6 udp_ports.h \
7 odebugmapper.h \ 7 odebugmapper.h \
8 omanufacturerdb.h \ 8 omanufacturerdb.h \
9 onetutils.h \ 9 onetutils.h \
10 onetwork.h \ 10 onetwork.h \
11 opcap.h \ 11 opcap.h \
12 ostation.h 12 ostation.h
13SOURCES = odebugmapper.cpp \ 13SOURCES = odebugmapper.cpp \
14 omanufacturerdb.cpp \ 14 omanufacturerdb.cpp \
15 onetutils.cpp \ 15 onetutils.cpp \
16 onetwork.cpp \ 16 onetwork.cpp \
17 opcap.cpp \ 17 opcap.cpp \
18 ostation.cpp 18 ostation.cpp
19INTERFACES = 19INTERFACES =
20TARGET = opienet2 20TARGET = opienet2
21VERSION = 1.8.4 21VERSION = 1.8.5
22INCLUDEPATH += $(OPIEDIR)/include 22INCLUDEPATH += $(OPIEDIR)/include
23DEPENDPATH += $(OPIEDIR)/include 23DEPENDPATH += $(OPIEDIR)/include
24LIBS += -lpcap 24LIBS += -lpcap
25 25
26 26
27!contains( platform, x11 ) { 27!contains( platform, x11 ) {
28 include( $(OPIEDIR)/include.pro ) 28 include( $(OPIEDIR)/include.pro )
29} 29}
30 30
31contains( platform, x11 ) { 31contains( platform, x11 ) {
32 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 32 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
33} 33}
34 34
35!isEmpty( LIBPCAP_INC_DIR ) { 35!isEmpty( LIBPCAP_INC_DIR ) {
36 INCLUDEPATH = $$LIBPCAP_INC_DIR $$INCLUDEPATH 36 INCLUDEPATH = $$LIBPCAP_INC_DIR $$INCLUDEPATH
37} 37}
38!isEmpty( LIBPCAP_LIB_DIR ) { 38!isEmpty( LIBPCAP_LIB_DIR ) {
39 LIBS = -L$$LIBPCAP_LIB_DIR $$LIBS 39 LIBS = -L$$LIBPCAP_LIB_DIR $$LIBS
40} 40}
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h
index bdc653f..5219d92 100644
--- a/libopie2/opienet/ostation.h
+++ b/libopie2/opienet/ostation.h
@@ -1,82 +1,83 @@
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-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. 4 =.
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; version 2 of the License. 11 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : 12     ._= =}       :
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 OSTATION_H 31#ifndef OSTATION_H
32#define OSTATION_H 32#define OSTATION_H
33 33
34#include <opie2/onetutils.h> 34#include <opie2/onetutils.h>
35 35
36#include <qlist.h> 36#include <qlist.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43namespace Opie { 43namespace Opie {
44namespace Net { 44namespace Net {
45 45
46class OStation; 46class OStation;
47 47
48 48
49typedef QList<OStation> OStationList; 49typedef QList<OStation> OStationList;
50 50
51/*====================================================================================== 51/*======================================================================================
52 * OStation 52 * OStation
53 *======================================================================================*/ 53 *======================================================================================*/
54 54
55class OStation 55class OStation
56{ 56{
57 public: 57 public:
58 OStation(); 58 OStation();
59 ~OStation(); 59 ~OStation();
60 60
61 void dump(); 61 void dump();
62 62
63 /* Ethernet */ 63 /* Ethernet */
64 QString type; 64 QString type;
65 OMacAddress macAddress; 65 OMacAddress macAddress;
66 QHostAddress ipAddress; 66 QHostAddress ipAddress;
67 67
68 /* WaveLan */ 68 /* WaveLan */
69 QString ssid; 69 QString ssid;
70 OMacAddress apAddress; 70 OMacAddress apAddress;
71 int channel; 71 int channel;
72 int level;
72 bool encrypted; 73 bool encrypted;
73 private: 74 private:
74 class Private; 75 class Private;
75 Private *d; 76 Private *d;
76}; 77};
77 78
78} 79}
79} 80}
80 81
81#endif // OSTATION_H 82#endif // OSTATION_H
82 83