1 /*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <stdio.h>
18
19 #define LOG_TAG "SupplicantState"
20 #include <cutils/log.h>
21
22 #include "SupplicantState.h"
23
toString(int val,char * buffer,int max)24 char *SupplicantState::toString(int val, char *buffer, int max) {
25 if (val == SupplicantState::UNKNOWN)
26 strncpy(buffer, "UNKNOWN", max);
27 else if (val == SupplicantState::DISCONNECTED)
28 strncpy(buffer, "DISCONNECTED", max);
29 else if (val == SupplicantState::INACTIVE)
30 strncpy(buffer, "INACTIVE", max);
31 else if (val == SupplicantState::SCANNING)
32 strncpy(buffer, "SCANNING", max);
33 else if (val == SupplicantState::ASSOCIATING)
34 strncpy(buffer, "ASSOCIATING", max);
35 else if (val == SupplicantState::ASSOCIATED)
36 strncpy(buffer, "ASSOCIATED", max);
37 else if (val == SupplicantState::FOURWAY_HANDSHAKE)
38 strncpy(buffer, "FOURWAY_HANDSHAKE", max);
39 else if (val == SupplicantState::GROUP_HANDSHAKE)
40 strncpy(buffer, "GROUP_HANDSHAKE", max);
41 else if (val == SupplicantState::COMPLETED)
42 strncpy(buffer, "COMPLETED", max);
43 else if (val == SupplicantState::IDLE)
44 strncpy(buffer, "IDLE", max);
45 else
46 strncpy(buffer, "(internal error)", max);
47
48 return buffer;
49 }
50