author | mickeyl <mickeyl> | 2004-08-09 13:30:13 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-08-09 13:30:13 (UTC) |
commit | a0527fcaa0b530df47f654333b2c9476d3072022 (patch) (unidiff) | |
tree | d1ae514ed31af4642b477a01f260adaf1a1a9a7c | |
parent | 0784cfdbd261c43856b45be6ab7439841e69b858 (diff) | |
download | opie-a0527fcaa0b530df47f654333b2c9476d3072022.zip opie-a0527fcaa0b530df47f654333b2c9476d3072022.tar.gz opie-a0527fcaa0b530df47f654333b2c9476d3072022.tar.bz2 |
- adjust headers
- kill a warning
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 6 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.h | 6 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 2 |
3 files changed, 5 insertions, 9 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index 209ec94..3003e12 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp | |||
@@ -1,142 +1,140 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 12 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 20 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
28 | |||
29 | */ | 27 | */ |
30 | 28 | ||
31 | #include "omanufacturerdb.h" | 29 | #include "omanufacturerdb.h" |
32 | 30 | ||
33 | #define OPIE_IMPROVE_GUI_LATENCY 1 | 31 | #define OPIE_IMPROVE_GUI_LATENCY 1 |
34 | 32 | ||
35 | /* OPIE */ | 33 | /* OPIE */ |
36 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
37 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 35 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
38 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
39 | #endif | 37 | #endif |
40 | 38 | ||
41 | /* QT */ | 39 | /* QT */ |
42 | #include <qapplication.h> | 40 | #include <qapplication.h> |
43 | #include <qfile.h> | 41 | #include <qfile.h> |
44 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
45 | 43 | ||
46 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
47 | namespace Opie { | 45 | namespace Opie { |
48 | namespace Net { | 46 | namespace Net { |
49 | 47 | ||
50 | OManufacturerDB* OManufacturerDB::_instance = 0; | 48 | OManufacturerDB* OManufacturerDB::_instance = 0; |
51 | 49 | ||
52 | OManufacturerDB* OManufacturerDB::instance() | 50 | OManufacturerDB* OManufacturerDB::instance() |
53 | { | 51 | { |
54 | if ( !OManufacturerDB::_instance ) | 52 | if ( !OManufacturerDB::_instance ) |
55 | { | 53 | { |
56 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; | 54 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; |
57 | _instance = new OManufacturerDB(); | 55 | _instance = new OManufacturerDB(); |
58 | } | 56 | } |
59 | return _instance; | 57 | return _instance; |
60 | } | 58 | } |
61 | 59 | ||
62 | 60 | ||
63 | OManufacturerDB::OManufacturerDB() | 61 | OManufacturerDB::OManufacturerDB() |
64 | { | 62 | { |
65 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 63 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
66 | Global::statusMessage( "Reading Manufacturers..." ); | 64 | Global::statusMessage( "Reading Manufacturers..." ); |
67 | #endif | 65 | #endif |
68 | QString filename( "/etc/manufacturers" ); | 66 | QString filename( "/etc/manufacturers" ); |
69 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 67 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
70 | if ( !QFile::exists( filename ) ) | 68 | if ( !QFile::exists( filename ) ) |
71 | { | 69 | { |
72 | filename = "/opt/QtPalmtop/etc/manufacturers"; | 70 | filename = "/opt/QtPalmtop/etc/manufacturers"; |
73 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 71 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
74 | if ( !QFile::exists( filename ) ) | 72 | if ( !QFile::exists( filename ) ) |
75 | { | 73 | { |
76 | filename = "/usr/share/wellenreiter/manufacturers"; | 74 | filename = "/usr/share/wellenreiter/manufacturers"; |
77 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 75 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
78 | } | 76 | } |
79 | } | 77 | } |
80 | 78 | ||
81 | QFile file( filename ); | 79 | QFile file( filename ); |
82 | bool hasFile = file.open( IO_ReadOnly ); | 80 | bool hasFile = file.open( IO_ReadOnly ); |
83 | if (!hasFile) | 81 | if (!hasFile) |
84 | { | 82 | { |
85 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; | 83 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; |
86 | } | 84 | } |
87 | else | 85 | else |
88 | { | 86 | { |
89 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; | 87 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; |
90 | QTextStream s( &file ); | 88 | QTextStream s( &file ); |
91 | QString addr; | 89 | QString addr; |
92 | QString manu; | 90 | QString manu; |
93 | QString extManu; | 91 | QString extManu; |
94 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 92 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
95 | int counter = 0; | 93 | int counter = 0; |
96 | #endif | 94 | #endif |
97 | while (!s.atEnd()) | 95 | while (!s.atEnd()) |
98 | { | 96 | { |
99 | s >> addr; | 97 | s >> addr; |
100 | s >> manu; | 98 | s >> manu; |
101 | s >> extManu; | 99 | s >> extManu; |
102 | 100 | ||
103 | manufacturers.insert( addr, manu ); | 101 | manufacturers.insert( addr, manu ); |
104 | manufacturersExt.insert( addr, extManu ); | 102 | manufacturersExt.insert( addr, extManu ); |
105 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; | 103 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; |
106 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 104 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
107 | counter++; | 105 | counter++; |
108 | if ( counter == 50 ) | 106 | if ( counter == 50 ) |
109 | { | 107 | { |
110 | qApp->processEvents(); | 108 | qApp->processEvents(); |
111 | counter = 0; | 109 | counter = 0; |
112 | } | 110 | } |
113 | #endif | 111 | #endif |
114 | } | 112 | } |
115 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; | 113 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; |
116 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 114 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
117 | Global::statusMessage( "Manufacturers Complete..." ); | 115 | Global::statusMessage( "Manufacturers Complete..." ); |
118 | #endif | 116 | #endif |
119 | } | 117 | } |
120 | } | 118 | } |
121 | 119 | ||
122 | 120 | ||
123 | OManufacturerDB::~OManufacturerDB() | 121 | OManufacturerDB::~OManufacturerDB() |
124 | { | 122 | { |
125 | } | 123 | } |
126 | 124 | ||
127 | 125 | ||
128 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const | 126 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const |
129 | { | 127 | { |
130 | return manufacturers[macaddr.upper().left(8)]; | 128 | return manufacturers[macaddr.upper().left(8)]; |
131 | } | 129 | } |
132 | 130 | ||
133 | 131 | ||
134 | const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const | 132 | const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const |
135 | { | 133 | { |
136 | QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); | 134 | QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); |
137 | return it == manufacturersExt.end() ? lookup( macaddr ) : *it; | 135 | return it == manufacturersExt.end() ? lookup( macaddr ) : *it; |
138 | } | 136 | } |
139 | 137 | ||
140 | } | 138 | } |
141 | } | 139 | } |
142 | 140 | ||
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h index 5c1940e..c667e20 100644 --- a/libopie2/opienet/omanufacturerdb.h +++ b/libopie2/opienet/omanufacturerdb.h | |||
@@ -1,77 +1,75 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 12 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 20 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
28 | |||
29 | */ | 27 | */ |
30 | 28 | ||
31 | #ifndef OMANUFACTURERDB_H | 29 | #ifndef OMANUFACTURERDB_H |
32 | #define OMANUFACTURERDB_H | 30 | #define OMANUFACTURERDB_H |
33 | 31 | ||
34 | #include <qmap.h> | 32 | #include <qmap.h> |
35 | 33 | ||
36 | namespace Opie { | 34 | namespace Opie { |
37 | namespace Net { | 35 | namespace Net { |
38 | 36 | ||
39 | /** | 37 | /** |
40 | * @brief A Ethernet card vendor database. | 38 | * @brief A Ethernet card vendor database. |
41 | * | 39 | * |
42 | * This class encapsulates the lookup of Ethernet vendor given a | 40 | * This class encapsulates the lookup of Ethernet vendor given a |
43 | * certain Mac Address. Only the first three bytes define the vendor. | 41 | * certain Mac Address. Only the first three bytes define the vendor. |
44 | */ | 42 | */ |
45 | class OManufacturerDB | 43 | class OManufacturerDB |
46 | { | 44 | { |
47 | public: | 45 | public: |
48 | /** | 46 | /** |
49 | * @returns the one-and-only @ref OManufacturerDB instance. | 47 | * @returns the one-and-only @ref OManufacturerDB instance. |
50 | */ | 48 | */ |
51 | static OManufacturerDB* instance(); | 49 | static OManufacturerDB* instance(); |
52 | /** | 50 | /** |
53 | * @returns the short manufacturer string given a @a macaddr. | 51 | * @returns the short manufacturer string given a @a macaddr. |
54 | */ | 52 | */ |
55 | const QString& lookup( const QString& macaddr ) const; | 53 | const QString& lookup( const QString& macaddr ) const; |
56 | /** | 54 | /** |
57 | * @returns the enhanced manufacturer string given a @a macaddr. | 55 | * @returns the enhanced manufacturer string given a @a macaddr. |
58 | */ | 56 | */ |
59 | const QString& lookupExt( const QString& macaddr ) const; | 57 | const QString& lookupExt( const QString& macaddr ) const; |
60 | 58 | ||
61 | protected: | 59 | protected: |
62 | OManufacturerDB(); | 60 | OManufacturerDB(); |
63 | virtual ~OManufacturerDB(); | 61 | virtual ~OManufacturerDB(); |
64 | 62 | ||
65 | private: | 63 | private: |
66 | QMap<QString, QString> manufacturers; | 64 | QMap<QString, QString> manufacturers; |
67 | QMap<QString, QString> manufacturersExt; | 65 | QMap<QString, QString> manufacturersExt; |
68 | static OManufacturerDB* _instance; | 66 | static OManufacturerDB* _instance; |
69 | class Private; | 67 | class Private; |
70 | Private *d; | 68 | Private *d; |
71 | }; | 69 | }; |
72 | 70 | ||
73 | } | 71 | } |
74 | } | 72 | } |
75 | 73 | ||
76 | #endif | 74 | #endif |
77 | 75 | ||
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index c185805..047a704 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp | |||
@@ -1,241 +1,241 @@ | |||
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@Vanille.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.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 | #include <assert.h> | 37 | #include <assert.h> |
38 | #include <stdio.h> | 38 | #include <stdio.h> |
39 | 39 | ||
40 | namespace Opie { | 40 | namespace Opie { |
41 | namespace Net { | 41 | namespace Net { |
42 | 42 | ||
43 | /*====================================================================================== | 43 | /*====================================================================================== |
44 | * OMacAddress | 44 | * OMacAddress |
45 | *======================================================================================*/ | 45 | *======================================================================================*/ |
46 | 46 | ||
47 | // static initializer for broadcast and unknown MAC Adresses | 47 | // static initializer for broadcast and unknown MAC Adresses |
48 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 48 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
49 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); | 49 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); |
50 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; | 50 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; |
51 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); | 51 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); |
52 | 52 | ||
53 | //TODO: Incorporate Ethernet Manufacturer database here! (inline or so) | 53 | //TODO: Incorporate Ethernet Manufacturer database here! (inline or so) |
54 | 54 | ||
55 | OMacAddress::OMacAddress() | 55 | OMacAddress::OMacAddress() |
56 | { | 56 | { |
57 | memcpy( _bytes, __unknown, 6 ); | 57 | memcpy( _bytes, __unknown, 6 ); |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | OMacAddress::OMacAddress( unsigned char* p ) | 61 | OMacAddress::OMacAddress( unsigned char* p ) |
62 | { | 62 | { |
63 | memcpy( _bytes, p, 6 ); | 63 | memcpy( _bytes, p, 6 ); |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | OMacAddress::OMacAddress( const unsigned char* p ) | 67 | OMacAddress::OMacAddress( const unsigned char* p ) |
68 | { | 68 | { |
69 | memcpy( _bytes, p, 6 ); | 69 | memcpy( _bytes, p, 6 ); |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | OMacAddress::OMacAddress( struct ifreq& ifr ) | 73 | OMacAddress::OMacAddress( struct ifreq& ifr ) |
74 | { | 74 | { |
75 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); | 75 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | OMacAddress::~OMacAddress() | 79 | OMacAddress::~OMacAddress() |
80 | { | 80 | { |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | //#ifdef QT_NO_DEBUG | 84 | //#ifdef QT_NO_DEBUG |
85 | //inline | 85 | //inline |
86 | //#endif | 86 | //#endif |
87 | const unsigned char* OMacAddress::native() const | 87 | const unsigned char* OMacAddress::native() const |
88 | { | 88 | { |
89 | return (const unsigned char*) &_bytes; | 89 | return (const unsigned char*) &_bytes; |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | OMacAddress OMacAddress::fromString( const QString& str ) | 93 | OMacAddress OMacAddress::fromString( const QString& str ) |
94 | { | 94 | { |
95 | QString addr( str ); | 95 | QString addr( str ); |
96 | unsigned char buf[6]; | 96 | unsigned char buf[6]; |
97 | bool ok = true; | 97 | bool ok = true; |
98 | int index = 14; | 98 | int index = 14; |
99 | for ( int i = 5; i >= 0; --i ) | 99 | for ( int i = 5; i >= 0; --i ) |
100 | { | 100 | { |
101 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); | 101 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); |
102 | if ( !ok ) return OMacAddress::unknown; | 102 | if ( !ok ) return OMacAddress::unknown; |
103 | addr.truncate( index ); | 103 | addr.truncate( index ); |
104 | index -= 3; | 104 | index -= 3; |
105 | } | 105 | } |
106 | return (const unsigned char*) &buf; | 106 | return (const unsigned char*) &buf; |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | QString OMacAddress::toString( bool substitute ) const | 110 | QString OMacAddress::toString( bool substitute ) const |
111 | { | 111 | { |
112 | QString manu; | 112 | QString manu; |
113 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); | 113 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); |
114 | QString serial; | 114 | QString serial; |
115 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); | 115 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); |
116 | if ( !substitute ) return manu+serial; | 116 | if ( !substitute ) return manu+serial; |
117 | // fallback - if no vendor is found, just use the number | 117 | // fallback - if no vendor is found, just use the number |
118 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); | 118 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); |
119 | return textmanu.isNull() ? manu+serial : textmanu+serial; | 119 | return textmanu.isNull() ? manu+serial : textmanu+serial; |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | QString OMacAddress::manufacturer() const | 123 | QString OMacAddress::manufacturer() const |
124 | { | 124 | { |
125 | return OManufacturerDB::instance()->lookupExt( toString() ); | 125 | return OManufacturerDB::instance()->lookupExt( toString() ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) | 129 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) |
130 | { | 130 | { |
131 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; | 131 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | /*====================================================================================== | 135 | /*====================================================================================== |
136 | * OHostAddress | 136 | * OHostAddress |
137 | *======================================================================================*/ | 137 | *======================================================================================*/ |
138 | 138 | ||
139 | 139 | ||
140 | /*====================================================================================== | 140 | /*====================================================================================== |
141 | * OPrivateIOCTL | 141 | * OPrivateIOCTL |
142 | *======================================================================================*/ | 142 | *======================================================================================*/ |
143 | 143 | ||
144 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) | 144 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) |
145 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) | 145 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) |
146 | { | 146 | { |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | OPrivateIOCTL::~OPrivateIOCTL() | 150 | OPrivateIOCTL::~OPrivateIOCTL() |
151 | { | 151 | { |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | int OPrivateIOCTL::numberGetArgs() const | 155 | int OPrivateIOCTL::numberGetArgs() const |
156 | { | 156 | { |
157 | return _getargs & IW_PRIV_SIZE_MASK; | 157 | return _getargs & IW_PRIV_SIZE_MASK; |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | int OPrivateIOCTL::typeGetArgs() const | 161 | int OPrivateIOCTL::typeGetArgs() const |
162 | { | 162 | { |
163 | return _getargs & IW_PRIV_TYPE_MASK >> 12; | 163 | return _getargs & IW_PRIV_TYPE_MASK >> 12; |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | int OPrivateIOCTL::numberSetArgs() const | 167 | int OPrivateIOCTL::numberSetArgs() const |
168 | { | 168 | { |
169 | return _setargs & IW_PRIV_SIZE_MASK; | 169 | return _setargs & IW_PRIV_SIZE_MASK; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | int OPrivateIOCTL::typeSetArgs() const | 173 | int OPrivateIOCTL::typeSetArgs() const |
174 | { | 174 | { |
175 | return _setargs & IW_PRIV_TYPE_MASK >> 12; | 175 | return _setargs & IW_PRIV_TYPE_MASK >> 12; |
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||
179 | void OPrivateIOCTL::invoke() const | 179 | void OPrivateIOCTL::invoke() const |
180 | { | 180 | { |
181 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); | 181 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) | 185 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) |
186 | { | 186 | { |
187 | 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; |
188 | arglist[num] = value; | 188 | arglist[num] = value; |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | 192 | ||
193 | namespace Internal { | 193 | namespace Internal { |
194 | /*====================================================================================== | 194 | /*====================================================================================== |
195 | * assorted functions | 195 | * assorted functions |
196 | *======================================================================================*/ | 196 | *======================================================================================*/ |
197 | 197 | ||
198 | void dumpBytes( const unsigned char* data, int num ) | 198 | void dumpBytes( const unsigned char* data, int num ) |
199 | { | 199 | { |
200 | printf( "Dumping %d bytes @ %0x", num, data ); | 200 | printf( "Dumping %d bytes @ 0x%p", num, data ); |
201 | printf( "-------------------------------------------\n" ); | 201 | printf( "-------------------------------------------\n" ); |
202 | 202 | ||
203 | for ( int i = 0; i < num; ++i ) | 203 | for ( int i = 0; i < num; ++i ) |
204 | { | 204 | { |
205 | printf( "%02x ", data[i] ); | 205 | printf( "%02x ", data[i] ); |
206 | if ( !((i+1) % 32) ) printf( "\n" ); | 206 | if ( !((i+1) % 32) ) printf( "\n" ); |
207 | } | 207 | } |
208 | printf( "\n\n" ); | 208 | printf( "\n\n" ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | int stringToMode( const QString& mode ) | 212 | int stringToMode( const QString& mode ) |
213 | { | 213 | { |
214 | if ( mode == "auto" ) return IW_MODE_AUTO; | 214 | if ( mode == "auto" ) return IW_MODE_AUTO; |
215 | else if ( mode == "adhoc" ) return IW_MODE_ADHOC; | 215 | else if ( mode == "adhoc" ) return IW_MODE_ADHOC; |
216 | else if ( mode == "managed" ) return IW_MODE_INFRA; | 216 | else if ( mode == "managed" ) return IW_MODE_INFRA; |
217 | else if ( mode == "master" ) return IW_MODE_MASTER; | 217 | else if ( mode == "master" ) return IW_MODE_MASTER; |
218 | else if ( mode == "repeater" ) return IW_MODE_REPEAT; | 218 | else if ( mode == "repeater" ) return IW_MODE_REPEAT; |
219 | else if ( mode == "secondary" ) return IW_MODE_SECOND; | 219 | else if ( mode == "secondary" ) return IW_MODE_SECOND; |
220 | else if ( mode == "monitor" ) return IW_MODE_MONITOR; | 220 | else if ( mode == "monitor" ) return IW_MODE_MONITOR; |
221 | else assert( 0 ); | 221 | else assert( 0 ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | QString modeToString( int mode ) | 225 | QString modeToString( int mode ) |
226 | { | 226 | { |
227 | switch ( mode ) | 227 | switch ( mode ) |
228 | { | 228 | { |
229 | case IW_MODE_AUTO: return "auto"; | 229 | case IW_MODE_AUTO: return "auto"; |
230 | case IW_MODE_ADHOC: return "adhoc"; | 230 | case IW_MODE_ADHOC: return "adhoc"; |
231 | case IW_MODE_INFRA: return "managed"; | 231 | case IW_MODE_INFRA: return "managed"; |
232 | case IW_MODE_MASTER: return "master"; | 232 | case IW_MODE_MASTER: return "master"; |
233 | case IW_MODE_REPEAT: return "repeater"; | 233 | case IW_MODE_REPEAT: return "repeater"; |
234 | case IW_MODE_SECOND: return "second"; | 234 | case IW_MODE_SECOND: return "second"; |
235 | case IW_MODE_MONITOR: return "monitor"; | 235 | case IW_MODE_MONITOR: return "monitor"; |
236 | default: assert( 0 ); | 236 | default: assert( 0 ); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | } | 241 | } |