author | simon <simon> | 2003-04-20 10:19:39 (UTC) |
---|---|---|
committer | simon <simon> | 2003-04-20 10:19:39 (UTC) |
commit | b2583563a61e1ac1d9207fb3c008443a5fc7dc3c (patch) (unidiff) | |
tree | bd9543d81221f036aceed53e666ae1a43e26eb84 /libopie2/opienet | |
parent | e24ed721e823232876a266cd78cd7341675b4378 (diff) | |
download | opie-b2583563a61e1ac1d9207fb3c008443a5fc7dc3c.zip opie-b2583563a61e1ac1d9207fb3c008443a5fc7dc3c.tar.gz opie-b2583563a61e1ac1d9207fb3c008443a5fc7dc3c.tar.bz2 |
- removed those:
-#ifdef QT_NO_DEBUG
-inline
-#endif
<some method here not marked inline in the header file>
it makes little sense to inline a method in the .cpp file for non-debug
builds, apart from that it causes the method not to be emitted for
non-debug builds, causing undefined references in apps referencing them
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index 236f108..e05efc2 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp | |||
@@ -1,221 +1,209 @@ | |||
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 | #include <opie2/omanufacturerdb.h> | 34 | #include <opie2/omanufacturerdb.h> |
35 | 35 | ||
36 | #include <net/if.h> | 36 | #include <net/if.h> |
37 | 37 | ||
38 | #include <cstdio> | 38 | #include <cstdio> |
39 | using namespace std; | 39 | using namespace std; |
40 | 40 | ||
41 | #define IW_PRIV_TYPE_MASK 0x7000 | 41 | #define IW_PRIV_TYPE_MASK 0x7000 |
42 | #define IW_PRIV_TYPE_NONE 0x0000 | 42 | #define IW_PRIV_TYPE_NONE 0x0000 |
43 | #define IW_PRIV_TYPE_BYTE 0x1000 | 43 | #define IW_PRIV_TYPE_BYTE 0x1000 |
44 | #define IW_PRIV_TYPE_CHAR 0x2000 | 44 | #define IW_PRIV_TYPE_CHAR 0x2000 |
45 | #define IW_PRIV_TYPE_INT 0x4000 | 45 | #define IW_PRIV_TYPE_INT 0x4000 |
46 | #define IW_PRIV_TYPE_FLOAT 0x5000 | 46 | #define IW_PRIV_TYPE_FLOAT 0x5000 |
47 | #define IW_PRIV_TYPE_ADDR 0x6000 | 47 | #define IW_PRIV_TYPE_ADDR 0x6000 |
48 | #define IW_PRIV_SIZE_FIXED 0x0800 | 48 | #define IW_PRIV_SIZE_FIXED 0x0800 |
49 | #define IW_PRIV_SIZE_MASK 0x07FF | 49 | #define IW_PRIV_SIZE_MASK 0x07FF |
50 | 50 | ||
51 | /*====================================================================================== | 51 | /*====================================================================================== |
52 | * OMacAddress | 52 | * OMacAddress |
53 | *======================================================================================*/ | 53 | *======================================================================================*/ |
54 | 54 | ||
55 | // static initializer for broadcast and unknown MAC Adresses | 55 | // static initializer for broadcast and unknown MAC Adresses |
56 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 56 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
57 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); | 57 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); |
58 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; | 58 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; |
59 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); | 59 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); |
60 | 60 | ||
61 | 61 | ||
62 | //TODO: Incorporate Ethernet Manufacturer database here! | 62 | //TODO: Incorporate Ethernet Manufacturer database here! |
63 | 63 | ||
64 | OMacAddress::OMacAddress( unsigned char* p ) | 64 | OMacAddress::OMacAddress( unsigned char* p ) |
65 | { | 65 | { |
66 | memcpy( _bytes, p, 6 ); | 66 | memcpy( _bytes, p, 6 ); |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | OMacAddress::OMacAddress( const unsigned char* p ) | 70 | OMacAddress::OMacAddress( const unsigned char* p ) |
71 | { | 71 | { |
72 | memcpy( _bytes, p, 6 ); | 72 | memcpy( _bytes, p, 6 ); |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | OMacAddress::OMacAddress( struct ifreq& ifr ) | 76 | OMacAddress::OMacAddress( struct ifreq& ifr ) |
77 | { | 77 | { |
78 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); | 78 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | OMacAddress::~OMacAddress() | 82 | OMacAddress::~OMacAddress() |
83 | { | 83 | { |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | //#ifdef QT_NO_DEBUG | 87 | //#ifdef QT_NO_DEBUG |
88 | //inline | 88 | //inline |
89 | //#endif | 89 | //#endif |
90 | const unsigned char* OMacAddress::native() const | 90 | const unsigned char* OMacAddress::native() const |
91 | { | 91 | { |
92 | return (const unsigned char*) &_bytes; | 92 | return (const unsigned char*) &_bytes; |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | OMacAddress OMacAddress::fromString( const QString& str ) | 96 | OMacAddress OMacAddress::fromString( const QString& str ) |
97 | { | 97 | { |
98 | QString addr( str ); | 98 | QString addr( str ); |
99 | unsigned char buf[6]; | 99 | unsigned char buf[6]; |
100 | bool ok = true; | 100 | bool ok = true; |
101 | int index = 14; | 101 | int index = 14; |
102 | for ( int i = 5; i >= 0; --i ) | 102 | for ( int i = 5; i >= 0; --i ) |
103 | { | 103 | { |
104 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); | 104 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); |
105 | if ( !ok ) return OMacAddress::unknown; | 105 | if ( !ok ) return OMacAddress::unknown; |
106 | addr.truncate( index ); | 106 | addr.truncate( index ); |
107 | index -= 3; | 107 | index -= 3; |
108 | } | 108 | } |
109 | return (const unsigned char*) &buf; | 109 | return (const unsigned char*) &buf; |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | QString OMacAddress::toString( bool substitute ) const | 113 | QString OMacAddress::toString( bool substitute ) const |
114 | { | 114 | { |
115 | QString manu; | 115 | QString manu; |
116 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); | 116 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); |
117 | QString serial; | 117 | QString serial; |
118 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); | 118 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); |
119 | if ( !substitute ) return manu+serial; | 119 | if ( !substitute ) return manu+serial; |
120 | // fallback - if no vendor is found, just use the number | 120 | // fallback - if no vendor is found, just use the number |
121 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); | 121 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); |
122 | return textmanu.isNull() ? manu+serial : textmanu + serial; | 122 | return textmanu.isNull() ? manu+serial : textmanu + serial; |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | QString OMacAddress::manufacturer() const | 126 | QString OMacAddress::manufacturer() const |
127 | { | 127 | { |
128 | return OManufacturerDB::instance()->lookup( toString() ); | 128 | return OManufacturerDB::instance()->lookup( toString() ); |
129 | } | 129 | } |
130 | 130 | ||
131 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) | 131 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) |
132 | { | 132 | { |
133 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; | 133 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | /*====================================================================================== | 137 | /*====================================================================================== |
138 | * OHostAddress | 138 | * OHostAddress |
139 | *======================================================================================*/ | 139 | *======================================================================================*/ |
140 | 140 | ||
141 | 141 | ||
142 | /*====================================================================================== | 142 | /*====================================================================================== |
143 | * OPrivateIOCTL | 143 | * OPrivateIOCTL |
144 | *======================================================================================*/ | 144 | *======================================================================================*/ |
145 | 145 | ||
146 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) | 146 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) |
147 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) | 147 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) |
148 | { | 148 | { |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | OPrivateIOCTL::~OPrivateIOCTL() | 152 | OPrivateIOCTL::~OPrivateIOCTL() |
153 | { | 153 | { |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | #ifdef QT_NO_DEBUG | ||
158 | inline | ||
159 | #endif | ||
160 | int OPrivateIOCTL::numberGetArgs() const | 157 | int OPrivateIOCTL::numberGetArgs() const |
161 | { | 158 | { |
162 | return _getargs & IW_PRIV_SIZE_MASK; | 159 | return _getargs & IW_PRIV_SIZE_MASK; |
163 | } | 160 | } |
164 | 161 | ||
165 | 162 | ||
166 | #ifdef QT_NO_DEBUG | ||
167 | inline | ||
168 | #endif | ||
169 | int OPrivateIOCTL::typeGetArgs() const | 163 | int OPrivateIOCTL::typeGetArgs() const |
170 | { | 164 | { |
171 | return _getargs & IW_PRIV_TYPE_MASK >> 12; | 165 | return _getargs & IW_PRIV_TYPE_MASK >> 12; |
172 | } | 166 | } |
173 | 167 | ||
174 | 168 | ||
175 | #ifdef QT_NO_DEBUG | ||
176 | inline | ||
177 | #endif | ||
178 | int OPrivateIOCTL::numberSetArgs() const | 169 | int OPrivateIOCTL::numberSetArgs() const |
179 | { | 170 | { |
180 | return _setargs & IW_PRIV_SIZE_MASK; | 171 | return _setargs & IW_PRIV_SIZE_MASK; |
181 | } | 172 | } |
182 | 173 | ||
183 | 174 | ||
184 | #ifdef QT_NO_DEBUG | ||
185 | inline | ||
186 | #endif | ||
187 | int OPrivateIOCTL::typeSetArgs() const | 175 | int OPrivateIOCTL::typeSetArgs() const |
188 | { | 176 | { |
189 | return _setargs & IW_PRIV_TYPE_MASK >> 12; | 177 | return _setargs & IW_PRIV_TYPE_MASK >> 12; |
190 | } | 178 | } |
191 | 179 | ||
192 | 180 | ||
193 | void OPrivateIOCTL::invoke() const | 181 | void OPrivateIOCTL::invoke() const |
194 | { | 182 | { |
195 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); | 183 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); |
196 | } | 184 | } |
197 | 185 | ||
198 | 186 | ||
199 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) | 187 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) |
200 | { | 188 | { |
201 | u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; | 189 | u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; |
202 | arglist[num] = value; | 190 | arglist[num] = value; |
203 | } | 191 | } |
204 | 192 | ||
205 | /*====================================================================================== | 193 | /*====================================================================================== |
206 | * assorted functions | 194 | * assorted functions |
207 | *======================================================================================*/ | 195 | *======================================================================================*/ |
208 | 196 | ||
209 | void dumpBytes( const unsigned char* data, int num ) | 197 | void dumpBytes( const unsigned char* data, int num ) |
210 | { | 198 | { |
211 | printf( "Dumping %d bytes @ %0x", num, data ); | 199 | printf( "Dumping %d bytes @ %0x", num, data ); |
212 | printf( "-------------------------------------------\n" ); | 200 | printf( "-------------------------------------------\n" ); |
213 | 201 | ||
214 | for ( int i = 0; i < num; ++i ) | 202 | for ( int i = 0; i < num; ++i ) |
215 | { | 203 | { |
216 | printf( "%02x ", data[i] ); | 204 | printf( "%02x ", data[i] ); |
217 | if ( !((i+1) % 32) ) printf( "\n" ); | 205 | if ( !((i+1) % 32) ) printf( "\n" ); |
218 | } | 206 | } |
219 | printf( "\n\n" ); | 207 | printf( "\n\n" ); |
220 | } | 208 | } |
221 | 209 | ||