-rw-r--r-- | libopie2/opienet/onetwork.cpp | 38 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 3 | ||||
-rw-r--r-- | libopie2/opienet/ostation.h | 2 |
3 files changed, 38 insertions, 5 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 546be9e..0a74019 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,151 +1,153 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003-2005 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; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
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 | /* OPIE */ | 31 | /* OPIE */ |
32 | 32 | ||
33 | #include <opie2/onetwork.h> | 33 | #include <opie2/onetwork.h> |
34 | #include <opie2/ostation.h> | 34 | #include <opie2/ostation.h> |
35 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | 38 | ||
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qapplication.h> | ||
41 | 42 | ||
42 | /* UNIX */ | 43 | /* UNIX */ |
43 | 44 | ||
44 | #include <assert.h> | 45 | #include <assert.h> |
45 | #include <arpa/inet.h> | 46 | #include <arpa/inet.h> |
46 | #include <errno.h> | 47 | #include <errno.h> |
47 | #include <string.h> | 48 | #include <string.h> |
48 | #include <stdlib.h> | 49 | #include <stdlib.h> |
49 | #include <math.h> | 50 | #include <math.h> |
50 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
51 | #include <sys/socket.h> | 52 | #include <sys/socket.h> |
52 | #include <sys/types.h> | 53 | #include <sys/types.h> |
53 | #include <unistd.h> | 54 | #include <unistd.h> |
54 | #include <linux/sockios.h> | 55 | #include <linux/sockios.h> |
55 | #include <net/if_arp.h> | 56 | #include <net/if_arp.h> |
57 | #include <net/ethernet.h> | ||
56 | #include <stdarg.h> | 58 | #include <stdarg.h> |
57 | 59 | ||
58 | #ifndef NODEBUG | 60 | #ifndef NODEBUG |
59 | #include <opie2/odebugmapper.h> | 61 | #include <opie2/odebugmapper.h> |
60 | 62 | ||
61 | using namespace Opie::Core; | 63 | using namespace Opie::Core; |
62 | using namespace Opie::Net::Internal; | 64 | using namespace Opie::Net::Internal; |
63 | DebugMapper* debugmapper = new DebugMapper(); | 65 | DebugMapper* debugmapper = new DebugMapper(); |
64 | #endif | 66 | #endif |
65 | 67 | ||
66 | /*====================================================================================== | 68 | /*====================================================================================== |
67 | * ONetwork | 69 | * ONetwork |
68 | *======================================================================================*/ | 70 | *======================================================================================*/ |
69 | 71 | ||
70 | namespace Opie { | 72 | namespace Opie { |
71 | namespace Net { | 73 | namespace Net { |
72 | ONetwork* ONetwork::_instance = 0; | 74 | ONetwork* ONetwork::_instance = 0; |
73 | 75 | ||
74 | ONetwork::ONetwork() | 76 | ONetwork::ONetwork() |
75 | { | 77 | { |
76 | odebug << "ONetwork::ONetwork()" << oendl; | 78 | odebug << "ONetwork::ONetwork()" << oendl; |
77 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; | 79 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; |
78 | synchronize(); | 80 | synchronize(); |
79 | } | 81 | } |
80 | 82 | ||
81 | void ONetwork::synchronize() | 83 | void ONetwork::synchronize() |
82 | { | 84 | { |
83 | // gather available interfaces by inspecting /proc/net/dev | 85 | // gather available interfaces by inspecting /proc/net/dev |
84 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 86 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
85 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 87 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
86 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev | 88 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev |
87 | 89 | ||
88 | _interfaces.clear(); | 90 | _interfaces.clear(); |
89 | QString str; | 91 | QString str; |
90 | QFile f( "/proc/net/dev" ); | 92 | QFile f( "/proc/net/dev" ); |
91 | bool hasFile = f.open( IO_ReadOnly ); | 93 | bool hasFile = f.open( IO_ReadOnly ); |
92 | if ( !hasFile ) | 94 | if ( !hasFile ) |
93 | { | 95 | { |
94 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; | 96 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; |
95 | return; | 97 | return; |
96 | } | 98 | } |
97 | QTextStream s( &f ); | 99 | QTextStream s( &f ); |
98 | s.readLine(); | 100 | s.readLine(); |
99 | s.readLine(); | 101 | s.readLine(); |
100 | while ( !s.atEnd() ) | 102 | while ( !s.atEnd() ) |
101 | { | 103 | { |
102 | s >> str; | 104 | s >> str; |
103 | str.truncate( str.find( ':' ) ); | 105 | str.truncate( str.find( ':' ) ); |
104 | odebug << "ONetwork: found interface '" << str << "'" << oendl; | 106 | odebug << "ONetwork: found interface '" << str << "'" << oendl; |
105 | ONetworkInterface* iface = 0; | 107 | ONetworkInterface* iface = 0; |
106 | if ( isWirelessInterface( str ) ) | 108 | if ( isWirelessInterface( str ) ) |
107 | { | 109 | { |
108 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 110 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
109 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; | 111 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; |
110 | } | 112 | } |
111 | else | 113 | else |
112 | { | 114 | { |
113 | iface = new ONetworkInterface( this, (const char*) str ); | 115 | iface = new ONetworkInterface( this, (const char*) str ); |
114 | } | 116 | } |
115 | _interfaces.insert( str, iface ); | 117 | _interfaces.insert( str, iface ); |
116 | s.readLine(); | 118 | s.readLine(); |
117 | } | 119 | } |
118 | } | 120 | } |
119 | 121 | ||
120 | 122 | ||
121 | short ONetwork::wirelessExtensionCompileVersion() | 123 | short ONetwork::wirelessExtensionCompileVersion() |
122 | { | 124 | { |
123 | return WIRELESS_EXT; | 125 | return WIRELESS_EXT; |
124 | } | 126 | } |
125 | 127 | ||
126 | 128 | ||
127 | int ONetwork::count() const | 129 | int ONetwork::count() const |
128 | { | 130 | { |
129 | return _interfaces.count(); | 131 | return _interfaces.count(); |
130 | } | 132 | } |
131 | 133 | ||
132 | 134 | ||
133 | ONetworkInterface* ONetwork::interface( const QString& iface ) const | 135 | ONetworkInterface* ONetwork::interface( const QString& iface ) const |
134 | { | 136 | { |
135 | return _interfaces[iface]; | 137 | return _interfaces[iface]; |
136 | } | 138 | } |
137 | 139 | ||
138 | 140 | ||
139 | ONetwork* ONetwork::instance() | 141 | ONetwork* ONetwork::instance() |
140 | { | 142 | { |
141 | if ( !_instance ) _instance = new ONetwork(); | 143 | if ( !_instance ) _instance = new ONetwork(); |
142 | return _instance; | 144 | return _instance; |
143 | } | 145 | } |
144 | 146 | ||
145 | 147 | ||
146 | ONetwork::InterfaceIterator ONetwork::iterator() const | 148 | ONetwork::InterfaceIterator ONetwork::iterator() const |
147 | { | 149 | { |
148 | return ONetwork::InterfaceIterator( _interfaces ); | 150 | return ONetwork::InterfaceIterator( _interfaces ); |
149 | } | 151 | } |
150 | 152 | ||
151 | 153 | ||
@@ -398,192 +400,200 @@ OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | |||
398 | if ( _maxChannel >= 6 ) _channels.append( 6 ); | 400 | if ( _maxChannel >= 6 ) _channels.append( 6 ); |
399 | if ( _maxChannel >= 12 ) _channels.append( 12 ); | 401 | if ( _maxChannel >= 12 ) _channels.append( 12 ); |
400 | _channel = _channels.begin(); | 402 | _channel = _channels.begin(); |
401 | } | 403 | } |
402 | 404 | ||
403 | 405 | ||
404 | OChannelHopper::~OChannelHopper() | 406 | OChannelHopper::~OChannelHopper() |
405 | { | 407 | { |
406 | } | 408 | } |
407 | 409 | ||
408 | 410 | ||
409 | bool OChannelHopper::isActive() const | 411 | bool OChannelHopper::isActive() const |
410 | { | 412 | { |
411 | return _tid; | 413 | return _tid; |
412 | } | 414 | } |
413 | 415 | ||
414 | 416 | ||
415 | int OChannelHopper::channel() const | 417 | int OChannelHopper::channel() const |
416 | { | 418 | { |
417 | return *_channel; | 419 | return *_channel; |
418 | } | 420 | } |
419 | 421 | ||
420 | 422 | ||
421 | void OChannelHopper::timerEvent( QTimerEvent* ) | 423 | void OChannelHopper::timerEvent( QTimerEvent* ) |
422 | { | 424 | { |
423 | _iface->setChannel( *_channel ); | 425 | _iface->setChannel( *_channel ); |
424 | emit( hopped( *_channel ) ); | 426 | emit( hopped( *_channel ) ); |
425 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; | 427 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; |
426 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 428 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
427 | } | 429 | } |
428 | 430 | ||
429 | 431 | ||
430 | void OChannelHopper::setInterval( int interval ) | 432 | void OChannelHopper::setInterval( int interval ) |
431 | { | 433 | { |
432 | if ( interval == _interval ) | 434 | if ( interval == _interval ) |
433 | return; | 435 | return; |
434 | 436 | ||
435 | if ( _interval ) | 437 | if ( _interval ) |
436 | killTimer( _tid ); | 438 | killTimer( _tid ); |
437 | 439 | ||
438 | _tid = 0; | 440 | _tid = 0; |
439 | _interval = interval; | 441 | _interval = interval; |
440 | 442 | ||
441 | if ( _interval ) | 443 | if ( _interval ) |
442 | { | 444 | { |
443 | _tid = startTimer( interval ); | 445 | _tid = startTimer( interval ); |
444 | } | 446 | } |
445 | } | 447 | } |
446 | 448 | ||
447 | 449 | ||
448 | int OChannelHopper::interval() const | 450 | int OChannelHopper::interval() const |
449 | { | 451 | { |
450 | return _interval; | 452 | return _interval; |
451 | } | 453 | } |
452 | 454 | ||
453 | 455 | ||
454 | /*====================================================================================== | 456 | /*====================================================================================== |
455 | * OWirelessNetworkInterface | 457 | * OWirelessNetworkInterface |
456 | *======================================================================================*/ | 458 | *======================================================================================*/ |
457 | 459 | ||
458 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 460 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
459 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 461 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
460 | { | 462 | { |
461 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; | 463 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; |
462 | init(); | 464 | init(); |
463 | } | 465 | } |
464 | 466 | ||
465 | 467 | ||
466 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 468 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
467 | { | 469 | { |
468 | } | 470 | } |
469 | 471 | ||
470 | 472 | ||
471 | struct iwreq& OWirelessNetworkInterface::iwr() const | 473 | struct iwreq& OWirelessNetworkInterface::iwr() const |
472 | { | 474 | { |
473 | return _iwr; | 475 | return _iwr; |
474 | } | 476 | } |
475 | 477 | ||
476 | 478 | ||
477 | void OWirelessNetworkInterface::init() | 479 | void OWirelessNetworkInterface::init() |
478 | { | 480 | { |
479 | odebug << "OWirelessNetworkInterface::init()" << oendl; | 481 | odebug << "OWirelessNetworkInterface::init()" << oendl; |
480 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 482 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
481 | buildInformation(); | 483 | buildInformation(); |
482 | buildPrivateList(); | 484 | buildPrivateList(); |
483 | dumpInformation(); | 485 | dumpInformation(); |
484 | } | 486 | } |
485 | 487 | ||
486 | 488 | ||
487 | bool OWirelessNetworkInterface::isAssociated() const | 489 | bool OWirelessNetworkInterface::isAssociated() const |
488 | { | 490 | { |
489 | //FIXME: handle different modes | 491 | //FIXME: handle different modes |
490 | return !(associatedAP() == OMacAddress::unknown); | 492 | return !(associatedAP() == OMacAddress::unknown); |
491 | } | 493 | } |
492 | 494 | ||
493 | 495 | ||
496 | void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const | ||
497 | { | ||
498 | _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; | ||
499 | ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); | ||
500 | wioctl( SIOCSIWAP ); | ||
501 | } | ||
502 | |||
503 | |||
494 | OMacAddress OWirelessNetworkInterface::associatedAP() const | 504 | OMacAddress OWirelessNetworkInterface::associatedAP() const |
495 | { | 505 | { |
496 | if ( ioctl( SIOCGIWAP ) ) | 506 | if ( ioctl( SIOCGIWAP ) ) |
497 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; | 507 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; |
498 | else | 508 | else |
499 | return OMacAddress::unknown; | 509 | return OMacAddress::unknown; |
500 | } | 510 | } |
501 | 511 | ||
502 | 512 | ||
503 | void OWirelessNetworkInterface::buildInformation() | 513 | void OWirelessNetworkInterface::buildInformation() |
504 | { | 514 | { |
505 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 515 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
506 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 516 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
507 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 517 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
508 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 518 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
509 | //ML: _too much_ space. This is damn shitty crap *sigh* | 519 | //ML: _too much_ space. This is damn shitty crap *sigh* |
510 | //ML: We allocate a large memory region in RAM and check whether the | 520 | //ML: We allocate a large memory region in RAM and check whether the |
511 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 521 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
512 | //ML: so please forward this... | 522 | //ML: so please forward this... |
513 | 523 | ||
514 | struct iwreq wrq; | 524 | struct iwreq wrq; |
515 | int len = sizeof( struct iw_range )*2; | 525 | int len = sizeof( struct iw_range )*2; |
516 | char *buffer = (char*) malloc( len ); | 526 | char *buffer = (char*) malloc( len ); |
517 | //FIXME: Validate if we actually got the memory block | 527 | //FIXME: Validate if we actually got the memory block |
518 | memset( buffer, 0, len ); | 528 | memset( buffer, 0, len ); |
519 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 529 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
520 | wrq.u.data.pointer = (caddr_t) buffer; | 530 | wrq.u.data.pointer = (caddr_t) buffer; |
521 | wrq.u.data.length = sizeof( struct iw_range ); | 531 | wrq.u.data.length = sizeof( struct iw_range ); |
522 | wrq.u.data.flags = 0; | 532 | wrq.u.data.flags = 0; |
523 | 533 | ||
524 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 534 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) |
525 | { | 535 | { |
526 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl; | 536 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl; |
527 | _channels.insert( 2412, 1 ); // 2.412 GHz | 537 | _channels.insert( 2412, 1 ); // 2.412 GHz |
528 | _channels.insert( 2417, 2 ); // 2.417 GHz | 538 | _channels.insert( 2417, 2 ); // 2.417 GHz |
529 | _channels.insert( 2422, 3 ); // 2.422 GHz | 539 | _channels.insert( 2422, 3 ); // 2.422 GHz |
530 | _channels.insert( 2427, 4 ); // 2.427 GHz | 540 | _channels.insert( 2427, 4 ); // 2.427 GHz |
531 | _channels.insert( 2432, 5 ); // 2.432 GHz | 541 | _channels.insert( 2432, 5 ); // 2.432 GHz |
532 | _channels.insert( 2437, 6 ); // 2.437 GHz | 542 | _channels.insert( 2437, 6 ); // 2.437 GHz |
533 | _channels.insert( 2442, 7 ); // 2.442 GHz | 543 | _channels.insert( 2442, 7 ); // 2.442 GHz |
534 | _channels.insert( 2447, 8 ); // 2.447 GHz | 544 | _channels.insert( 2447, 8 ); // 2.447 GHz |
535 | _channels.insert( 2452, 9 ); // 2.452 GHz | 545 | _channels.insert( 2452, 9 ); // 2.452 GHz |
536 | _channels.insert( 2457, 10 ); // 2.457 GHz | 546 | _channels.insert( 2457, 10 ); // 2.457 GHz |
537 | _channels.insert( 2462, 11 ); // 2.462 GHz | 547 | _channels.insert( 2462, 11 ); // 2.462 GHz |
538 | 548 | ||
539 | memset( &_range, 0, sizeof( struct iw_range ) ); | 549 | memset( &_range, 0, sizeof( struct iw_range ) ); |
540 | } | 550 | } |
541 | else | 551 | else |
542 | { | 552 | { |
543 | // <check if the driver overwrites stuff> | 553 | // <check if the driver overwrites stuff> |
544 | int max = 0; | 554 | int max = 0; |
545 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 555 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
546 | if (buffer[r] != 0) | 556 | if (buffer[r] != 0) |
547 | max = r; | 557 | max = r; |
548 | if (max > 0) | 558 | if (max > 0) |
549 | { | 559 | { |
550 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() | 560 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() |
551 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; | 561 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; |
552 | } | 562 | } |
553 | // </check if the driver overwrites stuff> | 563 | // </check if the driver overwrites stuff> |
554 | 564 | ||
555 | struct iw_range range; | 565 | struct iw_range range; |
556 | memcpy( &range, buffer, sizeof range ); | 566 | memcpy( &range, buffer, sizeof range ); |
557 | 567 | ||
558 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; | 568 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; |
559 | for ( int i = 0; i < range.num_frequency; ++i ) | 569 | for ( int i = 0; i < range.num_frequency; ++i ) |
560 | { | 570 | { |
561 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 571 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
562 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; | 572 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; |
563 | _channels.insert( freq, i+1 ); | 573 | _channels.insert( freq, i+1 ); |
564 | } | 574 | } |
565 | } | 575 | } |
566 | 576 | ||
567 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); | 577 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); |
568 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; | 578 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; |
569 | free(buffer); | 579 | free(buffer); |
570 | } | 580 | } |
571 | 581 | ||
572 | 582 | ||
573 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const | 583 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const |
574 | { | 584 | { |
575 | return _range.we_version_compiled; | 585 | return _range.we_version_compiled; |
576 | } | 586 | } |
577 | 587 | ||
578 | 588 | ||
579 | void OWirelessNetworkInterface::buildPrivateList() | 589 | void OWirelessNetworkInterface::buildPrivateList() |
580 | { | 590 | { |
581 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; | 591 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; |
582 | 592 | ||
583 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 593 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
584 | 594 | ||
585 | _iwr.u.data.pointer = (char*) &priv; | 595 | _iwr.u.data.pointer = (char*) &priv; |
586 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 596 | _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.flags = 0; | 597 | _iwr.u.data.flags = 0; |
588 | 598 | ||
589 | if ( !wioctl( SIOCGIWPRIV ) ) | 599 | if ( !wioctl( SIOCGIWPRIV ) ) |
@@ -813,199 +823,197 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, .. | |||
813 | << "' does not support private ioctl '" << call << "'" << oendl; | 823 | << "' does not support private ioctl '" << call << "'" << oendl; |
814 | return; | 824 | return; |
815 | } | 825 | } |
816 | if ( priv->numberSetArgs() != numargs ) | 826 | if ( priv->numberSetArgs() != numargs ) |
817 | { | 827 | { |
818 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" | 828 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" |
819 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; | 829 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; |
820 | return; | 830 | return; |
821 | } | 831 | } |
822 | 832 | ||
823 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; | 833 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; |
824 | memset( &_iwr, 0, sizeof _iwr ); | 834 | memset( &_iwr, 0, sizeof _iwr ); |
825 | va_list argp; | 835 | va_list argp; |
826 | va_start( argp, numargs ); | 836 | va_start( argp, numargs ); |
827 | for ( int i = 0; i < numargs; ++i ) | 837 | for ( int i = 0; i < numargs; ++i ) |
828 | { | 838 | { |
829 | priv->setParameter( i, va_arg( argp, int ) ); | 839 | priv->setParameter( i, va_arg( argp, int ) ); |
830 | } | 840 | } |
831 | va_end( argp ); | 841 | va_end( argp ); |
832 | priv->invoke(); | 842 | priv->invoke(); |
833 | } | 843 | } |
834 | 844 | ||
835 | 845 | ||
836 | void OWirelessNetworkInterface::getPrivate( const QString& ) | 846 | void OWirelessNetworkInterface::getPrivate( const QString& ) |
837 | { | 847 | { |
838 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; | 848 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; |
839 | } | 849 | } |
840 | 850 | ||
841 | 851 | ||
842 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 852 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
843 | { | 853 | { |
844 | return child( call.local8Bit() ); | 854 | return child( call.local8Bit() ); |
845 | } | 855 | } |
846 | 856 | ||
847 | 857 | ||
848 | QString OWirelessNetworkInterface::SSID() const | 858 | QString OWirelessNetworkInterface::SSID() const |
849 | { | 859 | { |
850 | char str[IW_ESSID_MAX_SIZE]; | 860 | char str[IW_ESSID_MAX_SIZE]; |
851 | _iwr.u.essid.pointer = &str[0]; | 861 | _iwr.u.essid.pointer = &str[0]; |
852 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 862 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
853 | if ( !wioctl( SIOCGIWESSID ) ) | 863 | if ( !wioctl( SIOCGIWESSID ) ) |
854 | { | 864 | { |
855 | return "<unknown>"; | 865 | return "<unknown>"; |
856 | } | 866 | } |
857 | else | 867 | else |
858 | { | 868 | { |
859 | return str; | 869 | return str; |
860 | } | 870 | } |
861 | } | 871 | } |
862 | 872 | ||
863 | 873 | ||
864 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 874 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
865 | { | 875 | { |
866 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 876 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
867 | _iwr.u.essid.length = ssid.length()+1; // zero byte | 877 | _iwr.u.essid.length = ssid.length()+1; // zero byte |
868 | wioctl( SIOCSIWESSID ); | 878 | wioctl( SIOCSIWESSID ); |
869 | } | 879 | } |
870 | 880 | ||
871 | 881 | ||
872 | OStationList* OWirelessNetworkInterface::scanNetwork() | 882 | OStationList* OWirelessNetworkInterface::scanNetwork() |
873 | { | 883 | { |
874 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 884 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
875 | _iwr.u.param.value = 0; | 885 | _iwr.u.param.value = 0; |
876 | if ( !wioctl( SIOCSIWSCAN ) ) | 886 | if ( !wioctl( SIOCSIWSCAN ) ) |
877 | { | 887 | { |
878 | return 0; | 888 | return 0; |
879 | } | 889 | } |
880 | 890 | ||
881 | OStationList* stations = new OStationList(); | 891 | OStationList* stations = new OStationList(); |
882 | 892 | ||
883 | int timeout = 10000000; | 893 | int timeout = 10000000; |
884 | 894 | ||
885 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; | 895 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; |
886 | 896 | ||
887 | bool results = false; | 897 | bool results = false; |
888 | struct timeval tv; | 898 | struct timeval tv; |
889 | tv.tv_sec = 0; | 899 | tv.tv_sec = 0; |
890 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 900 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
891 | char buffer[IW_SCAN_MAX_DATA]; | 901 | char buffer[IW_SCAN_MAX_DATA]; |
892 | 902 | ||
893 | while ( !results && timeout > 0 ) | 903 | while ( !results && timeout > 0 ) |
894 | { | 904 | { |
895 | timeout -= tv.tv_usec; | 905 | timeout -= tv.tv_usec; |
896 | select( 0, 0, 0, 0, &tv ); | 906 | select( 0, 0, 0, 0, &tv ); |
897 | 907 | ||
898 | _iwr.u.data.pointer = &buffer[0]; | 908 | _iwr.u.data.pointer = &buffer[0]; |
899 | _iwr.u.data.flags = 0; | 909 | _iwr.u.data.flags = 0; |
900 | _iwr.u.data.length = sizeof buffer; | 910 | _iwr.u.data.length = sizeof buffer; |
901 | if ( wioctl( SIOCGIWSCAN ) ) | 911 | if ( wioctl( SIOCGIWSCAN ) ) |
902 | { | 912 | { |
903 | results = true; | 913 | results = true; |
904 | continue; | 914 | continue; |
905 | } | 915 | } |
906 | else if ( errno == EAGAIN) | 916 | else if ( errno == EAGAIN) |
907 | { | 917 | { |
908 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; | 918 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; |
909 | #if 0 | ||
910 | if ( qApp ) | 919 | if ( qApp ) |
911 | { | 920 | { |
912 | qApp->processEvents( 100 ); | 921 | qApp->processEvents( 100 ); |
913 | continue; | 922 | continue; |
914 | } | 923 | } |
915 | #endif | ||
916 | tv.tv_sec = 0; | 924 | tv.tv_sec = 0; |
917 | tv.tv_usec = 100000; | 925 | tv.tv_usec = 100000; |
918 | continue; | 926 | continue; |
919 | } | 927 | } |
920 | } | 928 | } |
921 | 929 | ||
922 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; | 930 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; |
923 | 931 | ||
924 | if ( results ) | 932 | if ( results ) |
925 | { | 933 | { |
926 | odebug << " - result length = " << _iwr.u.data.length << oendl; | 934 | odebug << " - result length = " << _iwr.u.data.length << oendl; |
927 | if ( !_iwr.u.data.length ) | 935 | if ( !_iwr.u.data.length ) |
928 | { | 936 | { |
929 | odebug << " - no results (empty neighbourhood)" << oendl; | 937 | odebug << " - no results (empty neighbourhood)" << oendl; |
930 | return stations; | 938 | return stations; |
931 | } | 939 | } |
932 | 940 | ||
933 | odebug << " - results are in!" << oendl; | 941 | odebug << " - results are in!" << oendl; |
934 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); | 942 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); |
935 | 943 | ||
936 | // parse results | 944 | // parse results |
937 | struct iw_event iwe; | 945 | struct iw_event iwe; |
938 | struct iw_stream_descr stream; | 946 | struct iw_stream_descr stream; |
939 | unsigned int cmd_index, event_type, event_len; | 947 | unsigned int cmd_index, event_type, event_len; |
940 | char *pointer; | 948 | char *pointer; |
941 | 949 | ||
942 | const char standard_ioctl_hdr[] = { | 950 | const char standard_ioctl_hdr[] = { |
943 | IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ | 951 | IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ |
944 | IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ | 952 | IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ |
945 | IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ | 953 | IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ |
946 | IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ | 954 | IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ |
947 | IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ | 955 | IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ |
948 | IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ | 956 | IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ |
949 | IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ | 957 | IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ |
950 | IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ | 958 | IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ |
951 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ | 959 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ |
952 | IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ | 960 | IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ |
953 | IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ | 961 | IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ |
954 | IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ | 962 | IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ |
955 | IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ | 963 | IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ |
956 | IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ | 964 | IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ |
957 | IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ | 965 | IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ |
958 | IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ | 966 | IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ |
959 | IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ | 967 | IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ |
960 | IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ | 968 | IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ |
961 | IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ | 969 | IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ |
962 | IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ | 970 | IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ |
963 | IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ | 971 | IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ |
964 | IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ | 972 | IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ |
965 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 973 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
966 | IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ | 974 | IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ |
967 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ | 975 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ |
968 | IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ | 976 | IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ |
969 | IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ | 977 | IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ |
970 | IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ | 978 | IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ |
971 | IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ | 979 | IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ |
972 | IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ | 980 | IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ |
973 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 981 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
974 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 982 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
975 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ | 983 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ |
976 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ | 984 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ |
977 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ | 985 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ |
978 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ | 986 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ |
979 | IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ | 987 | IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ |
980 | IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ | 988 | IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ |
981 | IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ | 989 | IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ |
982 | IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ | 990 | IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ |
983 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ | 991 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ |
984 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ | 992 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ |
985 | IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ | 993 | IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ |
986 | IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ | 994 | IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ |
987 | IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ | 995 | IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ |
988 | IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ | 996 | IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ |
989 | }; | 997 | }; |
990 | 998 | ||
991 | const char standard_event_hdr[] = { | 999 | const char standard_event_hdr[] = { |
992 | IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ | 1000 | IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ |
993 | IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ | 1001 | IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ |
994 | IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ | 1002 | IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ |
995 | IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ | 1003 | IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ |
996 | IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ | 1004 | IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ |
997 | IW_HEADER_TYPE_POINT, /* IWEVGENIE */ | 1005 | IW_HEADER_TYPE_POINT, /* IWEVGENIE */ |
998 | IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */ | 1006 | IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */ |
999 | IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */ | 1007 | IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */ |
1000 | IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */ | 1008 | IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */ |
1001 | IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */ | 1009 | IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */ |
1002 | }; | 1010 | }; |
1003 | 1011 | ||
1004 | 1012 | ||
1005 | const int event_type_size[] = { | 1013 | const int event_type_size[] = { |
1006 | IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */ | 1014 | IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */ |
1007 | 0, | 1015 | 0, |
1008 | IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */ | 1016 | IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */ |
1009 | 0, | 1017 | 0, |
1010 | IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */ | 1018 | IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */ |
1011 | IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */ | 1019 | IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */ |
@@ -1034,207 +1042,227 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
1034 | cmd_index = iwe.cmd - SIOCIWFIRST; | 1042 | cmd_index = iwe.cmd - SIOCIWFIRST; |
1035 | 1043 | ||
1036 | if(cmd_index < sizeof(standard_ioctl_hdr)) | 1044 | if(cmd_index < sizeof(standard_ioctl_hdr)) |
1037 | event_type = standard_ioctl_hdr[cmd_index]; | 1045 | event_type = standard_ioctl_hdr[cmd_index]; |
1038 | } | 1046 | } |
1039 | else { | 1047 | else { |
1040 | cmd_index = iwe.cmd - IWEVFIRST; | 1048 | cmd_index = iwe.cmd - IWEVFIRST; |
1041 | 1049 | ||
1042 | if(cmd_index < sizeof(standard_event_hdr)) | 1050 | if(cmd_index < sizeof(standard_event_hdr)) |
1043 | event_type = standard_event_hdr[cmd_index]; | 1051 | event_type = standard_event_hdr[cmd_index]; |
1044 | } | 1052 | } |
1045 | 1053 | ||
1046 | /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ | 1054 | /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ |
1047 | event_len = event_type_size[event_type]; | 1055 | event_len = event_type_size[event_type]; |
1048 | 1056 | ||
1049 | /* Fixup for later version of WE */ | 1057 | /* Fixup for later version of WE */ |
1050 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) | 1058 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) |
1051 | event_len -= IW_EV_POINT_OFF; | 1059 | event_len -= IW_EV_POINT_OFF; |
1052 | 1060 | ||
1053 | /* Check if we know about this event */ | 1061 | /* Check if we know about this event */ |
1054 | if(event_len <= IW_EV_LCP_LEN) { | 1062 | if(event_len <= IW_EV_LCP_LEN) { |
1055 | /* Skip to next event */ | 1063 | /* Skip to next event */ |
1056 | stream.current += iwe.len; | 1064 | stream.current += iwe.len; |
1057 | continue; | 1065 | continue; |
1058 | } | 1066 | } |
1059 | 1067 | ||
1060 | event_len -= IW_EV_LCP_LEN; | 1068 | event_len -= IW_EV_LCP_LEN; |
1061 | 1069 | ||
1062 | /* Set pointer on data */ | 1070 | /* Set pointer on data */ |
1063 | if(stream.value != NULL) | 1071 | if(stream.value != NULL) |
1064 | pointer = stream.value; /* Next value in event */ | 1072 | pointer = stream.value; /* Next value in event */ |
1065 | else | 1073 | else |
1066 | pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */ | 1074 | pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */ |
1067 | 1075 | ||
1068 | if((pointer + event_len) > stream.end) { | 1076 | if((pointer + event_len) > stream.end) { |
1069 | /* Go to next event */ | 1077 | /* Go to next event */ |
1070 | stream.current += iwe.len; | 1078 | stream.current += iwe.len; |
1071 | break; | 1079 | break; |
1072 | } | 1080 | } |
1073 | 1081 | ||
1074 | /* Fixup for later version of WE */ | 1082 | /* Fixup for later version of WE */ |
1075 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) | 1083 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) |
1076 | memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); | 1084 | memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); |
1077 | else | 1085 | else |
1078 | memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len); | 1086 | memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len); |
1079 | 1087 | ||
1080 | /* Skip event in the stream */ | 1088 | /* Skip event in the stream */ |
1081 | pointer += event_len; | 1089 | pointer += event_len; |
1082 | 1090 | ||
1083 | /* Special processing for iw_point events */ | 1091 | /* Special processing for iw_point events */ |
1084 | if(event_type == IW_HEADER_TYPE_POINT) { | 1092 | if(event_type == IW_HEADER_TYPE_POINT) { |
1085 | /* Check the length of the payload */ | 1093 | /* Check the length of the payload */ |
1086 | 1094 | ||
1087 | if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0) | 1095 | if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0) |
1088 | /* Set pointer on variable part (warning : non aligned) */ | 1096 | /* Set pointer on variable part (warning : non aligned) */ |
1089 | iwe.u.data.pointer = pointer; | 1097 | iwe.u.data.pointer = pointer; |
1090 | else | 1098 | else |
1091 | /* No data */ | 1099 | /* No data */ |
1092 | iwe.u.data.pointer = NULL; | 1100 | iwe.u.data.pointer = NULL; |
1093 | /* Go to next event */ | 1101 | /* Go to next event */ |
1094 | stream.current += iwe.len; | 1102 | stream.current += iwe.len; |
1095 | } | 1103 | } |
1096 | 1104 | ||
1097 | else { | 1105 | else { |
1098 | /* Is there more value in the event ? */ | 1106 | /* Is there more value in the event ? */ |
1099 | if((pointer + event_len) <= (stream.current + iwe.len)) | 1107 | if((pointer + event_len) <= (stream.current + iwe.len)) |
1100 | /* Go to next value */ | 1108 | /* Go to next value */ |
1101 | stream.value = pointer; | 1109 | stream.value = pointer; |
1102 | else { | 1110 | else { |
1103 | /* Go to next event */ | 1111 | /* Go to next event */ |
1104 | stream.value = NULL; | 1112 | stream.value = NULL; |
1105 | stream.current += iwe.len; | 1113 | stream.current += iwe.len; |
1106 | } | 1114 | } |
1107 | } | 1115 | } |
1108 | 1116 | ||
1109 | struct iw_event *we = &iwe; | 1117 | struct iw_event *we = &iwe; |
1110 | //------ | 1118 | //------ |
1111 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; | 1119 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; |
1112 | switch (we->cmd) | 1120 | switch (we->cmd) |
1113 | { | 1121 | { |
1114 | case SIOCGIWAP: | 1122 | case SIOCGIWAP: |
1115 | { | 1123 | { |
1116 | odebug << "SIOCGIWAP" << oendl; | 1124 | odebug << "SIOCGIWAP" << oendl; |
1117 | stations->append( new OStation() ); | 1125 | stations->append( new OStation() ); |
1118 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; | 1126 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; |
1119 | break; | 1127 | break; |
1120 | } | 1128 | } |
1121 | case SIOCGIWMODE: | 1129 | case SIOCGIWMODE: |
1122 | { | 1130 | { |
1123 | odebug << "SIOCGIWMODE" << oendl; | 1131 | odebug << "SIOCGIWMODE" << oendl; |
1124 | stations->last()->type = modeToString( we->u.mode ); | 1132 | stations->last()->type = modeToString( we->u.mode ); |
1125 | break; | 1133 | break; |
1126 | } | 1134 | } |
1127 | case SIOCGIWFREQ: | 1135 | case SIOCGIWFREQ: |
1128 | { | 1136 | { |
1129 | odebug << "SIOCGIWFREQ" << oendl; | 1137 | odebug << "SIOCGIWFREQ" << oendl; |
1130 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; | 1138 | if ( we->u.freq.m > 1000 ) |
1139 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; | ||
1140 | else | ||
1141 | stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e )); | ||
1131 | break; | 1142 | break; |
1132 | } | 1143 | } |
1133 | case SIOCGIWESSID: | 1144 | case SIOCGIWESSID: |
1134 | { | 1145 | { |
1135 | odebug << "SIOCGIWESSID" << oendl; | 1146 | odebug << "SIOCGIWESSID" << oendl; |
1136 | we->u.essid.length = '\0'; // make sure it is zero terminated | 1147 | we->u.essid.length = '\0'; // make sure it is zero terminated |
1137 | stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); | 1148 | stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); |
1138 | odebug << "ESSID: " << stations->last()->ssid << oendl; | 1149 | odebug << "ESSID: " << stations->last()->ssid << oendl; |
1139 | break; | 1150 | break; |
1140 | } | 1151 | } |
1152 | case IWEVQUAL: | ||
1153 | { | ||
1154 | odebug << "IWEVQUAL" << oendl; | ||
1155 | stations->last()->level = static_cast<int>(we->u.qual.level); | ||
1156 | break; /* Quality part of statistics (scan) */ | ||
1157 | } | ||
1158 | case SIOCGIWENCODE: | ||
1159 | { | ||
1160 | odebug << "SIOCGIWENCODE" << oendl; | ||
1161 | stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); | ||
1162 | break; | ||
1163 | } | ||
1164 | |||
1165 | case SIOCGIWRATE: | ||
1166 | { | ||
1167 | odebug << "SIOCGIWRATE" << oendl; | ||
1168 | stations->last()->rates.append(we->u.bitrate.value); | ||
1169 | break; | ||
1170 | } | ||
1141 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; | 1171 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; |
1142 | case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; | ||
1143 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ | 1172 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ |
1144 | case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ | ||
1145 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ | 1173 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ |
1146 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ | 1174 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ |
1147 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ | 1175 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ |
1148 | default: odebug << "unhandled event" << oendl; | 1176 | default: odebug << "unhandled event" << oendl; |
1149 | } | 1177 | } |
1150 | 1178 | ||
1151 | } while (true); | 1179 | } while (true); |
1152 | } | 1180 | } |
1153 | else | 1181 | else |
1154 | { | 1182 | { |
1155 | odebug << " - no results (timeout) :(" << oendl; | 1183 | odebug << " - no results (timeout) :(" << oendl; |
1156 | } | 1184 | } |
1157 | return stations; | 1185 | return stations; |
1158 | } | 1186 | } |
1159 | 1187 | ||
1160 | 1188 | ||
1161 | int OWirelessNetworkInterface::signalStrength() const | 1189 | int OWirelessNetworkInterface::signalStrength() const |
1162 | { | 1190 | { |
1163 | iw_statistics stat; | 1191 | iw_statistics stat; |
1164 | ::memset( &stat, 0, sizeof stat ); | 1192 | ::memset( &stat, 0, sizeof stat ); |
1165 | _iwr.u.data.pointer = (char*) &stat; | 1193 | _iwr.u.data.pointer = (char*) &stat; |
1166 | _iwr.u.data.flags = 0; | 1194 | _iwr.u.data.flags = 0; |
1167 | _iwr.u.data.length = sizeof stat; | 1195 | _iwr.u.data.length = sizeof stat; |
1168 | 1196 | ||
1169 | if ( !wioctl( SIOCGIWSTATS ) ) | 1197 | if ( !wioctl( SIOCGIWSTATS ) ) |
1170 | { | 1198 | { |
1171 | return -1; | 1199 | return -1; |
1172 | } | 1200 | } |
1173 | 1201 | ||
1174 | int max = _range.max_qual.qual; | 1202 | int max = _range.max_qual.qual; |
1175 | int cur = stat.qual.qual; | 1203 | int cur = stat.qual.qual; |
1176 | // int lev = stat.qual.level; //FIXME: Do something with them? | 1204 | // int lev = stat.qual.level; //FIXME: Do something with them? |
1177 | // int noi = stat.qual.noise; //FIXME: Do something with them? | 1205 | // int noi = stat.qual.noise; //FIXME: Do something with them? |
1178 | 1206 | ||
1179 | 1207 | ||
1180 | return max != 0 ? cur*100/max: -1; | 1208 | return max != 0 ? cur*100/max: -1; |
1181 | } | 1209 | } |
1182 | 1210 | ||
1183 | 1211 | ||
1184 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 1212 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
1185 | { | 1213 | { |
1186 | #ifndef NODEBUG | 1214 | #ifndef NODEBUG |
1187 | int result = ::ioctl( _sfd, call, &iwreq ); | 1215 | int result = ::ioctl( _sfd, call, &iwreq ); |
1188 | 1216 | ||
1189 | if ( result == -1 ) | 1217 | if ( result == -1 ) |
1190 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1218 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1191 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 1219 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
1192 | else | 1220 | else |
1193 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1221 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1194 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; | 1222 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; |
1195 | 1223 | ||
1196 | return ( result != -1 ); | 1224 | return ( result != -1 ); |
1197 | #else | 1225 | #else |
1198 | return ::ioctl( _sfd, call, &iwreq ) != -1; | 1226 | return ::ioctl( _sfd, call, &iwreq ) != -1; |
1199 | #endif | 1227 | #endif |
1200 | } | 1228 | } |
1201 | 1229 | ||
1202 | 1230 | ||
1203 | bool OWirelessNetworkInterface::wioctl( int call ) const | 1231 | bool OWirelessNetworkInterface::wioctl( int call ) const |
1204 | { | 1232 | { |
1205 | strcpy( _iwr.ifr_name, name() ); | 1233 | strcpy( _iwr.ifr_name, name() ); |
1206 | return wioctl( call, _iwr ); | 1234 | return wioctl( call, _iwr ); |
1207 | } | 1235 | } |
1208 | 1236 | ||
1209 | 1237 | ||
1210 | /*====================================================================================== | 1238 | /*====================================================================================== |
1211 | * OMonitoringInterface | 1239 | * OMonitoringInterface |
1212 | *======================================================================================*/ | 1240 | *======================================================================================*/ |
1213 | 1241 | ||
1214 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1242 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1215 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) | 1243 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
1216 | { | 1244 | { |
1217 | } | 1245 | } |
1218 | 1246 | ||
1219 | 1247 | ||
1220 | OMonitoringInterface::~OMonitoringInterface() | 1248 | OMonitoringInterface::~OMonitoringInterface() |
1221 | { | 1249 | { |
1222 | } | 1250 | } |
1223 | 1251 | ||
1224 | 1252 | ||
1225 | void OMonitoringInterface::setChannel( int c ) | 1253 | void OMonitoringInterface::setChannel( int c ) |
1226 | { | 1254 | { |
1227 | // use standard WE channel switching protocol | 1255 | // use standard WE channel switching protocol |
1228 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 1256 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
1229 | _if->_iwr.u.freq.m = c; | 1257 | _if->_iwr.u.freq.m = c; |
1230 | _if->_iwr.u.freq.e = 0; | 1258 | _if->_iwr.u.freq.e = 0; |
1231 | _if->wioctl( SIOCSIWFREQ ); | 1259 | _if->wioctl( SIOCSIWFREQ ); |
1232 | } | 1260 | } |
1233 | 1261 | ||
1234 | 1262 | ||
1235 | void OMonitoringInterface::setEnabled( bool ) | 1263 | void OMonitoringInterface::setEnabled( bool ) |
1236 | { | 1264 | { |
1237 | } | 1265 | } |
1238 | 1266 | ||
1239 | 1267 | ||
1240 | /*====================================================================================== | 1268 | /*====================================================================================== |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 4d9912d..fa9f39f 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -320,192 +320,195 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
320 | friend class OCiscoMonitoringInterface; | 320 | friend class OCiscoMonitoringInterface; |
321 | friend class OWlanNGMonitoringInterface; | 321 | friend class OWlanNGMonitoringInterface; |
322 | friend class OHostAPMonitoringInterface; | 322 | friend class OHostAPMonitoringInterface; |
323 | friend class OOrinocoMonitoringInterface; | 323 | friend class OOrinocoMonitoringInterface; |
324 | 324 | ||
325 | friend class OPrivateIOCTL; | 325 | friend class OPrivateIOCTL; |
326 | 326 | ||
327 | public: | 327 | public: |
328 | /** | 328 | /** |
329 | * Constructor. | 329 | * Constructor. |
330 | */ | 330 | */ |
331 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 331 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
332 | /** | 332 | /** |
333 | * Destructor. | 333 | * Destructor. |
334 | */ | 334 | */ |
335 | virtual ~OWirelessNetworkInterface(); | 335 | virtual ~OWirelessNetworkInterface(); |
336 | /** | 336 | /** |
337 | * Setting the @a channel of the interface changes the radio frequency (RF) | 337 | * Setting the @a channel of the interface changes the radio frequency (RF) |
338 | * of the corresponding wireless network device. | 338 | * of the corresponding wireless network device. |
339 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. | 339 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. |
340 | * @see channels() | 340 | * @see channels() |
341 | */ | 341 | */ |
342 | virtual void setChannel( int channel ) const; | 342 | virtual void setChannel( int channel ) const; |
343 | /** | 343 | /** |
344 | * @returns the channel index of the current radio frequency. | 344 | * @returns the channel index of the current radio frequency. |
345 | */ | 345 | */ |
346 | virtual int channel() const; | 346 | virtual int channel() const; |
347 | /** | 347 | /** |
348 | * @returns the current radio frequency (in MHz). | 348 | * @returns the current radio frequency (in MHz). |
349 | */ | 349 | */ |
350 | virtual double frequency() const; | 350 | virtual double frequency() const; |
351 | /** | 351 | /** |
352 | * @returns the number of radio frequency channels for the | 352 | * @returns the number of radio frequency channels for the |
353 | * corresponding wireless network device. | 353 | * corresponding wireless network device. |
354 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 354 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
355 | */ | 355 | */ |
356 | virtual int channels() const; | 356 | virtual int channels() const; |
357 | /** | 357 | /** |
358 | * Set the IEEE 802.11 operation @a mode. | 358 | * Set the IEEE 802.11 operation @a mode. |
359 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master | 359 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master |
360 | * @warning Not all drivers support the all modes. | 360 | * @warning Not all drivers support the all modes. |
361 | * @note You might have to change the SSID to get the operation mode change into effect. | 361 | * @note You might have to change the SSID to get the operation mode change into effect. |
362 | */ | 362 | */ |
363 | virtual void setMode( const QString& mode ); | 363 | virtual void setMode( const QString& mode ); |
364 | /** | 364 | /** |
365 | * @returns the current IEEE 802.11 operation mode. | 365 | * @returns the current IEEE 802.11 operation mode. |
366 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown | 366 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown |
367 | * | 367 | * |
368 | * @note: Important note concerning the 'monitor' mode: | 368 | * @note: Important note concerning the 'monitor' mode: |
369 | * Setting the monitor mode on a wireless network interface enables | 369 | * Setting the monitor mode on a wireless network interface enables |
370 | * listening to IEEE 802.11 data and management frames which normally | 370 | * listening to IEEE 802.11 data and management frames which normally |
371 | * are handled by the device firmware. This can be used to detect | 371 | * are handled by the device firmware. This can be used to detect |
372 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. | 372 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. |
373 | * @warning Standard wireless network drives don't support the monitor mode. | 373 | * @warning Standard wireless network drives don't support the monitor mode. |
374 | * @warning You need a patched driver for this to work. | 374 | * @warning You need a patched driver for this to work. |
375 | * @note Enabling the monitor mode is highly driver dependent and requires | 375 | * @note Enabling the monitor mode is highly driver dependent and requires |
376 | * the proper @ref OMonitoringInterface to be associated with the interface. | 376 | * the proper @ref OMonitoringInterface to be associated with the interface. |
377 | * @see OMonitoringInterface | 377 | * @see OMonitoringInterface |
378 | */ | 378 | */ |
379 | virtual QString mode() const; | 379 | virtual QString mode() const; |
380 | /** | 380 | /** |
381 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. | 381 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. |
382 | * @see OChannelHopper | 382 | * @see OChannelHopper |
383 | */ | 383 | */ |
384 | virtual void setChannelHopping( int interval = 0 ); | 384 | virtual void setChannelHopping( int interval = 0 ); |
385 | /** | 385 | /** |
386 | * @returns the channel hopping interval or 0, if channel hopping is disabled. | 386 | * @returns the channel hopping interval or 0, if channel hopping is disabled. |
387 | */ | 387 | */ |
388 | virtual int channelHopping() const; | 388 | virtual int channelHopping() const; |
389 | /** | 389 | /** |
390 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before | 390 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before |
391 | */ | 391 | */ |
392 | virtual OChannelHopper* channelHopper() const; | 392 | virtual OChannelHopper* channelHopper() const; |
393 | /** | 393 | /** |
394 | * Set the station @a nickname. | 394 | * Set the station @a nickname. |
395 | */ | 395 | */ |
396 | virtual void setNickName( const QString& nickname ); | 396 | virtual void setNickName( const QString& nickname ); |
397 | /** | 397 | /** |
398 | * @returns the current station nickname. | 398 | * @returns the current station nickname. |
399 | */ | 399 | */ |
400 | virtual QString nickName() const; | 400 | virtual QString nickName() const; |
401 | /** | 401 | /** |
402 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. | 402 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. |
403 | * @see OPrivateIOCTL | 403 | * @see OPrivateIOCTL |
404 | */ | 404 | */ |
405 | virtual void setPrivate( const QString& command, int number, ... ); | 405 | virtual void setPrivate( const QString& command, int number, ... ); |
406 | /** | 406 | /** |
407 | * @returns true if the interface is featuring the private IOCTL @command. | 407 | * @returns true if the interface is featuring the private IOCTL @command. |
408 | */ | 408 | */ |
409 | virtual bool hasPrivate( const QString& command ); | 409 | virtual bool hasPrivate( const QString& command ); |
410 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 410 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
411 | /** | 411 | /** |
412 | * @returns true if the interface is associated to an access point | 412 | * @returns true if the interface is associated to an access point |
413 | * @note: This information is only valid if the interface is in managed mode. | 413 | * @note: This information is only valid if the interface is in managed mode. |
414 | */ | 414 | */ |
415 | virtual bool isAssociated() const; | 415 | virtual bool isAssociated() const; |
416 | /** Set the @a mac associated AP address. | ||
417 | */ | ||
418 | virtual void setAssociatedAP( const OMacAddress& mac ) const; | ||
416 | /** | 419 | /** |
417 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. | 420 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. |
418 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. | 421 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. |
419 | */ | 422 | */ |
420 | virtual OMacAddress associatedAP() const; | 423 | virtual OMacAddress associatedAP() const; |
421 | /** | 424 | /** |
422 | * Set the @a ssid (Service Set ID) string. This is used to decide | 425 | * Set the @a ssid (Service Set ID) string. This is used to decide |
423 | * which network to associate with (use "any" to let the driver decide). | 426 | * which network to associate with (use "any" to let the driver decide). |
424 | */ | 427 | */ |
425 | virtual void setSSID( const QString& ssid ); | 428 | virtual void setSSID( const QString& ssid ); |
426 | /** | 429 | /** |
427 | * @returns the current SSID (Service Set ID). | 430 | * @returns the current SSID (Service Set ID). |
428 | */ | 431 | */ |
429 | virtual QString SSID() const; | 432 | virtual QString SSID() const; |
430 | /** | 433 | /** |
431 | * Perform scanning the wireless network neighbourhood. | 434 | * Perform scanning the wireless network neighbourhood. |
432 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! | 435 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! |
433 | */ | 436 | */ |
434 | virtual OStationList* scanNetwork(); | 437 | virtual OStationList* scanNetwork(); |
435 | /** | 438 | /** |
436 | * @return signal strength to associated neighbour (in percent). | 439 | * @return signal strength to associated neighbour (in percent). |
437 | * In infrastructure mode, this is the signal strength of the Access Point. | 440 | * In infrastructure mode, this is the signal strength of the Access Point. |
438 | * In other modes the result is driver dependent. | 441 | * In other modes the result is driver dependent. |
439 | */ | 442 | */ |
440 | virtual int signalStrength() const; | 443 | virtual int signalStrength() const; |
441 | /** | 444 | /** |
442 | * @returns the wireless extension version used by the interface driver. | 445 | * @returns the wireless extension version used by the interface driver. |
443 | **/ | 446 | **/ |
444 | short wirelessExtensionDriverVersion() const; | 447 | short wirelessExtensionDriverVersion() const; |
445 | /** | 448 | /** |
446 | * @internal commit pending changes to the driver | 449 | * @internal commit pending changes to the driver |
447 | */ | 450 | */ |
448 | void commit() const; | 451 | void commit() const; |
449 | 452 | ||
450 | protected: | 453 | protected: |
451 | void buildInformation(); | 454 | void buildInformation(); |
452 | void buildPrivateList(); | 455 | void buildPrivateList(); |
453 | void dumpInformation() const; | 456 | void dumpInformation() const; |
454 | virtual void init(); | 457 | virtual void init(); |
455 | struct iwreq& iwr() const; | 458 | struct iwreq& iwr() const; |
456 | bool wioctl( int call ) const; | 459 | bool wioctl( int call ) const; |
457 | bool wioctl( int call, struct iwreq& ) const; | 460 | bool wioctl( int call, struct iwreq& ) const; |
458 | 461 | ||
459 | protected: | 462 | protected: |
460 | mutable struct iwreq _iwr; | 463 | mutable struct iwreq _iwr; |
461 | QMap<int,int> _channels; | 464 | QMap<int,int> _channels; |
462 | struct iw_range _range; | 465 | struct iw_range _range; |
463 | 466 | ||
464 | private: | 467 | private: |
465 | OChannelHopper* _hopper; | 468 | OChannelHopper* _hopper; |
466 | class Private; | 469 | class Private; |
467 | Private *d; | 470 | Private *d; |
468 | }; | 471 | }; |
469 | 472 | ||
470 | 473 | ||
471 | /*====================================================================================== | 474 | /*====================================================================================== |
472 | * OMonitoringInterface | 475 | * OMonitoringInterface |
473 | *======================================================================================*/ | 476 | *======================================================================================*/ |
474 | 477 | ||
475 | 478 | ||
476 | class OMonitoringInterface | 479 | class OMonitoringInterface |
477 | { | 480 | { |
478 | public: | 481 | public: |
479 | OMonitoringInterface(); | 482 | OMonitoringInterface(); |
480 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 483 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
481 | virtual ~OMonitoringInterface(); | 484 | virtual ~OMonitoringInterface(); |
482 | 485 | ||
483 | public: | 486 | public: |
484 | virtual void setEnabled( bool ); | 487 | virtual void setEnabled( bool ); |
485 | virtual void setChannel( int ); | 488 | virtual void setChannel( int ); |
486 | 489 | ||
487 | virtual QString name() const = 0; | 490 | virtual QString name() const = 0; |
488 | 491 | ||
489 | protected: | 492 | protected: |
490 | OWirelessNetworkInterface* _if; | 493 | OWirelessNetworkInterface* _if; |
491 | bool _prismHeader; | 494 | bool _prismHeader; |
492 | private: | 495 | private: |
493 | class Private; | 496 | class Private; |
494 | Private *d; | 497 | Private *d; |
495 | 498 | ||
496 | }; | 499 | }; |
497 | 500 | ||
498 | 501 | ||
499 | /*====================================================================================== | 502 | /*====================================================================================== |
500 | * OCiscoMonitoring | 503 | * OCiscoMonitoring |
501 | *======================================================================================*/ | 504 | *======================================================================================*/ |
502 | 505 | ||
503 | 506 | ||
504 | class OCiscoMonitoringInterface : public OMonitoringInterface | 507 | class OCiscoMonitoringInterface : public OMonitoringInterface |
505 | { | 508 | { |
506 | public: | 509 | public: |
507 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 510 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
508 | virtual ~OCiscoMonitoringInterface(); | 511 | virtual ~OCiscoMonitoringInterface(); |
509 | 512 | ||
510 | virtual void setEnabled( bool ); | 513 | virtual void setEnabled( bool ); |
511 | virtual QString name() const; | 514 | virtual QString name() const; |
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h index 5219d92..86c9a52 100644 --- a/libopie2/opienet/ostation.h +++ b/libopie2/opienet/ostation.h | |||
@@ -1,83 +1,85 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003-2005 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; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
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 | #ifndef OSTATION_H | 31 | #ifndef OSTATION_H |
32 | #define OSTATION_H | 32 | #define OSTATION_H |
33 | 33 | ||
34 | #include <opie2/onetutils.h> | 34 | #include <opie2/onetutils.h> |
35 | 35 | ||
36 | #include <qlist.h> | 36 | #include <qlist.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 | #include <qvaluelist.h> | ||
40 | 41 | ||
41 | #include <sys/types.h> | 42 | #include <sys/types.h> |
42 | 43 | ||
43 | namespace Opie { | 44 | namespace Opie { |
44 | namespace Net { | 45 | namespace Net { |
45 | 46 | ||
46 | class OStation; | 47 | class OStation; |
47 | 48 | ||
48 | 49 | ||
49 | typedef QList<OStation> OStationList; | 50 | typedef QList<OStation> OStationList; |
50 | 51 | ||
51 | /*====================================================================================== | 52 | /*====================================================================================== |
52 | * OStation | 53 | * OStation |
53 | *======================================================================================*/ | 54 | *======================================================================================*/ |
54 | 55 | ||
55 | class OStation | 56 | class OStation |
56 | { | 57 | { |
57 | public: | 58 | public: |
58 | OStation(); | 59 | OStation(); |
59 | ~OStation(); | 60 | ~OStation(); |
60 | 61 | ||
61 | void dump(); | 62 | void dump(); |
62 | 63 | ||
63 | /* Ethernet */ | 64 | /* Ethernet */ |
64 | QString type; | 65 | QString type; |
65 | OMacAddress macAddress; | 66 | OMacAddress macAddress; |
66 | QHostAddress ipAddress; | 67 | QHostAddress ipAddress; |
67 | 68 | ||
68 | /* WaveLan */ | 69 | /* WaveLan */ |
69 | QString ssid; | 70 | QString ssid; |
70 | OMacAddress apAddress; | 71 | OMacAddress apAddress; |
71 | int channel; | 72 | int channel; |
72 | int level; | 73 | int level; |
73 | bool encrypted; | 74 | bool encrypted; |
75 | QValueList <int> rates; | ||
74 | private: | 76 | private: |
75 | class Private; | 77 | class Private; |
76 | Private *d; | 78 | Private *d; |
77 | }; | 79 | }; |
78 | 80 | ||
79 | } | 81 | } |
80 | } | 82 | } |
81 | 83 | ||
82 | #endif // OSTATION_H | 84 | #endif // OSTATION_H |
83 | 85 | ||