-rw-r--r-- | libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp | 63 | ||||
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 1 | ||||
-rw-r--r-- | libopie2/libopie2.control | 6 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 96 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.h | 37 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 21 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 3 | ||||
-rw-r--r-- | libopie2/opienet/opcap.cpp | 8 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 12 |
9 files changed, 205 insertions, 42 deletions
diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp index 7581888..f800336 100644 --- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp +++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp | |||
@@ -1,202 +1,217 @@ | |||
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 | ||
14 | class Station | 14 | class 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 | ||
26 | QDict<Station> stations; | 26 | QDict<Station> stations; |
27 | 27 | ||
28 | //======================== Application class =============================== | 28 | //======================== Application class =============================== |
29 | 29 | ||
30 | class Wellenreiter : public QApplication | 30 | class Wellenreiter : public QApplication |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ) | 34 | Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ) |
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 (C) 2003 M-M-M *\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 | /* | ||
87 | |||
88 | // ifconfig down the interface - this enable more crash-proof | ||
89 | // scanning with drivers like spectrum_cs... | ||
90 | if ( wiface->isUp() ) | ||
91 | { | ||
92 | printf( "Interface status is up... switching to down... " ); | ||
93 | wiface->setUp( false ); | ||
94 | if ( wiface->isUp() ) | ||
95 | { | ||
96 | printf( "failed (%s). Exiting.\n", strerror( errno ) ); | ||
97 | exit( -1 ); | ||
98 | } | ||
99 | else | ||
100 | { | ||
101 | printf( "ok.\n" ); | ||
102 | } | ||
103 | } | ||
104 | else | ||
105 | printf( "Interface status is already down - good.\n" ); | ||
106 | |||
107 | */ | ||
108 | |||
109 | // ifconfig +promisc the interface to receive all packets | 86 | // ifconfig +promisc the interface to receive all packets |
110 | if ( !wiface->promiscuousMode() ) | 87 | if ( !wiface->promiscuousMode() ) |
111 | { | 88 | { |
112 | printf( "Interface status is not promisc... switching to promisc... " ); | 89 | printf( "Interface status is not promisc... switching to promisc... " ); |
113 | wiface->setPromiscuousMode( true ); | 90 | wiface->setPromiscuousMode( true ); |
114 | if ( !wiface->promiscuousMode() ) | 91 | if ( !wiface->promiscuousMode() ) |
115 | { | 92 | { |
116 | printf( "failed (%s). Exiting.\n", strerror( errno ) ); | 93 | printf( "failed (%s). Exiting.\n", strerror( errno ) ); |
117 | exit( -1 ); | 94 | exit( -1 ); |
118 | } | 95 | } |
119 | else | 96 | else |
120 | { | 97 | { |
121 | printf( "ok.\n" ); | 98 | printf( "ok.\n" ); |
122 | } | 99 | } |
123 | } | 100 | } |
124 | else | 101 | else |
125 | printf( "Interface status is already promisc - good.\n" ); | 102 | printf( "Interface status is already promisc - good.\n" ); |
126 | 103 | ||
127 | // connect a monitoring strategy to the interface | 104 | // connect a monitoring strategy to the interface |
128 | if ( driver == "orinoco" ) | 105 | if ( driver == "orinoco" ) |
129 | new OOrinocoMonitoringInterface( wiface ); | 106 | new OOrinocoMonitoringInterface( wiface ); |
130 | else | 107 | else |
131 | { | 108 | { |
132 | printf( "Unknown driver. Exiting\n" ); | 109 | printf( "Unknown driver. Exiting\n" ); |
133 | exit( -1 ); | 110 | exit( -1 ); |
134 | } | 111 | } |
135 | 112 | ||
136 | // enable monitoring mode | 113 | // enable monitoring mode |
137 | printf( "Enabling monitor mode...\n" ); | 114 | printf( "Enabling monitor mode...\n" ); |
138 | wiface->setMonitorMode( true ); | 115 | wiface->setMonitorMode( true ); |
139 | 116 | ||
140 | // open a packet capturer | 117 | // open a packet capturer |
141 | cap = new OPacketCapturer(); | 118 | cap = new OPacketCapturer(); |
142 | cap->open( interface ); | 119 | cap->open( interface ); |
143 | if ( !cap->isOpen() ) | 120 | if ( !cap->isOpen() ) |
144 | { | 121 | { |
145 | printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); | 122 | printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); |
146 | exit( -1 ); | 123 | exit( -1 ); |
147 | } | 124 | } |
148 | 125 | ||
149 | // set capturer to non-blocking mode | 126 | // set capturer to non-blocking mode |
150 | cap->setBlocking( false ); | 127 | cap->setBlocking( false ); |
151 | 128 | ||
152 | // start channel hopper | 129 | // start channel hopper |
153 | wiface->setChannelHopping( 1000 ); | 130 | wiface->setChannelHopping( 1000 ); |
154 | 131 | ||
155 | // connect | 132 | // connect |
156 | connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 133 | connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
157 | 134 | ||
158 | } | 135 | } |
159 | 136 | ||
160 | ~Wellenreiter() {}; | 137 | ~Wellenreiter() {}; |
161 | 138 | ||
162 | public slots: | 139 | public slots: |
163 | void receivePacket(OPacket* p) | 140 | void receivePacket(OPacket* p) |
164 | { | 141 | { |
165 | if (!p) | 142 | if (!p) |
166 | { | 143 | { |
167 | printf( "(empty packet received)\n" ); | 144 | printf( "(empty packet received)\n" ); |
168 | return; | 145 | return; |
169 | } | 146 | } |
170 | 147 | ||
171 | OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); | 148 | OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); |
172 | |||
173 | if ( beacon ) | 149 | if ( beacon ) |
174 | { | 150 | { |
175 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 151 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
176 | QString essid = ssid ? ssid->ID() : "<unknown>"; | 152 | QString essid = ssid ? ssid->ID() : "<unknown>"; |
177 | 153 | ||
178 | if ( stations.find( essid ) ) | 154 | if ( stations.find( essid ) ) |
179 | stations[essid]->beacons++; | 155 | stations[essid]->beacons++; |
180 | else | 156 | else |
181 | { | 157 | { |
182 | printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid ); | 158 | printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid ); |
183 | stations.insert( essid, new Station( "unknown", wiface->channel(), | 159 | stations.insert( essid, new Station( "unknown", wiface->channel(), |
184 | ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); | 160 | ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); |
185 | } | 161 | } |
162 | return; | ||
163 | } | ||
164 | |||
165 | OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" ); | ||
166 | if ( data ) | ||
167 | { | ||
168 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | ||
169 | if ( wlan->fromDS() && !wlan->toDS() ) | ||
170 | { | ||
171 | printf( "FromDS: '%s' -> '%s' via '%s'\n", | ||
172 | (const char*) wlan->macAddress3().toString(true), | ||
173 | (const char*) wlan->macAddress1().toString(true), | ||
174 | (const char*) wlan->macAddress2().toString(true) ); | ||
175 | } | ||
176 | else | ||
177 | if ( !wlan->fromDS() && wlan->toDS() ) | ||
178 | { | ||
179 | printf( "ToDS: '%s' -> '%s' via '%s'\n", | ||
180 | (const char*) wlan->macAddress2().toString(true), | ||
181 | (const char*) wlan->macAddress3().toString(true), | ||
182 | (const char*) wlan->macAddress1().toString(true) ); | ||
183 | } | ||
184 | else | ||
185 | if ( wlan->fromDS() && wlan->toDS() ) | ||
186 | { | ||
187 | printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n", | ||
188 | (const char*) wlan->macAddress4().toString(true), | ||
189 | (const char*) wlan->macAddress3().toString(true), | ||
190 | (const char*) wlan->macAddress1().toString(true), | ||
191 | (const char*) wlan->macAddress2().toString(true) ); | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n", | ||
196 | (const char*) wlan->macAddress2().toString(true), | ||
197 | (const char*) wlan->macAddress1().toString(true), | ||
198 | (const char*) wlan->macAddress3().toString(true) ); | ||
199 | } | ||
200 | return; | ||
186 | } | 201 | } |
187 | } | 202 | } |
188 | private: | 203 | private: |
189 | OPacketCapturer* cap; | 204 | OPacketCapturer* cap; |
190 | OWirelessNetworkInterface* wiface; | 205 | OWirelessNetworkInterface* wiface; |
191 | }; | 206 | }; |
192 | 207 | ||
193 | 208 | ||
194 | int main( int argc, char** argv ) | 209 | int main( int argc, char** argv ) |
195 | { | 210 | { |
196 | Wellenreiter w( argc, argv ); | 211 | Wellenreiter w( argc, argv ); |
197 | w.exec(); | 212 | w.exec(); |
198 | return 0; | 213 | return 0; |
199 | } | 214 | } |
200 | 215 | ||
201 | #include "miniwellenreiter.moc" | 216 | #include "miniwellenreiter.moc" |
202 | 217 | ||
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index 020fc23..f801b15 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1,61 +1,62 @@ | |||
1 | #include <opie2/onetwork.h> | 1 | #include <opie2/onetwork.h> |
2 | 2 | ||
3 | int main( int argc, char** argv ) | 3 | int main( int argc, char** argv ) |
4 | { | 4 | { |
5 | qDebug( "OPIE Network Demo" ); | 5 | qDebug( "OPIE Network Demo" ); |
6 | 6 | ||
7 | ONetwork* net = ONetwork::instance(); | 7 | ONetwork* net = ONetwork::instance(); |
8 | 8 | ||
9 | ONetwork::InterfaceIterator it = net->iterator(); | 9 | ONetwork::InterfaceIterator it = net->iterator(); |
10 | 10 | ||
11 | while ( it.current() ) | 11 | while ( it.current() ) |
12 | { | 12 | { |
13 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); | 13 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); |
14 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); | 14 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); |
15 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); | ||
15 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); | 16 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); |
16 | if ( it.current()->isWireless() ) | 17 | if ( it.current()->isWireless() ) |
17 | { | 18 | { |
18 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 19 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
19 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); | 20 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); |
20 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); | 21 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); |
21 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); | 22 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); |
22 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); | 23 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); |
23 | 24 | ||
24 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | 25 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) |
25 | //{ | 26 | //{ |
26 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); | 27 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); |
27 | //} | 28 | //} |
28 | 29 | ||
29 | // try to set monitor mode | 30 | // try to set monitor mode |
30 | 31 | ||
31 | /* | 32 | /* |
32 | 33 | ||
33 | // first some wrong calls to check if this is working | 34 | // first some wrong calls to check if this is working |
34 | iface->setPrivate( "seppel", 10 ); | 35 | iface->setPrivate( "seppel", 10 ); |
35 | iface->setPrivate( "monitor", 0 ); | 36 | iface->setPrivate( "monitor", 0 ); |
36 | 37 | ||
37 | // now the real deal | 38 | // now the real deal |
38 | iface->setPrivate( "monitor", 2, 2, 3 ); | 39 | iface->setPrivate( "monitor", 2, 2, 3 ); |
39 | 40 | ||
40 | */ | 41 | */ |
41 | 42 | ||
42 | // trying to set hw address to 12:34:56:AB:CD:EF | 43 | // trying to set hw address to 12:34:56:AB:CD:EF |
43 | 44 | ||
44 | /* | 45 | /* |
45 | 46 | ||
46 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | 47 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); |
47 | iface->setUp( false ); | 48 | iface->setUp( false ); |
48 | iface->setMacAddress( addr ); | 49 | iface->setMacAddress( addr ); |
49 | iface->setUp( true ); | 50 | iface->setUp( true ); |
50 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); | 51 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); |
51 | 52 | ||
52 | */ | 53 | */ |
53 | 54 | ||
54 | 55 | ||
55 | } | 56 | } |
56 | ++it; | 57 | ++it; |
57 | } | 58 | } |
58 | 59 | ||
59 | return 0; | 60 | return 0; |
60 | 61 | ||
61 | } | 62 | } |
diff --git a/libopie2/libopie2.control b/libopie2/libopie2.control index 24a7c37..866d106 100644 --- a/libopie2/libopie2.control +++ b/libopie2/libopie2.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Files: $OPIEDIR/lib/libopiecore2.so.1.8.1 $OPIEDIR/lib/libopiecore2.so.1.8 $OPIEDIR/lib/libopiecore2.so.1 $OPIEDIR/lib/libopienet2.so.1.8.1 $OPIEDIR/lib/libopienet2.so.1.8 $OPIEDIR/lib/libopienet2.so.1 $OPIEDIR/lib/libopieui2.so.1.8.1 $OPIEDIR/lib/libopieui2.so.1.8 $OPIEDIR/lib/libopieui2.so.1 | 1 | Files: $OPIEDIR/lib/libopiecore2.so.1.8.1 $OPIEDIR/lib/libopiecore2.so.1.8 $OPIEDIR/lib/libopiecore2.so.1 $OPIEDIR/lib/libopienet2.so.1.8.1 $OPIEDIR/lib/libopienet2.so.1.8 $OPIEDIR/lib/libopienet2.so.1 $OPIEDIR/lib/libopieui2.so.1.8.1 $OPIEDIR/lib/libopieui2.so.1.8 $OPIEDIR/lib/libopieui2.so.1 $OPIEDIR/etc/manufacturers |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/system | 3 | Section: opie/system |
4 | Maintainer: Opie Team <opie@handhelds.org> | 4 | Maintainer: Opie Team <opie@handhelds.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: 1.8.1-$SUB_VERSION.1 | 6 | Version: 1.8.1-$SUB_VERSION.2 |
7 | Depends: libqpe1 | 7 | Depends: libqpe1 |
8 | Provides: libopie2 | 8 | Provides: libopie2 |
9 | Replaces: libopie2 | ||
10 | Description: Opie library 2.0 | 9 | Description: Opie library 2.0 |
10 | |||
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp new file mode 100644 index 0000000..ea15125 --- a/dev/null +++ b/libopie2/opienet/omanufacturerdb.cpp | |||
@@ -0,0 +1,96 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "omanufacturerdb.h" | ||
17 | |||
18 | // Qt | ||
19 | #include <qstring.h> | ||
20 | #include <qfile.h> | ||
21 | #include <qtextstream.h> | ||
22 | |||
23 | OManufacturerDB* OManufacturerDB::_instance = 0; | ||
24 | |||
25 | OManufacturerDB* OManufacturerDB::instance() | ||
26 | { | ||
27 | if ( !OManufacturerDB::_instance ) | ||
28 | { | ||
29 | qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." ); | ||
30 | _instance = new OManufacturerDB(); | ||
31 | } | ||
32 | return _instance; | ||
33 | } | ||
34 | |||
35 | |||
36 | OManufacturerDB::OManufacturerDB() | ||
37 | { | ||
38 | QString filename( "/etc/manufacturers" ); | ||
39 | qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); | ||
40 | if ( !QFile::exists( filename ) ) | ||
41 | { | ||
42 | filename = "/opt/QtPalmtop/etc/manufacturers"; | ||
43 | qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); | ||
44 | if ( !QFile::exists( filename ) ) | ||
45 | { | ||
46 | filename = "/usr/share/wellenreiter/manufacturers"; | ||
47 | qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | QFile file( filename ); | ||
52 | bool hasFile = file.open( IO_ReadOnly ); | ||
53 | if (!hasFile) | ||
54 | { | ||
55 | qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename ); | ||
56 | } | ||
57 | else | ||
58 | { | ||
59 | qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); | ||
60 | QTextStream s( &file ); | ||
61 | QString addr; | ||
62 | QString manu; | ||
63 | while (!s.atEnd()) | ||
64 | { | ||
65 | s >> addr; | ||
66 | if ( !addr ) // read nothing!? | ||
67 | { | ||
68 | continue; | ||
69 | } | ||
70 | else | ||
71 | if ( addr[0] == '#' ) | ||
72 | { | ||
73 | s.readLine(); | ||
74 | continue; | ||
75 | } | ||
76 | s.skipWhiteSpace(); | ||
77 | s >> manu; | ||
78 | s.readLine(); | ||
79 | //qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); | ||
80 | manufacturers.insert( addr, manu ); | ||
81 | |||
82 | } | ||
83 | } | ||
84 | |||
85 | } | ||
86 | |||
87 | |||
88 | OManufacturerDB::~OManufacturerDB() | ||
89 | { | ||
90 | } | ||
91 | |||
92 | |||
93 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const | ||
94 | { | ||
95 | return manufacturers[macaddr.upper().left(8)]; | ||
96 | } | ||
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h new file mode 100644 index 0000000..5e66c37 --- a/dev/null +++ b/libopie2/opienet/omanufacturerdb.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef OMANUFACTURERDB_H | ||
17 | #define OMANUFACTURERDB_H | ||
18 | |||
19 | #include <qmap.h> | ||
20 | |||
21 | class OManufacturerDB | ||
22 | { | ||
23 | public: | ||
24 | static OManufacturerDB* instance(); | ||
25 | const QString& lookup( const QString& macaddr ) const; | ||
26 | |||
27 | protected: | ||
28 | OManufacturerDB(); | ||
29 | virtual ~OManufacturerDB(); | ||
30 | |||
31 | private: | ||
32 | QMap<QString, QString> manufacturers; | ||
33 | static OManufacturerDB* _instance; | ||
34 | }; | ||
35 | |||
36 | #endif | ||
37 | |||
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index 2485f30..236f108 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp | |||
@@ -1,212 +1,221 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/onetutils.h> | 32 | #include <opie2/onetutils.h> |
33 | #include <opie2/onetwork.h> | 33 | #include <opie2/onetwork.h> |
34 | #include <opie2/omanufacturerdb.h> | ||
34 | 35 | ||
35 | #include <net/if.h> | 36 | #include <net/if.h> |
36 | 37 | ||
37 | #include <cstdio> | 38 | #include <cstdio> |
38 | using namespace std; | 39 | using namespace std; |
39 | 40 | ||
40 | #define IW_PRIV_TYPE_MASK 0x7000 | 41 | #define IW_PRIV_TYPE_MASK 0x7000 |
41 | #define IW_PRIV_TYPE_NONE 0x0000 | 42 | #define IW_PRIV_TYPE_NONE 0x0000 |
42 | #define IW_PRIV_TYPE_BYTE 0x1000 | 43 | #define IW_PRIV_TYPE_BYTE 0x1000 |
43 | #define IW_PRIV_TYPE_CHAR 0x2000 | 44 | #define IW_PRIV_TYPE_CHAR 0x2000 |
44 | #define IW_PRIV_TYPE_INT 0x4000 | 45 | #define IW_PRIV_TYPE_INT 0x4000 |
45 | #define IW_PRIV_TYPE_FLOAT 0x5000 | 46 | #define IW_PRIV_TYPE_FLOAT 0x5000 |
46 | #define IW_PRIV_TYPE_ADDR 0x6000 | 47 | #define IW_PRIV_TYPE_ADDR 0x6000 |
47 | #define IW_PRIV_SIZE_FIXED 0x0800 | 48 | #define IW_PRIV_SIZE_FIXED 0x0800 |
48 | #define IW_PRIV_SIZE_MASK 0x07FF | 49 | #define IW_PRIV_SIZE_MASK 0x07FF |
49 | 50 | ||
50 | /*====================================================================================== | 51 | /*====================================================================================== |
51 | * OMacAddress | 52 | * OMacAddress |
52 | *======================================================================================*/ | 53 | *======================================================================================*/ |
53 | 54 | ||
54 | // static initializer for broadcast and unknown MAC Adresses | 55 | // static initializer for broadcast and unknown MAC Adresses |
55 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 56 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
56 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); | 57 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); |
57 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; | 58 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; |
58 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); | 59 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); |
59 | 60 | ||
60 | 61 | ||
61 | //TODO: Incorporate Ethernet Manufacturer database here! | 62 | //TODO: Incorporate Ethernet Manufacturer database here! |
62 | 63 | ||
63 | OMacAddress::OMacAddress( unsigned char* p ) | 64 | OMacAddress::OMacAddress( unsigned char* p ) |
64 | { | 65 | { |
65 | memcpy( _bytes, p, 6 ); | 66 | memcpy( _bytes, p, 6 ); |
66 | } | 67 | } |
67 | 68 | ||
68 | 69 | ||
69 | OMacAddress::OMacAddress( const unsigned char* p ) | 70 | OMacAddress::OMacAddress( const unsigned char* p ) |
70 | { | 71 | { |
71 | memcpy( _bytes, p, 6 ); | 72 | memcpy( _bytes, p, 6 ); |
72 | } | 73 | } |
73 | 74 | ||
74 | 75 | ||
75 | OMacAddress::OMacAddress( struct ifreq& ifr ) | 76 | OMacAddress::OMacAddress( struct ifreq& ifr ) |
76 | { | 77 | { |
77 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); | 78 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); |
78 | } | 79 | } |
79 | 80 | ||
80 | 81 | ||
81 | OMacAddress::~OMacAddress() | 82 | OMacAddress::~OMacAddress() |
82 | { | 83 | { |
83 | } | 84 | } |
84 | 85 | ||
85 | 86 | ||
86 | //#ifdef QT_NO_DEBUG | 87 | //#ifdef QT_NO_DEBUG |
87 | //inline | 88 | //inline |
88 | //#endif | 89 | //#endif |
89 | const unsigned char* OMacAddress::native() const | 90 | const unsigned char* OMacAddress::native() const |
90 | { | 91 | { |
91 | return (const unsigned char*) &_bytes; | 92 | return (const unsigned char*) &_bytes; |
92 | } | 93 | } |
93 | 94 | ||
94 | 95 | ||
95 | OMacAddress OMacAddress::fromString( const QString& str ) | 96 | OMacAddress OMacAddress::fromString( const QString& str ) |
96 | { | 97 | { |
97 | QString addr( str ); | 98 | QString addr( str ); |
98 | unsigned char buf[6]; | 99 | unsigned char buf[6]; |
99 | bool ok = true; | 100 | bool ok = true; |
100 | int index = 14; | 101 | int index = 14; |
101 | for ( int i = 5; i >= 0; --i ) | 102 | for ( int i = 5; i >= 0; --i ) |
102 | { | 103 | { |
103 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); | 104 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); |
104 | if ( !ok ) return OMacAddress::unknown; | 105 | if ( !ok ) return OMacAddress::unknown; |
105 | addr.truncate( index ); | 106 | addr.truncate( index ); |
106 | index -= 3; | 107 | index -= 3; |
107 | } | 108 | } |
108 | return (const unsigned char*) &buf; | 109 | return (const unsigned char*) &buf; |
109 | } | 110 | } |
110 | 111 | ||
111 | 112 | ||
112 | QString OMacAddress::toString() const | 113 | QString OMacAddress::toString( bool substitute ) const |
113 | { | 114 | { |
114 | QString s; | 115 | QString manu; |
115 | s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 116 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); |
116 | _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff, | 117 | QString serial; |
117 | _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); | 118 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); |
118 | return s; | 119 | if ( !substitute ) return manu+serial; |
120 | // fallback - if no vendor is found, just use the number | ||
121 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); | ||
122 | return textmanu.isNull() ? manu+serial : textmanu + serial; | ||
119 | } | 123 | } |
120 | 124 | ||
121 | 125 | ||
126 | QString OMacAddress::manufacturer() const | ||
127 | { | ||
128 | return OManufacturerDB::instance()->lookup( toString() ); | ||
129 | } | ||
130 | |||
122 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) | 131 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) |
123 | { | 132 | { |
124 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; | 133 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; |
125 | } | 134 | } |
126 | 135 | ||
127 | 136 | ||
128 | /*====================================================================================== | 137 | /*====================================================================================== |
129 | * OHostAddress | 138 | * OHostAddress |
130 | *======================================================================================*/ | 139 | *======================================================================================*/ |
131 | 140 | ||
132 | 141 | ||
133 | /*====================================================================================== | 142 | /*====================================================================================== |
134 | * OPrivateIOCTL | 143 | * OPrivateIOCTL |
135 | *======================================================================================*/ | 144 | *======================================================================================*/ |
136 | 145 | ||
137 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) | 146 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) |
138 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) | 147 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) |
139 | { | 148 | { |
140 | } | 149 | } |
141 | 150 | ||
142 | 151 | ||
143 | OPrivateIOCTL::~OPrivateIOCTL() | 152 | OPrivateIOCTL::~OPrivateIOCTL() |
144 | { | 153 | { |
145 | } | 154 | } |
146 | 155 | ||
147 | 156 | ||
148 | #ifdef QT_NO_DEBUG | 157 | #ifdef QT_NO_DEBUG |
149 | inline | 158 | inline |
150 | #endif | 159 | #endif |
151 | int OPrivateIOCTL::numberGetArgs() const | 160 | int OPrivateIOCTL::numberGetArgs() const |
152 | { | 161 | { |
153 | return _getargs & IW_PRIV_SIZE_MASK; | 162 | return _getargs & IW_PRIV_SIZE_MASK; |
154 | } | 163 | } |
155 | 164 | ||
156 | 165 | ||
157 | #ifdef QT_NO_DEBUG | 166 | #ifdef QT_NO_DEBUG |
158 | inline | 167 | inline |
159 | #endif | 168 | #endif |
160 | int OPrivateIOCTL::typeGetArgs() const | 169 | int OPrivateIOCTL::typeGetArgs() const |
161 | { | 170 | { |
162 | return _getargs & IW_PRIV_TYPE_MASK >> 12; | 171 | return _getargs & IW_PRIV_TYPE_MASK >> 12; |
163 | } | 172 | } |
164 | 173 | ||
165 | 174 | ||
166 | #ifdef QT_NO_DEBUG | 175 | #ifdef QT_NO_DEBUG |
167 | inline | 176 | inline |
168 | #endif | 177 | #endif |
169 | int OPrivateIOCTL::numberSetArgs() const | 178 | int OPrivateIOCTL::numberSetArgs() const |
170 | { | 179 | { |
171 | return _setargs & IW_PRIV_SIZE_MASK; | 180 | return _setargs & IW_PRIV_SIZE_MASK; |
172 | } | 181 | } |
173 | 182 | ||
174 | 183 | ||
175 | #ifdef QT_NO_DEBUG | 184 | #ifdef QT_NO_DEBUG |
176 | inline | 185 | inline |
177 | #endif | 186 | #endif |
178 | int OPrivateIOCTL::typeSetArgs() const | 187 | int OPrivateIOCTL::typeSetArgs() const |
179 | { | 188 | { |
180 | return _setargs & IW_PRIV_TYPE_MASK >> 12; | 189 | return _setargs & IW_PRIV_TYPE_MASK >> 12; |
181 | } | 190 | } |
182 | 191 | ||
183 | 192 | ||
184 | void OPrivateIOCTL::invoke() const | 193 | void OPrivateIOCTL::invoke() const |
185 | { | 194 | { |
186 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); | 195 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); |
187 | } | 196 | } |
188 | 197 | ||
189 | 198 | ||
190 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) | 199 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) |
191 | { | 200 | { |
192 | u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; | 201 | u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; |
193 | arglist[num] = value; | 202 | arglist[num] = value; |
194 | } | 203 | } |
195 | 204 | ||
196 | /*====================================================================================== | 205 | /*====================================================================================== |
197 | * assorted functions | 206 | * assorted functions |
198 | *======================================================================================*/ | 207 | *======================================================================================*/ |
199 | 208 | ||
200 | void dumpBytes( const unsigned char* data, int num ) | 209 | void dumpBytes( const unsigned char* data, int num ) |
201 | { | 210 | { |
202 | printf( "Dumping %d bytes @ %0x", num, data ); | 211 | printf( "Dumping %d bytes @ %0x", num, data ); |
203 | printf( "-------------------------------------------\n" ); | 212 | printf( "-------------------------------------------\n" ); |
204 | 213 | ||
205 | for ( int i = 0; i < num; ++i ) | 214 | for ( int i = 0; i < num; ++i ) |
206 | { | 215 | { |
207 | printf( "%02x ", data[i] ); | 216 | printf( "%02x ", data[i] ); |
208 | if ( !((i+1) % 32) ) printf( "\n" ); | 217 | if ( !((i+1) % 32) ) printf( "\n" ); |
209 | } | 218 | } |
210 | printf( "\n\n" ); | 219 | printf( "\n\n" ); |
211 | } | 220 | } |
212 | 221 | ||
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 73d52cc..bedea63 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h | |||
@@ -1,157 +1,158 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef ONETUTILS_H | 32 | #ifndef ONETUTILS_H |
33 | #define ONETUTILS_H | 33 | #define ONETUTILS_H |
34 | 34 | ||
35 | #include <qdict.h> | 35 | #include <qdict.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | #include <qhostaddress.h> | 38 | #include <qhostaddress.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | #include <sys/types.h> | 41 | #include <sys/types.h> |
42 | 42 | ||
43 | struct ifreq; | 43 | struct ifreq; |
44 | class OWirelessNetworkInterface; | 44 | class OWirelessNetworkInterface; |
45 | 45 | ||
46 | /*====================================================================================== | 46 | /*====================================================================================== |
47 | * OMacAddress | 47 | * OMacAddress |
48 | *======================================================================================*/ | 48 | *======================================================================================*/ |
49 | 49 | ||
50 | class OMacAddress | 50 | class OMacAddress |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | OMacAddress( unsigned char* ); | 53 | OMacAddress( unsigned char* ); |
54 | OMacAddress( const unsigned char* ); | 54 | OMacAddress( const unsigned char* ); |
55 | OMacAddress( struct ifreq& ); | 55 | OMacAddress( struct ifreq& ); |
56 | ~OMacAddress(); | 56 | ~OMacAddress(); |
57 | 57 | ||
58 | QString toString() const; | 58 | QString manufacturer() const; |
59 | QString toString( bool substitute = false ) const; | ||
59 | const unsigned char* native() const; | 60 | const unsigned char* native() const; |
60 | 61 | ||
61 | static OMacAddress fromString( const QString& ); | 62 | static OMacAddress fromString( const QString& ); |
62 | 63 | ||
63 | public: | 64 | public: |
64 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff | 65 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff |
65 | static const OMacAddress& unknown; // 44:44:44:44:44:44 | 66 | static const OMacAddress& unknown; // 44:44:44:44:44:44 |
66 | 67 | ||
67 | private: | 68 | private: |
68 | unsigned char _bytes[6]; | 69 | unsigned char _bytes[6]; |
69 | 70 | ||
70 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 71 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
71 | 72 | ||
72 | }; | 73 | }; |
73 | 74 | ||
74 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 75 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
75 | 76 | ||
76 | 77 | ||
77 | /*====================================================================================== | 78 | /*====================================================================================== |
78 | * OHostAddress | 79 | * OHostAddress |
79 | *======================================================================================*/ | 80 | *======================================================================================*/ |
80 | 81 | ||
81 | class OHostAddress : public QHostAddress | 82 | class OHostAddress : public QHostAddress |
82 | { | 83 | { |
83 | public: | 84 | public: |
84 | OHostAddress(); | 85 | OHostAddress(); |
85 | ~OHostAddress(); | 86 | ~OHostAddress(); |
86 | }; | 87 | }; |
87 | 88 | ||
88 | 89 | ||
89 | /*====================================================================================== | 90 | /*====================================================================================== |
90 | * OPrivateIOCTL | 91 | * OPrivateIOCTL |
91 | *======================================================================================*/ | 92 | *======================================================================================*/ |
92 | 93 | ||
93 | class OPrivateIOCTL : public QObject | 94 | class OPrivateIOCTL : public QObject |
94 | { | 95 | { |
95 | public: | 96 | public: |
96 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); | 97 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); |
97 | ~OPrivateIOCTL(); | 98 | ~OPrivateIOCTL(); |
98 | 99 | ||
99 | int numberGetArgs() const; | 100 | int numberGetArgs() const; |
100 | int typeGetArgs() const; | 101 | int typeGetArgs() const; |
101 | int numberSetArgs() const; | 102 | int numberSetArgs() const; |
102 | int typeSetArgs() const; | 103 | int typeSetArgs() const; |
103 | 104 | ||
104 | void invoke() const; | 105 | void invoke() const; |
105 | void setParameter( int, u_int32_t ); | 106 | void setParameter( int, u_int32_t ); |
106 | 107 | ||
107 | private: | 108 | private: |
108 | u_int32_t _ioctl; | 109 | u_int32_t _ioctl; |
109 | u_int16_t _getargs; | 110 | u_int16_t _getargs; |
110 | u_int16_t _setargs; | 111 | u_int16_t _setargs; |
111 | 112 | ||
112 | }; | 113 | }; |
113 | 114 | ||
114 | /*====================================================================================== | 115 | /*====================================================================================== |
115 | * Miscellaneous | 116 | * Miscellaneous |
116 | *======================================================================================*/ | 117 | *======================================================================================*/ |
117 | 118 | ||
118 | /* dump bytes */ | 119 | /* dump bytes */ |
119 | 120 | ||
120 | void dumpBytes( const unsigned char* data, int num ); | 121 | void dumpBytes( const unsigned char* data, int num ); |
121 | 122 | ||
122 | /* Network to host order macros */ | 123 | /* Network to host order macros */ |
123 | 124 | ||
124 | #ifdef LBL_ALIGN | 125 | #ifdef LBL_ALIGN |
125 | #define EXTRACT_16BITS(p) \ | 126 | #define EXTRACT_16BITS(p) \ |
126 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ | 127 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ |
127 | (u_int16_t)*((const u_int8_t *)(p) + 1))) | 128 | (u_int16_t)*((const u_int8_t *)(p) + 1))) |
128 | #define EXTRACT_32BITS(p) \ | 129 | #define EXTRACT_32BITS(p) \ |
129 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ | 130 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ |
130 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ | 131 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ |
131 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ | 132 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ |
132 | (u_int32_t)*((const u_int8_t *)(p) + 3))) | 133 | (u_int32_t)*((const u_int8_t *)(p) + 3))) |
133 | #else | 134 | #else |
134 | #define EXTRACT_16BITS(p) \ | 135 | #define EXTRACT_16BITS(p) \ |
135 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) | 136 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) |
136 | #define EXTRACT_32BITS(p) \ | 137 | #define EXTRACT_32BITS(p) \ |
137 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) | 138 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) |
138 | #endif | 139 | #endif |
139 | 140 | ||
140 | #define EXTRACT_24BITS(p) \ | 141 | #define EXTRACT_24BITS(p) \ |
141 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ | 142 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ |
142 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 143 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
143 | (u_int32_t)*((const u_int8_t *)(p) + 2))) | 144 | (u_int32_t)*((const u_int8_t *)(p) + 2))) |
144 | 145 | ||
145 | /* Little endian protocol host order macros */ | 146 | /* Little endian protocol host order macros */ |
146 | #define EXTRACT_LE_8BITS(p) (*(p)) | 147 | #define EXTRACT_LE_8BITS(p) (*(p)) |
147 | #define EXTRACT_LE_16BITS(p) \ | 148 | #define EXTRACT_LE_16BITS(p) \ |
148 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 149 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
149 | (u_int16_t)*((const u_int8_t *)(p) + 0))) | 150 | (u_int16_t)*((const u_int8_t *)(p) + 0))) |
150 | #define EXTRACT_LE_32BITS(p) \ | 151 | #define EXTRACT_LE_32BITS(p) \ |
151 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ | 152 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ |
152 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ | 153 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ |
153 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 154 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
154 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | 155 | (u_int32_t)*((const u_int8_t *)(p) + 0))) |
155 | 156 | ||
156 | #endif // ONETUTILS_H | 157 | #endif // ONETUTILS_H |
157 | 158 | ||
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 6ddd457..40aac2c 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -1,832 +1,832 @@ | |||
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 the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
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 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/opcap.h> | 36 | #include <opie2/opcap.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) | 40 | #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) |
41 | #include <qsocketnotifier.h> | 41 | #include <qsocketnotifier.h> |
42 | 42 | ||
43 | /*====================================================================================== | 43 | /*====================================================================================== |
44 | * OPacket | 44 | * OPacket |
45 | *======================================================================================*/ | 45 | *======================================================================================*/ |
46 | 46 | ||
47 | OPacket::OPacket( packetheaderstruct header, const unsigned char* data, QObject* parent ) | 47 | OPacket::OPacket( packetheaderstruct header, const unsigned char* data, QObject* parent ) |
48 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) | 48 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) |
49 | { | 49 | { |
50 | qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); | 50 | qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); |
51 | 51 | ||
52 | _end = (unsigned char*) data + header.len; | 52 | _end = (unsigned char*) data + header.len; |
53 | qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); | 53 | qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); |
54 | 54 | ||
55 | if ( packetCapturer()->dataLink() == DLT_EN10MB ) | 55 | if ( packetCapturer()->dataLink() == DLT_EN10MB ) |
56 | { | 56 | { |
57 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); | 57 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); |
58 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); | 58 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); |
59 | } | 59 | } |
60 | else | 60 | else |
61 | { | 61 | { |
62 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); | 62 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); |
63 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); | 63 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | OPacket::~OPacket() | 68 | OPacket::~OPacket() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | OPacketCapturer* OPacket::packetCapturer() const | 73 | OPacketCapturer* OPacket::packetCapturer() const |
74 | { | 74 | { |
75 | return parent()->inherits( "OPacketCapturer" ) ? static_cast<OPacketCapturer*>( parent() ) : 0; | 75 | return parent()->inherits( "OPacketCapturer" ) ? static_cast<OPacketCapturer*>( parent() ) : 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | timevalstruct OPacket::timeval() const | 79 | timevalstruct OPacket::timeval() const |
80 | { | 80 | { |
81 | return _hdr.ts; | 81 | return _hdr.ts; |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | int OPacket::caplen() const | 85 | int OPacket::caplen() const |
86 | { | 86 | { |
87 | return _hdr.caplen; | 87 | return _hdr.caplen; |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | QString OPacket::dump( int bpl ) const | 91 | QString OPacket::dump( int bpl ) const |
92 | { | 92 | { |
93 | static int index = 0; | 93 | static int index = 0; |
94 | index++; | 94 | index++; |
95 | int len = _hdr.caplen; | 95 | int len = _hdr.caplen; |
96 | QString str; | 96 | QString str; |
97 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | 97 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); |
98 | str.append( "0000: " ); | 98 | str.append( "0000: " ); |
99 | QString tmp; | 99 | QString tmp; |
100 | QString bytes; | 100 | QString bytes; |
101 | QString chars; | 101 | QString chars; |
102 | 102 | ||
103 | for ( int i = 0; i < len; ++i ) | 103 | for ( int i = 0; i < len; ++i ) |
104 | { | 104 | { |
105 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 105 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
106 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 106 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
107 | else chars.append( '.' ); | 107 | else chars.append( '.' ); |
108 | 108 | ||
109 | if ( !((i+1) % bpl) ) | 109 | if ( !((i+1) % bpl) ) |
110 | { | 110 | { |
111 | str.append( bytes ); | 111 | str.append( bytes ); |
112 | str.append( ' ' ); | 112 | str.append( ' ' ); |
113 | str.append( chars ); | 113 | str.append( chars ); |
114 | str.append( '\n' ); | 114 | str.append( '\n' ); |
115 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | 115 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); |
116 | bytes = ""; | 116 | bytes = ""; |
117 | chars = ""; | 117 | chars = ""; |
118 | } | 118 | } |
119 | 119 | ||
120 | } | 120 | } |
121 | if ( (len % bpl) ) | 121 | if ( (len % bpl) ) |
122 | { | 122 | { |
123 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 123 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
124 | str.append( chars ); | 124 | str.append( chars ); |
125 | } | 125 | } |
126 | str.append( '\n' ); | 126 | str.append( '\n' ); |
127 | return str; | 127 | return str; |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | 131 | ||
132 | int OPacket::len() const | 132 | int OPacket::len() const |
133 | { | 133 | { |
134 | return _hdr.len; | 134 | return _hdr.len; |
135 | } | 135 | } |
136 | 136 | ||
137 | /*====================================================================================== | 137 | /*====================================================================================== |
138 | * OEthernetPacket | 138 | * OEthernetPacket |
139 | *======================================================================================*/ | 139 | *======================================================================================*/ |
140 | 140 | ||
141 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 141 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |
142 | :QObject( parent, "Ethernet" ), _ether( data ) | 142 | :QObject( parent, "Ethernet" ), _ether( data ) |
143 | 143 | ||
144 | { | 144 | { |
145 | 145 | ||
146 | qDebug( "Source = %s", (const char*) sourceAddress().toString() ); | 146 | qDebug( "Source = %s", (const char*) sourceAddress().toString() ); |
147 | qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); | 147 | qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); |
148 | 148 | ||
149 | if ( sourceAddress() == OMacAddress::broadcast ) | 149 | if ( sourceAddress() == OMacAddress::broadcast ) |
150 | qDebug( "Source is broadcast address" ); | 150 | qDebug( "Source is broadcast address" ); |
151 | if ( destinationAddress() == OMacAddress::broadcast ) | 151 | if ( destinationAddress() == OMacAddress::broadcast ) |
152 | qDebug( "Destination is broadcast address" ); | 152 | qDebug( "Destination is broadcast address" ); |
153 | 153 | ||
154 | switch ( type() ) | 154 | switch ( type() ) |
155 | { | 155 | { |
156 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 156 | case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
157 | case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; } | 157 | case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; } |
158 | case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } | 158 | case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } |
159 | default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); | 159 | default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); |
160 | } | 160 | } |
161 | 161 | ||
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | OEthernetPacket::~OEthernetPacket() | 165 | OEthernetPacket::~OEthernetPacket() |
166 | { | 166 | { |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | OMacAddress OEthernetPacket::sourceAddress() const | 170 | OMacAddress OEthernetPacket::sourceAddress() const |
171 | { | 171 | { |
172 | return OMacAddress( _ether->ether_shost ); | 172 | return OMacAddress( _ether->ether_shost ); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | OMacAddress OEthernetPacket::destinationAddress() const | 176 | OMacAddress OEthernetPacket::destinationAddress() const |
177 | { | 177 | { |
178 | return OMacAddress( _ether->ether_dhost ); | 178 | return OMacAddress( _ether->ether_dhost ); |
179 | } | 179 | } |
180 | 180 | ||
181 | int OEthernetPacket::type() const | 181 | int OEthernetPacket::type() const |
182 | { | 182 | { |
183 | return ntohs( _ether->ether_type ); | 183 | return ntohs( _ether->ether_type ); |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | /*====================================================================================== | 187 | /*====================================================================================== |
188 | * OIPPacket | 188 | * OIPPacket |
189 | *======================================================================================*/ | 189 | *======================================================================================*/ |
190 | 190 | ||
191 | 191 | ||
192 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) | 192 | OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) |
193 | :QObject( parent, "IP" ), _iphdr( data ) | 193 | :QObject( parent, "IP" ), _iphdr( data ) |
194 | 194 | ||
195 | { | 195 | { |
196 | qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); | 196 | qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); |
197 | 197 | ||
198 | //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); | 198 | //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); |
199 | //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); | 199 | //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); |
200 | 200 | ||
201 | qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); | 201 | qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); |
202 | qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); | 202 | qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); |
203 | 203 | ||
204 | switch ( protocol() ) | 204 | switch ( protocol() ) |
205 | { | 205 | { |
206 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; | 206 | case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; |
207 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; | 207 | case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; |
208 | default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); | 208 | default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); |
209 | } | 209 | } |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | OIPPacket::~OIPPacket() | 213 | OIPPacket::~OIPPacket() |
214 | { | 214 | { |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | QHostAddress OIPPacket::fromIPAddress() const | 218 | QHostAddress OIPPacket::fromIPAddress() const |
219 | { | 219 | { |
220 | return EXTRACT_32BITS( &_iphdr->saddr ); | 220 | return EXTRACT_32BITS( &_iphdr->saddr ); |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | QHostAddress OIPPacket::toIPAddress() const | 224 | QHostAddress OIPPacket::toIPAddress() const |
225 | { | 225 | { |
226 | return EXTRACT_32BITS( &_iphdr->saddr ); | 226 | return EXTRACT_32BITS( &_iphdr->saddr ); |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | int OIPPacket::tos() const | 230 | int OIPPacket::tos() const |
231 | { | 231 | { |
232 | return _iphdr->tos; | 232 | return _iphdr->tos; |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | int OIPPacket::len() const | 236 | int OIPPacket::len() const |
237 | { | 237 | { |
238 | return EXTRACT_16BITS( &_iphdr->tot_len ); | 238 | return EXTRACT_16BITS( &_iphdr->tot_len ); |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | int OIPPacket::id() const | 242 | int OIPPacket::id() const |
243 | { | 243 | { |
244 | return EXTRACT_16BITS( &_iphdr->id ); | 244 | return EXTRACT_16BITS( &_iphdr->id ); |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | int OIPPacket::offset() const | 248 | int OIPPacket::offset() const |
249 | { | 249 | { |
250 | return EXTRACT_16BITS( &_iphdr->frag_off ); | 250 | return EXTRACT_16BITS( &_iphdr->frag_off ); |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | int OIPPacket::ttl() const | 254 | int OIPPacket::ttl() const |
255 | { | 255 | { |
256 | return _iphdr->ttl; | 256 | return _iphdr->ttl; |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | int OIPPacket::protocol() const | 260 | int OIPPacket::protocol() const |
261 | { | 261 | { |
262 | return _iphdr->protocol; | 262 | return _iphdr->protocol; |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | int OIPPacket::checksum() const | 266 | int OIPPacket::checksum() const |
267 | { | 267 | { |
268 | return EXTRACT_16BITS( &_iphdr->check ); | 268 | return EXTRACT_16BITS( &_iphdr->check ); |
269 | } | 269 | } |
270 | 270 | ||
271 | /*====================================================================================== | 271 | /*====================================================================================== |
272 | * OUDPPacket | 272 | * OUDPPacket |
273 | *======================================================================================*/ | 273 | *======================================================================================*/ |
274 | 274 | ||
275 | 275 | ||
276 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) | 276 | OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) |
277 | :QObject( parent, "UDP" ), _udphdr( data ) | 277 | :QObject( parent, "UDP" ), _udphdr( data ) |
278 | 278 | ||
279 | { | 279 | { |
280 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); | 280 | qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); |
281 | } | 281 | } |
282 | 282 | ||
283 | OUDPPacket::~OUDPPacket() | 283 | OUDPPacket::~OUDPPacket() |
284 | { | 284 | { |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | /*====================================================================================== | 288 | /*====================================================================================== |
289 | * OTCPPacket | 289 | * OTCPPacket |
290 | *======================================================================================*/ | 290 | *======================================================================================*/ |
291 | 291 | ||
292 | 292 | ||
293 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) | 293 | OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) |
294 | :QObject( parent, "TCP" ), _tcphdr( data ) | 294 | :QObject( parent, "TCP" ), _tcphdr( data ) |
295 | 295 | ||
296 | { | 296 | { |
297 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); | 297 | qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); |
298 | } | 298 | } |
299 | 299 | ||
300 | OTCPPacket::~OTCPPacket() | 300 | OTCPPacket::~OTCPPacket() |
301 | { | 301 | { |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | /*====================================================================================== | 305 | /*====================================================================================== |
306 | * OWaveLanPacket | 306 | * OWaveLanPacket |
307 | *======================================================================================*/ | 307 | *======================================================================================*/ |
308 | 308 | ||
309 | 309 | ||
310 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) | 310 | OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) |
311 | :QObject( parent, "802.11" ), _wlanhdr( data ) | 311 | :QObject( parent, "802.11" ), _wlanhdr( data ) |
312 | 312 | ||
313 | { | 313 | { |
314 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); | 314 | qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); |
315 | qDebug( "type: %0X", type() ); | 315 | qDebug( "type: %0X", type() ); |
316 | qDebug( "subType: %0X", subType() ); | 316 | qDebug( "subType: %0X", subType() ); |
317 | qDebug( "duration: %d", duration() ); | 317 | qDebug( "duration: %d", duration() ); |
318 | qDebug( "powermanagement: %d", usesPowerManagement() ); | 318 | qDebug( "powermanagement: %d", usesPowerManagement() ); |
319 | qDebug( "wep: %d", usesWep() ); | 319 | qDebug( "wep: %d", usesWep() ); |
320 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); | 320 | qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); |
321 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); | 321 | qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); |
322 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); | 322 | qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); |
323 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); | 323 | qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); |
324 | 324 | ||
325 | switch ( type() ) | 325 | switch ( type() ) |
326 | { | 326 | { |
327 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; | 327 | case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; |
328 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; | 328 | case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; |
329 | //case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_ctrl_header*) data, this ); break; | 329 | //case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_ctrl_header*) data, this ); break; |
330 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown type!" ); | 330 | default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown type!" ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | OWaveLanPacket::~OWaveLanPacket() | 334 | OWaveLanPacket::~OWaveLanPacket() |
335 | { | 335 | { |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | int OWaveLanPacket::duration() const | 339 | int OWaveLanPacket::duration() const |
340 | { | 340 | { |
341 | return _wlanhdr->duration; | 341 | return _wlanhdr->duration; |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | OMacAddress OWaveLanPacket::macAddress1() const | 345 | OMacAddress OWaveLanPacket::macAddress1() const |
346 | { | 346 | { |
347 | return OMacAddress( _wlanhdr->mac1 ); | 347 | return OMacAddress( _wlanhdr->mac1 ); |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | OMacAddress OWaveLanPacket::macAddress2() const | 351 | OMacAddress OWaveLanPacket::macAddress2() const |
352 | { | 352 | { |
353 | return OMacAddress( _wlanhdr->mac2 ); | 353 | return OMacAddress( _wlanhdr->mac2 ); |
354 | } | 354 | } |
355 | 355 | ||
356 | 356 | ||
357 | OMacAddress OWaveLanPacket::macAddress3() const | 357 | OMacAddress OWaveLanPacket::macAddress3() const |
358 | { | 358 | { |
359 | return OMacAddress( _wlanhdr->mac3 ); | 359 | return OMacAddress( _wlanhdr->mac3 ); |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | OMacAddress OWaveLanPacket::macAddress4() const | 363 | OMacAddress OWaveLanPacket::macAddress4() const |
364 | { | 364 | { |
365 | return OMacAddress( _wlanhdr->mac4 ); | 365 | return OMacAddress( _wlanhdr->mac4 ); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | int OWaveLanPacket::subType() const | 369 | int OWaveLanPacket::subType() const |
370 | { | 370 | { |
371 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 371 | return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | int OWaveLanPacket::type() const | 375 | int OWaveLanPacket::type() const |
376 | { | 376 | { |
377 | return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 377 | return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | int OWaveLanPacket::version() const | 381 | int OWaveLanPacket::version() const |
382 | { | 382 | { |
383 | return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 383 | return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | bool OWaveLanPacket::fromDS() const | 387 | bool OWaveLanPacket::fromDS() const |
388 | { | 388 | { |
389 | return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 389 | return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | bool OWaveLanPacket::toDS() const | 393 | bool OWaveLanPacket::toDS() const |
394 | { | 394 | { |
395 | return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 395 | return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | bool OWaveLanPacket::usesPowerManagement() const | 399 | bool OWaveLanPacket::usesPowerManagement() const |
400 | { | 400 | { |
401 | return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 401 | return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | bool OWaveLanPacket::usesWep() const | 405 | bool OWaveLanPacket::usesWep() const |
406 | { | 406 | { |
407 | return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); | 407 | return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | /*====================================================================================== | 411 | /*====================================================================================== |
412 | * OWaveLanManagementPacket | 412 | * OWaveLanManagementPacket |
413 | *======================================================================================*/ | 413 | *======================================================================================*/ |
414 | 414 | ||
415 | OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) | 415 | OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) |
416 | :QObject( parent, "802.11 Management" ), _header( data ), | 416 | :QObject( parent, "802.11 Management" ), _header( data ), |
417 | _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) | 417 | _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) |
418 | { | 418 | { |
419 | qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); | 419 | qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); |
420 | 420 | ||
421 | switch ( ((OWaveLanPacket*) this->parent() )->subType() ) | 421 | switch ( ((OWaveLanPacket*) this->parent() )->subType() ) |
422 | { | 422 | { |
423 | case ST_BEACON: | 423 | case ST_BEACON: |
424 | { | 424 | { |
425 | // nice, received a beacon... | 425 | // nice, received a beacon... |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | // grab tagged values | 429 | // grab tagged values |
430 | const unsigned char* ptr = (const unsigned char*) (_body+1); | 430 | const unsigned char* ptr = (const unsigned char*) (_body+1); |
431 | while (ptr < end) | 431 | while (ptr < end) |
432 | { | 432 | { |
433 | switch ( *ptr ) | 433 | switch ( *ptr ) |
434 | { | 434 | { |
435 | case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; | 435 | case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; |
436 | case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; | 436 | case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; |
437 | case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; | 437 | case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; |
438 | case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; | 438 | case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; |
439 | case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; | 439 | case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; |
440 | case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; | 440 | case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; |
441 | case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; | 441 | case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; |
442 | case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; | 442 | case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; |
443 | } | 443 | } |
444 | ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value | 444 | ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value |
445 | ptr+= 2; // skip tag ID and length | 445 | ptr+= 2; // skip tag ID and length |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | 449 | ||
450 | OWaveLanManagementPacket::~OWaveLanManagementPacket() | 450 | OWaveLanManagementPacket::~OWaveLanManagementPacket() |
451 | { | 451 | { |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | int OWaveLanManagementPacket::beaconInterval() const | 455 | int OWaveLanManagementPacket::beaconInterval() const |
456 | { | 456 | { |
457 | return EXTRACT_LE_16BITS( &_body->beacon_interval ); | 457 | return EXTRACT_LE_16BITS( &_body->beacon_interval ); |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | int OWaveLanManagementPacket::capabilities() const | 461 | int OWaveLanManagementPacket::capabilities() const |
462 | { | 462 | { |
463 | return EXTRACT_LE_16BITS( &_body->capability_info ); | 463 | return EXTRACT_LE_16BITS( &_body->capability_info ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | bool OWaveLanManagementPacket::canESS() const | 467 | bool OWaveLanManagementPacket::canESS() const |
468 | { | 468 | { |
469 | return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 469 | return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | bool OWaveLanManagementPacket::canIBSS() const | 473 | bool OWaveLanManagementPacket::canIBSS() const |
474 | { | 474 | { |
475 | return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 475 | return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
476 | } | 476 | } |
477 | 477 | ||
478 | 478 | ||
479 | bool OWaveLanManagementPacket::canCFP() const | 479 | bool OWaveLanManagementPacket::canCFP() const |
480 | { | 480 | { |
481 | return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 481 | return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | bool OWaveLanManagementPacket::canCFP_REQ() const | 485 | bool OWaveLanManagementPacket::canCFP_REQ() const |
486 | { | 486 | { |
487 | return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 487 | return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
488 | } | 488 | } |
489 | 489 | ||
490 | 490 | ||
491 | bool OWaveLanManagementPacket::canPrivacy() const | 491 | bool OWaveLanManagementPacket::canPrivacy() const |
492 | { | 492 | { |
493 | return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); | 493 | return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); |
494 | } | 494 | } |
495 | 495 | ||
496 | 496 | ||
497 | /*====================================================================================== | 497 | /*====================================================================================== |
498 | * OWaveLanManagementSSID | 498 | * OWaveLanManagementSSID |
499 | *======================================================================================*/ | 499 | *======================================================================================*/ |
500 | 500 | ||
501 | OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) | 501 | OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) |
502 | :QObject( parent, "802.11 SSID" ), _data( data ) | 502 | :QObject( parent, "802.11 SSID" ), _data( data ) |
503 | { | 503 | { |
504 | qDebug( "OWaveLanManagementSSID()" ); | 504 | qDebug( "OWaveLanManagementSSID()" ); |
505 | } | 505 | } |
506 | 506 | ||
507 | 507 | ||
508 | OWaveLanManagementSSID::~OWaveLanManagementSSID() | 508 | OWaveLanManagementSSID::~OWaveLanManagementSSID() |
509 | { | 509 | { |
510 | } | 510 | } |
511 | 511 | ||
512 | 512 | ||
513 | QString OWaveLanManagementSSID::ID() const | 513 | QString OWaveLanManagementSSID::ID() const |
514 | { | 514 | { |
515 | int length = _data->length; | 515 | int length = _data->length; |
516 | if ( length > 32 ) length = 32; | 516 | if ( length > 32 ) length = 32; |
517 | char essid[length+1]; | 517 | char essid[length+1]; |
518 | memcpy( &essid, &_data->ssid, length ); | 518 | memcpy( &essid, &_data->ssid, length ); |
519 | essid[length] = 0x0; | 519 | essid[length] = 0x0; |
520 | return essid; | 520 | return essid; |
521 | } | 521 | } |
522 | 522 | ||
523 | 523 | ||
524 | /*====================================================================================== | 524 | /*====================================================================================== |
525 | * OWaveLanManagementRates | 525 | * OWaveLanManagementRates |
526 | *======================================================================================*/ | 526 | *======================================================================================*/ |
527 | 527 | ||
528 | OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) | 528 | OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) |
529 | :QObject( parent, "802.11 Rates" ), _data( data ) | 529 | :QObject( parent, "802.11 Rates" ), _data( data ) |
530 | { | 530 | { |
531 | qDebug( "OWaveLanManagementRates()" ); | 531 | qDebug( "OWaveLanManagementRates()" ); |
532 | } | 532 | } |
533 | 533 | ||
534 | 534 | ||
535 | OWaveLanManagementRates::~OWaveLanManagementRates() | 535 | OWaveLanManagementRates::~OWaveLanManagementRates() |
536 | { | 536 | { |
537 | } | 537 | } |
538 | 538 | ||
539 | /*====================================================================================== | 539 | /*====================================================================================== |
540 | * OWaveLanManagementCF | 540 | * OWaveLanManagementCF |
541 | *======================================================================================*/ | 541 | *======================================================================================*/ |
542 | 542 | ||
543 | OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) | 543 | OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) |
544 | :QObject( parent, "802.11 CF" ), _data( data ) | 544 | :QObject( parent, "802.11 CF" ), _data( data ) |
545 | { | 545 | { |
546 | qDebug( "OWaveLanManagementCF()" ); | 546 | qDebug( "OWaveLanManagementCF()" ); |
547 | } | 547 | } |
548 | 548 | ||
549 | 549 | ||
550 | OWaveLanManagementCF::~OWaveLanManagementCF() | 550 | OWaveLanManagementCF::~OWaveLanManagementCF() |
551 | { | 551 | { |
552 | } | 552 | } |
553 | 553 | ||
554 | /*====================================================================================== | 554 | /*====================================================================================== |
555 | * OWaveLanManagementFH | 555 | * OWaveLanManagementFH |
556 | *======================================================================================*/ | 556 | *======================================================================================*/ |
557 | 557 | ||
558 | OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) | 558 | OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) |
559 | :QObject( parent, "802.11 FH" ), _data( data ) | 559 | :QObject( parent, "802.11 FH" ), _data( data ) |
560 | { | 560 | { |
561 | qDebug( "OWaveLanManagementFH()" ); | 561 | qDebug( "OWaveLanManagementFH()" ); |
562 | } | 562 | } |
563 | 563 | ||
564 | 564 | ||
565 | OWaveLanManagementFH::~OWaveLanManagementFH() | 565 | OWaveLanManagementFH::~OWaveLanManagementFH() |
566 | { | 566 | { |
567 | } | 567 | } |
568 | 568 | ||
569 | /*====================================================================================== | 569 | /*====================================================================================== |
570 | * OWaveLanManagementDS | 570 | * OWaveLanManagementDS |
571 | *======================================================================================*/ | 571 | *======================================================================================*/ |
572 | 572 | ||
573 | OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) | 573 | OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) |
574 | :QObject( parent, "802.11 DS" ), _data( data ) | 574 | :QObject( parent, "802.11 DS" ), _data( data ) |
575 | { | 575 | { |
576 | qDebug( "OWaveLanManagementDS()" ); | 576 | qDebug( "OWaveLanManagementDS()" ); |
577 | } | 577 | } |
578 | 578 | ||
579 | 579 | ||
580 | OWaveLanManagementDS::~OWaveLanManagementDS() | 580 | OWaveLanManagementDS::~OWaveLanManagementDS() |
581 | { | 581 | { |
582 | } | 582 | } |
583 | 583 | ||
584 | 584 | ||
585 | int OWaveLanManagementDS::channel() const | 585 | int OWaveLanManagementDS::channel() const |
586 | { | 586 | { |
587 | return _data->channel; | 587 | return _data->channel; |
588 | } | 588 | } |
589 | 589 | ||
590 | /*====================================================================================== | 590 | /*====================================================================================== |
591 | * OWaveLanManagementTim | 591 | * OWaveLanManagementTim |
592 | *======================================================================================*/ | 592 | *======================================================================================*/ |
593 | 593 | ||
594 | OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) | 594 | OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) |
595 | :QObject( parent, "802.11 Tim" ), _data( data ) | 595 | :QObject( parent, "802.11 Tim" ), _data( data ) |
596 | { | 596 | { |
597 | qDebug( "OWaveLanManagementTim()" ); | 597 | qDebug( "OWaveLanManagementTim()" ); |
598 | } | 598 | } |
599 | 599 | ||
600 | 600 | ||
601 | OWaveLanManagementTim::~OWaveLanManagementTim() | 601 | OWaveLanManagementTim::~OWaveLanManagementTim() |
602 | { | 602 | { |
603 | } | 603 | } |
604 | 604 | ||
605 | /*====================================================================================== | 605 | /*====================================================================================== |
606 | * OWaveLanManagementIBSS | 606 | * OWaveLanManagementIBSS |
607 | *======================================================================================*/ | 607 | *======================================================================================*/ |
608 | 608 | ||
609 | OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) | 609 | OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) |
610 | :QObject( parent, "802.11 IBSS" ), _data( data ) | 610 | :QObject( parent, "802.11 IBSS" ), _data( data ) |
611 | { | 611 | { |
612 | qDebug( "OWaveLanManagementIBSS()" ); | 612 | qDebug( "OWaveLanManagementIBSS()" ); |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | OWaveLanManagementIBSS::~OWaveLanManagementIBSS() | 616 | OWaveLanManagementIBSS::~OWaveLanManagementIBSS() |
617 | { | 617 | { |
618 | } | 618 | } |
619 | 619 | ||
620 | /*====================================================================================== | 620 | /*====================================================================================== |
621 | * OWaveLanManagementChallenge | 621 | * OWaveLanManagementChallenge |
622 | *======================================================================================*/ | 622 | *======================================================================================*/ |
623 | 623 | ||
624 | OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) | 624 | OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) |
625 | :QObject( parent, "802.11 Challenge" ), _data( data ) | 625 | :QObject( parent, "802.11 Challenge" ), _data( data ) |
626 | { | 626 | { |
627 | qDebug( "OWaveLanManagementChallenge()" ); | 627 | qDebug( "OWaveLanManagementChallenge()" ); |
628 | } | 628 | } |
629 | 629 | ||
630 | 630 | ||
631 | OWaveLanManagementChallenge::~OWaveLanManagementChallenge() | 631 | OWaveLanManagementChallenge::~OWaveLanManagementChallenge() |
632 | { | 632 | { |
633 | } | 633 | } |
634 | 634 | ||
635 | /*====================================================================================== | 635 | /*====================================================================================== |
636 | * OWaveLanDataPacket | 636 | * OWaveLanDataPacket |
637 | *======================================================================================*/ | 637 | *======================================================================================*/ |
638 | 638 | ||
639 | OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) | 639 | OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) |
640 | :QObject( parent, "802.11 Data" ), _header( data ) | 640 | :QObject( parent, "802.11 Data" ), _header( data ) |
641 | { | 641 | { |
642 | //qDebug( "size of header = %d", sizeof( struct ieee_802_11_data_header ) ); | 642 | qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." ); |
643 | //qDebug( "header: %0x", data ); | 643 | |
644 | const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); | 644 | const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); |
645 | //qDebug( "payload: %0x", payload ); | ||
646 | 645 | ||
646 | #warning The next line works for most cases, but can not be correct generally! | ||
647 | if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address | 647 | if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address |
648 | 648 | ||
649 | new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); | 649 | new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); |
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | OWaveLanDataPacket::~OWaveLanDataPacket() | 653 | OWaveLanDataPacket::~OWaveLanDataPacket() |
654 | { | 654 | { |
655 | } | 655 | } |
656 | 656 | ||
657 | 657 | ||
658 | /*====================================================================================== | 658 | /*====================================================================================== |
659 | * OLLCPacket | 659 | * OLLCPacket |
660 | *======================================================================================*/ | 660 | *======================================================================================*/ |
661 | 661 | ||
662 | OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) | 662 | OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) |
663 | :QObject( parent, "802.11 802_2" ), _header( data ) | 663 | :QObject( parent, "802.11 LLC" ), _header( data ) |
664 | { | 664 | { |
665 | qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." ); | 665 | qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." ); |
666 | 666 | ||
667 | if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) | 667 | if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) |
668 | { | 668 | { |
669 | qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) ); | 669 | qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) ); |
670 | 670 | ||
671 | switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h | 671 | switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h |
672 | { | 672 | { |
673 | case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; | 673 | case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; |
674 | default: qDebug( "OLLCPacket::OLLCPacket(): Unknown Encapsulation Type" ); | 674 | default: qDebug( "OLLCPacket::OLLCPacket(): Unknown Encapsulation Type" ); |
675 | } | 675 | } |
676 | 676 | ||
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
680 | 680 | ||
681 | OLLCPacket::~OLLCPacket() | 681 | OLLCPacket::~OLLCPacket() |
682 | { | 682 | { |
683 | } | 683 | } |
684 | 684 | ||
685 | /*====================================================================================== | 685 | /*====================================================================================== |
686 | * OPacketCapturer | 686 | * OPacketCapturer |
687 | *======================================================================================*/ | 687 | *======================================================================================*/ |
688 | 688 | ||
689 | OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) | 689 | OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) |
690 | :QObject( parent, name ), _name( QString::null ), _open( false ), | 690 | :QObject( parent, name ), _name( QString::null ), _open( false ), |
691 | _pch( 0 ), _sn( 0 ) | 691 | _pch( 0 ), _sn( 0 ) |
692 | { | 692 | { |
693 | } | 693 | } |
694 | 694 | ||
695 | 695 | ||
696 | OPacketCapturer::~OPacketCapturer() | 696 | OPacketCapturer::~OPacketCapturer() |
697 | { | 697 | { |
698 | if ( _open ) | 698 | if ( _open ) |
699 | { | 699 | { |
700 | qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." ); | 700 | qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." ); |
701 | close(); | 701 | close(); |
702 | } | 702 | } |
703 | } | 703 | } |
704 | 704 | ||
705 | 705 | ||
706 | void OPacketCapturer::setBlocking( bool b ) | 706 | void OPacketCapturer::setBlocking( bool b ) |
707 | { | 707 | { |
708 | if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) | 708 | if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) |
709 | { | 709 | { |
710 | qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." ); | 710 | qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." ); |
711 | } | 711 | } |
712 | else | 712 | else |
713 | { | 713 | { |
714 | qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf ); | 714 | qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf ); |
715 | } | 715 | } |
716 | } | 716 | } |
717 | 717 | ||
718 | 718 | ||
719 | bool OPacketCapturer::blocking() const | 719 | bool OPacketCapturer::blocking() const |
720 | { | 720 | { |
721 | int b = pcap_getnonblock( _pch, _errbuf ); | 721 | int b = pcap_getnonblock( _pch, _errbuf ); |
722 | if ( b == -1 ) | 722 | if ( b == -1 ) |
723 | { | 723 | { |
724 | qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf ); | 724 | qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf ); |
725 | return -1; | 725 | return -1; |
726 | } | 726 | } |
727 | return !b; | 727 | return !b; |
728 | } | 728 | } |
729 | 729 | ||
730 | 730 | ||
731 | void OPacketCapturer::close() | 731 | void OPacketCapturer::close() |
732 | { | 732 | { |
733 | if ( _open ) | 733 | if ( _open ) |
734 | { | 734 | { |
735 | if ( _sn ) | 735 | if ( _sn ) |
736 | { | 736 | { |
737 | _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 737 | _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
738 | delete _sn; | 738 | delete _sn; |
739 | } | 739 | } |
740 | pcap_close( _pch ); | 740 | pcap_close( _pch ); |
741 | _open = false; | 741 | _open = false; |
742 | } | 742 | } |
743 | } | 743 | } |
744 | 744 | ||
745 | 745 | ||
746 | int OPacketCapturer::dataLink() const | 746 | int OPacketCapturer::dataLink() const |
747 | { | 747 | { |
748 | return pcap_datalink( _pch ); | 748 | return pcap_datalink( _pch ); |
749 | } | 749 | } |
750 | 750 | ||
751 | 751 | ||
752 | int OPacketCapturer::fileno() const | 752 | int OPacketCapturer::fileno() const |
753 | { | 753 | { |
754 | if ( _open ) | 754 | if ( _open ) |
755 | { | 755 | { |
756 | return pcap_fileno( _pch ); | 756 | return pcap_fileno( _pch ); |
757 | } | 757 | } |
758 | else | 758 | else |
759 | { | 759 | { |
760 | return -1; | 760 | return -1; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | 763 | ||
764 | 764 | ||
765 | OPacket* OPacketCapturer::next() | 765 | OPacket* OPacketCapturer::next() |
766 | { | 766 | { |
767 | packetheaderstruct header; | 767 | packetheaderstruct header; |
768 | qDebug( "==> OPacketCapturer::next()" ); | 768 | qDebug( "==> OPacketCapturer::next()" ); |
769 | const unsigned char* pdata = pcap_next( _pch, &header ); | 769 | const unsigned char* pdata = pcap_next( _pch, &header ); |
770 | qDebug( "<== OPacketCapturer::next()" ); | 770 | qDebug( "<== OPacketCapturer::next()" ); |
771 | 771 | ||
772 | if ( header.len ) | 772 | if ( header.len ) |
773 | return new OPacket( header, pdata, this ); | 773 | return new OPacket( header, pdata, this ); |
774 | else | 774 | else |
775 | return 0; | 775 | return 0; |
776 | } | 776 | } |
777 | 777 | ||
778 | 778 | ||
779 | bool OPacketCapturer::open( const QString& name ) | 779 | bool OPacketCapturer::open( const QString& name ) |
780 | { | 780 | { |
781 | if ( _open ) | 781 | if ( _open ) |
782 | { | 782 | { |
783 | if ( name == _name ) // ignore opening an already openend device | 783 | if ( name == _name ) // ignore opening an already openend device |
784 | { | 784 | { |
785 | return true; | 785 | return true; |
786 | } | 786 | } |
787 | else // close the last opened device | 787 | else // close the last opened device |
788 | { | 788 | { |
789 | close(); | 789 | close(); |
790 | } | 790 | } |
791 | } | 791 | } |
792 | 792 | ||
793 | _name = name; | 793 | _name = name; |
794 | 794 | ||
795 | pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); | 795 | pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); |
796 | 796 | ||
797 | if ( handle ) | 797 | if ( handle ) |
798 | { | 798 | { |
799 | qDebug( "OPacketCapturer::open(): libpcap opened successfully." ); | 799 | qDebug( "OPacketCapturer::open(): libpcap opened successfully." ); |
800 | _pch = handle; | 800 | _pch = handle; |
801 | _open = true; | 801 | _open = true; |
802 | 802 | ||
803 | // in case we have an application object, create a socket notifier | 803 | // in case we have an application object, create a socket notifier |
804 | if ( qApp ) | 804 | if ( qApp ) |
805 | { | 805 | { |
806 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); | 806 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); |
807 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 807 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
808 | } | 808 | } |
809 | 809 | ||
810 | return true; | 810 | return true; |
811 | } | 811 | } |
812 | else | 812 | else |
813 | { | 813 | { |
814 | qDebug( "OPacketCapturer::open(): can't open libpcap: %s", _errbuf ); | 814 | qDebug( "OPacketCapturer::open(): can't open libpcap: %s", _errbuf ); |
815 | return false; | 815 | return false; |
816 | } | 816 | } |
817 | 817 | ||
818 | } | 818 | } |
819 | 819 | ||
820 | 820 | ||
821 | bool OPacketCapturer::isOpen() const | 821 | bool OPacketCapturer::isOpen() const |
822 | { | 822 | { |
823 | return _open; | 823 | return _open; |
824 | } | 824 | } |
825 | 825 | ||
826 | 826 | ||
827 | void OPacketCapturer::readyToReceive() | 827 | void OPacketCapturer::readyToReceive() |
828 | { | 828 | { |
829 | qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(...)'" ); | 829 | qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(...)'" ); |
830 | emit receivedPacket( next() ); | 830 | emit receivedPacket( next() ); |
831 | } | 831 | } |
832 | 832 | ||
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index e73afbf..3f9166a 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro | |||
@@ -1,18 +1,22 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = onetutils.cpp onetwork.h opcap.h | 4 | HEADERS = omanufacturerdb.cpp \ |
5 | 5 | onetutils.cpp \ | |
6 | SOURCES = onetutils.cpp onetwork.cpp opcap.cpp | 6 | onetwork.h \ |
7 | opcap.h | ||
8 | SOURCES = omanufacturerdb.cpp \ | ||
9 | onetutils.cpp \ | ||
10 | onetwork.cpp \ | ||
11 | opcap.cpp | ||
7 | INTERFACES = | 12 | INTERFACES = |
8 | TARGET = opienet2 | 13 | TARGET = opienet2 |
9 | VERSION = 1.8.1 | 14 | VERSION = 1.8.1 |
10 | INCLUDEPATH += $(OPIEDIR)/include | 15 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH += $(OPIEDIR)/include | 16 | DEPENDPATH += $(OPIEDIR)/include |
12 | LIBS += -lpcap | 17 | LIBS += -lpcap |
13 | |||
14 | MOC_DIR = moc | 18 | MOC_DIR = moc |
15 | OBJECTS_DIR = obj | 19 | OBJECTS_DIR = obj |
16 | 20 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 21 | include ( $(OPIEDIR)/include.pro ) |
18 | 22 | ||