summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-01-03 18:33:43 (UTC)
committer mickeyl <mickeyl>2004-01-03 18:33:43 (UTC)
commit27b84ed363fd7fc52092e3c2d1e49dca079b7ffd (patch) (unidiff)
tree932806dc83d84720bcb259df8711d894932580e1
parent3889c8f853aa2d128f54389b17f08fc7b9150788 (diff)
downloadopie-27b84ed363fd7fc52092e3c2d1e49dca079b7ffd.zip
opie-27b84ed363fd7fc52092e3c2d1e49dca079b7ffd.tar.gz
opie-27b84ed363fd7fc52092e3c2d1e49dca079b7ffd.tar.bz2
slightly improve the speed reading the manufacturers list
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp13
-rwxr-xr-xlibopie2/tools/regen.py198
-rw-r--r--noncore/net/wellenreiter/ChangeLog9
3 files changed, 205 insertions, 15 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index 595633d..f61270b 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -73,37 +73,46 @@ OManufacturerDB::OManufacturerDB()
73 bool hasFile = file.open( IO_ReadOnly ); 73 bool hasFile = file.open( IO_ReadOnly );
74 if (!hasFile) 74 if (!hasFile)
75 { 75 {
76 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 76 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
77 } 77 }
78 else 78 else
79 { 79 {
80 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 80 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
81 QTextStream s( &file ); 81 QTextStream s( &file );
82 QString addr; 82 QString addr;
83 QString manu; 83 QString manu;
84 QString extManu; 84 QString extManu;
85 #ifdef OPIE_IMPROVE_GUI_LATENCY
86 int counter = 0;
87 #endif
85 while (!s.atEnd()) 88 while (!s.atEnd())
86 { 89 {
87 s >> addr; 90 s >> addr;
88 s >> manu; 91 s >> manu;
89 s >> extManu; 92 s >> extManu;
90 93
91 manufacturers.insert( addr, manu ); 94 manufacturers.insert( addr, manu );
92 manufacturersExt.insert( addr, extManu ); 95 manufacturersExt.insert( addr, extManu );
93 odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 96 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
94 #ifdef OPIE_IMPROVE_GUI_LATENCY 97 #ifdef OPIE_IMPROVE_GUI_LATENCY
95 if ( qApp ) qApp->processEvents(); 98 counter++;
99 if ( counter == 50 )
100 {
101 qApp->processEvents();
102 counter = 0;
103 }
96 #endif 104 #endif
97 } 105 }
106 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
98 } 107 }
99} 108}
100 109
101 110
102OManufacturerDB::~OManufacturerDB() 111OManufacturerDB::~OManufacturerDB()
103{ 112{
104} 113}
105 114
106 115
107const QString& OManufacturerDB::lookup( const QString& macaddr ) const 116const QString& OManufacturerDB::lookup( const QString& macaddr ) const
108{ 117{
109 return manufacturers[macaddr.upper().left(8)]; 118 return manufacturers[macaddr.upper().left(8)];
diff --git a/libopie2/tools/regen.py b/libopie2/tools/regen.py
index 3779896..89385e1 100755
--- a/libopie2/tools/regen.py
+++ b/libopie2/tools/regen.py
@@ -1,73 +1,78 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2 2
3# 3"""Regenerate C++ mapping classes"""
4# regenerate ioctl_table.h 4
5# 5#---------------------------------------------------------------------------#
6# #
7#---------------------------------------------------------------------------#
8
9def regenDebugMapper( basename ):
10 """
11 Debug Mapper - maps ioctl numbers to names, e.g. 0x4x5a -> SIOCGIWNAME
12 """
6 13
7import sys
8import os
9result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines() 14result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines()
10 15
11try: 16try:
12 tablehfile = file( sys.argv[1]+".h", "w" ) 17 tablehfile = file( basename+".h", "w" )
13except: 18except:
14 tablehfile = sys.stdout 19 tablehfile = sys.stdout
15 20
16try: 21try:
17 tablecfile = file( sys.argv[1]+".cpp", "w" ) 22 tablecfile = file( basename+".cpp", "w" )
18except: 23except:
19 tablecfile = sys.stdout 24 tablecfile = sys.stdout
20 25
21print >>tablehfile,""" 26print >>tablehfile,"""
22/* 27/*
23 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 28 * debug value mapper - generated by %s - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
24 */ 29 */
25 30
26#ifndef DEBUGMAPPER_H 31#ifndef DEBUGMAPPER_H
27#define DEBUGMAPPER_H 32#define DEBUGMAPPER_H
28 33
29#include <qstring.h> 34#include <qstring.h>
30#include <qintdict.h> 35#include <qintdict.h>
31 36
32typedef QIntDict<QString> IntStringMap; 37typedef QIntDict<QString> IntStringMap;
33 38
34class DebugMapper 39class DebugMapper
35{ 40{
36 public: 41 public:
37 DebugMapper(); 42 DebugMapper();
38 ~DebugMapper(); 43 ~DebugMapper();
39 44
40 const QString& map( int value ) const; 45 const QString& map( int value ) const;
41 private: 46 private:
42 IntStringMap _map; 47 IntStringMap _map;
43}; 48};
44 49
45#endif 50#endif
46""" 51""" % sys.argv[0]
47 52
48print >>tablecfile,""" 53print >>tablecfile,"""
49/* 54/*
50 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 55 * debug value mapper - generated by %s - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
51 */ 56 */
52 57
53#include <opie2/odebug.h> 58#include <opie2/odebug.h>
54 59
55#include "%s" 60#include "%s"
56 61
57DebugMapper::DebugMapper() 62DebugMapper::DebugMapper()
58{ 63{
59 odebug << "DebugMapper::DebugMapper()" << oendl; 64 odebug << "DebugMapper::DebugMapper()" << oendl;
60 65
61""" % (tablehfile.name) 66""" % ( sys.argv[0], tablehfile.name )
62 67
63for line in result: 68for line in result:
64 l = line.split() 69 l = line.split()
65 if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ): 70 if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ):
66 print >>sys.stderr, "can't parse line: %s" % l 71 print >>sys.stderr, "can't parse line: %s" % l
67 continue 72 continue
68 print >>tablecfile, " _map.insert( %s, new QString(\"%s\") );" % ( l[2], l[1] ) 73 print >>tablecfile, " _map.insert( %s, new QString(\"%s\") );" % ( l[2], l[1] )
69 74
70 75
71print >>tablecfile,""" 76print >>tablecfile,"""
72}; 77};
73 78
@@ -85,12 +90,183 @@ const QString& DebugMapper::map( int value ) const
85 if ( !result ) 90 if ( !result )
86 { 91 {
87 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl; 92 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
88 return QString::null; 93 return QString::null;
89 } 94 }
90 else 95 else
91 { 96 {
92 return *result; 97 return *result;
93 } 98 }
94} 99}
95 100
96""" 101"""
102
103#---------------------------------------------------------------------------#
104# #
105#---------------------------------------------------------------------------#
106
107def regenManufacturerDB( basename ):
108
109 try:
110 h = file( basename+".h", "w" )
111 except:
112 h = sys.stdout
113
114 try:
115 cpp = file( basename+".cpp", "w" )
116 except:
117 cpp = sys.stdout
118
119 print >>h,"""
120#ifndef OMANUFACTURERDB_H
121#define OMANUFACTURERDB_H
122
123#include <qmap.h>
124
125/**
126 * @brief A Ethernet card vendor database.
127 *
128 * This class encapsulates the lookup of Ethernet vendor given a
129 * certain Mac Address. Only the first three bytes define the vendor.
130 */
131class OManufacturerDB
132{
133 public:
134 /**
135 * @returns the one-and-only @ref OManufacturerDB instance.
136 */
137 static OManufacturerDB* instance();
138 /**
139 * @returns the short manufacturer string given a @a macaddr.
140 */
141 const QString& lookup( const QString& macaddr ) const;
142 /**
143 * @returns the enhanced manufacturer string given a @a macaddr.
144 */
145 const QString& lookupExt( const QString& macaddr ) const;
146
147 protected:
148 OManufacturerDB();
149 virtual ~OManufacturerDB();
150
151 private:
152 QMap<QString, QString> manufacturers;
153 QMap<QString, QString> manufacturersExt;
154 static OManufacturerDB* _instance;
155};
156
157#endif
158"""
159
160 print >>cpp,"""
161#include "%s.h"
162
163/* OPIE CORE */
164#include <opie2/odebug.h>
165
166/* QT */
167#include <qapplication.h>
168#include <qstring.h>
169
170#define OPIE_IMPROVE_GUI_LATENCY 1
171
172OManufacturerDB* OManufacturerDB::_instance = 0;
173
174OManufacturerDB* OManufacturerDB::instance()
175{
176 if ( !OManufacturerDB::_instance )
177 {
178 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
179 _instance = new OManufacturerDB();
180 }
181 return _instance;
182}
183
184
185OManufacturerDB::OManufacturerDB()
186{
187""" % basename
188
189 count = 0
190 for line in sys.stdin:
191 if line[0] == "#": # skip comments
192 continue
193 #print line.strip()
194 entries = line.strip().split()
195 #print "number of entries =", len( entries )
196 #print entries
197 if len( entries ) < 2:
198 continue
199 elif len( entries ) == 2:
200 count += 1
201 print "2-line detected."
202 print >>cpp, ' manufacturers.insert( "%s", "%s" );' % ( entries[0], entries[1] )
203 print >>cpp, ' manufacturersExt.insert( "%s", "%s" );' % ( entries[0], entries[1] )
204 elif len( entries ) > 2:
205 count += 1
206 print "3-line detected."
207 print >>cpp, ' manufacturers.insert( "%s", "%s" );' % ( entries[0], entries[1] )
208 print >>cpp, ' manufacturersExt.insert( "%s", "%s" );' % ( entries[0], "_".join( entries[3:] ) )
209 else:
210 assert( false )
211 if not (count % 1000):
212 print >>cpp,"""
213#ifdef OPIE_IMPROVE_GUI_LATENCY
214 if (qApp) qApp->processEvents();
215#endif
216"""
217 print "successfully parsed", count, "manufacturer lines"
218 print >>cpp,"""
219}
220
221
222OManufacturerDB::~OManufacturerDB()
223{
224}
225
226
227const QString& OManufacturerDB::lookup( const QString& macaddr ) const
228{
229 return manufacturers[macaddr.upper().left(8)];
230}
231
232
233const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
234{
235 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
236 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
237}
238"""
239
240#---------------------------------------------------------------------------#
241# #
242#---------------------------------------------------------------------------#
243
244#---------------------------------------------------------------------------#
245# #
246#---------------------------------------------------------------------------#
247
248#---------------------------------------------------------------------------#
249# #
250#---------------------------------------------------------------------------#
251
252import sys
253import os
254import copy
255
256if __name__ == "__main__":
257 if len( sys.argv ) != 3:
258 print """
259Usage: %s <table> <basename>
260
261Available tables: %s
262""" % ( sys.argv[0], [ str(k)[5:] for k in copy.copy( locals() ) if k.startswith( "regen" ) ] )
263 sys.exit( -1 )
264
265 try:
266 func = locals()["regen%s" % sys.argv[1]]
267 except KeyError:
268 print "Table '%s' unknown." % sys.argv[1]
269 sys.exit( -1 )
270 else:
271 func( sys.argv[2] )
272 sys.exit( 0 ) \ No newline at end of file
diff --git a/noncore/net/wellenreiter/ChangeLog b/noncore/net/wellenreiter/ChangeLog
index 1ce25d5..55e13fc 100644
--- a/noncore/net/wellenreiter/ChangeLog
+++ b/noncore/net/wellenreiter/ChangeLog
@@ -1,19 +1,24 @@
1 2004-??-?? Michael Lauer <mickey@Vanille.de>
2
3 * Improved the speed reading the manufacturer list
4 * GPS coordinates are now presented in the DMS (as opposed to decimal) format
5
1 2003-12-18 Michael Lauer <mickey@Vanille.de> 6 2003-12-18 Michael Lauer <mickey@Vanille.de>
2 7
3 * Released as Version 1.0.2 (Development Snapshot) 8 * Released as Version 1.0.2 (Development Snapshot)
4 * Add automatic uploading of capture files to "The Capture Dump" site at 9 * Added automatic uploading of capture files to "The Capture Dump" site at
5 http://www.Vanille.de/projects/capturedump.spy 10 http://www.Vanille.de/projects/capturedump.spy
6 * Initial reading of the manufacturer database happens now in background 11 * Initial reading of the manufacturer database happens now in background
7 * Remove deprecated setMonitorMode() API ==> Use setMode( "monitor" ) now. 12 * Removed deprecated setMonitorMode() API ==> Use setMode( "monitor" ) now.
8 The monitor mode now tries to use the standard IW_MODE_MONITOR first. If that 13 The monitor mode now tries to use the standard IW_MODE_MONITOR first. If that
9 doesn't work, it falls back to using the proprietary iwpriv commands 14 doesn't work, it falls back to using the proprietary iwpriv commands
10 15
11 2003-11-30 Michael Lauer <mickey@Vanille.de> 16 2003-11-30 Michael Lauer <mickey@Vanille.de>
12 17
13 * Released as Version 1.0.1 (Development Snapshot) 18 * Released as Version 1.0.1 (Development Snapshot)
14 * Fixed ARP decoding for wired networks. 19 * Fixed ARP decoding for wired networks.
15 Interestingly, 802.11 encapsulates these in IP packets, while wired ethernet just tags the type_of_protocol. 20 Interestingly, 802.11 encapsulates these in IP packets, while wired ethernet just tags the type_of_protocol.
16 * Added reading GPS data from a gps daemon. 21 * Added reading GPS data from a gps daemon.
17 * Started preparations for utilizing Wellenreiter II in wired networks. 22 * Started preparations for utilizing Wellenreiter II in wired networks.
18 * Implemented persistant configuration interface and retriggerable auto detection. 23 * Implemented persistant configuration interface and retriggerable auto detection.
19 * Added QCOP interface for talking to opie-networksettings. 24 * Added QCOP interface for talking to opie-networksettings.