summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp2
-rw-r--r--libopie2/opienet/opcap.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 767651e..dc2e388 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -548,97 +548,97 @@ void OWirelessNetworkInterface::buildChannelList()
548} 548}
549 549
550 550
551void OWirelessNetworkInterface::buildPrivateList() 551void OWirelessNetworkInterface::buildPrivateList()
552{ 552{
553 qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); 553 qDebug( "OWirelessNetworkInterface::buildPrivateList()" );
554 554
555 struct iw_priv_args priv[IW_MAX_PRIV_DEF]; 555 struct iw_priv_args priv[IW_MAX_PRIV_DEF];
556 556
557 _iwr.u.data.pointer = (char*) &priv; 557 _iwr.u.data.pointer = (char*) &priv;
558 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself 558 _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself
559 _iwr.u.data.flags = 0; 559 _iwr.u.data.flags = 0;
560 560
561 if ( !wioctl( SIOCGIWPRIV ) ) 561 if ( !wioctl( SIOCGIWPRIV ) )
562 { 562 {
563 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); 563 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) );
564 return; 564 return;
565 } 565 }
566 566
567 for ( int i = 0; i < _iwr.u.data.length; ++i ) 567 for ( int i = 0; i < _iwr.u.data.length; ++i )
568 { 568 {
569 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); 569 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
570 } 570 }
571 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); 571 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." );
572} 572}
573 573
574 574
575int OWirelessNetworkInterface::channel() const 575int OWirelessNetworkInterface::channel() const
576{ 576{
577 //FIXME: When monitoring enabled, then use it 577 //FIXME: When monitoring enabled, then use it
578 //FIXME: to gather the current RF channel 578 //FIXME: to gather the current RF channel
579 //FIXME: Until then, get active channel from hopper. 579 //FIXME: Until then, get active channel from hopper.
580 if ( _hopper && _hopper->isActive() ) 580 if ( _hopper && _hopper->isActive() )
581 return _hopper->channel(); 581 return _hopper->channel();
582 582
583 if ( !wioctl( SIOCGIWFREQ ) ) 583 if ( !wioctl( SIOCGIWFREQ ) )
584 { 584 {
585 return -1; 585 return -1;
586 } 586 }
587 else 587 else
588 { 588 {
589 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; 589 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ];
590 } 590 }
591} 591}
592 592
593 593
594void OWirelessNetworkInterface::setChannel( int c ) const 594void OWirelessNetworkInterface::setChannel( int c ) const
595{ 595{
596 if ( c ) 596 if ( !c )
597 { 597 {
598 qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); 598 qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" );
599 return; 599 return;
600 } 600 }
601 601
602 if ( !_mon ) 602 if ( !_mon )
603 { 603 {
604 memset( &_iwr, 0, sizeof( struct iwreq ) ); 604 memset( &_iwr, 0, sizeof( struct iwreq ) );
605 _iwr.u.freq.m = c; 605 _iwr.u.freq.m = c;
606 _iwr.u.freq.e = 0; 606 _iwr.u.freq.e = 0;
607 wioctl( SIOCSIWFREQ ); 607 wioctl( SIOCSIWFREQ );
608 } 608 }
609 else 609 else
610 { 610 {
611 _mon->setChannel( c ); 611 _mon->setChannel( c );
612 } 612 }
613} 613}
614 614
615 615
616double OWirelessNetworkInterface::frequency() const 616double OWirelessNetworkInterface::frequency() const
617{ 617{
618 if ( !wioctl( SIOCGIWFREQ ) ) 618 if ( !wioctl( SIOCGIWFREQ ) )
619 { 619 {
620 return -1.0; 620 return -1.0;
621 } 621 }
622 else 622 else
623 { 623 {
624 return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; 624 return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0;
625 } 625 }
626} 626}
627 627
628 628
629int OWirelessNetworkInterface::channels() const 629int OWirelessNetworkInterface::channels() const
630{ 630{
631 return _channels.count(); 631 return _channels.count();
632} 632}
633 633
634 634
635void OWirelessNetworkInterface::setChannelHopping( int interval ) 635void OWirelessNetworkInterface::setChannelHopping( int interval )
636{ 636{
637 if ( !_hopper ) _hopper = new OChannelHopper( this ); 637 if ( !_hopper ) _hopper = new OChannelHopper( this );
638 _hopper->setInterval( interval ); 638 _hopper->setInterval( interval );
639 //FIXME: When and by whom will the channel hopper be deleted? 639 //FIXME: When and by whom will the channel hopper be deleted?
640 //TODO: rely on QObject hierarchy 640 //TODO: rely on QObject hierarchy
641} 641}
642 642
643 643
644int OWirelessNetworkInterface::channelHopping() const 644int OWirelessNetworkInterface::channelHopping() const
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 38ca1a1..6331b2d 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -1098,97 +1098,97 @@ void OPacketCapturer::close()
1098 1098
1099 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); 1099 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." );
1100 qDebug( "--------------------------------------------------" ); 1100 qDebug( "--------------------------------------------------" );
1101 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) 1101 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
1102 qDebug( "%s : %d", (const char*) it.key(), it.data() ); 1102 qDebug( "%s : %d", (const char*) it.key(), it.data() );
1103 qDebug( "--------------------------------------------------" ); 1103 qDebug( "--------------------------------------------------" );
1104 1104
1105} 1105}
1106 1106
1107 1107
1108int OPacketCapturer::dataLink() const 1108int OPacketCapturer::dataLink() const
1109{ 1109{
1110 return pcap_datalink( _pch ); 1110 return pcap_datalink( _pch );
1111} 1111}
1112 1112
1113 1113
1114void OPacketCapturer::dump( OPacket* p ) 1114void OPacketCapturer::dump( OPacket* p )
1115{ 1115{
1116 if ( !_pcd ) 1116 if ( !_pcd )
1117 { 1117 {
1118 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" ); 1118 qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" );
1119 return; 1119 return;
1120 } 1120 }
1121 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); 1121 pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data );
1122} 1122}
1123 1123
1124 1124
1125int OPacketCapturer::fileno() const 1125int OPacketCapturer::fileno() const
1126{ 1126{
1127 if ( _open ) 1127 if ( _open )
1128 { 1128 {
1129 return pcap_fileno( _pch ); 1129 return pcap_fileno( _pch );
1130 } 1130 }
1131 else 1131 else
1132 { 1132 {
1133 return -1; 1133 return -1;
1134 } 1134 }
1135} 1135}
1136 1136
1137 1137
1138OPacket* OPacketCapturer::next( int time ) 1138OPacket* OPacketCapturer::next( int time )
1139{ 1139{
1140 fd_set fds; 1140 fd_set fds;
1141 struct timeval tv; 1141 struct timeval tv;
1142 FD_ZERO( &fds ); 1142 FD_ZERO( &fds );
1143 FD_SET( pcap_fileno( _pch ), &fds ); 1143 FD_SET( pcap_fileno( _pch ), &fds );
1144 tv.tv_sec = time / 1000; 1144 tv.tv_sec = time / 1000;
1145 tv.tv_usec = time % 1000; 1145 tv.tv_usec = time % 1000;
1146 int retval = select( 1, &fds, NULL, NULL, &tv); 1146 int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv);
1147 if ( retval > 0 ) // clear to read! 1147 if ( retval > 0 ) // clear to read!
1148 return next(); 1148 return next();
1149 else 1149 else
1150 return 0; 1150 return 0;
1151} 1151}
1152 1152
1153 1153
1154OPacket* OPacketCapturer::next() 1154OPacket* OPacketCapturer::next()
1155{ 1155{
1156 packetheaderstruct header; 1156 packetheaderstruct header;
1157 qDebug( "==> OPacketCapturer::next()" ); 1157 qDebug( "==> OPacketCapturer::next()" );
1158 const unsigned char* pdata = pcap_next( _pch, &header ); 1158 const unsigned char* pdata = pcap_next( _pch, &header );
1159 qDebug( "<== OPacketCapturer::next()" ); 1159 qDebug( "<== OPacketCapturer::next()" );
1160 1160
1161 if ( pdata && header.len ) 1161 if ( pdata && header.len )
1162 { 1162 {
1163 OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); 1163 OPacket* p = new OPacket( dataLink(), header, pdata, 0 );
1164 // packets shouldn't be inserted in the QObject child-parent hierarchy, 1164 // packets shouldn't be inserted in the QObject child-parent hierarchy,
1165 // because due to memory constraints they will be deleted as soon 1165 // because due to memory constraints they will be deleted as soon
1166 // as possible - that is right after they have been processed 1166 // as possible - that is right after they have been processed
1167 // by emit() [ see below ] 1167 // by emit() [ see below ]
1168 //TODO: make gathering statistics optional, because it takes time 1168 //TODO: make gathering statistics optional, because it takes time
1169 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); 1169 p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) );
1170 #ifndef NODEBUG 1170 #ifndef NODEBUG
1171 p->dumpStructure( const_cast<QObjectList*>( p->children() ) ); 1171 p->dumpStructure( const_cast<QObjectList*>( p->children() ) );
1172 #endif 1172 #endif
1173 return p; 1173 return p;
1174 } 1174 }
1175 else 1175 else
1176 { 1176 {
1177 qWarning( "OPacketCapturer::next() - no packet received!" ); 1177 qWarning( "OPacketCapturer::next() - no packet received!" );
1178 return 0; 1178 return 0;
1179 } 1179 }
1180} 1180}
1181 1181
1182 1182
1183bool OPacketCapturer::open( const QString& name ) 1183bool OPacketCapturer::open( const QString& name )
1184{ 1184{
1185 if ( _open ) 1185 if ( _open )
1186 { 1186 {
1187 if ( name == _name ) // ignore opening an already openend device 1187 if ( name == _name ) // ignore opening an already openend device
1188 { 1188 {
1189 return true; 1189 return true;
1190 } 1190 }
1191 else // close the last opened device 1191 else // close the last opened device
1192 { 1192 {
1193 close(); 1193 close();
1194 } 1194 }