summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/802_11_user.h4
-rw-r--r--libopie2/opienet/opcap.cpp38
-rw-r--r--libopie2/opienet/opcap.h2
3 files changed, 30 insertions, 14 deletions
diff --git a/libopie2/opienet/802_11_user.h b/libopie2/opienet/802_11_user.h
index ad84514..7ae27c5 100644
--- a/libopie2/opienet/802_11_user.h
+++ b/libopie2/opienet/802_11_user.h
@@ -240,29 +240,29 @@ struct ieee_802_11_mgmt_header {
u_int8_t da[6];
u_int8_t sa[6];
u_int8_t bssid[6];
u_int16_t seq_ctrl;
};
struct ieee_802_11_data_header {
- u_int16_t frame_control;
+ u_int16_t fc;
u_int16_t duration;
u_int8_t mac1[6];
u_int8_t mac2[6];
u_int8_t mac3[6];
u_int16_t SeqCtl;
u_int8_t mac4[6];
// u_int16_t gapLen;
// u_int8_t gap[8];
};
struct ieee_802_11_control_header {
- u_int16_t frame_control;
+ u_int16_t fc;
u_int16_t duration;
u_int8_t mac1[6];
u_int8_t mac2[6];
u_int8_t mac3[6];
u_int16_t SeqCtl;
u_int8_t mac4[6];
// u_int16_t gapLen;
// u_int8_t gap[8];
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index e9b3b2c..012c0a3 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -233,18 +233,18 @@ int OEthernetPacket::type() const
*======================================================================================*/
OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
:QObject( parent, "IP" ), _iphdr( data )
{
odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl;
- odebug << "FromAddress = " << fromIPAddress().toString();
- odebug << " toAddress = " << toIPAddress().toString();
+ odebug << "FromAddress = " << fromIPAddress().toString() << oendl;
+ odebug << " toAddress = " << toIPAddress().toString() << oendl;
switch ( protocol() )
{
case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl;
}
@@ -334,17 +334,17 @@ QString OARPPacket::type() const
{
case 1: return "REQUEST";
case 2: return "REPLY";
case 3: return "RREQUEST";
case 4: return "RREPLY";
case 8: return "InREQUEST";
case 9: return "InREPLY";
case 10: return "NAK";
- default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>";
+ default: owarn << "OARPPacket::type(): invalid ARP type!" << oendl; return "<unknown>";
}
}
QHostAddress OARPPacket::senderIPV4Address() const
{
return EXTRACT_32BITS( &_arphdr->ar_sip );
}
@@ -488,17 +488,17 @@ QString ODHCPPacket::type() const
case 1: return "DISCOVER";
case 2: return "OFFER";
case 3: return "REQUEST";
case 4: return "DECLINE";
case 5: return "ACK";
case 6: return "NAK";
case 7: return "RELEASE";
case 8: return "INFORM";
- default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>";
+ default: owarn << "ODHCPPacket::type(): invalid DHCP type " << _dhcphdr->op << oendl; return "<unknown>";
}
}
QHostAddress ODHCPPacket::clientAddress() const
{
return EXTRACT_32BITS( &_dhcphdr->ciaddr );
}
@@ -760,19 +760,17 @@ QString OWaveLanManagementPacket::managementType() const
case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break;
case ST_PROBE_REQUEST: return "ProbeRequest"; break;
case ST_PROBE_RESPONSE: return "ProbeResponse"; break;
case ST_BEACON: return "Beacon"; break;
case ST_ATIM: return "Atim"; break;
case ST_DISASSOC: return "Disassociation"; break;
case ST_AUTH: return "Authentication"; break;
case ST_DEAUTH: return "Deathentication"; break;
- default:
- qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) );
- return "Unknown";
+ default: owarn << "OWaveLanManagementPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; return "Unknown";
}
}
int OWaveLanManagementPacket::beaconInterval() const
{
return EXTRACT_LE_16BITS( &_body->beacon_interval );
}
@@ -1006,32 +1004,48 @@ OLLCPacket::~OLLCPacket()
/*======================================================================================
* OWaveLanControlPacket
*======================================================================================*/
OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
:QObject( parent, "802.11 Control" ), _header( data )
{
odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl;
- //TODO: Implement this
+ odebug << "Detected subtype is " << controlType() << oendl;
}
OWaveLanControlPacket::~OWaveLanControlPacket()
{
}
+QString OWaveLanControlPacket::controlType() const
+{
+ switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) )
+ {
+ case CTRL_PS_POLL: return "PowerSavePoll"; break;
+ case CTRL_RTS: return "RequestToSend"; break;
+ case CTRL_CTS: return "ClearToSend"; break;
+ case CTRL_ACK: return "Acknowledge"; break;
+ case CTRL_CF_END: return "ContentionFreeEnd"; break;
+ case CTRL_END_ACK: return "AcknowledgeEnd"; break;
+ default:
+ owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl;
+ return "Unknown";
+ }
+}
+
+
/*======================================================================================
* OPacketCapturer
*======================================================================================*/
OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
- :QObject( parent, name ), _name( QString::null ), _open( false ),
- _pch( 0 ), _pcd( 0 ), _sn( 0 )
+ :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 )
{
}
OPacketCapturer::~OPacketCapturer()
{
if ( _open )
{
@@ -1104,17 +1118,17 @@ int OPacketCapturer::dataLink() const
return pcap_datalink( _pch );
}
void OPacketCapturer::dump( OPacket* p )
{
if ( !_pcd )
{
- qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" );
+ owarn << "OPacketCapturer::dump() - cannot dump without open capture file!" << oendl;
return;
}
pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data );
}
int OPacketCapturer::fileno() const
{
@@ -1163,17 +1177,17 @@ OPacket* OPacketCapturer::next()
p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
#ifndef NODEBUG
p->dumpStructure( const_cast<QObjectList*>( p->children() ) );
#endif
return p;
}
else
{
- qWarning( "OPacketCapturer::next() - no packet received!" );
+ owarn << "OPacketCapturer::next() - no packet received!" << oendl;
return 0;
}
}
bool OPacketCapturer::open( const QString& name )
{
if ( _open )
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 497fd6b..b373c56 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -392,16 +392,18 @@ class OWaveLanDataPacket : public QObject
class OWaveLanControlPacket : public QObject
{
Q_OBJECT
public:
OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 );
virtual ~OWaveLanControlPacket();
+ QString controlType() const;
+
private:
const struct ieee_802_11_control_header* _header;
};
/*======================================================================================
* OLLCPacket - IEEE 802.2 Link Level Control
*======================================================================================*/