-rw-r--r-- | libopie2/opienet/onetwork.cpp | 11 | ||||
-rw-r--r-- | libopie2/opienet/ostation.cpp | 8 |
2 files changed, 11 insertions, 8 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index e141097..67718ba 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -416,388 +416,391 @@ bool OChannelHopper::isActive() const | |||
416 | int OChannelHopper::channel() const | 416 | int OChannelHopper::channel() const |
417 | { | 417 | { |
418 | return *_channel; | 418 | return *_channel; |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void OChannelHopper::timerEvent( QTimerEvent* ) | 422 | void OChannelHopper::timerEvent( QTimerEvent* ) |
423 | { | 423 | { |
424 | _iface->setChannel( *_channel ); | 424 | _iface->setChannel( *_channel ); |
425 | emit( hopped( *_channel ) ); | 425 | emit( hopped( *_channel ) ); |
426 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; | 426 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; |
427 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 427 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
428 | } | 428 | } |
429 | 429 | ||
430 | 430 | ||
431 | void OChannelHopper::setInterval( int interval ) | 431 | void OChannelHopper::setInterval( int interval ) |
432 | { | 432 | { |
433 | if ( interval == _interval ) | 433 | if ( interval == _interval ) |
434 | return; | 434 | return; |
435 | 435 | ||
436 | if ( _interval ) | 436 | if ( _interval ) |
437 | killTimer( _tid ); | 437 | killTimer( _tid ); |
438 | 438 | ||
439 | _tid = 0; | 439 | _tid = 0; |
440 | _interval = interval; | 440 | _interval = interval; |
441 | 441 | ||
442 | if ( _interval ) | 442 | if ( _interval ) |
443 | { | 443 | { |
444 | _tid = startTimer( interval ); | 444 | _tid = startTimer( interval ); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | 448 | ||
449 | int OChannelHopper::interval() const | 449 | int OChannelHopper::interval() const |
450 | { | 450 | { |
451 | return _interval; | 451 | return _interval; |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | /*====================================================================================== | 455 | /*====================================================================================== |
456 | * OWirelessNetworkInterface | 456 | * OWirelessNetworkInterface |
457 | *======================================================================================*/ | 457 | *======================================================================================*/ |
458 | 458 | ||
459 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 459 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
460 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 460 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
461 | { | 461 | { |
462 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; | 462 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; |
463 | init(); | 463 | init(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 467 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
468 | { | 468 | { |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | struct iwreq& OWirelessNetworkInterface::iwr() const | 472 | struct iwreq& OWirelessNetworkInterface::iwr() const |
473 | { | 473 | { |
474 | return _iwr; | 474 | return _iwr; |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | void OWirelessNetworkInterface::init() | 478 | void OWirelessNetworkInterface::init() |
479 | { | 479 | { |
480 | odebug << "OWirelessNetworkInterface::init()" << oendl; | 480 | odebug << "OWirelessNetworkInterface::init()" << oendl; |
481 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 481 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
482 | buildInformation(); | 482 | buildInformation(); |
483 | buildPrivateList(); | 483 | buildPrivateList(); |
484 | dumpInformation(); | 484 | dumpInformation(); |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | bool OWirelessNetworkInterface::isAssociated() const | 488 | bool OWirelessNetworkInterface::isAssociated() const |
489 | { | 489 | { |
490 | //FIXME: handle different modes | 490 | //FIXME: handle different modes |
491 | return !(associatedAP() == OMacAddress::unknown); | 491 | return !(associatedAP() == OMacAddress::unknown); |
492 | } | 492 | } |
493 | 493 | ||
494 | 494 | ||
495 | OMacAddress OWirelessNetworkInterface::associatedAP() const | 495 | OMacAddress OWirelessNetworkInterface::associatedAP() const |
496 | { | 496 | { |
497 | if ( ioctl( SIOCGIWAP ) ) | 497 | if ( ioctl( SIOCGIWAP ) ) |
498 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; | 498 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; |
499 | else | 499 | else |
500 | return OMacAddress::unknown; | 500 | return OMacAddress::unknown; |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | void OWirelessNetworkInterface::buildInformation() | 504 | void OWirelessNetworkInterface::buildInformation() |
505 | { | 505 | { |
506 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 506 | //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 | 507 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
508 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 508 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
509 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 509 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
510 | //ML: _too much_ space. This is damn shitty crap *sigh* | 510 | //ML: _too much_ space. This is damn shitty crap *sigh* |
511 | //ML: We allocate a large memory region in RAM and check whether the | 511 | //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, | 512 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
513 | //ML: so please forward this... | 513 | //ML: so please forward this... |
514 | 514 | ||
515 | struct iwreq wrq; | 515 | struct iwreq wrq; |
516 | int len = sizeof( struct iw_range )*2; | 516 | int len = sizeof( struct iw_range )*2; |
517 | char *buffer = (char*) malloc( len ); | 517 | char *buffer = (char*) malloc( len ); |
518 | //FIXME: Validate if we actually got the memory block | 518 | //FIXME: Validate if we actually got the memory block |
519 | memset( buffer, 0, len ); | 519 | memset( buffer, 0, len ); |
520 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 520 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
521 | wrq.u.data.pointer = (caddr_t) buffer; | 521 | wrq.u.data.pointer = (caddr_t) buffer; |
522 | wrq.u.data.length = sizeof( struct iw_range ); | 522 | wrq.u.data.length = sizeof( struct iw_range ); |
523 | wrq.u.data.flags = 0; | 523 | wrq.u.data.flags = 0; |
524 | 524 | ||
525 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 525 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) |
526 | { | 526 | { |
527 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl; | 527 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl; |
528 | _channels.insert( 2412, 1 ); // 2.412 GHz | 528 | _channels.insert( 2412, 1 ); // 2.412 GHz |
529 | _channels.insert( 2417, 2 ); // 2.417 GHz | 529 | _channels.insert( 2417, 2 ); // 2.417 GHz |
530 | _channels.insert( 2422, 3 ); // 2.422 GHz | 530 | _channels.insert( 2422, 3 ); // 2.422 GHz |
531 | _channels.insert( 2427, 4 ); // 2.427 GHz | 531 | _channels.insert( 2427, 4 ); // 2.427 GHz |
532 | _channels.insert( 2432, 5 ); // 2.432 GHz | 532 | _channels.insert( 2432, 5 ); // 2.432 GHz |
533 | _channels.insert( 2437, 6 ); // 2.437 GHz | 533 | _channels.insert( 2437, 6 ); // 2.437 GHz |
534 | _channels.insert( 2442, 7 ); // 2.442 GHz | 534 | _channels.insert( 2442, 7 ); // 2.442 GHz |
535 | _channels.insert( 2447, 8 ); // 2.447 GHz | 535 | _channels.insert( 2447, 8 ); // 2.447 GHz |
536 | _channels.insert( 2452, 9 ); // 2.452 GHz | 536 | _channels.insert( 2452, 9 ); // 2.452 GHz |
537 | _channels.insert( 2457, 10 ); // 2.457 GHz | 537 | _channels.insert( 2457, 10 ); // 2.457 GHz |
538 | _channels.insert( 2462, 11 ); // 2.462 GHz | 538 | _channels.insert( 2462, 11 ); // 2.462 GHz |
539 | 539 | ||
540 | memset( &_range, 0, sizeof( struct iw_range ) ); | 540 | memset( &_range, 0, sizeof( struct iw_range ) ); |
541 | } | 541 | } |
542 | else | 542 | else |
543 | { | 543 | { |
544 | // <check if the driver overwrites stuff> | 544 | // <check if the driver overwrites stuff> |
545 | int max = 0; | 545 | int max = 0; |
546 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 546 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
547 | if (buffer[r] != 0) | 547 | if (buffer[r] != 0) |
548 | max = r; | 548 | max = r; |
549 | if (max > 0) | 549 | if (max > 0) |
550 | { | 550 | { |
551 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() | 551 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() |
552 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; | 552 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; |
553 | } | 553 | } |
554 | // </check if the driver overwrites stuff> | 554 | // </check if the driver overwrites stuff> |
555 | 555 | ||
556 | struct iw_range range; | 556 | struct iw_range range; |
557 | memcpy( &range, buffer, sizeof range ); | 557 | memcpy( &range, buffer, sizeof range ); |
558 | 558 | ||
559 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; | 559 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; |
560 | for ( int i = 0; i < range.num_frequency; ++i ) | 560 | for ( int i = 0; i < range.num_frequency; ++i ) |
561 | { | 561 | { |
562 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 562 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
563 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; | 563 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; |
564 | _channels.insert( freq, i+1 ); | 564 | _channels.insert( freq, i+1 ); |
565 | } | 565 | } |
566 | } | 566 | } |
567 | 567 | ||
568 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); | 568 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); |
569 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; | 569 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; |
570 | free(buffer); | 570 | free(buffer); |
571 | } | 571 | } |
572 | 572 | ||
573 | 573 | ||
574 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const | 574 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const |
575 | { | 575 | { |
576 | return _range.we_version_compiled; | 576 | return _range.we_version_compiled; |
577 | } | 577 | } |
578 | 578 | ||
579 | 579 | ||
580 | void OWirelessNetworkInterface::buildPrivateList() | 580 | void OWirelessNetworkInterface::buildPrivateList() |
581 | { | 581 | { |
582 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; | 582 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; |
583 | 583 | ||
584 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 584 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
585 | 585 | ||
586 | _iwr.u.data.pointer = (char*) &priv; | 586 | _iwr.u.data.pointer = (char*) &priv; |
587 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 587 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself |
588 | _iwr.u.data.flags = 0; | 588 | _iwr.u.data.flags = 0; |
589 | 589 | ||
590 | if ( !wioctl( SIOCGIWPRIV ) ) | 590 | if ( !wioctl( SIOCGIWPRIV ) ) |
591 | { | 591 | { |
592 | owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information." << oendl; | 592 | owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information." << oendl; |
593 | return; | 593 | return; |
594 | } | 594 | } |
595 | 595 | ||
596 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 596 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
597 | { | 597 | { |
598 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 598 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
599 | } | 599 | } |
600 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; | 600 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; |
601 | } | 601 | } |
602 | 602 | ||
603 | 603 | ||
604 | void OWirelessNetworkInterface::dumpInformation() const | 604 | void OWirelessNetworkInterface::dumpInformation() const |
605 | { | 605 | { |
606 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; | 606 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; |
607 | 607 | ||
608 | qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", | 608 | odebug << " - driver's idea of maximum throughput is " << _range.throughput |
609 | _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); | 609 | << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 ) |
610 | qDebug( " - driver for '%s' (V%d) has been compiled against WE V%d", | 610 | << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ) |
611 | name(), _range.we_version_source, _range.we_version_compiled ); | 611 | << " Mb/s" << oendl; |
612 | |||
613 | odebug << " - driver for '" << name() << "' (V" << _range.we_version_source | ||
614 | << ") has been compiled against WE V" << _range.we_version_compiled << oendl; | ||
612 | 615 | ||
613 | if ( _range.we_version_compiled != WIRELESS_EXT ) | 616 | if ( _range.we_version_compiled != WIRELESS_EXT ) |
614 | { | 617 | { |
615 | owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; | 618 | owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; |
616 | } | 619 | } |
617 | 620 | ||
618 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; | 621 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; |
619 | } | 622 | } |
620 | 623 | ||
621 | 624 | ||
622 | int OWirelessNetworkInterface::channel() const | 625 | int OWirelessNetworkInterface::channel() const |
623 | { | 626 | { |
624 | //FIXME: When monitoring enabled, then use it | 627 | //FIXME: When monitoring enabled, then use it |
625 | //FIXME: to gather the current RF channel | 628 | //FIXME: to gather the current RF channel |
626 | //FIXME: Until then, get active channel from hopper. | 629 | //FIXME: Until then, get active channel from hopper. |
627 | if ( _hopper && _hopper->isActive() ) | 630 | if ( _hopper && _hopper->isActive() ) |
628 | return _hopper->channel(); | 631 | return _hopper->channel(); |
629 | 632 | ||
630 | if ( !wioctl( SIOCGIWFREQ ) ) | 633 | if ( !wioctl( SIOCGIWFREQ ) ) |
631 | { | 634 | { |
632 | return -1; | 635 | return -1; |
633 | } | 636 | } |
634 | else | 637 | else |
635 | { | 638 | { |
636 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 639 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
637 | } | 640 | } |
638 | } | 641 | } |
639 | 642 | ||
640 | 643 | ||
641 | void OWirelessNetworkInterface::setChannel( int c ) const | 644 | void OWirelessNetworkInterface::setChannel( int c ) const |
642 | { | 645 | { |
643 | if ( !c ) | 646 | if ( !c ) |
644 | { | 647 | { |
645 | oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; | 648 | oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; |
646 | return; | 649 | return; |
647 | } | 650 | } |
648 | 651 | ||
649 | if ( !_mon ) | 652 | if ( !_mon ) |
650 | { | 653 | { |
651 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 654 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
652 | _iwr.u.freq.m = c; | 655 | _iwr.u.freq.m = c; |
653 | _iwr.u.freq.e = 0; | 656 | _iwr.u.freq.e = 0; |
654 | wioctl( SIOCSIWFREQ ); | 657 | wioctl( SIOCSIWFREQ ); |
655 | } | 658 | } |
656 | else | 659 | else |
657 | { | 660 | { |
658 | _mon->setChannel( c ); | 661 | _mon->setChannel( c ); |
659 | } | 662 | } |
660 | } | 663 | } |
661 | 664 | ||
662 | 665 | ||
663 | double OWirelessNetworkInterface::frequency() const | 666 | double OWirelessNetworkInterface::frequency() const |
664 | { | 667 | { |
665 | if ( !wioctl( SIOCGIWFREQ ) ) | 668 | if ( !wioctl( SIOCGIWFREQ ) ) |
666 | { | 669 | { |
667 | return -1.0; | 670 | return -1.0; |
668 | } | 671 | } |
669 | else | 672 | else |
670 | { | 673 | { |
671 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 674 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
672 | } | 675 | } |
673 | } | 676 | } |
674 | 677 | ||
675 | 678 | ||
676 | int OWirelessNetworkInterface::channels() const | 679 | int OWirelessNetworkInterface::channels() const |
677 | { | 680 | { |
678 | return _channels.count(); | 681 | return _channels.count(); |
679 | } | 682 | } |
680 | 683 | ||
681 | 684 | ||
682 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 685 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
683 | { | 686 | { |
684 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 687 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
685 | _hopper->setInterval( interval ); | 688 | _hopper->setInterval( interval ); |
686 | //FIXME: When and by whom will the channel hopper be deleted? | 689 | //FIXME: When and by whom will the channel hopper be deleted? |
687 | //TODO: rely on QObject hierarchy | 690 | //TODO: rely on QObject hierarchy |
688 | } | 691 | } |
689 | 692 | ||
690 | 693 | ||
691 | int OWirelessNetworkInterface::channelHopping() const | 694 | int OWirelessNetworkInterface::channelHopping() const |
692 | { | 695 | { |
693 | return _hopper->interval(); | 696 | return _hopper->interval(); |
694 | } | 697 | } |
695 | 698 | ||
696 | 699 | ||
697 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | 700 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const |
698 | { | 701 | { |
699 | return _hopper; | 702 | return _hopper; |
700 | } | 703 | } |
701 | 704 | ||
702 | 705 | ||
703 | void OWirelessNetworkInterface::commit() const | 706 | void OWirelessNetworkInterface::commit() const |
704 | { | 707 | { |
705 | wioctl( SIOCSIWCOMMIT ); | 708 | wioctl( SIOCSIWCOMMIT ); |
706 | } | 709 | } |
707 | 710 | ||
708 | 711 | ||
709 | void OWirelessNetworkInterface::setMode( const QString& newMode ) | 712 | void OWirelessNetworkInterface::setMode( const QString& newMode ) |
710 | { | 713 | { |
711 | #ifdef FINALIZE | 714 | #ifdef FINALIZE |
712 | QString currentMode = mode(); | 715 | QString currentMode = mode(); |
713 | if ( currentMode == newMode ) return; | 716 | if ( currentMode == newMode ) return; |
714 | #endif | 717 | #endif |
715 | 718 | ||
716 | odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl; | 719 | odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl; |
717 | 720 | ||
718 | _iwr.u.mode = stringToMode( newMode ); | 721 | _iwr.u.mode = stringToMode( newMode ); |
719 | 722 | ||
720 | if ( _iwr.u.mode != IW_MODE_MONITOR ) | 723 | if ( _iwr.u.mode != IW_MODE_MONITOR ) |
721 | { | 724 | { |
722 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! | 725 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! |
723 | _iwr.u.mode = stringToMode( newMode ); | 726 | _iwr.u.mode = stringToMode( newMode ); |
724 | wioctl( SIOCSIWMODE ); | 727 | wioctl( SIOCSIWMODE ); |
725 | 728 | ||
726 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) | 729 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) |
727 | 730 | ||
728 | if ( mode() == "monitor" ) | 731 | if ( mode() == "monitor" ) |
729 | { | 732 | { |
730 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl; | 733 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl; |
731 | if ( _mon ) | 734 | if ( _mon ) |
732 | _mon->setEnabled( false ); | 735 | _mon->setEnabled( false ); |
733 | else | 736 | else |
734 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; | 737 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; |
735 | } | 738 | } |
736 | 739 | ||
737 | } | 740 | } |
738 | else // special iwpriv fallback for monitor mode | 741 | else // special iwpriv fallback for monitor mode |
739 | { | 742 | { |
740 | if ( wioctl( SIOCSIWMODE ) ) | 743 | if ( wioctl( SIOCSIWMODE ) ) |
741 | { | 744 | { |
742 | odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; | 745 | odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; |
743 | } | 746 | } |
744 | else | 747 | else |
745 | { | 748 | { |
746 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; | 749 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; |
747 | 750 | ||
748 | if ( _mon ) | 751 | if ( _mon ) |
749 | _mon->setEnabled( true ); | 752 | _mon->setEnabled( true ); |
750 | else | 753 | else |
751 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; | 754 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; |
752 | } | 755 | } |
753 | } | 756 | } |
754 | } | 757 | } |
755 | 758 | ||
756 | 759 | ||
757 | QString OWirelessNetworkInterface::mode() const | 760 | QString OWirelessNetworkInterface::mode() const |
758 | { | 761 | { |
759 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 762 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
760 | 763 | ||
761 | if ( !wioctl( SIOCGIWMODE ) ) | 764 | if ( !wioctl( SIOCGIWMODE ) ) |
762 | { | 765 | { |
763 | return "<unknown>"; | 766 | return "<unknown>"; |
764 | } | 767 | } |
765 | 768 | ||
766 | odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; | 769 | odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; |
767 | 770 | ||
768 | // legacy compatible monitor mode check | 771 | // legacy compatible monitor mode check |
769 | 772 | ||
770 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) | 773 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) |
771 | { | 774 | { |
772 | return "monitor"; | 775 | return "monitor"; |
773 | } | 776 | } |
774 | else | 777 | else |
775 | { | 778 | { |
776 | return modeToString( _iwr.u.mode ); | 779 | return modeToString( _iwr.u.mode ); |
777 | } | 780 | } |
778 | } | 781 | } |
779 | 782 | ||
780 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | 783 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) |
781 | { | 784 | { |
782 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); | 785 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); |
783 | _iwr.u.essid.length = nickname.length(); | 786 | _iwr.u.essid.length = nickname.length(); |
784 | wioctl( SIOCSIWNICKN ); | 787 | wioctl( SIOCSIWNICKN ); |
785 | } | 788 | } |
786 | 789 | ||
787 | 790 | ||
788 | QString OWirelessNetworkInterface::nickName() const | 791 | QString OWirelessNetworkInterface::nickName() const |
789 | { | 792 | { |
790 | char str[IW_ESSID_MAX_SIZE]; | 793 | char str[IW_ESSID_MAX_SIZE]; |
791 | _iwr.u.data.pointer = &str[0]; | 794 | _iwr.u.data.pointer = &str[0]; |
792 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 795 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
793 | if ( !wioctl( SIOCGIWNICKN ) ) | 796 | if ( !wioctl( SIOCGIWNICKN ) ) |
794 | { | 797 | { |
795 | return "<unknown>"; | 798 | return "<unknown>"; |
796 | } | 799 | } |
797 | else | 800 | else |
798 | { | 801 | { |
799 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 802 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
800 | return str; | 803 | return str; |
801 | } | 804 | } |
802 | } | 805 | } |
803 | 806 | ||
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp index ce0995b..b5ac325 100644 --- a/libopie2/opienet/ostation.cpp +++ b/libopie2/opienet/ostation.cpp | |||
@@ -1,72 +1,72 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <opie2/ostation.h> | 31 | #include <opie2/ostation.h> |
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | 33 | ||
34 | 34 | ||
35 | using namespace Opie::Core; | 35 | using namespace Opie::Core; |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | namespace Net { | 38 | namespace Net { |
39 | /*====================================================================================== | 39 | /*====================================================================================== |
40 | * OStation | 40 | * OStation |
41 | *======================================================================================*/ | 41 | *======================================================================================*/ |
42 | 42 | ||
43 | OStation::OStation() | 43 | OStation::OStation() |
44 | { | 44 | { |
45 | odebug << "OStation::OStation()" << oendl; | 45 | odebug << "OStation::OStation()" << oendl; |
46 | 46 | ||
47 | type = "<unknown>"; | 47 | type = "<unknown>"; |
48 | macAddress = OMacAddress::unknown; | 48 | macAddress = OMacAddress::unknown; |
49 | ssid = "<unknown>"; | 49 | ssid = "<unknown>"; |
50 | channel = 0; | 50 | channel = 0; |
51 | apAddress = OMacAddress::unknown; | 51 | apAddress = OMacAddress::unknown; |
52 | 52 | ||
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | OStation::~OStation() | 56 | OStation::~OStation() |
57 | { | 57 | { |
58 | odebug << "OStation::~OStation()" << oendl; | 58 | odebug << "OStation::~OStation()" << oendl; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void OStation::dump() | 62 | void OStation::dump() |
63 | { | 63 | { |
64 | odebug << "------- OStation::dump() ------------" << oendl; | 64 | odebug << "------- OStation::dump() ------------" << oendl; |
65 | qDebug( "type: %s", (const char*) type ); | 65 | odebug << "type: " << type << "" << oendl; |
66 | qDebug( "mac: %s", (const char*) macAddress.toString() ); | 66 | odebug << "mac: " << macAddress.toString() << "" << oendl; |
67 | qDebug( "ap: %s", (const char*) apAddress.toString() ); | 67 | odebug << "ap: " << apAddress.toString() << "" << oendl; |
68 | qDebug( "ip: %s", (const char*) ipAddress.toString() ); | 68 | odebug << "ip: " << ipAddress.toString() << "" << oendl; |
69 | } | 69 | } |
70 | 70 | ||
71 | } | 71 | } |
72 | } | 72 | } |