Denislam Valeev / Mbed OS Nucleo_rtos_basic
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers get_security.cpp Source File

get_security.cpp

00001 /*
00002  * Copyright (c) 2017, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00006  * not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #include <cstring>
00019 #include "mbed.h"
00020 #include "nsapi_types.h"
00021 
00022 nsapi_security get_security()
00023 {
00024 #if defined MBED_CONF_APP_WIFI_SECURE_PROTOCOL
00025     static const char *SEC_WEP = "WEP";
00026     static const char *SEC_WPA = "WPA";
00027     static const char *SEC_WPA2 = "WPA2";
00028     static const char *SEC_WPA_WPA2 = "WPA/WPA2";
00029 
00030     if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WEP) == 0) {
00031         return NSAPI_SECURITY_WEP ;
00032     }
00033     if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA) == 0) {
00034         return NSAPI_SECURITY_WPA ;
00035     }
00036     if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA2) == 0) {
00037         return NSAPI_SECURITY_WPA2 ;
00038     }
00039     if (strcmp(MBED_CONF_APP_WIFI_SECURE_PROTOCOL, SEC_WPA_WPA2) == 0) {
00040         return NSAPI_SECURITY_WPA_WPA2 ;
00041     }
00042 #endif
00043     return NSAPI_SECURITY_NONE ;
00044 }