3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

common: Add security_from_str

The reverse operation of security_to_str.
This commit is contained in:
Andrew Zaborowski 2016-06-07 05:29:57 +02:00 committed by Denis Kenzior
parent 0cb233cdde
commit 8be78588e2
2 changed files with 22 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#endif #endif
#include <stddef.h> #include <stddef.h>
#include <string.h>
#include "src/iwd.h" #include "src/iwd.h"
#include "src/common.h" #include "src/common.h"
@ -44,3 +45,19 @@ const char *security_to_str(enum security security)
return NULL; return NULL;
} }
bool security_from_str(const char *str, enum security *security)
{
if (!strcmp(str, "open"))
*security = SECURITY_NONE;
else if (!strcmp(str, "wep"))
*security = SECURITY_WEP;
else if (!strcmp(str, "psk"))
*security = SECURITY_PSK;
else if (!strcmp(str, "8021x"))
*security = SECURITY_8021X;
else
return false;
return true;
}

View File

@ -20,4 +20,9 @@
* *
*/ */
#include <stdbool.h>
enum security;
const char *security_to_str(enum security security); const char *security_to_str(enum security security);
bool security_from_str(const char *str, enum security *security);