system/corennnnn
Révision | d0290eadc563f5a34fc1969f91621860d8756eff (tree) |
---|---|
l'heure | 2009-06-17 04:01:50 |
Auteur | San Mehat <san@goog...> |
Commiter | San Mehat |
nexus: Fix SupplicantStatus decoding
Signed-off-by: San Mehat <san@google.com>
@@ -17,7 +17,7 @@ | ||
17 | 17 | #include <stdlib.h> |
18 | 18 | #include <string.h> |
19 | 19 | |
20 | -#define LOG_TAG "SupplicantState" | |
20 | +#define LOG_TAG "SupplicantStatus" | |
21 | 21 | #include <cutils/log.h> |
22 | 22 | |
23 | 23 | #include "SupplicantStatus.h" |
@@ -52,18 +52,37 @@ SupplicantStatus *SupplicantStatus::createStatus(char *data, int len) { | ||
52 | 52 | char *next = data; |
53 | 53 | char *line; |
54 | 54 | while((line = strsep(&next, "\n"))) { |
55 | - char *token = strsep(&next, "="); | |
56 | - char *value = strsep(&next, "="); | |
57 | - | |
55 | + char *line_next = line; | |
56 | + char *token = strsep(&line_next, "="); | |
57 | + char *value = strsep(&line_next, "="); | |
58 | 58 | if (!strcmp(token, "bssid")) |
59 | 59 | bssid = strdup(value); |
60 | 60 | else if (!strcmp(token, "ssid")) |
61 | 61 | ssid = strdup(value); |
62 | 62 | else if (!strcmp(token, "id")) |
63 | 63 | id = atoi(value); |
64 | - else if (!strcmp(token, "wpa_state")) | |
65 | - state = atoi(value); | |
66 | - else | |
64 | + else if (!strcmp(token, "wpa_state")) { | |
65 | + if (!strcmp(value, "DISCONNECTED")) | |
66 | + state = SupplicantState::DISCONNECTED; | |
67 | + else if (!strcmp(value, "INACTIVE")) | |
68 | + state = SupplicantState::INACTIVE; | |
69 | + else if (!strcmp(value, "SCANNING")) | |
70 | + state = SupplicantState::SCANNING; | |
71 | + else if (!strcmp(value, "ASSOCIATING")) | |
72 | + state = SupplicantState::ASSOCIATING; | |
73 | + else if (!strcmp(value, "ASSOCIATED")) | |
74 | + state = SupplicantState::ASSOCIATED; | |
75 | + else if (!strcmp(value, "FOURWAY_HANDSHAKE")) | |
76 | + state = SupplicantState::FOURWAY_HANDSHAKE; | |
77 | + else if (!strcmp(value, "GROUP_HANDSHAKE")) | |
78 | + state = SupplicantState::GROUP_HANDSHAKE; | |
79 | + else if (!strcmp(value, "COMPLETED")) | |
80 | + state = SupplicantState::COMPLETED; | |
81 | + else if (!strcmp(value, "IDLE")) | |
82 | + state = SupplicantState::IDLE; | |
83 | + else | |
84 | + LOGE("Unknown supplicant state '%s'", value); | |
85 | + } else | |
67 | 86 | LOGD("Ignoring unsupported status token '%s'", token); |
68 | 87 | } |
69 | 88 |