aboutsummaryrefslogtreecommitdiffstats
path: root/nexus/ScanResult.cpp
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-05-10 09:27:07 -0700
committerSan Mehat <san@google.com>2009-05-12 14:02:32 -0700
commit69772dc644e1ccc12b6394267f010100470f3c95 (patch)
tree687e8fa9015bb4dbd176a21553c16f2803e8cc9e /nexus/ScanResult.cpp
parentd768066ef54270a0d3ccfccd50ae8238db5a2cdd (diff)
downloadsystem_core-69772dc644e1ccc12b6394267f010100470f3c95.tar.gz
system_core-69772dc644e1ccc12b6394267f010100470f3c95.tar.bz2
system_core-69772dc644e1ccc12b6394267f010100470f3c95.zip
nexus: Move to a line based protocol (similar to FTP) + fix bugs
Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'nexus/ScanResult.cpp')
-rw-r--r--nexus/ScanResult.cpp58
1 files changed, 41 insertions, 17 deletions
diff --git a/nexus/ScanResult.cpp b/nexus/ScanResult.cpp
index b7237b57..dc7599af 100644
--- a/nexus/ScanResult.cpp
+++ b/nexus/ScanResult.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <stdlib.h>
+#include <ctype.h>
#define LOG_TAG "ScanResult"
#include <cutils/log.h>
@@ -24,30 +25,53 @@ ScanResult::ScanResult() {
}
ScanResult::ScanResult(char *rawResult) {
- char *tok, *next = NULL;
+ char *p = rawResult, *q = rawResult;
+ char tmp[255];
- if (!(tok = strtok_r(rawResult, "\t", &next)))
- goto out_bad;
- mBssid = strdup(tok);
+ // BSSID
+ for (q = p; *q != '\t'; ++q);
+ strncpy(tmp, p, (q - p));
+ tmp[q-p] = '\0';
+ mBssid = strdup(tmp);
+ ++q;
- if (!(tok = strtok_r(NULL, "\t", &next)))
- goto out_bad;
- mFreq = atoi(tok);
+ // FREQ
+ for (p = q; *q != '\t'; ++q);
+ strncpy(tmp, p, (q - p));
+ tmp[q-p] = '\0';
+ mFreq = atoi(tmp);
+ ++q;
- if (!(tok = strtok_r(NULL, "\t", &next)))
- goto out_bad;
- mLevel = atoi(tok);
+ // LEVEL
+ for (p = q; *q != '\t'; ++q);
+ strncpy(tmp, p, (q - p));
+ tmp[q-p] = '\0';
+ mLevel = atoi(tmp);
+ ++q;
- if (!(tok = strtok_r(rawResult, "\t", &next)))
- goto out_bad;
- mFlags = strdup(tok);
+ // FLAGS
+ for (p = q; *q != '\t'; ++q);
+ strncpy(tmp, p, (q - p));
+ tmp[q-p] = '\0';
+ mFlags = strdup(tmp);
+ ++q;
- if (!(tok = strtok_r(rawResult, "\t", &next)))
- goto out_bad;
- mSsid = strdup(tok);
+ // XXX: For some reason Supplicant sometimes sends a double-tab here.
+ // haven't had time to dig into it ...
+ if (*q == '\t')
+ q++;
+
+ for (p = q; *q != '\t'; ++q) {
+ if (*q == '\0')
+ break;
+ }
- return;
+ strncpy(tmp, p, (q - p));
+ tmp[q-p] = '\0';
+ mSsid = strdup(tmp);
+ ++q;
+ return;
out_bad:
LOGW("Malformatted scan result (%s)", rawResult);
}