summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
Unidiff
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp51
1 files changed, 51 insertions, 0 deletions
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
643void 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
663QString 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
642void OWirelessNetworkInterface::setMonitorMode( bool b ) 685void 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
702void 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
659QString OWirelessNetworkInterface::nickName() const 710QString OWirelessNetworkInterface::nickName() const
660{ 711{
661 char str[IW_ESSID_MAX_SIZE]; 712 char str[IW_ESSID_MAX_SIZE];