-rw-r--r-- | libopie2/opienet/onetwork.cpp | 45 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 6 | ||||
-rw-r--r-- | libopie2/opienet/ostation.cpp | 49 | ||||
-rw-r--r-- | libopie2/opienet/ostation.h | 67 |
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 | |||
@@ -21,32 +21,33 @@ | |||
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> |
@@ -868,37 +869,79 @@ int OWirelessNetworkInterface::scanNetwork() | |||
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 | ||
893 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 936 | bool 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 |
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 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = 802_11_user.h \ | 4 | HEADERS = 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 | ||
13 | SOURCES = oioctlmap.cpp \ | 14 | SOURCES = 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 | ||
18 | INTERFACES = | 20 | INTERFACES = |
19 | TARGET = opienet2 | 21 | TARGET = opienet2 |
20 | VERSION = 1.8.1 | 22 | VERSION = 1.8.1 |
21 | INCLUDEPATH += $(OPIEDIR)/include | 23 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH += $(OPIEDIR)/include | 24 | DEPENDPATH += $(OPIEDIR)/include |
23 | LIBS += -lpcap | 25 | LIBS += -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 | ||
30 | contains( platform, x11 ) { | 32 | contains( 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 | |||
38 | OStation::OStation() | ||
39 | { | ||
40 | qDebug( "OStation::OStation()" ); | ||
41 | } | ||
42 | |||
43 | |||
44 | OStation::~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 | |||
45 | class OStation; | ||
46 | |||
47 | typedef QDict<OStation> OStationDict; | ||
48 | |||
49 | /*====================================================================================== | ||
50 | * OStation | ||
51 | *======================================================================================*/ | ||
52 | |||
53 | class 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 | |||