summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 0fb21ff..2485f30 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,212 +1,212 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
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 34
35#include <net/if.h> 35#include <net/if.h>
36 36
37#include <cstdio> 37#include <cstdio>
38using namespace std; 38using namespace std;
39 39
40#define IW_PRIV_TYPE_MASK 0x7000 40#define IW_PRIV_TYPE_MASK 0x7000
41#define IW_PRIV_TYPE_NONE 0x0000 41#define IW_PRIV_TYPE_NONE 0x0000
42#define IW_PRIV_TYPE_BYTE 0x1000 42#define IW_PRIV_TYPE_BYTE 0x1000
43#define IW_PRIV_TYPE_CHAR 0x2000 43#define IW_PRIV_TYPE_CHAR 0x2000
44#define IW_PRIV_TYPE_INT 0x4000 44#define IW_PRIV_TYPE_INT 0x4000
45#define IW_PRIV_TYPE_FLOAT 0x5000 45#define IW_PRIV_TYPE_FLOAT 0x5000
46#define IW_PRIV_TYPE_ADDR 0x6000 46#define IW_PRIV_TYPE_ADDR 0x6000
47#define IW_PRIV_SIZE_FIXED 0x0800 47#define IW_PRIV_SIZE_FIXED 0x0800
48#define IW_PRIV_SIZE_MASK 0x07FF 48#define IW_PRIV_SIZE_MASK 0x07FF
49 49
50/*====================================================================================== 50/*======================================================================================
51 * OMacAddress 51 * OMacAddress
52 *======================================================================================*/ 52 *======================================================================================*/
53 53
54// static initializer for broadcast and unknown MAC Adresses 54// static initializer for broadcast and unknown MAC Adresses
55const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 55const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
56const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 56const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
57const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 57const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
58const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 58const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
59 59
60 60
61//TODO: Incorporate Ethernet Manufacturer database here! 61//TODO: Incorporate Ethernet Manufacturer database here!
62 62
63OMacAddress::OMacAddress( unsigned char* p ) 63OMacAddress::OMacAddress( unsigned char* p )
64{ 64{
65 memcpy( _bytes, p, 6 ); 65 memcpy( _bytes, p, 6 );
66} 66}
67 67
68 68
69OMacAddress::OMacAddress( const unsigned char* p ) 69OMacAddress::OMacAddress( const unsigned char* p )
70{ 70{
71 memcpy( _bytes, p, 6 ); 71 memcpy( _bytes, p, 6 );
72} 72}
73 73
74 74
75OMacAddress::OMacAddress( struct ifreq& ifr ) 75OMacAddress::OMacAddress( struct ifreq& ifr )
76{ 76{
77 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 77 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
78} 78}
79 79
80 80
81OMacAddress::~OMacAddress() 81OMacAddress::~OMacAddress()
82{ 82{
83} 83}
84 84
85 85
86#ifdef QT_NO_DEBUG 86//#ifdef QT_NO_DEBUG
87inline 87//inline
88#endif 88//#endif
89const unsigned char* OMacAddress::native() const 89const unsigned char* OMacAddress::native() const
90{ 90{
91 return (const unsigned char*) &_bytes; 91 return (const unsigned char*) &_bytes;
92} 92}
93 93
94 94
95OMacAddress OMacAddress::fromString( const QString& str ) 95OMacAddress OMacAddress::fromString( const QString& str )
96{ 96{
97 QString addr( str ); 97 QString addr( str );
98 unsigned char buf[6]; 98 unsigned char buf[6];
99 bool ok = true; 99 bool ok = true;
100 int index = 14; 100 int index = 14;
101 for ( int i = 5; i >= 0; --i ) 101 for ( int i = 5; i >= 0; --i )
102 { 102 {
103 buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); 103 buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
104 if ( !ok ) return OMacAddress::unknown; 104 if ( !ok ) return OMacAddress::unknown;
105 addr.truncate( index ); 105 addr.truncate( index );
106 index -= 3; 106 index -= 3;
107 } 107 }
108 return (const unsigned char*) &buf; 108 return (const unsigned char*) &buf;
109} 109}
110 110
111 111
112QString OMacAddress::toString() const 112QString OMacAddress::toString() const
113{ 113{
114 QString s; 114 QString s;
115 s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 115 s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
116 _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff, 116 _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff,
117 _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 117 _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
118 return s; 118 return s;
119} 119}
120 120
121 121
122bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 122bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
123{ 123{
124 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 124 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
125} 125}
126 126
127 127
128/*====================================================================================== 128/*======================================================================================
129 * OHostAddress 129 * OHostAddress
130 *======================================================================================*/ 130 *======================================================================================*/
131 131
132 132
133/*====================================================================================== 133/*======================================================================================
134 * OPrivateIOCTL 134 * OPrivateIOCTL
135 *======================================================================================*/ 135 *======================================================================================*/
136 136
137OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 137OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
138 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 138 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
139{ 139{
140} 140}
141 141
142 142
143OPrivateIOCTL::~OPrivateIOCTL() 143OPrivateIOCTL::~OPrivateIOCTL()
144{ 144{
145} 145}
146 146
147 147
148#ifdef QT_NO_DEBUG 148#ifdef QT_NO_DEBUG
149inline 149inline
150#endif 150#endif
151int OPrivateIOCTL::numberGetArgs() const 151int OPrivateIOCTL::numberGetArgs() const
152{ 152{
153 return _getargs & IW_PRIV_SIZE_MASK; 153 return _getargs & IW_PRIV_SIZE_MASK;
154} 154}
155 155
156 156
157#ifdef QT_NO_DEBUG 157#ifdef QT_NO_DEBUG
158inline 158inline
159#endif 159#endif
160int OPrivateIOCTL::typeGetArgs() const 160int OPrivateIOCTL::typeGetArgs() const
161{ 161{
162 return _getargs & IW_PRIV_TYPE_MASK >> 12; 162 return _getargs & IW_PRIV_TYPE_MASK >> 12;
163} 163}
164 164
165 165
166#ifdef QT_NO_DEBUG 166#ifdef QT_NO_DEBUG
167inline 167inline
168#endif 168#endif
169int OPrivateIOCTL::numberSetArgs() const 169int OPrivateIOCTL::numberSetArgs() const
170{ 170{
171 return _setargs & IW_PRIV_SIZE_MASK; 171 return _setargs & IW_PRIV_SIZE_MASK;
172} 172}
173 173
174 174
175#ifdef QT_NO_DEBUG 175#ifdef QT_NO_DEBUG
176inline 176inline
177#endif 177#endif
178int OPrivateIOCTL::typeSetArgs() const 178int OPrivateIOCTL::typeSetArgs() const
179{ 179{
180 return _setargs & IW_PRIV_TYPE_MASK >> 12; 180 return _setargs & IW_PRIV_TYPE_MASK >> 12;
181} 181}
182 182
183 183
184void OPrivateIOCTL::invoke() const 184void OPrivateIOCTL::invoke() const
185{ 185{
186 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 186 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
187} 187}
188 188
189 189
190void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 190void OPrivateIOCTL::setParameter( int num, u_int32_t value )
191{ 191{
192 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 192 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
193 arglist[num] = value; 193 arglist[num] = value;
194} 194}
195 195
196/*====================================================================================== 196/*======================================================================================
197 * assorted functions 197 * assorted functions
198 *======================================================================================*/ 198 *======================================================================================*/
199 199
200void dumpBytes( const unsigned char* data, int num ) 200void dumpBytes( const unsigned char* data, int num )
201{ 201{
202 printf( "Dumping %d bytes @ %0x", num, data ); 202 printf( "Dumping %d bytes @ %0x", num, data );
203 printf( "-------------------------------------------\n" ); 203 printf( "-------------------------------------------\n" );
204 204
205 for ( int i = 0; i < num; ++i ) 205 for ( int i = 0; i < num; ++i )
206 { 206 {
207 printf( "%02x ", data[i] ); 207 printf( "%02x ", data[i] );
208 if ( !((i+1) % 32) ) printf( "\n" ); 208 if ( !((i+1) % 32) ) printf( "\n" );
209 } 209 }
210 printf( "\n\n" ); 210 printf( "\n\n" );
211} 211}
212 212