summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-21 18:09:34 (UTC)
committer mickeyl <mickeyl>2003-10-21 18:09:34 (UTC)
commit3e9d8077999bd928b7103bd19f7b41f305c573d9 (patch) (unidiff)
tree507ee7f3a1539d02af159fb0fed4153e08c5ece0
parent76ca3158518a851085b5a5ebe3724d0c0c3be857 (diff)
downloadopie-3e9d8077999bd928b7103bd19f7b41f305c573d9.zip
opie-3e9d8077999bd928b7103bd19f7b41f305c573d9.tar.gz
opie-3e9d8077999bd928b7103bd19f7b41f305c573d9.tar.bz2
- more work on scanning
- start OStation class representing a network node
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp45
-rw-r--r--libopie2/opienet/opienet.pro6
-rw-r--r--libopie2/opienet/ostation.cpp49
-rw-r--r--libopie2/opienet/ostation.h67
4 files changed, 164 insertions, 3 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 918ba07..a85a510 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,164 +1,165 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34/* OPIE */ 34/* OPIE */
35 35
36#include <opie2/onetwork.h> 36#include <opie2/onetwork.h>
37#include <opie2/ostation.h>
37 38
38/* QT */ 39/* QT */
39 40
40#include <qfile.h> 41#include <qfile.h>
41#include <qtextstream.h> 42#include <qtextstream.h>
42 43
43/* UNIX */ 44/* UNIX */
44 45
45#include <assert.h> 46#include <assert.h>
46#include <arpa/inet.h> 47#include <arpa/inet.h>
47#include <cerrno> 48#include <cerrno>
48#include <cstring> 49#include <cstring>
49#include <cstdlib> 50#include <cstdlib>
50#include <math.h> 51#include <math.h>
51#include <sys/ioctl.h> 52#include <sys/ioctl.h>
52#include <sys/socket.h> 53#include <sys/socket.h>
53#include <sys/types.h> 54#include <sys/types.h>
54#include <unistd.h> 55#include <unistd.h>
55#include <linux/sockios.h> 56#include <linux/sockios.h>
56#include <net/if_arp.h> 57#include <net/if_arp.h>
57#include <stdarg.h> 58#include <stdarg.h>
58 59
59using namespace std; 60using namespace std;
60 61
61#ifndef NODEBUG 62#ifndef NODEBUG
62#include <opie2/oioctlmap.h> 63#include <opie2/oioctlmap.h>
63IntStringMap* _ioctlmap = constructIoctlMap(); 64IntStringMap* _ioctlmap = constructIoctlMap();
64#endif 65#endif
65 66
66/*====================================================================================== 67/*======================================================================================
67 * ONetwork 68 * ONetwork
68 *======================================================================================*/ 69 *======================================================================================*/
69 70
70ONetwork* ONetwork::_instance = 0; 71ONetwork* ONetwork::_instance = 0;
71 72
72ONetwork::ONetwork() 73ONetwork::ONetwork()
73{ 74{
74 qDebug( "ONetwork::ONetwork()" ); 75 qDebug( "ONetwork::ONetwork()" );
75 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); 76 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT );
76 synchronize(); 77 synchronize();
77} 78}
78 79
79void ONetwork::synchronize() 80void ONetwork::synchronize()
80{ 81{
81 // gather available interfaces by inspecting /proc/net/dev 82 // gather available interfaces by inspecting /proc/net/dev
82 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 83 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
83 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 84 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
84 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 85 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
85 86
86 _interfaces.clear(); 87 _interfaces.clear();
87 QString str; 88 QString str;
88 QFile f( "/proc/net/dev" ); 89 QFile f( "/proc/net/dev" );
89 bool hasFile = f.open( IO_ReadOnly ); 90 bool hasFile = f.open( IO_ReadOnly );
90 if ( !hasFile ) 91 if ( !hasFile )
91 { 92 {
92 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); 93 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
93 return; 94 return;
94 } 95 }
95 QTextStream s( &f ); 96 QTextStream s( &f );
96 s.readLine(); 97 s.readLine();
97 s.readLine(); 98 s.readLine();
98 while ( !s.atEnd() ) 99 while ( !s.atEnd() )
99 { 100 {
100 s >> str; 101 s >> str;
101 str.truncate( str.find( ':' ) ); 102 str.truncate( str.find( ':' ) );
102 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 103 qDebug( "ONetwork: found interface '%s'", (const char*) str );
103 ONetworkInterface* iface; 104 ONetworkInterface* iface;
104 if ( isWirelessInterface( str ) ) 105 if ( isWirelessInterface( str ) )
105 { 106 {
106 iface = new OWirelessNetworkInterface( this, (const char*) str ); 107 iface = new OWirelessNetworkInterface( this, (const char*) str );
107 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 108 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
108 } 109 }
109 else 110 else
110 { 111 {
111 iface = new ONetworkInterface( this, (const char*) str ); 112 iface = new ONetworkInterface( this, (const char*) str );
112 } 113 }
113 _interfaces.insert( str, iface ); 114 _interfaces.insert( str, iface );
114 s.readLine(); 115 s.readLine();
115 } 116 }
116} 117}
117 118
118 119
119short ONetwork::wirelessExtensionVersion() 120short ONetwork::wirelessExtensionVersion()
120{ 121{
121 return WIRELESS_EXT; 122 return WIRELESS_EXT;
122} 123}
123 124
124 125
125int ONetwork::count() const 126int ONetwork::count() const
126{ 127{
127 return _interfaces.count(); 128 return _interfaces.count();
128} 129}
129 130
130 131
131ONetworkInterface* ONetwork::interface( const QString& iface ) const 132ONetworkInterface* ONetwork::interface( const QString& iface ) const
132{ 133{
133 return _interfaces[iface]; 134 return _interfaces[iface];
134} 135}
135 136
136 137
137ONetwork* ONetwork::instance() 138ONetwork* ONetwork::instance()
138{ 139{
139 if ( !_instance ) _instance = new ONetwork(); 140 if ( !_instance ) _instance = new ONetwork();
140 return _instance; 141 return _instance;
141} 142}
142 143
143 144
144ONetwork::InterfaceIterator ONetwork::iterator() const 145ONetwork::InterfaceIterator ONetwork::iterator() const
145{ 146{
146 return ONetwork::InterfaceIterator( _interfaces ); 147 return ONetwork::InterfaceIterator( _interfaces );
147} 148}
148 149
149 150
150bool ONetwork::isWirelessInterface( const char* name ) const 151bool ONetwork::isWirelessInterface( const char* name ) const
151{ 152{
152 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 153 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
153 struct iwreq iwr; 154 struct iwreq iwr;
154 memset( &iwr, 0, sizeof( struct iwreq ) ); 155 memset( &iwr, 0, sizeof( struct iwreq ) );
155 strcpy( (char*) &iwr.ifr_name, name ); 156 strcpy( (char*) &iwr.ifr_name, name );
156 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 157 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
157 return result != -1; 158 return result != -1;
158} 159}
159 160
160/*====================================================================================== 161/*======================================================================================
161 * ONetworkInterface 162 * ONetworkInterface
162 *======================================================================================*/ 163 *======================================================================================*/
163 164
164ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) 165ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
@@ -756,261 +757,303 @@ QString OWirelessNetworkInterface::nickName() const
756 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 757 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
757 if ( !wioctl( SIOCGIWNICKN ) ) 758 if ( !wioctl( SIOCGIWNICKN ) )
758 { 759 {
759 return "<unknown>"; 760 return "<unknown>";
760 } 761 }
761 else 762 else
762 { 763 {
763 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 764 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
764 return str; 765 return str;
765 } 766 }
766} 767}
767 768
768 769
769void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) 770void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
770{ 771{
771 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 772 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
772 if ( !priv ) 773 if ( !priv )
773 { 774 {
774 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); 775 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call );
775 return; 776 return;
776 } 777 }
777 if ( priv->numberSetArgs() != numargs ) 778 if ( priv->numberSetArgs() != numargs )
778 { 779 {
779 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); 780 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs );
780 return; 781 return;
781 } 782 }
782 783
783 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); 784 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() );
784 memset( &_iwr, 0, sizeof _iwr ); 785 memset( &_iwr, 0, sizeof _iwr );
785 va_list argp; 786 va_list argp;
786 va_start( argp, numargs ); 787 va_start( argp, numargs );
787 for ( int i = 0; i < numargs; ++i ) 788 for ( int i = 0; i < numargs; ++i )
788 { 789 {
789 priv->setParameter( i, va_arg( argp, int ) ); 790 priv->setParameter( i, va_arg( argp, int ) );
790 } 791 }
791 va_end( argp ); 792 va_end( argp );
792 priv->invoke(); 793 priv->invoke();
793} 794}
794 795
795 796
796void OWirelessNetworkInterface::getPrivate( const QString& call ) 797void OWirelessNetworkInterface::getPrivate( const QString& call )
797{ 798{
798 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); 799 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
799} 800}
800 801
801 802
802bool OWirelessNetworkInterface::hasPrivate( const QString& call ) 803bool OWirelessNetworkInterface::hasPrivate( const QString& call )
803{ 804{
804 return child( (const char*) call ); 805 return child( (const char*) call );
805} 806}
806 807
807 808
808QString OWirelessNetworkInterface::SSID() const 809QString OWirelessNetworkInterface::SSID() const
809{ 810{
810 char str[IW_ESSID_MAX_SIZE]; 811 char str[IW_ESSID_MAX_SIZE];
811 _iwr.u.essid.pointer = &str[0]; 812 _iwr.u.essid.pointer = &str[0];
812 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 813 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
813 if ( !wioctl( SIOCGIWESSID ) ) 814 if ( !wioctl( SIOCGIWESSID ) )
814 { 815 {
815 return "<unknown>"; 816 return "<unknown>";
816 } 817 }
817 else 818 else
818 { 819 {
819 return str; 820 return str;
820 } 821 }
821} 822}
822 823
823 824
824void OWirelessNetworkInterface::setSSID( const QString& ssid ) 825void OWirelessNetworkInterface::setSSID( const QString& ssid )
825{ 826{
826 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 827 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
827 _iwr.u.essid.length = ssid.length(); 828 _iwr.u.essid.length = ssid.length();
828 wioctl( SIOCSIWESSID ); 829 wioctl( SIOCSIWESSID );
829} 830}
830 831
831 832
832int OWirelessNetworkInterface::scanNetwork() 833int OWirelessNetworkInterface::scanNetwork()
833{ 834{
834 _iwr.u.param.flags = IW_SCAN_DEFAULT; 835 _iwr.u.param.flags = IW_SCAN_DEFAULT;
835 _iwr.u.param.value = 0; 836 _iwr.u.param.value = 0;
836 if ( !wioctl( SIOCSIWSCAN ) ) 837 if ( !wioctl( SIOCSIWSCAN ) )
837 { 838 {
838 return -1; 839 return -1;
839 } 840 }
840 841
841 int timeout = 1000000; 842 int timeout = 1000000;
842 843
843 qDebug( "ONetworkInterface::scanNetwork() - scan started." ); 844 qDebug( "ONetworkInterface::scanNetwork() - scan started." );
844 845
845 bool results = false; 846 bool results = false;
846 struct timeval tv; 847 struct timeval tv;
847 tv.tv_sec = 0; 848 tv.tv_sec = 0;
848 tv.tv_usec = 250000; // initial timeout ~ 250ms 849 tv.tv_usec = 250000; // initial timeout ~ 250ms
849 char buffer[IW_SCAN_MAX_DATA]; 850 char buffer[IW_SCAN_MAX_DATA];
850 851
851 while ( !results && timeout > 0 ) 852 while ( !results && timeout > 0 )
852 { 853 {
853 timeout -= tv.tv_usec; 854 timeout -= tv.tv_usec;
854 select( 0, 0, 0, 0, &tv ); 855 select( 0, 0, 0, 0, &tv );
855 856
856 _iwr.u.data.pointer = &buffer[0]; 857 _iwr.u.data.pointer = &buffer[0];
857 _iwr.u.data.flags = 0; 858 _iwr.u.data.flags = 0;
858 _iwr.u.data.length = sizeof buffer; 859 _iwr.u.data.length = sizeof buffer;
859 if ( wioctl( SIOCGIWSCAN ) ) 860 if ( wioctl( SIOCGIWSCAN ) )
860 { 861 {
861 results = true; 862 results = true;
862 continue; 863 continue;
863 } 864 }
864 else if ( errno == EAGAIN) 865 else if ( errno == EAGAIN)
865 { 866 {
866 qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); 867 qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." );
867 #if 0 868 #if 0
868 if ( qApp ) 869 if ( qApp )
869 { 870 {
870 qApp->processEvents( 100 ); 871 qApp->processEvents( 100 );
871 continue; 872 continue;
872 } 873 }
873 #endif 874 #endif
874 tv.tv_sec = 0; 875 tv.tv_sec = 0;
875 tv.tv_usec = 100000; 876 tv.tv_usec = 100000;
876 continue; 877 continue;
877 } 878 }
878 } 879 }
879 880
880 qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); 881 qDebug( "ONetworkInterface::scanNetwork() - scan finished." );
881 882
882 if ( results ) 883 if ( results )
883 { 884 {
885 qDebug( " - result length = %d", _iwr.u.data.length );
886 if ( !_iwr.u.data.length )
887 {
888 qDebug( " - no results (empty neighbourhood)" );
889 return 0;
890 }
891
884 qDebug( " - results are in!" ); 892 qDebug( " - results are in!" );
893 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
894
895 int stations = 0;
896
897 // parse results
898
899 int offset = 0;
900 struct iw_event* we = (struct iw_event*) &buffer[0];
901
902 while ( offset < _iwr.u.data.length )
903 {
904 //const char* cmd = *(*_ioctlmap)[we->cmd];
905 //if ( !cmd ) cmd = "<unknown>";
906 qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len );
907 switch (we->cmd)
908 {
909 case SIOCGIWAP: qDebug( "SIOCGIWAP" ); stations++; break;
910 case SIOCGIWMODE: qDebug( "SIOCGIWMODE" ); break;
911 case SIOCGIWFREQ: qDebug( "SIOCGIWFREQ" ); break;
912 case SIOCGIWESSID: qDebug( "SIOCGIWESSID" ); break;
913 case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break;
914 case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break;
915 case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */
916 case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */
917 case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */
918 case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */
919 case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */
920 default: qDebug( "unhandled event" );
921 }
922
923 offset += we->len;
924 we = (struct iw_event*) &buffer[offset];
925 }
926
885 } 927 }
886 else 928 else
887 { 929 {
888 qDebug( " - no results :(" ); 930 qDebug( " - no results (timeout) :(" );
931 return 0;
889 } 932 }
890} 933}
891 934
892 935
893bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 936bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
894{ 937{
895 #ifndef NODEBUG 938 #ifndef NODEBUG
896 int result = ::ioctl( _sfd, call, &iwreq ); 939 int result = ::ioctl( _sfd, call, &iwreq );
897 if ( result == -1 ) 940 if ( result == -1 )
898 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); 941 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) );
899 else 942 else
900 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); 943 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call );
901 return ( result != -1 ); 944 return ( result != -1 );
902 #else 945 #else
903 return ::ioctl( _sfd, call, &iwreq ) != -1; 946 return ::ioctl( _sfd, call, &iwreq ) != -1;
904 #endif 947 #endif
905} 948}
906 949
907 950
908bool OWirelessNetworkInterface::wioctl( int call ) const 951bool OWirelessNetworkInterface::wioctl( int call ) const
909{ 952{
910 strcpy( _iwr.ifr_name, name() ); 953 strcpy( _iwr.ifr_name, name() );
911 return wioctl( call, _iwr ); 954 return wioctl( call, _iwr );
912} 955}
913 956
914 957
915/*====================================================================================== 958/*======================================================================================
916 * OMonitoringInterface 959 * OMonitoringInterface
917 *======================================================================================*/ 960 *======================================================================================*/
918 961
919OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 962OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
920 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 963 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
921{ 964{
922} 965}
923 966
924 967
925OMonitoringInterface::~OMonitoringInterface() 968OMonitoringInterface::~OMonitoringInterface()
926{ 969{
927} 970}
928 971
929 972
930void OMonitoringInterface::setChannel( int c ) 973void OMonitoringInterface::setChannel( int c )
931{ 974{
932 // use standard WE channel switching protocol 975 // use standard WE channel switching protocol
933 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 976 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
934 _if->_iwr.u.freq.m = c; 977 _if->_iwr.u.freq.m = c;
935 _if->_iwr.u.freq.e = 0; 978 _if->_iwr.u.freq.e = 0;
936 _if->wioctl( SIOCSIWFREQ ); 979 _if->wioctl( SIOCSIWFREQ );
937} 980}
938 981
939 982
940bool OMonitoringInterface::enabled() const 983bool OMonitoringInterface::enabled() const
941{ 984{
942 return _if->monitorMode(); 985 return _if->monitorMode();
943} 986}
944 987
945 988
946void OMonitoringInterface::setEnabled( bool b ) 989void OMonitoringInterface::setEnabled( bool b )
947{ 990{
948} 991}
949 992
950 993
951/*====================================================================================== 994/*======================================================================================
952 * OCiscoMonitoringInterface 995 * OCiscoMonitoringInterface
953 *======================================================================================*/ 996 *======================================================================================*/
954 997
955OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 998OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
956 :OMonitoringInterface( iface, prismHeader ) 999 :OMonitoringInterface( iface, prismHeader )
957{ 1000{
958 iface->setMonitoring( this ); 1001 iface->setMonitoring( this );
959} 1002}
960 1003
961 1004
962OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1005OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
963{ 1006{
964} 1007}
965 1008
966 1009
967void OCiscoMonitoringInterface::setEnabled( bool b ) 1010void OCiscoMonitoringInterface::setEnabled( bool b )
968{ 1011{
969 QString fname; 1012 QString fname;
970 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 1013 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
971 QFile f( fname ); 1014 QFile f( fname );
972 if ( !f.exists() ) return; 1015 if ( !f.exists() ) return;
973 1016
974 if ( f.open( IO_WriteOnly ) ) 1017 if ( f.open( IO_WriteOnly ) )
975 { 1018 {
976 QTextStream s( &f ); 1019 QTextStream s( &f );
977 s << "Mode: r"; 1020 s << "Mode: r";
978 s << "Mode: y"; 1021 s << "Mode: y";
979 s << "XmitPower: 1"; 1022 s << "XmitPower: 1";
980 } 1023 }
981 1024
982 // flushing and closing will be done automatically when f goes out of scope 1025 // flushing and closing will be done automatically when f goes out of scope
983} 1026}
984 1027
985 1028
986QString OCiscoMonitoringInterface::name() const 1029QString OCiscoMonitoringInterface::name() const
987{ 1030{
988 return "cisco"; 1031 return "cisco";
989} 1032}
990 1033
991 1034
992void OCiscoMonitoringInterface::setChannel( int ) 1035void OCiscoMonitoringInterface::setChannel( int )
993{ 1036{
994 // cisco devices automatically switch channels when in monitor mode 1037 // cisco devices automatically switch channels when in monitor mode
995} 1038}
996 1039
997 1040
998/*====================================================================================== 1041/*======================================================================================
999 * OWlanNGMonitoringInterface 1042 * OWlanNGMonitoringInterface
1000 *======================================================================================*/ 1043 *======================================================================================*/
1001 1044
1002 1045
1003OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1046OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1004 :OMonitoringInterface( iface, prismHeader ) 1047 :OMonitoringInterface( iface, prismHeader )
1005{ 1048{
1006 iface->setMonitoring( this ); 1049 iface->setMonitoring( this );
1007} 1050}
1008 1051
1009 1052
1010OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 1053OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
1011{ 1054{
1012} 1055}
1013 1056
1014 1057
1015void OWlanNGMonitoringInterface::setEnabled( bool b ) 1058void OWlanNGMonitoringInterface::setEnabled( bool b )
1016{ 1059{
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro
index 304d968..d966462 100644
--- a/libopie2/opienet/opienet.pro
+++ b/libopie2/opienet/opienet.pro
@@ -1,32 +1,34 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = 802_11_user.h \ 4HEADERS = 802_11_user.h \
5 dhcp.h \ 5 dhcp.h \
6 udp_ports.h \ 6 udp_ports.h \
7 wireless.h \ 7 wireless.h \
8 oioctlmap.h \ 8 oioctlmap.h \
9 omanufacturerdb.h \ 9 omanufacturerdb.h \
10 onetutils.h \ 10 onetutils.h \
11 onetwork.h \ 11 onetwork.h \
12 opcap.h 12 opcap.h \
13 ostation.h
13SOURCES = oioctlmap.cpp \ 14SOURCES = oioctlmap.cpp \
14 omanufacturerdb.cpp \ 15 omanufacturerdb.cpp \
15 onetutils.cpp \ 16 onetutils.cpp \
16 onetwork.cpp \ 17 onetwork.cpp \
17 opcap.cpp 18 opcap.cpp \
19 ostation.cpp
18INTERFACES = 20INTERFACES =
19TARGET = opienet2 21TARGET = opienet2
20VERSION = 1.8.1 22VERSION = 1.8.1
21INCLUDEPATH += $(OPIEDIR)/include 23INCLUDEPATH += $(OPIEDIR)/include
22DEPENDPATH += $(OPIEDIR)/include 24DEPENDPATH += $(OPIEDIR)/include
23LIBS += -lpcap 25LIBS += -lpcap
24 26
25 27
26!contains( platform, x11 ) { 28!contains( platform, x11 ) {
27 include ( $(OPIEDIR)/include.pro ) 29 include ( $(OPIEDIR)/include.pro )
28} 30}
29 31
30contains( platform, x11 ) { 32contains( platform, x11 ) {
31 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 33 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
32} 34}
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
new file mode 100644
index 0000000..3817b31
--- a/dev/null
+++ b/libopie2/opienet/ostation.cpp
@@ -0,0 +1,49 @@
1/*
2                 This file is part of the Opie Project
3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32#include <opie2/ostation.h>
33
34/*======================================================================================
35 * OStation
36 *======================================================================================*/
37
38OStation::OStation()
39{
40 qDebug( "OStation::OStation()" );
41}
42
43
44OStation::~OStation()
45{
46 qDebug( "OStation::~OStation()" );
47}
48
49
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h
new file mode 100644
index 0000000..f61570b
--- a/dev/null
+++ b/libopie2/opienet/ostation.h
@@ -0,0 +1,67 @@
1/*
2                 This file is part of the Opie Project
3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32#ifndef OSTATION_H
33#define OSTATION_H
34
35#include <opie2/onetutils.h>
36
37#include <qdict.h>
38#include <qmap.h>
39#include <qstring.h>
40#include <qhostaddress.h>
41#include <qobject.h>
42
43#include <sys/types.h>
44
45class OStation;
46
47typedef QDict<OStation> OStationDict;
48
49/*======================================================================================
50 * OStation
51 *======================================================================================*/
52
53class OStation
54{
55 public:
56 OStation();
57 ~OStation();
58
59 private:
60 OMacAddress macAddress;
61 QHostAddress ipAddress;
62 QString ssid;
63 QString type;
64};
65
66#endif // OSTATION_H
67