author | skyhusker <skyhusker> | 2005-04-20 10:20:20 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-04-20 10:20:20 (UTC) |
commit | f6b9c85c09692f298ffa5ee95e1f171a9e158502 (patch) (unidiff) | |
tree | d147bc5b67eb9bc3c7f042a4fa2fb1868d37faef | |
parent | 6ec538f7e4a84e4f76addaf558c415b7dffc659b (diff) | |
download | opie-f6b9c85c09692f298ffa5ee95e1f171a9e158502.zip opie-f6b9c85c09692f298ffa5ee95e1f171a9e158502.tar.gz opie-f6b9c85c09692f298ffa5ee95e1f171a9e158502.tar.bz2 |
Added function to set the associated AP address. Some improvements to scanNetwork(): read the signal quality, AP rates and fix channel reading when driver reports values < 1000.
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 36 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 3 | ||||
-rw-r--r-- | libopie2/opienet/ostation.h | 2 |
3 files changed, 37 insertions, 4 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 546be9e..0a74019 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qapplication.h> | ||
41 | 42 | ||
42 | /* UNIX */ | 43 | /* UNIX */ |
43 | 44 | ||
@@ -53,6 +54,7 @@ | |||
53 | #include <unistd.h> | 54 | #include <unistd.h> |
54 | #include <linux/sockios.h> | 55 | #include <linux/sockios.h> |
55 | #include <net/if_arp.h> | 56 | #include <net/if_arp.h> |
57 | #include <net/ethernet.h> | ||
56 | #include <stdarg.h> | 58 | #include <stdarg.h> |
57 | 59 | ||
58 | #ifndef NODEBUG | 60 | #ifndef NODEBUG |
@@ -491,6 +493,14 @@ bool OWirelessNetworkInterface::isAssociated() const | |||
491 | } | 493 | } |
492 | 494 | ||
493 | 495 | ||
496 | void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const | ||
497 | { | ||
498 | _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; | ||
499 | ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); | ||
500 | wioctl( SIOCSIWAP ); | ||
501 | } | ||
502 | |||
503 | |||
494 | OMacAddress OWirelessNetworkInterface::associatedAP() const | 504 | OMacAddress OWirelessNetworkInterface::associatedAP() const |
495 | { | 505 | { |
496 | if ( ioctl( SIOCGIWAP ) ) | 506 | if ( ioctl( SIOCGIWAP ) ) |
@@ -906,13 +916,11 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
906 | else if ( errno == EAGAIN) | 916 | else if ( errno == EAGAIN) |
907 | { | 917 | { |
908 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; | 918 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; |
909 | #if 0 | ||
910 | if ( qApp ) | 919 | if ( qApp ) |
911 | { | 920 | { |
912 | qApp->processEvents( 100 ); | 921 | qApp->processEvents( 100 ); |
913 | continue; | 922 | continue; |
914 | } | 923 | } |
915 | #endif | ||
916 | tv.tv_sec = 0; | 924 | tv.tv_sec = 0; |
917 | tv.tv_usec = 100000; | 925 | tv.tv_usec = 100000; |
918 | continue; | 926 | continue; |
@@ -1127,7 +1135,10 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
1127 | case SIOCGIWFREQ: | 1135 | case SIOCGIWFREQ: |
1128 | { | 1136 | { |
1129 | odebug << "SIOCGIWFREQ" << oendl; | 1137 | odebug << "SIOCGIWFREQ" << oendl; |
1138 | if ( we->u.freq.m > 1000 ) | ||
1130 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; | 1139 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; |
1140 | else | ||
1141 | stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e )); | ||
1131 | break; | 1142 | break; |
1132 | } | 1143 | } |
1133 | case SIOCGIWESSID: | 1144 | case SIOCGIWESSID: |
@@ -1138,10 +1149,27 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
1138 | odebug << "ESSID: " << stations->last()->ssid << oendl; | 1149 | odebug << "ESSID: " << stations->last()->ssid << oendl; |
1139 | break; | 1150 | break; |
1140 | } | 1151 | } |
1152 | case IWEVQUAL: | ||
1153 | { | ||
1154 | odebug << "IWEVQUAL" << oendl; | ||
1155 | stations->last()->level = static_cast<int>(we->u.qual.level); | ||
1156 | break; /* Quality part of statistics (scan) */ | ||
1157 | } | ||
1158 | case SIOCGIWENCODE: | ||
1159 | { | ||
1160 | odebug << "SIOCGIWENCODE" << oendl; | ||
1161 | stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); | ||
1162 | break; | ||
1163 | } | ||
1164 | |||
1165 | case SIOCGIWRATE: | ||
1166 | { | ||
1167 | odebug << "SIOCGIWRATE" << oendl; | ||
1168 | stations->last()->rates.append(we->u.bitrate.value); | ||
1169 | break; | ||
1170 | } | ||
1141 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; | 1171 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; |
1142 | case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break; | ||
1143 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ | 1172 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ |
1144 | case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */ | ||
1145 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ | 1173 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ |
1146 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ | 1174 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ |
1147 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ | 1175 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 4d9912d..fa9f39f 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -413,6 +413,9 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
413 | * @note: This information is only valid if the interface is in managed mode. | 413 | * @note: This information is only valid if the interface is in managed mode. |
414 | */ | 414 | */ |
415 | virtual bool isAssociated() const; | 415 | virtual bool isAssociated() const; |
416 | /** Set the @a mac associated AP address. | ||
417 | */ | ||
418 | virtual void setAssociatedAP( const OMacAddress& mac ) const; | ||
416 | /** | 419 | /** |
417 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. | 420 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. |
418 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. | 421 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. |
diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h index 5219d92..86c9a52 100644 --- a/libopie2/opienet/ostation.h +++ b/libopie2/opienet/ostation.h | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | #include <qhostaddress.h> | 38 | #include <qhostaddress.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | #include <qvaluelist.h> | ||
40 | 41 | ||
41 | #include <sys/types.h> | 42 | #include <sys/types.h> |
42 | 43 | ||
@@ -71,6 +72,7 @@ class OStation | |||
71 | int channel; | 72 | int channel; |
72 | int level; | 73 | int level; |
73 | bool encrypted; | 74 | bool encrypted; |
75 | QValueList <int> rates; | ||
74 | private: | 76 | private: |
75 | class Private; | 77 | class Private; |
76 | Private *d; | 78 | Private *d; |