-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 18 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 28 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 3 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 50 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 8 |
5 files changed, 73 insertions, 34 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index b010ac5..020fc23 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -30,2 +30,4 @@ int main( int argc, char** argv ) | |||
30 | 30 | ||
31 | /* | ||
32 | |||
31 | // first some wrong calls to check if this is working | 33 | // first some wrong calls to check if this is working |
@@ -36,2 +38,18 @@ int main( int argc, char** argv ) | |||
36 | iface->setPrivate( "monitor", 2, 2, 3 ); | 38 | iface->setPrivate( "monitor", 2, 2, 3 ); |
39 | |||
40 | */ | ||
41 | |||
42 | // trying to set hw address to 12:34:56:AB:CD:EF | ||
43 | |||
44 | /* | ||
45 | |||
46 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | ||
47 | iface->setUp( false ); | ||
48 | iface->setMacAddress( addr ); | ||
49 | iface->setUp( true ); | ||
50 | qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); | ||
51 | |||
52 | */ | ||
53 | |||
54 | |||
37 | } | 55 | } |
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index b317810..0fb21ff 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp | |||
@@ -64,3 +64,3 @@ OMacAddress::OMacAddress( unsigned char* p ) | |||
64 | { | 64 | { |
65 | memcpy( _bytes, p, 6 ); // D'OH! memcpy in my sources... eeek... | 65 | memcpy( _bytes, p, 6 ); |
66 | } | 66 | } |
@@ -85,2 +85,28 @@ OMacAddress::~OMacAddress() | |||
85 | 85 | ||
86 | #ifdef QT_NO_DEBUG | ||
87 | inline | ||
88 | #endif | ||
89 | const unsigned char* OMacAddress::native() const | ||
90 | { | ||
91 | return (const unsigned char*) &_bytes; | ||
92 | } | ||
93 | |||
94 | |||
95 | OMacAddress OMacAddress::fromString( const QString& str ) | ||
96 | { | ||
97 | QString addr( str ); | ||
98 | unsigned char buf[6]; | ||
99 | bool ok = true; | ||
100 | int index = 14; | ||
101 | for ( int i = 5; i >= 0; --i ) | ||
102 | { | ||
103 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); | ||
104 | if ( !ok ) return OMacAddress::unknown; | ||
105 | addr.truncate( index ); | ||
106 | index -= 3; | ||
107 | } | ||
108 | return (const unsigned char*) &buf; | ||
109 | } | ||
110 | |||
111 | |||
86 | QString OMacAddress::toString() const | 112 | QString OMacAddress::toString() const |
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 8be042b..73d52cc 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h | |||
@@ -58,2 +58,5 @@ class OMacAddress | |||
58 | QString toString() const; | 58 | QString toString() const; |
59 | const unsigned char* native() const; | ||
60 | |||
61 | static OMacAddress fromString( const QString& ); | ||
59 | 62 | ||
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index f52279a..e916c44 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -226,2 +226,10 @@ QString ONetworkInterface::ipV4Address() const | |||
226 | 226 | ||
227 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | ||
228 | { | ||
229 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | ||
230 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | ||
231 | ioctl( SIOCSIFHWADDR ); | ||
232 | } | ||
233 | |||
234 | |||
227 | OMacAddress ONetworkInterface::macAddress() const | 235 | OMacAddress ONetworkInterface::macAddress() const |
@@ -649,2 +657,9 @@ void OWirelessNetworkInterface::getPrivate( const QString& call ) | |||
649 | { | 657 | { |
658 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); | ||
659 | } | ||
660 | |||
661 | |||
662 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | ||
663 | { | ||
664 | return child( (const char*) call ); | ||
650 | } | 665 | } |
@@ -836,13 +851,8 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) | |||
836 | 851 | ||
852 | //TODO: check wireless extensions version on runtime and use | ||
853 | //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 | ||
854 | |||
837 | if ( b ) | 855 | if ( b ) |
838 | { | 856 | { |
839 | #if WIRELESS_EXT > 14 | 857 | _if->setPrivate( "monitor", 1, 2 ); |
840 | _if->_iwr.u.mode = IW_MODE_MONITOR; | ||
841 | _if->wioctl( SIOCSIWMODE ); | ||
842 | #else | ||
843 | int* args = (int*) &_if->_iwr.u.name; | ||
844 | args[0] = 2; | ||
845 | args[1] = 0; | ||
846 | _if->wioctl( SIOCDEVPRIVATE ); | ||
847 | #endif | ||
848 | } | 858 | } |
@@ -850,11 +860,3 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) | |||
850 | { | 860 | { |
851 | #if WIRELESS_EXT > 14 | 861 | _if->setPrivate( "monitor", 1, 0 ); |
852 | _if->_iwr.u.mode = IW_MODE_INFRA; | ||
853 | _if->wioctl( SIOCSIWMODE ); | ||
854 | #else | ||
855 | int* args = (int*) &_if->_iwr.u.name; | ||
856 | args[0] = 0; | ||
857 | args[1] = 0; | ||
858 | _if->wioctl( SIOCDEVPRIVATE ); | ||
859 | #endif | ||
860 | } | 862 | } |
@@ -887,7 +889,3 @@ void OOrinocoMonitoringInterface::setChannel( int c ) | |||
887 | { | 889 | { |
888 | // call iwpriv <device> monitor 2 <channel> | 890 | _if->setPrivate( "monitor", 2, 2, c ); |
889 | int* args = (int*) &_if->_iwr.u.name; | ||
890 | args[0] = 2; | ||
891 | args[1] = c; | ||
892 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); | ||
893 | } | 891 | } |
@@ -903,7 +901,3 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) | |||
903 | { | 901 | { |
904 | // call iwpriv <device> monitor 0 0 | 902 | _if->setPrivate( "monitor", 2, 0, 0 ); |
905 | int* args = (int*) &_if->_iwr.u.name; | ||
906 | args[0] = 0; | ||
907 | args[1] = 0; | ||
908 | _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); | ||
909 | } | 903 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 4cadbeb..e249aee 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -65,6 +65,2 @@ | |||
65 | 65 | ||
66 | #ifndef SIOCIWFIRSTPRIV | ||
67 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | ||
68 | #endif | ||
69 | |||
70 | class ONetworkInterface; | 66 | class ONetworkInterface; |
@@ -127,2 +123,3 @@ class ONetworkInterface : public QObject | |||
127 | QString ipV4Address() const; | 123 | QString ipV4Address() const; |
124 | void setMacAddress( const OMacAddress& ); | ||
128 | OMacAddress macAddress() const; | 125 | OMacAddress macAddress() const; |
@@ -206,2 +203,3 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
206 | virtual void setPrivate( const QString&, int, ... ); | 203 | virtual void setPrivate( const QString&, int, ... ); |
204 | virtual bool hasPrivate( const QString& ); | ||
207 | virtual void getPrivate( const QString& ); | 205 | virtual void getPrivate( const QString& ); |
@@ -251,3 +249,3 @@ class OMonitoringInterface | |||
251 | protected: | 249 | protected: |
252 | const OWirelessNetworkInterface* _if; | 250 | OWirelessNetworkInterface* _if; |
253 | 251 | ||