author | mickeyl <mickeyl> | 2003-10-05 13:12:45 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-05 13:12:45 (UTC) |
commit | 634a68b636a0fa24232029b79ffa915a5621b2be (patch) (unidiff) | |
tree | 3e4c58bebfd624e841c314f1db68d985d81cdc6c /libopie2/opienet | |
parent | dc9510f788212a6be063349461540e4bea690f51 (diff) | |
download | opie-634a68b636a0fa24232029b79ffa915a5621b2be.zip opie-634a68b636a0fa24232029b79ffa915a5621b2be.tar.gz opie-634a68b636a0fa24232029b79ffa915a5621b2be.tar.bz2 |
* start with preparations for scanning wired networks
* dhcp recognition now works nicely
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 7 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 1 | ||||
-rw-r--r-- | libopie2/opienet/opcap.cpp | 27 | ||||
-rw-r--r-- | libopie2/opienet/opcap.h | 5 |
4 files changed, 38 insertions, 2 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index 08c40b4..ad0e89d 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp | |||
@@ -57,10 +57,15 @@ const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | |||
57 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); | 57 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); |
58 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; | 58 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; |
59 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); | 59 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); |
60 | 60 | ||
61 | //TODO: Incorporate Ethernet Manufacturer database here! (inline or so) | ||
62 | |||
63 | OMacAddress::OMacAddress() | ||
64 | { | ||
65 | memcpy( _bytes, __unknown, 6 ); | ||
66 | } | ||
61 | 67 | ||
62 | //TODO: Incorporate Ethernet Manufacturer database here! | ||
63 | 68 | ||
64 | OMacAddress::OMacAddress( unsigned char* p ) | 69 | OMacAddress::OMacAddress( unsigned char* p ) |
65 | { | 70 | { |
66 | memcpy( _bytes, p, 6 ); | 71 | memcpy( _bytes, p, 6 ); |
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 9611518..18731ba 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h | |||
@@ -50,8 +50,9 @@ class OWirelessNetworkInterface; | |||
50 | class OMacAddress | 50 | class OMacAddress |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | // QString c'tor? -zecke | 53 | // QString c'tor? -zecke |
54 | OMacAddress(); | ||
54 | OMacAddress( unsigned char* ); | 55 | OMacAddress( unsigned char* ); |
55 | OMacAddress( const unsigned char* ); | 56 | OMacAddress( const unsigned char* ); |
56 | OMacAddress( struct ifreq& ); | 57 | OMacAddress( struct ifreq& ); |
57 | ~OMacAddress(); | 58 | ~OMacAddress(); |
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 7a6f61b..313f5bb 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp | |||
@@ -107,8 +107,31 @@ void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | |||
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | void OPacket::dumpStructure( QObjectList* l ) | ||
112 | { | ||
113 | QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); | ||
114 | qDebug( "OPacket::dumpStructure: %s", (const char*) packetString ); | ||
115 | } | ||
116 | |||
117 | |||
118 | QString OPacket::_dumpStructure( QObjectList* l ) | ||
119 | { | ||
120 | if (!l) return QString::null; | ||
121 | QObject* o = l->first(); | ||
122 | QString str(" "); | ||
123 | |||
124 | while ( o ) | ||
125 | { | ||
126 | str.append( o->name() ); | ||
127 | str.append( " |" ); | ||
128 | str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); | ||
129 | o = l->next(); | ||
130 | } | ||
131 | return str; | ||
132 | } | ||
133 | |||
111 | QString OPacket::dump( int bpl ) const | 134 | QString OPacket::dump( int bpl ) const |
112 | { | 135 | { |
113 | static int index = 0; | 136 | static int index = 0; |
114 | index++; | 137 | index++; |
@@ -1115,9 +1138,11 @@ OPacket* OPacketCapturer::next() | |||
1115 | // as possible - that is right after they have been processed | 1138 | // as possible - that is right after they have been processed |
1116 | // by emit() [ see below ] | 1139 | // by emit() [ see below ] |
1117 | //TODO: make gathering statistics optional, because it takes time | 1140 | //TODO: make gathering statistics optional, because it takes time |
1118 | p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); | 1141 | p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); |
1119 | 1142 | #ifndef NODEBUG | |
1143 | p->dumpStructure( const_cast<QObjectList*>( p->children() ) ); | ||
1144 | #endif | ||
1120 | return p; | 1145 | return p; |
1121 | } | 1146 | } |
1122 | else | 1147 | else |
1123 | { | 1148 | { |
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index a031dd1..f0d1d81 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h | |||
@@ -132,8 +132,13 @@ class OPacket : public QObject | |||
132 | 132 | ||
133 | void updateStats( QMap<QString,int>&, QObjectList* ); | 133 | void updateStats( QMap<QString,int>&, QObjectList* ); |
134 | 134 | ||
135 | private: | 135 | private: |
136 | |||
137 | void dumpStructure( QObjectList* ); | ||
138 | QString _dumpStructure( QObjectList* ); | ||
139 | |||
140 | private: | ||
136 | const packetheaderstruct _hdr; // pcap packet header | 141 | const packetheaderstruct _hdr; // pcap packet header |
137 | const unsigned char* _data; // pcap packet data | 142 | const unsigned char* _data; // pcap packet data |
138 | const unsigned char* _end; // end of pcap packet data | 143 | const unsigned char* _end; // end of pcap packet data |
139 | }; | 144 | }; |