-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 | |||
@@ -1,126 +1,131 @@ | |||
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 | #include <opie2/omanufacturerdb.h> |
35 | 35 | ||
36 | #include <net/if.h> | 36 | #include <net/if.h> |
37 | 37 | ||
38 | #include <cstdio> | 38 | #include <cstdio> |
39 | using namespace std; | 39 | using namespace std; |
40 | 40 | ||
41 | #define IW_PRIV_TYPE_MASK 0x7000 | 41 | #define IW_PRIV_TYPE_MASK 0x7000 |
42 | #define IW_PRIV_TYPE_NONE 0x0000 | 42 | #define IW_PRIV_TYPE_NONE 0x0000 |
43 | #define IW_PRIV_TYPE_BYTE 0x1000 | 43 | #define IW_PRIV_TYPE_BYTE 0x1000 |
44 | #define IW_PRIV_TYPE_CHAR 0x2000 | 44 | #define IW_PRIV_TYPE_CHAR 0x2000 |
45 | #define IW_PRIV_TYPE_INT 0x4000 | 45 | #define IW_PRIV_TYPE_INT 0x4000 |
46 | #define IW_PRIV_TYPE_FLOAT 0x5000 | 46 | #define IW_PRIV_TYPE_FLOAT 0x5000 |
47 | #define IW_PRIV_TYPE_ADDR 0x6000 | 47 | #define IW_PRIV_TYPE_ADDR 0x6000 |
48 | #define IW_PRIV_SIZE_FIXED 0x0800 | 48 | #define IW_PRIV_SIZE_FIXED 0x0800 |
49 | #define IW_PRIV_SIZE_MASK 0x07FF | 49 | #define IW_PRIV_SIZE_MASK 0x07FF |
50 | 50 | ||
51 | /*====================================================================================== | 51 | /*====================================================================================== |
52 | * OMacAddress | 52 | * OMacAddress |
53 | *======================================================================================*/ | 53 | *======================================================================================*/ |
54 | 54 | ||
55 | // static initializer for broadcast and unknown MAC Adresses | 55 | // static initializer for broadcast and unknown MAC Adresses |
56 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 56 | 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 ); |
67 | } | 72 | } |
68 | 73 | ||
69 | 74 | ||
70 | OMacAddress::OMacAddress( const unsigned char* p ) | 75 | OMacAddress::OMacAddress( const unsigned char* p ) |
71 | { | 76 | { |
72 | memcpy( _bytes, p, 6 ); | 77 | memcpy( _bytes, p, 6 ); |
73 | } | 78 | } |
74 | 79 | ||
75 | 80 | ||
76 | OMacAddress::OMacAddress( struct ifreq& ifr ) | 81 | OMacAddress::OMacAddress( struct ifreq& ifr ) |
77 | { | 82 | { |
78 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); | 83 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); |
79 | } | 84 | } |
80 | 85 | ||
81 | 86 | ||
82 | OMacAddress::~OMacAddress() | 87 | OMacAddress::~OMacAddress() |
83 | { | 88 | { |
84 | } | 89 | } |
85 | 90 | ||
86 | 91 | ||
87 | //#ifdef QT_NO_DEBUG | 92 | //#ifdef QT_NO_DEBUG |
88 | //inline | 93 | //inline |
89 | //#endif | 94 | //#endif |
90 | const unsigned char* OMacAddress::native() const | 95 | const unsigned char* OMacAddress::native() const |
91 | { | 96 | { |
92 | return (const unsigned char*) &_bytes; | 97 | return (const unsigned char*) &_bytes; |
93 | } | 98 | } |
94 | 99 | ||
95 | 100 | ||
96 | OMacAddress OMacAddress::fromString( const QString& str ) | 101 | OMacAddress OMacAddress::fromString( const QString& str ) |
97 | { | 102 | { |
98 | QString addr( str ); | 103 | QString addr( str ); |
99 | unsigned char buf[6]; | 104 | unsigned char buf[6]; |
100 | bool ok = true; | 105 | bool ok = true; |
101 | int index = 14; | 106 | int index = 14; |
102 | for ( int i = 5; i >= 0; --i ) | 107 | for ( int i = 5; i >= 0; --i ) |
103 | { | 108 | { |
104 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); | 109 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); |
105 | if ( !ok ) return OMacAddress::unknown; | 110 | if ( !ok ) return OMacAddress::unknown; |
106 | addr.truncate( index ); | 111 | addr.truncate( index ); |
107 | index -= 3; | 112 | index -= 3; |
108 | } | 113 | } |
109 | return (const unsigned char*) &buf; | 114 | return (const unsigned char*) &buf; |
110 | } | 115 | } |
111 | 116 | ||
112 | 117 | ||
113 | QString OMacAddress::toString( bool substitute ) const | 118 | QString OMacAddress::toString( bool substitute ) const |
114 | { | 119 | { |
115 | QString manu; | 120 | QString manu; |
116 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); | 121 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); |
117 | QString serial; | 122 | QString serial; |
118 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); | 123 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); |
119 | if ( !substitute ) return manu+serial; | 124 | if ( !substitute ) return manu+serial; |
120 | // fallback - if no vendor is found, just use the number | 125 | // fallback - if no vendor is found, just use the number |
121 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); | 126 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); |
122 | return textmanu.isNull() ? manu+serial : textmanu+serial; | 127 | return textmanu.isNull() ? manu+serial : textmanu+serial; |
123 | } | 128 | } |
124 | 129 | ||
125 | 130 | ||
126 | QString OMacAddress::manufacturer() const | 131 | QString OMacAddress::manufacturer() const |
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 | |||
@@ -1,117 +1,118 @@ | |||
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 | // 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(); |
58 | 59 | ||
59 | QString manufacturer() const; | 60 | QString manufacturer() const; |
60 | QString toString( bool substitute = false ) const; | 61 | QString toString( bool substitute = false ) const; |
61 | const unsigned char* native() const; | 62 | const unsigned char* native() const; |
62 | 63 | ||
63 | // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? | 64 | // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? |
64 | static OMacAddress fromString( const QString& ); | 65 | static OMacAddress fromString( const QString& ); |
65 | 66 | ||
66 | public: | 67 | public: |
67 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff | 68 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff |
68 | static const OMacAddress& unknown; // 44:44:44:44:44:44 | 69 | static const OMacAddress& unknown; // 44:44:44:44:44:44 |
69 | 70 | ||
70 | private: | 71 | private: |
71 | unsigned char _bytes[6]; | 72 | unsigned char _bytes[6]; |
72 | 73 | ||
73 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 74 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
74 | 75 | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 78 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
78 | 79 | ||
79 | 80 | ||
80 | /*====================================================================================== | 81 | /*====================================================================================== |
81 | * OHostAddress | 82 | * OHostAddress |
82 | *======================================================================================*/ | 83 | *======================================================================================*/ |
83 | 84 | ||
84 | class OHostAddress : public QHostAddress | 85 | class OHostAddress : public QHostAddress |
85 | { | 86 | { |
86 | public: | 87 | public: |
87 | OHostAddress(); | 88 | OHostAddress(); |
88 | ~OHostAddress(); | 89 | ~OHostAddress(); |
89 | }; | 90 | }; |
90 | 91 | ||
91 | 92 | ||
92 | /*====================================================================================== | 93 | /*====================================================================================== |
93 | * OPrivateIOCTL | 94 | * OPrivateIOCTL |
94 | *======================================================================================*/ | 95 | *======================================================================================*/ |
95 | 96 | ||
96 | class OPrivateIOCTL : public QObject | 97 | class OPrivateIOCTL : public QObject |
97 | { | 98 | { |
98 | public: | 99 | public: |
99 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); | 100 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); |
100 | ~OPrivateIOCTL(); | 101 | ~OPrivateIOCTL(); |
101 | 102 | ||
102 | int numberGetArgs() const; | 103 | int numberGetArgs() const; |
103 | int typeGetArgs() const; | 104 | int typeGetArgs() const; |
104 | int numberSetArgs() const; | 105 | int numberSetArgs() const; |
105 | int typeSetArgs() const; | 106 | int typeSetArgs() const; |
106 | 107 | ||
107 | // FIXME return int? as ::ioctl does? -zecke | 108 | // FIXME return int? as ::ioctl does? -zecke |
108 | void invoke() const; | 109 | void invoke() const; |
109 | void setParameter( int, u_int32_t ); | 110 | void setParameter( int, u_int32_t ); |
110 | 111 | ||
111 | private: | 112 | private: |
112 | u_int32_t _ioctl; | 113 | u_int32_t _ioctl; |
113 | u_int16_t _getargs; | 114 | u_int16_t _getargs; |
114 | u_int16_t _setargs; | 115 | u_int16_t _setargs; |
115 | 116 | ||
116 | }; | 117 | }; |
117 | 118 | ||
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 | |||
@@ -47,128 +47,151 @@ | |||
47 | * OPacket | 47 | * OPacket |
48 | *======================================================================================*/ | 48 | *======================================================================================*/ |
49 | 49 | ||
50 | OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) | 50 | OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) |
51 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) | 51 | :QObject( parent, "Generic" ), _hdr( header ), _data( data ) |
52 | { | 52 | { |
53 | //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); | 53 | //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); |
54 | 54 | ||
55 | _end = (unsigned char*) data + header.len; | 55 | _end = (unsigned char*) data + header.len; |
56 | //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); | 56 | //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); |
57 | 57 | ||
58 | switch ( datalink ) | 58 | switch ( datalink ) |
59 | { | 59 | { |
60 | case DLT_EN10MB: | 60 | case DLT_EN10MB: |
61 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); | 61 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); |
62 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); | 62 | new OEthernetPacket( _end, (const struct ether_header*) data, this ); |
63 | break; | 63 | break; |
64 | 64 | ||
65 | case DLT_IEEE802_11: | 65 | case DLT_IEEE802_11: |
66 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); | 66 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); |
67 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); | 67 | new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); |
68 | break; | 68 | break; |
69 | 69 | ||
70 | case DLT_PRISM_HEADER: | 70 | case DLT_PRISM_HEADER: |
71 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); | 71 | qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); |
72 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); | 72 | new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); |
73 | break; | 73 | break; |
74 | 74 | ||
75 | default: | 75 | default: |
76 | qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); | 76 | qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | OPacket::~OPacket() | 81 | OPacket::~OPacket() |
82 | { | 82 | { |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | timevalstruct OPacket::timeval() const | 86 | timevalstruct OPacket::timeval() const |
87 | { | 87 | { |
88 | return _hdr.ts; | 88 | return _hdr.ts; |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | int OPacket::caplen() const | 92 | int OPacket::caplen() const |
93 | { | 93 | { |
94 | return _hdr.caplen; | 94 | return _hdr.caplen; |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) | 98 | void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) |
99 | { | 99 | { |
100 | if (!l) return; | 100 | if (!l) return; |
101 | QObject* o = l->first(); | 101 | QObject* o = l->first(); |
102 | while ( o ) | 102 | while ( o ) |
103 | { | 103 | { |
104 | stats[o->name()]++; | 104 | stats[o->name()]++; |
105 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); | 105 | updateStats( stats, const_cast<QObjectList*>( o->children() ) ); |
106 | o = l->next(); | 106 | o = l->next(); |
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++; |
115 | int len = _hdr.caplen; | 138 | int len = _hdr.caplen; |
116 | QString str; | 139 | QString str; |
117 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); | 140 | str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); |
118 | str.append( "0000: " ); | 141 | str.append( "0000: " ); |
119 | QString tmp; | 142 | QString tmp; |
120 | QString bytes; | 143 | QString bytes; |
121 | QString chars; | 144 | QString chars; |
122 | 145 | ||
123 | for ( int i = 0; i < len; ++i ) | 146 | for ( int i = 0; i < len; ++i ) |
124 | { | 147 | { |
125 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); | 148 | tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); |
126 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); | 149 | if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); |
127 | else chars.append( '.' ); | 150 | else chars.append( '.' ); |
128 | 151 | ||
129 | if ( !((i+1) % bpl) ) | 152 | if ( !((i+1) % bpl) ) |
130 | { | 153 | { |
131 | str.append( bytes ); | 154 | str.append( bytes ); |
132 | str.append( ' ' ); | 155 | str.append( ' ' ); |
133 | str.append( chars ); | 156 | str.append( chars ); |
134 | str.append( '\n' ); | 157 | str.append( '\n' ); |
135 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); | 158 | tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); |
136 | bytes = ""; | 159 | bytes = ""; |
137 | chars = ""; | 160 | chars = ""; |
138 | } | 161 | } |
139 | 162 | ||
140 | } | 163 | } |
141 | if ( (len % bpl) ) | 164 | if ( (len % bpl) ) |
142 | { | 165 | { |
143 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); | 166 | str.append( bytes.leftJustify( 1 + 3*bpl ) ); |
144 | str.append( chars ); | 167 | str.append( chars ); |
145 | } | 168 | } |
146 | str.append( '\n' ); | 169 | str.append( '\n' ); |
147 | return str; | 170 | return str; |
148 | } | 171 | } |
149 | 172 | ||
150 | 173 | ||
151 | int OPacket::len() const | 174 | int OPacket::len() const |
152 | { | 175 | { |
153 | return _hdr.len; | 176 | return _hdr.len; |
154 | } | 177 | } |
155 | 178 | ||
156 | 179 | ||
157 | /*====================================================================================== | 180 | /*====================================================================================== |
158 | * OEthernetPacket | 181 | * OEthernetPacket |
159 | *======================================================================================*/ | 182 | *======================================================================================*/ |
160 | 183 | ||
161 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) | 184 | OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) |
162 | :QObject( parent, "Ethernet" ), _ether( data ) | 185 | :QObject( parent, "Ethernet" ), _ether( data ) |
163 | { | 186 | { |
164 | 187 | ||
165 | qDebug( "Source = %s", (const char*) sourceAddress().toString() ); | 188 | qDebug( "Source = %s", (const char*) sourceAddress().toString() ); |
166 | qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); | 189 | qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); |
167 | 190 | ||
168 | if ( sourceAddress() == OMacAddress::broadcast ) | 191 | if ( sourceAddress() == OMacAddress::broadcast ) |
169 | qDebug( "Source is broadcast address" ); | 192 | qDebug( "Source is broadcast address" ); |
170 | if ( destinationAddress() == OMacAddress::broadcast ) | 193 | if ( destinationAddress() == OMacAddress::broadcast ) |
171 | qDebug( "Destination is broadcast address" ); | 194 | qDebug( "Destination is broadcast address" ); |
172 | 195 | ||
173 | switch ( type() ) | 196 | switch ( type() ) |
174 | { | 197 | { |
@@ -1055,129 +1078,131 @@ void OPacketCapturer::close() | |||
1055 | { | 1078 | { |
1056 | if ( _sn ) | 1079 | if ( _sn ) |
1057 | { | 1080 | { |
1058 | _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 1081 | _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
1059 | delete _sn; | 1082 | delete _sn; |
1060 | } | 1083 | } |
1061 | closeDumpFile(); | 1084 | closeDumpFile(); |
1062 | _open = false; | 1085 | _open = false; |
1063 | } | 1086 | } |
1064 | 1087 | ||
1065 | qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); | 1088 | qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); |
1066 | qDebug( "--------------------------------------------------" ); | 1089 | qDebug( "--------------------------------------------------" ); |
1067 | for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) | 1090 | for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) |
1068 | qDebug( "%s : %d", (const char*) it.key(), it.data() ); | 1091 | qDebug( "%s : %d", (const char*) it.key(), it.data() ); |
1069 | qDebug( "--------------------------------------------------" ); | 1092 | qDebug( "--------------------------------------------------" ); |
1070 | 1093 | ||
1071 | } | 1094 | } |
1072 | 1095 | ||
1073 | 1096 | ||
1074 | int OPacketCapturer::dataLink() const | 1097 | int OPacketCapturer::dataLink() const |
1075 | { | 1098 | { |
1076 | return pcap_datalink( _pch ); | 1099 | return pcap_datalink( _pch ); |
1077 | } | 1100 | } |
1078 | 1101 | ||
1079 | 1102 | ||
1080 | void OPacketCapturer::dump( OPacket* p ) | 1103 | void OPacketCapturer::dump( OPacket* p ) |
1081 | { | 1104 | { |
1082 | if ( !_pcd ) | 1105 | if ( !_pcd ) |
1083 | { | 1106 | { |
1084 | qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" ); | 1107 | qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" ); |
1085 | return; | 1108 | return; |
1086 | } | 1109 | } |
1087 | pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); | 1110 | pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); |
1088 | } | 1111 | } |
1089 | 1112 | ||
1090 | 1113 | ||
1091 | int OPacketCapturer::fileno() const | 1114 | int OPacketCapturer::fileno() const |
1092 | { | 1115 | { |
1093 | if ( _open ) | 1116 | if ( _open ) |
1094 | { | 1117 | { |
1095 | return pcap_fileno( _pch ); | 1118 | return pcap_fileno( _pch ); |
1096 | } | 1119 | } |
1097 | else | 1120 | else |
1098 | { | 1121 | { |
1099 | return -1; | 1122 | return -1; |
1100 | } | 1123 | } |
1101 | } | 1124 | } |
1102 | 1125 | ||
1103 | OPacket* OPacketCapturer::next() | 1126 | OPacket* OPacketCapturer::next() |
1104 | { | 1127 | { |
1105 | packetheaderstruct header; | 1128 | packetheaderstruct header; |
1106 | qDebug( "==> OPacketCapturer::next()" ); | 1129 | qDebug( "==> OPacketCapturer::next()" ); |
1107 | const unsigned char* pdata = pcap_next( _pch, &header ); | 1130 | const unsigned char* pdata = pcap_next( _pch, &header ); |
1108 | qDebug( "<== OPacketCapturer::next()" ); | 1131 | qDebug( "<== OPacketCapturer::next()" ); |
1109 | 1132 | ||
1110 | if ( pdata && header.len ) | 1133 | if ( pdata && header.len ) |
1111 | { | 1134 | { |
1112 | OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); | 1135 | OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); |
1113 | // packets shouldn't be inserted in the QObject child-parent hierarchy, | 1136 | // packets shouldn't be inserted in the QObject child-parent hierarchy, |
1114 | // because due to memory constraints they will be deleted as soon | 1137 | // because due to memory constraints they will be deleted as soon |
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 | { |
1124 | qWarning( "OPacketCapturer::next() - no packet received!" ); | 1149 | qWarning( "OPacketCapturer::next() - no packet received!" ); |
1125 | return 0; | 1150 | return 0; |
1126 | } | 1151 | } |
1127 | } | 1152 | } |
1128 | 1153 | ||
1129 | 1154 | ||
1130 | bool OPacketCapturer::open( const QString& name ) | 1155 | bool OPacketCapturer::open( const QString& name ) |
1131 | { | 1156 | { |
1132 | if ( _open ) | 1157 | if ( _open ) |
1133 | { | 1158 | { |
1134 | if ( name == _name ) // ignore opening an already openend device | 1159 | if ( name == _name ) // ignore opening an already openend device |
1135 | { | 1160 | { |
1136 | return true; | 1161 | return true; |
1137 | } | 1162 | } |
1138 | else // close the last opened device | 1163 | else // close the last opened device |
1139 | { | 1164 | { |
1140 | close(); | 1165 | close(); |
1141 | } | 1166 | } |
1142 | } | 1167 | } |
1143 | 1168 | ||
1144 | _name = name; | 1169 | _name = name; |
1145 | 1170 | ||
1146 | // open libpcap | 1171 | // open libpcap |
1147 | pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); | 1172 | pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); |
1148 | 1173 | ||
1149 | if ( !handle ) | 1174 | if ( !handle ) |
1150 | { | 1175 | { |
1151 | qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); | 1176 | qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); |
1152 | return false; | 1177 | return false; |
1153 | } | 1178 | } |
1154 | 1179 | ||
1155 | qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name ); | 1180 | qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name ); |
1156 | _pch = handle; | 1181 | _pch = handle; |
1157 | _open = true; | 1182 | _open = true; |
1158 | _stats.clear(); | 1183 | _stats.clear(); |
1159 | 1184 | ||
1160 | // in case we have an application object, create a socket notifier | 1185 | // in case we have an application object, create a socket notifier |
1161 | if ( qApp ) //TODO: I don't like this here... | 1186 | if ( qApp ) //TODO: I don't like this here... |
1162 | { | 1187 | { |
1163 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); | 1188 | _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); |
1164 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); | 1189 | connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); |
1165 | } | 1190 | } |
1166 | 1191 | ||
1167 | return true; | 1192 | return true; |
1168 | } | 1193 | } |
1169 | 1194 | ||
1170 | 1195 | ||
1171 | bool OPacketCapturer::openDumpFile( const QString& filename ) | 1196 | bool OPacketCapturer::openDumpFile( const QString& filename ) |
1172 | { | 1197 | { |
1173 | pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); | 1198 | pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); |
1174 | if ( !dump ) | 1199 | if ( !dump ) |
1175 | { | 1200 | { |
1176 | qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf ); | 1201 | qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf ); |
1177 | return false; | 1202 | return false; |
1178 | } | 1203 | } |
1179 | qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename ); | 1204 | qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename ); |
1180 | _pcd = dump; | 1205 | _pcd = dump; |
1181 | 1206 | ||
1182 | return true; | 1207 | return true; |
1183 | } | 1208 | } |
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 | |||
@@ -72,128 +72,133 @@ class QSocketNotifier; | |||
72 | * OPacket - A frame on the wire | 72 | * OPacket - A frame on the wire |
73 | *======================================================================================*/ | 73 | *======================================================================================*/ |
74 | 74 | ||
75 | /** @brief A class representing a data frame on the wire. | 75 | /** @brief A class representing a data frame on the wire. |
76 | * | 76 | * |
77 | * The whole family of the packet classes are used when capturing frames from a network. | 77 | * The whole family of the packet classes are used when capturing frames from a network. |
78 | * Most standard network protocols in use share a common architecture, which mostly is | 78 | * Most standard network protocols in use share a common architecture, which mostly is |
79 | * a packet header and then the packet payload. In layered architectures, each lower layer | 79 | * a packet header and then the packet payload. In layered architectures, each lower layer |
80 | * encapsulates data from its upper layer - that is it | 80 | * encapsulates data from its upper layer - that is it |
81 | * treats the data from its upper layer as payload and prepends an own header to the packet, | 81 | * treats the data from its upper layer as payload and prepends an own header to the packet, |
82 | * which - again - is treated as the payload for the layer below. The figure below is an | 82 | * which - again - is treated as the payload for the layer below. The figure below is an |
83 | * example for how such a data frame is composed out of packets, e.g. when sending a mail. | 83 | * example for how such a data frame is composed out of packets, e.g. when sending a mail. |
84 | * | 84 | * |
85 | * <pre> | 85 | * <pre> |
86 | * | User Data | == Mail Data | 86 | * | User Data | == Mail Data |
87 | * | SMTP Header | User Data | == SMTP | 87 | * | SMTP Header | User Data | == SMTP |
88 | * | TCP Header | SMTP Header | User Data | == TCP | 88 | * | TCP Header | SMTP Header | User Data | == TCP |
89 | * | IP Header | TCP Header | SMTP Header | User Data | == IP | 89 | * | IP Header | TCP Header | SMTP Header | User Data | == IP |
90 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC | 90 | * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC |
91 | * | 91 | * |
92 | * </pre> | 92 | * </pre> |
93 | * | 93 | * |
94 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer | 94 | * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer |
95 | * also contains a few more levels of encapsulation. | 95 | * also contains a few more levels of encapsulation. |
96 | * Since the type of the payload is more or less independent from the encapsulating protocol, | 96 | * Since the type of the payload is more or less independent from the encapsulating protocol, |
97 | * the header must be inspected before attempting to decode the payload. Hence, the | 97 | * the header must be inspected before attempting to decode the payload. Hence, the |
98 | * encapsulation level varies and can't be deduced without actually looking into the packets. | 98 | * encapsulation level varies and can't be deduced without actually looking into the packets. |
99 | * | 99 | * |
100 | * For actually working with captured frames, it's useful to identify the packets via names and | 100 | * For actually working with captured frames, it's useful to identify the packets via names and |
101 | * insert them into a parent/child - relationship based on the encapsulation. This is why | 101 | * insert them into a parent/child - relationship based on the encapsulation. This is why |
102 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is | 102 | * all packet classes derive from QObject. The amount of overhead caused by the QObject is |
103 | * not a problem in this case, because we're talking about a theoratical maximum of about | 103 | * not a problem in this case, because we're talking about a theoratical maximum of about |
104 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the | 104 | * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the |
105 | * QObject also cares about destroying the sub-, (child-) packets. | 105 | * QObject also cares about destroying the sub-, (child-) packets. |
106 | * | 106 | * |
107 | * This enables us to perform a simple look for packets of a certain type: | 107 | * This enables us to perform a simple look for packets of a certain type: |
108 | * @code | 108 | * @code |
109 | * OPacketCapturer* pcap = new OPacketCapturer(); | 109 | * OPacketCapturer* pcap = new OPacketCapturer(); |
110 | * pcap->open( "eth0" ); | 110 | * pcap->open( "eth0" ); |
111 | * OPacket* p = pcap->next(); | 111 | * OPacket* p = pcap->next(); |
112 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists | 112 | * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists |
113 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; | 113 | * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; |
114 | * | 114 | * |
115 | */ | 115 | */ |
116 | 116 | ||
117 | class OPacket : public QObject | 117 | class OPacket : public QObject |
118 | { | 118 | { |
119 | Q_OBJECT | 119 | Q_OBJECT |
120 | 120 | ||
121 | friend class OPacketCapturer; | 121 | friend class OPacketCapturer; |
122 | 122 | ||
123 | public: | 123 | public: |
124 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); | 124 | OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); |
125 | virtual ~OPacket(); | 125 | virtual ~OPacket(); |
126 | 126 | ||
127 | timevalstruct timeval() const; | 127 | timevalstruct timeval() const; |
128 | 128 | ||
129 | int caplen() const; | 129 | int caplen() const; |
130 | int len() const; | 130 | int len() const; |
131 | QString dump( int = 32 ) const; | 131 | QString dump( int = 32 ) const; |
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 | }; |
140 | 145 | ||
141 | /*====================================================================================== | 146 | /*====================================================================================== |
142 | * OEthernetPacket - DLT_EN10MB frame | 147 | * OEthernetPacket - DLT_EN10MB frame |
143 | *======================================================================================*/ | 148 | *======================================================================================*/ |
144 | 149 | ||
145 | class OEthernetPacket : public QObject | 150 | class OEthernetPacket : public QObject |
146 | { | 151 | { |
147 | Q_OBJECT | 152 | Q_OBJECT |
148 | 153 | ||
149 | public: | 154 | public: |
150 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); | 155 | OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); |
151 | virtual ~OEthernetPacket(); | 156 | virtual ~OEthernetPacket(); |
152 | 157 | ||
153 | OMacAddress sourceAddress() const; | 158 | OMacAddress sourceAddress() const; |
154 | OMacAddress destinationAddress() const; | 159 | OMacAddress destinationAddress() const; |
155 | int type() const; | 160 | int type() const; |
156 | 161 | ||
157 | private: | 162 | private: |
158 | const struct ether_header* _ether; | 163 | const struct ether_header* _ether; |
159 | }; | 164 | }; |
160 | 165 | ||
161 | /*====================================================================================== | 166 | /*====================================================================================== |
162 | * OPrismHeaderPacket - DLT_PRISM_HEADER frame | 167 | * OPrismHeaderPacket - DLT_PRISM_HEADER frame |
163 | *======================================================================================*/ | 168 | *======================================================================================*/ |
164 | 169 | ||
165 | class OPrismHeaderPacket : public QObject | 170 | class OPrismHeaderPacket : public QObject |
166 | { | 171 | { |
167 | Q_OBJECT | 172 | Q_OBJECT |
168 | 173 | ||
169 | public: | 174 | public: |
170 | OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); | 175 | OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); |
171 | virtual ~OPrismHeaderPacket(); | 176 | virtual ~OPrismHeaderPacket(); |
172 | 177 | ||
173 | unsigned int signalStrength() const; | 178 | unsigned int signalStrength() const; |
174 | 179 | ||
175 | private: | 180 | private: |
176 | const struct prism_hdr* _header; | 181 | const struct prism_hdr* _header; |
177 | }; | 182 | }; |
178 | 183 | ||
179 | /*====================================================================================== | 184 | /*====================================================================================== |
180 | * OWaveLanPacket - DLT_IEEE802_11 frame | 185 | * OWaveLanPacket - DLT_IEEE802_11 frame |
181 | *======================================================================================*/ | 186 | *======================================================================================*/ |
182 | 187 | ||
183 | class OWaveLanPacket : public QObject | 188 | class OWaveLanPacket : public QObject |
184 | { | 189 | { |
185 | Q_OBJECT | 190 | Q_OBJECT |
186 | 191 | ||
187 | public: | 192 | public: |
188 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); | 193 | OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); |
189 | virtual ~OWaveLanPacket(); | 194 | virtual ~OWaveLanPacket(); |
190 | 195 | ||
191 | int duration() const; | 196 | int duration() const; |
192 | bool fromDS() const; | 197 | bool fromDS() const; |
193 | bool toDS() const; | 198 | bool toDS() const; |
194 | virtual OMacAddress macAddress1() const; | 199 | virtual OMacAddress macAddress1() const; |
195 | virtual OMacAddress macAddress2() const; | 200 | virtual OMacAddress macAddress2() const; |
196 | virtual OMacAddress macAddress3() const; | 201 | virtual OMacAddress macAddress3() const; |
197 | virtual OMacAddress macAddress4() const; | 202 | virtual OMacAddress macAddress4() const; |
198 | bool usesPowerManagement() const; | 203 | bool usesPowerManagement() const; |
199 | int type() const; | 204 | int type() const; |