author | mickeyl <mickeyl> | 2003-05-01 00:59:20 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-01 00:59:20 (UTC) |
commit | 1d721ddb247e9000e29fba3150e0cce5f59f543e (patch) (unidiff) | |
tree | 70b659b209395c8aff25442afaa4fc57c29679e6 | |
parent | 30c685f9da06d19c993e9bdb74f349dabbde063e (diff) | |
download | opie-1d721ddb247e9000e29fba3150e0cce5f59f543e.zip opie-1d721ddb247e9000e29fba3150e0cce5f59f543e.tar.gz opie-1d721ddb247e9000e29fba3150e0cce5f59f543e.tar.bz2 |
implement and document a bunch of missing methods
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 21 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 51 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 58 |
3 files changed, 105 insertions, 25 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index f801b15..fd68772 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -19,7 +19,6 @@ int main( int argc, char** argv ) | |||
19 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 19 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
20 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); | 20 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); |
21 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); | 21 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); |
22 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); | ||
23 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); | 22 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); |
24 | 23 | ||
25 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | 24 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) |
@@ -27,7 +26,23 @@ int main( int argc, char** argv ) | |||
27 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); | 26 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); |
28 | //} | 27 | //} |
29 | 28 | ||
30 | // try to set monitor mode | 29 | // nickname |
30 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); | ||
31 | iface->setNickName( "MyNickName" ); | ||
32 | if ( iface->nickName() != "MyNickName" ) | ||
33 | qDebug( "DEMO: Warning! Can't change nickname" ); | ||
34 | else | ||
35 | qDebug( "DEMO: Nickname change successful." ); | ||
36 | |||
37 | // operation mode | ||
38 | qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); | ||
39 | iface->setMode( "adhoc" ); | ||
40 | if ( iface->mode() != "adhoc" ) | ||
41 | qDebug( "DEMO: Warning! Can't change operation mode" ); | ||
42 | else | ||
43 | qDebug( "DEMO: Operation Mode change successful." ); | ||
44 | |||
45 | iface->setMode( "managed" ); | ||
31 | 46 | ||
32 | /* | 47 | /* |
33 | 48 | ||
@@ -38,8 +53,6 @@ int main( int argc, char** argv ) | |||
38 | // now the real deal | 53 | // now the real deal |
39 | iface->setPrivate( "monitor", 2, 2, 3 ); | 54 | iface->setPrivate( "monitor", 2, 2, 3 ); |
40 | 55 | ||
41 | */ | ||
42 | |||
43 | // trying to set hw address to 12:34:56:AB:CD:EF | 56 | // trying to set hw address to 12:34:56:AB:CD:EF |
44 | 57 | ||
45 | /* | 58 | /* |
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 95e7043..2dfff1d 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -42,6 +42,7 @@ | |||
42 | 42 | ||
43 | /* UNIX */ | 43 | /* UNIX */ |
44 | 44 | ||
45 | #include <assert.h> | ||
45 | #include <arpa/inet.h> | 46 | #include <arpa/inet.h> |
46 | #include <cerrno> | 47 | #include <cerrno> |
47 | #include <cstring> | 48 | #include <cstring> |
@@ -639,6 +640,48 @@ OChannelHopper* OWirelessNetworkInterface::channelHopper() const | |||
639 | } | 640 | } |
640 | 641 | ||
641 | 642 | ||
643 | void OWirelessNetworkInterface::setMode( const QString& mode ) | ||
644 | { | ||
645 | if ( mode == "auto" ) _iwr.u.mode = IW_MODE_AUTO; | ||
646 | else if ( mode == "adhoc" ) _iwr.u.mode = IW_MODE_ADHOC; | ||
647 | else if ( mode == "managed" ) _iwr.u.mode = IW_MODE_INFRA; | ||
648 | else if ( mode == "master" ) _iwr.u.mode = IW_MODE_MASTER; | ||
649 | else if ( mode == "repeater" ) _iwr.u.mode = IW_MODE_REPEAT; | ||
650 | else if ( mode == "secondary" ) _iwr.u.mode = IW_MODE_SECOND; | ||
651 | #if WIRELESS_EXT > 14 | ||
652 | else if ( mode == "monitor" ) _iwr.u.mode = IW_MODE_MONITOR; | ||
653 | #endif | ||
654 | else | ||
655 | { | ||
656 | qDebug( "ONetwork: Warning! Invalid IEEE 802.11 mode '%s' specified.", (const char*) mode ); | ||
657 | return; | ||
658 | } | ||
659 | wioctl( SIOCSIWMODE ); | ||
660 | } | ||
661 | |||
662 | |||
663 | QString OWirelessNetworkInterface::mode() const | ||
664 | { | ||
665 | if ( !wioctl( SIOCGIWMODE ) ) | ||
666 | { | ||
667 | return "<unknown>"; | ||
668 | } | ||
669 | switch ( _iwr.u.mode ) | ||
670 | { | ||
671 | case IW_MODE_AUTO: return "auto"; | ||
672 | case IW_MODE_ADHOC: return "adhoc"; | ||
673 | case IW_MODE_INFRA: return "managed"; | ||
674 | case IW_MODE_MASTER: return "master"; | ||
675 | case IW_MODE_REPEAT: return "repeater"; | ||
676 | case IW_MODE_SECOND: return "secondary"; | ||
677 | #if WIRELESS_EXT > 14 | ||
678 | case IW_MODE_MONITOR: return "monitor"; | ||
679 | #endif | ||
680 | default: assert( 0 ); // shouldn't happen | ||
681 | } | ||
682 | } | ||
683 | |||
684 | |||
642 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 685 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
643 | { | 686 | { |
644 | if ( _mon ) | 687 | if ( _mon ) |
@@ -656,6 +699,14 @@ bool OWirelessNetworkInterface::monitorMode() const | |||
656 | } | 699 | } |
657 | 700 | ||
658 | 701 | ||
702 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | ||
703 | { | ||
704 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); | ||
705 | _iwr.u.essid.length = nickname.length(); | ||
706 | wioctl( SIOCSIWNICKN ); | ||
707 | } | ||
708 | |||
709 | |||
659 | QString OWirelessNetworkInterface::nickName() const | 710 | QString OWirelessNetworkInterface::nickName() const |
660 | { | 711 | { |
661 | char str[IW_ESSID_MAX_SIZE]; | 712 | char str[IW_ESSID_MAX_SIZE]; |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index f052317..a29b29d 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -34,6 +34,10 @@ | |||
34 | #ifndef ONETWORK_H | 34 | #ifndef ONETWORK_H |
35 | #define ONETWORK_H | 35 | #define ONETWORK_H |
36 | 36 | ||
37 | /* OPIE */ | ||
38 | |||
39 | #include <opie2/onetutils.h> | ||
40 | |||
37 | /* QT */ | 41 | /* QT */ |
38 | 42 | ||
39 | #include <qvaluelist.h> | 43 | #include <qvaluelist.h> |
@@ -42,10 +46,6 @@ | |||
42 | #include <qobject.h> | 46 | #include <qobject.h> |
43 | #include <qhostaddress.h> | 47 | #include <qhostaddress.h> |
44 | 48 | ||
45 | /* OPIE */ | ||
46 | |||
47 | #include <opie2/onetutils.h> | ||
48 | |||
49 | #ifndef IFNAMSIZ | 49 | #ifndef IFNAMSIZ |
50 | #define IFNAMSIZ 16 | 50 | #define IFNAMSIZ 16 |
51 | #endif | 51 | #endif |
@@ -100,12 +100,12 @@ class ONetwork : public QObject | |||
100 | */ | 100 | */ |
101 | InterfaceIterator iterator() const; | 101 | InterfaceIterator iterator() const; |
102 | /** | 102 | /** |
103 | * @returns true, if the @p interface supports the wireless extension protocol. | 103 | * @returns true, if the @a interface supports the wireless extension protocol. |
104 | */ | 104 | */ |
105 | // FIXME QString? -zecke | 105 | // FIXME QString? -zecke |
106 | bool isWirelessInterface( const char* interface ) const; | 106 | bool isWirelessInterface( const char* interface ) const; |
107 | /** | 107 | /** |
108 | * @returns a pointer to the @ref ONetworkInterface object for the specified @p interface or 0, if not found | 108 | * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found |
109 | * @see ONetworkInterface | 109 | * @see ONetworkInterface |
110 | */ | 110 | */ |
111 | // FIXME: const QString& is prefered over QString!!! -zecke | 111 | // FIXME: const QString& is prefered over QString!!! -zecke |
@@ -198,7 +198,7 @@ class ONetworkInterface : public QObject | |||
198 | /** | 198 | /** |
199 | * @returns the IPv4 address associated with the interface. | 199 | * @returns the IPv4 address associated with the interface. |
200 | */ | 200 | */ |
201 | QString ipV4Address() const; | 201 | QString ipV4Address() const; //TODO: make this return an OHostAddress |
202 | /** | 202 | /** |
203 | * Associate the MAC address @a addr with the interface. | 203 | * Associate the MAC address @a addr with the interface. |
204 | * @note It can be necessary to shut down the interface prior to calling this method. | 204 | * @note It can be necessary to shut down the interface prior to calling this method. |
@@ -216,7 +216,7 @@ class ONetworkInterface : public QObject | |||
216 | /** | 216 | /** |
217 | * @returns the IPv4 netmask associated with the interface. | 217 | * @returns the IPv4 netmask associated with the interface. |
218 | */ | 218 | */ |
219 | QString ipV4Netmask() const; | 219 | QString ipV4Netmask() const; //TODO: make this return an OHostAddress |
220 | /** | 220 | /** |
221 | * @returns the data link type currently associated with the interface. | 221 | * @returns the data link type currently associated with the interface. |
222 | * @see #include <net/if_arp.h> for possible values. | 222 | * @see #include <net/if_arp.h> for possible values. |
@@ -317,8 +317,6 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
317 | friend class OPrivateIOCTL; | 317 | friend class OPrivateIOCTL; |
318 | 318 | ||
319 | public: | 319 | public: |
320 | enum Mode { AdHoc, Managed, Monitor }; | ||
321 | |||
322 | /** | 320 | /** |
323 | * Constructor. | 321 | * Constructor. |
324 | */ | 322 | */ |
@@ -346,11 +344,18 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
346 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 344 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
347 | */ | 345 | */ |
348 | virtual int channels() const; | 346 | virtual int channels() const; |
349 | //virtual double frequency(int) const; | 347 | /** |
350 | 348 | * Set the IEEE 802.11 operation @a mode. | |
351 | virtual void setMode( Mode ) {}; //FIXME: Implement and document this | 349 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master |
352 | virtual bool mode() const {}; //FIXME: Implement and document this | 350 | * @warning Not all drivers support the all modes. |
353 | 351 | * @note You might have to change the SSID to get the operation mode change into effect. | |
352 | */ | ||
353 | virtual void setMode( const QString& mode ); | ||
354 | /** | ||
355 | * @returns the current IEEE 802.11 operation mode. | ||
356 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown | ||
357 | */ | ||
358 | virtual QString mode() const; | ||
354 | /** | 359 | /** |
355 | * Setting the monitor mode on a wireless network interface enables | 360 | * Setting the monitor mode on a wireless network interface enables |
356 | * listening to IEEE 802.11 data and management frames which normally | 361 | * listening to IEEE 802.11 data and management frames which normally |
@@ -362,11 +367,11 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
362 | * the proper @ref OMonitoringInterface to be associated with the interface. | 367 | * the proper @ref OMonitoringInterface to be associated with the interface. |
363 | * @see OMonitoringInterface | 368 | * @see OMonitoringInterface |
364 | */ | 369 | */ |
365 | virtual void setMonitorMode( bool ); | 370 | virtual void setMonitorMode( bool ); //FIXME: ==> setMode( "monitor" ); |
366 | /** | 371 | /** |
367 | * @returns true if the device is listening in IEEE 802.11 monitor mode | 372 | * @returns true if the device is listening in IEEE 802.11 monitor mode |
368 | */ | 373 | */ |
369 | virtual bool monitorMode() const; | 374 | virtual bool monitorMode() const; //FIXME: ==> mode() |
370 | /** | 375 | /** |
371 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. | 376 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. |
372 | * @see OChannelHopper | 377 | * @see OChannelHopper |
@@ -383,7 +388,7 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
383 | /** | 388 | /** |
384 | * Set the station @a nickname. | 389 | * Set the station @a nickname. |
385 | */ | 390 | */ |
386 | virtual void setNickName( const QString& nickname ) {}; //FIXME: Implement this | 391 | virtual void setNickName( const QString& nickname ); |
387 | /** | 392 | /** |
388 | * @returns the current station nickname. | 393 | * @returns the current station nickname. |
389 | */ | 394 | */ |
@@ -400,9 +405,20 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
400 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 405 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
401 | 406 | ||
402 | virtual bool isAssociated() const {}; //FIXME: Implement and document this | 407 | virtual bool isAssociated() const {}; //FIXME: Implement and document this |
403 | virtual QString associatedAP() const; //FIXME: Implement and document this | 408 | /** |
404 | 409 | * @returns the MAC address of the Access Point if the | |
405 | virtual void setSSID( const QString& ); | 410 | * device is in infrastructure mode. @returns a (more or less random) CELL |
411 | * address if the device is in adhoc mode. | ||
412 | */ | ||
413 | virtual QString associatedAP() const; | ||
414 | /** | ||
415 | * Set the @a ssid (Service Set ID) string. This is used to decide | ||
416 | * which network to associate with (use "any" to let the driver decide). | ||
417 | */ | ||
418 | virtual void setSSID( const QString& ssid ); | ||
419 | /** | ||
420 | * @returns the current SSID (Service Set ID). | ||
421 | */ | ||
406 | virtual QString SSID() const; | 422 | virtual QString SSID() const; |
407 | 423 | ||
408 | protected: | 424 | protected: |