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
@@ -39,12 +39,13 @@
39 39
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
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>
48#include <cstdlib> 49#include <cstdlib>
49#include <math.h> 50#include <math.h>
50#include <sys/ioctl.h> 51#include <sys/ioctl.h>
@@ -636,12 +637,54 @@ int OWirelessNetworkInterface::channelHopping() const
636OChannelHopper* OWirelessNetworkInterface::channelHopper() const 637OChannelHopper* OWirelessNetworkInterface::channelHopper() const
637{ 638{
638 return _hopper; 639 return _hopper;
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 )
645 _mon->setEnabled( b ); 688 _mon->setEnabled( b );
646 else 689 else
647 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 690 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
@@ -653,12 +696,20 @@ bool OWirelessNetworkInterface::monitorMode() const
653 qDebug( "dataLinkType = %d", dataLinkType() ); 696 qDebug( "dataLinkType = %d", dataLinkType() );
654 return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); 697 return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 );
655 // 802 is the header type for PRISM - Linux support for this is pending... 698 // 802 is the header type for PRISM - Linux support for this is pending...
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];
662 _iwr.u.data.pointer = &str[0]; 713 _iwr.u.data.pointer = &str[0];
663 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 714 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
664 if ( !wioctl( SIOCGIWNICKN ) ) 715 if ( !wioctl( SIOCGIWNICKN ) )