San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 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 | |
| 24 | char *SupplicantState::toString(int val, char *buffer, int max) { |
| 25 | if (val == SupplicantState::UNKNOWN) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 26 | strncpy(buffer, "UNKNOWN", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 27 | else if (val == SupplicantState::DISCONNECTED) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 28 | strncpy(buffer, "DISCONNECTED", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 29 | else if (val == SupplicantState::INACTIVE) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 30 | strncpy(buffer, "INACTIVE", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 31 | else if (val == SupplicantState::SCANNING) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 32 | strncpy(buffer, "SCANNING", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 33 | else if (val == SupplicantState::ASSOCIATING) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 34 | strncpy(buffer, "ASSOCIATING", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 35 | else if (val == SupplicantState::ASSOCIATED) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 36 | strncpy(buffer, "ASSOCIATED", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 37 | else if (val == SupplicantState::FOURWAY_HANDSHAKE) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 38 | strncpy(buffer, "FOURWAY_HANDSHAKE", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 39 | else if (val == SupplicantState::GROUP_HANDSHAKE) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 40 | strncpy(buffer, "GROUP_HANDSHAKE", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 41 | else if (val == SupplicantState::COMPLETED) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 42 | strncpy(buffer, "COMPLETED", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 43 | else if (val == SupplicantState::IDLE) |
San Mehat | c4a895b | 2009-06-23 21:10:57 -0700 | [diff] [blame] | 44 | strncpy(buffer, "IDLE", max); |
San Mehat | 3c5a6f0 | 2009-05-22 15:36:13 -0700 | [diff] [blame] | 45 | else |
| 46 | strncpy(buffer, "(internal error)", max); |
| 47 | |
| 48 | return buffer; |
| 49 | } |