summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-06-01 10:04:21 -0700
committerSan Mehat <san@google.com>2009-06-02 10:26:58 -0700
commit21e90f0e10b5a75e583b10799c0084ddab3433d6 (patch)
treec4b287dd51b1bc4d14a3eaf467a699dae23a0aa8
parent78828ff4f5f959fcf8066ecb6a6b689d2a3c5985 (diff)
downloadsystem_core-21e90f0e10b5a75e583b10799c0084ddab3433d6.zip
system_core-21e90f0e10b5a75e583b10799c0084ddab3433d6.tar.gz
system_core-21e90f0e10b5a75e583b10799c0084ddab3433d6.tar.bz2
nexus: Validate that priority and KeyManagement are set before enabling a network
Signed-off-by: San Mehat <san@google.com>
-rw-r--r--nexus/WifiNetwork.cpp14
-rw-r--r--nexus/WifiNetwork.h9
2 files changed, 19 insertions, 4 deletions
diff --git a/nexus/WifiNetwork.cpp b/nexus/WifiNetwork.cpp
index 1f53a20..818b91d 100644
--- a/nexus/WifiNetwork.cpp
+++ b/nexus/WifiNetwork.cpp
@@ -551,6 +551,20 @@ int WifiNetwork::setAllowedGroupCiphers(uint32_t mask) {
}
int WifiNetwork::setEnabled(bool enabled) {
+
+ if (enabled) {
+ if (getPriority() == -1) {
+ LOGE("Cannot enable network when priority is not set");
+ errno = EAGAIN;
+ return -1;
+ }
+ if (getAllowedKeyManagement() == KeyManagementMask::UNKNOWN) {
+ LOGE("Cannot enable network when KeyManagement is not set");
+ errno = EAGAIN;
+ return -1;
+ }
+ }
+
if (mSuppl->enableNetwork(mNetid, enabled))
return -1;
diff --git a/nexus/WifiNetwork.h b/nexus/WifiNetwork.h
index bdffa8b..360ccc2 100644
--- a/nexus/WifiNetwork.h
+++ b/nexus/WifiNetwork.h
@@ -23,10 +23,11 @@
class KeyManagementMask {
public:
- static const uint32_t NONE = 0;
- static const uint32_t WPA_PSK = 0x01;
- static const uint32_t WPA_EAP = 0x02;
- static const uint32_t IEEE8021X = 0x04;
+ static const uint32_t UNKNOWN = 0;
+ static const uint32_t NONE = 0x01;
+ static const uint32_t WPA_PSK = 0x02;
+ static const uint32_t WPA_EAP = 0x04;
+ static const uint32_t IEEE8021X = 0x08;
static const uint32_t ALL = WPA_PSK | WPA_EAP | IEEE8021X;
};