summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetutils.cpp
Unidiff
Diffstat (limited to 'libopie2/opienet/onetutils.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 48cfa43..7794334 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -16,48 +16,51 @@
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/onetutils.h> 32#include <opie2/onetutils.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/omanufacturerdb.h> 34#include <opie2/omanufacturerdb.h>
35 35
36#include <net/if.h> 36#include <net/if.h>
37#include <assert.h> 37#include <assert.h>
38#include <stdio.h> 38#include <stdio.h>
39 39
40namespace Opie {
41namespace Net {
42
40/*====================================================================================== 43/*======================================================================================
41 * OMacAddress 44 * OMacAddress
42 *======================================================================================*/ 45 *======================================================================================*/
43 46
44// static initializer for broadcast and unknown MAC Adresses 47// static initializer for broadcast and unknown MAC Adresses
45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 48const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 49const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 50const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 51const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
49 52
50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) 53//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
51 54
52OMacAddress::OMacAddress() 55OMacAddress::OMacAddress()
53{ 56{
54 memcpy( _bytes, __unknown, 6 ); 57 memcpy( _bytes, __unknown, 6 );
55} 58}
56 59
57 60
58OMacAddress::OMacAddress( unsigned char* p ) 61OMacAddress::OMacAddress( unsigned char* p )
59{ 62{
60 memcpy( _bytes, p, 6 ); 63 memcpy( _bytes, p, 6 );
61} 64}
62 65
63 66
@@ -164,69 +167,75 @@ int OPrivateIOCTL::typeGetArgs() const
164int OPrivateIOCTL::numberSetArgs() const 167int OPrivateIOCTL::numberSetArgs() const
165{ 168{
166 return _setargs & IW_PRIV_SIZE_MASK; 169 return _setargs & IW_PRIV_SIZE_MASK;
167} 170}
168 171
169 172
170int OPrivateIOCTL::typeSetArgs() const 173int OPrivateIOCTL::typeSetArgs() const
171{ 174{
172 return _setargs & IW_PRIV_TYPE_MASK >> 12; 175 return _setargs & IW_PRIV_TYPE_MASK >> 12;
173} 176}
174 177
175 178
176void OPrivateIOCTL::invoke() const 179void OPrivateIOCTL::invoke() const
177{ 180{
178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 181 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
179} 182}
180 183
181 184
182void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 185void OPrivateIOCTL::setParameter( int num, u_int32_t value )
183{ 186{
184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 187 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
185 arglist[num] = value; 188 arglist[num] = value;
186} 189}
187 190
191
192
193namespace Private {
188/*====================================================================================== 194/*======================================================================================
189 * assorted functions 195 * assorted functions
190 *======================================================================================*/ 196 *======================================================================================*/
191 197
192void dumpBytes( const unsigned char* data, int num ) 198void dumpBytes( const unsigned char* data, int num )
193{ 199{
194 printf( "Dumping %d bytes @ %0x", num, data ); 200 printf( "Dumping %d bytes @ %0x", num, data );
195 printf( "-------------------------------------------\n" ); 201 printf( "-------------------------------------------\n" );
196 202
197 for ( int i = 0; i < num; ++i ) 203 for ( int i = 0; i < num; ++i )
198 { 204 {
199 printf( "%02x ", data[i] ); 205 printf( "%02x ", data[i] );
200 if ( !((i+1) % 32) ) printf( "\n" ); 206 if ( !((i+1) % 32) ) printf( "\n" );
201 } 207 }
202 printf( "\n\n" ); 208 printf( "\n\n" );
203} 209}
204 210
205 211
206int stringToMode( const QString& mode ) 212int stringToMode( const QString& mode )
207{ 213{
208 if ( mode == "auto" ) return IW_MODE_AUTO; 214 if ( mode == "auto" ) return IW_MODE_AUTO;
209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 215 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
210 else if ( mode == "managed" ) return IW_MODE_INFRA; 216 else if ( mode == "managed" ) return IW_MODE_INFRA;
211 else if ( mode == "master" ) return IW_MODE_MASTER; 217 else if ( mode == "master" ) return IW_MODE_MASTER;
212 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 218 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
213 else if ( mode == "secondary" ) return IW_MODE_SECOND; 219 else if ( mode == "secondary" ) return IW_MODE_SECOND;
214 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 220 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
215 else assert( 0 ); 221 else assert( 0 );
216} 222}
217 223
218 224
219QString modeToString( int mode ) 225QString modeToString( int mode )
220{ 226{
221 switch ( mode ) 227 switch ( mode )
222 { 228 {
223 case IW_MODE_AUTO: return "auto"; 229 case IW_MODE_AUTO: return "auto";
224 case IW_MODE_ADHOC: return "adhoc"; 230 case IW_MODE_ADHOC: return "adhoc";
225 case IW_MODE_INFRA: return "managed"; 231 case IW_MODE_INFRA: return "managed";
226 case IW_MODE_MASTER: return "master"; 232 case IW_MODE_MASTER: return "master";
227 case IW_MODE_REPEAT: return "repeater"; 233 case IW_MODE_REPEAT: return "repeater";
228 case IW_MODE_SECOND: return "second"; 234 case IW_MODE_SECOND: return "second";
229 case IW_MODE_MONITOR: return "monitor"; 235 case IW_MODE_MONITOR: return "monitor";
230 default: assert( 0 ); 236 default: assert( 0 );
231 } 237 }
232} 238}
239}
240}
241}