summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-01 22:44:38 (UTC)
committer mickeyl <mickeyl>2003-12-01 22:44:38 (UTC)
commit7a7683d435cfbb4fa2d6ed99fd4a94d388402aec (patch) (unidiff)
tree1a34de131d935f34dd2622e3606ba664a7783e24
parenta4a47fca8badeca2b1aae51b39295ccdc8782c4f (diff)
downloadopie-7a7683d435cfbb4fa2d6ed99fd4a94d388402aec.zip
opie-7a7683d435cfbb4fa2d6ed99fd4a94d388402aec.tar.gz
opie-7a7683d435cfbb4fa2d6ed99fd4a94d388402aec.tar.bz2
slowly start to refactor & cleanup libopie2 before merging it with libopie1
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp2
-rw-r--r--libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp25
-rw-r--r--libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro4
-rw-r--r--libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp7
-rw-r--r--libopie2/libopie2.control4
-rw-r--r--libopie2/opiecore/libopiecore2.control2
-rw-r--r--libopie2/opiecore/oconfig.cpp4
-rw-r--r--libopie2/opiecore/oconfig.h6
-rw-r--r--libopie2/opiecore/odebug.cpp3
-rw-r--r--libopie2/opiecore/oglobal.cpp9
-rw-r--r--libopie2/opiecore/oglobal.h18
-rw-r--r--libopie2/opiecore/oglobalsettings.cpp1
-rw-r--r--libopie2/opiecore/opiecore.pro2
-rw-r--r--libopie2/opiedb/libopiedb2.control4
-rw-r--r--libopie2/opiedb/opiedb.pro2
-rw-r--r--libopie2/opiemm/libopiemm2.control4
-rw-r--r--libopie2/opiemm/opiemm.pro2
-rw-r--r--libopie2/opienet/dhcp.h3
-rw-r--r--libopie2/opienet/libopienet2.control4
-rw-r--r--libopie2/opienet/odebugmapper.cpp8
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp67
-rw-r--r--libopie2/opienet/omanufacturerdb.h43
-rw-r--r--libopie2/opienet/onetutils.cpp2
-rw-r--r--libopie2/opienet/onetwork.cpp6
-rw-r--r--libopie2/opienet/onetwork.h5
-rw-r--r--libopie2/opienet/opcap.cpp5
-rw-r--r--libopie2/opienet/opcap.h5
-rw-r--r--libopie2/opienet/opienet.pro2
-rw-r--r--libopie2/opienet/ostation.cpp3
-rw-r--r--libopie2/opienet/ostation.h3
-rw-r--r--libopie2/opienet/udp_ports.h2
-rw-r--r--libopie2/opiepim/libopiepim2.control4
-rw-r--r--libopie2/opiepim/opiepim.pro2
-rw-r--r--libopie2/opieui/libopieui2.control4
-rw-r--r--libopie2/opieui/opieui.pro2
-rwxr-xr-xlibopie2/tools/regen.py8
36 files changed, 162 insertions, 115 deletions
diff --git a/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp
index 74886fa..e8bf04f 100644
--- a/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp
+++ b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp
@@ -1,138 +1,140 @@
1/* QT */ 1/* QT */
2 2
3#include <qvbox.h> 3#include <qvbox.h>
4#include <qhbox.h> 4#include <qhbox.h>
5#include <qvbuttongroup.h> 5#include <qvbuttongroup.h>
6#include <qhbuttongroup.h> 6#include <qhbuttongroup.h>
7#include <qlineedit.h> 7#include <qlineedit.h>
8#include <qradiobutton.h> 8#include <qradiobutton.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10 10
11/* OPIE */ 11/* OPIE */
12 12
13#include <qpe/config.h> 13#include <qpe/config.h>
14 14
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16#include <opie2/oapplication.h> 16#include <opie2/oapplication.h>
17#include <opie2/oglobal.h> 17#include <opie2/oglobal.h>
18#include <opie2/oglobalsettings.h> 18#include <opie2/oglobalsettings.h>
19 19
20class DemoApp : public OApplication 20class DemoApp : public OApplication
21{ 21{
22Q_OBJECT 22Q_OBJECT
23public: 23public:
24 DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" ) 24 DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" )
25 { 25 {
26 // you have access to your OApplication object via oApp 26 // you have access to your OApplication object via oApp
27 qDebug( "Process-wide OApplication object @ %0x", oApp ); 27 qDebug( "Process-wide OApplication object @ %0x", oApp );
28 28
29 // you have access to global settings via OGlobalSettings 29 // you have access to global settings via OGlobalSettings
30 int mode = OGlobalSettings::debugMode(); 30 int mode = OGlobalSettings::debugMode();
31 31
32 QVBox* vbox = new QVBox(); 32 QVBox* vbox = new QVBox();
33 setMainWidget( vbox ); 33 setMainWidget( vbox );
34 34
35 g = new QVButtonGroup( "Output Strategy", vbox ); 35 g = new QVButtonGroup( "Output Strategy", vbox );
36 QRadioButton* r0 = new QRadioButton( "file", g ); 36 QRadioButton* r0 = new QRadioButton( "file", g );
37 QRadioButton* r1 = new QRadioButton( "messagebox", g ); 37 QRadioButton* r1 = new QRadioButton( "messagebox", g );
38 QRadioButton* r2 = new QRadioButton( "stderr", g ); 38 QRadioButton* r2 = new QRadioButton( "stderr", g );
39 QRadioButton* r3 = new QRadioButton( "syslog", g ); 39 QRadioButton* r3 = new QRadioButton( "syslog", g );
40 QRadioButton* r4 = new QRadioButton( "socket", g ); 40 QRadioButton* r4 = new QRadioButton( "socket", g );
41 g->insert( r0, 0 ); 41 g->insert( r0, 0 );
42 g->insert( r1, 1 ); 42 g->insert( r1, 1 );
43 g->insert( r2, 2 ); 43 g->insert( r2, 2 );
44 g->insert( r3, 3 ); 44 g->insert( r3, 3 );
45 g->insert( r4, 4 ); 45 g->insert( r4, 4 );
46 g->setRadioButtonExclusive( true ); 46 g->setRadioButtonExclusive( true );
47 connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) ); 47 connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) );
48 48
49 if ( mode != -1 ) g->setButton( mode ); 49 if ( mode != -1 ) g->setButton( mode );
50 50
51 QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox ); 51 QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox );
52 e = new QLineEdit( hbox ); 52 e = new QLineEdit( hbox );
53 QPushButton* pb = new QPushButton( hbox ); 53 QPushButton* pb = new QPushButton( hbox );
54 54
55 connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) ); 55 connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) );
56 connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) ); 56 connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) );
57 57
58 // show the additional debug mode dependent output information 58 // show the additional debug mode dependent output information
59 e->setText( OGlobalSettings::debugOutput() ); 59 e->setText( OGlobalSettings::debugOutput() );
60 60
61 // buttos 61 // buttos
62 QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox ); 62 QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox );
63 connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) ); 63 connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) );
64 QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox ); 64 QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox );
65 connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) ); 65 connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) );
66 QPushButton* error = new QPushButton( "Emit an Error Output!", vbox ); 66 QPushButton* error = new QPushButton( "Emit an Error Output!", vbox );
67 connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) ); 67 connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) );
68 QPushButton* fatal = new QPushButton( "Emit a Fatal Output!", vbox ); 68 QPushButton* fatal = new QPushButton( "Emit a Fatal Output!", vbox );
69 connect( fatal, SIGNAL( clicked() ), this, SLOT( emitFatalOutput() ) ); 69 connect( fatal, SIGNAL( clicked() ), this, SLOT( emitFatalOutput() ) );
70 70
71 QPushButton* tb = new QPushButton( "Emit a Fatal Backtrace!", vbox ); 71 QPushButton* tb = new QPushButton( "Emit a Fatal Backtrace!", vbox );
72 connect( tb, SIGNAL( clicked() ), this, SLOT( emitTBOutput() ) ); 72 connect( tb, SIGNAL( clicked() ), this, SLOT( emitTBOutput() ) );
73 73
74 info->show(); 74 info->show();
75 warn->show(); 75 warn->show();
76 error->show(); 76 error->show();
77 fatal->show(); 77 fatal->show();
78 tb->show(); 78 tb->show();
79 g->show(); 79 g->show();
80 hbox->show(); 80 hbox->show();
81 e->show(); 81 e->show();
82 vbox->show(); 82 vbox->show();
83 showMainWidget( vbox ); 83 showMainWidget( vbox );
84 } 84 }
85 85
86public slots: 86public slots:
87 void chooseMethod(int method) 87 void chooseMethod(int method)
88 { 88 {
89 m = method; 89 m = method;
90 qDebug( "choosing method: %d", method ); 90 qDebug( "choosing method: %d", method );
91 OConfig* g = OGlobal::config(); 91 OConfig* g = OGlobal::config();
92 g->setGroup( "General" ); 92 g->setGroup( "General" );
93 g->writeEntry( "debugMode", m ); 93 g->writeEntry( "debugMode", m );
94 e->setText( OGlobalSettings::debugOutput() ); 94 e->setText( OGlobalSettings::debugOutput() );
95 g->write();
95 } 96 }
96 void updateDebugOutput() 97 void updateDebugOutput()
97 { 98 {
98 OConfig* g = OGlobal::config(); 99 OConfig* g = OGlobal::config();
99 g->setGroup( "General" ); 100 g->setGroup( "General" );
100 g->writeEntry( "debugOutput"+QString::number(OGlobalSettings::debugMode()), e->text() ); 101 g->writeEntry( "debugOutput"+QString::number(OGlobalSettings::debugMode()), e->text() );
102 g->write();
101 } 103 }
102 void emitInfoOutput() 104 void emitInfoOutput()
103 { 105 {
104 odebug << "This is a debug message" << oendl; 106 odebug << "This is a debug message" << oendl;
105 } 107 }
106 void emitWarningOutput() 108 void emitWarningOutput()
107 { 109 {
108 owarn << "This is a warning message" << oendl; 110 owarn << "This is a warning message" << oendl;
109 } 111 }
110 void emitErrorOutput() 112 void emitErrorOutput()
111 { 113 {
112 oerr << "This is an errror message" << oendl; 114 oerr << "This is an errror message" << oendl;
113 } 115 }
114 void emitFatalOutput() 116 void emitFatalOutput()
115 { 117 {
116 ofatal << "This is a fatal message" << oendl; 118 ofatal << "This is a fatal message" << oendl;
117 } 119 }
118 void emitTBOutput() 120 void emitTBOutput()
119 { 121 {
120 ofatal << "This is a fatal message + backtrace\n" + odBacktrace(); // odBacktrace includes \n 122 ofatal << "This is a fatal message + backtrace\n" + odBacktrace(); // odBacktrace includes \n
121 } 123 }
122 124
123private: 125private:
124 QButtonGroup* g; 126 QButtonGroup* g;
125 int m; 127 int m;
126 QLineEdit* e; 128 QLineEdit* e;
127}; 129};
128 130
129int main( int argc, char** argv ) 131int main( int argc, char** argv )
130{ 132{
131 DemoApp* app = new DemoApp( argc, argv ); 133 DemoApp* app = new DemoApp( argc, argv );
132 app->exec(); 134 app->exec();
133 135
134 return 0; 136 return 0;
135 137
136} 138}
137 139
138#include "moc/odebugdemo.moc" 140#include "moc/odebugdemo.moc"
diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
index c49daa0..eb2e8e8 100644
--- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
+++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
@@ -1,217 +1,232 @@
1#include <qdict.h> 1#include <qdict.h>
2#include <qsocketnotifier.h> 2#include <qsocketnotifier.h>
3#include <qstring.h> 3#include <qstring.h>
4#include <opie2/onetwork.h> 4#include <opie2/onetwork.h>
5#include <qapplication.h> 5#include <qapplication.h>
6#include <opie2/opcap.h> 6#include <opie2/opcap.h>
7#include <cerrno> 7#include <cerrno>
8#include <cstdio> 8#include <cstdio>
9#include <cstdlib> 9#include <cstdlib>
10#include <cstring> 10#include <cstring>
11 11
12//======================== Station help class =============================== 12//======================== Station help class ===============================
13 13
14class Station 14class Station
15{ 15{
16 public: 16 public:
17 Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {}; 17 Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {};
18 ~Station() {}; 18 ~Station() {};
19 19
20 QString type; 20 QString type;
21 int channel; 21 int channel;
22 bool wep; 22 bool wep;
23 int beacons; 23 int beacons;
24}; 24};
25 25
26QDict<Station> stations; 26QDict<Station> stations;
27 27
28//======================== Application class =============================== 28//======================== Application class ===============================
29 29
30class Wellenreiter : public QApplication 30class Wellenreiter : public QApplication
31{ 31{
32Q_OBJECT 32Q_OBJECT
33public: 33public:
34 Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ) 34 Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 )
35 { 35 {
36 36
37 ONetwork* net = ONetwork::instance(); 37 ONetwork* net = ONetwork::instance();
38 38
39 if ( argc < 3 ) 39 if ( argc < 3 )
40 { 40 {
41 printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] ); 41 printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] );
42 printf( "\n" ); 42 printf( "\n" );
43 printf( "Valid wireless interfaces (detected) are:\n" ); 43 printf( "Valid wireless interfaces (detected) are:\n" );
44 44
45 ONetwork::InterfaceIterator it = net->iterator(); 45 ONetwork::InterfaceIterator it = net->iterator();
46 while ( it.current() ) 46 while ( it.current() )
47 { 47 {
48 if ( it.current()->isWireless() ) 48 if ( it.current()->isWireless() )
49 { 49 {
50 printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), 50 printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(),
51 (const char*) it.current()->macAddress().toString(), 51 (const char*) it.current()->macAddress().toString(),
52 (const char*) it.current()->ipV4Address() ); 52 (const char*) it.current()->ipV4Address() );
53 } 53 }
54 ++it; 54 ++it;
55 } 55 }
56 exit( -1 ); 56 exit( -1 );
57 } 57 }
58 58
59 printf( "****************************************************\n" ); 59 printf( "*******************************************************************\n" );
60 printf( "* Wellenreiter mini edition 1.0 (C) 2003 M-M-M *\n" ); 60 printf( "* Wellenreiter mini edition 1.0.0 (C) 2003 Michael 'Mickey' Lauer *\n" );
61 printf( "****************************************************\n" ); 61 printf( "*******************************************************************\n" );
62 printf( "\n\n" ); 62 printf( "\n\n" );
63 63
64 QString interface( argv[1] ); 64 QString interface( argv[1] );
65 QString driver( argv[2] ); 65 QString driver( argv[2] );
66 66
67 printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver ); 67 printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver );
68 68
69 // sanity checks before downcasting 69 // sanity checks before downcasting
70 ONetworkInterface* iface = net->interface( interface ); 70 ONetworkInterface* iface = net->interface( interface );
71 if ( !iface ) 71 if ( !iface )
72 { 72 {
73 printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface ); 73 printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface );
74 exit( -1 ); 74 exit( -1 );
75 } 75 }
76 if ( !iface->isWireless() ) 76 if ( !iface->isWireless() )
77 { 77 {
78 printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface ); 78 printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface );
79 exit( -1 ); 79 exit( -1 );
80 } 80 }
81 81
82 // downcast should be safe now 82 // downcast should be safe now
83 wiface = (OWirelessNetworkInterface*) iface; 83 wiface = (OWirelessNetworkInterface*) iface;
84 printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() ); 84 printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() );
85 85
86 // ifconfig +promisc the interface to receive all packets 86 // ifconfig +promisc the interface to receive all packets
87 if ( !wiface->promiscuousMode() ) 87 if ( !wiface->promiscuousMode() )
88 { 88 {
89 printf( "Interface status is not promisc... switching to promisc... " ); 89 printf( "Interface status is not promisc... switching to promisc... " );
90 wiface->setPromiscuousMode( true ); 90 wiface->setPromiscuousMode( true );
91 if ( !wiface->promiscuousMode() ) 91 if ( !wiface->promiscuousMode() )
92 { 92 {
93 printf( "failed (%s). Exiting.\n", strerror( errno ) ); 93 printf( "failed (%s). Exiting.\n", strerror( errno ) );
94 exit( -1 ); 94 exit( -1 );
95 } 95 }
96 else 96 else
97 { 97 {
98 printf( "ok.\n" ); 98 printf( "ok.\n" );
99 } 99 }
100 } 100 }
101 else 101 else
102 printf( "Interface status is already promisc - good.\n" ); 102 printf( "Interface status is already promisc - good.\n" );
103 103
104 // connect a monitoring strategy to the interface 104 // connect a monitoring strategy to the interface
105 if ( driver == "orinoco" ) 105 if ( driver == "orinoco" )
106 new OOrinocoMonitoringInterface( wiface, false ); 106 new OOrinocoMonitoringInterface( wiface, false );
107 else 107 else
108 if ( driver == "hostap" )
109 new OHostAPMonitoringInterface( wiface, false );
110 else
111 if ( driver == "wlan-ng" )
112 new OWlanNGMonitoringInterface( wiface, false );
113 else
108 { 114 {
109 printf( "Unknown driver. Exiting\n" ); 115 printf( "Unknown driver. Exiting\n" );
110 exit( -1 ); 116 exit( -1 );
111 } 117 }
112 118
113 // enable monitoring mode 119 // enable monitoring mode
114 printf( "Enabling monitor mode...\n" ); 120 printf( "Enabling monitor mode...\n" );
115 //wiface->setMonitorMode( true ); 121 wiface->setMode( "monitor" );
116 122
117 // open a packet capturer 123 // open a packet capturer
118 cap = new OPacketCapturer(); 124 cap = new OPacketCapturer();
119 cap->open( interface ); 125 cap->open( interface );
120 if ( !cap->isOpen() ) 126 if ( !cap->isOpen() )
121 { 127 {
122 printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); 128 printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) );
123 exit( -1 ); 129 exit( -1 );
124 } 130 }
125 131
126 // set capturer to non-blocking mode 132 // set capturer to non-blocking mode
127 cap->setBlocking( false ); 133 cap->setBlocking( false );
128 134
129 // start channel hopper 135 // start channel hopper
130 //wiface->setChannelHopping( 1000 ); 136 //wiface->setChannelHopping( 1000 );
131 137
132 // connect 138 // connect
133 connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 139 connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
140 // timer
141 startTimer( 1000 );
134 142
135 } 143 }
136 144
137 ~Wellenreiter() {}; 145 ~Wellenreiter() {};
138 146
139public slots: 147public slots:
148 virtual void timerEvent(QTimerEvent* e)
149 {
150 wiface->setChannel( channel++ );
151 if ( channel == 14 ) channel = 1;
152 }
153
140 void receivePacket(OPacket* p) 154 void receivePacket(OPacket* p)
141 { 155 {
142 if (!p) 156 if (!p)
143 { 157 {
144 printf( "(empty packet received)\n" ); 158 printf( "(empty packet received)\n" );
145 return; 159 return;
146 } 160 }
147 161
148 OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); 162 OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" );
149 if ( beacon ) 163 if ( beacon )
150 { 164 {
151 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 165 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
152 QString essid = ssid ? ssid->ID() : "<unknown>"; 166 QString essid = ssid ? ssid->ID() : "<unknown>";
153 167
154 if ( stations.find( essid ) ) 168 if ( stations.find( essid ) )
155 stations[essid]->beacons++; 169 stations[essid]->beacons++;
156 else 170 else
157 { 171 {
158 printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid ); 172 printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid );
159 stations.insert( essid, new Station( "unknown", wiface->channel(), 173 stations.insert( essid, new Station( "unknown", wiface->channel(),
160 ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); 174 ((OWaveLanPacket*) beacon->parent())->usesWep() ) );
161 } 175 }
162 return; 176 return;
163 } 177 }
164 178
165 OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" ); 179 OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" );
166 if ( data ) 180 if ( data )
167 { 181 {
168 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 182 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
169 if ( wlan->fromDS() && !wlan->toDS() ) 183 if ( wlan->fromDS() && !wlan->toDS() )
170 { 184 {
171 printf( "FromDS: '%s' -> '%s' via '%s'\n", 185 printf( "FromDS: '%s' -> '%s' via '%s'\n",
172 (const char*) wlan->macAddress3().toString(true), 186 (const char*) wlan->macAddress3().toString(true),
173 (const char*) wlan->macAddress1().toString(true), 187 (const char*) wlan->macAddress1().toString(true),
174 (const char*) wlan->macAddress2().toString(true) ); 188 (const char*) wlan->macAddress2().toString(true) );
175 } 189 }
176 else 190 else
177 if ( !wlan->fromDS() && wlan->toDS() ) 191 if ( !wlan->fromDS() && wlan->toDS() )
178 { 192 {
179 printf( "ToDS: '%s' -> '%s' via '%s'\n", 193 printf( "ToDS: '%s' -> '%s' via '%s'\n",
180 (const char*) wlan->macAddress2().toString(true), 194 (const char*) wlan->macAddress2().toString(true),
181 (const char*) wlan->macAddress3().toString(true), 195 (const char*) wlan->macAddress3().toString(true),
182 (const char*) wlan->macAddress1().toString(true) ); 196 (const char*) wlan->macAddress1().toString(true) );
183 } 197 }
184 else 198 else
185 if ( wlan->fromDS() && wlan->toDS() ) 199 if ( wlan->fromDS() && wlan->toDS() )
186 { 200 {
187 printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n", 201 printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n",
188 (const char*) wlan->macAddress4().toString(true), 202 (const char*) wlan->macAddress4().toString(true),
189 (const char*) wlan->macAddress3().toString(true), 203 (const char*) wlan->macAddress3().toString(true),
190 (const char*) wlan->macAddress1().toString(true), 204 (const char*) wlan->macAddress1().toString(true),
191 (const char*) wlan->macAddress2().toString(true) ); 205 (const char*) wlan->macAddress2().toString(true) );
192 } 206 }
193 else 207 else
194 { 208 {
195 printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n", 209 printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n",
196 (const char*) wlan->macAddress2().toString(true), 210 (const char*) wlan->macAddress2().toString(true),
197 (const char*) wlan->macAddress1().toString(true), 211 (const char*) wlan->macAddress1().toString(true),
198 (const char*) wlan->macAddress3().toString(true) ); 212 (const char*) wlan->macAddress3().toString(true) );
199 } 213 }
200 return; 214 return;
201 } 215 }
202 } 216 }
203private: 217private:
204 OPacketCapturer* cap; 218 OPacketCapturer* cap;
205 OWirelessNetworkInterface* wiface; 219 OWirelessNetworkInterface* wiface;
220 int channel;
206}; 221};
207 222
208 223
209int main( int argc, char** argv ) 224int main( int argc, char** argv )
210{ 225{
211 Wellenreiter w( argc, argv ); 226 Wellenreiter w( argc, argv );
212 w.exec(); 227 w.exec();
213 return 0; 228 return 0;
214} 229}
215 230
216#include "miniwellenreiter.moc" 231#include "miniwellenreiter.moc"
217 232
diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro
index 7ce535c..b2c5c14 100644
--- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro
+++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro
@@ -1,13 +1,13 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on debug 2CONFIG = qt warn_on debug
3HEADERS = 3HEADERS =
4SOURCES = miniwellenreiter.cpp 4SOURCES = miniwellenreiter.cpp
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lopiecore2 -lopienet2 7LIBS += -lopiecore2 -lopienet2
8TARGET = miniwellenreiter 8TARGET = miniwellenreiter
9MOC_DIR = moc 9MOC_DIR = moc
10OBJECTS_DIR = obj 10OBJECTS_DIR = obj
11 11
12include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )
13 13
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
index 06b8b19..4763316 100644
--- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
+++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
@@ -1,142 +1,143 @@
1#include <opie2/onetwork.h> 1#include <opie2/onetwork.h>
2#include <opie2/ostation.h> 2#include <opie2/ostation.h>
3#include <opie2/omanufacturerdb.h> 3#include <opie2/omanufacturerdb.h>
4 4
5#include <unistd.h> 5#include <unistd.h>
6 6
7int main( int argc, char** argv ) 7int main( int argc, char** argv )
8{ 8{
9 qDebug( "OPIE Network Demo" ); 9 qDebug( "OPIE Network Demo" );
10 10
11 ONetwork* net = ONetwork::instance(); 11 ONetwork* net = ONetwork::instance();
12 12
13 ONetwork::InterfaceIterator it = net->iterator(); 13 ONetwork::InterfaceIterator it = net->iterator();
14 14
15 while ( it.current() ) 15 while ( it.current() )
16 { 16 {
17 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); 17 qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() );
18 qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() ); 18 qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() );
19 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); 19 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() );
20 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); 20 qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) );
21 qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); 21 qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() );
22 qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); 22 qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) );
23 qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); 23 qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) );
24 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); 24 qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
25 if ( it.current()->isWireless() ) 25 if ( it.current()->isWireless() )
26 { 26 {
27 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); 27 OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
28 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); 28 qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
29 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); 29 qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
30 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); 30 qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );
31 31
32 //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) 32 //if ( iface->mode() == OWirelessNetworkInterface::adhoc )
33 //{ 33 //{
34 //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); 34 //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() );
35 //} 35 //}
36 36
37 /* 37 /*
38 38
39 // nickname 39 // nickname
40 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); 40 qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
41 iface->setNickName( "MyNickName" ); 41 iface->setNickName( "MyNickName" );
42 if ( iface->nickName() != "MyNickName" ) 42 if ( iface->nickName() != "MyNickName" )
43 qDebug( "DEMO: Warning! Can't change nickname" ); 43 qDebug( "DEMO: Warning! Can't change nickname" );
44 else 44 else
45 qDebug( "DEMO: Nickname change successful." ); 45 qDebug( "DEMO: Nickname change successful." );
46 46
47 /* 47 /*
48 48
49 // operation mode 49 // operation mode
50 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); 50 qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() );
51 iface->setMode( "adhoc" ); 51 iface->setMode( "adhoc" );
52 if ( iface->mode() != "adhoc" ) 52 if ( iface->mode() != "adhoc" )
53 qDebug( "DEMO: Warning! Can't change operation mode" ); 53 qDebug( "DEMO: Warning! Can't change operation mode" );
54 else 54 else
55 qDebug( "DEMO: Operation Mode change successful." ); 55 qDebug( "DEMO: Operation Mode change successful." );
56 56
57 // RF channel 57 // RF channel
58 qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); 58 qDebug( "DEMO: Current Channel is '%d'", iface->channel() );
59 iface->setChannel( 1 ); 59 iface->setChannel( 1 );
60 if ( iface->channel() != 1 ) 60 if ( iface->channel() != 1 )
61 qDebug( "DEMO: Warning! Can't change RF channel" ); 61 qDebug( "DEMO: Warning! Can't change RF channel" );
62 else 62 else
63 qDebug( "DEMO: RF channel change successful." ); 63 qDebug( "DEMO: RF channel change successful." );
64 64
65 iface->setMode( "managed" ); 65 iface->setMode( "managed" );
66 66
67 */ 67 */
68 68
69 /* 69 /*
70 70
71 // network scan 71 // network scan
72 72
73 OStationList* stations = iface->scanNetwork(); 73 OStationList* stations = iface->scanNetwork();
74 if ( stations ) 74 if ( stations )
75 { 75 {
76 qDebug( "DEMO: # of stations around = %d", stations->count() ); 76 qDebug( "DEMO: # of stations around = %d", stations->count() );
77 OStation* station; 77 OStation* station;
78 for ( station = stations->first(); station != 0; station = stations->next() ) 78 for ( station = stations->first(); station != 0; station = stations->next() )
79 { 79 {
80 qDebug( "DEMO: station dump following..." ); 80 qDebug( "DEMO: station dump following..." );
81 station->dump(); 81 station->dump();
82 } 82 }
83 } 83 }
84 84
85 else 85 else
86 { 86 {
87 qDebug( "DEMO: Warning! Scan didn't work!" ); 87 qDebug( "DEMO: Warning! Scan didn't work!" );
88 } 88 }
89 89
90 /* 90 /*
91 91
92 // first some wrong calls to check if this is working 92 // first some wrong calls to check if this is working
93 iface->setPrivate( "seppel", 10 ); 93 iface->setPrivate( "seppel", 10 );
94 iface->setPrivate( "monitor", 0 ); 94 iface->setPrivate( "monitor", 0 );
95 95
96 // now the real deal 96 // now the real deal
97 iface->setPrivate( "monitor", 2, 2, 3 ); 97 iface->setPrivate( "monitor", 2, 2, 3 );
98 98
99 // trying to set hw address to 12:34:56:AB:CD:EF 99 // trying to set hw address to 12:34:56:AB:CD:EF
100 100
101 /* 101 /*
102 102
103 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); 103 OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" );
104 iface->setUp( false ); 104 iface->setUp( false );
105 iface->setMacAddress( addr ); 105 iface->setMacAddress( addr );
106 iface->setUp( true ); 106 iface->setUp( true );
107 qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); 107 qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() );
108 108
109 */ 109 */
110 110
111 // monitor test 111 // monitor test
112 112
113 /* 113
114 114
115 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); 115 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );
116 iface->setMode( "monitor" ); 116 iface->setMode( "monitor" );
117 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); 117 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );
118 118
119 sleep( 1 ); */ 119 sleep( 1 );
120 120
121 iface->setMode( "master" ); 121 iface->setChannel( 1 );
122 iface->setMode( "managed" );
122 123
123 //sleep( 1 ); 124 //sleep( 1 );
124 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); 125 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );
125 126
126 /*iface->setMode( "adhoc" ); 127 /*iface->setMode( "adhoc" );
127 sleep( 1 ); 128 sleep( 1 );
128 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); 129 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );
129 iface->setMode( "managed" ); 130 iface->setMode( "managed" );
130 sleep( 1 ); 131 sleep( 1 );
131 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); 132 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );
132 iface->setMode( "master" ); 133 iface->setMode( "master" );
133 sleep( 1 ); 134 sleep( 1 );
134 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );*/ 135 qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );*/
135 136
136 } 137 }
137 ++it; 138 ++it;
138 } 139 }
139 140
140 return 0; 141 return 0;
141 142
142} 143}
diff --git a/libopie2/libopie2.control b/libopie2/libopie2.control
index 6e11cbf..f54efd8 100644
--- a/libopie2/libopie2.control
+++ b/libopie2/libopie2.control
@@ -1,11 +1,11 @@
1Package: libopie2 1Package: libopie2
2Files: 2Files:
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libopiecore2 (1.8.1), libopiedb2 (1.8.1), libopiemm2 (1.8.1), libopienet2 (1.8.1), libopiepim2 (1.8.1), libopieui2 (1.8.1) 8Depends: libopiecore2 (1.8.2), libopiedb2 (1.8.2), libopiemm2 (1.8.2), libopienet2 (1.8.2), libopiepim2 (1.8.2), libopieui2 (1.8.2)
9Provides: libopie2 9Provides: libopie2
10Description: Opie library 2.0 10Description: Opie library 2.0
11 11
diff --git a/libopie2/opiecore/libopiecore2.control b/libopie2/opiecore/libopiecore2.control
index 7dec1b9..956d24f 100644
--- a/libopie2/opiecore/libopiecore2.control
+++ b/libopie2/opiecore/libopiecore2.control
@@ -1,11 +1,11 @@
1Package: libopiecore2 1Package: libopiecore2
2Files: $OPIEDIR/lib/libopiecore2.so.* 2Files: $OPIEDIR/lib/libopiecore2.so.*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1 8Depends: libqpe1
9Provides: libopiecore2 9Provides: libopiecore2
10Description: Opie library 2.0 CORE 10Description: Opie library 2.0 CORE
11 11
diff --git a/libopie2/opiecore/oconfig.cpp b/libopie2/opiecore/oconfig.cpp
index dc4d0b3..fb5eabb 100644
--- a/libopie2/opiecore/oconfig.cpp
+++ b/libopie2/opiecore/oconfig.cpp
@@ -1,201 +1,203 @@
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 Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the config classes from the KDE Project which are 5 Inspired by the config classes from the KDE Project which are
6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32/* QT */ 32/* QT */
33 33
34#include <qfont.h> 34#include <qfont.h>
35#include <qcolor.h> 35#include <qcolor.h>
36 36
37/* OPIE */ 37/* OPIE */
38 38
39#include <opie2/oconfig.h> 39#include <opie2/oconfig.h>
40 40
41OConfig::OConfig( const QString &name, Domain domain ) 41OConfig::OConfig( const QString &name, Domain domain )
42 :OpieConfig( name, domain ) 42 :Config( name, domain )
43{ 43{
44 qDebug( "OConfig::OConfig()" );
44} 45}
45 46
46OConfig::~OConfig() 47OConfig::~OConfig()
47{ 48{
49 qDebug( "OConfig::~OConfig()" );
48} 50}
49 51
50QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const 52QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const
51{ 53{
52 QColor aRetColor; 54 QColor aRetColor;
53 int nRed = 0, nGreen = 0, nBlue = 0; 55 int nRed = 0, nGreen = 0, nBlue = 0;
54 56
55 QString aValue = readEntry( key ); 57 QString aValue = readEntry( key );
56 if( !aValue.isEmpty() ) 58 if( !aValue.isEmpty() )
57 { 59 {
58 if ( aValue.at(0) == '#' ) 60 if ( aValue.at(0) == '#' )
59 { 61 {
60 aRetColor.setNamedColor(aValue); 62 aRetColor.setNamedColor(aValue);
61 } 63 }
62 else 64 else
63 { 65 {
64 bool bOK; 66 bool bOK;
65 67
66 // find first part (red) 68 // find first part (red)
67 int nIndex = aValue.find( ',' ); 69 int nIndex = aValue.find( ',' );
68 70
69 if( nIndex == -1 ) 71 if( nIndex == -1 )
70 { 72 {
71 // return a sensible default -- Bernd 73 // return a sensible default -- Bernd
72 if( pDefault ) 74 if( pDefault )
73 aRetColor = *pDefault; 75 aRetColor = *pDefault;
74 return aRetColor; 76 return aRetColor;
75 } 77 }
76 78
77 nRed = aValue.left( nIndex ).toInt( &bOK ); 79 nRed = aValue.left( nIndex ).toInt( &bOK );
78 80
79 // find second part (green) 81 // find second part (green)
80 int nOldIndex = nIndex; 82 int nOldIndex = nIndex;
81 nIndex = aValue.find( ',', nOldIndex+1 ); 83 nIndex = aValue.find( ',', nOldIndex+1 );
82 84
83 if( nIndex == -1 ) 85 if( nIndex == -1 )
84 { 86 {
85 // return a sensible default -- Bernd 87 // return a sensible default -- Bernd
86 if( pDefault ) 88 if( pDefault )
87 aRetColor = *pDefault; 89 aRetColor = *pDefault;
88 return aRetColor; 90 return aRetColor;
89 } 91 }
90 nGreen = aValue.mid( nOldIndex+1, 92 nGreen = aValue.mid( nOldIndex+1,
91 nIndex-nOldIndex-1 ).toInt( &bOK ); 93 nIndex-nOldIndex-1 ).toInt( &bOK );
92 94
93 // find third part (blue) 95 // find third part (blue)
94 nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK ); 96 nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK );
95 97
96 aRetColor.setRgb( nRed, nGreen, nBlue ); 98 aRetColor.setRgb( nRed, nGreen, nBlue );
97 } 99 }
98 } 100 }
99 else { 101 else {
100 102
101 if( pDefault ) 103 if( pDefault )
102 aRetColor = *pDefault; 104 aRetColor = *pDefault;
103 } 105 }
104 106
105 return aRetColor; 107 return aRetColor;
106} 108}
107 109
108// FIXME: The whole font handling has to be revised for Opie 110// FIXME: The whole font handling has to be revised for Opie
109 111
110QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const 112QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const
111{ 113{
112 /* 114 /*
113 QFont aRetFont; 115 QFont aRetFont;
114 116
115 QString aValue = readEntry( key ); 117 QString aValue = readEntry( key );
116 if( !aValue.isNull() ) { 118 if( !aValue.isNull() ) {
117 if ( aValue.contains( ',' ) > 5 ) { 119 if ( aValue.contains( ',' ) > 5 ) {
118 // KDE3 and upwards entry 120 // KDE3 and upwards entry
119 if ( !aRetFont.fromString( aValue ) && pDefault ) 121 if ( !aRetFont.fromString( aValue ) && pDefault )
120 aRetFont = *pDefault; 122 aRetFont = *pDefault;
121 } 123 }
122 else { 124 else {
123 // backward compatibility with older font formats 125 // backward compatibility with older font formats
124 // ### remove KDE 3.1 ? 126 // ### remove KDE 3.1 ?
125 // find first part (font family) 127 // find first part (font family)
126 int nIndex = aValue.find( ',' ); 128 int nIndex = aValue.find( ',' );
127 if( nIndex == -1 ){ 129 if( nIndex == -1 ){
128 if( pDefault ) 130 if( pDefault )
129 aRetFont = *pDefault; 131 aRetFont = *pDefault;
130 return aRetFont; 132 return aRetFont;
131 } 133 }
132 aRetFont.setFamily( aValue.left( nIndex ) ); 134 aRetFont.setFamily( aValue.left( nIndex ) );
133 135
134 // find second part (point size) 136 // find second part (point size)
135 int nOldIndex = nIndex; 137 int nOldIndex = nIndex;
136 nIndex = aValue.find( ',', nOldIndex+1 ); 138 nIndex = aValue.find( ',', nOldIndex+1 );
137 if( nIndex == -1 ){ 139 if( nIndex == -1 ){
138 if( pDefault ) 140 if( pDefault )
139 aRetFont = *pDefault; 141 aRetFont = *pDefault;
140 return aRetFont; 142 return aRetFont;
141 } 143 }
142 144
143 aRetFont.setPointSize( aValue.mid( nOldIndex+1, 145 aRetFont.setPointSize( aValue.mid( nOldIndex+1,
144 nIndex-nOldIndex-1 ).toInt() ); 146 nIndex-nOldIndex-1 ).toInt() );
145 147
146 // find third part (style hint) 148 // find third part (style hint)
147 nOldIndex = nIndex; 149 nOldIndex = nIndex;
148 nIndex = aValue.find( ',', nOldIndex+1 ); 150 nIndex = aValue.find( ',', nOldIndex+1 );
149 151
150 if( nIndex == -1 ){ 152 if( nIndex == -1 ){
151 if( pDefault ) 153 if( pDefault )
152 aRetFont = *pDefault; 154 aRetFont = *pDefault;
153 return aRetFont; 155 return aRetFont;
154 } 156 }
155 157
156 aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); 158 aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() );
157 159
158 // find fourth part (char set) 160 // find fourth part (char set)
159 nOldIndex = nIndex; 161 nOldIndex = nIndex;
160 nIndex = aValue.find( ',', nOldIndex+1 ); 162 nIndex = aValue.find( ',', nOldIndex+1 );
161 163
162 if( nIndex == -1 ){ 164 if( nIndex == -1 ){
163 if( pDefault ) 165 if( pDefault )
164 aRetFont = *pDefault; 166 aRetFont = *pDefault;
165 return aRetFont; 167 return aRetFont;
166 } 168 }
167 169
168 QString chStr=aValue.mid( nOldIndex+1, 170 QString chStr=aValue.mid( nOldIndex+1,
169 nIndex-nOldIndex-1 ); 171 nIndex-nOldIndex-1 );
170 // find fifth part (weight) 172 // find fifth part (weight)
171 nOldIndex = nIndex; 173 nOldIndex = nIndex;
172 nIndex = aValue.find( ',', nOldIndex+1 ); 174 nIndex = aValue.find( ',', nOldIndex+1 );
173 175
174 if( nIndex == -1 ){ 176 if( nIndex == -1 ){
175 if( pDefault ) 177 if( pDefault )
176 aRetFont = *pDefault; 178 aRetFont = *pDefault;
177 return aRetFont; 179 return aRetFont;
178 } 180 }
179 181
180 aRetFont.setWeight( aValue.mid( nOldIndex+1, 182 aRetFont.setWeight( aValue.mid( nOldIndex+1,
181 nIndex-nOldIndex-1 ).toUInt() ); 183 nIndex-nOldIndex-1 ).toUInt() );
182 184
183 // find sixth part (font bits) 185 // find sixth part (font bits)
184 uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); 186 uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
185 187
186 aRetFont.setItalic( nFontBits & 0x01 ); 188 aRetFont.setItalic( nFontBits & 0x01 );
187 aRetFont.setUnderline( nFontBits & 0x02 ); 189 aRetFont.setUnderline( nFontBits & 0x02 );
188 aRetFont.setStrikeOut( nFontBits & 0x04 ); 190 aRetFont.setStrikeOut( nFontBits & 0x04 );
189 aRetFont.setFixedPitch( nFontBits & 0x08 ); 191 aRetFont.setFixedPitch( nFontBits & 0x08 );
190 aRetFont.setRawMode( nFontBits & 0x20 ); 192 aRetFont.setRawMode( nFontBits & 0x20 );
191 } 193 }
192 } 194 }
193 else 195 else
194 { 196 {
195 if( pDefault ) 197 if( pDefault )
196 aRetFont = *pDefault; 198 aRetFont = *pDefault;
197 } 199 }
198 return aRetFont; 200 return aRetFont;
199 */ 201 */
200 return QFont("Helvetica",10); 202 return QFont("Helvetica",10);
201} 203}
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index 75aa170..444d280 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -1,140 +1,140 @@
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 Inspired by the config classes from the KDE Project which are 5 Inspired by the config classes from the KDE Project which are
6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32#ifndef OCONFIG_H 32#ifndef OCONFIG_H
33#define OCONFIG_H 33#define OCONFIG_H
34 34
35//FIXME: Implement for X11 or reuse libqpe/Config there also? 35//FIXME: Implement for X11 or reuse libqpe/Config there also?
36//FIXME: Or rather use QSettings also for libqpe? 36//FIXME: Or rather use QSettings also for libqpe?
37 37
38#include "opieconfig.h" 38#include <qpe/config.h>
39 39
40class QColor; 40class QColor;
41class QFont; 41class QFont;
42 42
43/** 43/**
44 * A Configuration class based on the Qtopia @ref Config class 44 * A Configuration class based on the Qtopia @ref Config class
45 * featuring additional handling of color and font entries 45 * featuring additional handling of color and font entries
46 */ 46 */
47 47
48class OConfig : public OpieConfig 48class OConfig : public Config
49{ 49{
50 public: 50 public:
51 /** 51 /**
52 * Constructs a OConfig object with a @a name. 52 * Constructs a OConfig object with a @a name.
53 */ 53 */
54 OConfig( const QString &name, Domain domain = User ); 54 OConfig( const QString &name, Domain domain = User );
55 /** 55 /**
56 * Destructs the OConfig object. 56 * Destructs the OConfig object.
57 * 57 *
58 * Writes back any dirty configuration entries, and destroys 58 * Writes back any dirty configuration entries, and destroys
59 * dynamically created objects. 59 * dynamically created objects.
60 */ 60 */
61 virtual ~OConfig(); 61 virtual ~OConfig();
62 /** 62 /**
63 * @returns the name of the current group. 63 * @returns the name of the current group.
64 * The current group is used for searching keys and accessing entries. 64 * The current group is used for searching keys and accessing entries.
65 */ 65 */
66 const QString& group() { return OpieConfig::group(); }; 66 const QString& group() { return git.key(); };
67 /** 67 /**
68 * @returns a @ref QColor entry or a @a default value if the key is not found. 68 * @returns a @ref QColor entry or a @a default value if the key is not found.
69 */ 69 */
70 QColor readColorEntry( const QString& key, const QColor* pDefault ) const; 70 QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
71 /** 71 /**
72 * @returns a @ref QFont value or a @a default value if the key is not found. 72 * @returns a @ref QFont value or a @a default value if the key is not found.
73 */ 73 */
74 QFont readFontEntry( const QString& key, const QFont* pDefault ) const; 74 QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
75}; 75};
76 76
77/** 77/**
78 * @brief Helper class for easier use of OConfig groups. 78 * @brief Helper class for easier use of OConfig groups.
79 * 79 *
80 * Careful programmers always set the group of a 80 * Careful programmers always set the group of a
81 * @ref OConfig object to the group they want to read from 81 * @ref OConfig object to the group they want to read from
82 * and set it back to the old one of afterwards. This is usually 82 * and set it back to the old one of afterwards. This is usually
83 * written as: 83 * written as:
84 * <pre> 84 * <pre>
85 * 85 *
86 * QString oldgroup config()->group(); 86 * QString oldgroup config()->group();
87 * config()->setGroup( "TheGroupThatIWant" ); 87 * config()->setGroup( "TheGroupThatIWant" );
88 * ... 88 * ...
89 * config()->writeEntry( "Blah", "Blubb" ); 89 * config()->writeEntry( "Blah", "Blubb" );
90 * 90 *
91 * config()->setGroup( oldgroup ); 91 * config()->setGroup( oldgroup );
92 * </pre> 92 * </pre>
93 * 93 *
94 * In order to facilitate this task, you can use 94 * In order to facilitate this task, you can use
95 * OConfigGroupSaver. Simply construct such an object ON THE STACK 95 * OConfigGroupSaver. Simply construct such an object ON THE STACK
96 * when you want to switch to a new group. Then, when the object goes 96 * when you want to switch to a new group. Then, when the object goes
97 * out of scope, the group will automatically be restored. If you 97 * out of scope, the group will automatically be restored. If you
98 * want to use several different groups within a function or method, 98 * want to use several different groups within a function or method,
99 * you can still use OConfigGroupSaver: Simply enclose all work with 99 * you can still use OConfigGroupSaver: Simply enclose all work with
100 * one group (including the creation of the OConfigGroupSaver object) 100 * one group (including the creation of the OConfigGroupSaver object)
101 * in one block. 101 * in one block.
102 * 102 *
103 * @author Matthias Kalle Dalheimer <Kalle@kde.org> 103 * @author Matthias Kalle Dalheimer <Kalle@kde.org>
104 * @version $Id$ 104 * @version $Id$
105 * @see OConfig 105 * @see OConfig
106 */ 106 */
107 107
108class OConfigGroupSaver 108class OConfigGroupSaver
109{ 109{
110 public: 110 public:
111 /** 111 /**
112 * Constructor. 112 * Constructor.
113 * Create the object giving a @config object and a @a group to become 113 * Create the object giving a @config object and a @a group to become
114 * the current group. 114 * the current group.
115 */ 115 */
116 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) 116 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
117 { _config->setGroup( group ); } 117 { _config->setGroup( group ); }
118 118
119 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) 119 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
120 { _config->setGroup( group ); } 120 { _config->setGroup( group ); }
121 121
122 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) 122 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
123 { _config->setGroup( group ); } 123 { _config->setGroup( group ); }
124 /** 124 /**
125 * Destructor. 125 * Destructor.
126 * Restores the last current group. 126 * Restores the last current group.
127 */ 127 */
128 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } 128 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
129 129
130 OConfig* config() { return _config; }; 130 OConfig* config() { return _config; };
131 131
132 private: 132 private:
133 OConfig* _config; 133 OConfig* _config;
134 QString _oldgroup; 134 QString _oldgroup;
135 135
136 OConfigGroupSaver( const OConfigGroupSaver& ); 136 OConfigGroupSaver( const OConfigGroupSaver& );
137 OConfigGroupSaver& operator=( const OConfigGroupSaver& ); 137 OConfigGroupSaver& operator=( const OConfigGroupSaver& );
138}; 138};
139 139
140#endif // OCONFIG_H 140#endif // OCONFIG_H
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index b2a37bc..4505ce7 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -1,632 +1,631 @@
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@tm.informatik.uni-frankfurt.de) 3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
4 Inspired by the KDE debug classes, which are
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
6 (C) 2002 Holger Freyther (freyther@kde.org) 4 (C) 2002 Holger Freyther (freyther@kde.org)
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
7 =. 6 =.
8 .=l. 7 .=l.
9           .>+-= 8           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 15    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 22++=   -.     .`     .: details.
24 :     =  ...= . :.=- 23 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
31*/ 30*/
32 31
33// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo 32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo
34// functions inlined to noops (which would then conflict with their definition here). 33// functions inlined to noops (which would then conflict with their definition here).
35 34
36#include <opie2/odebug.h> 35#include <opie2/odebug.h>
37 36
38#ifdef OPIE_NO_DEBUG 37#ifdef OPIE_NO_DEBUG
39#undef odDebug 38#undef odDebug
40#undef odBacktrace 39#undef odBacktrace
41#endif 40#endif
42 41
43/* OPIE */ 42/* OPIE */
44 43
45#include <opie2/oapplication.h> 44#include <opie2/oapplication.h>
46#include <opie2/oglobalsettings.h> 45#include <opie2/oglobalsettings.h>
47#include <opie2/oconfig.h> 46#include <opie2/oconfig.h>
48 47
49/* QT */ 48/* QT */
50 49
51#include <qbrush.h> 50#include <qbrush.h>
52#include <qdatetime.h> 51#include <qdatetime.h>
53#include <qfile.h> 52#include <qfile.h>
54#include <qhostaddress.h> 53#include <qhostaddress.h>
55#include <qmessagebox.h> 54#include <qmessagebox.h>
56#include <qintdict.h> 55#include <qintdict.h>
57#include <qpoint.h> 56#include <qpoint.h>
58#include <qrect.h> 57#include <qrect.h>
59#include <qregion.h> 58#include <qregion.h>
60#include <qsize.h> 59#include <qsize.h>
61#include <qsocketdevice.h> 60#include <qsocketdevice.h>
62#include <qstring.h> 61#include <qstring.h>
63#include <qstringlist.h> 62#include <qstringlist.h>
64#include <qtextstream.h> 63#include <qtextstream.h>
65 64
66/* UNIX */ 65/* UNIX */
67 66
68#include <stdlib.h> // abort 67#include <stdlib.h> // abort
69#include <unistd.h> // getpid 68#include <unistd.h> // getpid
70#include <stdarg.h> // vararg stuff 69#include <stdarg.h> // vararg stuff
71#include <ctype.h> // isprint 70#include <ctype.h> // isprint
72#include <syslog.h> 71#include <syslog.h>
73#include <errno.h> 72#include <errno.h>
74#include <string.h> 73#include <string.h>
75 74
76#ifndef OPIE_NO_BACKTRACE 75#ifndef OPIE_NO_BACKTRACE
77#include <execinfo.h> 76#include <execinfo.h>
78#endif 77#endif
79 78
80 79
81/*====================================================================================== 80/*======================================================================================
82 * debug levels 81 * debug levels
83 *======================================================================================*/ 82 *======================================================================================*/
84 83
85enum DebugLevels { 84enum DebugLevels {
86 ODEBUG_INFO = 0, 85 ODEBUG_INFO = 0,
87 ODEBUG_WARN = 1, 86 ODEBUG_WARN = 1,
88 ODEBUG_ERROR = 2, 87 ODEBUG_ERROR = 2,
89 ODEBUG_FATAL = 3 88 ODEBUG_FATAL = 3
90}; 89};
91 90
92/*====================================================================================== 91/*======================================================================================
93 * oDebug private data 92 * oDebug private data
94 *======================================================================================*/ 93 *======================================================================================*/
95 94
96/*====================================================================================== 95/*======================================================================================
97 * the main debug function 96 * the main debug function
98 *======================================================================================*/ 97 *======================================================================================*/
99 98
100static void oDebugBackend( unsigned short level, unsigned int area, const char *data) 99static void oDebugBackend( unsigned short level, unsigned int area, const char *data)
101{ 100{
102 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 101 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
103 102
104 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 103 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
105 // ML: example use. I think it's not necessary to implement such a strategy here. 104 // ML: example use. I think it's not necessary to implement such a strategy here.
106 // ML: Comments? 105 // ML: Comments?
107 106
108 int priority = 0; 107 int priority = 0;
109 QString caption; 108 QString caption;
110 QString lev; 109 QString lev;
111 switch( level ) 110 switch( level )
112 { 111 {
113 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 112 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
114 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 113 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
115 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 114 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
116 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 115 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
117 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 116 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
118 } 117 }
119 118
120 short output = OGlobalSettings::debugMode(); 119 short output = OGlobalSettings::debugMode();
121 if (!oApp && (output == 1)) 120 if (!oApp && (output == 1))
122 { 121 {
123 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 122 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
124 output = 2; // need an application object to use MsgBox 123 output = 2; // need an application object to use MsgBox
125 } 124 }
126 125
127 // gcc 2.9x is dumb and sucks... can you hear it? 126 // gcc 2.9x is dumb and sucks... can you hear it?
128 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 127 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
129 QString areaName; 128 QString areaName;
130 if ( oApp ) areaName = oApp->appName(); 129 if ( oApp ) areaName = oApp->appName();
131 else areaName = "<unknown>"; 130 else areaName = "<unknown>";
132 131
133 // Output 132 // Output
134 switch( output ) 133 switch( output )
135 { 134 {
136 case -1: // ignore 135 case -1: // ignore
137 { 136 {
138 return; 137 return;
139 } 138 }
140 case 0: // File 139 case 0: // File
141 { 140 {
142 QString outputFilename = OGlobalSettings::debugOutput(); 141 QString outputFilename = OGlobalSettings::debugOutput();
143 142
144 const int BUFSIZE = 4096; 143 const int BUFSIZE = 4096;
145 char buf[BUFSIZE] = ""; 144 char buf[BUFSIZE] = "";
146 buf[BUFSIZE-1] = '\0'; 145 buf[BUFSIZE-1] = '\0';
147 int nSize; 146 int nSize;
148 147
149 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); 148 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data);
150 149
151 QFile outputFile( outputFilename ); 150 QFile outputFile( outputFilename );
152 if ( outputFile.open( IO_WriteOnly | IO_Append ) ) 151 if ( outputFile.open( IO_WriteOnly | IO_Append ) )
153 { 152 {
154 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) 153 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) )
155 { 154 {
156 outputFile.writeBlock( buf, BUFSIZE-1 ); 155 outputFile.writeBlock( buf, BUFSIZE-1 );
157 } 156 }
158 else 157 else
159 { 158 {
160 outputFile.writeBlock( buf, nSize ); 159 outputFile.writeBlock( buf, nSize );
161 } 160 }
162 } 161 }
163 else 162 else
164 { 163 {
165 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) ); 164 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) );
166 } 165 }
167 break; 166 break;
168 } // automatic close of file here 167 } // automatic close of file here
169 168
170 case 1: // Message Box 169 case 1: // Message Box
171 { 170 {
172 // Since we are in opiecore here, we cannot use OMsgBox and use 171 // Since we are in opiecore here, we cannot use OMsgBox and use
173 // QMessageBox instead 172 // QMessageBox instead
174 173
175 caption += QString("(") + areaName + ")"; 174 caption += QString("(") + areaName + ")";
176 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr? 175 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr?
177 break; 176 break;
178 } 177 }
179 178
180 case 2: // Shell 179 case 2: // Shell
181 { 180 {
182 FILE *output = stderr; 181 FILE *output = stderr;
183 fprintf( output, "%s: ", (const char*) areaName ); 182 fprintf( output, "%s: ", (const char*) areaName );
184 fputs( data, output); 183 fputs( data, output);
185 break; 184 break;
186 } 185 }
187 186
188 case 3: // syslog 187 case 3: // syslog
189 { 188 {
190 syslog( priority, "%s", data); 189 syslog( priority, "%s", data);
191 break; 190 break;
192 } 191 }
193 192
194 case 4: // socket 193 case 4: // socket
195 { 194 {
196 QString destination = OGlobalSettings::debugOutput(); 195 QString destination = OGlobalSettings::debugOutput();
197 if ( destination && destination.find(":") != -1 ) 196 if ( destination && destination.find(":") != -1 )
198 { 197 {
199 QString host = destination.left( destination.find(":") ); 198 QString host = destination.left( destination.find(":") );
200 QString port = destination.right( destination.length()-host.length()-1 ); 199 QString port = destination.right( destination.length()-host.length()-1 );
201 QHostAddress addr; 200 QHostAddress addr;
202 addr.setAddress( host ); 201 addr.setAddress( host );
203 // TODO: sanity check the address 202 // TODO: sanity check the address
204 QString line; 203 QString line;
205 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data ); 204 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data );
206 QSocketDevice s( QSocketDevice::Datagram ); 205 QSocketDevice s( QSocketDevice::Datagram );
207 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() ); 206 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() );
208 if ( result == -1 ) 207 if ( result == -1 )
209 { 208 {
210 qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) ); 209 qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) );
211 } 210 }
212 } 211 }
213 break; 212 break;
214 } 213 }
215 } 214 }
216 215
217 // check if we should abort 216 // check if we should abort
218 217
219 /* 218 /*
220 219
221 if( ( nLevel == ODEBUG_FATAL ) 220 if( ( nLevel == ODEBUG_FATAL )
222 && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) ) 221 && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) )
223 abort(); 222 abort();
224 223
225 */ 224 */
226} 225}
227 226
228/*====================================================================================== 227/*======================================================================================
229 * odbgstream 228 * odbgstream
230 *======================================================================================*/ 229 *======================================================================================*/
231 230
232odbgstream& perror( odbgstream &s) 231odbgstream& perror( odbgstream &s)
233{ 232{
234 return s << QString::fromLocal8Bit(strerror(errno)); 233 return s << QString::fromLocal8Bit(strerror(errno));
235} 234}
236 235
237odbgstream odDebug(int area) 236odbgstream odDebug(int area)
238{ 237{
239 return odbgstream(area, ODEBUG_INFO); 238 return odbgstream(area, ODEBUG_INFO);
240} 239}
241odbgstream odDebug(bool cond, int area) 240odbgstream odDebug(bool cond, int area)
242{ 241{
243 if (cond) return odbgstream(area, ODEBUG_INFO); 242 if (cond) return odbgstream(area, ODEBUG_INFO);
244 else return odbgstream(0, 0, false); 243 else return odbgstream(0, 0, false);
245} 244}
246 245
247odbgstream odError(int area) 246odbgstream odError(int area)
248{ 247{
249 return odbgstream("ERROR: ", area, ODEBUG_ERROR); 248 return odbgstream("ERROR: ", area, ODEBUG_ERROR);
250} 249}
251 250
252odbgstream odError(bool cond, int area) 251odbgstream odError(bool cond, int area)
253{ 252{
254 if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false); 253 if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false);
255} 254}
256 255
257odbgstream odWarning(int area) 256odbgstream odWarning(int area)
258{ 257{
259 return odbgstream("WARNING: ", area, ODEBUG_WARN); 258 return odbgstream("WARNING: ", area, ODEBUG_WARN);
260} 259}
261 260
262odbgstream odWarning(bool cond, int area) 261odbgstream odWarning(bool cond, int area)
263{ 262{
264 if (cond) return odbgstream("WARNING: ", area, ODEBUG_WARN); else return odbgstream(0,0,false); 263 if (cond) return odbgstream("WARNING: ", area, ODEBUG_WARN); else return odbgstream(0,0,false);
265} 264}
266 265
267odbgstream odFatal(int area) 266odbgstream odFatal(int area)
268{ 267{
269 return odbgstream("FATAL: ", area, ODEBUG_FATAL); 268 return odbgstream("FATAL: ", area, ODEBUG_FATAL);
270} 269}
271 270
272odbgstream odFatal(bool cond, int area) 271odbgstream odFatal(bool cond, int area)
273{ 272{
274 if (cond) return odbgstream("FATAL: ", area, ODEBUG_FATAL); else return odbgstream(0,0,false); 273 if (cond) return odbgstream("FATAL: ", area, ODEBUG_FATAL); else return odbgstream(0,0,false);
275} 274}
276 275
277odbgstream::odbgstream(unsigned int _area, unsigned int _level, bool _print) 276odbgstream::odbgstream(unsigned int _area, unsigned int _level, bool _print)
278 :area(_area), level(_level), print(_print) 277 :area(_area), level(_level), print(_print)
279{ 278{
280} 279}
281 280
282 281
283odbgstream::odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print) 282odbgstream::odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print)
284 :output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) 283 :output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print)
285{ 284{
286} 285}
287 286
288 287
289odbgstream::odbgstream(odbgstream &str) 288odbgstream::odbgstream(odbgstream &str)
290 :output(str.output), area(str.area), level(str.level), print(str.print) 289 :output(str.output), area(str.area), level(str.level), print(str.print)
291{ 290{
292 str.output.truncate(0); 291 str.output.truncate(0);
293} 292}
294 293
295 294
296odbgstream::odbgstream(const odbgstream &str) 295odbgstream::odbgstream(const odbgstream &str)
297 :output(str.output), area(str.area), level(str.level), print(str.print) 296 :output(str.output), area(str.area), level(str.level), print(str.print)
298{ 297{
299} 298}
300 299
301odbgstream& odbgstream::operator<<(bool i) 300odbgstream& odbgstream::operator<<(bool i)
302{ 301{
303 if (!print) return *this; 302 if (!print) return *this;
304 output += QString::fromLatin1(i ? "true" : "false"); 303 output += QString::fromLatin1(i ? "true" : "false");
305 return *this; 304 return *this;
306} 305}
307 306
308 307
309odbgstream& odbgstream::operator<<(short i) 308odbgstream& odbgstream::operator<<(short i)
310{ 309{
311 if (!print) return *this; 310 if (!print) return *this;
312 QString tmp; tmp.setNum(i); output += tmp; 311 QString tmp; tmp.setNum(i); output += tmp;
313 return *this; 312 return *this;
314} 313}
315 314
316 315
317odbgstream& odbgstream::operator<<(unsigned short i) 316odbgstream& odbgstream::operator<<(unsigned short i)
318{ 317{
319 if (!print) return *this; 318 if (!print) return *this;
320 QString tmp; tmp.setNum(i); output += tmp; 319 QString tmp; tmp.setNum(i); output += tmp;
321 return *this; 320 return *this;
322} 321}
323 322
324 323
325odbgstream& odbgstream::operator<<(unsigned char i) 324odbgstream& odbgstream::operator<<(unsigned char i)
326{ 325{
327 return operator<<( static_cast<char>( i ) ); 326 return operator<<( static_cast<char>( i ) );
328} 327}
329 328
330 329
331odbgstream& odbgstream::operator<<(int i) 330odbgstream& odbgstream::operator<<(int i)
332{ 331{
333 if (!print) return *this; 332 if (!print) return *this;
334 QString tmp; tmp.setNum(i); output += tmp; 333 QString tmp; tmp.setNum(i); output += tmp;
335 return *this; 334 return *this;
336} 335}
337 336
338 337
339odbgstream& odbgstream::operator<<(unsigned int i) 338odbgstream& odbgstream::operator<<(unsigned int i)
340{ 339{
341 if (!print) return *this; 340 if (!print) return *this;
342 QString tmp; tmp.setNum(i); output += tmp; 341 QString tmp; tmp.setNum(i); output += tmp;
343 return *this; 342 return *this;
344} 343}
345 344
346 345
347odbgstream& odbgstream::operator<<(long i) 346odbgstream& odbgstream::operator<<(long i)
348{ 347{
349 if (!print) return *this; 348 if (!print) return *this;
350 QString tmp; tmp.setNum(i); output += tmp; 349 QString tmp; tmp.setNum(i); output += tmp;
351 return *this; 350 return *this;
352} 351}
353 352
354 353
355odbgstream& odbgstream::operator<<(unsigned long i) 354odbgstream& odbgstream::operator<<(unsigned long i)
356{ 355{
357 if (!print) return *this; 356 if (!print) return *this;
358 QString tmp; tmp.setNum(i); output += tmp; 357 QString tmp; tmp.setNum(i); output += tmp;
359 return *this; 358 return *this;
360} 359}
361 360
362 361
363odbgstream& odbgstream::operator<<(const QString& string) 362odbgstream& odbgstream::operator<<(const QString& string)
364{ 363{
365 if (!print) return *this; 364 if (!print) return *this;
366 output += string; 365 output += string;
367 if (output.at(output.length() -1 ) == '\n') 366 if (output.at(output.length() -1 ) == '\n')
368 flush(); 367 flush();
369 return *this; 368 return *this;
370} 369}
371 370
372 371
373odbgstream& odbgstream::operator<<(const char *string) 372odbgstream& odbgstream::operator<<(const char *string)
374{ 373{
375 if (!print) return *this; 374 if (!print) return *this;
376 output += QString::fromUtf8(string); 375 output += QString::fromUtf8(string);
377 if (output.at(output.length() - 1) == '\n') 376 if (output.at(output.length() - 1) == '\n')
378 flush(); 377 flush();
379 return *this; 378 return *this;
380} 379}
381 380
382 381
383odbgstream& odbgstream::operator<<(const QCString& string) 382odbgstream& odbgstream::operator<<(const QCString& string)
384{ 383{
385 *this << string.data(); 384 *this << string.data();
386 return *this; 385 return *this;
387} 386}
388 387
389 388
390odbgstream& odbgstream::operator<<(const void * p) 389odbgstream& odbgstream::operator<<(const void * p)
391{ 390{
392 form("%p", p); 391 form("%p", p);
393 return *this; 392 return *this;
394} 393}
395 394
396odbgstream& odbgstream::operator<<(double d) 395odbgstream& odbgstream::operator<<(double d)
397{ 396{
398 QString tmp; tmp.setNum(d); output += tmp; 397 QString tmp; tmp.setNum(d); output += tmp;
399 return *this; 398 return *this;
400} 399}
401 400
402/* 401/*
403odbgstream::odbgstream &form(const char *format, ...) 402odbgstream::odbgstream &form(const char *format, ...)
404#ifdef __GNUC__ 403#ifdef __GNUC__
405 __attribute__ ( ( format ( printf, 2, 3 ) ) ) 404 __attribute__ ( ( format ( printf, 2, 3 ) ) )
406#endif 405#endif
407 ; 406 ;
408*/ 407*/
409 408
410void odbgstream::flush() 409void odbgstream::flush()
411{ 410{
412 if ( output.isEmpty() || !print ) 411 if ( output.isEmpty() || !print )
413 { 412 {
414 return; 413 return;
415 } 414 }
416 else 415 else
417 { 416 {
418 oDebugBackend( level, area, output.local8Bit().data() ); 417 oDebugBackend( level, area, output.local8Bit().data() );
419 output = QString::null; 418 output = QString::null;
420 } 419 }
421} 420}
422 421
423odbgstream& odbgstream::form(const char *format, ...) 422odbgstream& odbgstream::form(const char *format, ...)
424{ 423{
425 char buf[4096]; 424 char buf[4096];
426 va_list arguments; 425 va_list arguments;
427 va_start( arguments, format ); 426 va_start( arguments, format );
428 buf[sizeof(buf)-1] = '\0'; 427 buf[sizeof(buf)-1] = '\0';
429 vsnprintf( buf, sizeof(buf)-1, format, arguments ); 428 vsnprintf( buf, sizeof(buf)-1, format, arguments );
430 va_end(arguments); 429 va_end(arguments);
431 *this << buf; 430 *this << buf;
432 return *this; 431 return *this;
433} 432}
434 433
435odbgstream::~odbgstream() 434odbgstream::~odbgstream()
436{ 435{
437 if (!output.isEmpty()) 436 if (!output.isEmpty())
438 { 437 {
439 fprintf(stderr, "ASSERT: debug output not ended with \\n\n"); 438 fprintf(stderr, "ASSERT: debug output not ended with \\n\n");
440 *this << "\n"; 439 *this << "\n";
441 } 440 }
442} 441}
443 442
444odbgstream& odbgstream::operator<<(char ch) 443odbgstream& odbgstream::operator<<(char ch)
445{ 444{
446 if (!print) return *this; 445 if (!print) return *this;
447 if (!isprint(ch)) 446 if (!isprint(ch))
448 { 447 {
449 output += "\\x" + QString::number( static_cast<uint>( ch ) + 0x100, 16 ).right(2); 448 output += "\\x" + QString::number( static_cast<uint>( ch ) + 0x100, 16 ).right(2);
450 } 449 }
451 else 450 else
452 { 451 {
453 output += ch; 452 output += ch;
454 if (ch == '\n') flush(); 453 if (ch == '\n') flush();
455 } 454 }
456 return *this; 455 return *this;
457} 456}
458 457
459odbgstream& odbgstream::operator<<( QWidget* widget ) 458odbgstream& odbgstream::operator<<( QWidget* widget )
460{ 459{
461 QString string, temp; 460 QString string, temp;
462 // ----- 461 // -----
463 if(widget==0) 462 if(widget==0)
464 { 463 {
465 string=(QString)"[Null pointer]"; 464 string=(QString)"[Null pointer]";
466 } else 465 } else
467 { 466 {
468 temp.setNum((ulong)widget, 16); 467 temp.setNum((ulong)widget, 16);
469 string=(QString)"["+widget->className()+" pointer " + "(0x" + temp + ")"; 468 string=(QString)"["+widget->className()+" pointer " + "(0x" + temp + ")";
470 if(widget->name(0)==0) 469 if(widget->name(0)==0)
471 { 470 {
472 string += " to unnamed widget, "; 471 string += " to unnamed widget, ";
473 } else 472 } else
474 { 473 {
475 string += (QString)" to widget " + widget->name() + ", "; 474 string += (QString)" to widget " + widget->name() + ", ";
476 } 475 }
477 string += "geometry=" 476 string += "geometry="
478 + QString().setNum(widget->width()) 477 + QString().setNum(widget->width())
479 + "x"+QString().setNum(widget->height()) 478 + "x"+QString().setNum(widget->height())
480 + "+"+QString().setNum(widget->x()) 479 + "+"+QString().setNum(widget->x())
481 + "+"+QString().setNum(widget->y()) 480 + "+"+QString().setNum(widget->y())
482 + "]"; 481 + "]";
483 } 482 }
484 if (!print) return *this; 483 if (!print) return *this;
485 484
486 output += string; 485 output += string;
487 if (output.at(output.length()-1) == '\n') 486 if (output.at(output.length()-1) == '\n')
488 { 487 {
489 flush(); 488 flush();
490 } 489 }
491 return *this; 490 return *this;
492} 491}
493 492
494/* 493/*
495 * either use 'output' directly and do the flush if needed 494 * either use 'output' directly and do the flush if needed
496 * or use the QString operator which calls the char* operator 495 * or use the QString operator which calls the char* operator
497 * 496 *
498 */ 497 */
499odbgstream& odbgstream::operator<<( const QDateTime& time) 498odbgstream& odbgstream::operator<<( const QDateTime& time)
500{ 499{
501 *this << time.toString(); 500 *this << time.toString();
502 return *this; 501 return *this;
503} 502}
504 503
505 504
506odbgstream& odbgstream::operator<<( const QDate& date) 505odbgstream& odbgstream::operator<<( const QDate& date)
507{ 506{
508 *this << date.toString(); 507 *this << date.toString();
509 508
510 return *this; 509 return *this;
511} 510}
512 511
513 512
514odbgstream& odbgstream::operator<<( const QTime& time ) 513odbgstream& odbgstream::operator<<( const QTime& time )
515{ 514{
516 *this << time.toString(); 515 *this << time.toString();
517 return *this; 516 return *this;
518} 517}
519 518
520 519
521odbgstream& odbgstream::operator<<( const QPoint& p ) 520odbgstream& odbgstream::operator<<( const QPoint& p )
522{ 521{
523 *this << "(" << p.x() << ", " << p.y() << ")"; 522 *this << "(" << p.x() << ", " << p.y() << ")";
524 return *this; 523 return *this;
525} 524}
526 525
527 526
528odbgstream& odbgstream::operator<<( const QSize& s ) 527odbgstream& odbgstream::operator<<( const QSize& s )
529{ 528{
530 *this << "[" << s.width() << "x" << s.height() << "]"; 529 *this << "[" << s.width() << "x" << s.height() << "]";
531 return *this; 530 return *this;
532} 531}
533 532
534 533
535odbgstream& odbgstream::operator<<( const QRect& r ) 534odbgstream& odbgstream::operator<<( const QRect& r )
536{ 535{
537 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]"; 536 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]";
538 return *this; 537 return *this;
539} 538}
540 539
541 540
542odbgstream& odbgstream::operator<<( const QRegion& reg ) 541odbgstream& odbgstream::operator<<( const QRegion& reg )
543{ 542{
544 /* Qt2 doesn't have a QMemArray... :( 543 /* Qt2 doesn't have a QMemArray... :(
545 *this << "[ "; 544 *this << "[ ";
546 QMemArray<QRect>rs=reg.rects(); 545 QMemArray<QRect>rs=reg.rects();
547 for (uint i=0;i<rs.size();++i) 546 for (uint i=0;i<rs.size();++i)
548 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ; 547 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ;
549 *this <<"]"; 548 *this <<"]";
550 */ 549 */
551 return *this; 550 return *this;
552} 551}
553 552
554 553
555odbgstream& odbgstream::operator<<( const QStringList& l ) 554odbgstream& odbgstream::operator<<( const QStringList& l )
556{ 555{
557 *this << "("; 556 *this << "(";
558 *this << l.join(","); 557 *this << l.join(",");
559 *this << ")"; 558 *this << ")";
560 559
561 return *this; 560 return *this;
562} 561}
563 562
564 563
565odbgstream& odbgstream::operator<<( const QColor& c ) 564odbgstream& odbgstream::operator<<( const QColor& c )
566{ 565{
567 if ( c.isValid() ) 566 if ( c.isValid() )
568 *this << c.name(); 567 *this << c.name();
569 else 568 else
570 *this << "(invalid/default)"; 569 *this << "(invalid/default)";
571 return *this; 570 return *this;
572} 571}
573 572
574 573
575odbgstream& odbgstream::operator<<( const QBrush& b) 574odbgstream& odbgstream::operator<<( const QBrush& b)
576{ 575{
577 static const char* const s_brushStyles[] = { 576 static const char* const s_brushStyles[] = {
578 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern", 577 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern",
579 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern", 578 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern",
580 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern", 579 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern",
581 "DiagCrossPattern" }; 580 "DiagCrossPattern" };
582 581
583 *this <<"[ style: "; 582 *this <<"[ style: ";
584 *this <<s_brushStyles[ b.style() ]; 583 *this <<s_brushStyles[ b.style() ];
585 *this <<" color: "; 584 *this <<" color: ";
586 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes) 585 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes)
587 if ( b.color().isValid() ) 586 if ( b.color().isValid() )
588 *this <<b.color().name() ; 587 *this <<b.color().name() ;
589 else 588 else
590 *this <<"(invalid/default)"; 589 *this <<"(invalid/default)";
591 if ( b.pixmap() ) 590 if ( b.pixmap() )
592 *this <<" has a pixmap"; 591 *this <<" has a pixmap";
593 *this <<" ]"; 592 *this <<" ]";
594 return *this; 593 return *this;
595} 594}
596 595
597 596
598 597
599QString odBacktrace( int levels ) 598QString odBacktrace( int levels )
600{ 599{
601 QString s; 600 QString s;
602#ifndef OPIE_NO_BACKTRACE 601#ifndef OPIE_NO_BACKTRACE
603 void* trace[256]; 602 void* trace[256];
604 int n = backtrace(trace, 256); 603 int n = backtrace(trace, 256);
605 char** strings = backtrace_symbols (trace, n); 604 char** strings = backtrace_symbols (trace, n);
606 605
607 if ( levels != -1 ) 606 if ( levels != -1 )
608 n = QMIN( n, levels ); 607 n = QMIN( n, levels );
609 s = "[\n"; 608 s = "[\n";
610 609
611 for (int i = 0; i < n; ++i) 610 for (int i = 0; i < n; ++i)
612 s += QString::number(i) + 611 s += QString::number(i) +
613 QString::fromLatin1(": ") + 612 QString::fromLatin1(": ") +
614 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n"); 613 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
615 s += "]\n"; 614 s += "]\n";
616 free (strings); 615 free (strings);
617#endif 616#endif
618 return s; 617 return s;
619} 618}
620 619
621void odClearDebugConfig() 620void odClearDebugConfig()
622{ 621{
623 /* 622 /*
624 delete oDebug_data->config; 623 delete oDebug_data->config;
625 oDebug_data->config = 0; 624 oDebug_data->config = 0;
626 */ 625 */
627} 626}
628 627
629#ifdef OPIE_NO_DEBUG 628#ifdef OPIE_NO_DEBUG
630#define odDebug ondDebug 629#define odDebug ondDebug
631#define odBacktrace ondBacktrace 630#define odBacktrace ondBacktrace
632#endif 631#endif
diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp
index f6071be..ae2fcb6 100644
--- a/libopie2/opiecore/oglobal.cpp
+++ b/libopie2/opiecore/oglobal.cpp
@@ -1,36 +1,43 @@
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 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (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#include <opie2/oglobal.h> 31#include <opie2/oglobal.h>
32 32
33OConfig* OGlobal::_config = 0;
34
33OConfig* OGlobal::config() 35OConfig* OGlobal::config()
34{ 36{
35 return globalconfig; 37 if ( !OGlobal::_config )
38 {
39 qDebug( "OGlobal::creating global configuration instance." );
40 OGlobal::_config = new OConfig( "global" );
41 }
42 return OGlobal::_config;
36} 43}
diff --git a/libopie2/opiecore/oglobal.h b/libopie2/opiecore/oglobal.h
index 23cedde..2dc4f9e 100644
--- a/libopie2/opiecore/oglobal.h
+++ b/libopie2/opiecore/oglobal.h
@@ -1,49 +1,49 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29*/ 28*/
30 29
31#ifndef OGLOBAL_H 30#ifndef OGLOBAL_H
32#define OGLOBAL_H 31#define OGLOBAL_H
33 32
34#include <qpe/global.h>
35#include <opie2/oconfig.h> 33#include <opie2/oconfig.h>
36 34
37static OConfig *globalconfig = new OConfig( "global" ); 35//FIXME Is it wise or even necessary to inherit OGlobal from Global?
38 36// once we totally skip libqpe it should ideally swallow Global -zecke
39//FIXME: Is it wise or even necessary to inherit OGlobal from Global? 37// You're right. I deleted global as the base class. -mickeyl
40// once we totally skip libqpe it should ideally swallow Global -zecke
41 38
42class OGlobal : public Global 39class OGlobal
43{ 40{
44 public: 41 public:
45 // do we want to put that into OApplication as in KApplication -zecke 42 //FIXME Do we want to put that into OApplication as in KApplication? -zecke
43 // We already have a per-application config in OApplication
44 // ( accessed through oApp->config() ), but this one is the global one! -mickeyl
46 static OConfig* config(); 45 static OConfig* config();
46 static OConfig* _config;
47}; 47};
48 48
49#endif // OGLOBAL_H 49#endif // OGLOBAL_H
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp
index 1799529..66adbd0 100644
--- a/libopie2/opiecore/oglobalsettings.cpp
+++ b/libopie2/opiecore/oglobalsettings.cpp
@@ -1,547 +1,548 @@
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 Inspired by the KDE globalsettings which are 5 Inspired by the KDE globalsettings which are
6 Copyright (C) 2000 David Faure <faure@kde.org> 6 Copyright (C) 2000 David Faure <faure@kde.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33/* OPIE */ 33/* OPIE */
34 34
35#include <opie2/oglobalsettings.h> 35#include <opie2/oglobalsettings.h>
36#include <opie2/oconfig.h> 36#include <opie2/oconfig.h>
37#include <opie2/oglobal.h> 37#include <opie2/oglobal.h>
38 38
39/* QT */ 39/* QT */
40 40
41#include <qobject.h>
41#include <qdir.h> 42#include <qdir.h>
42#include <qpixmap.h> 43#include <qpixmap.h>
43#include <qfontinfo.h> 44#include <qfontinfo.h>
44 45
45/* UNIX */ 46/* UNIX */
46 47
47#include <stdlib.h> 48#include <stdlib.h>
48 49
49QString* OGlobalSettings::s_desktopPath = 0; 50QString* OGlobalSettings::s_desktopPath = 0;
50QString* OGlobalSettings::s_autostartPath = 0; 51QString* OGlobalSettings::s_autostartPath = 0;
51QString* OGlobalSettings::s_trashPath = 0; 52QString* OGlobalSettings::s_trashPath = 0;
52QString* OGlobalSettings::s_documentPath = 0; 53QString* OGlobalSettings::s_documentPath = 0;
53QFont *OGlobalSettings::_generalFont = 0; 54QFont *OGlobalSettings::_generalFont = 0;
54QFont *OGlobalSettings::_fixedFont = 0; 55QFont *OGlobalSettings::_fixedFont = 0;
55QFont *OGlobalSettings::_toolBarFont = 0; 56QFont *OGlobalSettings::_toolBarFont = 0;
56QFont *OGlobalSettings::_menuFont = 0; 57QFont *OGlobalSettings::_menuFont = 0;
57QFont *OGlobalSettings::_windowTitleFont = 0; 58QFont *OGlobalSettings::_windowTitleFont = 0;
58QFont *OGlobalSettings::_taskbarFont = 0; 59QFont *OGlobalSettings::_taskbarFont = 0;
59 60
60QColor *OGlobalSettings::OpieGray = 0; 61QColor *OGlobalSettings::OpieGray = 0;
61QColor *OGlobalSettings::OpieHighlight = 0; 62QColor *OGlobalSettings::OpieHighlight = 0;
62QColor *OGlobalSettings::OpieAlternate = 0; 63QColor *OGlobalSettings::OpieAlternate = 0;
63 64
64OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; 65OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0;
65 66
66//FIXME: Add manipulators to the accessors 67//FIXME: Add manipulators to the accessors
67 68
68int OGlobalSettings::dndEventDelay() 69int OGlobalSettings::dndEventDelay()
69{ 70{
70 OConfig *c = OGlobal::config(); 71 OConfig *c = OGlobal::config();
71 OConfigGroupSaver cgs( c, "General" ); 72 OConfigGroupSaver cgs( c, "General" );
72 return c->readNumEntry("DndDelay", 2); 73 return c->readNumEntry("DndDelay", 2);
73} 74}
74 75
75bool OGlobalSettings::singleClick() 76bool OGlobalSettings::singleClick()
76{ 77{
77 OConfig *c = OGlobal::config(); 78 OConfig *c = OGlobal::config();
78 OConfigGroupSaver cgs( c, "OPIE" ); 79 OConfigGroupSaver cgs( c, "OPIE" );
79 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); 80 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK);
80} 81}
81 82
82bool OGlobalSettings::insertTearOffHandle() 83bool OGlobalSettings::insertTearOffHandle()
83{ 84{
84 OConfig *c = OGlobal::config(); 85 OConfig *c = OGlobal::config();
85 OConfigGroupSaver cgs( c, "OPIE" ); 86 OConfigGroupSaver cgs( c, "OPIE" );
86 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); 87 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES);
87} 88}
88 89
89bool OGlobalSettings::changeCursorOverIcon() 90bool OGlobalSettings::changeCursorOverIcon()
90{ 91{
91 OConfig *c = OGlobal::config(); 92 OConfig *c = OGlobal::config();
92 OConfigGroupSaver cgs( c, "OPIE" ); 93 OConfigGroupSaver cgs( c, "OPIE" );
93 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); 94 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR);
94} 95}
95 96
96bool OGlobalSettings::visualActivate() 97bool OGlobalSettings::visualActivate()
97{ 98{
98 OConfig *c = OGlobal::config(); 99 OConfig *c = OGlobal::config();
99 OConfigGroupSaver cgs( c, "OPIE" ); 100 OConfigGroupSaver cgs( c, "OPIE" );
100 return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); 101 return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE);
101} 102}
102 103
103unsigned int OGlobalSettings::visualActivateSpeed() 104unsigned int OGlobalSettings::visualActivateSpeed()
104{ 105{
105 OConfig *c = OGlobal::config(); 106 OConfig *c = OGlobal::config();
106 OConfigGroupSaver cgs( c, "OPIE" ); 107 OConfigGroupSaver cgs( c, "OPIE" );
107 return 108 return
108 c->readNumEntry( 109 c->readNumEntry(
109 "VisualActivateSpeed", 110 "VisualActivateSpeed",
110 OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 111 OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED
111 ); 112 );
112} 113}
113 114
114int OGlobalSettings::autoSelectDelay() 115int OGlobalSettings::autoSelectDelay()
115{ 116{
116 OConfig *c = OGlobal::config(); 117 OConfig *c = OGlobal::config();
117 OConfigGroupSaver cgs( c, "OPIE" ); 118 OConfigGroupSaver cgs( c, "OPIE" );
118 return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); 119 return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY);
119} 120}
120 121
121OGlobalSettings::Completion OGlobalSettings::completionMode() 122OGlobalSettings::Completion OGlobalSettings::completionMode()
122{ 123{
123 int completion; 124 int completion;
124 OConfig *c = OGlobal::config(); 125 OConfig *c = OGlobal::config();
125 OConfigGroupSaver cgs( c, "General" ); 126 OConfigGroupSaver cgs( c, "General" );
126 completion = c->readNumEntry("completionMode", -1); 127 completion = c->readNumEntry("completionMode", -1);
127 if ((completion < (int) CompletionNone) || 128 if ((completion < (int) CompletionNone) ||
128 (completion > (int) CompletionPopupAuto)) 129 (completion > (int) CompletionPopupAuto))
129 { 130 {
130 completion = (int) CompletionPopup; // Default 131 completion = (int) CompletionPopup; // Default
131 } 132 }
132 return (Completion) completion; 133 return (Completion) completion;
133} 134}
134 135
135 136
136bool OGlobalSettings::showContextMenusOnPress () 137bool OGlobalSettings::showContextMenusOnPress ()
137{ 138{
138 OConfig *c = OGlobal::config(); 139 OConfig *c = OGlobal::config();
139 OConfigGroupSaver cgs (c, "ContextMenus"); 140 OConfigGroupSaver cgs (c, "ContextMenus");
140 141
141 return cgs.config()->readBoolEntry("ShowOnPress", true); 142 return cgs.config()->readBoolEntry("ShowOnPress", true);
142} 143}
143 144
144 145
145int OGlobalSettings::contextMenuKey () 146int OGlobalSettings::contextMenuKey ()
146{ 147{
147 OConfig *c = OGlobal::config(); 148 OConfig *c = OGlobal::config();
148 OConfigGroupSaver cgs (c, "Shortcuts"); 149 OConfigGroupSaver cgs (c, "Shortcuts");
149 150
150 //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); 151 //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu"));
151 //return cut.keyCodeQt(); 152 //return cut.keyCodeQt();
152 153
153 return 0; // FIXME 154 return 0; // FIXME
154} 155}
155 156
156 157
157OGlobalSettings::Debug OGlobalSettings::debugMode() 158OGlobalSettings::Debug OGlobalSettings::debugMode()
158{ 159{
159 OConfig *c = OGlobal::config(); 160 OConfig *c = OGlobal::config();
160 OConfigGroupSaver cgs( c, "General" ); 161 OConfigGroupSaver cgs( c, "General" );
161 int debug = c->readNumEntry( "debugMode", -1 ); 162 int debug = c->readNumEntry( "debugMode", -1 );
162 if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) 163 if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) )
163 { 164 {
164 debug = (int) DebugStdErr; // Default 165 debug = (int) DebugStdErr; // Default
165 } 166 }
166 return (Debug) debug; 167 return (Debug) debug;
167} 168}
168 169
169 170
170QString OGlobalSettings::debugOutput() 171QString OGlobalSettings::debugOutput()
171{ 172{
172 OConfig *c = OGlobal::config(); 173 OConfig *c = OGlobal::config();
173 OConfigGroupSaver cgs( c, "General" ); 174 OConfigGroupSaver cgs( c, "General" );
174 QString deflt = QString::null; 175 QString deflt = QString::null;
175 switch( debugMode() ) 176 switch( debugMode() )
176 { 177 {
177 case DebugNone: break; // no additional information needed 178 case DebugNone: break; // no additional information needed
178 case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in 179 case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in
179 case DebugMsgBox: break; // no additional information needed 180 case DebugMsgBox: break; // no additional information needed
180 case DebugStdErr: break; // no additional information needed 181 case DebugStdErr: break; // no additional information needed
181 case DebugSysLog: break; // no additional information needed 182 case DebugSysLog: break; // no additional information needed
182 case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to 183 case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to
183 } 184 }
184 185
185 return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); 186 return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt );
186} 187}
187 188
188 189
189QColor OGlobalSettings::toolBarHighlightColor() 190QColor OGlobalSettings::toolBarHighlightColor()
190{ 191{
191 initColors(); 192 initColors();
192 OConfig *c = OGlobal::config(); 193 OConfig *c = OGlobal::config();
193 OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); 194 OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") );
194 return c->readColorEntry("HighlightColor", OpieHighlight); 195 return c->readColorEntry("HighlightColor", OpieHighlight);
195} 196}
196 197
197QColor OGlobalSettings::inactiveTitleColor() 198QColor OGlobalSettings::inactiveTitleColor()
198{ 199{
199 if (!OpieGray) OpieGray = new QColor(220, 220, 220); 200 if (!OpieGray) OpieGray = new QColor(220, 220, 220);
200 OConfig *c = OGlobal::config(); 201 OConfig *c = OGlobal::config();
201 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 202 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
202 return c->readColorEntry( "inactiveBackground", OpieGray ); 203 return c->readColorEntry( "inactiveBackground", OpieGray );
203} 204}
204 205
205QColor OGlobalSettings::inactiveTextColor() 206QColor OGlobalSettings::inactiveTextColor()
206{ 207{
207 OConfig *c = OGlobal::config(); 208 OConfig *c = OGlobal::config();
208 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 209 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
209 return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); 210 return c->readColorEntry( "inactiveForeground", &Qt::darkGray );
210} 211}
211 212
212QColor OGlobalSettings::activeTitleColor() 213QColor OGlobalSettings::activeTitleColor()
213{ 214{
214 initColors(); 215 initColors();
215 OConfig *c = OGlobal::config(); 216 OConfig *c = OGlobal::config();
216 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 217 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
217 return c->readColorEntry( "activeBackground", OpieHighlight); 218 return c->readColorEntry( "activeBackground", OpieHighlight);
218} 219}
219 220
220QColor OGlobalSettings::activeTextColor() 221QColor OGlobalSettings::activeTextColor()
221{ 222{
222 OConfig *c = OGlobal::config(); 223 OConfig *c = OGlobal::config();
223 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 224 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
224 return c->readColorEntry( "activeForeground", &Qt::white ); 225 return c->readColorEntry( "activeForeground", &Qt::white );
225} 226}
226 227
227int OGlobalSettings::contrast() 228int OGlobalSettings::contrast()
228{ 229{
229 OConfig *c = OGlobal::config(); 230 OConfig *c = OGlobal::config();
230 OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); 231 OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") );
231 return c->readNumEntry( "contrast", 7 ); 232 return c->readNumEntry( "contrast", 7 );
232} 233}
233 234
234// following functions should work in OPIE - how to sync with appearance changes? 235// following functions should work in OPIE - how to sync with appearance changes?
235 236
236QColor OGlobalSettings::baseColor() 237QColor OGlobalSettings::baseColor()
237{ 238{
238 OConfig *c = OGlobal::config(); 239 OConfig *c = OGlobal::config();
239 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 240 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
240 return c->readColorEntry( "Base", &Qt::white ); 241 return c->readColorEntry( "Base", &Qt::white );
241} 242}
242 243
243QColor OGlobalSettings::textColor() 244QColor OGlobalSettings::textColor()
244{ 245{
245 OConfig *c = OGlobal::config(); 246 OConfig *c = OGlobal::config();
246 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 247 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
247 return c->readColorEntry( "Text", &Qt::black ); 248 return c->readColorEntry( "Text", &Qt::black );
248} 249}
249 250
250QColor OGlobalSettings::highlightedTextColor() 251QColor OGlobalSettings::highlightedTextColor()
251{ 252{
252 OConfig *c = OGlobal::config(); 253 OConfig *c = OGlobal::config();
253 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 254 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
254 return c->readColorEntry( "HighlightedText", &Qt::white ); 255 return c->readColorEntry( "HighlightedText", &Qt::white );
255} 256}
256 257
257QColor OGlobalSettings::highlightColor() 258QColor OGlobalSettings::highlightColor()
258{ 259{
259 initColors(); 260 initColors();
260 OConfig *c = OGlobal::config(); 261 OConfig *c = OGlobal::config();
261 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 262 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
262 return c->readColorEntry( "Highlight", OpieHighlight ); 263 return c->readColorEntry( "Highlight", OpieHighlight );
263} 264}
264 265
265QColor OGlobalSettings::alternateBackgroundColor() 266QColor OGlobalSettings::alternateBackgroundColor()
266{ 267{
267 initColors(); 268 initColors();
268 OConfig *c = OGlobal::config(); 269 OConfig *c = OGlobal::config();
269 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 270 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
270 *OpieAlternate = calculateAlternateBackgroundColor( baseColor() ); 271 *OpieAlternate = calculateAlternateBackgroundColor( baseColor() );
271 return c->readColorEntry( "alternateBackground", OpieAlternate ); 272 return c->readColorEntry( "alternateBackground", OpieAlternate );
272} 273}
273 274
274QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base) 275QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base)
275{ 276{
276 if (base == Qt::white) 277 if (base == Qt::white)
277 return QColor(238,246,255); 278 return QColor(238,246,255);
278 else 279 else
279 { 280 {
280 int h, s, v; 281 int h, s, v;
281 base.hsv( &h, &s, &v ); 282 base.hsv( &h, &s, &v );
282 if (v > 128) 283 if (v > 128)
283 return base.dark(106); 284 return base.dark(106);
284 else if (base != Qt::black) 285 else if (base != Qt::black)
285 return base.light(110); 286 return base.light(110);
286 287
287 return QColor(32,32,32); 288 return QColor(32,32,32);
288 } 289 }
289} 290}
290 291
291QColor OGlobalSettings::linkColor() 292QColor OGlobalSettings::linkColor()
292{ 293{
293 initColors(); 294 initColors();
294 OConfig *c = OGlobal::config(); 295 OConfig *c = OGlobal::config();
295 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 296 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
296 return c->readColorEntry( "linkColor", OpieGray ); 297 return c->readColorEntry( "linkColor", OpieGray );
297} 298}
298 299
299QColor OGlobalSettings::visitedLinkColor() 300QColor OGlobalSettings::visitedLinkColor()
300{ 301{
301 OConfig *c = OGlobal::config(); 302 OConfig *c = OGlobal::config();
302 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 303 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
303 return c->readColorEntry( "visitedLinkColor", &Qt::magenta ); 304 return c->readColorEntry( "visitedLinkColor", &Qt::magenta );
304} 305}
305 306
306// FIXME: font stuff currently uses a different format in OPIE, so the 307// FIXME: font stuff currently uses a different format in OPIE, so the
307// functions below are not yet applicable. The whole font stuff for OPIE 308// functions below are not yet applicable. The whole font stuff for OPIE
308// has to be revised anyway 309// has to be revised anyway
309 310
310QFont OGlobalSettings::generalFont() 311QFont OGlobalSettings::generalFont()
311{ 312{
312 if (_generalFont) 313 if (_generalFont)
313 return *_generalFont; 314 return *_generalFont;
314 315
315 _generalFont = new QFont("helvetica", 10); 316 _generalFont = new QFont("helvetica", 10);
316 _generalFont->setPixelSize(10); 317 _generalFont->setPixelSize(10);
317 _generalFont->setStyleHint(QFont::SansSerif); 318 _generalFont->setStyleHint(QFont::SansSerif);
318 319
319 OConfig *c = OGlobal::config(); 320 OConfig *c = OGlobal::config();
320 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 321 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
321 *_generalFont = c->readFontEntry("font", _generalFont); 322 *_generalFont = c->readFontEntry("font", _generalFont);
322 323
323 return *_generalFont; 324 return *_generalFont;
324} 325}
325 326
326QFont OGlobalSettings::fixedFont() 327QFont OGlobalSettings::fixedFont()
327{ 328{
328 if (_fixedFont) 329 if (_fixedFont)
329 return *_fixedFont; 330 return *_fixedFont;
330 331
331 _fixedFont = new QFont("courier", 12); 332 _fixedFont = new QFont("courier", 12);
332 _fixedFont->setPixelSize(12); 333 _fixedFont->setPixelSize(12);
333 _fixedFont->setStyleHint(QFont::TypeWriter); 334 _fixedFont->setStyleHint(QFont::TypeWriter);
334 335
335 OConfig *c = OGlobal::config(); 336 OConfig *c = OGlobal::config();
336 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 337 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
337 *_fixedFont = c->readFontEntry("fixed", _fixedFont); 338 *_fixedFont = c->readFontEntry("fixed", _fixedFont);
338 339
339 return *_fixedFont; 340 return *_fixedFont;
340} 341}
341 342
342QFont OGlobalSettings::toolBarFont() 343QFont OGlobalSettings::toolBarFont()
343{ 344{
344 if(_toolBarFont) 345 if(_toolBarFont)
345 return *_toolBarFont; 346 return *_toolBarFont;
346 347
347 _toolBarFont = new QFont("helvetica", 10); 348 _toolBarFont = new QFont("helvetica", 10);
348 _toolBarFont->setPixelSize(10); 349 _toolBarFont->setPixelSize(10);
349 _toolBarFont->setStyleHint(QFont::SansSerif); 350 _toolBarFont->setStyleHint(QFont::SansSerif);
350 351
351 OConfig *c = OGlobal::config(); 352 OConfig *c = OGlobal::config();
352 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 353 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
353 *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont); 354 *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont);
354 355
355 return *_toolBarFont; 356 return *_toolBarFont;
356} 357}
357 358
358QFont OGlobalSettings::menuFont() 359QFont OGlobalSettings::menuFont()
359{ 360{
360 if(_menuFont) 361 if(_menuFont)
361 return *_menuFont; 362 return *_menuFont;
362 363
363 _menuFont = new QFont("helvetica", 12); 364 _menuFont = new QFont("helvetica", 12);
364 _menuFont->setPixelSize(12); 365 _menuFont->setPixelSize(12);
365 _menuFont->setStyleHint(QFont::SansSerif); 366 _menuFont->setStyleHint(QFont::SansSerif);
366 367
367 OConfig *c = OGlobal::config(); 368 OConfig *c = OGlobal::config();
368 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 369 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
369 *_menuFont = c->readFontEntry("menuFont", _menuFont); 370 *_menuFont = c->readFontEntry("menuFont", _menuFont);
370 371
371 return *_menuFont; 372 return *_menuFont;
372} 373}
373 374
374QFont OGlobalSettings::windowTitleFont() 375QFont OGlobalSettings::windowTitleFont()
375{ 376{
376 if(_windowTitleFont) 377 if(_windowTitleFont)
377 return *_windowTitleFont; 378 return *_windowTitleFont;
378 379
379 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold); 380 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold);
380 _windowTitleFont->setPixelSize(12); 381 _windowTitleFont->setPixelSize(12);
381 _windowTitleFont->setStyleHint(QFont::SansSerif); 382 _windowTitleFont->setStyleHint(QFont::SansSerif);
382 383
383 OConfig *c = OGlobal::config(); 384 OConfig *c = OGlobal::config();
384 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 385 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
385 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency 386 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency
386 387
387 return *_windowTitleFont; 388 return *_windowTitleFont;
388} 389}
389 390
390QFont OGlobalSettings::taskbarFont() 391QFont OGlobalSettings::taskbarFont()
391{ 392{
392 if(_taskbarFont) 393 if(_taskbarFont)
393 return *_taskbarFont; 394 return *_taskbarFont;
394 395
395 _taskbarFont = new QFont("helvetica", 8); 396 _taskbarFont = new QFont("helvetica", 8);
396 _taskbarFont->setPixelSize(8); 397 _taskbarFont->setPixelSize(8);
397 _taskbarFont->setStyleHint(QFont::SansSerif); 398 _taskbarFont->setStyleHint(QFont::SansSerif);
398 399
399 OConfig *c = OGlobal::config(); 400 OConfig *c = OGlobal::config();
400 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 401 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
401 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont); 402 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont);
402 403
403 return *_taskbarFont; 404 return *_taskbarFont;
404} 405}
405 406
406// FIXME: the whole path stuff has to be revised for OPIE 407// FIXME: the whole path stuff has to be revised for OPIE
407 408
408void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. 409void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here.
409{ 410{
410 if ( s_desktopPath != 0 ) 411 if ( s_desktopPath != 0 )
411 return; 412 return;
412 413
413 s_desktopPath = new QString(); 414 s_desktopPath = new QString();
414 s_autostartPath = new QString(); 415 s_autostartPath = new QString();
415 s_trashPath = new QString(); 416 s_trashPath = new QString();
416 s_documentPath = new QString(); 417 s_documentPath = new QString();
417 418
418 OConfig *config = OGlobal::config(); 419 OConfig *config = OGlobal::config();
419 //bool dollarExpansion = config->isDollarExpansion(); 420 //bool dollarExpansion = config->isDollarExpansion();
420 //config->setDollarExpansion(true); 421 //config->setDollarExpansion(true);
421 OConfigGroupSaver cgs( config, "Paths" ); 422 OConfigGroupSaver cgs( config, "Paths" );
422 423
423 // Desktop Path 424 // Desktop Path
424 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/"; 425 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/";
425 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath); 426 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath);
426 if ( (*s_desktopPath)[0] != '/' ) 427 if ( (*s_desktopPath)[0] != '/' )
427 s_desktopPath->prepend( QDir::homeDirPath() + "/" ); 428 s_desktopPath->prepend( QDir::homeDirPath() + "/" );
428 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath ); 429 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath );
429 if ( s_desktopPath->right(1) != "/") 430 if ( s_desktopPath->right(1) != "/")
430 *s_desktopPath += "/"; 431 *s_desktopPath += "/";
431 432
432 // Trash Path 433 // Trash Path
433 *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/"; 434 *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/";
434 *s_trashPath = config->readEntry( "Trash" , *s_trashPath); 435 *s_trashPath = config->readEntry( "Trash" , *s_trashPath);
435 if ( (*s_trashPath)[0] != '/' ) 436 if ( (*s_trashPath)[0] != '/' )
436 s_trashPath->prepend( QDir::homeDirPath() + "/" ); 437 s_trashPath->prepend( QDir::homeDirPath() + "/" );
437 *s_trashPath = QDir::cleanDirPath( *s_trashPath ); 438 *s_trashPath = QDir::cleanDirPath( *s_trashPath );
438 if ( s_trashPath->right(1) != "/") 439 if ( s_trashPath->right(1) != "/")
439 *s_trashPath += "/"; 440 *s_trashPath += "/";
440 // We need to save it in any case, in case the language changes later on, 441 // We need to save it in any case, in case the language changes later on,
441 if ( !config->hasKey( "Trash" ) ) 442 if ( !config->hasKey( "Trash" ) )
442 { 443 {
443 //config->writePathEntry( "Trash", *s_trashPath, true, true ); 444 //config->writePathEntry( "Trash", *s_trashPath, true, true );
444 config->writeEntry( "Trash", *s_trashPath ); 445 config->writeEntry( "Trash", *s_trashPath );
445 //config->sync(); 446 //config->sync();
446 } 447 }
447 448
448/* // Autostart Path 449/* // Autostart Path
449 *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/"; 450 *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/";
450 *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath); 451 *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath);
451 if ( (*s_autostartPath)[0] != '/' ) 452 if ( (*s_autostartPath)[0] != '/' )
452 s_autostartPath->prepend( QDir::homeDirPath() + "/" ); 453 s_autostartPath->prepend( QDir::homeDirPath() + "/" );
453 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath ); 454 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath );
454 if ( s_autostartPath->right(1) != "/") 455 if ( s_autostartPath->right(1) != "/")
455 *s_autostartPath += "/"; 456 *s_autostartPath += "/";
456*/ 457*/
457 // Document Path 458 // Document Path
458 *s_documentPath = QString::null; 459 *s_documentPath = QString::null;
459 *s_documentPath = config->readEntry( "Documents" , *s_documentPath); 460 *s_documentPath = config->readEntry( "Documents" , *s_documentPath);
460 if ( (*s_documentPath)[0] != '/' ) 461 if ( (*s_documentPath)[0] != '/' )
461 s_documentPath->prepend( QDir::homeDirPath() + "/" ); 462 s_documentPath->prepend( QDir::homeDirPath() + "/" );
462 *s_documentPath = QDir::cleanDirPath( *s_documentPath ); 463 *s_documentPath = QDir::cleanDirPath( *s_documentPath );
463 if ( s_documentPath->right(1) != "/") 464 if ( s_documentPath->right(1) != "/")
464 *s_documentPath += "/"; 465 *s_documentPath += "/";
465 466
466 //config->setDollarExpansion(dollarExpansion); 467 //config->setDollarExpansion(dollarExpansion);
467 468
468 // Make sure this app gets the notifications about those paths 469 // Make sure this app gets the notifications about those paths
469 //if (kapp) 470 //if (kapp)
470 //kapp->addKipcEventMask(KIPC::SettingsChanged); 471 //kapp->addKipcEventMask(KIPC::SettingsChanged);
471} 472}
472 473
473void OGlobalSettings::initColors() 474void OGlobalSettings::initColors()
474{ 475{
475 if ( !OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 ); 476 if ( !OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 );
476 if ( !OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 ); 477 if ( !OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 );
477 if ( !OpieGray ) OpieGray = new QColor( 220, 210, 215 ); 478 if ( !OpieGray ) OpieGray = new QColor( 220, 210, 215 );
478} 479}
479 480
480void OGlobalSettings::rereadFontSettings() 481void OGlobalSettings::rereadFontSettings()
481{ 482{
482 delete _generalFont; 483 delete _generalFont;
483 _generalFont = 0L; 484 _generalFont = 0L;
484 delete _fixedFont; 485 delete _fixedFont;
485 _fixedFont = 0L; 486 _fixedFont = 0L;
486 delete _menuFont; 487 delete _menuFont;
487 _menuFont = 0L; 488 _menuFont = 0L;
488 delete _toolBarFont; 489 delete _toolBarFont;
489 _toolBarFont = 0L; 490 _toolBarFont = 0L;
490 delete _windowTitleFont; 491 delete _windowTitleFont;
491 _windowTitleFont = 0L; 492 _windowTitleFont = 0L;
492 delete _taskbarFont; 493 delete _taskbarFont;
493 _taskbarFont = 0L; 494 _taskbarFont = 0L;
494} 495}
495 496
496void OGlobalSettings::rereadPathSettings() 497void OGlobalSettings::rereadPathSettings()
497{ 498{
498 qDebug( "OGlobalSettings::rereadPathSettings" ); 499 qDebug( "OGlobalSettings::rereadPathSettings" );
499 delete s_autostartPath; 500 delete s_autostartPath;
500 s_autostartPath = 0L; 501 s_autostartPath = 0L;
501 delete s_trashPath; 502 delete s_trashPath;
502 s_trashPath = 0L; 503 s_trashPath = 0L;
503 delete s_desktopPath; 504 delete s_desktopPath;
504 s_desktopPath = 0L; 505 s_desktopPath = 0L;
505 delete s_documentPath; 506 delete s_documentPath;
506 s_documentPath = 0L; 507 s_documentPath = 0L;
507} 508}
508 509
509OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings() 510OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings()
510{ 511{
511 if ( ! s_mouseSettings ) 512 if ( ! s_mouseSettings )
512 { 513 {
513 s_mouseSettings = new OMouseSettings; 514 s_mouseSettings = new OMouseSettings;
514 OMouseSettings & s = *s_mouseSettings; // for convenience 515 OMouseSettings & s = *s_mouseSettings; // for convenience
515 516
516 OConfigGroupSaver cgs( OGlobal::config(), "Mouse" ); 517 OConfigGroupSaver cgs( OGlobal::config(), "Mouse" );
517 QString setting = OGlobal::config()->readEntry("MouseButtonMapping"); 518 QString setting = OGlobal::config()->readEntry("MouseButtonMapping");
518 if (setting == "RightHanded") 519 if (setting == "RightHanded")
519 s.handed = OMouseSettings::RightHanded; 520 s.handed = OMouseSettings::RightHanded;
520 else if (setting == "LeftHanded") 521 else if (setting == "LeftHanded")
521 s.handed = OMouseSettings::LeftHanded; 522 s.handed = OMouseSettings::LeftHanded;
522 else 523 else
523 { 524 {
524 525
525 // FIXME: Implement for Opie / Qt Embedded 526 // FIXME: Implement for Opie / Qt Embedded
526 527
527 } 528 }
528 } 529 }
529 return *s_mouseSettings; 530 return *s_mouseSettings;
530} 531}
531 532
532void OGlobalSettings::rereadMouseSettings() 533void OGlobalSettings::rereadMouseSettings()
533{ 534{
534 delete s_mouseSettings; 535 delete s_mouseSettings;
535 s_mouseSettings = 0L; 536 s_mouseSettings = 0L;
536} 537}
537 538
538// FIXME: This won't be necessary, or will it? :-D 539// FIXME: This won't be necessary, or will it? :-D
539 540
540bool OGlobalSettings::isMultiHead() 541bool OGlobalSettings::isMultiHead()
541{ 542{
542 QCString multiHead = getenv("OPIE_MULTIHEAD"); 543 QCString multiHead = getenv("OPIE_MULTIHEAD");
543 if (!multiHead.isEmpty()) { 544 if (!multiHead.isEmpty()) {
544 return (multiHead.lower() == "true"); 545 return (multiHead.lower() == "true");
545 } 546 }
546 return false; 547 return false;
547} 548}
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro
index fe5800e..5d630ea 100644
--- a/libopie2/opiecore/opiecore.pro
+++ b/libopie2/opiecore/opiecore.pro
@@ -1,43 +1,43 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oapplication.h \ 4HEADERS = oapplication.h \
5 opieapplication.h \ 5 opieapplication.h \
6 oconfig.h \ 6 oconfig.h \
7 opieconfig.h \ 7 opieconfig.h \
8 ocompletionbase.h \ 8 ocompletionbase.h \
9 ocompletion.h \ 9 ocompletion.h \
10 odebug.h \ 10 odebug.h \
11 oglobal.h \ 11 oglobal.h \
12 oglobalsettings.h \ 12 oglobalsettings.h \
13 osortablevaluelist.h 13 osortablevaluelist.h
14 14
15 15
16SOURCES = oapplication.cpp \ 16SOURCES = oapplication.cpp \
17 opieapplication.cpp \ 17 opieapplication.cpp \
18 oconfig.cpp \ 18 oconfig.cpp \
19 opieconfig.cpp \ 19 opieconfig.cpp \
20 ocompletionbase.cpp \ 20 ocompletionbase.cpp \
21 ocompletion.cpp \ 21 ocompletion.cpp \
22 odebug.cpp \ 22 odebug.cpp \
23 oglobal.cpp \ 23 oglobal.cpp \
24 oglobalsettings.cpp 24 oglobalsettings.cpp
25 25
26INTERFACES = 26INTERFACES =
27TARGET = opiecore2 27TARGET = opiecore2
28VERSION = 1.8.1 28VERSION = 1.8.2
29INCLUDEPATH += $(OPIEDIR)/include 29INCLUDEPATH += $(OPIEDIR)/include
30DEPENDPATH += $(OPIEDIR)/include 30DEPENDPATH += $(OPIEDIR)/include
31MOC_DIR = moc 31MOC_DIR = moc
32OBJECTS_DIR = obj 32OBJECTS_DIR = obj
33 33
34 34
35!contains( platform, x11 ) { 35!contains( platform, x11 ) {
36 LIBS = -lqpe 36 LIBS = -lqpe
37 include ( $(OPIEDIR)/include.pro ) 37 include ( $(OPIEDIR)/include.pro )
38} 38}
39 39
40contains( platform, x11 ) { 40contains( platform, x11 ) {
41 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 41 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
42} 42}
43 43
diff --git a/libopie2/opiedb/libopiedb2.control b/libopie2/opiedb/libopiedb2.control
index 3fe3820..5500dc8 100644
--- a/libopie2/opiedb/libopiedb2.control
+++ b/libopie2/opiedb/libopiedb2.control
@@ -1,11 +1,11 @@
1Package: libopiedb2 1Package: libopiedb2
2Files: $OPIEDIR/lib/libopiedb2.so* 2Files: $OPIEDIR/lib/libopiedb2.so*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.1) 8Depends: libqpe1, libopiecore2 (1.8.2)
9Provides: libopiedb2 9Provides: libopiedb2
10Description: Opie library 2.0 DB 10Description: Opie library 2.0 DB
11 11
diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro
index 6a4e8f1..d869e6f 100644
--- a/libopie2/opiedb/opiedb.pro
+++ b/libopie2/opiedb/opiedb.pro
@@ -1,41 +1,41 @@
1TEMPLATE = lib 1TEMPLATE = lib
2#CONFIG += qt warn_on debug 2#CONFIG += qt warn_on debug
3CONFIG += qt warn_on release 3CONFIG += qt warn_on release
4DESTDIR = $(OPIEDIR)/lib 4DESTDIR = $(OPIEDIR)/lib
5HEADERS = osqlbackend.h \ 5HEADERS = osqlbackend.h \
6 osqldriver.h \ 6 osqldriver.h \
7 osqlerror.h \ 7 osqlerror.h \
8 osqlmanager.h \ 8 osqlmanager.h \
9 osqlquery.h \ 9 osqlquery.h \
10 osqlresult.h \ 10 osqlresult.h \
11 osqltable.h \ 11 osqltable.h \
12 osqlbackendmanager.h \ 12 osqlbackendmanager.h \
13 osqlitedriver.h 13 osqlitedriver.h
14SOURCES = osqlbackend.cpp \ 14SOURCES = osqlbackend.cpp \
15 osqldriver.cpp \ 15 osqldriver.cpp \
16 osqlerror.cpp \ 16 osqlerror.cpp \
17 osqlmanager.cpp \ 17 osqlmanager.cpp \
18 osqlquery.cpp \ 18 osqlquery.cpp \
19 osqlresult.cpp \ 19 osqlresult.cpp \
20 osqltable.cpp \ 20 osqltable.cpp \
21 osqlbackendmanager.cpp \ 21 osqlbackendmanager.cpp \
22 osqlitedriver.cpp 22 osqlitedriver.cpp
23INTERFACES = 23INTERFACES =
24TARGET = opiedb2 24TARGET = opiedb2
25VERSION = 1.8.1 25VERSION = 1.8.2
26INCLUDEPATH += $(OPIEDIR)/include 26INCLUDEPATH += $(OPIEDIR)/include
27DEPENDPATH += $(OPIEDIR)/include 27DEPENDPATH += $(OPIEDIR)/include
28 28
29MOC_DIR = moc 29MOC_DIR = moc
30OBJECTS_DIR = obj 30OBJECTS_DIR = obj
31 31
32LIBS += -lsqlite -lqpe 32LIBS += -lsqlite -lqpe
33 33
34!contains( platform, x11 ) { 34!contains( platform, x11 ) {
35 include ( $(OPIEDIR)/include.pro ) 35 include ( $(OPIEDIR)/include.pro )
36} 36}
37 37
38contains( platform, x11 ) { 38contains( platform, x11 ) {
39 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 39 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
40} 40}
41 41
diff --git a/libopie2/opiemm/libopiemm2.control b/libopie2/opiemm/libopiemm2.control
index 7fbadef..f528969 100644
--- a/libopie2/opiemm/libopiemm2.control
+++ b/libopie2/opiemm/libopiemm2.control
@@ -1,11 +1,11 @@
1Package: libopiemm2 1Package: libopiemm2
2Files: $OPIEDIR/lib/libopiemm2.so.* 2Files: $OPIEDIR/lib/libopiemm2.so.*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.1) 8Depends: libqpe1, libopiecore2 (1.8.2)
9Provides: libopiemm2 9Provides: libopiemm2
10Description: Opie library 2.0 MM 10Description: Opie library 2.0 MM
11 11
diff --git a/libopie2/opiemm/opiemm.pro b/libopie2/opiemm/opiemm.pro
index d3ce8f7..d5c8238 100644
--- a/libopie2/opiemm/opiemm.pro
+++ b/libopie2/opiemm/opiemm.pro
@@ -1,22 +1,22 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = osoundsystem.h 4HEADERS = osoundsystem.h
5SOURCES = osoundsystem.cpp 5SOURCES = osoundsystem.cpp
6INTERFACES = 6INTERFACES =
7TARGET = opiemm2 7TARGET = opiemm2
8VERSION = 1.8.1 8VERSION = 1.8.2
9INCLUDEPATH += $(OPIEDIR)/include 9INCLUDEPATH += $(OPIEDIR)/include
10DEPENDPATH += $(OPIEDIR)/include 10DEPENDPATH += $(OPIEDIR)/include
11LIBS += 11LIBS +=
12MOC_DIR = moc 12MOC_DIR = moc
13OBJECTS_DIR = obj 13OBJECTS_DIR = obj
14 14
15 15
16!contains( platform, x11 ) { 16!contains( platform, x11 ) {
17 include ( $(OPIEDIR)/include.pro ) 17 include ( $(OPIEDIR)/include.pro )
18} 18}
19 19
20contains( platform, x11 ) { 20contains( platform, x11 ) {
21 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 21 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
22} 22}
diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h
index 3f2f775..368e375 100644
--- a/libopie2/opienet/dhcp.h
+++ b/libopie2/opienet/dhcp.h
@@ -1,200 +1,201 @@
1/* dhcp.h 1/* dhcp.h
2 2
3 Protocol structures... */ 3 Protocol structures... */
4 4
5/* 5/*
6 * Copyright (c) 1995-2001 The Internet Software Consortium. 6 * Copyright (c) 1995-2001 The Internet Software Consortium.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names 18 * 3. Neither the name of The Internet Software Consortium nor the names
19 * of its contributors may be used to endorse or promote products derived 19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission. 20 * from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * This software has been written for the Internet Software Consortium 36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more 37 * by Ted Lemon in cooperation with Vixie Enterprises. To learn more
38 * about the Internet Software Consortium, see ``http://www.isc.org''. 38 * about the Internet Software Consortium, see ``http://www.isc.org''.
39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''. 39 * To learn more about Vixie Enterprises, see ``http://www.vix.com''.
40 */ 40 */
41 41
42#ifndef DHCP_H 42#ifndef DHCP_H
43#define DHCP_H 43#define DHCP_H
44 44
45 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 45 #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \
46 20 + /* IP header */ \ 46 20 + /* IP header */ \
47 8) /* UDP header */ 47 8) /* UDP header */
48 #define DHCP_SNAME_LEN 64 48 #define DHCP_SNAME_LEN 64
49 #define DHCP_FILE_LEN 128 49 #define DHCP_FILE_LEN 128
50 #define DHCP_FIXED_NON_UDP236 50 #define DHCP_FIXED_NON_UDP236
51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) 51 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
52 /* Everything but options. */ 52 /* Everything but options. */
53 #define DHCP_MTU_MAX 1500 53 #define DHCP_MTU_MAX 1500
54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) 54 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
55 55
56 #define BOOTP_MIN_LEN 300 56 #define BOOTP_MIN_LEN 300
57#define DHCP_MIN_LEN 548 57#define DHCP_MIN_LEN 548
58 58
59struct dhcp_packet { 59struct dhcp_packet {
60 u_int8_t op; /* 0: Message opcode/type */ 60 u_int8_t op; /* 0: Message opcode/type */
61 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */ 61 u_int8_t htype;/* 1: Hardware addr type (net/if_types.h) */
62 u_int8_t hlen; /* 2: Hardware addr length */ 62 u_int8_t hlen; /* 2: Hardware addr length */
63 u_int8_t hops; /* 3: Number of relay agent hops from client */ 63 u_int8_t hops; /* 3: Number of relay agent hops from client */
64 u_int32_t xid; /* 4: Transaction ID */ 64 u_int32_t xid; /* 4: Transaction ID */
65 u_int16_t secs; /* 8: Seconds since client started looking */ 65 u_int16_t secs; /* 8: Seconds since client started looking */
66 u_int16_t flags;/* 10: Flag bits */ 66 u_int16_t flags;/* 10: Flag bits */
67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */ 67 struct in_addr ciaddr;/* 12: Client IP address (if already in use) */
68 struct in_addr yiaddr;/* 16: Client IP address */ 68 struct in_addr yiaddr;/* 16: Client IP address */
69 struct in_addr siaddr;/* 18: IP address of next server to talk to */ 69 struct in_addr siaddr;/* 18: IP address of next server to talk to */
70 struct in_addr giaddr;/* 20: DHCP relay agent IP address */ 70 struct in_addr giaddr;/* 20: DHCP relay agent IP address */
71 unsigned char chaddr [16];/* 24: Client hardware address */ 71 unsigned char chaddr [16];/* 24: Client hardware address */
72 char sname [DHCP_SNAME_LEN];/* 40: Server name */ 72 char sname [DHCP_SNAME_LEN];/* 40: Server name */
73 char file [DHCP_FILE_LEN];/* 104: Boot filename */ 73 char file [DHCP_FILE_LEN];/* 104: Boot filename */
74 unsigned char options [DHCP_OPTION_LEN]; 74 unsigned char options [DHCP_OPTION_LEN];
75 /* 212: Optional parameters 75 /* 212: Optional parameters
76 (actual length dependent on MTU). */ 76 (actual length dependent on MTU). */
77}; 77};
78 78
79/* BOOTP (rfc951) message types */ 79/* BOOTP (rfc951) message types */
80 #define BOOTREQUEST1 80 #define BOOTREQUEST1
81 #define BOOTREPLY2 81 #define BOOTREPLY2
82 82
83/* Possible values for flags field... */ 83/* Possible values for flags field... */
84#define BOOTP_BROADCAST 32768L 84#define BOOTP_BROADCAST 32768L
85 85
86/* Possible values for hardware type (htype) field... */ 86/* Possible values for hardware type (htype) field... */
87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */ 87 #define HTYPE_ETHER1 /* Ethernet 10Mbps */
88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/ 88 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring...*/
89 #define HTYPE_FDDI 8 /* FDDI... */ 89 #define HTYPE_FDDI 8 /* FDDI... */
90 90
91/* Magic cookie validating dhcp options field (and bootp vendor 91/* Magic cookie validating dhcp options field (and bootp vendor
92 extensions field). */ 92 extensions field). */
93 #define DHCP_OPTIONS_COOKIE"\143\202\123\143" 93 #define DHCP_OPTIONS_COOKIE"\143\202\123\143"
94 94
95/* DHCP Option codes: */ 95/* DHCP Option codes: */
96 96
97 #define DHO_PAD 0 97 #define DHO_PAD 0
98 #define DHO_SUBNET_MASK 1 98 #define DHO_SUBNET_MASK 1
99 #define DHO_TIME_OFFSET 2 99 #define DHO_TIME_OFFSET 2
100 #define DHO_ROUTERS 3 100 #define DHO_ROUTERS 3
101 #define DHO_TIME_SERVERS 4 101 #define DHO_TIME_SERVERS 4
102 #define DHO_NAME_SERVERS 5 102 #define DHO_NAME_SERVERS 5
103 #define DHO_DOMAIN_NAME_SERVERS 6 103 #define DHO_DOMAIN_NAME_SERVERS 6
104 #define DHO_LOG_SERVERS 7 104 #define DHO_LOG_SERVERS 7
105 #define DHO_COOKIE_SERVERS 8 105 #define DHO_COOKIE_SERVERS 8
106 #define DHO_LPR_SERVERS 9 106 #define DHO_LPR_SERVERS 9
107 #define DHO_IMPRESS_SERVERS 10 107 #define DHO_IMPRESS_SERVERS 10
108 #define DHO_RESOURCE_LOCATION_SERVERS11 108 #define DHO_RESOURCE_LOCATION_SERVERS11
109 #define DHO_HOST_NAME 12 109 #define DHO_HOST_NAME 12
110 #define DHO_BOOT_SIZE 13 110 #define DHO_BOOT_SIZE 13
111 #define DHO_MERIT_DUMP 14 111 #define DHO_MERIT_DUMP 14
112 #define DHO_DOMAIN_NAME 15 112 #define DHO_DOMAIN_NAME 15
113 #define DHO_SWAP_SERVER 16 113 #define DHO_SWAP_SERVER 16
114 #define DHO_ROOT_PATH 17 114 #define DHO_ROOT_PATH 17
115 #define DHO_EXTENSIONS_PATH 18 115 #define DHO_EXTENSIONS_PATH 18
116 #define DHO_IP_FORWARDING 19 116 #define DHO_IP_FORWARDING 19
117 #define DHO_NON_LOCAL_SOURCE_ROUTING20 117 #define DHO_NON_LOCAL_SOURCE_ROUTING20
118 #define DHO_POLICY_FILTER 21 118 #define DHO_POLICY_FILTER 21
119 #define DHO_MAX_DGRAM_REASSEMBLY22 119 #define DHO_MAX_DGRAM_REASSEMBLY22
120 #define DHO_DEFAULT_IP_TTL 23 120 #define DHO_DEFAULT_IP_TTL 23
121 #define DHO_PATH_MTU_AGING_TIMEOUT24 121 #define DHO_PATH_MTU_AGING_TIMEOUT24
122 #define DHO_PATH_MTU_PLATEAU_TABLE25 122 #define DHO_PATH_MTU_PLATEAU_TABLE25
123 #define DHO_INTERFACE_MTU 26 123 #define DHO_INTERFACE_MTU 26
124 #define DHO_ALL_SUBNETS_LOCAL 27 124 #define DHO_ALL_SUBNETS_LOCAL 27
125 #define DHO_BROADCAST_ADDRESS 28 125 #define DHO_BROADCAST_ADDRESS 28
126 #define DHO_PERFORM_MASK_DISCOVERY29 126 #define DHO_PERFORM_MASK_DISCOVERY29
127 #define DHO_MASK_SUPPLIER 30 127 #define DHO_MASK_SUPPLIER 30
128 #define DHO_ROUTER_DISCOVERY 31 128 #define DHO_ROUTER_DISCOVERY 31
129 #define DHO_ROUTER_SOLICITATION_ADDRESS32 129 #define DHO_ROUTER_SOLICITATION_ADDRESS32
130 #define DHO_STATIC_ROUTES 33 130 #define DHO_STATIC_ROUTES 33
131 #define DHO_TRAILER_ENCAPSULATION34 131 #define DHO_TRAILER_ENCAPSULATION34
132 #define DHO_ARP_CACHE_TIMEOUT 35 132 #define DHO_ARP_CACHE_TIMEOUT 35
133 #define DHO_IEEE802_3_ENCAPSULATION36 133 #define DHO_IEEE802_3_ENCAPSULATION36
134 #define DHO_DEFAULT_TCP_TTL 37 134 #define DHO_DEFAULT_TCP_TTL 37
135 #define DHO_TCP_KEEPALIVE_INTERVAL38 135 #define DHO_TCP_KEEPALIVE_INTERVAL38
136 #define DHO_TCP_KEEPALIVE_GARBAGE39 136 #define DHO_TCP_KEEPALIVE_GARBAGE39
137 #define DHO_NIS_DOMAIN 40 137 #define DHO_NIS_DOMAIN 40
138 #define DHO_NIS_SERVERS 41 138 #define DHO_NIS_SERVERS 41
139 #define DHO_NTP_SERVERS 42 139 #define DHO_NTP_SERVERS 42
140 #define DHO_VENDOR_ENCAPSULATED_OPTIONS43 140 #define DHO_VENDOR_ENCAPSULATED_OPTIONS43
141 #define DHO_NETBIOS_NAME_SERVERS44 141 #define DHO_NETBIOS_NAME_SERVERS44
142 #define DHO_NETBIOS_DD_SERVER 45 142 #define DHO_NETBIOS_DD_SERVER 45
143 #define DHO_NETBIOS_NODE_TYPE 46 143 #define DHO_NETBIOS_NODE_TYPE 46
144 #define DHO_NETBIOS_SCOPE 47 144 #define DHO_NETBIOS_SCOPE 47
145 #define DHO_FONT_SERVERS 48 145 #define DHO_FONT_SERVERS 48
146 #define DHO_X_DISPLAY_MANAGER 49 146 #define DHO_X_DISPLAY_MANAGER 49
147 #define DHO_DHCP_REQUESTED_ADDRESS50 147 #define DHO_DHCP_REQUESTED_ADDRESS50
148 #define DHO_DHCP_LEASE_TIME 51 148 #define DHO_DHCP_LEASE_TIME 51
149 #define DHO_DHCP_OPTION_OVERLOAD52 149 #define DHO_DHCP_OPTION_OVERLOAD52
150 #define DHO_DHCP_MESSAGE_TYPE 53 150 #define DHO_DHCP_MESSAGE_TYPE 53
151 #define DHO_DHCP_SERVER_IDENTIFIER54 151 #define DHO_DHCP_SERVER_IDENTIFIER54
152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55 152 #define DHO_DHCP_PARAMETER_REQUEST_LIST55
153 #define DHO_DHCP_MESSAGE 56 153 #define DHO_DHCP_MESSAGE 56
154 #define DHO_DHCP_MAX_MESSAGE_SIZE57 154 #define DHO_DHCP_MAX_MESSAGE_SIZE57
155 #define DHO_DHCP_RENEWAL_TIME 58 155 #define DHO_DHCP_RENEWAL_TIME 58
156 #define DHO_DHCP_REBINDING_TIME 59 156 #define DHO_DHCP_REBINDING_TIME 59
157 #define DHO_VENDOR_CLASS_IDENTIFIER60 157 #define DHO_VENDOR_CLASS_IDENTIFIER60
158 #define DHO_DHCP_CLIENT_IDENTIFIER61 158 #define DHO_DHCP_CLIENT_IDENTIFIER61
159 #define DHO_NWIP_DOMAIN_NAME 62 159 #define DHO_NWIP_DOMAIN_NAME 62
160 #define DHO_NWIP_SUBOPTIONS 63 160 #define DHO_NWIP_SUBOPTIONS 63
161 #define DHO_USER_CLASS 77 161 #define DHO_USER_CLASS 77
162 #define DHO_FQDN 81 162 #define DHO_FQDN 81
163 #define DHO_DHCP_AGENT_OPTIONS 82 163 #define DHO_DHCP_AGENT_OPTIONS 82
164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ 164 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */
165/* The DHO_AUTHENTICATE option is not a standard yet, so I've 165/* The DHO_AUTHENTICATE option is not a standard yet, so I've
166 allocated an option out of the "local" option space for it on a 166 allocated an option out of the "local" option space for it on a
167 temporary basis. Once an option code number is assigned, I will 167 temporary basis. Once an option code number is assigned, I will
168 immediately and shamelessly break this, so don't count on it 168 immediately and shamelessly break this, so don't count on it
169 continuing to work. */ 169 continuing to work. */
170 #define DHO_AUTHENTICATE 210 170 #define DHO_AUTHENTICATE 210
171 171
172 #define DHO_END 255 172 #define DHO_END 255
173 173
174/* DHCP message types. */ 174/* DHCP message types. */
175 #define DHCPDISCOVER1 175 #define DHCPDISCOVER1
176 #define DHCPOFFER2 176 #define DHCPOFFER2
177 #define DHCPREQUEST3 177 #define DHCPREQUEST3
178 #define DHCPDECLINE4 178 #define DHCPDECLINE4
179 #define DHCPACK 5 179 #define DHCPACK 5
180 #define DHCPNAK 6 180 #define DHCPNAK 6
181 #define DHCPRELEASE7 181 #define DHCPRELEASE7
182 #define DHCPINFORM8 182 #define DHCPINFORM8
183 183
184/* Relay Agent Information option subtypes: */ 184/* Relay Agent Information option subtypes: */
185 #define RAI_CIRCUIT_ID1 185 #define RAI_CIRCUIT_ID1
186 #define RAI_REMOTE_ID2 186 #define RAI_REMOTE_ID2
187 #define RAI_AGENT_ID3 187 #define RAI_AGENT_ID3
188 188
189/* FQDN suboptions: */ 189/* FQDN suboptions: */
190 #define FQDN_NO_CLIENT_UPDATE 1 190 #define FQDN_NO_CLIENT_UPDATE 1
191 #define FQDN_SERVER_UPDATE 2 191 #define FQDN_SERVER_UPDATE 2
192 #define FQDN_ENCODED 3 192 #define FQDN_ENCODED 3
193 #define FQDN_RCODE1 4 193 #define FQDN_RCODE1 4
194 #define FQDN_RCODE2 5 194 #define FQDN_RCODE2 5
195 #define FQDN_HOSTNAME 6 195 #define FQDN_HOSTNAME 6
196 #define FQDN_DOMAINNAME 7 196 #define FQDN_DOMAINNAME 7
197 #define FQDN_FQDN 8 197 #define FQDN_FQDN 8
198 #define FQDN_SUBOPTION_COUNT 8 198 #define FQDN_SUBOPTION_COUNT 8
199 199
200#endif \ No newline at end of file 200#endif
201
diff --git a/libopie2/opienet/libopienet2.control b/libopie2/opienet/libopienet2.control
index 65d8464..8eb0704 100644
--- a/libopie2/opienet/libopienet2.control
+++ b/libopie2/opienet/libopienet2.control
@@ -1,11 +1,11 @@
1Package: libopienet2 1Package: libopienet2
2Files: $OPIEDIR/lib/libopienet2.so.* $OPIEDIR/etc/manufacturers 2Files: $OPIEDIR/lib/libopienet2.so.* $OPIEDIR/etc/manufacturers
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.1) 8Depends: libopiecore2 (1.8.2)
9Provides: libopienet2 9Provides: libopienet2
10Description: Opie library 2.0 NET 10Description: Opie library 2.0 NET
11 11
diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp
index d62b3ba..7e4ab2b 100644
--- a/libopie2/opienet/odebugmapper.cpp
+++ b/libopie2/opienet/odebugmapper.cpp
@@ -1,213 +1,215 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#include <opie2/odebug.h>
7
6#include "odebugmapper.h" 8#include "odebugmapper.h"
7 9
8DebugMapper::DebugMapper() 10DebugMapper::DebugMapper()
9{ 11{
10 qDebug( "DebugMapper::DebugMapper()" ); 12 odebug << "DebugMapper::DebugMapper()" << oendl;
11 13
12 14
13 _map.insert( 0x8902, new QString("SIOCSPGRP") ); 15 _map.insert( 0x8902, new QString("SIOCSPGRP") );
14 _map.insert( 0x8904, new QString("SIOCGPGRP") ); 16 _map.insert( 0x8904, new QString("SIOCGPGRP") );
15 _map.insert( 0x8905, new QString("SIOCATMARK") ); 17 _map.insert( 0x8905, new QString("SIOCATMARK") );
16 _map.insert( 0x8906, new QString("SIOCGSTAMP") ); 18 _map.insert( 0x8906, new QString("SIOCGSTAMP") );
17 _map.insert( 0x890B, new QString("SIOCADDRT") ); 19 _map.insert( 0x890B, new QString("SIOCADDRT") );
18 _map.insert( 0x890C, new QString("SIOCDELRT") ); 20 _map.insert( 0x890C, new QString("SIOCDELRT") );
19 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 21 _map.insert( 0x890D, new QString("SIOCRTMSG") );
20 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 22 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
21 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 23 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
22 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 24 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
23 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 25 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
24 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 26 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
25 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 27 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
26 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 28 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
27 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 29 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
28 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 30 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
29 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 31 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
30 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 32 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
31 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 33 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
32 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 34 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
33 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 35 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
34 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 36 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
35 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 37 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
36 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 38 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
37 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 39 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
38 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 40 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
39 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 41 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
40 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 42 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
41 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 43 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
42 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 44 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
43 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 45 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
44 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 46 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
45 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 47 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
46 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 48 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
47 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 49 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
48 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 50 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
49 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 51 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
50 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 52 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
51 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 53 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
52 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 54 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
53 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 55 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
54 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 56 _map.insert( 0x8940, new QString("SIOCGIFBR") );
55 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 57 _map.insert( 0x8941, new QString("SIOCSIFBR") );
56 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); 58 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
57 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); 59 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
58 _map.insert( 0x8953, new QString("SIOCDARP") ); 60 _map.insert( 0x8953, new QString("SIOCDARP") );
59 _map.insert( 0x8954, new QString("SIOCGARP") ); 61 _map.insert( 0x8954, new QString("SIOCGARP") );
60 _map.insert( 0x8955, new QString("SIOCSARP") ); 62 _map.insert( 0x8955, new QString("SIOCSARP") );
61 _map.insert( 0x8960, new QString("SIOCDRARP") ); 63 _map.insert( 0x8960, new QString("SIOCDRARP") );
62 _map.insert( 0x8961, new QString("SIOCGRARP") ); 64 _map.insert( 0x8961, new QString("SIOCGRARP") );
63 _map.insert( 0x8962, new QString("SIOCSRARP") ); 65 _map.insert( 0x8962, new QString("SIOCSRARP") );
64 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 66 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
65 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 67 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
66 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 68 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
67 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 69 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
68 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 70 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
69 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 71 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
70 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") ); 72 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") );
71 _map.insert( 0x00000000, new QString("SIOC_VOID") ); 73 _map.insert( 0x00000000, new QString("SIOC_VOID") );
72 _map.insert( 0x20000000, new QString("SIOC_OUT") ); 74 _map.insert( 0x20000000, new QString("SIOC_OUT") );
73 _map.insert( 0x40000000, new QString("SIOC_IN") ); 75 _map.insert( 0x40000000, new QString("SIOC_IN") );
74 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") ); 76 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") );
75 _map.insert( 0x8B01, new QString("SIOCGIWNAME") ); 77 _map.insert( 0x8B01, new QString("SIOCGIWNAME") );
76 _map.insert( 0x8B02, new QString("SIOCSIWNWID") ); 78 _map.insert( 0x8B02, new QString("SIOCSIWNWID") );
77 _map.insert( 0x8B03, new QString("SIOCGIWNWID") ); 79 _map.insert( 0x8B03, new QString("SIOCGIWNWID") );
78 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") ); 80 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") );
79 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") ); 81 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") );
80 _map.insert( 0x8B06, new QString("SIOCSIWMODE") ); 82 _map.insert( 0x8B06, new QString("SIOCSIWMODE") );
81 _map.insert( 0x8B07, new QString("SIOCGIWMODE") ); 83 _map.insert( 0x8B07, new QString("SIOCGIWMODE") );
82 _map.insert( 0x8B08, new QString("SIOCSIWSENS") ); 84 _map.insert( 0x8B08, new QString("SIOCSIWSENS") );
83 _map.insert( 0x8B09, new QString("SIOCGIWSENS") ); 85 _map.insert( 0x8B09, new QString("SIOCGIWSENS") );
84 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") ); 86 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") );
85 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") ); 87 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") );
86 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") ); 88 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") );
87 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") ); 89 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") );
88 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") ); 90 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") );
89 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") ); 91 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") );
90 _map.insert( 0x8B10, new QString("SIOCSIWSPY") ); 92 _map.insert( 0x8B10, new QString("SIOCSIWSPY") );
91 _map.insert( 0x8B11, new QString("SIOCGIWSPY") ); 93 _map.insert( 0x8B11, new QString("SIOCGIWSPY") );
92 _map.insert( 0x8B14, new QString("SIOCSIWAP") ); 94 _map.insert( 0x8B14, new QString("SIOCSIWAP") );
93 _map.insert( 0x8B15, new QString("SIOCGIWAP") ); 95 _map.insert( 0x8B15, new QString("SIOCGIWAP") );
94 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") ); 96 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") );
95 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") ); 97 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") );
96 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") ); 98 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") );
97 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") ); 99 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") );
98 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") ); 100 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") );
99 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") ); 101 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") );
100 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") ); 102 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") );
101 _map.insert( 0x8B20, new QString("SIOCSIWRATE") ); 103 _map.insert( 0x8B20, new QString("SIOCSIWRATE") );
102 _map.insert( 0x8B21, new QString("SIOCGIWRATE") ); 104 _map.insert( 0x8B21, new QString("SIOCGIWRATE") );
103 _map.insert( 0x8B22, new QString("SIOCSIWRTS") ); 105 _map.insert( 0x8B22, new QString("SIOCSIWRTS") );
104 _map.insert( 0x8B23, new QString("SIOCGIWRTS") ); 106 _map.insert( 0x8B23, new QString("SIOCGIWRTS") );
105 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") ); 107 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") );
106 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") ); 108 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") );
107 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") ); 109 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") );
108 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") ); 110 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") );
109 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") ); 111 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") );
110 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") ); 112 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") );
111 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") ); 113 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") );
112 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") ); 114 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") );
113 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") ); 115 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") );
114 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") ); 116 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") );
115 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") ); 117 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") );
116 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") ); 118 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") );
117 _map.insert( 0x8B00, new QString("SIOCIWFIRST") ); 119 _map.insert( 0x8B00, new QString("SIOCIWFIRST") );
118 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") ); 120 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") );
119 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") ); 121 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") );
120 _map.insert( 0x890B, new QString("SIOCADDRT") ); 122 _map.insert( 0x890B, new QString("SIOCADDRT") );
121 _map.insert( 0x890C, new QString("SIOCDELRT") ); 123 _map.insert( 0x890C, new QString("SIOCDELRT") );
122 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 124 _map.insert( 0x890D, new QString("SIOCRTMSG") );
123 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 125 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
124 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 126 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
125 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 127 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
126 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 128 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
127 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 129 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
128 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 130 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
129 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 131 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
130 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 132 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
131 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 133 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
132 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 134 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
133 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 135 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
134 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 136 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
135 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 137 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
136 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 138 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
137 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 139 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
138 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 140 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
139 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 141 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
140 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 142 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
141 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 143 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
142 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 144 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
143 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 145 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
144 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 146 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
145 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 147 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
146 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 148 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
147 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 149 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
148 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 150 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
149 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 151 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
150 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 152 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
151 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 153 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
152 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 154 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
153 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 155 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
154 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 156 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
155 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 157 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
156 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 158 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
157 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 159 _map.insert( 0x8940, new QString("SIOCGIFBR") );
158 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 160 _map.insert( 0x8941, new QString("SIOCSIFBR") );
159 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); 161 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
160 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); 162 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
161 _map.insert( 0x8944, new QString("SIOCGIFDIVERT") ); 163 _map.insert( 0x8944, new QString("SIOCGIFDIVERT") );
162 _map.insert( 0x8945, new QString("SIOCSIFDIVERT") ); 164 _map.insert( 0x8945, new QString("SIOCSIFDIVERT") );
163 _map.insert( 0x8946, new QString("SIOCETHTOOL") ); 165 _map.insert( 0x8946, new QString("SIOCETHTOOL") );
164 _map.insert( 0x8947, new QString("SIOCGMIIPHY") ); 166 _map.insert( 0x8947, new QString("SIOCGMIIPHY") );
165 _map.insert( 0x8948, new QString("SIOCGMIIREG") ); 167 _map.insert( 0x8948, new QString("SIOCGMIIREG") );
166 _map.insert( 0x8949, new QString("SIOCSMIIREG") ); 168 _map.insert( 0x8949, new QString("SIOCSMIIREG") );
167 _map.insert( 0x894A, new QString("SIOCWANDEV") ); 169 _map.insert( 0x894A, new QString("SIOCWANDEV") );
168 _map.insert( 0x8953, new QString("SIOCDARP") ); 170 _map.insert( 0x8953, new QString("SIOCDARP") );
169 _map.insert( 0x8954, new QString("SIOCGARP") ); 171 _map.insert( 0x8954, new QString("SIOCGARP") );
170 _map.insert( 0x8955, new QString("SIOCSARP") ); 172 _map.insert( 0x8955, new QString("SIOCSARP") );
171 _map.insert( 0x8960, new QString("SIOCDRARP") ); 173 _map.insert( 0x8960, new QString("SIOCDRARP") );
172 _map.insert( 0x8961, new QString("SIOCGRARP") ); 174 _map.insert( 0x8961, new QString("SIOCGRARP") );
173 _map.insert( 0x8962, new QString("SIOCSRARP") ); 175 _map.insert( 0x8962, new QString("SIOCSRARP") );
174 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 176 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
175 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 177 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
176 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 178 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
177 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 179 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
178 _map.insert( 0x8982, new QString("SIOCGIFVLAN") ); 180 _map.insert( 0x8982, new QString("SIOCGIFVLAN") );
179 _map.insert( 0x8983, new QString("SIOCSIFVLAN") ); 181 _map.insert( 0x8983, new QString("SIOCSIFVLAN") );
180 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") ); 182 _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") );
181 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") ); 183 _map.insert( 0x8991, new QString("SIOCBONDRELEASE") );
182 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") ); 184 _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") );
183 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") ); 185 _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") );
184 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") ); 186 _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") );
185 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") ); 187 _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") );
186 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 188 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
187 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 189 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
188 190
189}; 191};
190 192
191 193
192DebugMapper::~DebugMapper() 194DebugMapper::~DebugMapper()
193{ 195{
194 qDebug( "DebugMapper::~DebugMapper()" ); 196 odebug << "DebugMapper::~DebugMapper()" << oendl;
195} 197}
196 198
197 199
198const QString& DebugMapper::map( int value ) const 200const QString& DebugMapper::map( int value ) const
199{ 201{
200 QString* result = _map[ value ]; 202 QString* result = _map[ value ];
201 203
202 if ( !result ) 204 if ( !result )
203 { 205 {
204 qDebug( "DebugMapper::map() - value not found." ); 206 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
205 return QString::null; 207 return QString::null;
206 } 208 }
207 else 209 else
208 { 210 {
209 return *result; 211 return *result;
210 } 212 }
211} 213}
212 214
213 215
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index c3c213c..bcce11f 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,118 +1,131 @@
1/********************************************************************** 1/*
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2                 This file is part of the Opie Project
3** 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4** This file is part of Opie Environment. 4 =.
5** 5 .=l.
6** This file may be distributed and/or modified under the terms of the 6           .>+-=
7** GNU General Public License version 2 as published by the Free Software 7 _;:,     .>    :=|. This program is free software; you can
8** Foundation and appearing in the file LICENSE.GPL included in the 8.> <`_,   >  .   <= redistribute it and/or modify it under
9** packaging of this file. 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10** 10.="- .-=="i,     .._ License as published by the Free Software
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12     ._= =}       : or (at your option) any later version.
13** 13    .%`+i>       _;_.
14**********************************************************************/ 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28
29*/
15 30
16#include "omanufacturerdb.h" 31#include "omanufacturerdb.h"
17 32
33/* OPIE CORE */
34#include <opie2/odebug.h>
35
18/* QT */ 36/* QT */
19#include <qstring.h> 37#include <qstring.h>
20#include <qfile.h> 38#include <qfile.h>
21#include <qtextstream.h> 39#include <qtextstream.h>
22 40
23OManufacturerDB* OManufacturerDB::_instance = 0; 41OManufacturerDB* OManufacturerDB::_instance = 0;
24 42
25OManufacturerDB* OManufacturerDB::instance() 43OManufacturerDB* OManufacturerDB::instance()
26{ 44{
27 if ( !OManufacturerDB::_instance ) 45 if ( !OManufacturerDB::_instance )
28 { 46 {
29 qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." ); 47 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
30 _instance = new OManufacturerDB(); 48 _instance = new OManufacturerDB();
31 } 49 }
32 return _instance; 50 return _instance;
33} 51}
34 52
35 53
36OManufacturerDB::OManufacturerDB() 54OManufacturerDB::OManufacturerDB()
37{ 55{
38 QString filename( "/etc/manufacturers" ); 56 QString filename( "/etc/manufacturers" );
39 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 57 odebug << "OManufacturerDB: trying to read " << filename << oendl;
40 if ( !QFile::exists( filename ) ) 58 if ( !QFile::exists( filename ) )
41 { 59 {
42 filename = "/opt/QtPalmtop/etc/manufacturers"; 60 filename = "/opt/QtPalmtop/etc/manufacturers";
43 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 61 odebug << "OManufacturerDB: trying to read " << filename << oendl;
44 if ( !QFile::exists( filename ) ) 62 if ( !QFile::exists( filename ) )
45 { 63 {
46 filename = "/usr/share/wellenreiter/manufacturers"; 64 filename = "/usr/share/wellenreiter/manufacturers";
47 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 65 odebug << "OManufacturerDB: trying to read " << filename << oendl;
48 } 66 }
49 } 67 }
50 68
51 QFile file( filename ); 69 QFile file( filename );
52 bool hasFile = file.open( IO_ReadOnly ); 70 bool hasFile = file.open( IO_ReadOnly );
53 if (!hasFile) 71 if (!hasFile)
54 { 72 {
55 qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename ); 73 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
56 } 74 }
57 else 75 else
58 { 76 {
59 qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); 77 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
60 QTextStream s( &file ); 78 QTextStream s( &file );
61 QString addr; 79 QString addr;
62 QString manu; 80 QString manu;
63 QString extManu; 81 QString extManu;
64 while (!s.atEnd()) 82 while (!s.atEnd())
65 { 83 {
66 s >> addr; 84 s >> addr;
67 if ( !addr ) // read nothing!? 85 if ( !addr ) // read nothing!?
68 { 86 {
69 continue; 87 continue;
70 } 88 }
71 else 89 else
72 if ( addr[0] == '#' ) 90 if ( addr[0] == '#' )
73 { 91 {
74 continue; 92 continue;
75 } 93 }
76 s.skipWhiteSpace(); 94 s.skipWhiteSpace();
77 s >> manu; 95 s >> manu;
78 s.skipWhiteSpace(); 96 s.skipWhiteSpace();
79 s >> extManu; 97 s >> extManu;
80 if ( extManu[0] == '#' ) // we have an extended manufacturer 98 if ( extManu[0] == '#' ) // we have an extended manufacturer
81 { 99 {
82 s.skipWhiteSpace(); 100 s.skipWhiteSpace();
83 extManu = s.readLine(); 101 extManu = s.readLine();
84 #ifdef DEBUG 102 odebug << "OManufacturerDB: read " << extManu << " as extended manufacturer string" << oendl;
85 qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
86 #endif
87 manufacturersExt.insert( addr, extManu ); 103 manufacturersExt.insert( addr, extManu );
88 } 104 }
89 else 105 else
90 s.readLine(); 106 s.readLine();
91 #ifdef DEBUG 107 odebug << "OManufacturerDB: read tuple " << addr << ", " << manu << oendl;
92 qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
93 #endif
94 manufacturers.insert( addr, manu ); 108 manufacturers.insert( addr, manu );
95
96 } 109 }
97 } 110 }
98 111
99} 112}
100 113
101 114
102OManufacturerDB::~OManufacturerDB() 115OManufacturerDB::~OManufacturerDB()
103{ 116{
104} 117}
105 118
106 119
107const QString& OManufacturerDB::lookup( const QString& macaddr ) const 120const QString& OManufacturerDB::lookup( const QString& macaddr ) const
108{ 121{
109 return manufacturers[macaddr.upper().left(8)]; 122 return manufacturers[macaddr.upper().left(8)];
110} 123}
111 124
112 125
113const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 126const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
114{ 127{
115 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 128 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
116 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 129 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
117} 130}
118 131
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index 651f624..c2712e5 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -1,54 +1,69 @@
1/********************************************************************** 1/*
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2                 This file is part of the Opie Project
3** 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4** This file is part of Opie Environment. 4 =.
5** 5 .=l.
6** This file may be distributed and/or modified under the terms of the 6           .>+-=
7** GNU General Public License version 2 as published by the Free Software 7 _;:,     .>    :=|. This program is free software; you can
8** Foundation and appearing in the file LICENSE.GPL included in the 8.> <`_,   >  .   <= redistribute it and/or modify it under
9** packaging of this file. 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10** 10.="- .-=="i,     .._ License as published by the Free Software
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12     ._= =}       : or (at your option) any later version.
13** 13    .%`+i>       _;_.
14**********************************************************************/ 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28
29*/
15 30
16#ifndef OMANUFACTURERDB_H 31#ifndef OMANUFACTURERDB_H
17#define OMANUFACTURERDB_H 32#define OMANUFACTURERDB_H
18 33
19#include <qmap.h> 34#include <qmap.h>
20 35
21/** 36/**
22 * @brief A Ethernet card vendor database. 37 * @brief A Ethernet card vendor database.
23 * 38 *
24 * This class encapsulates the lookup of Ethernet vendor given a 39 * This class encapsulates the lookup of Ethernet vendor given a
25 * certain Mac Address. Only the first three bytes define the vendor. 40 * certain Mac Address. Only the first three bytes define the vendor.
26 */ 41 */
27class OManufacturerDB 42class OManufacturerDB
28{ 43{
29 public: 44 public:
30 /** 45 /**
31 * @returns the one-and-only @ref OManufacturerDB instance. 46 * @returns the one-and-only @ref OManufacturerDB instance.
32 */ 47 */
33 static OManufacturerDB* instance(); 48 static OManufacturerDB* instance();
34 /** 49 /**
35 * @returns the short manufacturer string given a @a macaddr. 50 * @returns the short manufacturer string given a @a macaddr.
36 */ 51 */
37 const QString& lookup( const QString& macaddr ) const; 52 const QString& lookup( const QString& macaddr ) const;
38 /** 53 /**
39 * @returns the enhanced manufacturer string given a @a macaddr. 54 * @returns the enhanced manufacturer string given a @a macaddr.
40 */ 55 */
41 const QString& lookupExt( const QString& macaddr ) const; 56 const QString& lookupExt( const QString& macaddr ) const;
42 57
43 protected: 58 protected:
44 OManufacturerDB(); 59 OManufacturerDB();
45 virtual ~OManufacturerDB(); 60 virtual ~OManufacturerDB();
46 61
47 private: 62 private:
48 QMap<QString, QString> manufacturers; 63 QMap<QString, QString> manufacturers;
49 QMap<QString, QString> manufacturersExt; 64 QMap<QString, QString> manufacturersExt;
50 static OManufacturerDB* _instance; 65 static OManufacturerDB* _instance;
51}; 66};
52 67
53#endif 68#endif
54 69
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index e3eb327..48cfa43 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -1,232 +1,232 @@
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@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/*====================================================================================== 40/*======================================================================================
41 * OMacAddress 41 * OMacAddress
42 *======================================================================================*/ 42 *======================================================================================*/
43 43
44// static initializer for broadcast and unknown MAC Adresses 44// static initializer for broadcast and unknown MAC Adresses
45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 45const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); 46const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast );
47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; 47const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 };
48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); 48const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown );
49 49
50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so) 50//TODO: Incorporate Ethernet Manufacturer database here! (inline or so)
51 51
52OMacAddress::OMacAddress() 52OMacAddress::OMacAddress()
53{ 53{
54 memcpy( _bytes, __unknown, 6 ); 54 memcpy( _bytes, __unknown, 6 );
55} 55}
56 56
57 57
58OMacAddress::OMacAddress( unsigned char* p ) 58OMacAddress::OMacAddress( unsigned char* p )
59{ 59{
60 memcpy( _bytes, p, 6 ); 60 memcpy( _bytes, p, 6 );
61} 61}
62 62
63 63
64OMacAddress::OMacAddress( const unsigned char* p ) 64OMacAddress::OMacAddress( const unsigned char* p )
65{ 65{
66 memcpy( _bytes, p, 6 ); 66 memcpy( _bytes, p, 6 );
67} 67}
68 68
69 69
70OMacAddress::OMacAddress( struct ifreq& ifr ) 70OMacAddress::OMacAddress( struct ifreq& ifr )
71{ 71{
72 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 72 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
73} 73}
74 74
75 75
76OMacAddress::~OMacAddress() 76OMacAddress::~OMacAddress()
77{ 77{
78} 78}
79 79
80 80
81//#ifdef QT_NO_DEBUG 81//#ifdef QT_NO_DEBUG
82//inline 82//inline
83//#endif 83//#endif
84const unsigned char* OMacAddress::native() const 84const unsigned char* OMacAddress::native() const
85{ 85{
86 return (const unsigned char*) &_bytes; 86 return (const unsigned char*) &_bytes;
87} 87}
88 88
89 89
90OMacAddress OMacAddress::fromString( const QString& str ) 90OMacAddress OMacAddress::fromString( const QString& str )
91{ 91{
92 QString addr( str ); 92 QString addr( str );
93 unsigned char buf[6]; 93 unsigned char buf[6];
94 bool ok = true; 94 bool ok = true;
95 int index = 14; 95 int index = 14;
96 for ( int i = 5; i >= 0; --i ) 96 for ( int i = 5; i >= 0; --i )
97 { 97 {
98 buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); 98 buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
99 if ( !ok ) return OMacAddress::unknown; 99 if ( !ok ) return OMacAddress::unknown;
100 addr.truncate( index ); 100 addr.truncate( index );
101 index -= 3; 101 index -= 3;
102 } 102 }
103 return (const unsigned char*) &buf; 103 return (const unsigned char*) &buf;
104} 104}
105 105
106 106
107QString OMacAddress::toString( bool substitute ) const 107QString OMacAddress::toString( bool substitute ) const
108{ 108{
109 QString manu; 109 QString manu;
110 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); 110 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
111 QString serial; 111 QString serial;
112 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 112 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
113 if ( !substitute ) return manu+serial; 113 if ( !substitute ) return manu+serial;
114 // fallback - if no vendor is found, just use the number 114 // fallback - if no vendor is found, just use the number
115 QString textmanu = OManufacturerDB::instance()->lookup( manu ); 115 QString textmanu = OManufacturerDB::instance()->lookup( manu );
116 return textmanu.isNull() ? manu+serial : textmanu+serial; 116 return textmanu.isNull() ? manu+serial : textmanu+serial;
117} 117}
118 118
119 119
120QString OMacAddress::manufacturer() const 120QString OMacAddress::manufacturer() const
121{ 121{
122 return OManufacturerDB::instance()->lookupExt( toString() ); 122 return OManufacturerDB::instance()->lookupExt( toString() );
123} 123}
124 124
125 125
126bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 126bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
127{ 127{
128 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 128 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
129} 129}
130 130
131 131
132/*====================================================================================== 132/*======================================================================================
133 * OHostAddress 133 * OHostAddress
134 *======================================================================================*/ 134 *======================================================================================*/
135 135
136 136
137/*====================================================================================== 137/*======================================================================================
138 * OPrivateIOCTL 138 * OPrivateIOCTL
139 *======================================================================================*/ 139 *======================================================================================*/
140 140
141OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 141OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
142 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 142 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
143{ 143{
144} 144}
145 145
146 146
147OPrivateIOCTL::~OPrivateIOCTL() 147OPrivateIOCTL::~OPrivateIOCTL()
148{ 148{
149} 149}
150 150
151 151
152int OPrivateIOCTL::numberGetArgs() const 152int OPrivateIOCTL::numberGetArgs() const
153{ 153{
154 return _getargs & IW_PRIV_SIZE_MASK; 154 return _getargs & IW_PRIV_SIZE_MASK;
155} 155}
156 156
157 157
158int OPrivateIOCTL::typeGetArgs() const 158int OPrivateIOCTL::typeGetArgs() const
159{ 159{
160 return _getargs & IW_PRIV_TYPE_MASK >> 12; 160 return _getargs & IW_PRIV_TYPE_MASK >> 12;
161} 161}
162 162
163 163
164int OPrivateIOCTL::numberSetArgs() const 164int OPrivateIOCTL::numberSetArgs() const
165{ 165{
166 return _setargs & IW_PRIV_SIZE_MASK; 166 return _setargs & IW_PRIV_SIZE_MASK;
167} 167}
168 168
169 169
170int OPrivateIOCTL::typeSetArgs() const 170int OPrivateIOCTL::typeSetArgs() const
171{ 171{
172 return _setargs & IW_PRIV_TYPE_MASK >> 12; 172 return _setargs & IW_PRIV_TYPE_MASK >> 12;
173} 173}
174 174
175 175
176void OPrivateIOCTL::invoke() const 176void OPrivateIOCTL::invoke() const
177{ 177{
178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 178 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
179} 179}
180 180
181 181
182void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 182void OPrivateIOCTL::setParameter( int num, u_int32_t value )
183{ 183{
184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 184 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
185 arglist[num] = value; 185 arglist[num] = value;
186} 186}
187 187
188/*====================================================================================== 188/*======================================================================================
189 * assorted functions 189 * assorted functions
190 *======================================================================================*/ 190 *======================================================================================*/
191 191
192void dumpBytes( const unsigned char* data, int num ) 192void dumpBytes( const unsigned char* data, int num )
193{ 193{
194 printf( "Dumping %d bytes @ %0x", num, data ); 194 printf( "Dumping %d bytes @ %0x", num, data );
195 printf( "-------------------------------------------\n" ); 195 printf( "-------------------------------------------\n" );
196 196
197 for ( int i = 0; i < num; ++i ) 197 for ( int i = 0; i < num; ++i )
198 { 198 {
199 printf( "%02x ", data[i] ); 199 printf( "%02x ", data[i] );
200 if ( !((i+1) % 32) ) printf( "\n" ); 200 if ( !((i+1) % 32) ) printf( "\n" );
201 } 201 }
202 printf( "\n\n" ); 202 printf( "\n\n" );
203} 203}
204 204
205 205
206int stringToMode( const QString& mode ) 206int stringToMode( const QString& mode )
207{ 207{
208 if ( mode == "auto" ) return IW_MODE_AUTO; 208 if ( mode == "auto" ) return IW_MODE_AUTO;
209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 209 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
210 else if ( mode == "managed" ) return IW_MODE_INFRA; 210 else if ( mode == "managed" ) return IW_MODE_INFRA;
211 else if ( mode == "master" ) return IW_MODE_MASTER; 211 else if ( mode == "master" ) return IW_MODE_MASTER;
212 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 212 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
213 else if ( mode == "secondary" ) return IW_MODE_SECOND; 213 else if ( mode == "secondary" ) return IW_MODE_SECOND;
214 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 214 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
215 else assert( 0 ); 215 else assert( 0 );
216} 216}
217 217
218 218
219QString modeToString( int mode ) 219QString modeToString( int mode )
220{ 220{
221 switch ( mode ) 221 switch ( mode )
222 { 222 {
223 case IW_MODE_AUTO: return "auto"; 223 case IW_MODE_AUTO: return "auto";
224 case IW_MODE_ADHOC: return "adhoc"; 224 case IW_MODE_ADHOC: return "adhoc";
225 case IW_MODE_INFRA: return "managed"; 225 case IW_MODE_INFRA: return "managed";
226 case IW_MODE_MASTER: return "master"; 226 case IW_MODE_MASTER: return "master";
227 case IW_MODE_REPEAT: return "repeater"; 227 case IW_MODE_REPEAT: return "repeater";
228 case IW_MODE_SECOND: return "second"; 228 case IW_MODE_SECOND: return "second";
229 case IW_MODE_MONITOR: return "monitor"; 229 case IW_MODE_MONITOR: return "monitor";
230 default: assert( 0 ); 230 default: assert( 0 );
231 } 231 }
232} 232}
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 95c813f..6a9280f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,1190 +1,1188 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34/* OPIE */ 31/* OPIE */
35 32
36#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
37#include <opie2/ostation.h> 34#include <opie2/ostation.h>
38 35
39/* QT */ 36/* QT */
40 37
41#include <qfile.h> 38#include <qfile.h>
42#include <qtextstream.h> 39#include <qtextstream.h>
43 40
44/* UNIX */ 41/* UNIX */
45 42
46#include <assert.h> 43#include <assert.h>
47#include <arpa/inet.h> 44#include <arpa/inet.h>
48#include <errno.h> 45#include <errno.h>
49#include <string.h> 46#include <string.h>
50#include <stdlib.h> 47#include <stdlib.h>
51#include <math.h> 48#include <math.h>
52#include <sys/ioctl.h> 49#include <sys/ioctl.h>
53#include <sys/socket.h> 50#include <sys/socket.h>
54#include <sys/types.h> 51#include <sys/types.h>
55#include <unistd.h> 52#include <unistd.h>
56#include <linux/sockios.h> 53#include <linux/sockios.h>
57#include <net/if_arp.h> 54#include <net/if_arp.h>
58#include <stdarg.h> 55#include <stdarg.h>
59 56
60#ifndef NODEBUG 57#ifndef NODEBUG
61#include <opie2/odebugmapper.h> 58#include <opie2/odebugmapper.h>
62DebugMapper* debugmapper = new DebugMapper(); 59DebugMapper* debugmapper = new DebugMapper();
63#endif 60#endif
64 61
65/*====================================================================================== 62/*======================================================================================
66 * ONetwork 63 * ONetwork
67 *======================================================================================*/ 64 *======================================================================================*/
68 65
69ONetwork* ONetwork::_instance = 0; 66ONetwork* ONetwork::_instance = 0;
70 67
71ONetwork::ONetwork() 68ONetwork::ONetwork()
72{ 69{
73 qDebug( "ONetwork::ONetwork()" ); 70 qDebug( "ONetwork::ONetwork()" );
74 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); 71 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT );
75 synchronize(); 72 synchronize();
76} 73}
77 74
78void ONetwork::synchronize() 75void ONetwork::synchronize()
79{ 76{
80 // gather available interfaces by inspecting /proc/net/dev 77 // gather available interfaces by inspecting /proc/net/dev
81 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 78 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
82 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 79 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
83 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 80 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
84 81
85 _interfaces.clear(); 82 _interfaces.clear();
86 QString str; 83 QString str;
87 QFile f( "/proc/net/dev" ); 84 QFile f( "/proc/net/dev" );
88 bool hasFile = f.open( IO_ReadOnly ); 85 bool hasFile = f.open( IO_ReadOnly );
89 if ( !hasFile ) 86 if ( !hasFile )
90 { 87 {
91 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); 88 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
92 return; 89 return;
93 } 90 }
94 QTextStream s( &f ); 91 QTextStream s( &f );
95 s.readLine(); 92 s.readLine();
96 s.readLine(); 93 s.readLine();
97 while ( !s.atEnd() ) 94 while ( !s.atEnd() )
98 { 95 {
99 s >> str; 96 s >> str;
100 str.truncate( str.find( ':' ) ); 97 str.truncate( str.find( ':' ) );
101 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 98 qDebug( "ONetwork: found interface '%s'", (const char*) str );
102 ONetworkInterface* iface; 99 ONetworkInterface* iface;
103 if ( isWirelessInterface( str ) ) 100 if ( isWirelessInterface( str ) )
104 { 101 {
105 iface = new OWirelessNetworkInterface( this, (const char*) str ); 102 iface = new OWirelessNetworkInterface( this, (const char*) str );
106 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 103 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
107 } 104 }
108 else 105 else
109 { 106 {
110 iface = new ONetworkInterface( this, (const char*) str ); 107 iface = new ONetworkInterface( this, (const char*) str );
111 } 108 }
112 _interfaces.insert( str, iface ); 109 _interfaces.insert( str, iface );
113 s.readLine(); 110 s.readLine();
114 } 111 }
115} 112}
116 113
117 114
118short ONetwork::wirelessExtensionVersion() 115short ONetwork::wirelessExtensionVersion()
119{ 116{
120 return WIRELESS_EXT; 117 return WIRELESS_EXT;
121} 118}
122 119
123 120
124int ONetwork::count() const 121int ONetwork::count() const
125{ 122{
126 return _interfaces.count(); 123 return _interfaces.count();
127} 124}
128 125
129 126
130ONetworkInterface* ONetwork::interface( const QString& iface ) const 127ONetworkInterface* ONetwork::interface( const QString& iface ) const
131{ 128{
132 return _interfaces[iface]; 129 return _interfaces[iface];
133} 130}
134 131
135 132
136ONetwork* ONetwork::instance() 133ONetwork* ONetwork::instance()
137{ 134{
138 if ( !_instance ) _instance = new ONetwork(); 135 if ( !_instance ) _instance = new ONetwork();
139 return _instance; 136 return _instance;
140} 137}
141 138
142 139
143ONetwork::InterfaceIterator ONetwork::iterator() const 140ONetwork::InterfaceIterator ONetwork::iterator() const
144{ 141{
145 return ONetwork::InterfaceIterator( _interfaces ); 142 return ONetwork::InterfaceIterator( _interfaces );
146} 143}
147 144
148 145
149bool ONetwork::isWirelessInterface( const char* name ) const 146bool ONetwork::isWirelessInterface( const char* name ) const
150{ 147{
151 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 148 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
152 struct iwreq iwr; 149 struct iwreq iwr;
153 memset( &iwr, 0, sizeof( struct iwreq ) ); 150 memset( &iwr, 0, sizeof( struct iwreq ) );
154 strcpy( (char*) &iwr.ifr_name, name ); 151 strcpy( (char*) &iwr.ifr_name, name );
155 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 152 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
156 return result != -1; 153 return result != -1;
157} 154}
158 155
159/*====================================================================================== 156/*======================================================================================
160 * ONetworkInterface 157 * ONetworkInterface
161 *======================================================================================*/ 158 *======================================================================================*/
162 159
163ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) 160ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
164 :QObject( parent, name ), 161 :QObject( parent, name ),
165 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 162 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
166{ 163{
167 qDebug( "ONetworkInterface::ONetworkInterface()" ); 164 qDebug( "ONetworkInterface::ONetworkInterface()" );
168 init(); 165 init();
169} 166}
170 167
171 168
172struct ifreq& ONetworkInterface::ifr() const 169struct ifreq& ONetworkInterface::ifr() const
173{ 170{
174 return _ifr; 171 return _ifr;
175} 172}
176 173
177 174
178void ONetworkInterface::init() 175void ONetworkInterface::init()
179{ 176{
180 qDebug( "ONetworkInterface::init()" ); 177 qDebug( "ONetworkInterface::init()" );
181 178
182 memset( &_ifr, 0, sizeof( struct ifreq ) ); 179 memset( &_ifr, 0, sizeof( struct ifreq ) );
183 180
184 if ( _sfd == -1 ) 181 if ( _sfd == -1 )
185 { 182 {
186 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); 183 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() );
187 return; 184 return;
188 } 185 }
189} 186}
190 187
191 188
192bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const 189bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
193{ 190{
194 #ifndef NODEBUG 191 #ifndef NODEBUG
195 int result = ::ioctl( _sfd, call, &ifreq ); 192 int result = ::ioctl( _sfd, call, &ifreq );
196 if ( result == -1 ) 193 if ( result == -1 )
197 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); 194 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
198 else 195 else
199 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); 196 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
200 return ( result != -1 ); 197 return ( result != -1 );
201 #else 198 #else
202 return ::ioctl( _sfd, call, &ifreq ) != -1; 199 return ::ioctl( _sfd, call, &ifreq ) != -1;
203 #endif 200 #endif
204} 201}
205 202
206 203
207bool ONetworkInterface::ioctl( int call ) const 204bool ONetworkInterface::ioctl( int call ) const
208{ 205{
209 strcpy( _ifr.ifr_name, name() ); 206 strcpy( _ifr.ifr_name, name() );
210 return ioctl( call, _ifr ); 207 return ioctl( call, _ifr );
211} 208}
212 209
213 210
214bool ONetworkInterface::isLoopback() const 211bool ONetworkInterface::isLoopback() const
215{ 212{
216 ioctl( SIOCGIFFLAGS ); 213 ioctl( SIOCGIFFLAGS );
217 return _ifr.ifr_flags & IFF_LOOPBACK; 214 return _ifr.ifr_flags & IFF_LOOPBACK;
218} 215}
219 216
220 217
221bool ONetworkInterface::setUp( bool b ) 218bool ONetworkInterface::setUp( bool b )
222{ 219{
223 ioctl( SIOCGIFFLAGS ); 220 ioctl( SIOCGIFFLAGS );
224 if ( b ) _ifr.ifr_flags |= IFF_UP; 221 if ( b ) _ifr.ifr_flags |= IFF_UP;
225 else _ifr.ifr_flags &= (~IFF_UP); 222 else _ifr.ifr_flags &= (~IFF_UP);
226 return ioctl( SIOCSIFFLAGS ); 223 return ioctl( SIOCSIFFLAGS );
227} 224}
228 225
229 226
230bool ONetworkInterface::isUp() const 227bool ONetworkInterface::isUp() const
231{ 228{
232 ioctl( SIOCGIFFLAGS ); 229 ioctl( SIOCGIFFLAGS );
233 return _ifr.ifr_flags & IFF_UP; 230 return _ifr.ifr_flags & IFF_UP;
234} 231}
235 232
236 233
237void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) 234void ONetworkInterface::setIPV4Address( const QHostAddress& addr )
238{ 235{
239 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 236 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
240 sa->sin_family = AF_INET; 237 sa->sin_family = AF_INET;
241 sa->sin_port = 0; 238 sa->sin_port = 0;
242 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 239 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
243 ioctl( SIOCSIFADDR ); 240 ioctl( SIOCSIFADDR );
244} 241}
245 242
246 243
247QString ONetworkInterface::ipV4Address() const 244QString ONetworkInterface::ipV4Address() const
248{ 245{
249 if ( ioctl( SIOCGIFADDR ) ) 246 if ( ioctl( SIOCGIFADDR ) )
250 { 247 {
251 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; 248 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
252 //FIXME: Use QHostAddress here 249 //FIXME: Use QHostAddress here
253 return QString( inet_ntoa( sa->sin_addr ) ); 250 return QString( inet_ntoa( sa->sin_addr ) );
254 } 251 }
255 else 252 else
256 return "<unknown>"; 253 return "<unknown>";
257 254
258} 255}
259 256
260 257
261void ONetworkInterface::setMacAddress( const OMacAddress& addr ) 258void ONetworkInterface::setMacAddress( const OMacAddress& addr )
262{ 259{
263 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; 260 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
264 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); 261 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 );
265 ioctl( SIOCSIFHWADDR ); 262 ioctl( SIOCSIFHWADDR );
266} 263}
267 264
268 265
269OMacAddress ONetworkInterface::macAddress() const 266OMacAddress ONetworkInterface::macAddress() const
270{ 267{
271 if ( ioctl( SIOCGIFHWADDR ) ) 268 if ( ioctl( SIOCGIFHWADDR ) )
272 { 269 {
273 return OMacAddress( _ifr ); 270 return OMacAddress( _ifr );
274 } 271 }
275 else 272 else
276 { 273 {
277 return OMacAddress::unknown; 274 return OMacAddress::unknown;
278 } 275 }
279} 276}
280 277
281 278
282void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) 279void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr )
283{ 280{
284 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 281 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
285 sa->sin_family = AF_INET; 282 sa->sin_family = AF_INET;
286 sa->sin_port = 0; 283 sa->sin_port = 0;
287 sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); 284 sa->sin_addr.s_addr = htonl( addr.ip4Addr() );
288 ioctl( SIOCSIFNETMASK ); 285 ioctl( SIOCSIFNETMASK );
289} 286}
290 287
291 288
292QString ONetworkInterface::ipV4Netmask() const 289QString ONetworkInterface::ipV4Netmask() const
293{ 290{
294 if ( ioctl( SIOCGIFNETMASK ) ) 291 if ( ioctl( SIOCGIFNETMASK ) )
295 { 292 {
296 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; 293 struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr;
297 //FIXME: Use QHostAddress here 294 //FIXME: Use QHostAddress here
298 return QString( inet_ntoa( sa->sin_addr ) ); 295 return QString( inet_ntoa( sa->sin_addr ) );
299 } 296 }
300 else 297 else
301 return "<unknown>"; 298 return "<unknown>";
302} 299}
303 300
304 301
305int ONetworkInterface::dataLinkType() const 302int ONetworkInterface::dataLinkType() const
306{ 303{
307 if ( ioctl( SIOCGIFHWADDR ) ) 304 if ( ioctl( SIOCGIFHWADDR ) )
308 { 305 {
309 return _ifr.ifr_hwaddr.sa_family; 306 return _ifr.ifr_hwaddr.sa_family;
310 } 307 }
311 else 308 else
312 { 309 {
313 return -1; 310 return -1;
314 } 311 }
315} 312}
316 313
317 314
318void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 315void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
319{ 316{
320 _mon = m; 317 _mon = m;
321 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); 318 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() );
322} 319}
323 320
324 321
325OMonitoringInterface* ONetworkInterface::monitoring() const 322OMonitoringInterface* ONetworkInterface::monitoring() const
326{ 323{
327 return _mon; 324 return _mon;
328} 325}
329 326
330 327
331ONetworkInterface::~ONetworkInterface() 328ONetworkInterface::~ONetworkInterface()
332{ 329{
333 qDebug( "ONetworkInterface::~ONetworkInterface()" ); 330 qDebug( "ONetworkInterface::~ONetworkInterface()" );
334 if ( _sfd != -1 ) ::close( _sfd ); 331 if ( _sfd != -1 ) ::close( _sfd );
335} 332}
336 333
337 334
338bool ONetworkInterface::setPromiscuousMode( bool b ) 335bool ONetworkInterface::setPromiscuousMode( bool b )
339{ 336{
340 ioctl( SIOCGIFFLAGS ); 337 ioctl( SIOCGIFFLAGS );
341 if ( b ) _ifr.ifr_flags |= IFF_PROMISC; 338 if ( b ) _ifr.ifr_flags |= IFF_PROMISC;
342 else _ifr.ifr_flags &= (~IFF_PROMISC); 339 else _ifr.ifr_flags &= (~IFF_PROMISC);
343 return ioctl( SIOCSIFFLAGS ); 340 return ioctl( SIOCSIFFLAGS );
344} 341}
345 342
346 343
347bool ONetworkInterface::promiscuousMode() const 344bool ONetworkInterface::promiscuousMode() const
348{ 345{
349 ioctl( SIOCGIFFLAGS ); 346 ioctl( SIOCGIFFLAGS );
350 return _ifr.ifr_flags & IFF_PROMISC; 347 return _ifr.ifr_flags & IFF_PROMISC;
351} 348}
352 349
353 350
354bool ONetworkInterface::isWireless() const 351bool ONetworkInterface::isWireless() const
355{ 352{
356 return ioctl( SIOCGIWNAME ); 353 return ioctl( SIOCGIWNAME );
357} 354}
358 355
359 356
360/*====================================================================================== 357/*======================================================================================
361 * OChannelHopper 358 * OChannelHopper
362 *======================================================================================*/ 359 *======================================================================================*/
363 360
364OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) 361OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
365 :QObject( 0, "Mickey's funky hopper" ), 362 :QObject( 0, "Mickey's funky hopper" ),
366 _iface( iface ), _interval( 0 ), _tid( 0 ) 363 _iface( iface ), _interval( 0 ), _tid( 0 )
367{ 364{
368 int _maxChannel = iface->channels()+1; 365 int _maxChannel = iface->channels()+1;
369 // generate fancy hopping sequence honoring the device capabilities 366 // generate fancy hopping sequence honoring the device capabilities
370 if ( _maxChannel >= 1 ) _channels.append( 1 ); 367 if ( _maxChannel >= 1 ) _channels.append( 1 );
371 if ( _maxChannel >= 7 ) _channels.append( 7 ); 368 if ( _maxChannel >= 7 ) _channels.append( 7 );
372 if ( _maxChannel >= 13 ) _channels.append( 13 ); 369 if ( _maxChannel >= 13 ) _channels.append( 13 );
373 if ( _maxChannel >= 2 ) _channels.append( 2 ); 370 if ( _maxChannel >= 2 ) _channels.append( 2 );
374 if ( _maxChannel >= 8 ) _channels.append( 8 ); 371 if ( _maxChannel >= 8 ) _channels.append( 8 );
375 if ( _maxChannel >= 3 ) _channels.append( 3 ); 372 if ( _maxChannel >= 3 ) _channels.append( 3 );
376 if ( _maxChannel >= 14 ) _channels.append( 14 ); 373 if ( _maxChannel >= 14 ) _channels.append( 14 );
377 if ( _maxChannel >= 9 ) _channels.append( 9 ); 374 if ( _maxChannel >= 9 ) _channels.append( 9 );
378 if ( _maxChannel >= 4 ) _channels.append( 4 ); 375 if ( _maxChannel >= 4 ) _channels.append( 4 );
379 if ( _maxChannel >= 10 ) _channels.append( 10 ); 376 if ( _maxChannel >= 10 ) _channels.append( 10 );
380 if ( _maxChannel >= 5 ) _channels.append( 5 ); 377 if ( _maxChannel >= 5 ) _channels.append( 5 );
381 if ( _maxChannel >= 11 ) _channels.append( 11 ); 378 if ( _maxChannel >= 11 ) _channels.append( 11 );
382 if ( _maxChannel >= 6 ) _channels.append( 6 ); 379 if ( _maxChannel >= 6 ) _channels.append( 6 );
383 if ( _maxChannel >= 12 ) _channels.append( 12 ); 380 if ( _maxChannel >= 12 ) _channels.append( 12 );
384 _channel = _channels.begin(); 381 _channel = _channels.begin();
385 382
386} 383}
387 384
388 385
389OChannelHopper::~OChannelHopper() 386OChannelHopper::~OChannelHopper()
390{ 387{
391} 388}
392 389
393 390
394bool OChannelHopper::isActive() const 391bool OChannelHopper::isActive() const
395{ 392{
396 return _tid; 393 return _tid;
397} 394}
398 395
399 396
400int OChannelHopper::channel() const 397int OChannelHopper::channel() const
401{ 398{
402 return *_channel; 399 return *_channel;
403} 400}
404 401
405 402
406void OChannelHopper::timerEvent( QTimerEvent* ) 403void OChannelHopper::timerEvent( QTimerEvent* )
407{ 404{
408 _iface->setChannel( *_channel ); 405 _iface->setChannel( *_channel );
409 emit( hopped( *_channel ) ); 406 emit( hopped( *_channel ) );
410 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", 407 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'",
411 *_channel, (const char*) _iface->name() ); 408 *_channel, (const char*) _iface->name() );
412 if ( ++_channel == _channels.end() ) _channel = _channels.begin(); 409 if ( ++_channel == _channels.end() ) _channel = _channels.begin();
413} 410}
414 411
415 412
416void OChannelHopper::setInterval( int interval ) 413void OChannelHopper::setInterval( int interval )
417{ 414{
418 if ( interval == _interval ) 415 if ( interval == _interval )
419 return; 416 return;
420 417
421 if ( _interval ) 418 if ( _interval )
422 killTimer( _tid ); 419 killTimer( _tid );
423 420
424 _tid = 0; 421 _tid = 0;
425 _interval = interval; 422 _interval = interval;
426 423
427 if ( _interval ) 424 if ( _interval )
428 { 425 {
429 _tid = startTimer( interval ); 426 _tid = startTimer( interval );
430 } 427 }
431} 428}
432 429
433 430
434int OChannelHopper::interval() const 431int OChannelHopper::interval() const
435{ 432{
436 return _interval; 433 return _interval;
437} 434}
438 435
439 436
440/*====================================================================================== 437/*======================================================================================
441 * OWirelessNetworkInterface 438 * OWirelessNetworkInterface
442 *======================================================================================*/ 439 *======================================================================================*/
443 440
444OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) 441OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name )
445 :ONetworkInterface( parent, name ), _hopper( 0 ) 442 :ONetworkInterface( parent, name ), _hopper( 0 )
446{ 443{
447 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); 444 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
448 init(); 445 init();
449} 446}
450 447
451 448
452OWirelessNetworkInterface::~OWirelessNetworkInterface() 449OWirelessNetworkInterface::~OWirelessNetworkInterface()
453{ 450{
454} 451}
455 452
456 453
457struct iwreq& OWirelessNetworkInterface::iwr() const 454struct iwreq& OWirelessNetworkInterface::iwr() const
458{ 455{
459 return _iwr; 456 return _iwr;
460} 457}
461 458
462 459
463void OWirelessNetworkInterface::init() 460void OWirelessNetworkInterface::init()
464{ 461{
465 qDebug( "OWirelessNetworkInterface::init()" ); 462 qDebug( "OWirelessNetworkInterface::init()" );
466 memset( &_iwr, 0, sizeof( struct iwreq ) ); 463 memset( &_iwr, 0, sizeof( struct iwreq ) );
467 buildInformation(); 464 buildInformation();
468 buildPrivateList(); 465 buildPrivateList();
469 dumpInformation(); 466 dumpInformation();
470} 467}
471 468
472 469
473bool OWirelessNetworkInterface::isAssociated() const 470bool OWirelessNetworkInterface::isAssociated() const
474{ 471{
475 //FIXME: handle different modes 472 //FIXME: handle different modes
476 return !(associatedAP() == OMacAddress::unknown); 473 return !(associatedAP() == OMacAddress::unknown);
477} 474}
478 475
479 476
480OMacAddress OWirelessNetworkInterface::associatedAP() const 477OMacAddress OWirelessNetworkInterface::associatedAP() const
481{ 478{
482 if ( ioctl( SIOCGIWAP ) ) 479 if ( ioctl( SIOCGIWAP ) )
483 return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; 480 return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0];
484 else 481 else
485 return OMacAddress::unknown; 482 return OMacAddress::unknown;
486} 483}
487 484
488 485
489void OWirelessNetworkInterface::buildInformation() 486void OWirelessNetworkInterface::buildInformation()
490{ 487{
491 //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck 488 //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck
492 //ML: The HostAP drivers need more than sizeof struct_iw range to complete 489 //ML: The HostAP drivers need more than sizeof struct_iw range to complete
493 //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". 490 //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length".
494 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate 491 //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate
495 //ML: _too much_ space. This is damn shitty crap *sigh* 492 //ML: _too much_ space. This is damn shitty crap *sigh*
496 //ML: We allocate a large memory region in RAM and check whether the 493 //ML: We allocate a large memory region in RAM and check whether the
497 //ML: driver pollutes this extra space. The complaint will be made on stdout, 494 //ML: driver pollutes this extra space. The complaint will be made on stdout,
498 //ML: so please forward this... 495 //ML: so please forward this...
499 496
500 struct iwreq wrq; 497 struct iwreq wrq;
501 int len = sizeof( struct iw_range )*2; 498 int len = sizeof( struct iw_range )*2;
502 char *buffer = (char*) malloc( len ); 499 char *buffer = (char*) malloc( len );
503 //FIXME: Validate if we actually got the memory block 500 //FIXME: Validate if we actually got the memory block
504 memset( buffer, 0, len ); 501 memset( buffer, 0, len );
505 memcpy( wrq.ifr_name, name(), IFNAMSIZ); 502 memcpy( wrq.ifr_name, name(), IFNAMSIZ);
506 wrq.u.data.pointer = (caddr_t) buffer; 503 wrq.u.data.pointer = (caddr_t) buffer;
507 wrq.u.data.length = sizeof( struct iw_range ); 504 wrq.u.data.length = sizeof( struct iw_range );
508 wrq.u.data.flags = 0; 505 wrq.u.data.flags = 0;
509 506
510 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) 507 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 )
511 { 508 {
512 qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); 509 qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) );
513 _channels.insert( 2412, 1 ); // 2.412 GHz 510 _channels.insert( 2412, 1 ); // 2.412 GHz
514 _channels.insert( 2417, 2 ); // 2.417 GHz 511 _channels.insert( 2417, 2 ); // 2.417 GHz
515 _channels.insert( 2422, 3 ); // 2.422 GHz 512 _channels.insert( 2422, 3 ); // 2.422 GHz
516 _channels.insert( 2427, 4 ); // 2.427 GHz 513 _channels.insert( 2427, 4 ); // 2.427 GHz
517 _channels.insert( 2432, 5 ); // 2.432 GHz 514 _channels.insert( 2432, 5 ); // 2.432 GHz
518 _channels.insert( 2437, 6 ); // 2.437 GHz 515 _channels.insert( 2437, 6 ); // 2.437 GHz
519 _channels.insert( 2442, 7 ); // 2.442 GHz 516 _channels.insert( 2442, 7 ); // 2.442 GHz
520 _channels.insert( 2447, 8 ); // 2.447 GHz 517 _channels.insert( 2447, 8 ); // 2.447 GHz
521 _channels.insert( 2452, 9 ); // 2.452 GHz 518 _channels.insert( 2452, 9 ); // 2.452 GHz
522 _channels.insert( 2457, 10 ); // 2.457 GHz 519 _channels.insert( 2457, 10 ); // 2.457 GHz
523 _channels.insert( 2462, 11 ); // 2.462 GHz 520 _channels.insert( 2462, 11 ); // 2.462 GHz
524 521
525 memset( &_range, 0, sizeof( struct iw_range ) ); 522 memset( &_range, 0, sizeof( struct iw_range ) );
526 } 523 }
527 else 524 else
528 { 525 {
529 // <check if the driver overwrites stuff> 526 // <check if the driver overwrites stuff>
530 int max = 0; 527 int max = 0;
531 for ( int r = sizeof( struct iw_range ); r < len; r++ ) 528 for ( int r = sizeof( struct iw_range ); r < len; r++ )
532 if (buffer[r] != 0) 529 if (buffer[r] != 0)
533 max = r; 530 max = r;
534 if (max > 0) 531 if (max > 0)
535 { 532 {
536 qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" 533 qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n"
537 "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); 534 "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) );
538 } 535 }
539 // </check if the driver overwrites stuff> 536 // </check if the driver overwrites stuff>
540 537
541 struct iw_range range; 538 struct iw_range range;
542 memcpy( &range, buffer, sizeof range ); 539 memcpy( &range, buffer, sizeof range );
543 540
544 qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); 541 qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency );
545 for ( int i = 0; i < range.num_frequency; ++i ) 542 for ( int i = 0; i < range.num_frequency; ++i )
546 { 543 {
547 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); 544 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
548 _channels.insert( freq, i+1 ); 545 _channels.insert( freq, i+1 );
549 } 546 }
550 } 547 }
551 548
552 memcpy( &_range, buffer, sizeof( struct iw_range ) ); 549 memcpy( &_range, buffer, sizeof( struct iw_range ) );
553 qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); 550 qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." );
554 free(buffer); 551 free(buffer);
555} 552}
556 553
557 554
558void OWirelessNetworkInterface::buildPrivateList() 555void OWirelessNetworkInterface::buildPrivateList()
559{ 556{
560 qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); 557 qDebug( "OWirelessNetworkInterface::buildPrivateList()" );
561 558
562 struct iw_priv_args priv[IW_MAX_PRIV_DEF]; 559 struct iw_priv_args priv[IW_MAX_PRIV_DEF];
563 560
564 _iwr.u.data.pointer = (char*) &priv; 561 _iwr.u.data.pointer = (char*) &priv;
565 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself 562 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
566 _iwr.u.data.flags = 0; 563 _iwr.u.data.flags = 0;
567 564
568 if ( !wioctl( SIOCGIWPRIV ) ) 565 if ( !wioctl( SIOCGIWPRIV ) )
569 { 566 {
570 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); 567 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) );
571 return; 568 return;
572 } 569 }
573 570
574 for ( int i = 0; i < _iwr.u.data.length; ++i ) 571 for ( int i = 0; i < _iwr.u.data.length; ++i )
575 { 572 {
576 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); 573 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
577 } 574 }
578 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); 575 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." );
579} 576}
580 577
581 578
582void OWirelessNetworkInterface::dumpInformation() const 579void OWirelessNetworkInterface::dumpInformation() const
583{ 580{
584 qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); 581 qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" );
585 582
586 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); 583 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 );
587 qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); 584 qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source );
588 585
589 qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); 586 qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" );
590} 587}
591 588
592 589
593int OWirelessNetworkInterface::channel() const 590int OWirelessNetworkInterface::channel() const
594{ 591{
595 //FIXME: When monitoring enabled, then use it 592 //FIXME: When monitoring enabled, then use it
596 //FIXME: to gather the current RF channel 593 //FIXME: to gather the current RF channel
597 //FIXME: Until then, get active channel from hopper. 594 //FIXME: Until then, get active channel from hopper.
598 if ( _hopper && _hopper->isActive() ) 595 if ( _hopper && _hopper->isActive() )
599 return _hopper->channel(); 596 return _hopper->channel();
600 597
601 if ( !wioctl( SIOCGIWFREQ ) ) 598 if ( !wioctl( SIOCGIWFREQ ) )
602 { 599 {
603 return -1; 600 return -1;
604 } 601 }
605 else 602 else
606 { 603 {
607 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; 604 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ];
608 } 605 }
609} 606}
610 607
611 608
612void OWirelessNetworkInterface::setChannel( int c ) const 609void OWirelessNetworkInterface::setChannel( int c ) const
613{ 610{
614 if ( !c ) 611 if ( !c )
615 { 612 {
616 qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); 613 qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" );
617 return; 614 return;
618 } 615 }
619 616
620 if ( !_mon ) 617 if ( !_mon )
621 { 618 {
622 memset( &_iwr, 0, sizeof( struct iwreq ) ); 619 memset( &_iwr, 0, sizeof( struct iwreq ) );
623 _iwr.u.freq.m = c; 620 _iwr.u.freq.m = c;
624 _iwr.u.freq.e = 0; 621 _iwr.u.freq.e = 0;
625 wioctl( SIOCSIWFREQ ); 622 wioctl( SIOCSIWFREQ );
626 } 623 }
627 else 624 else
628 { 625 {
629 _mon->setChannel( c ); 626 _mon->setChannel( c );
630 } 627 }
631} 628}
632 629
633 630
634double OWirelessNetworkInterface::frequency() const 631double OWirelessNetworkInterface::frequency() const
635{ 632{
636 if ( !wioctl( SIOCGIWFREQ ) ) 633 if ( !wioctl( SIOCGIWFREQ ) )
637 { 634 {
638 return -1.0; 635 return -1.0;
639 } 636 }
640 else 637 else
641 { 638 {
642 return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; 639 return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0;
643 } 640 }
644} 641}
645 642
646 643
647int OWirelessNetworkInterface::channels() const 644int OWirelessNetworkInterface::channels() const
648{ 645{
649 return _channels.count(); 646 return _channels.count();
650} 647}
651 648
652 649
653void OWirelessNetworkInterface::setChannelHopping( int interval ) 650void OWirelessNetworkInterface::setChannelHopping( int interval )
654{ 651{
655 if ( !_hopper ) _hopper = new OChannelHopper( this ); 652 if ( !_hopper ) _hopper = new OChannelHopper( this );
656 _hopper->setInterval( interval ); 653 _hopper->setInterval( interval );
657 //FIXME: When and by whom will the channel hopper be deleted? 654 //FIXME: When and by whom will the channel hopper be deleted?
658 //TODO: rely on QObject hierarchy 655 //TODO: rely on QObject hierarchy
659} 656}
660 657
661 658
662int OWirelessNetworkInterface::channelHopping() const 659int OWirelessNetworkInterface::channelHopping() const
663{ 660{
664 return _hopper->interval(); 661 return _hopper->interval();
665} 662}
666 663
667 664
668OChannelHopper* OWirelessNetworkInterface::channelHopper() const 665OChannelHopper* OWirelessNetworkInterface::channelHopper() const
669{ 666{
670 return _hopper; 667 return _hopper;
671} 668}
672 669
673 670
674void OWirelessNetworkInterface::commit() const 671void OWirelessNetworkInterface::commit() const
675{ 672{
676 wioctl( SIOCSIWCOMMIT ); 673 wioctl( SIOCSIWCOMMIT );
677} 674}
678 675
679 676
680void OWirelessNetworkInterface::setMode( const QString& newMode ) 677void OWirelessNetworkInterface::setMode( const QString& newMode )
681{ 678{
682 #ifdef FINALIZE 679 #ifdef FINALIZE
683 QString currentMode = mode(); 680 QString currentMode = mode();
684 if ( currentMode == newMode ) return; 681 if ( currentMode == newMode ) return;
685 #endif 682 #endif
686 683
687 qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) ); 684 qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) );
688 685
689 _iwr.u.mode = stringToMode( newMode ); 686 _iwr.u.mode = stringToMode( newMode );
690 687
691 if ( _iwr.u.mode != IW_MODE_MONITOR ) 688 if ( _iwr.u.mode != IW_MODE_MONITOR )
692 { 689 {
693 // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! 690 // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP!
694 _iwr.u.mode = stringToMode( newMode ); 691 _iwr.u.mode = stringToMode( newMode );
695 wioctl( SIOCSIWMODE ); 692 wioctl( SIOCSIWMODE );
696 693
697 // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) 694 // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now)
698 695
699 if ( mode() == "monitor" ) 696 if ( mode() == "monitor" )
700 { 697 {
701 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." ); 698 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." );
702 if ( _mon ) 699 if ( _mon )
703 _mon->setEnabled( false ); 700 _mon->setEnabled( false );
704 else 701 else
705 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 702 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
706 } 703 }
707 704
708 } 705 }
709 else // special iwpriv fallback for monitor mode 706 else // special iwpriv fallback for monitor mode
710 { 707 {
711 if ( wioctl( SIOCSIWMODE ) ) 708 if ( wioctl( SIOCSIWMODE ) )
712 { 709 {
713 qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); 710 qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" );
714 } 711 }
715 else 712 else
716 { 713 {
717 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." ); 714 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." );
718 715
719 if ( _mon ) 716 if ( _mon )
720 _mon->setEnabled( true ); 717 _mon->setEnabled( true );
721 else 718 else
722 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 719 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
723 } 720 }
724 } 721 }
725} 722}
726 723
727 724
728QString OWirelessNetworkInterface::mode() const 725QString OWirelessNetworkInterface::mode() const
729{ 726{
730 memset( &_iwr, 0, sizeof( struct iwreq ) ); 727 memset( &_iwr, 0, sizeof( struct iwreq ) );
731 728
732 if ( !wioctl( SIOCGIWMODE ) ) 729 if ( !wioctl( SIOCGIWMODE ) )
733 { 730 {
734 return "<unknown>"; 731 return "<unknown>";
735 } 732 }
736 733
737 qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) ); 734 qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) );
738 735
739 // legacy compatible monitor mode check 736 // legacy compatible monitor mode check
740 737
741 if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) 738 if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 )
742 { 739 {
743 return "monitor"; 740 return "monitor";
744 } 741 }
745 else 742 else
746 { 743 {
747 return modeToString( _iwr.u.mode ); 744 return modeToString( _iwr.u.mode );
748 } 745 }
749} 746}
750 747
751void OWirelessNetworkInterface::setNickName( const QString& nickname ) 748void OWirelessNetworkInterface::setNickName( const QString& nickname )
752{ 749{
753 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); 750 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname );
754 _iwr.u.essid.length = nickname.length(); 751 _iwr.u.essid.length = nickname.length();
755 wioctl( SIOCSIWNICKN ); 752 wioctl( SIOCSIWNICKN );
756} 753}
757 754
758 755
759QString OWirelessNetworkInterface::nickName() const 756QString OWirelessNetworkInterface::nickName() const
760{ 757{
761 char str[IW_ESSID_MAX_SIZE]; 758 char str[IW_ESSID_MAX_SIZE];
762 _iwr.u.data.pointer = &str[0]; 759 _iwr.u.data.pointer = &str[0];
763 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 760 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
764 if ( !wioctl( SIOCGIWNICKN ) ) 761 if ( !wioctl( SIOCGIWNICKN ) )
765 { 762 {
766 return "<unknown>"; 763 return "<unknown>";
767 } 764 }
768 else 765 else
769 { 766 {
770 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 767 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
771 return str; 768 return str;
772 } 769 }
773} 770}
774 771
775 772
776void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) 773void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
777{ 774{
778 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 775 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
779 if ( !priv ) 776 if ( !priv )
780 { 777 {
781 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); 778 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call );
782 return; 779 return;
783 } 780 }
784 if ( priv->numberSetArgs() != numargs ) 781 if ( priv->numberSetArgs() != numargs )
785 { 782 {
786 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); 783 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs );
787 return; 784 return;
788 } 785 }
789 786
790 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); 787 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() );
791 memset( &_iwr, 0, sizeof _iwr ); 788 memset( &_iwr, 0, sizeof _iwr );
792 va_list argp; 789 va_list argp;
793 va_start( argp, numargs ); 790 va_start( argp, numargs );
794 for ( int i = 0; i < numargs; ++i ) 791 for ( int i = 0; i < numargs; ++i )
795 { 792 {
796 priv->setParameter( i, va_arg( argp, int ) ); 793 priv->setParameter( i, va_arg( argp, int ) );
797 } 794 }
798 va_end( argp ); 795 va_end( argp );
799 priv->invoke(); 796 priv->invoke();
800} 797}
801 798
802 799
803void OWirelessNetworkInterface::getPrivate( const QString& call ) 800void OWirelessNetworkInterface::getPrivate( const QString& call )
804{ 801{
805 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); 802 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
806} 803}
807 804
808 805
809bool OWirelessNetworkInterface::hasPrivate( const QString& call ) 806bool OWirelessNetworkInterface::hasPrivate( const QString& call )
810{ 807{
811 return child( (const char*) call ); 808 return child( (const char*) call );
812} 809}
813 810
814 811
815QString OWirelessNetworkInterface::SSID() const 812QString OWirelessNetworkInterface::SSID() const
816{ 813{
817 char str[IW_ESSID_MAX_SIZE]; 814 char str[IW_ESSID_MAX_SIZE];
818 _iwr.u.essid.pointer = &str[0]; 815 _iwr.u.essid.pointer = &str[0];
819 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 816 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
820 if ( !wioctl( SIOCGIWESSID ) ) 817 if ( !wioctl( SIOCGIWESSID ) )
821 { 818 {
822 return "<unknown>"; 819 return "<unknown>";
823 } 820 }
824 else 821 else
825 { 822 {
826 return str; 823 return str;
827 } 824 }
828} 825}
829 826
830 827
831void OWirelessNetworkInterface::setSSID( const QString& ssid ) 828void OWirelessNetworkInterface::setSSID( const QString& ssid )
832{ 829{
833 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 830 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
834 _iwr.u.essid.length = ssid.length(); 831 _iwr.u.essid.length = ssid.length();
835 wioctl( SIOCSIWESSID ); 832 wioctl( SIOCSIWESSID );
836} 833}
837 834
838 835
839OStationList* OWirelessNetworkInterface::scanNetwork() 836OStationList* OWirelessNetworkInterface::scanNetwork()
840{ 837{
841 _iwr.u.param.flags = IW_SCAN_DEFAULT; 838 _iwr.u.param.flags = IW_SCAN_DEFAULT;
842 _iwr.u.param.value = 0; 839 _iwr.u.param.value = 0;
843 if ( !wioctl( SIOCSIWSCAN ) ) 840 if ( !wioctl( SIOCSIWSCAN ) )
844 { 841 {
845 return 0; 842 return 0;
846 } 843 }
847 844
848 OStationList* stations = new OStationList(); 845 OStationList* stations = new OStationList();
849 846
850 int timeout = 1000000; 847 int timeout = 1000000;
851 848
852 qDebug( "ONetworkInterface::scanNetwork() - scan started." ); 849 qDebug( "ONetworkInterface::scanNetwork() - scan started." );
853 850
854 bool results = false; 851 bool results = false;
855 struct timeval tv; 852 struct timeval tv;
856 tv.tv_sec = 0; 853 tv.tv_sec = 0;
857 tv.tv_usec = 250000; // initial timeout ~ 250ms 854 tv.tv_usec = 250000; // initial timeout ~ 250ms
858 char buffer[IW_SCAN_MAX_DATA]; 855 char buffer[IW_SCAN_MAX_DATA];
859 856
860 while ( !results && timeout > 0 ) 857 while ( !results && timeout > 0 )
861 { 858 {
862 timeout -= tv.tv_usec; 859 timeout -= tv.tv_usec;
863 select( 0, 0, 0, 0, &tv ); 860 select( 0, 0, 0, 0, &tv );
864 861
865 _iwr.u.data.pointer = &buffer[0]; 862 _iwr.u.data.pointer = &buffer[0];
866 _iwr.u.data.flags = 0; 863 _iwr.u.data.flags = 0;
867 _iwr.u.data.length = sizeof buffer; 864 _iwr.u.data.length = sizeof buffer;
868 if ( wioctl( SIOCGIWSCAN ) ) 865 if ( wioctl( SIOCGIWSCAN ) )
869 { 866 {
870 results = true; 867 results = true;
871 continue; 868 continue;
872 } 869 }
873 else if ( errno == EAGAIN) 870 else if ( errno == EAGAIN)
874 { 871 {
875 qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); 872 qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." );
876 #if 0 873 #if 0
877 if ( qApp ) 874 if ( qApp )
878 { 875 {
879 qApp->processEvents( 100 ); 876 qApp->processEvents( 100 );
880 continue; 877 continue;
881 } 878 }
882 #endif 879 #endif
883 tv.tv_sec = 0; 880 tv.tv_sec = 0;
884 tv.tv_usec = 100000; 881 tv.tv_usec = 100000;
885 continue; 882 continue;
886 } 883 }
887 } 884 }
888 885
889 qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); 886 qDebug( "ONetworkInterface::scanNetwork() - scan finished." );
890 887
891 if ( results ) 888 if ( results )
892 { 889 {
893 qDebug( " - result length = %d", _iwr.u.data.length ); 890 qDebug( " - result length = %d", _iwr.u.data.length );
894 if ( !_iwr.u.data.length ) 891 if ( !_iwr.u.data.length )
895 { 892 {
896 qDebug( " - no results (empty neighbourhood)" ); 893 qDebug( " - no results (empty neighbourhood)" );
897 return stations; 894 return stations;
898 } 895 }
899 896
900 qDebug( " - results are in!" ); 897 qDebug( " - results are in!" );
901 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); 898 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
902 899
903 // parse results 900 // parse results
904 901
905 int offset = 0; 902 int offset = 0;
906 struct iw_event* we = (struct iw_event*) &buffer[0]; 903 struct iw_event* we = (struct iw_event*) &buffer[0];
907 904
908 while ( offset < _iwr.u.data.length ) 905 while ( offset < _iwr.u.data.length )
909 { 906 {
910 //const char* cmd = *(*_ioctlmap)[we->cmd]; 907 //const char* cmd = *(*_ioctlmap)[we->cmd];
911 //if ( !cmd ) cmd = "<unknown>"; 908 //if ( !cmd ) cmd = "<unknown>";
912 qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); 909 qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len );
913 switch (we->cmd) 910 switch (we->cmd)
914 { 911 {
915 case SIOCGIWAP: 912 case SIOCGIWAP:
916 { 913 {
917 qDebug( "SIOCGIWAP" ); 914 qDebug( "SIOCGIWAP" );
918 stations->append( new OStation() ); 915 stations->append( new OStation() );
919 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; 916 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
920 break; 917 break;
921 } 918 }
922 case SIOCGIWMODE: 919 case SIOCGIWMODE:
923 { 920 {
924 qDebug( "SIOCGIWMODE" ); 921 qDebug( "SIOCGIWMODE" );
925 stations->last()->type = modeToString( we->u.mode ); 922 stations->last()->type = modeToString( we->u.mode );
926 break; 923 break;
927 } 924 }
928 case SIOCGIWFREQ: 925 case SIOCGIWFREQ:
929 { 926 {
930 qDebug( "SIOCGIWFREQ" ); 927 qDebug( "SIOCGIWFREQ" );
931 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; 928 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
932 break; 929 break;
933 } 930 }
934 case SIOCGIWESSID: 931 case SIOCGIWESSID:
935 { 932 {
936 qDebug( "SIOCGIWESSID" ); 933 qDebug( "SIOCGIWESSID" );
937 stations->last()->ssid = we->u.essid.pointer; 934 stations->last()->ssid = we->u.essid.pointer;
938 break; 935 break;
939 } 936 }
940 case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; 937 case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break;
941 case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; 938 case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break;
942 case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ 939 case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */
943 case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ 940 case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */
944 case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ 941 case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */
945 case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ 942 case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */
946 case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ 943 case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */
947 default: qDebug( "unhandled event" ); 944 default: qDebug( "unhandled event" );
948 } 945 }
949 946
950 offset += we->len; 947 offset += we->len;
951 we = (struct iw_event*) &buffer[offset]; 948 we = (struct iw_event*) &buffer[offset];
952 } 949 }
950 return stations;
953 951
954 return stations; 952 return stations;
955 953
956 } 954 }
957 else 955 else
958 { 956 {
959 qDebug( " - no results (timeout) :(" ); 957 qDebug( " - no results (timeout) :(" );
960 return stations; 958 return stations;
961 } 959 }
962} 960}
963 961
964 962
965bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 963bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
966{ 964{
967 #ifndef NODEBUG 965 #ifndef NODEBUG
968 int result = ::ioctl( _sfd, call, &iwreq ); 966 int result = ::ioctl( _sfd, call, &iwreq );
969 if ( result == -1 ) 967 if ( result == -1 )
970 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); 968 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) );
971 else 969 else
972 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); 970 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call );
973 return ( result != -1 ); 971 return ( result != -1 );
974 #else 972 #else
975 return ::ioctl( _sfd, call, &iwreq ) != -1; 973 return ::ioctl( _sfd, call, &iwreq ) != -1;
976 #endif 974 #endif
977} 975}
978 976
979 977
980bool OWirelessNetworkInterface::wioctl( int call ) const 978bool OWirelessNetworkInterface::wioctl( int call ) const
981{ 979{
982 strcpy( _iwr.ifr_name, name() ); 980 strcpy( _iwr.ifr_name, name() );
983 return wioctl( call, _iwr ); 981 return wioctl( call, _iwr );
984} 982}
985 983
986 984
987/*====================================================================================== 985/*======================================================================================
988 * OMonitoringInterface 986 * OMonitoringInterface
989 *======================================================================================*/ 987 *======================================================================================*/
990 988
991OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 989OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
992 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 990 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
993{ 991{
994} 992}
995 993
996 994
997OMonitoringInterface::~OMonitoringInterface() 995OMonitoringInterface::~OMonitoringInterface()
998{ 996{
999} 997}
1000 998
1001 999
1002void OMonitoringInterface::setChannel( int c ) 1000void OMonitoringInterface::setChannel( int c )
1003{ 1001{
1004 // use standard WE channel switching protocol 1002 // use standard WE channel switching protocol
1005 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1003 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
1006 _if->_iwr.u.freq.m = c; 1004 _if->_iwr.u.freq.m = c;
1007 _if->_iwr.u.freq.e = 0; 1005 _if->_iwr.u.freq.e = 0;
1008 _if->wioctl( SIOCSIWFREQ ); 1006 _if->wioctl( SIOCSIWFREQ );
1009} 1007}
1010 1008
1011 1009
1012void OMonitoringInterface::setEnabled( bool b ) 1010void OMonitoringInterface::setEnabled( bool b )
1013{ 1011{
1014} 1012}
1015 1013
1016 1014
1017/*====================================================================================== 1015/*======================================================================================
1018 * OCiscoMonitoringInterface 1016 * OCiscoMonitoringInterface
1019 *======================================================================================*/ 1017 *======================================================================================*/
1020 1018
1021OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1019OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1022 :OMonitoringInterface( iface, prismHeader ) 1020 :OMonitoringInterface( iface, prismHeader )
1023{ 1021{
1024 iface->setMonitoring( this ); 1022 iface->setMonitoring( this );
1025} 1023}
1026 1024
1027 1025
1028OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1026OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
1029{ 1027{
1030} 1028}
1031 1029
1032 1030
1033void OCiscoMonitoringInterface::setEnabled( bool b ) 1031void OCiscoMonitoringInterface::setEnabled( bool b )
1034{ 1032{
1035 QString fname; 1033 QString fname;
1036 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 1034 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
1037 QFile f( fname ); 1035 QFile f( fname );
1038 if ( !f.exists() ) return; 1036 if ( !f.exists() ) return;
1039 1037
1040 if ( f.open( IO_WriteOnly ) ) 1038 if ( f.open( IO_WriteOnly ) )
1041 { 1039 {
1042 QTextStream s( &f ); 1040 QTextStream s( &f );
1043 s << "Mode: r"; 1041 s << "Mode: r";
1044 s << "Mode: y"; 1042 s << "Mode: y";
1045 s << "XmitPower: 1"; 1043 s << "XmitPower: 1";
1046 } 1044 }
1047 1045
1048 // flushing and closing will be done automatically when f goes out of scope 1046 // flushing and closing will be done automatically when f goes out of scope
1049} 1047}
1050 1048
1051 1049
1052QString OCiscoMonitoringInterface::name() const 1050QString OCiscoMonitoringInterface::name() const
1053{ 1051{
1054 return "cisco"; 1052 return "cisco";
1055} 1053}
1056 1054
1057 1055
1058void OCiscoMonitoringInterface::setChannel( int ) 1056void OCiscoMonitoringInterface::setChannel( int )
1059{ 1057{
1060 // cisco devices automatically switch channels when in monitor mode 1058 // cisco devices automatically switch channels when in monitor mode
1061} 1059}
1062 1060
1063 1061
1064/*====================================================================================== 1062/*======================================================================================
1065 * OWlanNGMonitoringInterface 1063 * OWlanNGMonitoringInterface
1066 *======================================================================================*/ 1064 *======================================================================================*/
1067 1065
1068 1066
1069OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1067OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1070 :OMonitoringInterface( iface, prismHeader ) 1068 :OMonitoringInterface( iface, prismHeader )
1071{ 1069{
1072 iface->setMonitoring( this ); 1070 iface->setMonitoring( this );
1073} 1071}
1074 1072
1075 1073
1076OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 1074OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
1077{ 1075{
1078} 1076}
1079 1077
1080 1078
1081void OWlanNGMonitoringInterface::setEnabled( bool b ) 1079void OWlanNGMonitoringInterface::setEnabled( bool b )
1082{ 1080{
1083 //FIXME: do nothing if its already in the same mode 1081 //FIXME: do nothing if its already in the same mode
1084 1082
1085 QString enable = b ? "true" : "false"; 1083 QString enable = b ? "true" : "false";
1086 QString prism = _prismHeader ? "true" : "false"; 1084 QString prism = _prismHeader ? "true" : "false";
1087 QString cmd; 1085 QString cmd;
1088 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1086 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1089 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); 1087 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism );
1090 system( cmd ); 1088 system( cmd );
1091} 1089}
1092 1090
1093 1091
1094QString OWlanNGMonitoringInterface::name() const 1092QString OWlanNGMonitoringInterface::name() const
1095{ 1093{
1096 return "wlan-ng"; 1094 return "wlan-ng";
1097} 1095}
1098 1096
1099 1097
1100void OWlanNGMonitoringInterface::setChannel( int c ) 1098void OWlanNGMonitoringInterface::setChannel( int c )
1101{ 1099{
1102 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. 1100 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't.
1103 1101
1104 QString enable = "true"; //_if->monitorMode() ? "true" : "false"; 1102 QString enable = "true"; //_if->monitorMode() ? "true" : "false";
1105 QString prism = _prismHeader ? "true" : "false"; 1103 QString prism = _prismHeader ? "true" : "false";
1106 QString cmd; 1104 QString cmd;
1107 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1105 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1108 (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); 1106 (const char*) _if->name(), c, (const char*) enable, (const char*) prism );
1109 system( cmd ); 1107 system( cmd );
1110} 1108}
1111 1109
1112 1110
1113/*====================================================================================== 1111/*======================================================================================
1114 * OHostAPMonitoringInterface 1112 * OHostAPMonitoringInterface
1115 *======================================================================================*/ 1113 *======================================================================================*/
1116 1114
1117OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1115OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1118 :OMonitoringInterface( iface, prismHeader ) 1116 :OMonitoringInterface( iface, prismHeader )
1119{ 1117{
1120 iface->setMonitoring( this ); 1118 iface->setMonitoring( this );
1121} 1119}
1122 1120
1123OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 1121OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
1124{ 1122{
1125} 1123}
1126 1124
1127void OHostAPMonitoringInterface::setEnabled( bool b ) 1125void OHostAPMonitoringInterface::setEnabled( bool b )
1128{ 1126{
1129 int monitorCode = _prismHeader ? 1 : 2; 1127 int monitorCode = _prismHeader ? 1 : 2;
1130 if ( b ) 1128 if ( b )
1131 { 1129 {
1132 _if->setPrivate( "monitor", 1, monitorCode ); 1130 _if->setPrivate( "monitor", 1, monitorCode );
1133 } 1131 }
1134 else 1132 else
1135 { 1133 {
1136 _if->setPrivate( "monitor", 1, 0 ); 1134 _if->setPrivate( "monitor", 1, 0 );
1137 } 1135 }
1138} 1136}
1139 1137
1140 1138
1141QString OHostAPMonitoringInterface::name() const 1139QString OHostAPMonitoringInterface::name() const
1142{ 1140{
1143 return "hostap"; 1141 return "hostap";
1144} 1142}
1145 1143
1146 1144
1147/*====================================================================================== 1145/*======================================================================================
1148 * OOrinocoNetworkInterface 1146 * OOrinocoNetworkInterface
1149 *======================================================================================*/ 1147 *======================================================================================*/
1150 1148
1151OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1149OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1152 :OMonitoringInterface( iface, prismHeader ) 1150 :OMonitoringInterface( iface, prismHeader )
1153{ 1151{
1154 iface->setMonitoring( this ); 1152 iface->setMonitoring( this );
1155} 1153}
1156 1154
1157 1155
1158OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 1156OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
1159{ 1157{
1160} 1158}
1161 1159
1162 1160
1163void OOrinocoMonitoringInterface::setChannel( int c ) 1161void OOrinocoMonitoringInterface::setChannel( int c )
1164{ 1162{
1165 int monitorCode = _prismHeader ? 1 : 2; 1163 int monitorCode = _prismHeader ? 1 : 2;
1166 _if->setPrivate( "monitor", 2, monitorCode, c ); 1164 _if->setPrivate( "monitor", 2, monitorCode, c );
1167} 1165}
1168 1166
1169 1167
1170void OOrinocoMonitoringInterface::setEnabled( bool b ) 1168void OOrinocoMonitoringInterface::setEnabled( bool b )
1171{ 1169{
1172 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 1170 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
1173 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 1171 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
1174 // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported 1172 // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported
1175 1173
1176 if ( b ) 1174 if ( b )
1177 { 1175 {
1178 setChannel( 1 ); 1176 setChannel( 1 );
1179 } 1177 }
1180 else 1178 else
1181 { 1179 {
1182 _if->setPrivate( "monitor", 2, 0, 0 ); 1180 _if->setPrivate( "monitor", 2, 0, 0 );
1183 } 1181 }
1184} 1182}
1185 1183
1186 1184
1187QString OOrinocoMonitoringInterface::name() const 1185QString OOrinocoMonitoringInterface::name() const
1188{ 1186{
1189 return "orinoco"; 1187 return "orinoco";
1190} 1188}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index eb6c86e..bc9e299 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,542 +1,539 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34#ifndef ONETWORK_H 31#ifndef ONETWORK_H
35#define ONETWORK_H 32#define ONETWORK_H
36 33
37#include "wireless.h" 34#include "wireless.h"
38 35
39/* OPIE */ 36/* OPIE */
40 37
41#include <opie2/onetutils.h> 38#include <opie2/onetutils.h>
42#include <opie2/ostation.h> 39#include <opie2/ostation.h>
43 40
44/* QT */ 41/* QT */
45 42
46#include <qvaluelist.h> 43#include <qvaluelist.h>
47#include <qdict.h> 44#include <qdict.h>
48#include <qmap.h> 45#include <qmap.h>
49#include <qobject.h> 46#include <qobject.h>
50#include <qhostaddress.h> 47#include <qhostaddress.h>
51 48
52class ONetworkInterface; 49class ONetworkInterface;
53class OWirelessNetworkInterface; 50class OWirelessNetworkInterface;
54class OChannelHopper; 51class OChannelHopper;
55class OMonitoringInterface; 52class OMonitoringInterface;
56 53
57/*====================================================================================== 54/*======================================================================================
58 * ONetwork 55 * ONetwork
59 *======================================================================================*/ 56 *======================================================================================*/
60 57
61/** 58/**
62 * @brief A container class for all network interfaces 59 * @brief A container class for all network interfaces
63 * 60 *
64 * This class provides access to all available network interfaces of your computer. 61 * This class provides access to all available network interfaces of your computer.
65 * 62 *
66 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 63 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
67 */ 64 */
68class ONetwork : public QObject 65class ONetwork : public QObject
69{ 66{
70 Q_OBJECT 67 Q_OBJECT
71 68
72 public: 69 public:
73 typedef QDict<ONetworkInterface> InterfaceMap; 70 typedef QDict<ONetworkInterface> InterfaceMap;
74 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 71 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
75 72
76 public: 73 public:
77 /** 74 /**
78 * @returns the number of available interfaces 75 * @returns the number of available interfaces
79 */ 76 */
80 int count() const; 77 int count() const;
81 /** 78 /**
82 * @returns a pointer to the (one and only) @ref ONetwork instance. 79 * @returns a pointer to the (one and only) @ref ONetwork instance.
83 */ 80 */
84 static ONetwork* instance(); 81 static ONetwork* instance();
85 /** 82 /**
86 * @returns an iterator usable for iterating through all network interfaces. 83 * @returns an iterator usable for iterating through all network interfaces.
87 */ 84 */
88 InterfaceIterator iterator() const; 85 InterfaceIterator iterator() const;
89 /** 86 /**
90 * @returns true, if the @a interface supports the wireless extension protocol. 87 * @returns true, if the @a interface supports the wireless extension protocol.
91 */ 88 */
92 bool isWirelessInterface( const char* interface ) const; 89 bool isWirelessInterface( const char* interface ) const;
93 /** 90 /**
94 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. 91 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found.
95 * @see ONetworkInterface 92 * @see ONetworkInterface
96 */ 93 */
97 ONetworkInterface* interface( const QString& interface ) const; 94 ONetworkInterface* interface( const QString& interface ) const;
98 /** 95 /**
99 * @internal Rebuild the internal interface database 96 * @internal Rebuild the internal interface database
100 * @note Sometimes it might be useful to call this from client code, 97 * @note Sometimes it might be useful to call this from client code,
101 * e.g. after issuing a cardctl insert 98 * e.g. after issuing a cardctl insert
102 */ 99 */
103 void synchronize(); 100 void synchronize();
104 /** 101 /**
105 * @returns the wireless extension version used at compile time. 102 * @returns the wireless extension version used at compile time.
106 **/ 103 **/
107 static short wirelessExtensionVersion(); 104 static short wirelessExtensionVersion();
108 105
109 protected: 106 protected:
110 ONetwork(); 107 ONetwork();
111 108
112 private: 109 private:
113 static ONetwork* _instance; 110 static ONetwork* _instance;
114 InterfaceMap _interfaces; 111 InterfaceMap _interfaces;
115}; 112};
116 113
117 114
118/*====================================================================================== 115/*======================================================================================
119 * ONetworkInterface 116 * ONetworkInterface
120 *======================================================================================*/ 117 *======================================================================================*/
121 118
122/** 119/**
123 * @brief A network interface wrapper. 120 * @brief A network interface wrapper.
124 * 121 *
125 * This class provides a wrapper for a network interface. All the cumbersume details of 122 * This class provides a wrapper for a network interface. All the cumbersume details of
126 * Linux ioctls are hidden under a convenient high-level interface. 123 * Linux ioctls are hidden under a convenient high-level interface.
127 * @warning Most of the setting methods contained in this class require the appropriate 124 * @warning Most of the setting methods contained in this class require the appropriate
128 * process permissions to work. 125 * process permissions to work.
129 * 126 *
130 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 127 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
131 */ 128 */
132class ONetworkInterface : public QObject 129class ONetworkInterface : public QObject
133{ 130{
134 friend class OMonitoringInterface; 131 friend class OMonitoringInterface;
135 friend class OCiscoMonitoringInterface; 132 friend class OCiscoMonitoringInterface;
136 friend class OWlanNGMonitoringInterface; 133 friend class OWlanNGMonitoringInterface;
137 friend class OHostAPMonitoringInterface; 134 friend class OHostAPMonitoringInterface;
138 friend class OOrinocoMonitoringInterface; 135 friend class OOrinocoMonitoringInterface;
139 136
140 public: 137 public:
141 /** 138 /**
142 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 139 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
143 * but access them via @ref ONetwork::interface(). 140 * but access them via @ref ONetwork::interface().
144 */ 141 */
145 ONetworkInterface( QObject* parent, const char* name ); 142 ONetworkInterface( QObject* parent, const char* name );
146 /** 143 /**
147 * Destructor. 144 * Destructor.
148 */ 145 */
149 virtual ~ONetworkInterface(); 146 virtual ~ONetworkInterface();
150 /** 147 /**
151 * Associates a @a monitoring interface with this network interface. 148 * Associates a @a monitoring interface with this network interface.
152 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 149 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
153 */ 150 */
154 void setMonitoring( OMonitoringInterface* monitoring ); 151 void setMonitoring( OMonitoringInterface* monitoring );
155 /** 152 /**
156 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 153 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
157 */ 154 */
158 OMonitoringInterface* monitoring() const; 155 OMonitoringInterface* monitoring() const;
159 /** 156 /**
160 * Setting an interface to promiscuous mode enables the device to receive 157 * Setting an interface to promiscuous mode enables the device to receive
161 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 158 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
162 */ 159 */
163 bool setPromiscuousMode( bool ); 160 bool setPromiscuousMode( bool );
164 /** 161 /**
165 * @returns true if the interface is set to promiscuous mode. 162 * @returns true if the interface is set to promiscuous mode.
166 */ 163 */
167 bool promiscuousMode() const; 164 bool promiscuousMode() const;
168 /** 165 /**
169 * Setting an interface to up enables it to receive packets. 166 * Setting an interface to up enables it to receive packets.
170 */ 167 */
171 bool setUp( bool ); 168 bool setUp( bool );
172 /** 169 /**
173 * @returns true if the interface is up. 170 * @returns true if the interface is up.
174 */ 171 */
175 bool isUp() const; 172 bool isUp() const;
176 /** 173 /**
177 * @returns true if the interface is a loopback interface. 174 * @returns true if the interface is a loopback interface.
178 */ 175 */
179 bool isLoopback() const; 176 bool isLoopback() const;
180 /** 177 /**
181 * @returns true if the interface is featuring supports the wireless extension protocol. 178 * @returns true if the interface is featuring supports the wireless extension protocol.
182 */ 179 */
183 bool isWireless() const; 180 bool isWireless() const;
184 /** 181 /**
185 * Associate the IP address @ addr with the interface. 182 * Associate the IP address @ addr with the interface.
186 */ 183 */
187 void setIPV4Address( const QHostAddress& addr ); 184 void setIPV4Address( const QHostAddress& addr );
188 /** 185 /**
189 * @returns the IPv4 address associated with the interface. 186 * @returns the IPv4 address associated with the interface.
190 */ 187 */
191 QString ipV4Address() const; //TODO: make this return an OHostAddress 188 QString ipV4Address() const; //TODO: make this return an OHostAddress
192 /** 189 /**
193 * Associate the MAC address @a addr with the interface. 190 * Associate the MAC address @a addr with the interface.
194 * @note It can be necessary to shut down the interface prior to calling this method. 191 * @note It can be necessary to shut down the interface prior to calling this method.
195 * @warning This is not supported by all drivers. 192 * @warning This is not supported by all drivers.
196 */ 193 */
197 void setMacAddress( const OMacAddress& addr ); 194 void setMacAddress( const OMacAddress& addr );
198 /** 195 /**
199 * @returns the MAC address associated with the interface. 196 * @returns the MAC address associated with the interface.
200 */ 197 */
201 OMacAddress macAddress() const; 198 OMacAddress macAddress() const;
202 /** 199 /**
203 * Associate the IPv4 @a netmask with the interface. 200 * Associate the IPv4 @a netmask with the interface.
204 */ 201 */
205 void setIPV4Netmask( const QHostAddress& netmask ); 202 void setIPV4Netmask( const QHostAddress& netmask );
206 /** 203 /**
207 * @returns the IPv4 netmask associated with the interface. 204 * @returns the IPv4 netmask associated with the interface.
208 */ 205 */
209 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 206 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
210 /** 207 /**
211 * @returns the data link type currently associated with the interface. 208 * @returns the data link type currently associated with the interface.
212 * @see #include <net/if_arp.h> for possible values. 209 * @see #include <net/if_arp.h> for possible values.
213 */ 210 */
214 int dataLinkType() const; 211 int dataLinkType() const;
215 212
216 protected: 213 protected:
217 const int _sfd; 214 const int _sfd;
218 mutable ifreq _ifr; 215 mutable ifreq _ifr;
219 OMonitoringInterface* _mon; 216 OMonitoringInterface* _mon;
220 217
221 protected: 218 protected:
222 struct ifreq& ifr() const; 219 struct ifreq& ifr() const;
223 virtual void init(); 220 virtual void init();
224 bool ioctl( int call ) const; 221 bool ioctl( int call ) const;
225 bool ioctl( int call, struct ifreq& ) const; 222 bool ioctl( int call, struct ifreq& ) const;
226}; 223};
227 224
228/*====================================================================================== 225/*======================================================================================
229 * OChannelHopper 226 * OChannelHopper
230 *======================================================================================*/ 227 *======================================================================================*/
231 228
232/** 229/**
233 * @brief A radio frequency channel hopper. 230 * @brief A radio frequency channel hopper.
234 * 231 *
235 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 232 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
236 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 233 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
237 * This is necessary when in monitoring mode and scanning for other devices, because 234 * This is necessary when in monitoring mode and scanning for other devices, because
238 * the radio frequency hardware can only detect packets sent on the same frequency. 235 * the radio frequency hardware can only detect packets sent on the same frequency.
239 * 236 *
240 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 237 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
241 */ 238 */
242class OChannelHopper : public QObject 239class OChannelHopper : public QObject
243{ 240{
244 Q_OBJECT 241 Q_OBJECT
245 242
246 public: 243 public:
247 /** 244 /**
248 * Constructor. 245 * Constructor.
249 */ 246 */
250 OChannelHopper( OWirelessNetworkInterface* ); 247 OChannelHopper( OWirelessNetworkInterface* );
251 /** 248 /**
252 * Destructor. 249 * Destructor.
253 */ 250 */
254 virtual ~OChannelHopper(); 251 virtual ~OChannelHopper();
255 /** 252 /**
256 * @returns true, if the channel hopper is hopping channels 253 * @returns true, if the channel hopper is hopping channels
257 */ 254 */
258 bool isActive() const; 255 bool isActive() const;
259 /** 256 /**
260 * @returns the last hopped channel 257 * @returns the last hopped channel
261 */ 258 */
262 int channel() const; 259 int channel() const;
263 /** 260 /**
264 * Set the channel hopping @a interval. 261 * Set the channel hopping @a interval.
265 * An interval of 0 deactivates the channel hopper. 262 * An interval of 0 deactivates the channel hopper.
266 */ 263 */
267 void setInterval( int interval ); 264 void setInterval( int interval );
268 /** 265 /**
269 * @returns the channel hopping interval 266 * @returns the channel hopping interval
270 */ 267 */
271 int interval() const; 268 int interval() const;
272 269
273 signals: 270 signals:
274 /** 271 /**
275 * This signal is emitted right after the channel hopper performed a hop 272 * This signal is emitted right after the channel hopper performed a hop
276 */ 273 */
277 void hopped( int ); 274 void hopped( int );
278 275
279 protected: 276 protected:
280 virtual void timerEvent( QTimerEvent* ); 277 virtual void timerEvent( QTimerEvent* );
281 278
282 private: 279 private:
283 OWirelessNetworkInterface* _iface; 280 OWirelessNetworkInterface* _iface;
284 int _interval; 281 int _interval;
285 int _tid; 282 int _tid;
286 QValueList<int> _channels; 283 QValueList<int> _channels;
287 QValueList<int>::Iterator _channel; 284 QValueList<int>::Iterator _channel;
288}; 285};
289 286
290 287
291/*====================================================================================== 288/*======================================================================================
292 * OWirelessNetworkInterface 289 * OWirelessNetworkInterface
293 *======================================================================================*/ 290 *======================================================================================*/
294 291
295/** 292/**
296 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 293 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
297 * 294 *
298 * This class provides a high-level encapsulation of the Linux wireless extension API. 295 * This class provides a high-level encapsulation of the Linux wireless extension API.
299 * 296 *
300 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 297 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
301 */ 298 */
302class OWirelessNetworkInterface : public ONetworkInterface 299class OWirelessNetworkInterface : public ONetworkInterface
303{ 300{
304 friend class OMonitoringInterface; 301 friend class OMonitoringInterface;
305 friend class OCiscoMonitoringInterface; 302 friend class OCiscoMonitoringInterface;
306 friend class OWlanNGMonitoringInterface; 303 friend class OWlanNGMonitoringInterface;
307 friend class OHostAPMonitoringInterface; 304 friend class OHostAPMonitoringInterface;
308 friend class OOrinocoMonitoringInterface; 305 friend class OOrinocoMonitoringInterface;
309 306
310 friend class OPrivateIOCTL; 307 friend class OPrivateIOCTL;
311 308
312 public: 309 public:
313 /** 310 /**
314 * Constructor. 311 * Constructor.
315 */ 312 */
316 OWirelessNetworkInterface( QObject* parent, const char* name ); 313 OWirelessNetworkInterface( QObject* parent, const char* name );
317 /** 314 /**
318 * Destructor. 315 * Destructor.
319 */ 316 */
320 virtual ~OWirelessNetworkInterface(); 317 virtual ~OWirelessNetworkInterface();
321 /** 318 /**
322 * Setting the @a channel of the interface changes the radio frequency (RF) 319 * Setting the @a channel of the interface changes the radio frequency (RF)
323 * of the corresponding wireless network device. 320 * of the corresponding wireless network device.
324 * @note Common channel range is within [1-14]. A value of 0 is not allowed. 321 * @note Common channel range is within [1-14]. A value of 0 is not allowed.
325 * @see channels() 322 * @see channels()
326 */ 323 */
327 virtual void setChannel( int channel ) const; 324 virtual void setChannel( int channel ) const;
328 /** 325 /**
329 * @returns the channel index of the current radio frequency. 326 * @returns the channel index of the current radio frequency.
330 */ 327 */
331 virtual int channel() const; 328 virtual int channel() const;
332 /** 329 /**
333 * @returns the current radio frequency (in MHz). 330 * @returns the current radio frequency (in MHz).
334 */ 331 */
335 virtual double frequency() const; 332 virtual double frequency() const;
336 /** 333 /**
337 * @returns the number of radio frequency channels for the 334 * @returns the number of radio frequency channels for the
338 * corresponding wireless network device. 335 * corresponding wireless network device.
339 * @note European devices usually have 14 channels, while American typically feature 11 channels. 336 * @note European devices usually have 14 channels, while American typically feature 11 channels.
340 */ 337 */
341 virtual int channels() const; 338 virtual int channels() const;
342 /** 339 /**
343 * Set the IEEE 802.11 operation @a mode. 340 * Set the IEEE 802.11 operation @a mode.
344 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master 341 * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master
345 * @warning Not all drivers support the all modes. 342 * @warning Not all drivers support the all modes.
346 * @note You might have to change the SSID to get the operation mode change into effect. 343 * @note You might have to change the SSID to get the operation mode change into effect.
347 */ 344 */
348 virtual void setMode( const QString& mode ); 345 virtual void setMode( const QString& mode );
349 /** 346 /**
350 * @returns the current IEEE 802.11 operation mode. 347 * @returns the current IEEE 802.11 operation mode.
351 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown 348 * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown
352 * 349 *
353 * @note: Important note concerning the 'monitor' mode: 350 * @note: Important note concerning the 'monitor' mode:
354 * Setting the monitor mode on a wireless network interface enables 351 * Setting the monitor mode on a wireless network interface enables
355 * listening to IEEE 802.11 data and management frames which normally 352 * listening to IEEE 802.11 data and management frames which normally
356 * are handled by the device firmware. This can be used to detect 353 * are handled by the device firmware. This can be used to detect
357 * other wireless network devices, e.g. Access Points or Ad-hoc stations. 354 * other wireless network devices, e.g. Access Points or Ad-hoc stations.
358 * @warning Standard wireless network drives don't support the monitor mode. 355 * @warning Standard wireless network drives don't support the monitor mode.
359 * @warning You need a patched driver for this to work. 356 * @warning You need a patched driver for this to work.
360 * @note Enabling the monitor mode is highly driver dependent and requires 357 * @note Enabling the monitor mode is highly driver dependent and requires
361 * the proper @ref OMonitoringInterface to be associated with the interface. 358 * the proper @ref OMonitoringInterface to be associated with the interface.
362 * @see OMonitoringInterface 359 * @see OMonitoringInterface
363 */ 360 */
364 virtual QString mode() const; 361 virtual QString mode() const;
365 /** 362 /**
366 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. 363 * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping.
367 * @see OChannelHopper 364 * @see OChannelHopper
368 */ 365 */
369 virtual void setChannelHopping( int interval = 0 ); 366 virtual void setChannelHopping( int interval = 0 );
370 /** 367 /**
371 * @returns the channel hopping interval or 0, if channel hopping is disabled. 368 * @returns the channel hopping interval or 0, if channel hopping is disabled.
372 */ 369 */
373 virtual int channelHopping() const; 370 virtual int channelHopping() const;
374 /** 371 /**
375 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before 372 * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before
376 */ 373 */
377 virtual OChannelHopper* channelHopper() const; 374 virtual OChannelHopper* channelHopper() const;
378 /** 375 /**
379 * Set the station @a nickname. 376 * Set the station @a nickname.
380 */ 377 */
381 virtual void setNickName( const QString& nickname ); 378 virtual void setNickName( const QString& nickname );
382 /** 379 /**
383 * @returns the current station nickname. 380 * @returns the current station nickname.
384 */ 381 */
385 virtual QString nickName() const; 382 virtual QString nickName() const;
386 /** 383 /**
387 * Invoke the private IOCTL @a command with a @number of parameters on the network interface. 384 * Invoke the private IOCTL @a command with a @number of parameters on the network interface.
388 * @see OPrivateIOCTL 385 * @see OPrivateIOCTL
389 */ 386 */
390 virtual void setPrivate( const QString& command, int number, ... ); 387 virtual void setPrivate( const QString& command, int number, ... );
391 /** 388 /**
392 * @returns true if the interface is featuring the private IOCTL @command. 389 * @returns true if the interface is featuring the private IOCTL @command.
393 */ 390 */
394 virtual bool hasPrivate( const QString& command ); 391 virtual bool hasPrivate( const QString& command );
395 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this 392 virtual void getPrivate( const QString& command ); //FIXME: Implement and document this
396 /** 393 /**
397 * @returns true if the interface is associated to an access point 394 * @returns true if the interface is associated to an access point
398 * @note: This information is only valid if the interface is in managed mode. 395 * @note: This information is only valid if the interface is in managed mode.
399 */ 396 */
400 virtual bool isAssociated() const; 397 virtual bool isAssociated() const;
401 /** 398 /**
402 * @returns the MAC address of the Access Point if the device is in infrastructure mode. 399 * @returns the MAC address of the Access Point if the device is in infrastructure mode.
403 * @returns a (more or less random) cell ID address if the device is in adhoc mode. 400 * @returns a (more or less random) cell ID address if the device is in adhoc mode.
404 */ 401 */
405 virtual OMacAddress associatedAP() const; 402 virtual OMacAddress associatedAP() const;
406 /** 403 /**
407 * Set the @a ssid (Service Set ID) string. This is used to decide 404 * Set the @a ssid (Service Set ID) string. This is used to decide
408 * which network to associate with (use "any" to let the driver decide). 405 * which network to associate with (use "any" to let the driver decide).
409 */ 406 */
410 virtual void setSSID( const QString& ssid ); 407 virtual void setSSID( const QString& ssid );
411 /** 408 /**
412 * @returns the current SSID (Service Set ID). 409 * @returns the current SSID (Service Set ID).
413 */ 410 */
414 virtual QString SSID() const; 411 virtual QString SSID() const;
415 /** 412 /**
416 * Perform scanning the wireless network neighbourhood. 413 * Perform scanning the wireless network neighbourhood.
417 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! 414 * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
418 */ 415 */
419 virtual OStationList* scanNetwork(); 416 virtual OStationList* scanNetwork();
420 /** @internal commit pending changes to the driver 417 /** @internal commit pending changes to the driver
421 * 418 *
422 */ 419 */
423 void commit() const; 420 void commit() const;
424 421
425 protected: 422 protected:
426 void buildInformation(); 423 void buildInformation();
427 void buildPrivateList(); 424 void buildPrivateList();
428 void dumpInformation() const; 425 void dumpInformation() const;
429 virtual void init(); 426 virtual void init();
430 struct iwreq& iwr() const; 427 struct iwreq& iwr() const;
431 bool wioctl( int call ) const; 428 bool wioctl( int call ) const;
432 bool wioctl( int call, struct iwreq& ) const; 429 bool wioctl( int call, struct iwreq& ) const;
433 430
434 protected: 431 protected:
435 mutable struct iwreq _iwr; 432 mutable struct iwreq _iwr;
436 QMap<int,int> _channels; 433 QMap<int,int> _channels;
437 struct iw_range _range; 434 struct iw_range _range;
438 435
439 private: 436 private:
440 OChannelHopper* _hopper; 437 OChannelHopper* _hopper;
441}; 438};
442 439
443 440
444/*====================================================================================== 441/*======================================================================================
445 * OMonitoringInterface 442 * OMonitoringInterface
446 *======================================================================================*/ 443 *======================================================================================*/
447 444
448 445
449class OMonitoringInterface 446class OMonitoringInterface
450{ 447{
451 public: 448 public:
452 OMonitoringInterface(); 449 OMonitoringInterface();
453 OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 450 OMonitoringInterface( ONetworkInterface*, bool _prismHeader );
454 virtual ~OMonitoringInterface(); 451 virtual ~OMonitoringInterface();
455 452
456 public: 453 public:
457 virtual void setEnabled( bool ); 454 virtual void setEnabled( bool );
458 virtual void setChannel( int ); 455 virtual void setChannel( int );
459 456
460 virtual QString name() const = 0; 457 virtual QString name() const = 0;
461 458
462 protected: 459 protected:
463 OWirelessNetworkInterface* _if; 460 OWirelessNetworkInterface* _if;
464 bool _prismHeader; 461 bool _prismHeader;
465 462
466}; 463};
467 464
468 465
469/*====================================================================================== 466/*======================================================================================
470 * OCiscoMonitoring 467 * OCiscoMonitoring
471 *======================================================================================*/ 468 *======================================================================================*/
472 469
473 470
474class OCiscoMonitoringInterface : public OMonitoringInterface 471class OCiscoMonitoringInterface : public OMonitoringInterface
475{ 472{
476 public: 473 public:
477 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 474 OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
478 virtual ~OCiscoMonitoringInterface(); 475 virtual ~OCiscoMonitoringInterface();
479 476
480 virtual void setEnabled( bool ); 477 virtual void setEnabled( bool );
481 virtual QString name() const; 478 virtual QString name() const;
482 virtual void setChannel( int ); 479 virtual void setChannel( int );
483 480
484}; 481};
485 482
486 483
487/*====================================================================================== 484/*======================================================================================
488 * OWlanNGMonitoringInterface 485 * OWlanNGMonitoringInterface
489 *======================================================================================*/ 486 *======================================================================================*/
490 487
491 488
492class OWlanNGMonitoringInterface : public OMonitoringInterface 489class OWlanNGMonitoringInterface : public OMonitoringInterface
493{ 490{
494 public: 491 public:
495 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 492 OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader );
496 virtual ~OWlanNGMonitoringInterface(); 493 virtual ~OWlanNGMonitoringInterface();
497 494
498 public: 495 public:
499 virtual void setEnabled( bool ); 496 virtual void setEnabled( bool );
500 virtual QString name() const; 497 virtual QString name() const;
501 virtual void setChannel( int ); 498 virtual void setChannel( int );
502 499
503}; 500};
504 501
505 502
506/*====================================================================================== 503/*======================================================================================
507 * OHostAPMonitoringInterface 504 * OHostAPMonitoringInterface
508 *======================================================================================*/ 505 *======================================================================================*/
509 506
510 507
511class OHostAPMonitoringInterface : public OMonitoringInterface 508class OHostAPMonitoringInterface : public OMonitoringInterface
512{ 509{
513 public: 510 public:
514 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 511 OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader );
515 virtual ~OHostAPMonitoringInterface(); 512 virtual ~OHostAPMonitoringInterface();
516 513
517 public: 514 public:
518 virtual void setEnabled( bool ); 515 virtual void setEnabled( bool );
519 virtual QString name() const; 516 virtual QString name() const;
520 }; 517 };
521 518
522 519
523/*====================================================================================== 520/*======================================================================================
524 * OOrinocoMonitoringInterface 521 * OOrinocoMonitoringInterface
525 *======================================================================================*/ 522 *======================================================================================*/
526 523
527 524
528class OOrinocoMonitoringInterface : public OMonitoringInterface 525class OOrinocoMonitoringInterface : public OMonitoringInterface
529{ 526{
530 public: 527 public:
531 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); 528 OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader );
532 virtual ~OOrinocoMonitoringInterface(); 529 virtual ~OOrinocoMonitoringInterface();
533 530
534 public: 531 public:
535 virtual void setChannel( int ); 532 virtual void setChannel( int );
536 virtual void setEnabled( bool ); 533 virtual void setEnabled( bool );
537 virtual QString name() const; 534 virtual QString name() const;
538 535
539}; 536};
540 537
541#endif // ONETWORK_H 538#endif // ONETWORK_H
542 539
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 6331b2d..635224c 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1,1323 +1,1320 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34/* OPIE */ 31/* OPIE */
35#include <opie2/opcap.h> 32#include <opie2/opcap.h>
36 33
37/* QT */ 34/* QT */
38#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 35#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
39#include <qsocketnotifier.h> 36#include <qsocketnotifier.h>
40#include <qobjectlist.h> 37#include <qobjectlist.h>
41 38
42/* SYSTEM */ 39/* SYSTEM */
43#include <sys/time.h> 40#include <sys/time.h>
44#include <sys/types.h> 41#include <sys/types.h>
45#include <unistd.h> 42#include <unistd.h>
46 43
47/* LOCAL */ 44/* LOCAL */
48#include "udp_ports.h" 45#include "udp_ports.h"
49 46
50/*====================================================================================== 47/*======================================================================================
51 * OPacket 48 * OPacket
52 *======================================================================================*/ 49 *======================================================================================*/
53 50
54OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) 51OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent )
55 :QObject( parent, "Generic" ), _hdr( header ), _data( data ) 52 :QObject( parent, "Generic" ), _hdr( header ), _data( data )
56{ 53{
57 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 54 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
58 55
59 _end = (unsigned char*) data + header.len; 56 _end = (unsigned char*) data + header.len;
60 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); 57 //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end );
61 58
62 switch ( datalink ) 59 switch ( datalink )
63 { 60 {
64 case DLT_EN10MB: 61 case DLT_EN10MB:
65 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); 62 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" );
66 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 63 new OEthernetPacket( _end, (const struct ether_header*) data, this );
67 break; 64 break;
68 65
69 case DLT_IEEE802_11: 66 case DLT_IEEE802_11:
70 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); 67 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" );
71 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 68 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
72 break; 69 break;
73 70
74 case DLT_PRISM_HEADER: 71 case DLT_PRISM_HEADER:
75 qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); 72 qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" );
76 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 73 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
77 break; 74 break;
78 75
79 default: 76 default:
80 qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); 77 qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink );
81 } 78 }
82} 79}
83 80
84 81
85OPacket::~OPacket() 82OPacket::~OPacket()
86{ 83{
87} 84}
88 85
89 86
90timevalstruct OPacket::timeval() const 87timevalstruct OPacket::timeval() const
91{ 88{
92 return _hdr.ts; 89 return _hdr.ts;
93} 90}
94 91
95 92
96int OPacket::caplen() const 93int OPacket::caplen() const
97{ 94{
98 return _hdr.caplen; 95 return _hdr.caplen;
99} 96}
100 97
101 98
102void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) 99void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
103{ 100{
104 if (!l) return; 101 if (!l) return;
105 QObject* o = l->first(); 102 QObject* o = l->first();
106 while ( o ) 103 while ( o )
107 { 104 {
108 stats[o->name()]++; 105 stats[o->name()]++;
109 updateStats( stats, const_cast<QObjectList*>( o->children() ) ); 106 updateStats( stats, const_cast<QObjectList*>( o->children() ) );
110 o = l->next(); 107 o = l->next();
111 } 108 }
112} 109}
113 110
114 111
115void OPacket::dumpStructure( QObjectList* l ) 112void OPacket::dumpStructure( QObjectList* l )
116{ 113{
117 QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); 114 QString packetString( "[ |" + _dumpStructure( l ) + " ]" );
118 qDebug( "OPacket::dumpStructure: %s", (const char*) packetString ); 115 qDebug( "OPacket::dumpStructure: %s", (const char*) packetString );
119} 116}
120 117
121 118
122QString OPacket::_dumpStructure( QObjectList* l ) 119QString OPacket::_dumpStructure( QObjectList* l )
123{ 120{
124 if (!l) return QString::null; 121 if (!l) return QString::null;
125 QObject* o = l->first(); 122 QObject* o = l->first();
126 QString str(" "); 123 QString str(" ");
127 124
128 while ( o ) 125 while ( o )
129 { 126 {
130 str.append( o->name() ); 127 str.append( o->name() );
131 str.append( " |" ); 128 str.append( " |" );
132 str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); 129 str += _dumpStructure( const_cast<QObjectList*>( o->children() ) );
133 o = l->next(); 130 o = l->next();
134 } 131 }
135 return str; 132 return str;
136} 133}
137 134
138QString OPacket::dump( int bpl ) const 135QString OPacket::dump( int bpl ) const
139{ 136{
140 static int index = 0; 137 static int index = 0;
141 index++; 138 index++;
142 int len = _hdr.caplen; 139 int len = _hdr.caplen;
143 QString str; 140 QString str;
144 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); 141 str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len );
145 str.append( "0000: " ); 142 str.append( "0000: " );
146 QString tmp; 143 QString tmp;
147 QString bytes; 144 QString bytes;
148 QString chars; 145 QString chars;
149 146
150 for ( int i = 0; i < len; ++i ) 147 for ( int i = 0; i < len; ++i )
151 { 148 {
152 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); 149 tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp );
153 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); 150 if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] );
154 else chars.append( '.' ); 151 else chars.append( '.' );
155 152
156 if ( !((i+1) % bpl) ) 153 if ( !((i+1) % bpl) )
157 { 154 {
158 str.append( bytes ); 155 str.append( bytes );
159 str.append( ' ' ); 156 str.append( ' ' );
160 str.append( chars ); 157 str.append( chars );
161 str.append( '\n' ); 158 str.append( '\n' );
162 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); 159 tmp.sprintf( "%04X: ", i+1 ); str.append( tmp );
163 bytes = ""; 160 bytes = "";
164 chars = ""; 161 chars = "";
165 } 162 }
166 163
167 } 164 }
168 if ( (len % bpl) ) 165 if ( (len % bpl) )
169 { 166 {
170 str.append( bytes.leftJustify( 1 + 3*bpl ) ); 167 str.append( bytes.leftJustify( 1 + 3*bpl ) );
171 str.append( chars ); 168 str.append( chars );
172 } 169 }
173 str.append( '\n' ); 170 str.append( '\n' );
174 return str; 171 return str;
175} 172}
176 173
177 174
178int OPacket::len() const 175int OPacket::len() const
179{ 176{
180 return _hdr.len; 177 return _hdr.len;
181} 178}
182 179
183 180
184/*====================================================================================== 181/*======================================================================================
185 * OEthernetPacket 182 * OEthernetPacket
186 *======================================================================================*/ 183 *======================================================================================*/
187 184
188OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) 185OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent )
189 :QObject( parent, "Ethernet" ), _ether( data ) 186 :QObject( parent, "Ethernet" ), _ether( data )
190{ 187{
191 188
192 qDebug( "Source = %s", (const char*) sourceAddress().toString() ); 189 qDebug( "Source = %s", (const char*) sourceAddress().toString() );
193 qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); 190 qDebug( "Destination = %s", (const char*) destinationAddress().toString() );
194 191
195 if ( sourceAddress() == OMacAddress::broadcast ) 192 if ( sourceAddress() == OMacAddress::broadcast )
196 qDebug( "Source is broadcast address" ); 193 qDebug( "Source is broadcast address" );
197 if ( destinationAddress() == OMacAddress::broadcast ) 194 if ( destinationAddress() == OMacAddress::broadcast )
198 qDebug( "Destination is broadcast address" ); 195 qDebug( "Destination is broadcast address" );
199 196
200 switch ( type() ) 197 switch ( type() )
201 { 198 {
202 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 199 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
203 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 200 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
204 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } 201 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; }
205 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); 202 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" );
206 } 203 }
207 204
208} 205}
209 206
210 207
211OEthernetPacket::~OEthernetPacket() 208OEthernetPacket::~OEthernetPacket()
212{ 209{
213} 210}
214 211
215 212
216OMacAddress OEthernetPacket::sourceAddress() const 213OMacAddress OEthernetPacket::sourceAddress() const
217{ 214{
218 return OMacAddress( _ether->ether_shost ); 215 return OMacAddress( _ether->ether_shost );
219} 216}
220 217
221 218
222OMacAddress OEthernetPacket::destinationAddress() const 219OMacAddress OEthernetPacket::destinationAddress() const
223{ 220{
224 return OMacAddress( _ether->ether_dhost ); 221 return OMacAddress( _ether->ether_dhost );
225} 222}
226 223
227int OEthernetPacket::type() const 224int OEthernetPacket::type() const
228{ 225{
229 return ntohs( _ether->ether_type ); 226 return ntohs( _ether->ether_type );
230} 227}
231 228
232 229
233/*====================================================================================== 230/*======================================================================================
234 * OIPPacket 231 * OIPPacket
235 *======================================================================================*/ 232 *======================================================================================*/
236 233
237 234
238OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) 235OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
239 :QObject( parent, "IP" ), _iphdr( data ) 236 :QObject( parent, "IP" ), _iphdr( data )
240{ 237{
241 qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); 238 qDebug( "OIPPacket::OIPPacket(): decoding IP header..." );
242 239
243 //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); 240 //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) );
244 //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); 241 //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) );
245 242
246 qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); 243 qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() );
247 qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); 244 qDebug( " toAddress: %s", (const char*) toIPAddress().toString() );
248 245
249 switch ( protocol() ) 246 switch ( protocol() )
250 { 247 {
251 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; 248 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
252 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; 249 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
253 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); 250 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() );
254 } 251 }
255 252
256} 253}
257 254
258OIPPacket::~OIPPacket() 255OIPPacket::~OIPPacket()
259{ 256{
260} 257}
261 258
262 259
263QHostAddress OIPPacket::fromIPAddress() const 260QHostAddress OIPPacket::fromIPAddress() const
264{ 261{
265 return EXTRACT_32BITS( &_iphdr->saddr ); 262 return EXTRACT_32BITS( &_iphdr->saddr );
266} 263}
267 264
268 265
269QHostAddress OIPPacket::toIPAddress() const 266QHostAddress OIPPacket::toIPAddress() const
270{ 267{
271 return EXTRACT_32BITS( &_iphdr->saddr ); 268 return EXTRACT_32BITS( &_iphdr->saddr );
272} 269}
273 270
274 271
275int OIPPacket::tos() const 272int OIPPacket::tos() const
276{ 273{
277 return _iphdr->tos; 274 return _iphdr->tos;
278} 275}
279 276
280 277
281int OIPPacket::len() const 278int OIPPacket::len() const
282{ 279{
283 return EXTRACT_16BITS( &_iphdr->tot_len ); 280 return EXTRACT_16BITS( &_iphdr->tot_len );
284} 281}
285 282
286 283
287int OIPPacket::id() const 284int OIPPacket::id() const
288{ 285{
289 return EXTRACT_16BITS( &_iphdr->id ); 286 return EXTRACT_16BITS( &_iphdr->id );
290} 287}
291 288
292 289
293int OIPPacket::offset() const 290int OIPPacket::offset() const
294{ 291{
295 return EXTRACT_16BITS( &_iphdr->frag_off ); 292 return EXTRACT_16BITS( &_iphdr->frag_off );
296} 293}
297 294
298 295
299int OIPPacket::ttl() const 296int OIPPacket::ttl() const
300{ 297{
301 return _iphdr->ttl; 298 return _iphdr->ttl;
302} 299}
303 300
304 301
305int OIPPacket::protocol() const 302int OIPPacket::protocol() const
306{ 303{
307 return _iphdr->protocol; 304 return _iphdr->protocol;
308} 305}
309 306
310 307
311int OIPPacket::checksum() const 308int OIPPacket::checksum() const
312{ 309{
313 return EXTRACT_16BITS( &_iphdr->check ); 310 return EXTRACT_16BITS( &_iphdr->check );
314} 311}
315 312
316/*====================================================================================== 313/*======================================================================================
317 * OARPPacket 314 * OARPPacket
318 *======================================================================================*/ 315 *======================================================================================*/
319 316
320 317
321OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) 318OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent )
322 :QObject( parent, "ARP" ), _arphdr( data ) 319 :QObject( parent, "ARP" ), _arphdr( data )
323{ 320{
324 qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." ); 321 qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." );
325 qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() ); 322 qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() );
326 qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() ); 323 qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() );
327 qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() ); 324 qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() );
328} 325}
329 326
330 327
331OARPPacket::~OARPPacket() 328OARPPacket::~OARPPacket()
332{ 329{
333} 330}
334 331
335 332
336QString OARPPacket::type() const 333QString OARPPacket::type() const
337{ 334{
338 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) 335 switch ( EXTRACT_16BITS( &_arphdr->ar_op ) )
339 { 336 {
340 case 1: return "REQUEST"; 337 case 1: return "REQUEST";
341 case 2: return "REPLY"; 338 case 2: return "REPLY";
342 case 3: return "RREQUEST"; 339 case 3: return "RREQUEST";
343 case 4: return "RREPLY"; 340 case 4: return "RREPLY";
344 case 8: return "InREQUEST"; 341 case 8: return "InREQUEST";
345 case 9: return "InREPLY"; 342 case 9: return "InREPLY";
346 case 10: return "NAK"; 343 case 10: return "NAK";
347 default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; 344 default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>";
348 } 345 }
349} 346}
350 347
351 348
352QHostAddress OARPPacket::senderIPV4Address() const 349QHostAddress OARPPacket::senderIPV4Address() const
353{ 350{
354 return EXTRACT_32BITS( &_arphdr->ar_sip ); 351 return EXTRACT_32BITS( &_arphdr->ar_sip );
355} 352}
356 353
357 354
358QHostAddress OARPPacket::targetIPV4Address() const 355QHostAddress OARPPacket::targetIPV4Address() const
359{ 356{
360 return EXTRACT_32BITS( &_arphdr->ar_tip ); 357 return EXTRACT_32BITS( &_arphdr->ar_tip );
361} 358}
362 359
363 360
364OMacAddress OARPPacket::senderMacAddress() const 361OMacAddress OARPPacket::senderMacAddress() const
365{ 362{
366 return OMacAddress( _arphdr->ar_sha ); 363 return OMacAddress( _arphdr->ar_sha );
367} 364}
368 365
369 366
370OMacAddress OARPPacket::targetMacAddress() const 367OMacAddress OARPPacket::targetMacAddress() const
371{ 368{
372 return OMacAddress( _arphdr->ar_tha ); 369 return OMacAddress( _arphdr->ar_tha );
373} 370}
374 371
375 372
376/*====================================================================================== 373/*======================================================================================
377 * OUDPPacket 374 * OUDPPacket
378 *======================================================================================*/ 375 *======================================================================================*/
379 376
380 377
381OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) 378OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
382 :QObject( parent, "UDP" ), _udphdr( data ) 379 :QObject( parent, "UDP" ), _udphdr( data )
383 380
384{ 381{
385 qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); 382 qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." );
386 qDebug( "fromPort = %d", fromPort() ); 383 qDebug( "fromPort = %d", fromPort() );
387 qDebug( " toPort = %d", toPort() ); 384 qDebug( " toPort = %d", toPort() );
388 385
389 // TODO: Make this a case or a hash if we know more udp protocols 386 // TODO: Make this a case or a hash if we know more udp protocols
390 387
391 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || 388 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC ||
392 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) 389 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC )
393 { 390 {
394 qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." ); 391 qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." );
395 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); 392 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this );
396 } 393 }
397} 394}
398 395
399 396
400OUDPPacket::~OUDPPacket() 397OUDPPacket::~OUDPPacket()
401{ 398{
402} 399}
403 400
404 401
405int OUDPPacket::fromPort() const 402int OUDPPacket::fromPort() const
406{ 403{
407 return EXTRACT_16BITS( &_udphdr->source ); 404 return EXTRACT_16BITS( &_udphdr->source );
408} 405}
409 406
410 407
411int OUDPPacket::toPort() const 408int OUDPPacket::toPort() const
412{ 409{
413 return EXTRACT_16BITS( &_udphdr->dest ); 410 return EXTRACT_16BITS( &_udphdr->dest );
414} 411}
415 412
416 413
417int OUDPPacket::length() const 414int OUDPPacket::length() const
418{ 415{
419 return EXTRACT_16BITS( &_udphdr->len ); 416 return EXTRACT_16BITS( &_udphdr->len );
420} 417}
421 418
422 419
423int OUDPPacket::checksum() const 420int OUDPPacket::checksum() const
424{ 421{
425 return EXTRACT_16BITS( &_udphdr->check ); 422 return EXTRACT_16BITS( &_udphdr->check );
426} 423}
427 424
428 425
429/*====================================================================================== 426/*======================================================================================
430 * ODHCPPacket 427 * ODHCPPacket
431 *======================================================================================*/ 428 *======================================================================================*/
432 429
433 430
434ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) 431ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent )
435 :QObject( parent, "DHCP" ), _dhcphdr( data ) 432 :QObject( parent, "DHCP" ), _dhcphdr( data )
436 433
437{ 434{
438 qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." ); 435 qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." );
439 qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" ); 436 qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" );
440 qDebug( "clientAddress: %s", (const char*) clientAddress().toString() ); 437 qDebug( "clientAddress: %s", (const char*) clientAddress().toString() );
441 qDebug( " yourAddress: %s", (const char*) yourAddress().toString() ); 438 qDebug( " yourAddress: %s", (const char*) yourAddress().toString() );
442 qDebug( "serverAddress: %s", (const char*) serverAddress().toString() ); 439 qDebug( "serverAddress: %s", (const char*) serverAddress().toString() );
443 qDebug( " relayAddress: %s", (const char*) relayAddress().toString() ); 440 qDebug( " relayAddress: %s", (const char*) relayAddress().toString() );
444 qDebug( "parsing DHCP options..." ); 441 qDebug( "parsing DHCP options..." );
445 442
446 _type = 0; 443 _type = 0;
447 444
448 const unsigned char* option = &_dhcphdr->options[4]; 445 const unsigned char* option = &_dhcphdr->options[4];
449 char tag = -1; 446 char tag = -1;
450 char len = -1; 447 char len = -1;
451 448
452 while ( ( tag = *option++ ) != -1 /* end of option field */ ) 449 while ( ( tag = *option++ ) != -1 /* end of option field */ )
453 { 450 {
454 len = *option++; 451 len = *option++;
455 qDebug( "recognized DHCP option #%d, length %d", tag, len ); 452 qDebug( "recognized DHCP option #%d, length %d", tag, len );
456 453
457 if ( tag == DHO_DHCP_MESSAGE_TYPE ) 454 if ( tag == DHO_DHCP_MESSAGE_TYPE )
458 _type = *option; 455 _type = *option;
459 456
460 option += len; 457 option += len;
461 if ( option >= end ) 458 if ( option >= end )
462 { 459 {
463 qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" ); 460 qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" );
464 break; 461 break;
465 } 462 }
466 } 463 }
467 464
468 qDebug( "DHCP type seems to be '%s'", (const char*) type() ); 465 qDebug( "DHCP type seems to be '%s'", (const char*) type() );
469} 466}
470 467
471 468
472ODHCPPacket::~ODHCPPacket() 469ODHCPPacket::~ODHCPPacket()
473{ 470{
474} 471}
475 472
476 473
477bool ODHCPPacket::isRequest() const 474bool ODHCPPacket::isRequest() const
478{ 475{
479 return ( _dhcphdr->op == 01 ); 476 return ( _dhcphdr->op == 01 );
480} 477}
481 478
482 479
483bool ODHCPPacket::isReply() const 480bool ODHCPPacket::isReply() const
484{ 481{
485 return ( _dhcphdr->op == 02 ); 482 return ( _dhcphdr->op == 02 );
486} 483}
487 484
488 485
489QString ODHCPPacket::type() const 486QString ODHCPPacket::type() const
490{ 487{
491 switch ( _type ) 488 switch ( _type )
492 { 489 {
493 case 1: return "DISCOVER"; 490 case 1: return "DISCOVER";
494 case 2: return "OFFER"; 491 case 2: return "OFFER";
495 case 3: return "REQUEST"; 492 case 3: return "REQUEST";
496 case 4: return "DECLINE"; 493 case 4: return "DECLINE";
497 case 5: return "ACK"; 494 case 5: return "ACK";
498 case 6: return "NAK"; 495 case 6: return "NAK";
499 case 7: return "RELEASE"; 496 case 7: return "RELEASE";
500 case 8: return "INFORM"; 497 case 8: return "INFORM";
501 default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>"; 498 default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>";
502 } 499 }
503} 500}
504 501
505 502
506QHostAddress ODHCPPacket::clientAddress() const 503QHostAddress ODHCPPacket::clientAddress() const
507{ 504{
508 return EXTRACT_32BITS( &_dhcphdr->ciaddr ); 505 return EXTRACT_32BITS( &_dhcphdr->ciaddr );
509} 506}
510 507
511 508
512QHostAddress ODHCPPacket::yourAddress() const 509QHostAddress ODHCPPacket::yourAddress() const
513{ 510{
514 return EXTRACT_32BITS( &_dhcphdr->yiaddr ); 511 return EXTRACT_32BITS( &_dhcphdr->yiaddr );
515} 512}
516 513
517 514
518QHostAddress ODHCPPacket::serverAddress() const 515QHostAddress ODHCPPacket::serverAddress() const
519{ 516{
520 return EXTRACT_32BITS( &_dhcphdr->siaddr ); 517 return EXTRACT_32BITS( &_dhcphdr->siaddr );
521} 518}
522 519
523 520
524QHostAddress ODHCPPacket::relayAddress() const 521QHostAddress ODHCPPacket::relayAddress() const
525{ 522{
526 return EXTRACT_32BITS( &_dhcphdr->giaddr ); 523 return EXTRACT_32BITS( &_dhcphdr->giaddr );
527} 524}
528 525
529 526
530OMacAddress ODHCPPacket::clientMacAddress() const 527OMacAddress ODHCPPacket::clientMacAddress() const
531{ 528{
532 return OMacAddress( _dhcphdr->chaddr ); 529 return OMacAddress( _dhcphdr->chaddr );
533} 530}
534 531
535 532
536/*====================================================================================== 533/*======================================================================================
537 * OTCPPacket 534 * OTCPPacket
538 *======================================================================================*/ 535 *======================================================================================*/
539 536
540 537
541OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) 538OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
542 :QObject( parent, "TCP" ), _tcphdr( data ) 539 :QObject( parent, "TCP" ), _tcphdr( data )
543 540
544{ 541{
545 qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); 542 qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." );
546} 543}
547 544
548 545
549OTCPPacket::~OTCPPacket() 546OTCPPacket::~OTCPPacket()
550{ 547{
551} 548}
552 549
553 550
554int OTCPPacket::fromPort() const 551int OTCPPacket::fromPort() const
555{ 552{
556 return EXTRACT_16BITS( &_tcphdr->source ); 553 return EXTRACT_16BITS( &_tcphdr->source );
557} 554}
558 555
559 556
560int OTCPPacket::toPort() const 557int OTCPPacket::toPort() const
561{ 558{
562 return EXTRACT_16BITS( &_tcphdr->dest ); 559 return EXTRACT_16BITS( &_tcphdr->dest );
563} 560}
564 561
565 562
566int OTCPPacket::seq() const 563int OTCPPacket::seq() const
567{ 564{
568 return EXTRACT_16BITS( &_tcphdr->seq ); 565 return EXTRACT_16BITS( &_tcphdr->seq );
569} 566}
570 567
571 568
572int OTCPPacket::ack() const 569int OTCPPacket::ack() const
573{ 570{
574 return EXTRACT_16BITS( &_tcphdr->ack_seq ); 571 return EXTRACT_16BITS( &_tcphdr->ack_seq );
575} 572}
576 573
577 574
578int OTCPPacket::window() const 575int OTCPPacket::window() const
579{ 576{
580 return EXTRACT_16BITS( &_tcphdr->window ); 577 return EXTRACT_16BITS( &_tcphdr->window );
581} 578}
582 579
583 580
584int OTCPPacket::checksum() const 581int OTCPPacket::checksum() const
585{ 582{
586 return EXTRACT_16BITS( &_tcphdr->check ); 583 return EXTRACT_16BITS( &_tcphdr->check );
587} 584}
588 585
589/*====================================================================================== 586/*======================================================================================
590 * OPrismHeaderPacket 587 * OPrismHeaderPacket
591 *======================================================================================*/ 588 *======================================================================================*/
592 589
593 590
594OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) 591OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )
595 :QObject( parent, "Prism" ), _header( data ) 592 :QObject( parent, "Prism" ), _header( data )
596 593
597{ 594{
598 qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); 595 qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." );
599 596
600 qDebug( "Signal Strength = %d", data->signal.data ); 597 qDebug( "Signal Strength = %d", data->signal.data );
601 598
602 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); 599 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this );
603} 600}
604 601
605OPrismHeaderPacket::~OPrismHeaderPacket() 602OPrismHeaderPacket::~OPrismHeaderPacket()
606{ 603{
607} 604}
608 605
609 606
610unsigned int OPrismHeaderPacket::signalStrength() const 607unsigned int OPrismHeaderPacket::signalStrength() const
611{ 608{
612 return _header->signal.data; 609 return _header->signal.data;
613} 610}
614 611
615/*====================================================================================== 612/*======================================================================================
616 * OWaveLanPacket 613 * OWaveLanPacket
617 *======================================================================================*/ 614 *======================================================================================*/
618 615
619 616
620OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) 617OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent )
621 :QObject( parent, "802.11" ), _wlanhdr( data ) 618 :QObject( parent, "802.11" ), _wlanhdr( data )
622 619
623{ 620{
624 qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); 621 qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." );
625 qDebug( "type: %0X", type() ); 622 qDebug( "type: %0X", type() );
626 qDebug( "subType: %0X", subType() ); 623 qDebug( "subType: %0X", subType() );
627 qDebug( "duration: %d", duration() ); 624 qDebug( "duration: %d", duration() );
628 qDebug( "powermanagement: %d", usesPowerManagement() ); 625 qDebug( "powermanagement: %d", usesPowerManagement() );
629 qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); 626 qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" );
630 qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); 627 qDebug( "MAC1: %s", (const char*) macAddress1().toString() );
631 qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); 628 qDebug( "MAC2: %s", (const char*) macAddress2().toString() );
632 qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); 629 qDebug( "MAC3: %s", (const char*) macAddress3().toString() );
633 qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); 630 qDebug( "MAC4: %s", (const char*) macAddress4().toString() );
634 631
635 switch ( type() ) 632 switch ( type() )
636 { 633 {
637 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; 634 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break;
638 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; 635 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break;
639 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; 636 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break;
640 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); 637 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() );
641 } 638 }
642} 639}
643 640
644OWaveLanPacket::~OWaveLanPacket() 641OWaveLanPacket::~OWaveLanPacket()
645{ 642{
646} 643}
647 644
648 645
649int OWaveLanPacket::duration() const 646int OWaveLanPacket::duration() const
650{ 647{
651 return _wlanhdr->duration; 648 return _wlanhdr->duration;
652} 649}
653 650
654 651
655OMacAddress OWaveLanPacket::macAddress1() const 652OMacAddress OWaveLanPacket::macAddress1() const
656{ 653{
657 return OMacAddress( _wlanhdr->mac1 ); 654 return OMacAddress( _wlanhdr->mac1 );
658} 655}
659 656
660 657
661OMacAddress OWaveLanPacket::macAddress2() const 658OMacAddress OWaveLanPacket::macAddress2() const
662{ 659{
663 return OMacAddress( _wlanhdr->mac2 ); 660 return OMacAddress( _wlanhdr->mac2 );
664} 661}
665 662
666 663
667OMacAddress OWaveLanPacket::macAddress3() const 664OMacAddress OWaveLanPacket::macAddress3() const
668{ 665{
669 return OMacAddress( _wlanhdr->mac3 ); 666 return OMacAddress( _wlanhdr->mac3 );
670} 667}
671 668
672 669
673OMacAddress OWaveLanPacket::macAddress4() const 670OMacAddress OWaveLanPacket::macAddress4() const
674{ 671{
675 return OMacAddress( _wlanhdr->mac4 ); 672 return OMacAddress( _wlanhdr->mac4 );
676} 673}
677 674
678 675
679int OWaveLanPacket::subType() const 676int OWaveLanPacket::subType() const
680{ 677{
681 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 678 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
682} 679}
683 680
684 681
685int OWaveLanPacket::type() const 682int OWaveLanPacket::type() const
686{ 683{
687 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 684 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
688} 685}
689 686
690 687
691int OWaveLanPacket::version() const 688int OWaveLanPacket::version() const
692{ 689{
693 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 690 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
694} 691}
695 692
696 693
697bool OWaveLanPacket::fromDS() const 694bool OWaveLanPacket::fromDS() const
698{ 695{
699 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 696 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
700} 697}
701 698
702 699
703bool OWaveLanPacket::toDS() const 700bool OWaveLanPacket::toDS() const
704{ 701{
705 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 702 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
706} 703}
707 704
708 705
709bool OWaveLanPacket::usesPowerManagement() const 706bool OWaveLanPacket::usesPowerManagement() const
710{ 707{
711 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 708 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
712} 709}
713 710
714 711
715bool OWaveLanPacket::usesWep() const 712bool OWaveLanPacket::usesWep() const
716{ 713{
717 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 714 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
718} 715}
719 716
720 717
721/*====================================================================================== 718/*======================================================================================
722 * OWaveLanManagementPacket 719 * OWaveLanManagementPacket
723 *======================================================================================*/ 720 *======================================================================================*/
724 721
725OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) 722OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent )
726 :QObject( parent, "802.11 Management" ), _header( data ), 723 :QObject( parent, "802.11 Management" ), _header( data ),
727 _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) 724 _body( (const struct ieee_802_11_mgmt_body*) (data+1) )
728{ 725{
729 qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); 726 qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." );
730 qDebug( "Detected subtype is '%s'", (const char*) managementType() ); 727 qDebug( "Detected subtype is '%s'", (const char*) managementType() );
731 728
732 // grab tagged values 729 // grab tagged values
733 const unsigned char* ptr = (const unsigned char*) (_body+1); 730 const unsigned char* ptr = (const unsigned char*) (_body+1);
734 while (ptr < end) 731 while (ptr < end)
735 { 732 {
736 switch ( *ptr ) 733 switch ( *ptr )
737 { 734 {
738 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; 735 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break;
739 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; 736 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break;
740 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; 737 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break;
741 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; 738 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break;
742 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; 739 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break;
743 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; 740 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break;
744 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; 741 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break;
745 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; 742 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break;
746 } 743 }
747 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value 744 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value
748 ptr+= 2; // skip tag ID and length 745 ptr+= 2; // skip tag ID and length
749 } 746 }
750} 747}
751 748
752 749
753OWaveLanManagementPacket::~OWaveLanManagementPacket() 750OWaveLanManagementPacket::~OWaveLanManagementPacket()
754{ 751{
755} 752}
756 753
757 754
758QString OWaveLanManagementPacket::managementType() const 755QString OWaveLanManagementPacket::managementType() const
759{ 756{
760 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) 757 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) )
761 { 758 {
762 case ST_ASSOC_REQUEST: return "AssociationRequest"; break; 759 case ST_ASSOC_REQUEST: return "AssociationRequest"; break;
763 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break; 760 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break;
764 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break; 761 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break;
765 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break; 762 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break;
766 case ST_PROBE_REQUEST: return "ProbeRequest"; break; 763 case ST_PROBE_REQUEST: return "ProbeRequest"; break;
767 case ST_PROBE_RESPONSE: return "ProbeResponse"; break; 764 case ST_PROBE_RESPONSE: return "ProbeResponse"; break;
768 case ST_BEACON: return "Beacon"; break; 765 case ST_BEACON: return "Beacon"; break;
769 case ST_ATIM: return "Atim"; break; 766 case ST_ATIM: return "Atim"; break;
770 case ST_DISASSOC: return "Disassociation"; break; 767 case ST_DISASSOC: return "Disassociation"; break;
771 case ST_AUTH: return "Authentication"; break; 768 case ST_AUTH: return "Authentication"; break;
772 case ST_DEAUTH: return "Deathentication"; break; 769 case ST_DEAUTH: return "Deathentication"; break;
773 default: 770 default:
774 qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ); 771 qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) );
775 return "Unknown"; 772 return "Unknown";
776 } 773 }
777} 774}
778 775
779 776
780int OWaveLanManagementPacket::beaconInterval() const 777int OWaveLanManagementPacket::beaconInterval() const
781{ 778{
782 return EXTRACT_LE_16BITS( &_body->beacon_interval ); 779 return EXTRACT_LE_16BITS( &_body->beacon_interval );
783} 780}
784 781
785 782
786int OWaveLanManagementPacket::capabilities() const 783int OWaveLanManagementPacket::capabilities() const
787{ 784{
788 return EXTRACT_LE_16BITS( &_body->capability_info ); 785 return EXTRACT_LE_16BITS( &_body->capability_info );
789} 786}
790 787
791 788
792bool OWaveLanManagementPacket::canESS() const 789bool OWaveLanManagementPacket::canESS() const
793{ 790{
794 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 791 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) );
795} 792}
796 793
797 794
798bool OWaveLanManagementPacket::canIBSS() const 795bool OWaveLanManagementPacket::canIBSS() const
799{ 796{
800 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 797 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) );
801} 798}
802 799
803 800
804bool OWaveLanManagementPacket::canCFP() const 801bool OWaveLanManagementPacket::canCFP() const
805{ 802{
806 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); 803 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) );
807} 804}
808 805
809 806
810bool OWaveLanManagementPacket::canCFP_REQ() const 807bool OWaveLanManagementPacket::canCFP_REQ() const
811{ 808{
812 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); 809 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) );
813} 810}
814 811
815 812
816bool OWaveLanManagementPacket::canPrivacy() const 813bool OWaveLanManagementPacket::canPrivacy() const
817{ 814{
818 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); 815 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) );
819} 816}
820 817
821 818
822/*====================================================================================== 819/*======================================================================================
823 * OWaveLanManagementSSID 820 * OWaveLanManagementSSID
824 *======================================================================================*/ 821 *======================================================================================*/
825 822
826OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) 823OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent )
827 :QObject( parent, "802.11 SSID" ), _data( data ) 824 :QObject( parent, "802.11 SSID" ), _data( data )
828{ 825{
829 qDebug( "OWaveLanManagementSSID()" ); 826 qDebug( "OWaveLanManagementSSID()" );
830} 827}
831 828
832 829
833OWaveLanManagementSSID::~OWaveLanManagementSSID() 830OWaveLanManagementSSID::~OWaveLanManagementSSID()
834{ 831{
835} 832}
836 833
837 834
838QString OWaveLanManagementSSID::ID() const 835QString OWaveLanManagementSSID::ID() const
839{ 836{
840 int length = _data->length; 837 int length = _data->length;
841 if ( length > 32 ) length = 32; 838 if ( length > 32 ) length = 32;
842 char essid[length+1]; 839 char essid[length+1];
843 memcpy( &essid, &_data->ssid, length ); 840 memcpy( &essid, &_data->ssid, length );
844 essid[length] = 0x0; 841 essid[length] = 0x0;
845 return essid; 842 return essid;
846} 843}
847 844
848 845
849/*====================================================================================== 846/*======================================================================================
850 * OWaveLanManagementRates 847 * OWaveLanManagementRates
851 *======================================================================================*/ 848 *======================================================================================*/
852 849
853OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) 850OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent )
854 :QObject( parent, "802.11 Rates" ), _data( data ) 851 :QObject( parent, "802.11 Rates" ), _data( data )
855{ 852{
856 qDebug( "OWaveLanManagementRates()" ); 853 qDebug( "OWaveLanManagementRates()" );
857} 854}
858 855
859 856
860OWaveLanManagementRates::~OWaveLanManagementRates() 857OWaveLanManagementRates::~OWaveLanManagementRates()
861{ 858{
862} 859}
863 860
864/*====================================================================================== 861/*======================================================================================
865 * OWaveLanManagementCF 862 * OWaveLanManagementCF
866 *======================================================================================*/ 863 *======================================================================================*/
867 864
868OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) 865OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent )
869 :QObject( parent, "802.11 CF" ), _data( data ) 866 :QObject( parent, "802.11 CF" ), _data( data )
870{ 867{
871 qDebug( "OWaveLanManagementCF()" ); 868 qDebug( "OWaveLanManagementCF()" );
872} 869}
873 870
874 871
875OWaveLanManagementCF::~OWaveLanManagementCF() 872OWaveLanManagementCF::~OWaveLanManagementCF()
876{ 873{
877} 874}
878 875
879/*====================================================================================== 876/*======================================================================================
880 * OWaveLanManagementFH 877 * OWaveLanManagementFH
881 *======================================================================================*/ 878 *======================================================================================*/
882 879
883OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) 880OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent )
884 :QObject( parent, "802.11 FH" ), _data( data ) 881 :QObject( parent, "802.11 FH" ), _data( data )
885{ 882{
886 qDebug( "OWaveLanManagementFH()" ); 883 qDebug( "OWaveLanManagementFH()" );
887} 884}
888 885
889 886
890OWaveLanManagementFH::~OWaveLanManagementFH() 887OWaveLanManagementFH::~OWaveLanManagementFH()
891{ 888{
892} 889}
893 890
894/*====================================================================================== 891/*======================================================================================
895 * OWaveLanManagementDS 892 * OWaveLanManagementDS
896 *======================================================================================*/ 893 *======================================================================================*/
897 894
898OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) 895OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent )
899 :QObject( parent, "802.11 DS" ), _data( data ) 896 :QObject( parent, "802.11 DS" ), _data( data )
900{ 897{
901 qDebug( "OWaveLanManagementDS()" ); 898 qDebug( "OWaveLanManagementDS()" );
902} 899}
903 900
904 901
905OWaveLanManagementDS::~OWaveLanManagementDS() 902OWaveLanManagementDS::~OWaveLanManagementDS()
906{ 903{
907} 904}
908 905
909 906
910int OWaveLanManagementDS::channel() const 907int OWaveLanManagementDS::channel() const
911{ 908{
912 return _data->channel; 909 return _data->channel;
913} 910}
914 911
915/*====================================================================================== 912/*======================================================================================
916 * OWaveLanManagementTim 913 * OWaveLanManagementTim
917 *======================================================================================*/ 914 *======================================================================================*/
918 915
919OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) 916OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent )
920 :QObject( parent, "802.11 Tim" ), _data( data ) 917 :QObject( parent, "802.11 Tim" ), _data( data )
921{ 918{
922 qDebug( "OWaveLanManagementTim()" ); 919 qDebug( "OWaveLanManagementTim()" );
923} 920}
924 921
925 922
926OWaveLanManagementTim::~OWaveLanManagementTim() 923OWaveLanManagementTim::~OWaveLanManagementTim()
927{ 924{
928} 925}
929 926
930/*====================================================================================== 927/*======================================================================================
931 * OWaveLanManagementIBSS 928 * OWaveLanManagementIBSS
932 *======================================================================================*/ 929 *======================================================================================*/
933 930
934OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) 931OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent )
935 :QObject( parent, "802.11 IBSS" ), _data( data ) 932 :QObject( parent, "802.11 IBSS" ), _data( data )
936{ 933{
937 qDebug( "OWaveLanManagementIBSS()" ); 934 qDebug( "OWaveLanManagementIBSS()" );
938} 935}
939 936
940 937
941OWaveLanManagementIBSS::~OWaveLanManagementIBSS() 938OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
942{ 939{
943} 940}
944 941
945/*====================================================================================== 942/*======================================================================================
946 * OWaveLanManagementChallenge 943 * OWaveLanManagementChallenge
947 *======================================================================================*/ 944 *======================================================================================*/
948 945
949OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) 946OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent )
950 :QObject( parent, "802.11 Challenge" ), _data( data ) 947 :QObject( parent, "802.11 Challenge" ), _data( data )
951{ 948{
952 qDebug( "OWaveLanManagementChallenge()" ); 949 qDebug( "OWaveLanManagementChallenge()" );
953} 950}
954 951
955 952
956OWaveLanManagementChallenge::~OWaveLanManagementChallenge() 953OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
957{ 954{
958} 955}
959 956
960/*====================================================================================== 957/*======================================================================================
961 * OWaveLanDataPacket 958 * OWaveLanDataPacket
962 *======================================================================================*/ 959 *======================================================================================*/
963 960
964OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) 961OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
965 :QObject( parent, "802.11 Data" ), _header( data ) 962 :QObject( parent, "802.11 Data" ), _header( data )
966{ 963{
967 qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." ); 964 qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." );
968 965
969 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); 966 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header );
970 967
971 #warning The next line works for most cases, but can not be correct generally! 968 #warning The next line works for most cases, but can not be correct generally!
972 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address 969 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address
973 970
974 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); 971 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this );
975} 972}
976 973
977 974
978OWaveLanDataPacket::~OWaveLanDataPacket() 975OWaveLanDataPacket::~OWaveLanDataPacket()
979{ 976{
980} 977}
981 978
982 979
983/*====================================================================================== 980/*======================================================================================
984 * OLLCPacket 981 * OLLCPacket
985 *======================================================================================*/ 982 *======================================================================================*/
986 983
987OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) 984OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
988 :QObject( parent, "802.11 LLC" ), _header( data ) 985 :QObject( parent, "802.11 LLC" ), _header( data )
989{ 986{
990 qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." ); 987 qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." );
991 988
992 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) 989 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
993 { 990 {
994 qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 991 qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) );
995 992
996 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h 993 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
997 { 994 {
998 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 995 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
999 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 996 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
1000 default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 997 default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) );
1001 } 998 }
1002 999
1003 } 1000 }
1004} 1001}
1005 1002
1006 1003
1007OLLCPacket::~OLLCPacket() 1004OLLCPacket::~OLLCPacket()
1008{ 1005{
1009} 1006}
1010 1007
1011 1008
1012/*====================================================================================== 1009/*======================================================================================
1013 * OWaveLanControlPacket 1010 * OWaveLanControlPacket
1014 *======================================================================================*/ 1011 *======================================================================================*/
1015 1012
1016OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) 1013OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
1017 :QObject( parent, "802.11 Control" ), _header( data ) 1014 :QObject( parent, "802.11 Control" ), _header( data )
1018{ 1015{
1019 qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." ); 1016 qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." );
1020 //TODO: Implement this 1017 //TODO: Implement this
1021} 1018}
1022 1019
1023 1020
1024OWaveLanControlPacket::~OWaveLanControlPacket() 1021OWaveLanControlPacket::~OWaveLanControlPacket()
1025{ 1022{
1026} 1023}
1027 1024
1028 1025
1029/*====================================================================================== 1026/*======================================================================================
1030 * OPacketCapturer 1027 * OPacketCapturer
1031 *======================================================================================*/ 1028 *======================================================================================*/
1032 1029
1033OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 1030OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
1034 :QObject( parent, name ), _name( QString::null ), _open( false ), 1031 :QObject( parent, name ), _name( QString::null ), _open( false ),
1035 _pch( 0 ), _pcd( 0 ), _sn( 0 ) 1032 _pch( 0 ), _pcd( 0 ), _sn( 0 )
1036{ 1033{
1037} 1034}
1038 1035
1039 1036
1040OPacketCapturer::~OPacketCapturer() 1037OPacketCapturer::~OPacketCapturer()
1041{ 1038{
1042 if ( _open ) 1039 if ( _open )
1043 { 1040 {
1044 qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." ); 1041 qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." );
1045 close(); 1042 close();
1046 } 1043 }
1047} 1044}
1048 1045
1049 1046
1050void OPacketCapturer::setBlocking( bool b ) 1047void OPacketCapturer::setBlocking( bool b )
1051{ 1048{
1052 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) 1049 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
1053 { 1050 {
1054 qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." ); 1051 qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." );
1055 } 1052 }
1056 else 1053 else
1057 { 1054 {
1058 qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf ); 1055 qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf );
1059 } 1056 }
1060} 1057}
1061 1058
1062 1059
1063bool OPacketCapturer::blocking() const 1060bool OPacketCapturer::blocking() const
1064{ 1061{
1065 int b = pcap_getnonblock( _pch, _errbuf ); 1062 int b = pcap_getnonblock( _pch, _errbuf );
1066 if ( b == -1 ) 1063 if ( b == -1 )
1067 { 1064 {
1068 qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf ); 1065 qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf );
1069 return -1; 1066 return -1;
1070 } 1067 }
1071 return !b; 1068 return !b;
1072} 1069}
1073 1070
1074 1071
1075void OPacketCapturer::closeDumpFile() 1072void OPacketCapturer::closeDumpFile()
1076{ 1073{
1077 if ( _pcd ) 1074 if ( _pcd )
1078 { 1075 {
1079 pcap_dump_close( _pcd ); 1076 pcap_dump_close( _pcd );
1080 _pcd = 0; 1077 _pcd = 0;
1081 } 1078 }
1082 pcap_close( _pch ); 1079 pcap_close( _pch );
1083} 1080}
1084 1081
1085 1082
1086void OPacketCapturer::close() 1083void OPacketCapturer::close()
1087{ 1084{
1088 if ( _open ) 1085 if ( _open )
1089 { 1086 {
1090 if ( _sn ) 1087 if ( _sn )
1091 { 1088 {
1092 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1089 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1093 delete _sn; 1090 delete _sn;
1094 } 1091 }
1095 closeDumpFile(); 1092 closeDumpFile();
1096 _open = false; 1093 _open = false;
1097 } 1094 }
1098 1095
1099 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); 1096 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." );
1100 qDebug( "--------------------------------------------------" ); 1097 qDebug( "--------------------------------------------------" );
1101 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) 1098 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
1102 qDebug( "%s : %d", (const char*) it.key(), it.data() ); 1099 qDebug( "%s : %d", (const char*) it.key(), it.data() );
1103 qDebug( "--------------------------------------------------" ); 1100 qDebug( "--------------------------------------------------" );
1104 1101
1105} 1102}
1106 1103
1107 1104
1108int OPacketCapturer::dataLink() const 1105int OPacketCapturer::dataLink() const
1109{ 1106{
1110 return pcap_datalink( _pch ); 1107 return pcap_datalink( _pch );
1111} 1108}
1112 1109
1113 1110
1114void OPacketCapturer::dump( OPacket* p ) 1111void OPacketCapturer::dump( OPacket* p )
1115{ 1112{
1116 if ( !_pcd ) 1113 if ( !_pcd )
1117 { 1114 {
1118 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" ); 1115 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" );
1119 return; 1116 return;
1120 } 1117 }
1121 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); 1118 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data );
1122} 1119}
1123 1120
1124 1121
1125int OPacketCapturer::fileno() const 1122int OPacketCapturer::fileno() const
1126{ 1123{
1127 if ( _open ) 1124 if ( _open )
1128 { 1125 {
1129 return pcap_fileno( _pch ); 1126 return pcap_fileno( _pch );
1130 } 1127 }
1131 else 1128 else
1132 { 1129 {
1133 return -1; 1130 return -1;
1134 } 1131 }
1135} 1132}
1136 1133
1137 1134
1138OPacket* OPacketCapturer::next( int time ) 1135OPacket* OPacketCapturer::next( int time )
1139{ 1136{
1140 fd_set fds; 1137 fd_set fds;
1141 struct timeval tv; 1138 struct timeval tv;
1142 FD_ZERO( &fds ); 1139 FD_ZERO( &fds );
1143 FD_SET( pcap_fileno( _pch ), &fds ); 1140 FD_SET( pcap_fileno( _pch ), &fds );
1144 tv.tv_sec = time / 1000; 1141 tv.tv_sec = time / 1000;
1145 tv.tv_usec = time % 1000; 1142 tv.tv_usec = time % 1000;
1146 int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv); 1143 int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv);
1147 if ( retval > 0 ) // clear to read! 1144 if ( retval > 0 ) // clear to read!
1148 return next(); 1145 return next();
1149 else 1146 else
1150 return 0; 1147 return 0;
1151} 1148}
1152 1149
1153 1150
1154OPacket* OPacketCapturer::next() 1151OPacket* OPacketCapturer::next()
1155{ 1152{
1156 packetheaderstruct header; 1153 packetheaderstruct header;
1157 qDebug( "==> OPacketCapturer::next()" ); 1154 qDebug( "==> OPacketCapturer::next()" );
1158 const unsigned char* pdata = pcap_next( _pch, &header ); 1155 const unsigned char* pdata = pcap_next( _pch, &header );
1159 qDebug( "<== OPacketCapturer::next()" ); 1156 qDebug( "<== OPacketCapturer::next()" );
1160 1157
1161 if ( pdata && header.len ) 1158 if ( pdata && header.len )
1162 { 1159 {
1163 OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); 1160 OPacket* p = new OPacket( dataLink(), header, pdata, 0 );
1164 // packets shouldn't be inserted in the QObject child-parent hierarchy, 1161 // packets shouldn't be inserted in the QObject child-parent hierarchy,
1165 // because due to memory constraints they will be deleted as soon 1162 // because due to memory constraints they will be deleted as soon
1166 // as possible - that is right after they have been processed 1163 // as possible - that is right after they have been processed
1167 // by emit() [ see below ] 1164 // by emit() [ see below ]
1168 //TODO: make gathering statistics optional, because it takes time 1165 //TODO: make gathering statistics optional, because it takes time
1169 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); 1166 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
1170 #ifndef NODEBUG 1167 #ifndef NODEBUG
1171 p->dumpStructure( const_cast<QObjectList*>( p->children() ) ); 1168 p->dumpStructure( const_cast<QObjectList*>( p->children() ) );
1172 #endif 1169 #endif
1173 return p; 1170 return p;
1174 } 1171 }
1175 else 1172 else
1176 { 1173 {
1177 qWarning( "OPacketCapturer::next() - no packet received!" ); 1174 qWarning( "OPacketCapturer::next() - no packet received!" );
1178 return 0; 1175 return 0;
1179 } 1176 }
1180} 1177}
1181 1178
1182 1179
1183bool OPacketCapturer::open( const QString& name ) 1180bool OPacketCapturer::open( const QString& name )
1184{ 1181{
1185 if ( _open ) 1182 if ( _open )
1186 { 1183 {
1187 if ( name == _name ) // ignore opening an already openend device 1184 if ( name == _name ) // ignore opening an already openend device
1188 { 1185 {
1189 return true; 1186 return true;
1190 } 1187 }
1191 else // close the last opened device 1188 else // close the last opened device
1192 { 1189 {
1193 close(); 1190 close();
1194 } 1191 }
1195 } 1192 }
1196 1193
1197 _name = name; 1194 _name = name;
1198 1195
1199 // open libpcap 1196 // open libpcap
1200 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); 1197 pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] );
1201 1198
1202 if ( !handle ) 1199 if ( !handle )
1203 { 1200 {
1204 qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1201 qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
1205 return false; 1202 return false;
1206 } 1203 }
1207 1204
1208 qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name ); 1205 qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name );
1209 _pch = handle; 1206 _pch = handle;
1210 _open = true; 1207 _open = true;
1211 _stats.clear(); 1208 _stats.clear();
1212 1209
1213 // in case we have an application object, create a socket notifier 1210 // in case we have an application object, create a socket notifier
1214 if ( qApp ) //TODO: I don't like this here... 1211 if ( qApp ) //TODO: I don't like this here...
1215 { 1212 {
1216 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1213 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
1217 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1214 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1218 } 1215 }
1219 1216
1220 return true; 1217 return true;
1221} 1218}
1222 1219
1223 1220
1224bool OPacketCapturer::openDumpFile( const QString& filename ) 1221bool OPacketCapturer::openDumpFile( const QString& filename )
1225{ 1222{
1226 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); 1223 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) );
1227 if ( !dump ) 1224 if ( !dump )
1228 { 1225 {
1229 qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf ); 1226 qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf );
1230 return false; 1227 return false;
1231 } 1228 }
1232 qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename ); 1229 qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename );
1233 _pcd = dump; 1230 _pcd = dump;
1234 1231
1235 return true; 1232 return true;
1236} 1233}
1237 1234
1238 1235
1239bool OPacketCapturer::open( const QFile& file ) 1236bool OPacketCapturer::open( const QFile& file )
1240{ 1237{
1241 QString name = file.name(); 1238 QString name = file.name();
1242 1239
1243 if ( _open ) 1240 if ( _open )
1244 { 1241 {
1245 close(); 1242 close();
1246 if ( name == _name ) // ignore opening an already openend device 1243 if ( name == _name ) // ignore opening an already openend device
1247 { 1244 {
1248 return true; 1245 return true;
1249 } 1246 }
1250 else // close the last opened device 1247 else // close the last opened device
1251 { 1248 {
1252 close(); 1249 close();
1253 } 1250 }
1254 } 1251 }
1255 1252
1256 _name = name; 1253 _name = name;
1257 1254
1258 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); 1255 pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] );
1259 1256
1260 if ( handle ) 1257 if ( handle )
1261 { 1258 {
1262 qDebug( "OPacketCapturer::open(): libpcap opened successfully." ); 1259 qDebug( "OPacketCapturer::open(): libpcap opened successfully." );
1263 _pch = handle; 1260 _pch = handle;
1264 _open = true; 1261 _open = true;
1265 1262
1266 // in case we have an application object, create a socket notifier 1263 // in case we have an application object, create a socket notifier
1267 if ( qApp ) 1264 if ( qApp )
1268 { 1265 {
1269 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); 1266 _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read );
1270 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1267 connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1271 } 1268 }
1272 1269
1273 return true; 1270 return true;
1274 } 1271 }
1275 else 1272 else
1276 { 1273 {
1277 qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1274 qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf );
1278 return false; 1275 return false;
1279 } 1276 }
1280 1277
1281} 1278}
1282 1279
1283 1280
1284bool OPacketCapturer::isOpen() const 1281bool OPacketCapturer::isOpen() const
1285{ 1282{
1286 return _open; 1283 return _open;
1287} 1284}
1288 1285
1289 1286
1290void OPacketCapturer::readyToReceive() 1287void OPacketCapturer::readyToReceive()
1291{ 1288{
1292 qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" ); 1289 qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" );
1293 OPacket* p = next(); 1290 OPacket* p = next();
1294 emit receivedPacket( p ); 1291 emit receivedPacket( p );
1295 // emit is synchronous - packet has been dealt with, now it's safe to delete 1292 // emit is synchronous - packet has been dealt with, now it's safe to delete
1296 delete p; 1293 delete p;
1297} 1294}
1298 1295
1299 1296
1300const QMap<QString,int>& OPacketCapturer::statistics() const 1297const QMap<QString,int>& OPacketCapturer::statistics() const
1301{ 1298{
1302 return _stats; 1299 return _stats;
1303} 1300}
1304 1301
1305 1302
1306int OPacketCapturer::snapShot() const 1303int OPacketCapturer::snapShot() const
1307{ 1304{
1308 return pcap_snapshot( _pch ); 1305 return pcap_snapshot( _pch );
1309} 1306}
1310 1307
1311 1308
1312bool OPacketCapturer::swapped() const 1309bool OPacketCapturer::swapped() const
1313{ 1310{
1314 return pcap_is_swapped( _pch ); 1311 return pcap_is_swapped( _pch );
1315} 1312}
1316 1313
1317 1314
1318QString OPacketCapturer::version() const 1315QString OPacketCapturer::version() const
1319{ 1316{
1320 return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); 1317 return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) );
1321} 1318}
1322 1319
1323 1320
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 54b256b..497fd6b 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -1,667 +1,664 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 4 =.
8 .=l. 5 .=l.
9           .>+-= 6           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 13    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 20++=   -.     .`     .: details.
24 :     =  ...= . :.=- 21 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
31 28
32*/ 29*/
33 30
34#ifndef OPCAP_H 31#ifndef OPCAP_H
35#define OPCAP_H 32#define OPCAP_H
36 33
37/* LINUX */ 34/* LINUX */
38extern "C" // work around a bpf/pcap conflict in recent headers 35extern "C" // work around a bpf/pcap conflict in recent headers
39{ 36{
40 #include <pcap.h> 37 #include <pcap.h>
41} 38}
42#include <netinet/ether.h> 39#include <netinet/ether.h>
43#include <netinet/ip.h> 40#include <netinet/ip.h>
44#include <netinet/udp.h> 41#include <netinet/udp.h>
45#include <netinet/tcp.h> 42#include <netinet/tcp.h>
46#include <time.h> 43#include <time.h>
47 44
48/* QT */ 45/* QT */
49#include <qevent.h> 46#include <qevent.h>
50#include <qfile.h> 47#include <qfile.h>
51#include <qhostaddress.h> 48#include <qhostaddress.h>
52#include <qobject.h> 49#include <qobject.h>
53#include <qstring.h> 50#include <qstring.h>
54#include <qmap.h> 51#include <qmap.h>
55 52
56/* OPIE */ 53/* OPIE */
57#include <opie2/onetutils.h> 54#include <opie2/onetutils.h>
58 55
59/* Custom Network Includes */ 56/* Custom Network Includes */
60#include "802_11_user.h" 57#include "802_11_user.h"
61#include "dhcp.h" 58#include "dhcp.h"
62 59
63/* TYPEDEFS */ 60/* TYPEDEFS */
64typedef struct timeval timevalstruct; 61typedef struct timeval timevalstruct;
65typedef struct pcap_pkthdr packetheaderstruct; 62typedef struct pcap_pkthdr packetheaderstruct;
66 63
67/* FORWARDS */ 64/* FORWARDS */
68class OPacketCapturer; 65class OPacketCapturer;
69class QSocketNotifier; 66class QSocketNotifier;
70 67
71/*====================================================================================== 68/*======================================================================================
72 * OPacket - A frame on the wire 69 * OPacket - A frame on the wire
73 *======================================================================================*/ 70 *======================================================================================*/
74 71
75/** @brief A class representing a data frame on the wire. 72/** @brief A class representing a data frame on the wire.
76 * 73 *
77 * The whole family of the packet classes are used when capturing frames from a network. 74 * The whole family of the packet classes are used when capturing frames from a network.
78 * Most standard network protocols in use share a common architecture, which mostly is 75 * Most standard network protocols in use share a common architecture, which mostly is
79 * a packet header and then the packet payload. In layered architectures, each lower layer 76 * a packet header and then the packet payload. In layered architectures, each lower layer
80 * encapsulates data from its upper layer - that is it 77 * encapsulates data from its upper layer - that is it
81 * treats the data from its upper layer as payload and prepends an own header to the packet, 78 * treats the data from its upper layer as payload and prepends an own header to the packet,
82 * which - again - is treated as the payload for the layer below. The figure below is an 79 * which - again - is treated as the payload for the layer below. The figure below is an
83 * example for how such a data frame is composed out of packets, e.g. when sending a mail. 80 * example for how such a data frame is composed out of packets, e.g. when sending a mail.
84 * 81 *
85 * <pre> 82 * <pre>
86 * | User Data | == Mail Data 83 * | User Data | == Mail Data
87 * | SMTP Header | User Data | == SMTP 84 * | SMTP Header | User Data | == SMTP
88 * | TCP Header | SMTP Header | User Data | == TCP 85 * | TCP Header | SMTP Header | User Data | == TCP
89 * | IP Header | TCP Header | SMTP Header | User Data | == IP 86 * | IP Header | TCP Header | SMTP Header | User Data | == IP
90 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC 87 * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC
91 * 88 *
92 * </pre> 89 * </pre>
93 * 90 *
94 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer 91 * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer
95 * also contains a few more levels of encapsulation. 92 * also contains a few more levels of encapsulation.
96 * Since the type of the payload is more or less independent from the encapsulating protocol, 93 * Since the type of the payload is more or less independent from the encapsulating protocol,
97 * the header must be inspected before attempting to decode the payload. Hence, the 94 * the header must be inspected before attempting to decode the payload. Hence, the
98 * encapsulation level varies and can't be deduced without actually looking into the packets. 95 * encapsulation level varies and can't be deduced without actually looking into the packets.
99 * 96 *
100 * For actually working with captured frames, it's useful to identify the packets via names and 97 * For actually working with captured frames, it's useful to identify the packets via names and
101 * insert them into a parent/child - relationship based on the encapsulation. This is why 98 * insert them into a parent/child - relationship based on the encapsulation. This is why
102 * all packet classes derive from QObject. The amount of overhead caused by the QObject is 99 * all packet classes derive from QObject. The amount of overhead caused by the QObject is
103 * not a problem in this case, because we're talking about a theoratical maximum of about 100 * not a problem in this case, because we're talking about a theoratical maximum of about
104 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the 101 * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the
105 * QObject also cares about destroying the sub-, (child-) packets. 102 * QObject also cares about destroying the sub-, (child-) packets.
106 * 103 *
107 * This enables us to perform a simple look for packets of a certain type: 104 * This enables us to perform a simple look for packets of a certain type:
108 * @code 105 * @code
109 * OPacketCapturer* pcap = new OPacketCapturer(); 106 * OPacketCapturer* pcap = new OPacketCapturer();
110 * pcap->open( "eth0" ); 107 * pcap->open( "eth0" );
111 * OPacket* p = pcap->next(); 108 * OPacket* p = pcap->next();
112 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists 109 * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists
113 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; 110 * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl;
114 * 111 *
115 */ 112 */
116 113
117class OPacket : public QObject 114class OPacket : public QObject
118{ 115{
119 Q_OBJECT 116 Q_OBJECT
120 117
121 friend class OPacketCapturer; 118 friend class OPacketCapturer;
122 119
123 public: 120 public:
124 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); 121 OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent );
125 virtual ~OPacket(); 122 virtual ~OPacket();
126 123
127 timevalstruct timeval() const; 124 timevalstruct timeval() const;
128 125
129 int caplen() const; 126 int caplen() const;
130 int len() const; 127 int len() const;
131 QString dump( int = 32 ) const; 128 QString dump( int = 32 ) const;
132 129
133 void updateStats( QMap<QString,int>&, QObjectList* ); 130 void updateStats( QMap<QString,int>&, QObjectList* );
134 131
135 private: 132 private:
136 133
137 void dumpStructure( QObjectList* ); 134 void dumpStructure( QObjectList* );
138 QString _dumpStructure( QObjectList* ); 135 QString _dumpStructure( QObjectList* );
139 136
140 private: 137 private:
141 const packetheaderstruct _hdr; // pcap packet header 138 const packetheaderstruct _hdr; // pcap packet header
142 const unsigned char* _data; // pcap packet data 139 const unsigned char* _data; // pcap packet data
143 const unsigned char* _end; // end of pcap packet data 140 const unsigned char* _end; // end of pcap packet data
144}; 141};
145 142
146/*====================================================================================== 143/*======================================================================================
147 * OEthernetPacket - DLT_EN10MB frame 144 * OEthernetPacket - DLT_EN10MB frame
148 *======================================================================================*/ 145 *======================================================================================*/
149 146
150class OEthernetPacket : public QObject 147class OEthernetPacket : public QObject
151{ 148{
152 Q_OBJECT 149 Q_OBJECT
153 150
154 public: 151 public:
155 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); 152 OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 );
156 virtual ~OEthernetPacket(); 153 virtual ~OEthernetPacket();
157 154
158 OMacAddress sourceAddress() const; 155 OMacAddress sourceAddress() const;
159 OMacAddress destinationAddress() const; 156 OMacAddress destinationAddress() const;
160 int type() const; 157 int type() const;
161 158
162 private: 159 private:
163 const struct ether_header* _ether; 160 const struct ether_header* _ether;
164}; 161};
165 162
166/*====================================================================================== 163/*======================================================================================
167 * OPrismHeaderPacket - DLT_PRISM_HEADER frame 164 * OPrismHeaderPacket - DLT_PRISM_HEADER frame
168 *======================================================================================*/ 165 *======================================================================================*/
169 166
170class OPrismHeaderPacket : public QObject 167class OPrismHeaderPacket : public QObject
171{ 168{
172 Q_OBJECT 169 Q_OBJECT
173 170
174 public: 171 public:
175 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); 172 OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 );
176 virtual ~OPrismHeaderPacket(); 173 virtual ~OPrismHeaderPacket();
177 174
178 unsigned int signalStrength() const; 175 unsigned int signalStrength() const;
179 176
180 private: 177 private:
181 const struct prism_hdr* _header; 178 const struct prism_hdr* _header;
182}; 179};
183 180
184/*====================================================================================== 181/*======================================================================================
185 * OWaveLanPacket - DLT_IEEE802_11 frame 182 * OWaveLanPacket - DLT_IEEE802_11 frame
186 *======================================================================================*/ 183 *======================================================================================*/
187 184
188class OWaveLanPacket : public QObject 185class OWaveLanPacket : public QObject
189{ 186{
190 Q_OBJECT 187 Q_OBJECT
191 188
192 public: 189 public:
193 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); 190 OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 );
194 virtual ~OWaveLanPacket(); 191 virtual ~OWaveLanPacket();
195 192
196 int duration() const; 193 int duration() const;
197 bool fromDS() const; 194 bool fromDS() const;
198 bool toDS() const; 195 bool toDS() const;
199 virtual OMacAddress macAddress1() const; 196 virtual OMacAddress macAddress1() const;
200 virtual OMacAddress macAddress2() const; 197 virtual OMacAddress macAddress2() const;
201 virtual OMacAddress macAddress3() const; 198 virtual OMacAddress macAddress3() const;
202 virtual OMacAddress macAddress4() const; 199 virtual OMacAddress macAddress4() const;
203 bool usesPowerManagement() const; 200 bool usesPowerManagement() const;
204 int type() const; 201 int type() const;
205 int subType() const; 202 int subType() const;
206 int version() const; 203 int version() const;
207 bool usesWep() const; 204 bool usesWep() const;
208 205
209 private: 206 private:
210 const struct ieee_802_11_header* _wlanhdr; 207 const struct ieee_802_11_header* _wlanhdr;
211}; 208};
212 209
213 210
214/*====================================================================================== 211/*======================================================================================
215 * OWaveLanManagementPacket - type: management (T_MGMT) 212 * OWaveLanManagementPacket - type: management (T_MGMT)
216 *======================================================================================*/ 213 *======================================================================================*/
217 214
218class OWaveLanManagementPacket : public QObject 215class OWaveLanManagementPacket : public QObject
219{ 216{
220 Q_OBJECT 217 Q_OBJECT
221 218
222 public: 219 public:
223 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); 220 OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 );
224 virtual ~OWaveLanManagementPacket(); 221 virtual ~OWaveLanManagementPacket();
225 222
226 QString managementType() const; 223 QString managementType() const;
227 224
228 int beaconInterval() const; 225 int beaconInterval() const;
229 int capabilities() const; // generic 226 int capabilities() const; // generic
230 227
231 bool canESS() const; 228 bool canESS() const;
232 bool canIBSS() const; 229 bool canIBSS() const;
233 bool canCFP() const; 230 bool canCFP() const;
234 bool canCFP_REQ() const; 231 bool canCFP_REQ() const;
235 bool canPrivacy() const; 232 bool canPrivacy() const;
236 233
237 private: 234 private:
238 const struct ieee_802_11_mgmt_header* _header; 235 const struct ieee_802_11_mgmt_header* _header;
239 const struct ieee_802_11_mgmt_body* _body; 236 const struct ieee_802_11_mgmt_body* _body;
240}; 237};
241 238
242 239
243/*====================================================================================== 240/*======================================================================================
244 * OWaveLanManagementSSID 241 * OWaveLanManagementSSID
245 *======================================================================================*/ 242 *======================================================================================*/
246 243
247class OWaveLanManagementSSID : public QObject 244class OWaveLanManagementSSID : public QObject
248{ 245{
249 Q_OBJECT 246 Q_OBJECT
250 247
251 public: 248 public:
252 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); 249 OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 );
253 virtual ~OWaveLanManagementSSID(); 250 virtual ~OWaveLanManagementSSID();
254 251
255 QString ID() const; 252 QString ID() const;
256 253
257 private: 254 private:
258 const struct ssid_t* _data; 255 const struct ssid_t* _data;
259}; 256};
260 257
261/*====================================================================================== 258/*======================================================================================
262 * OWaveLanManagementRates 259 * OWaveLanManagementRates
263 *======================================================================================*/ 260 *======================================================================================*/
264 261
265class OWaveLanManagementRates : public QObject 262class OWaveLanManagementRates : public QObject
266{ 263{
267 Q_OBJECT 264 Q_OBJECT
268 265
269 public: 266 public:
270 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); 267 OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 );
271 virtual ~OWaveLanManagementRates(); 268 virtual ~OWaveLanManagementRates();
272 269
273 private: 270 private:
274 const struct rates_t* _data; 271 const struct rates_t* _data;
275}; 272};
276 273
277/*====================================================================================== 274/*======================================================================================
278 * OWaveLanManagementCF 275 * OWaveLanManagementCF
279 *======================================================================================*/ 276 *======================================================================================*/
280 277
281class OWaveLanManagementCF : public QObject 278class OWaveLanManagementCF : public QObject
282{ 279{
283 Q_OBJECT 280 Q_OBJECT
284 281
285 public: 282 public:
286 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); 283 OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 );
287 virtual ~OWaveLanManagementCF(); 284 virtual ~OWaveLanManagementCF();
288 285
289 private: 286 private:
290 const struct cf_t* _data; 287 const struct cf_t* _data;
291}; 288};
292 289
293/*====================================================================================== 290/*======================================================================================
294 * OWaveLanManagementFH 291 * OWaveLanManagementFH
295 *======================================================================================*/ 292 *======================================================================================*/
296 293
297class OWaveLanManagementFH : public QObject 294class OWaveLanManagementFH : public QObject
298{ 295{
299 Q_OBJECT 296 Q_OBJECT
300 297
301 public: 298 public:
302 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); 299 OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 );
303 virtual ~OWaveLanManagementFH(); 300 virtual ~OWaveLanManagementFH();
304 301
305 private: 302 private:
306 const struct fh_t* _data; 303 const struct fh_t* _data;
307}; 304};
308 305
309/*====================================================================================== 306/*======================================================================================
310 * OWaveLanManagementDS 307 * OWaveLanManagementDS
311 *======================================================================================*/ 308 *======================================================================================*/
312 309
313class OWaveLanManagementDS : public QObject 310class OWaveLanManagementDS : public QObject
314{ 311{
315 Q_OBJECT 312 Q_OBJECT
316 313
317 public: 314 public:
318 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); 315 OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 );
319 virtual ~OWaveLanManagementDS(); 316 virtual ~OWaveLanManagementDS();
320 317
321 int channel() const; 318 int channel() const;
322 319
323 private: 320 private:
324 const struct ds_t* _data; 321 const struct ds_t* _data;
325}; 322};
326 323
327/*====================================================================================== 324/*======================================================================================
328 * OWaveLanManagementTim 325 * OWaveLanManagementTim
329 *======================================================================================*/ 326 *======================================================================================*/
330 327
331class OWaveLanManagementTim : public QObject 328class OWaveLanManagementTim : public QObject
332{ 329{
333 Q_OBJECT 330 Q_OBJECT
334 331
335 public: 332 public:
336 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); 333 OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 );
337 virtual ~OWaveLanManagementTim(); 334 virtual ~OWaveLanManagementTim();
338 335
339 private: 336 private:
340 const struct tim_t* _data; 337 const struct tim_t* _data;
341}; 338};
342 339
343/*====================================================================================== 340/*======================================================================================
344 * OWaveLanManagementIBSS 341 * OWaveLanManagementIBSS
345 *======================================================================================*/ 342 *======================================================================================*/
346 343
347class OWaveLanManagementIBSS : public QObject 344class OWaveLanManagementIBSS : public QObject
348{ 345{
349 Q_OBJECT 346 Q_OBJECT
350 347
351 public: 348 public:
352 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); 349 OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 );
353 virtual ~OWaveLanManagementIBSS(); 350 virtual ~OWaveLanManagementIBSS();
354 351
355 private: 352 private:
356 const struct ibss_t* _data; 353 const struct ibss_t* _data;
357}; 354};
358 355
359/*====================================================================================== 356/*======================================================================================
360 * OWaveLanManagementChallenge 357 * OWaveLanManagementChallenge
361 *======================================================================================*/ 358 *======================================================================================*/
362 359
363class OWaveLanManagementChallenge : public QObject 360class OWaveLanManagementChallenge : public QObject
364{ 361{
365 Q_OBJECT 362 Q_OBJECT
366 363
367 public: 364 public:
368 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); 365 OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 );
369 virtual ~OWaveLanManagementChallenge(); 366 virtual ~OWaveLanManagementChallenge();
370 367
371 private: 368 private:
372 const struct challenge_t* _data; 369 const struct challenge_t* _data;
373}; 370};
374 371
375/*====================================================================================== 372/*======================================================================================
376 * OWaveLanDataPacket - type: data (T_DATA) 373 * OWaveLanDataPacket - type: data (T_DATA)
377 *======================================================================================*/ 374 *======================================================================================*/
378 375
379class OWaveLanDataPacket : public QObject 376class OWaveLanDataPacket : public QObject
380{ 377{
381 Q_OBJECT 378 Q_OBJECT
382 379
383 public: 380 public:
384 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); 381 OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 );
385 virtual ~OWaveLanDataPacket(); 382 virtual ~OWaveLanDataPacket();
386 383
387 private: 384 private:
388 const struct ieee_802_11_data_header* _header; 385 const struct ieee_802_11_data_header* _header;
389}; 386};
390 387
391/*====================================================================================== 388/*======================================================================================
392 * OWaveLanControlPacket - type: control (T_CTRL) 389 * OWaveLanControlPacket - type: control (T_CTRL)
393 *======================================================================================*/ 390 *======================================================================================*/
394 391
395class OWaveLanControlPacket : public QObject 392class OWaveLanControlPacket : public QObject
396{ 393{
397 Q_OBJECT 394 Q_OBJECT
398 395
399 public: 396 public:
400 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); 397 OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
401 virtual ~OWaveLanControlPacket(); 398 virtual ~OWaveLanControlPacket();
402 399
403 private: 400 private:
404 const struct ieee_802_11_control_header* _header; 401 const struct ieee_802_11_control_header* _header;
405}; 402};
406 403
407/*====================================================================================== 404/*======================================================================================
408 * OLLCPacket - IEEE 802.2 Link Level Control 405 * OLLCPacket - IEEE 802.2 Link Level Control
409 *======================================================================================*/ 406 *======================================================================================*/
410 407
411class OLLCPacket : public QObject 408class OLLCPacket : public QObject
412{ 409{
413 Q_OBJECT 410 Q_OBJECT
414 411
415 public: 412 public:
416 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); 413 OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 );
417 virtual ~OLLCPacket(); 414 virtual ~OLLCPacket();
418 415
419 private: 416 private:
420 const struct ieee_802_11_802_2_header* _header; 417 const struct ieee_802_11_802_2_header* _header;
421}; 418};
422 419
423/*====================================================================================== 420/*======================================================================================
424 * OIPPacket 421 * OIPPacket
425 *======================================================================================*/ 422 *======================================================================================*/
426 423
427class OIPPacket : public QObject 424class OIPPacket : public QObject
428{ 425{
429 Q_OBJECT 426 Q_OBJECT
430 427
431 public: 428 public:
432 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); 429 OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 );
433 virtual ~OIPPacket(); 430 virtual ~OIPPacket();
434 431
435 QHostAddress fromIPAddress() const; 432 QHostAddress fromIPAddress() const;
436 QHostAddress toIPAddress() const; 433 QHostAddress toIPAddress() const;
437 434
438 int tos() const; 435 int tos() const;
439 int len() const; 436 int len() const;
440 int id() const; 437 int id() const;
441 int offset() const; 438 int offset() const;
442 int ttl() const; 439 int ttl() const;
443 int protocol() const; 440 int protocol() const;
444 int checksum() const; 441 int checksum() const;
445 442
446 private: 443 private:
447 const struct iphdr* _iphdr; 444 const struct iphdr* _iphdr;
448}; 445};
449 446
450/*====================================================================================== 447/*======================================================================================
451 * OARPPacket 448 * OARPPacket
452 *======================================================================================*/ 449 *======================================================================================*/
453 450
454class OARPPacket : public QObject 451class OARPPacket : public QObject
455{ 452{
456 Q_OBJECT 453 Q_OBJECT
457 454
458 public: 455 public:
459 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); 456 OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 );
460 virtual ~OARPPacket(); 457 virtual ~OARPPacket();
461 458
462 QHostAddress senderIPV4Address() const; 459 QHostAddress senderIPV4Address() const;
463 OMacAddress senderMacAddress() const; 460 OMacAddress senderMacAddress() const;
464 QHostAddress targetIPV4Address() const; 461 QHostAddress targetIPV4Address() const;
465 OMacAddress targetMacAddress() const; 462 OMacAddress targetMacAddress() const;
466 463
467 //int type() const; 464 //int type() const;
468 QString type() const; 465 QString type() const;
469 466
470 private: 467 private:
471 const struct myarphdr* _arphdr; 468 const struct myarphdr* _arphdr;
472}; 469};
473 470
474/*====================================================================================== 471/*======================================================================================
475 * OUDPPacket 472 * OUDPPacket
476 *======================================================================================*/ 473 *======================================================================================*/
477 474
478class OUDPPacket : public QObject 475class OUDPPacket : public QObject
479{ 476{
480 Q_OBJECT 477 Q_OBJECT
481 478
482 public: 479 public:
483 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); 480 OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 );
484 virtual ~OUDPPacket(); 481 virtual ~OUDPPacket();
485 482
486 int fromPort() const; 483 int fromPort() const;
487 int toPort() const; 484 int toPort() const;
488 int length() const; 485 int length() const;
489 int checksum() const; 486 int checksum() const;
490 487
491 private: 488 private:
492 const struct udphdr* _udphdr; 489 const struct udphdr* _udphdr;
493}; 490};
494 491
495/*====================================================================================== 492/*======================================================================================
496 * ODHCPPacket 493 * ODHCPPacket
497 *======================================================================================*/ 494 *======================================================================================*/
498 495
499class ODHCPPacket : public QObject 496class ODHCPPacket : public QObject
500{ 497{
501 Q_OBJECT 498 Q_OBJECT
502 499
503 public: 500 public:
504 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); 501 ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 );
505 virtual ~ODHCPPacket(); 502 virtual ~ODHCPPacket();
506 503
507 QHostAddress clientAddress() const; 504 QHostAddress clientAddress() const;
508 QHostAddress yourAddress() const; 505 QHostAddress yourAddress() const;
509 QHostAddress serverAddress() const; 506 QHostAddress serverAddress() const;
510 QHostAddress relayAddress() const; 507 QHostAddress relayAddress() const;
511 508
512 OMacAddress clientMacAddress() const; 509 OMacAddress clientMacAddress() const;
513 510
514 bool isRequest() const; 511 bool isRequest() const;
515 bool isReply() const; 512 bool isReply() const;
516 QString type() const; 513 QString type() const;
517 514
518 private: 515 private:
519 const struct dhcp_packet* _dhcphdr; 516 const struct dhcp_packet* _dhcphdr;
520 unsigned char _type; 517 unsigned char _type;
521}; 518};
522 519
523/*====================================================================================== 520/*======================================================================================
524 * OTCPPacket 521 * OTCPPacket
525 *======================================================================================*/ 522 *======================================================================================*/
526 523
527class OTCPPacket : public QObject 524class OTCPPacket : public QObject
528{ 525{
529 Q_OBJECT 526 Q_OBJECT
530 527
531 public: 528 public:
532 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); 529 OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 );
533 virtual ~OTCPPacket(); 530 virtual ~OTCPPacket();
534 531
535 int fromPort() const; 532 int fromPort() const;
536 int toPort() const; 533 int toPort() const;
537 int seq() const; 534 int seq() const;
538 int ack() const; 535 int ack() const;
539 int window() const; 536 int window() const;
540 int checksum() const; 537 int checksum() const;
541 538
542 private: 539 private:
543 const struct tcphdr* _tcphdr; 540 const struct tcphdr* _tcphdr;
544}; 541};
545 542
546 543
547/*====================================================================================== 544/*======================================================================================
548 * OPacketCapturer 545 * OPacketCapturer
549 *======================================================================================*/ 546 *======================================================================================*/
550 547
551/** 548/**
552 * @brief A class based wrapper for network packet capturing. 549 * @brief A class based wrapper for network packet capturing.
553 * 550 *
554 * This class is the base of a high-level interface to the well known packet capturing 551 * This class is the base of a high-level interface to the well known packet capturing
555 * library libpcap. 552 * library libpcap.
556 * @see http://tcpdump.org 553 * @see http://tcpdump.org
557 */ 554 */
558class OPacketCapturer : public QObject 555class OPacketCapturer : public QObject
559{ 556{
560 Q_OBJECT 557 Q_OBJECT
561 558
562 public: 559 public:
563 /** 560 /**
564 * Constructor. 561 * Constructor.
565 */ 562 */
566 OPacketCapturer( QObject* parent = 0, const char* name = 0 ); 563 OPacketCapturer( QObject* parent = 0, const char* name = 0 );
567 /** 564 /**
568 * Destructor. 565 * Destructor.
569 */ 566 */
570 ~OPacketCapturer(); 567 ~OPacketCapturer();
571 /** 568 /**
572 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when 569 * Set the packet capturer to use blocking or non-blocking IO. This can be useful when
573 * not using the socket notifier, e.g. without an application object. 570 * not using the socket notifier, e.g. without an application object.
574 */ 571 */
575 void setBlocking( bool ); 572 void setBlocking( bool );
576 /** 573 /**
577 * @returns true if the packet capturer uses blocking IO calls. 574 * @returns true if the packet capturer uses blocking IO calls.
578 */ 575 */
579 bool blocking() const; 576 bool blocking() const;
580 /** 577 /**
581 * Close the packet capturer. This is automatically done in the destructor. 578 * Close the packet capturer. This is automatically done in the destructor.
582 */ 579 */
583 void close(); 580 void close();
584 /** 581 /**
585 * Close the output capture file. 582 * Close the output capture file.
586 */ 583 */
587 void closeDumpFile(); 584 void closeDumpFile();
588 /** 585 /**
589 * @returns the data link type. 586 * @returns the data link type.
590 * @see <pcap.h> for possible values. 587 * @see <pcap.h> for possible values.
591 */ 588 */
592 int dataLink() const; 589 int dataLink() const;
593 /** 590 /**
594 * Dump a packet to the output capture file. 591 * Dump a packet to the output capture file.
595 */ 592 */
596 void dump( OPacket* ); 593 void dump( OPacket* );
597 /** 594 /**
598 * @returns the file descriptor of the packet capturer. This is only useful, if 595 * @returns the file descriptor of the packet capturer. This is only useful, if
599 * not using the socket notifier, e.g. without an application object. 596 * not using the socket notifier, e.g. without an application object.
600 */ 597 */
601 int fileno() const; 598 int fileno() const;
602 /** 599 /**
603 * @returns the next @ref OPacket from the packet capturer. 600 * @returns the next @ref OPacket from the packet capturer.
604 * @note If blocking mode is true then this call might block. 601 * @note If blocking mode is true then this call might block.
605 */ 602 */
606 OPacket* next(); 603 OPacket* next();
607 /** 604 /**
608 * @returns the next @ref OPacket from the packet capturer, if 605 * @returns the next @ref OPacket from the packet capturer, if
609 * one arrives within @a time milliseconds. 606 * one arrives within @a time milliseconds.
610 */ 607 */
611 OPacket* next( int time ); 608 OPacket* next( int time );
612 /** 609 /**
613 * Open the packet capturer to capture packets in live-mode from @a interface. 610 * Open the packet capturer to capture packets in live-mode from @a interface.
614 */ 611 */
615 bool open( const QString& interface ); 612 bool open( const QString& interface );
616 /** 613 /**
617 * Open the packet capturer to capture packets in offline-mode from @a file. 614 * Open the packet capturer to capture packets in offline-mode from @a file.
618 */ 615 */
619 bool open( const QFile& file ); 616 bool open( const QFile& file );
620 /** 617 /**
621 * Open a prerecorded tcpdump compatible capture file for use with @ref dump() 618 * Open a prerecorded tcpdump compatible capture file for use with @ref dump()
622 */ 619 */
623 bool openDumpFile( const QString& filename ); 620 bool openDumpFile( const QString& filename );
624 /** 621 /**
625 * @returns true if the packet capturer is open 622 * @returns true if the packet capturer is open
626 */ 623 */
627 bool isOpen() const; 624 bool isOpen() const;
628 /** 625 /**
629 * @returns the snapshot length of this packet capturer 626 * @returns the snapshot length of this packet capturer
630 */ 627 */
631 int snapShot() const; 628 int snapShot() const;
632 /** 629 /**
633 * @returns true if the input capture file has a different byte-order 630 * @returns true if the input capture file has a different byte-order
634 * than the byte-order of the running system. 631 * than the byte-order of the running system.
635 */ 632 */
636 bool swapped() const; 633 bool swapped() const;
637 /** 634 /**
638 * @returns the libpcap version string used to write the input capture file. 635 * @returns the libpcap version string used to write the input capture file.
639 */ 636 */
640 QString version() const; 637 QString version() const;
641 /** 638 /**
642 * @returns the packet statistic database. 639 * @returns the packet statistic database.
643 * @see QMap 640 * @see QMap
644 */ 641 */
645 const QMap<QString,int>& statistics() const; 642 const QMap<QString,int>& statistics() const;
646 643
647 signals: 644 signals:
648 /** 645 /**
649 * This signal is emitted, when a packet has been received. 646 * This signal is emitted, when a packet has been received.
650 */ 647 */
651 void receivedPacket( OPacket* ); 648 void receivedPacket( OPacket* );
652 649
653 protected slots: 650 protected slots:
654 void readyToReceive(); 651 void readyToReceive();
655 652
656 protected: 653 protected:
657 QString _name; // devicename 654 QString _name; // devicename
658 bool _open; // check this before doing pcap calls 655 bool _open; // check this before doing pcap calls
659 pcap_t* _pch; // pcap library handle 656 pcap_t* _pch; // pcap library handle
660 pcap_dumper_t* _pcd; // pcap dumper handle 657 pcap_dumper_t* _pcd; // pcap dumper handle
661 QSocketNotifier* _sn; // socket notifier for main loop 658 QSocketNotifier* _sn; // socket notifier for main loop
662 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap 659 mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap
663 QMap<QString, int> _stats; // statistics; 660 QMap<QString, int> _stats; // statistics;
664}; 661};
665 662
666#endif // OPCAP_H 663#endif // OPCAP_H
667 664
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro
index 386c2db..2027481 100644
--- a/libopie2/opienet/opienet.pro
+++ b/libopie2/opienet/opienet.pro
@@ -1,34 +1,34 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = 802_11_user.h \ 4HEADERS = 802_11_user.h \
5 dhcp.h \ 5 dhcp.h \
6 udp_ports.h \ 6 udp_ports.h \
7 wireless.h \ 7 wireless.h \
8 odebugmapper.h \ 8 odebugmapper.h \
9 omanufacturerdb.h \ 9 omanufacturerdb.h \
10 onetutils.h \ 10 onetutils.h \
11 onetwork.h \ 11 onetwork.h \
12 opcap.h \ 12 opcap.h \
13 ostation.h 13 ostation.h
14SOURCES = odebugmapper.cpp \ 14SOURCES = odebugmapper.cpp \
15 omanufacturerdb.cpp \ 15 omanufacturerdb.cpp \
16 onetutils.cpp \ 16 onetutils.cpp \
17 onetwork.cpp \ 17 onetwork.cpp \
18 opcap.cpp \ 18 opcap.cpp \
19 ostation.cpp 19 ostation.cpp
20INTERFACES = 20INTERFACES =
21TARGET = opienet2 21TARGET = opienet2
22VERSION = 1.8.1 22VERSION = 1.8.2
23INCLUDEPATH += $(OPIEDIR)/include 23INCLUDEPATH += $(OPIEDIR)/include
24DEPENDPATH += $(OPIEDIR)/include 24DEPENDPATH += $(OPIEDIR)/include
25LIBS += -lpcap 25LIBS += -lpcap
26 26
27 27
28!contains( platform, x11 ) { 28!contains( platform, x11 ) {
29 include ( $(OPIEDIR)/include.pro ) 29 include ( $(OPIEDIR)/include.pro )
30} 30}
31 31
32contains( platform, x11 ) { 32contains( platform, x11 ) {
33 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 33 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
34} 34}
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index ba1e4f6..c363f0c 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -1,64 +1,63 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29 28
30*/ 29*/
31 30
32#include <opie2/ostation.h> 31#include <opie2/ostation.h>
33 32
34/*====================================================================================== 33/*======================================================================================
35 * OStation 34 * OStation
36 *======================================================================================*/ 35 *======================================================================================*/
37 36
38OStation::OStation() 37OStation::OStation()
39{ 38{
40 qDebug( "OStation::OStation()" ); 39 qDebug( "OStation::OStation()" );
41 40
42 type = "<unknown>"; 41 type = "<unknown>";
43 macAddress = OMacAddress::unknown; 42 macAddress = OMacAddress::unknown;
44 ssid = "<unknown>"; 43 ssid = "<unknown>";
45 channel = 0; 44 channel = 0;
46 apAddress = OMacAddress::unknown; 45 apAddress = OMacAddress::unknown;
47 46
48} 47}
49 48
50 49
51OStation::~OStation() 50OStation::~OStation()
52{ 51{
53 qDebug( "OStation::~OStation()" ); 52 qDebug( "OStation::~OStation()" );
54} 53}
55 54
56 55
57void OStation::dump() 56void OStation::dump()
58{ 57{
59 qDebug( "------- OStation::dump() ------------" ); 58 qDebug( "------- OStation::dump() ------------" );
60 qDebug( "type: %s", (const char*) type ); 59 qDebug( "type: %s", (const char*) type );
61 qDebug( "mac: %s", (const char*) macAddress.toString() ); 60 qDebug( "mac: %s", (const char*) macAddress.toString() );
62 qDebug( "ap: %s", (const char*) apAddress.toString() ); 61 qDebug( "ap: %s", (const char*) apAddress.toString() );
63 qDebug( "ip: %s", (const char*) ipAddress.toString() ); 62 qDebug( "ip: %s", (const char*) ipAddress.toString() );
64} 63}
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h
index a6956c9..1e7366d 100644
--- a/libopie2/opienet/ostation.h
+++ b/libopie2/opienet/ostation.h
@@ -1,74 +1,73 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29 28
30*/ 29*/
31 30
32#ifndef OSTATION_H 31#ifndef OSTATION_H
33#define OSTATION_H 32#define OSTATION_H
34 33
35#include <opie2/onetutils.h> 34#include <opie2/onetutils.h>
36 35
37#include <qlist.h> 36#include <qlist.h>
38#include <qstring.h> 37#include <qstring.h>
39#include <qhostaddress.h> 38#include <qhostaddress.h>
40#include <qobject.h> 39#include <qobject.h>
41 40
42#include <sys/types.h> 41#include <sys/types.h>
43 42
44class OStation; 43class OStation;
45 44
46typedef QList<OStation> OStationList; 45typedef QList<OStation> OStationList;
47 46
48/*====================================================================================== 47/*======================================================================================
49 * OStation 48 * OStation
50 *======================================================================================*/ 49 *======================================================================================*/
51 50
52class OStation 51class OStation
53{ 52{
54 public: 53 public:
55 OStation(); 54 OStation();
56 ~OStation(); 55 ~OStation();
57 56
58 void dump(); 57 void dump();
59 58
60 /* Ethernet */ 59 /* Ethernet */
61 QString type; 60 QString type;
62 OMacAddress macAddress; 61 OMacAddress macAddress;
63 QHostAddress ipAddress; 62 QHostAddress ipAddress;
64 63
65 /* WaveLan */ 64 /* WaveLan */
66 QString ssid; 65 QString ssid;
67 OMacAddress apAddress; 66 OMacAddress apAddress;
68 int channel; 67 int channel;
69 bool encrypted; 68 bool encrypted;
70}; 69};
71 70
72 71
73#endif // OSTATION_H 72#endif // OSTATION_H
74 73
diff --git a/libopie2/opienet/udp_ports.h b/libopie2/opienet/udp_ports.h
index 5e92497..3fb1c85 100644
--- a/libopie2/opienet/udp_ports.h
+++ b/libopie2/opienet/udp_ports.h
@@ -1,89 +1,89 @@
1/* 1/*
2 * This file has been generated by doing 2 * This file has been generated by doing
3 * find . -name "*"|xargs grep -h '#define UDP_PORT' > udp_ports.h 3 * find . -name "*"|xargs grep -h '#define UDP_PORT' > udp_ports.h
4 * in the root directory of Ethereal 0.9.15. Cudos to the Ethereal Team. 4 * in the root directory of Ethereal 0.9.15. Cudos to the Ethereal Team.
5 * -- Michael 'Mickey' Lauer <mickeyl@handhelds.org> 5 * -- Michael 'Mickey' Lauer <mickey@Vanille.de>
6 */ 6 */
7 7
8 #define UDP_PORT_AODV654 8 #define UDP_PORT_AODV654
9#define UDP_PORT_LENGTH 2 9#define UDP_PORT_LENGTH 2
10#define UDP_PORT_OFFSET PARAMETER_VALUE_OFFSET 10#define UDP_PORT_OFFSET PARAMETER_VALUE_OFFSET
11#define UDP_PORT_RAS1 1718 11#define UDP_PORT_RAS1 1718
12#define UDP_PORT_RAS2 1719 12#define UDP_PORT_RAS2 1719
13 #define UDP_PORT_CPHA8116 13 #define UDP_PORT_CPHA8116
14 #define UDP_PORT_DDTP1052 14 #define UDP_PORT_DDTP1052
15 #define UDP_PORT_CUPS631 15 #define UDP_PORT_CUPS631
16 #define UDP_PORT_DLSW 2067 16 #define UDP_PORT_DLSW 2067
17 #define UDP_PORT_ISAKMP500 17 #define UDP_PORT_ISAKMP500
18#define UDP_PORT_L2TP 1701 18#define UDP_PORT_L2TP 1701
19#define UDP_PORT_IAPP 2313 19#define UDP_PORT_IAPP 2313
20#define UDP_PORT_HSRP 1985 20#define UDP_PORT_HSRP 1985
21 #define UDP_PORT_SSDP 1900 21 #define UDP_PORT_SSDP 1900
22 #define UDP_PORT_TACACS49 22 #define UDP_PORT_TACACS49
23 #define UDP_PORT_CLDAP 389 23 #define UDP_PORT_CLDAP 389
24 #define UDP_PORT_VINES573 24 #define UDP_PORT_VINES573
25 #define UDP_PORT_NBNS137 25 #define UDP_PORT_NBNS137
26 #define UDP_PORT_NBDGM138 26 #define UDP_PORT_NBDGM138
27#define UDP_PORT_XYPLEX 173 27#define UDP_PORT_XYPLEX 173
28#define UDP_PORT_PIM_RP_DISC 496 28#define UDP_PORT_PIM_RP_DISC 496
29#define UDP_PORT_SLIMP3_V1 1069 29#define UDP_PORT_SLIMP3_V1 1069
30#define UDP_PORT_SLIMP3_V2 3483 30#define UDP_PORT_SLIMP3_V2 3483
31 #define UDP_PORT_RMCP 623 31 #define UDP_PORT_RMCP 623
32 #define UDP_PORT_RMCP_SECURE664 32 #define UDP_PORT_RMCP_SECURE664
33#define UDP_PORT_SYSLOG 514 33#define UDP_PORT_SYSLOG 514
34 #define UDP_PORT_SNMP 161 34 #define UDP_PORT_SNMP 161
35 #define UDP_PORT_SNMP_TRAP162 35 #define UDP_PORT_SNMP_TRAP162
36#define UDP_PORT_TFTP 69 36#define UDP_PORT_TFTP 69
37#define UDP_PORT_TIME 37 37#define UDP_PORT_TIME 37
38 #define UDP_PORT_STUN 3478 38 #define UDP_PORT_STUN 3478
39 #define UDP_PORT_SRVLOC427 39 #define UDP_PORT_SRVLOC427
40 #define UDP_PORT_TZSP0x9090 40 #define UDP_PORT_TZSP0x9090
41 #define UDP_PORT_WCCP2048 41 #define UDP_PORT_WCCP2048
42#define UDP_PORT_MSPROXY 1745 42#define UDP_PORT_MSPROXY 1745
43#define UDP_PORT_BOOTPS 67 43#define UDP_PORT_BOOTPS 67
44#define UDP_PORT_BOOTPC 68 44#define UDP_PORT_BOOTPC 68
45#define UDP_PORT_XDMCP 177 45#define UDP_PORT_XDMCP 177
46 #define UDP_PORT_DHCPV6_DOWNSTREAM546 46 #define UDP_PORT_DHCPV6_DOWNSTREAM546
47 #define UDP_PORT_DHCPV6_UPSTREAM547 47 #define UDP_PORT_DHCPV6_UPSTREAM547
48#define UDP_PORT_DNS 53 48#define UDP_PORT_DNS 53
49#define UDP_PORT_MDNS 5353 49#define UDP_PORT_MDNS 5353
50#define UDP_PORT_ICP 3130 50#define UDP_PORT_ICP 3130
51 #define UDP_PORT_ICQ4000 51 #define UDP_PORT_ICQ4000
52 #define UDP_PORT_IPX 213 /* RFC 1234 */ 52 #define UDP_PORT_IPX 213 /* RFC 1234 */
53#define UDP_PORT_LDP 646 53#define UDP_PORT_LDP 646
54#define UDP_PORT_LLC1 12000 54#define UDP_PORT_LLC1 12000
55#define UDP_PORT_LLC2 12001 55#define UDP_PORT_LLC2 12001
56#define UDP_PORT_LLC3 12002 56#define UDP_PORT_LLC3 12002
57#define UDP_PORT_LLC4 12003 57#define UDP_PORT_LLC4 12003
58#define UDP_PORT_LLC5 12004 58#define UDP_PORT_LLC5 12004
59#define UDP_PORT_MIP 434 59#define UDP_PORT_MIP 434
60 #define UDP_PORT_NCP 524 60 #define UDP_PORT_NCP 524
61 #define UDP_PORT_NTP123 61 #define UDP_PORT_NTP123
62#define UDP_PORT_RIP 520 62#define UDP_PORT_RIP 520
63 #define UDP_PORT_SAP9875 63 #define UDP_PORT_SAP9875
64#define UDP_PORT_SIP 5060 64#define UDP_PORT_SIP 5060
65 #define UDP_PORT_TIMED525 65 #define UDP_PORT_TIMED525
66#define UDP_PORT_RIPNG 521 66#define UDP_PORT_RIPNG 521
67 #define UDP_PORT_WSP 9200 /* wap-wsp */ 67 #define UDP_PORT_WSP 9200 /* wap-wsp */
68 #define UDP_PORT_WTP_WSP 9201 /* wap-wsp-wtp */ 68 #define UDP_PORT_WTP_WSP 9201 /* wap-wsp-wtp */
69 #define UDP_PORT_WTLS_WSP 9202 /* wap-wsp-s */ 69 #define UDP_PORT_WTLS_WSP 9202 /* wap-wsp-s */
70 #define UDP_PORT_WTLS_WTP_WSP 9203 /* wap-wsp-wtp-s*/ 70 #define UDP_PORT_WTLS_WTP_WSP 9203 /* wap-wsp-wtp-s*/
71 #define UDP_PORT_WSP_PUSH 2948 /* wap-wsp */ 71 #define UDP_PORT_WSP_PUSH 2948 /* wap-wsp */
72 #define UDP_PORT_WTLS_WSP_PUSH 2949 /* wap-wsp-s */ 72 #define UDP_PORT_WTLS_WSP_PUSH 2949 /* wap-wsp-s */
73#define UDP_PORT_WHO 513 73#define UDP_PORT_WHO 513
74 #define UDP_PORT_KERBEROS 88 74 #define UDP_PORT_KERBEROS 88
75#define UDP_PORT_SFLOW 6343 75#define UDP_PORT_SFLOW 6343
76#define UDP_PORT_LAPLINK 1547 76#define UDP_PORT_LAPLINK 1547
77 #define UDP_PORT_NETFLOW2055 77 #define UDP_PORT_NETFLOW2055
78 #define UDP_PORT_RX_LOW 7000 78 #define UDP_PORT_RX_LOW 7000
79 #define UDP_PORT_RX_HIGH7009 79 #define UDP_PORT_RX_HIGH7009
80 #define UDP_PORT_RX_AFS_BACKUPS7021 80 #define UDP_PORT_RX_AFS_BACKUPS7021
81#define UDP_PORT_MGCP_GATEWAY 2427 81#define UDP_PORT_MGCP_GATEWAY 2427
82#define UDP_PORT_MGCP_CALLAGENT 2727 82#define UDP_PORT_MGCP_CALLAGENT 2727
83#define UDP_PORT_PCLI 9000 83#define UDP_PORT_PCLI 9000
84#define UDP_PORT_ARTNET 0x1936 84#define UDP_PORT_ARTNET 0x1936
85#define UDP_PORT_TERREDO 3544 85#define UDP_PORT_TERREDO 3544
86 #define UDP_PORT_RADIUS 1645 86 #define UDP_PORT_RADIUS 1645
87 #define UDP_PORT_RADIUS_NEW1812 87 #define UDP_PORT_RADIUS_NEW1812
88 #define UDP_PORT_RADACCT1646 88 #define UDP_PORT_RADACCT1646
89 #define UDP_PORT_RADACCT_NEW1813 89 #define UDP_PORT_RADACCT_NEW1813
diff --git a/libopie2/opiepim/libopiepim2.control b/libopie2/opiepim/libopiepim2.control
index 5cfa453..ac8e13c 100644
--- a/libopie2/opiepim/libopiepim2.control
+++ b/libopie2/opiepim/libopiepim2.control
@@ -1,11 +1,11 @@
1Package: libopiepim2 1Package: libopiepim2
2Files: $OPIEDIR/lib/libopiepim2.so.* 2Files: $OPIEDIR/lib/libopiepim2.so.*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.1) 8Depends: libqpe1, libopiecore2 (1.8.2)
9Provides: libopiepim2 9Provides: libopiepim2
10Description: Opie library 2.0 PIM 10Description: Opie library 2.0 PIM
11 11
diff --git a/libopie2/opiepim/opiepim.pro b/libopie2/opiepim/opiepim.pro
index cc6ee90..3972c3f 100644
--- a/libopie2/opiepim/opiepim.pro
+++ b/libopie2/opiepim/opiepim.pro
@@ -1,24 +1,24 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = 4HEADERS =
5 5
6SOURCES = 6SOURCES =
7INTERFACES = 7INTERFACES =
8TARGET = opiepim2 8TARGET = opiepim2
9VERSION = 1.8.1 9VERSION = 1.8.2
10INCLUDEPATH += $(OPIEDIR)/include 10INCLUDEPATH += $(OPIEDIR)/include
11DEPENDPATH += $(OPIEDIR)/include 11DEPENDPATH += $(OPIEDIR)/include
12 12
13MOC_DIR = moc 13MOC_DIR = moc
14OBJECTS_DIR = obj 14OBJECTS_DIR = obj
15 15
16 16
17!contains( platform, x11 ) { 17!contains( platform, x11 ) {
18 include ( $(OPIEDIR)/include.pro ) 18 include ( $(OPIEDIR)/include.pro )
19} 19}
20 20
21contains( platform, x11 ) { 21contains( platform, x11 ) {
22 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 22 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
23} 23}
24 24
diff --git a/libopie2/opieui/libopieui2.control b/libopie2/opieui/libopieui2.control
index 6900fd6..71e6358 100644
--- a/libopie2/opieui/libopieui2.control
+++ b/libopie2/opieui/libopieui2.control
@@ -1,11 +1,11 @@
1Package: libopieui2 1Package: libopieui2
2Files: $OPIEDIR/lib/libopieui2.so.* 2Files: $OPIEDIR/lib/libopieui2.so.*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.1-$SUB_VERSION.2 7Version: 1.8.2-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.1) 8Depends: libqpe1, libopiecore2 (1.8.2)
9Provides: libopieui2 9Provides: libopieui2
10Description: Opie library 2.0 UI 10Description: Opie library 2.0 UI
11 11
diff --git a/libopie2/opieui/opieui.pro b/libopie2/opieui/opieui.pro
index 68a5c5f..4c15181 100644
--- a/libopie2/opieui/opieui.pro
+++ b/libopie2/opieui/opieui.pro
@@ -1,67 +1,67 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = ocompletionbox.h \ 4HEADERS = ocompletionbox.h \
5 ocombobox.h \ 5 ocombobox.h \
6 oeditlistbox.h \ 6 oeditlistbox.h \
7 olineedit.h \ 7 olineedit.h \
8 olistview.h \ 8 olistview.h \
9 oimageeffect.h \ 9 oimageeffect.h \
10 opixmapeffect.h \ 10 opixmapeffect.h \
11 opopupmenu.h \ 11 opopupmenu.h \
12 opixmapprovider.h \ 12 opixmapprovider.h \
13 oselector.h \ 13 oselector.h \
14 oversatileview.h \ 14 oversatileview.h \
15 oversatileviewitem.h \ 15 oversatileviewitem.h \
16 #ojanuswidget.h \ 16 #ojanuswidget.h \
17 odialog.h \ 17 odialog.h \
18 omenubar.h \ 18 omenubar.h \
19 opiemenubar.h \ 19 opiemenubar.h \
20 omessagebox.h \ 20 omessagebox.h \
21 oresource.h \ 21 oresource.h \
22 otoolbar.h \ 22 otoolbar.h \
23 oseparator.h 23 oseparator.h
24# otaskbarapplet.h 24# otaskbarapplet.h
25 25
26SOURCES = ocompletionbox.cpp \ 26SOURCES = ocompletionbox.cpp \
27 ocombobox.cpp \ 27 ocombobox.cpp \
28 oeditlistbox.cpp \ 28 oeditlistbox.cpp \
29 olineedit.cpp \ 29 olineedit.cpp \
30 olistview.cpp \ 30 olistview.cpp \
31 oimageeffect.cpp \ 31 oimageeffect.cpp \
32 opixmapeffect.cpp \ 32 opixmapeffect.cpp \
33 opopupmenu.cpp \ 33 opopupmenu.cpp \
34 opixmapprovider.cpp \ 34 opixmapprovider.cpp \
35 oselector.cpp \ 35 oselector.cpp \
36 oversatileview.cpp \ 36 oversatileview.cpp \
37 oversatileviewitem.cpp \ 37 oversatileviewitem.cpp \
38 #ojanuswidget.cpp \ 38 #ojanuswidget.cpp \
39 odialog.cpp \ 39 odialog.cpp \
40 omenubar.cpp \ 40 omenubar.cpp \
41 opiemenubar.cpp \ 41 opiemenubar.cpp \
42 oresource.cpp \ 42 oresource.cpp \
43 otoolbar.cpp \ 43 otoolbar.cpp \
44 oseparator.cpp #\ 44 oseparator.cpp #\
45# otaskbarapplet.cpp 45# otaskbarapplet.cpp
46 46
47INTERFACES = 47INTERFACES =
48TARGET = opieui2 48TARGET = opieui2
49VERSION = 1.8.1 49VERSION = 1.8.2
50INCLUDEPATH += $(OPIEDIR)/include 50INCLUDEPATH += $(OPIEDIR)/include
51DEPENDPATH += $(OPIEDIR)/include 51DEPENDPATH += $(OPIEDIR)/include
52LIBS += -lopiecore2 52LIBS += -lopiecore2
53MOC_DIR = moc 53MOC_DIR = moc
54OBJECTS_DIR = obj 54OBJECTS_DIR = obj
55 55
56 56
57!contains( platform, x11 ) { 57!contains( platform, x11 ) {
58 include ( $(OPIEDIR)/include.pro ) 58 include ( $(OPIEDIR)/include.pro )
59 HEADERS += otaskbarapplet.h 59 HEADERS += otaskbarapplet.h
60 SOURCES += otaskbarapplet.cpp 60 SOURCES += otaskbarapplet.cpp
61} 61}
62 62
63contains( platform, x11 ) { 63contains( platform, x11 ) {
64 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 64 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
65 message( Warning: NO otaskbarapplet ATM ) 65 message( Warning: NO otaskbarapplet ATM )
66} 66}
67 67
diff --git a/libopie2/tools/regen.py b/libopie2/tools/regen.py
index 9ad5352..3779896 100755
--- a/libopie2/tools/regen.py
+++ b/libopie2/tools/regen.py
@@ -1,94 +1,96 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2 2
3# 3#
4# regenerate ioctl_table.h 4# regenerate ioctl_table.h
5# 5#
6 6
7import sys 7import sys
8import os 8import os
9result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines() 9result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines()
10 10
11try: 11try:
12 tablehfile = file( sys.argv[1]+".h", "w" ) 12 tablehfile = file( sys.argv[1]+".h", "w" )
13except: 13except:
14 tablehfile = sys.stdout 14 tablehfile = sys.stdout
15 15
16try: 16try:
17 tablecfile = file( sys.argv[1]+".cpp", "w" ) 17 tablecfile = file( sys.argv[1]+".cpp", "w" )
18except: 18except:
19 tablecfile = sys.stdout 19 tablecfile = sys.stdout
20 20
21print >>tablehfile,""" 21print >>tablehfile,"""
22/* 22/*
23 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 23 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
24 */ 24 */
25 25
26#ifndef DEBUGMAPPER_H 26#ifndef DEBUGMAPPER_H
27#define DEBUGMAPPER_H 27#define DEBUGMAPPER_H
28 28
29#include <qstring.h> 29#include <qstring.h>
30#include <qintdict.h> 30#include <qintdict.h>
31 31
32typedef QIntDict<QString> IntStringMap; 32typedef QIntDict<QString> IntStringMap;
33 33
34class DebugMapper 34class DebugMapper
35{ 35{
36 public: 36 public:
37 DebugMapper(); 37 DebugMapper();
38 ~DebugMapper(); 38 ~DebugMapper();
39 39
40 const QString& map( int value ) const; 40 const QString& map( int value ) const;
41 private: 41 private:
42 IntStringMap _map; 42 IntStringMap _map;
43}; 43};
44 44
45#endif 45#endif
46""" 46"""
47 47
48print >>tablecfile,""" 48print >>tablecfile,"""
49/* 49/*
50 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 50 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
51 */ 51 */
52 52
53#include <opie2/odebug.h>
54
53#include "%s" 55#include "%s"
54 56
55DebugMapper::DebugMapper() 57DebugMapper::DebugMapper()
56{ 58{
57 qDebug( "DebugMapper::DebugMapper()" ); 59 odebug << "DebugMapper::DebugMapper()" << oendl;
58 60
59""" % (tablehfile.name) 61""" % (tablehfile.name)
60 62
61for line in result: 63for line in result:
62 l = line.split() 64 l = line.split()
63 if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ): 65 if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ):
64 print >>sys.stderr, "can't parse line: %s" % l 66 print >>sys.stderr, "can't parse line: %s" % l
65 continue 67 continue
66 print >>tablecfile, " _map.insert( %s, new QString(\"%s\") );" % ( l[2], l[1] ) 68 print >>tablecfile, " _map.insert( %s, new QString(\"%s\") );" % ( l[2], l[1] )
67 69
68 70
69print >>tablecfile,""" 71print >>tablecfile,"""
70}; 72};
71 73
72 74
73DebugMapper::~DebugMapper() 75DebugMapper::~DebugMapper()
74{ 76{
75 qDebug( "DebugMapper::~DebugMapper()" ); 77 odebug << "DebugMapper::~DebugMapper()" << oendl;
76} 78}
77 79
78 80
79const QString& DebugMapper::map( int value ) const 81const QString& DebugMapper::map( int value ) const
80{ 82{
81 QString* result = _map[ value ]; 83 QString* result = _map[ value ];
82 84
83 if ( !result ) 85 if ( !result )
84 { 86 {
85 qDebug( "DebugMapper::map() - value not found." ); 87 owarn << "DebugMapper::map() - value " << value << " is not found." << oendl;
86 return QString::null; 88 return QString::null;
87 } 89 }
88 else 90 else
89 { 91 {
90 return *result; 92 return *result;
91 } 93 }
92} 94}
93 95
94""" 96"""