summaryrefslogtreecommitdiff
path: root/libopie2/examples
authormickeyl <mickeyl>2003-12-01 22:44:38 (UTC)
committer mickeyl <mickeyl>2003-12-01 22:44:38 (UTC)
commit7a7683d435cfbb4fa2d6ed99fd4a94d388402aec (patch) (unidiff)
tree1a34de131d935f34dd2622e3606ba664a7783e24 /libopie2/examples
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 (limited to 'libopie2/examples') (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
4 files changed, 28 insertions, 10 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
@@ -83,30 +83,32 @@ public:
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;
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
@@ -22,52 +22,52 @@ class Station
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 );
@@ -96,56 +96,70 @@ public:
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" ) );
@@ -194,24 +208,25 @@ public slots:
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
@@ -101,33 +101,34 @@ int main( int argc, char** argv )
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 );