author | mickeyl <mickeyl> | 2004-03-12 13:04:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-12 13:04:07 (UTC) |
commit | d38384a6edb0110117e0297864f813b379d52789 (patch) (unidiff) | |
tree | 82929ccdea4c9e30e39971beea1a9f4a51bc7b57 /libopie2/opienet | |
parent | 36d9d18055dbed7a85ab2979d1e96dfb4017560b (diff) | |
download | opie-d38384a6edb0110117e0297864f813b379d52789.zip opie-d38384a6edb0110117e0297864f813b379d52789.tar.gz opie-d38384a6edb0110117e0297864f813b379d52789.tar.bz2 |
API change: OPacket::dumpStructure() now returns a QString and accepts void
API change: add QTextStream& operator<<( QTextStream& s, const OPacket& p );
-rw-r--r-- | libopie2/opienet/opcap.cpp | 21 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 35 |
2 files changed, 32 insertions, 24 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 7463320..fdd519c 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -110,14 +110,13 @@ void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | |||
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void OPacket::dumpStructure( QObjectList* l ) | 113 | QString OPacket::dumpStructure() const |
114 | { | 114 | { |
115 | QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); | 115 | return "[ |" + _dumpStructure( const_cast<QObjectList*>( this->children() ) ) + " ]"; |
116 | odebug << "OPacket::dumpStructure: " << packetString << oendl; | ||
117 | } | 116 | } |
118 | 117 | ||
119 | 118 | ||
120 | QString OPacket::_dumpStructure( QObjectList* l ) | 119 | QString OPacket::_dumpStructure( QObjectList* l ) const |
121 | { | 120 | { |
122 | if (!l) return QString::null; | 121 | if (!l) return QString::null; |
123 | QObject* o = l->first(); | 122 | QObject* o = l->first(); |
@@ -179,6 +178,12 @@ int OPacket::len() const | |||
179 | } | 178 | } |
180 | 179 | ||
181 | 180 | ||
181 | QTextStream& operator<<( QTextStream& s, const OPacket& p ) | ||
182 | { | ||
183 | s << p.dumpStructure(); | ||
184 | } | ||
185 | |||
186 | |||
182 | /*====================================================================================== | 187 | /*====================================================================================== |
183 | * OEthernetPacket | 188 | * OEthernetPacket |
184 | *======================================================================================*/ | 189 | *======================================================================================*/ |
@@ -729,7 +734,7 @@ OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, co | |||
729 | // Other management frames don't - which is why we have to inspect the subtype here. | 734 | // Other management frames don't - which is why we have to inspect the subtype here. |
730 | 735 | ||
731 | const unsigned char* ptr = managementType() == "Beacon" ? (const unsigned char*) (_body+1) : (const unsigned char*) (_header+1); | 736 | const unsigned char* ptr = managementType() == "Beacon" ? (const unsigned char*) (_body+1) : (const unsigned char*) (_header+1); |
732 | 737 | ||
733 | while (ptr < end) | 738 | while (ptr < end) |
734 | { | 739 | { |
735 | switch ( *ptr ) | 740 | switch ( *ptr ) |
@@ -1188,9 +1193,7 @@ OPacket* OPacketCapturer::next() | |||
1188 | // by emit() [ see below ] | 1193 | // by emit() [ see below ] |
1189 | //TODO: make gathering statistics optional, because it takes time | 1194 | //TODO: make gathering statistics optional, because it takes time |
1190 | p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); | 1195 | p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); |
1191 | #ifndef NODEBUG | 1196 | odebug << "OPacket::dumpStructure: " << p->dumpStructure() << oendl; |
1192 | p->dumpStructure( const_cast<QObjectList*>( p->children() ) ); | ||
1193 | #endif | ||
1194 | return p; | 1197 | return p; |
1195 | } | 1198 | } |
1196 | else | 1199 | else |
@@ -1338,7 +1341,7 @@ bool OPacketCapturer::swapped() const | |||
1338 | 1341 | ||
1339 | QString OPacketCapturer::version() const | 1342 | QString OPacketCapturer::version() const |
1340 | { | 1343 | { |
1341 | return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); | 1344 | return QString().sprintf( "%d.%d", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); |
1342 | } | 1345 | } |
1343 | 1346 | ||
1344 | 1347 | ||
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index f5dc5c0..b873b49 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -31,16 +31,8 @@ | |||
31 | #ifndef OPCAP_H | 31 | #ifndef OPCAP_H |
32 | #define OPCAP_H | 32 | #define OPCAP_H |
33 | 33 | ||
34 | /* LINUX */ | 34 | /* OPIE */ |
35 | extern "C" // work around a bpf/pcap conflict in recent headers | 35 | #include <opie2/onetutils.h> |
36 | { | ||
37 | #include <pcap.h> | ||
38 | } | ||
39 | #include <netinet/ether.h> | ||
40 | #include <netinet/ip.h> | ||
41 | #include <netinet/udp.h> | ||
42 | #include <netinet/tcp.h> | ||
43 | #include <time.h> | ||
44 | 36 | ||
45 | /* QT */ | 37 | /* QT */ |
46 | #include <qevent.h> | 38 | #include <qevent.h> |
@@ -48,15 +40,25 @@ extern "C" // work around a bpf/pcap conflict in recent headers | |||
48 | #include <qhostaddress.h> | 40 | #include <qhostaddress.h> |
49 | #include <qobject.h> | 41 | #include <qobject.h> |
50 | #include <qstring.h> | 42 | #include <qstring.h> |
43 | #include <qtextstream.h> | ||
51 | #include <qmap.h> | 44 | #include <qmap.h> |
52 | 45 | ||
53 | /* OPIE */ | 46 | /* STD */ |
54 | #include <opie2/onetutils.h> | 47 | extern "C" // work around a bpf/pcap conflict in recent headers |
48 | { | ||
49 | #include <pcap.h> | ||
50 | } | ||
51 | #include <netinet/ether.h> | ||
52 | #include <netinet/ip.h> | ||
53 | #include <netinet/udp.h> | ||
54 | #include <netinet/tcp.h> | ||
55 | #include <time.h> | ||
55 | 56 | ||
56 | /* Custom Network Includes */ | 57 | /* Custom Network Includes (must go here, don't reorder!) */ |
57 | #include "802_11_user.h" | 58 | #include "802_11_user.h" |
58 | #include "dhcp.h" | 59 | #include "dhcp.h" |
59 | 60 | ||
61 | |||
60 | /* TYPEDEFS */ | 62 | /* TYPEDEFS */ |
61 | typedef struct timeval timevalstruct; | 63 | typedef struct timeval timevalstruct; |
62 | typedef struct pcap_pkthdr packetheaderstruct; | 64 | typedef struct pcap_pkthdr packetheaderstruct; |
@@ -116,6 +118,7 @@ class OPacket : public QObject | |||
116 | Q_OBJECT | 118 | Q_OBJECT |
117 | 119 | ||
118 | friend class OPacketCapturer; | 120 | friend class OPacketCapturer; |
121 | friend QTextStream& operator<<( QTextStream& s, const OPacket& p ); | ||
119 | 122 | ||
120 | public: | 123 | public: |
121 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 124 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
@@ -131,8 +134,8 @@ class OPacket : public QObject | |||
131 | 134 | ||
132 | private: | 135 | private: |
133 | 136 | ||
134 | void dumpStructure( QObjectList* ); | 137 | QString dumpStructure() const; |
135 | QString _dumpStructure( QObjectList* ); | 138 | QString _dumpStructure( QObjectList* ) const; |
136 | 139 | ||
137 | private: | 140 | private: |
138 | const packetheaderstruct _hdr; // pcap packet header | 141 | const packetheaderstruct _hdr; // pcap packet header |
@@ -140,6 +143,8 @@ class OPacket : public QObject | |||
140 | const unsigned char* _end; // end of pcap packet data | 143 | const unsigned char* _end; // end of pcap packet data |
141 | }; | 144 | }; |
142 | 145 | ||
146 | QTextStream& operator<<( QTextStream& s, const OPacket& p ); | ||
147 | |||
143 | /*====================================================================================== | 148 | /*====================================================================================== |
144 | * OEthernetPacket - DLT_EN10MB frame | 149 | * OEthernetPacket - DLT_EN10MB frame |
145 | *======================================================================================*/ | 150 | *======================================================================================*/ |