Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 91 |
1 files changed, 40 insertions, 51 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index a85a510..50c6679 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -235,48 +235,49 @@ bool ONetworkInterface::isUp() const | |||
235 | return _ifr.ifr_flags & IFF_UP; | 235 | return _ifr.ifr_flags & IFF_UP; |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) | 239 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) |
240 | { | 240 | { |
241 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 241 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
242 | sa->sin_family = AF_INET; | 242 | sa->sin_family = AF_INET; |
243 | sa->sin_port = 0; | 243 | sa->sin_port = 0; |
244 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 244 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
245 | ioctl( SIOCSIFADDR ); | 245 | ioctl( SIOCSIFADDR ); |
246 | } | 246 | } |
247 | 247 | ||
248 | 248 | ||
249 | QString ONetworkInterface::ipV4Address() const | 249 | QString ONetworkInterface::ipV4Address() const |
250 | { | 250 | { |
251 | if ( ioctl( SIOCGIFADDR ) ) | 251 | if ( ioctl( SIOCGIFADDR ) ) |
252 | { | 252 | { |
253 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 253 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
254 | //FIXME: Use QHostAddress here | 254 | //FIXME: Use QHostAddress here |
255 | return QString( inet_ntoa( sa->sin_addr ) ); | 255 | return QString( inet_ntoa( sa->sin_addr ) ); |
256 | } | 256 | } |
257 | else | 257 | else |
258 | return "<unknown>"; | 258 | return "<unknown>"; |
259 | |||
259 | } | 260 | } |
260 | 261 | ||
261 | 262 | ||
262 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 263 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
263 | { | 264 | { |
264 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 265 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
265 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | 266 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); |
266 | ioctl( SIOCSIFHWADDR ); | 267 | ioctl( SIOCSIFHWADDR ); |
267 | } | 268 | } |
268 | 269 | ||
269 | 270 | ||
270 | OMacAddress ONetworkInterface::macAddress() const | 271 | OMacAddress ONetworkInterface::macAddress() const |
271 | { | 272 | { |
272 | if ( ioctl( SIOCGIFHWADDR ) ) | 273 | if ( ioctl( SIOCGIFHWADDR ) ) |
273 | { | 274 | { |
274 | return OMacAddress( _ifr ); | 275 | return OMacAddress( _ifr ); |
275 | } | 276 | } |
276 | else | 277 | else |
277 | { | 278 | { |
278 | return OMacAddress::unknown; | 279 | return OMacAddress::unknown; |
279 | } | 280 | } |
280 | } | 281 | } |
281 | 282 | ||
282 | 283 | ||
@@ -453,72 +454,58 @@ OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const cha | |||
453 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 454 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
454 | { | 455 | { |
455 | } | 456 | } |
456 | 457 | ||
457 | 458 | ||
458 | struct iwreq& OWirelessNetworkInterface::iwr() const | 459 | struct iwreq& OWirelessNetworkInterface::iwr() const |
459 | { | 460 | { |
460 | return _iwr; | 461 | return _iwr; |
461 | } | 462 | } |
462 | 463 | ||
463 | 464 | ||
464 | void OWirelessNetworkInterface::init() | 465 | void OWirelessNetworkInterface::init() |
465 | { | 466 | { |
466 | qDebug( "OWirelessNetworkInterface::init()" ); | 467 | qDebug( "OWirelessNetworkInterface::init()" ); |
467 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 468 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
468 | buildInformation(); | 469 | buildInformation(); |
469 | buildPrivateList(); | 470 | buildPrivateList(); |
470 | dumpInformation(); | 471 | dumpInformation(); |
471 | } | 472 | } |
472 | 473 | ||
473 | 474 | ||
474 | bool OWirelessNetworkInterface::isAssociated() const | 475 | bool OWirelessNetworkInterface::isAssociated() const |
475 | { | 476 | { |
476 | //FIXME: handle different modes | 477 | //FIXME: handle different modes |
477 | return associatedAP() != "44:44:44:44:44:44"; | 478 | return !(associatedAP() == OMacAddress::unknown); |
478 | } | 479 | } |
479 | 480 | ||
480 | 481 | ||
481 | QString OWirelessNetworkInterface::associatedAP() const | 482 | OMacAddress OWirelessNetworkInterface::associatedAP() const |
482 | { | 483 | { |
483 | //FIXME: use OMacAddress | ||
484 | QString mac; | ||
485 | |||
486 | if ( ioctl( SIOCGIWAP ) ) | 484 | if ( ioctl( SIOCGIWAP ) ) |
487 | { | 485 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; |
488 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | ||
489 | _ifr.ifr_hwaddr.sa_data[0]&0xff, | ||
490 | _ifr.ifr_hwaddr.sa_data[1]&0xff, | ||
491 | _ifr.ifr_hwaddr.sa_data[2]&0xff, | ||
492 | _ifr.ifr_hwaddr.sa_data[3]&0xff, | ||
493 | _ifr.ifr_hwaddr.sa_data[4]&0xff, | ||
494 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); | ||
495 | } | ||
496 | else | 486 | else |
497 | { | 487 | return OMacAddress::unknown; |
498 | mac = "<Unknown>"; | ||
499 | } | ||
500 | return mac; | ||
501 | } | 488 | } |
502 | 489 | ||
503 | 490 | ||
504 | void OWirelessNetworkInterface::buildInformation() | 491 | void OWirelessNetworkInterface::buildInformation() |
505 | { | 492 | { |
506 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 493 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
507 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 494 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
508 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 495 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
509 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 496 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
510 | //ML: _too much_ space. This is damn shitty crap *sigh* | 497 | //ML: _too much_ space. This is damn shitty crap *sigh* |
511 | //ML: We allocate a large memory region in RAM and check whether the | 498 | //ML: We allocate a large memory region in RAM and check whether the |
512 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 499 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
513 | //ML: so please forward this... | 500 | //ML: so please forward this... |
514 | 501 | ||
515 | struct iwreq wrq; | 502 | struct iwreq wrq; |
516 | int len = sizeof( struct iw_range )*2; | 503 | int len = sizeof( struct iw_range )*2; |
517 | char *buffer = (char*) malloc( len ); | 504 | char *buffer = (char*) malloc( len ); |
518 | //FIXME: Validate if we actually got the memory block | 505 | //FIXME: Validate if we actually got the memory block |
519 | memset( buffer, 0, len ); | 506 | memset( buffer, 0, len ); |
520 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 507 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
521 | wrq.u.data.pointer = (caddr_t) buffer; | 508 | wrq.u.data.pointer = (caddr_t) buffer; |
522 | wrq.u.data.length = sizeof( struct iw_range ); | 509 | wrq.u.data.length = sizeof( struct iw_range ); |
523 | wrq.u.data.flags = 0; | 510 | wrq.u.data.flags = 0; |
524 | 511 | ||
@@ -667,81 +654,60 @@ int OWirelessNetworkInterface::channels() const | |||
667 | 654 | ||
668 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 655 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
669 | { | 656 | { |
670 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 657 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
671 | _hopper->setInterval( interval ); | 658 | _hopper->setInterval( interval ); |
672 | //FIXME: When and by whom will the channel hopper be deleted? | 659 | //FIXME: When and by whom will the channel hopper be deleted? |
673 | //TODO: rely on QObject hierarchy | 660 | //TODO: rely on QObject hierarchy |
674 | } | 661 | } |
675 | 662 | ||
676 | 663 | ||
677 | int OWirelessNetworkInterface::channelHopping() const | 664 | int OWirelessNetworkInterface::channelHopping() const |
678 | { | 665 | { |
679 | return _hopper->interval(); | 666 | return _hopper->interval(); |
680 | } | 667 | } |
681 | 668 | ||
682 | 669 | ||
683 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | 670 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const |
684 | { | 671 | { |
685 | return _hopper; | 672 | return _hopper; |
686 | } | 673 | } |
687 | 674 | ||
688 | 675 | ||
689 | void OWirelessNetworkInterface::setMode( const QString& mode ) | 676 | void OWirelessNetworkInterface::setMode( const QString& mode ) |
690 | { | 677 | { |
691 | if ( mode == "auto" ) _iwr.u.mode = IW_MODE_AUTO; | 678 | _iwr.u.mode = stringToMode( mode ); |
692 | else if ( mode == "adhoc" ) _iwr.u.mode = IW_MODE_ADHOC; | ||
693 | else if ( mode == "managed" ) _iwr.u.mode = IW_MODE_INFRA; | ||
694 | else if ( mode == "master" ) _iwr.u.mode = IW_MODE_MASTER; | ||
695 | else if ( mode == "repeater" ) _iwr.u.mode = IW_MODE_REPEAT; | ||
696 | else if ( mode == "secondary" ) _iwr.u.mode = IW_MODE_SECOND; | ||
697 | else if ( mode == "monitor" ) _iwr.u.mode = IW_MODE_MONITOR; | ||
698 | else | ||
699 | { | ||
700 | qDebug( "ONetwork: Warning! Invalid IEEE 802.11 mode '%s' specified.", (const char*) mode ); | ||
701 | return; | ||
702 | } | ||
703 | wioctl( SIOCSIWMODE ); | 679 | wioctl( SIOCSIWMODE ); |
704 | } | 680 | } |
705 | 681 | ||
706 | 682 | ||
707 | QString OWirelessNetworkInterface::mode() const | 683 | QString OWirelessNetworkInterface::mode() const |
708 | { | 684 | { |
709 | if ( !wioctl( SIOCGIWMODE ) ) | 685 | if ( !wioctl( SIOCGIWMODE ) ) |
710 | { | 686 | { |
711 | return "<unknown>"; | 687 | return "<unknown>"; |
712 | } | 688 | } |
713 | switch ( _iwr.u.mode ) | 689 | return modeToString( _iwr.u.mode ); |
714 | { | ||
715 | case IW_MODE_AUTO: return "auto"; | ||
716 | case IW_MODE_ADHOC: return "adhoc"; | ||
717 | case IW_MODE_INFRA: return "managed"; | ||
718 | case IW_MODE_MASTER: return "master"; | ||
719 | case IW_MODE_REPEAT: return "repeater"; | ||
720 | case IW_MODE_SECOND: return "secondary"; | ||
721 | case IW_MODE_MONITOR: return "monitor"; | ||
722 | default: assert( 0 ); // shouldn't happen | ||
723 | } | ||
724 | } | 690 | } |
725 | 691 | ||
726 | 692 | ||
727 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 693 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
728 | { | 694 | { |
729 | if ( _mon ) | 695 | if ( _mon ) |
730 | _mon->setEnabled( b ); | 696 | _mon->setEnabled( b ); |
731 | else | 697 | else |
732 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 698 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
733 | } | 699 | } |
734 | 700 | ||
735 | 701 | ||
736 | bool OWirelessNetworkInterface::monitorMode() const | 702 | bool OWirelessNetworkInterface::monitorMode() const |
737 | { | 703 | { |
738 | qDebug( "dataLinkType = %d", dataLinkType() ); | 704 | qDebug( "dataLinkType = %d", dataLinkType() ); |
739 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); | 705 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); |
740 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... | 706 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... |
741 | //FIXME: What is 119, by the way? | 707 | //FIXME: What is 119, by the way? |
742 | } | 708 | } |
743 | 709 | ||
744 | 710 | ||
745 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | 711 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) |
746 | { | 712 | { |
747 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); | 713 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); |
@@ -809,147 +775,170 @@ bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | |||
809 | QString OWirelessNetworkInterface::SSID() const | 775 | QString OWirelessNetworkInterface::SSID() const |
810 | { | 776 | { |
811 | char str[IW_ESSID_MAX_SIZE]; | 777 | char str[IW_ESSID_MAX_SIZE]; |
812 | _iwr.u.essid.pointer = &str[0]; | 778 | _iwr.u.essid.pointer = &str[0]; |
813 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 779 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
814 | if ( !wioctl( SIOCGIWESSID ) ) | 780 | if ( !wioctl( SIOCGIWESSID ) ) |
815 | { | 781 | { |
816 | return "<unknown>"; | 782 | return "<unknown>"; |
817 | } | 783 | } |
818 | else | 784 | else |
819 | { | 785 | { |
820 | return str; | 786 | return str; |
821 | } | 787 | } |
822 | } | 788 | } |
823 | 789 | ||
824 | 790 | ||
825 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 791 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
826 | { | 792 | { |
827 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 793 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
828 | _iwr.u.essid.length = ssid.length(); | 794 | _iwr.u.essid.length = ssid.length(); |
829 | wioctl( SIOCSIWESSID ); | 795 | wioctl( SIOCSIWESSID ); |
830 | } | 796 | } |
831 | 797 | ||
832 | 798 | ||
833 | int OWirelessNetworkInterface::scanNetwork() | 799 | OStationList* OWirelessNetworkInterface::scanNetwork() |
834 | { | 800 | { |
835 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 801 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
836 | _iwr.u.param.value = 0; | 802 | _iwr.u.param.value = 0; |
837 | if ( !wioctl( SIOCSIWSCAN ) ) | 803 | if ( !wioctl( SIOCSIWSCAN ) ) |
838 | { | 804 | { |
839 | return -1; | 805 | return 0; |
840 | } | 806 | } |
841 | 807 | ||
808 | OStationList* stations = new OStationList(); | ||
809 | |||
842 | int timeout = 1000000; | 810 | int timeout = 1000000; |
843 | 811 | ||
844 | qDebug( "ONetworkInterface::scanNetwork() - scan started." ); | 812 | qDebug( "ONetworkInterface::scanNetwork() - scan started." ); |
845 | 813 | ||
846 | bool results = false; | 814 | bool results = false; |
847 | struct timeval tv; | 815 | struct timeval tv; |
848 | tv.tv_sec = 0; | 816 | tv.tv_sec = 0; |
849 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 817 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
850 | char buffer[IW_SCAN_MAX_DATA]; | 818 | char buffer[IW_SCAN_MAX_DATA]; |
851 | 819 | ||
852 | while ( !results && timeout > 0 ) | 820 | while ( !results && timeout > 0 ) |
853 | { | 821 | { |
854 | timeout -= tv.tv_usec; | 822 | timeout -= tv.tv_usec; |
855 | select( 0, 0, 0, 0, &tv ); | 823 | select( 0, 0, 0, 0, &tv ); |
856 | 824 | ||
857 | _iwr.u.data.pointer = &buffer[0]; | 825 | _iwr.u.data.pointer = &buffer[0]; |
858 | _iwr.u.data.flags = 0; | 826 | _iwr.u.data.flags = 0; |
859 | _iwr.u.data.length = sizeof buffer; | 827 | _iwr.u.data.length = sizeof buffer; |
860 | if ( wioctl( SIOCGIWSCAN ) ) | 828 | if ( wioctl( SIOCGIWSCAN ) ) |
861 | { | 829 | { |
862 | results = true; | 830 | results = true; |
863 | continue; | 831 | continue; |
864 | } | 832 | } |
865 | else if ( errno == EAGAIN) | 833 | else if ( errno == EAGAIN) |
866 | { | 834 | { |
867 | qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); | 835 | qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); |
868 | #if 0 | 836 | #if 0 |
869 | if ( qApp ) | 837 | if ( qApp ) |
870 | { | 838 | { |
871 | qApp->processEvents( 100 ); | 839 | qApp->processEvents( 100 ); |
872 | continue; | 840 | continue; |
873 | } | 841 | } |
874 | #endif | 842 | #endif |
875 | tv.tv_sec = 0; | 843 | tv.tv_sec = 0; |
876 | tv.tv_usec = 100000; | 844 | tv.tv_usec = 100000; |
877 | continue; | 845 | continue; |
878 | } | 846 | } |
879 | } | 847 | } |
880 | 848 | ||
881 | qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); | 849 | qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); |
882 | 850 | ||
883 | if ( results ) | 851 | if ( results ) |
884 | { | 852 | { |
885 | qDebug( " - result length = %d", _iwr.u.data.length ); | 853 | qDebug( " - result length = %d", _iwr.u.data.length ); |
886 | if ( !_iwr.u.data.length ) | 854 | if ( !_iwr.u.data.length ) |
887 | { | 855 | { |
888 | qDebug( " - no results (empty neighbourhood)" ); | 856 | qDebug( " - no results (empty neighbourhood)" ); |
889 | return 0; | 857 | return stations; |
890 | } | 858 | } |
891 | 859 | ||
892 | qDebug( " - results are in!" ); | 860 | qDebug( " - results are in!" ); |
893 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); | 861 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); |
894 | 862 | ||
895 | int stations = 0; | ||
896 | |||
897 | // parse results | 863 | // parse results |
898 | 864 | ||
899 | int offset = 0; | 865 | int offset = 0; |
900 | struct iw_event* we = (struct iw_event*) &buffer[0]; | 866 | struct iw_event* we = (struct iw_event*) &buffer[0]; |
901 | 867 | ||
902 | while ( offset < _iwr.u.data.length ) | 868 | while ( offset < _iwr.u.data.length ) |
903 | { | 869 | { |
904 | //const char* cmd = *(*_ioctlmap)[we->cmd]; | 870 | //const char* cmd = *(*_ioctlmap)[we->cmd]; |
905 | //if ( !cmd ) cmd = "<unknown>"; | 871 | //if ( !cmd ) cmd = "<unknown>"; |
906 | qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); | 872 | qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); |
907 | switch (we->cmd) | 873 | switch (we->cmd) |
908 | { | 874 | { |
909 | case SIOCGIWAP: qDebug( "SIOCGIWAP" ); stations++; break; | 875 | case SIOCGIWAP: |
910 | case SIOCGIWMODE: qDebug( "SIOCGIWMODE" ); break; | 876 | { |
911 | case SIOCGIWFREQ: qDebug( "SIOCGIWFREQ" ); break; | 877 | qDebug( "SIOCGIWAP" ); |
912 | case SIOCGIWESSID: qDebug( "SIOCGIWESSID" ); break; | 878 | stations->append( new OStation() ); |
879 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; | ||
880 | break; | ||
881 | } | ||
882 | case SIOCGIWMODE: | ||
883 | { | ||
884 | qDebug( "SIOCGIWMODE" ); | ||
885 | stations->last()->type = modeToString( we->u.mode ); | ||
886 | break; | ||
887 | } | ||
888 | case SIOCGIWFREQ: | ||
889 | { | ||
890 | qDebug( "SIOCGIWFREQ" ); | ||
891 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; | ||
892 | break; | ||
893 | } | ||
894 | case SIOCGIWESSID: | ||
895 | { | ||
896 | qDebug( "SIOCGIWESSID" ); | ||
897 | stations->last()->ssid = we->u.essid.pointer; | ||
898 | break; | ||
899 | } | ||
913 | case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; | 900 | case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; |
914 | case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; | 901 | case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; |
915 | case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ | 902 | case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ |
916 | case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ | 903 | case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ |
917 | case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ | 904 | case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ |
918 | case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ | 905 | case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ |
919 | case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ | 906 | case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ |
920 | default: qDebug( "unhandled event" ); | 907 | default: qDebug( "unhandled event" ); |
921 | } | 908 | } |
922 | 909 | ||
923 | offset += we->len; | 910 | offset += we->len; |
924 | we = (struct iw_event*) &buffer[offset]; | 911 | we = (struct iw_event*) &buffer[offset]; |
925 | } | 912 | } |
926 | 913 | ||
914 | return stations; | ||
915 | |||
927 | } | 916 | } |
928 | else | 917 | else |
929 | { | 918 | { |
930 | qDebug( " - no results (timeout) :(" ); | 919 | qDebug( " - no results (timeout) :(" ); |
931 | return 0; | 920 | return stations; |
932 | } | 921 | } |
933 | } | 922 | } |
934 | 923 | ||
935 | 924 | ||
936 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 925 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
937 | { | 926 | { |
938 | #ifndef NODEBUG | 927 | #ifndef NODEBUG |
939 | int result = ::ioctl( _sfd, call, &iwreq ); | 928 | int result = ::ioctl( _sfd, call, &iwreq ); |
940 | if ( result == -1 ) | 929 | if ( result == -1 ) |
941 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); | 930 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); |
942 | else | 931 | else |
943 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); | 932 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); |
944 | return ( result != -1 ); | 933 | return ( result != -1 ); |
945 | #else | 934 | #else |
946 | return ::ioctl( _sfd, call, &iwreq ) != -1; | 935 | return ::ioctl( _sfd, call, &iwreq ) != -1; |
947 | #endif | 936 | #endif |
948 | } | 937 | } |
949 | 938 | ||
950 | 939 | ||
951 | bool OWirelessNetworkInterface::wioctl( int call ) const | 940 | bool OWirelessNetworkInterface::wioctl( int call ) const |
952 | { | 941 | { |
953 | strcpy( _iwr.ifr_name, name() ); | 942 | strcpy( _iwr.ifr_name, name() ); |
954 | return wioctl( call, _iwr ); | 943 | return wioctl( call, _iwr ); |
955 | } | 944 | } |