summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2003-05-08 17:35:05 (UTC)
committer mickeyl <mickeyl>2003-05-08 17:35:05 (UTC)
commit41ca770b8bea964ea9c5905b1df1209fe4720f89 (patch) (unidiff)
tree585b10184e6afc283055ce3f7348ae19969b5174 /libopie2
parent197cdbb5ca34517c077b69bb8517787ab1e52aeb (diff)
downloadopie-41ca770b8bea964ea9c5905b1df1209fe4720f89.zip
opie-41ca770b8bea964ea9c5905b1df1209fe4720f89.tar.gz
opie-41ca770b8bea964ea9c5905b1df1209fe4720f89.tar.bz2
- sync manufacturer list with ethereal
- fix onetworkdemo example - add API for short/extended manufacturer names
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp4
-rw-r--r--libopie2/examples/opieui/opieui.pro4
-rw-r--r--libopie2/opiecore/oapplication.cpp12
-rw-r--r--libopie2/opiecore/oapplication.h2
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp24
-rw-r--r--libopie2/opienet/omanufacturerdb.h18
-rw-r--r--libopie2/opienet/onetutils.cpp5
7 files changed, 60 insertions, 9 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
index fd68772..6326ad0 100644
--- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
+++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
@@ -1,75 +1,79 @@
1#include <opie2/onetwork.h> 1#include <opie2/onetwork.h>
2#include <opie2/omanufacturerdb.h>
2 3
3int main( int argc, char** argv ) 4int main( int argc, char** argv )
4{ 5{
5 qDebug( "OPIE Network Demo" ); 6 qDebug( "OPIE Network Demo" );
6 7
7 ONetwork* net = ONetwork::instance(); 8 ONetwork* net = ONetwork::instance();
8 9
9 ONetwork::InterfaceIterator it = net->iterator(); 10 ONetwork::InterfaceIterator it = net->iterator();
10 11
11 while ( it.current() ) 12 while ( it.current() )
12 { 13 {
13 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); 14 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() );
14 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); 15 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() );
15 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); 16 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) );
17 qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() );
18 qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) );
19 qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) );
16 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); 20 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
17 if ( it.current()->isWireless() ) 21 if ( it.current()->isWireless() )
18 { 22 {
19 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); 23 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
20 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); 24 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
21 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); 25 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
22 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); 26 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );
23 27
24 //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) 28 //if ( iface->mode() == OWirelessNetworkInterface::adhoc )
25 //{ 29 //{
26 qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); 30 qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() );
27 //} 31 //}
28 32
29 // nickname 33 // nickname
30 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); 34 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
31 iface->setNickName( "MyNickName" ); 35 iface->setNickName( "MyNickName" );
32 if ( iface->nickName() != "MyNickName" ) 36 if ( iface->nickName() != "MyNickName" )
33 qDebug( "DEMO: Warning! Can't change nickname" ); 37 qDebug( "DEMO: Warning! Can't change nickname" );
34 else 38 else
35 qDebug( "DEMO: Nickname change successful." ); 39 qDebug( "DEMO: Nickname change successful." );
36 40
37 // operation mode 41 // operation mode
38 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); 42 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() );
39 iface->setMode( "adhoc" ); 43 iface->setMode( "adhoc" );
40 if ( iface->mode() != "adhoc" ) 44 if ( iface->mode() != "adhoc" )
41 qDebug( "DEMO: Warning! Can't change operation mode" ); 45 qDebug( "DEMO: Warning! Can't change operation mode" );
42 else 46 else
43 qDebug( "DEMO: Operation Mode change successful." ); 47 qDebug( "DEMO: Operation Mode change successful." );
44 48
45 iface->setMode( "managed" ); 49 iface->setMode( "managed" );
46 50
47 /* 51 /*
48 52
49 // first some wrong calls to check if this is working 53 // first some wrong calls to check if this is working
50 iface->setPrivate( "seppel", 10 ); 54 iface->setPrivate( "seppel", 10 );
51 iface->setPrivate( "monitor", 0 ); 55 iface->setPrivate( "monitor", 0 );
52 56
53 // now the real deal 57 // now the real deal
54 iface->setPrivate( "monitor", 2, 2, 3 ); 58 iface->setPrivate( "monitor", 2, 2, 3 );
55 59
56 // trying to set hw address to 12:34:56:AB:CD:EF 60 // trying to set hw address to 12:34:56:AB:CD:EF
57 61
58 /* 62 /*
59 63
60 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); 64 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" );
61 iface->setUp( false ); 65 iface->setUp( false );
62 iface->setMacAddress( addr ); 66 iface->setMacAddress( addr );
63 iface->setUp( true ); 67 iface->setUp( true );
64 qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); 68 qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() );
65 69
66 */ 70 */
67 71
68 72
69 } 73 }
70 ++it; 74 ++it;
71 } 75 }
72 76
73 return 0; 77 return 0;
74 78
75} 79}
diff --git a/libopie2/examples/opieui/opieui.pro b/libopie2/examples/opieui/opieui.pro
index b52f013..ad66f47 100644
--- a/libopie2/examples/opieui/opieui.pro
+++ b/libopie2/examples/opieui/opieui.pro
@@ -1,3 +1,3 @@
1TEMPLATE = subdirs 1TEMPLATE = subdirs
2SUBDIRS = olistviewdemo oversatileviewdemo 2SUBDIRS = olistviewdemo
3 3
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index 7a6c174..06d8ba2 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -1,113 +1,125 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 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#include <opie2/oapplication.h> 31#include <opie2/oapplication.h>
32#include <opie2/oconfig.h> 32#include <opie2/oconfig.h>
33 33
34#include <signal.h>
35#include <stdio.h>
36
34OApplication* OApplication::_instance = 0; 37OApplication* OApplication::_instance = 0;
35 38
36/**************************************************************************************************/ 39/**************************************************************************************************/
37/* OApplicationPrivate 40/* OApplicationPrivate
38/**************************************************************************************************/ 41/**************************************************************************************************/
39 42
40class OApplicationPrivate 43class OApplicationPrivate
41{ 44{
42 public: 45 public:
43 OApplicationPrivate() {}; 46 OApplicationPrivate() {};
44 ~OApplicationPrivate() {}; 47 ~OApplicationPrivate() {};
45}; 48};
46 49
47/**************************************************************************************************/ 50/**************************************************************************************************/
48/* OApplication 51/* OApplication
49/**************************************************************************************************/ 52/**************************************************************************************************/
50 53
51 54
52OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) 55OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
53 :QPEApplication( argc, argv ), 56 :QPEApplication( argc, argv ),
54 _appname( rAppName ), 57 _appname( rAppName ),
55 _config( 0 ) 58 _config( 0 )
56{ 59{
57 init(); 60 init();
58} 61}
59 62
60 63
61OApplication::~OApplication() 64OApplication::~OApplication()
62{ 65{
63 delete d; 66 delete d;
64 if ( _config ) 67 if ( _config )
65 delete _config; 68 delete _config;
66 OApplication::_instance = 0; 69 OApplication::_instance = 0;
67 // after deconstruction of the one-and-only application object, 70 // after deconstruction of the one-and-only application object,
68 // the construction of another object is allowed 71 // the construction of another object is allowed
69} 72}
70 73
71 74
72OConfig* OApplication::config() 75OConfig* OApplication::config()
73{ 76{
74 if ( !_config ) 77 if ( !_config )
75 { 78 {
76 _config = new OConfig( _appname ); 79 _config = new OConfig( _appname );
77 } 80 }
78 return _config; 81 return _config;
79} 82}
80 83
81 84
82void OApplication::init() 85void OApplication::init()
83{ 86{
84 d = new OApplicationPrivate(); 87 d = new OApplicationPrivate();
85 if ( !OApplication::_instance ) 88 if ( !OApplication::_instance )
86 { 89 {
87 OApplication::_instance = this; 90 OApplication::_instance = this;
91
92 /* register SIGSEGV handler to give programs an option
93 * to exit gracefully, e.g. save or close devices or files.
94 struct sigaction sa;
95 sa.sa_handler = ( void (*)(int) ) &segv_handler;
96 sa.sa_flags = SA_SIGINFO | SA_RESTART;
97 sigemptyset(&sa.sa_mask);
98 sigaction(SIGSEGV, &sa, NULL);
99 */
88 } 100 }
89 else 101 else
90 { 102 {
91 qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); 103 qFatal( "OApplication: Can't create more than one OApplication object. Aborting." );
92 } 104 }
93} 105}
94 106
95 107
96void OApplication::showMainWidget( QWidget* widget, bool nomax ) 108void OApplication::showMainWidget( QWidget* widget, bool nomax )
97{ 109{
98 QPEApplication::showMainWidget( widget, nomax ); 110 QPEApplication::showMainWidget( widget, nomax );
99 widget->setCaption( _appname ); 111 widget->setCaption( _appname );
100} 112}
101 113
102 114
103void OApplication::setTitle( const QString& title ) const 115void OApplication::setTitle( const QString& title ) const
104{ 116{
105 if ( mainWidget() ) 117 if ( mainWidget() )
106 { 118 {
107 if ( !title.isNull() ) 119 if ( !title.isNull() )
108 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); 120 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
109 else 121 else
110 mainWidget()->setCaption( _appname ); 122 mainWidget()->setCaption( _appname );
111 } 123 }
112} 124}
113 125
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index 94ac488..1bd34e2 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -1,102 +1,102 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 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#ifndef OAPPLICATION_H 31#ifndef OAPPLICATION_H
32#define OAPPLICATION_H 32#define OAPPLICATION_H
33 33
34#define oApp OApplication::oApplication() 34#define oApp OApplication::oApplication()
35 35
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37 37
38class OApplicationPrivate; 38class OApplicationPrivate;
39class OConfig; 39class OConfig;
40 40
41class OApplication: public QPEApplication 41class OApplication: public QPEApplication
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44 44
45 public: 45 public:
46 /** 46 /**
47 * Constructor. Parses command-line arguments and sets the window caption. 47 * Constructor. Parses command-line arguments and sets the window caption.
48 * 48 *
49 * @param rAppName application name. Will be used for finding the 49 * @param rAppName application name. Will be used for finding the
50 * associated message, icon and configuration files 50 * associated message, icon and configuration files
51 * 51 *
52 */ 52 */
53 OApplication( int& argc, char** argv, const QCString& rAppName ); 53 OApplication( int& argc, char** argv, const QCString& rAppName );
54 /** 54 /**
55 * Destructor. Destroys the application object and its children. 55 * Destructor. Destroys the application object and its children.
56 */ 56 */
57 virtual ~OApplication(); 57 virtual ~OApplication();
58 /** 58 /**
59 * @returns the process-wide application object 59 * @returns the process-wide application object
60 * 60 *
61 * This is similar to the global @ref QApplication pointer qApp. It 61 * This is similar to the global @ref QApplication pointer qApp. It
62 * allows access to the single global OApplication object, since 62 * allows access to the single global OApplication object, since
63 * more than one cannot be created in the same application. It 63 * more than one cannot be created in the same application. It
64 * saves you the trouble of having to pass the pointer explicitly 64 * saves you the trouble of having to pass the pointer explicitly
65 * to every function that may require it. 65 * to every function that may require it.
66 */ 66 */
67 static const OApplication* oApplication() { return _instance; }; 67 static const OApplication* oApplication() { return _instance; };
68 /** 68 /**
69 * Returns the application name as given during creation. 69 * Returns the application name as given during creation.
70 * 70 *
71 * @returns a reference to the application name 71 * @returns a reference to the application name
72 */ 72 */
73 const QCString& appName() const { return _appname; }; 73 const QCString& appName() const { return _appname; };
74 /** 74 /**
75 * @returns the application session config object. 75 * @returns the application session config object.
76 * 76 *
77 * @see OConfig 77 * @see OConfig
78 */ 78 */
79 OConfig* config(); 79 OConfig* config();
80 /** 80 /**
81 * Shows the main @a widget and sets the name of the application as window caption. 81 * Shows the main @a widget and sets the name of the application as window caption.
82 */ 82 */
83 virtual void showMainWidget( QWidget* widget, bool nomax = false ); 83 virtual void showMainWidget( QWidget* widget, bool nomax = false );
84 /** 84 /**
85 * Set the application title. The application title will be concatenated 85 * Set the application title. The application title will be concatenated
86 * to the application name given in the constructor. 86 * to the application name given in the constructor.
87 * 87 *
88 * @param title the title. If not given, resets caption to appname 88 * @param title the title. If not given, resets caption to appname
89 */ 89 */
90 virtual void setTitle( const QString& title = QString::null ) const; 90 virtual void setTitle( const QString& title = QString::null ) const;
91 91
92 protected: 92 protected:
93 void init(); 93 void init();
94 94
95 private: 95 private:
96 const QCString _appname; 96 const QCString _appname;
97 static OApplication* _instance; 97 static OApplication* _instance;
98 OConfig* _config; 98 OConfig* _config;
99 OApplicationPrivate* d; 99 OApplicationPrivate* d;
100}; 100};
101 101
102#endif // OAPPLICATION_H 102#endif // OAPPLICATION_H
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index ea15125..c185fc5 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,96 +1,114 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "omanufacturerdb.h" 16#include "omanufacturerdb.h"
17 17
18// Qt 18// Qt
19#include <qstring.h> 19#include <qstring.h>
20#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22 22
23OManufacturerDB* OManufacturerDB::_instance = 0; 23OManufacturerDB* OManufacturerDB::_instance = 0;
24 24
25OManufacturerDB* OManufacturerDB::instance() 25OManufacturerDB* OManufacturerDB::instance()
26{ 26{
27 if ( !OManufacturerDB::_instance ) 27 if ( !OManufacturerDB::_instance )
28 { 28 {
29 qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." ); 29 qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." );
30 _instance = new OManufacturerDB(); 30 _instance = new OManufacturerDB();
31 } 31 }
32 return _instance; 32 return _instance;
33} 33}
34 34
35 35
36OManufacturerDB::OManufacturerDB() 36OManufacturerDB::OManufacturerDB()
37{ 37{
38 QString filename( "/etc/manufacturers" ); 38 QString filename( "/etc/manufacturers" );
39 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 39 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
40 if ( !QFile::exists( filename ) ) 40 if ( !QFile::exists( filename ) )
41 { 41 {
42 filename = "/opt/QtPalmtop/etc/manufacturers"; 42 filename = "/opt/QtPalmtop/etc/manufacturers";
43 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 43 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
44 if ( !QFile::exists( filename ) ) 44 if ( !QFile::exists( filename ) )
45 { 45 {
46 filename = "/usr/share/wellenreiter/manufacturers"; 46 filename = "/usr/share/wellenreiter/manufacturers";
47 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 47 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
48 } 48 }
49 } 49 }
50 50
51 QFile file( filename ); 51 QFile file( filename );
52 bool hasFile = file.open( IO_ReadOnly ); 52 bool hasFile = file.open( IO_ReadOnly );
53 if (!hasFile) 53 if (!hasFile)
54 { 54 {
55 qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename ); 55 qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename );
56 } 56 }
57 else 57 else
58 { 58 {
59 qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); 59 qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename );
60 QTextStream s( &file ); 60 QTextStream s( &file );
61 QString addr; 61 QString addr;
62 QString manu; 62 QString manu;
63 QString extManu;
63 while (!s.atEnd()) 64 while (!s.atEnd())
64 { 65 {
65 s >> addr; 66 s >> addr;
66 if ( !addr ) // read nothing!? 67 if ( !addr ) // read nothing!?
67 { 68 {
68 continue; 69 continue;
69 } 70 }
70 else 71 else
71 if ( addr[0] == '#' ) 72 if ( addr[0] == '#' )
72 { 73 {
73 s.readLine();
74 continue; 74 continue;
75 } 75 }
76 s.skipWhiteSpace(); 76 s.skipWhiteSpace();
77 s >> manu; 77 s >> manu;
78 s.readLine(); 78 s.skipWhiteSpace();
79 //qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); 79 s >> extManu;
80 if ( extManu[0] == '#' ) // we have an extended manufacturer
81 {
82 s.skipWhiteSpace();
83 extManu = s.readLine();
84 qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
85 manufacturersExt.insert( addr, extManu );
86 }
87 else
88 s.readLine();
89 qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
80 manufacturers.insert( addr, manu ); 90 manufacturers.insert( addr, manu );
81 91
82 } 92 }
83 } 93 }
84 94
85} 95}
86 96
87 97
88OManufacturerDB::~OManufacturerDB() 98OManufacturerDB::~OManufacturerDB()
89{ 99{
90} 100}
91 101
92 102
93const QString& OManufacturerDB::lookup( const QString& macaddr ) const 103const QString& OManufacturerDB::lookup( const QString& macaddr ) const
94{ 104{
95 return manufacturers[macaddr.upper().left(8)]; 105 return manufacturers[macaddr.upper().left(8)];
96} 106}
107
108
109const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
110{
111 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
112 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
113}
114
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index cb0b6c8..651f624 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -1,38 +1,54 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef OMANUFACTURERDB_H 16#ifndef OMANUFACTURERDB_H
17#define OMANUFACTURERDB_H 17#define OMANUFACTURERDB_H
18 18
19#include <qmap.h> 19#include <qmap.h>
20 20
21/**
22 * @brief A Ethernet card vendor database.
23 *
24 * This class encapsulates the lookup of Ethernet vendor given a
25 * certain Mac Address. Only the first three bytes define the vendor.
26 */
21class OManufacturerDB 27class OManufacturerDB
22{ 28{
23 public: 29 public:
24 //FIXME make us consistent -zecke I use self(), sandman inst() you use instance() so we need to chose one! 30 /**
31 * @returns the one-and-only @ref OManufacturerDB instance.
32 */
25 static OManufacturerDB* instance(); 33 static OManufacturerDB* instance();
34 /**
35 * @returns the short manufacturer string given a @a macaddr.
36 */
26 const QString& lookup( const QString& macaddr ) const; 37 const QString& lookup( const QString& macaddr ) const;
38 /**
39 * @returns the enhanced manufacturer string given a @a macaddr.
40 */
41 const QString& lookupExt( const QString& macaddr ) const;
27 42
28 protected: 43 protected:
29 OManufacturerDB(); 44 OManufacturerDB();
30 virtual ~OManufacturerDB(); 45 virtual ~OManufacturerDB();
31 46
32 private: 47 private:
33 QMap<QString, QString> manufacturers; 48 QMap<QString, QString> manufacturers;
49 QMap<QString, QString> manufacturersExt;
34 static OManufacturerDB* _instance; 50 static OManufacturerDB* _instance;
35}; 51};
36 52
37#endif 53#endif
38 54
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index e05efc2..08c40b4 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,209 +1,210 @@
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>
39using namespace std; 39using 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
56const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 56const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
57const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 57const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
58const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 58const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
59const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 59const 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
64OMacAddress::OMacAddress( unsigned char* p ) 64OMacAddress::OMacAddress( unsigned char* p )
65{ 65{
66 memcpy( _bytes, p, 6 ); 66 memcpy( _bytes, p, 6 );
67} 67}
68 68
69 69
70OMacAddress::OMacAddress( const unsigned char* p ) 70OMacAddress::OMacAddress( const unsigned char* p )
71{ 71{
72 memcpy( _bytes, p, 6 ); 72 memcpy( _bytes, p, 6 );
73} 73}
74 74
75 75
76OMacAddress::OMacAddress( struct ifreq& ifr ) 76OMacAddress::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
82OMacAddress::~OMacAddress() 82OMacAddress::~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
90const unsigned char* OMacAddress::native() const 90const 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
96OMacAddress OMacAddress::fromString( const QString& str ) 96OMacAddress 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
113QString OMacAddress::toString( bool substitute ) const 113QString 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
126QString OMacAddress::manufacturer() const 126QString OMacAddress::manufacturer() const
127{ 127{
128 return OManufacturerDB::instance()->lookup( toString() ); 128 return OManufacturerDB::instance()->lookupExt( toString() );
129} 129}
130 130
131
131bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 132bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
132{ 133{
133 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 134 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
134} 135}
135 136
136 137
137/*====================================================================================== 138/*======================================================================================
138 * OHostAddress 139 * OHostAddress
139 *======================================================================================*/ 140 *======================================================================================*/
140 141
141 142
142/*====================================================================================== 143/*======================================================================================
143 * OPrivateIOCTL 144 * OPrivateIOCTL
144 *======================================================================================*/ 145 *======================================================================================*/
145 146
146OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 147OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
147 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 148 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
148{ 149{
149} 150}
150 151
151 152
152OPrivateIOCTL::~OPrivateIOCTL() 153OPrivateIOCTL::~OPrivateIOCTL()
153{ 154{
154} 155}
155 156
156 157
157int OPrivateIOCTL::numberGetArgs() const 158int OPrivateIOCTL::numberGetArgs() const
158{ 159{
159 return _getargs & IW_PRIV_SIZE_MASK; 160 return _getargs & IW_PRIV_SIZE_MASK;
160} 161}
161 162
162 163
163int OPrivateIOCTL::typeGetArgs() const 164int OPrivateIOCTL::typeGetArgs() const
164{ 165{
165 return _getargs & IW_PRIV_TYPE_MASK >> 12; 166 return _getargs & IW_PRIV_TYPE_MASK >> 12;
166} 167}
167 168
168 169
169int OPrivateIOCTL::numberSetArgs() const 170int OPrivateIOCTL::numberSetArgs() const
170{ 171{
171 return _setargs & IW_PRIV_SIZE_MASK; 172 return _setargs & IW_PRIV_SIZE_MASK;
172} 173}
173 174
174 175
175int OPrivateIOCTL::typeSetArgs() const 176int OPrivateIOCTL::typeSetArgs() const
176{ 177{
177 return _setargs & IW_PRIV_TYPE_MASK >> 12; 178 return _setargs & IW_PRIV_TYPE_MASK >> 12;
178} 179}
179 180
180 181
181void OPrivateIOCTL::invoke() const 182void OPrivateIOCTL::invoke() const
182{ 183{
183 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 184 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
184} 185}
185 186
186 187
187void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 188void OPrivateIOCTL::setParameter( int num, u_int32_t value )
188{ 189{
189 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 190 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
190 arglist[num] = value; 191 arglist[num] = value;
191} 192}
192 193
193/*====================================================================================== 194/*======================================================================================
194 * assorted functions 195 * assorted functions
195 *======================================================================================*/ 196 *======================================================================================*/
196 197
197void dumpBytes( const unsigned char* data, int num ) 198void dumpBytes( const unsigned char* data, int num )
198{ 199{
199 printf( "Dumping %d bytes @ %0x", num, data ); 200 printf( "Dumping %d bytes @ %0x", num, data );
200 printf( "-------------------------------------------\n" ); 201 printf( "-------------------------------------------\n" );
201 202
202 for ( int i = 0; i < num; ++i ) 203 for ( int i = 0; i < num; ++i )
203 { 204 {
204 printf( "%02x ", data[i] ); 205 printf( "%02x ", data[i] );
205 if ( !((i+1) % 32) ) printf( "\n" ); 206 if ( !((i+1) % 32) ) printf( "\n" );
206 } 207 }
207 printf( "\n\n" ); 208 printf( "\n\n" );
208} 209}
209 210