diff --git a/src/common.c b/src/common.c index 71376815..77265994 100644 --- a/src/common.c +++ b/src/common.c @@ -25,6 +25,7 @@ #endif #include +#include #include "src/iwd.h" #include "src/common.h" @@ -44,3 +45,19 @@ const char *security_to_str(enum security security) 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; +} diff --git a/src/common.h b/src/common.h index e300524e..766d0bea 100644 --- a/src/common.h +++ b/src/common.h @@ -20,4 +20,9 @@ * */ +#include + +enum security; + const char *security_to_str(enum security security); +bool security_from_str(const char *str, enum security *security);