mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
common: Add security_from_str
The reverse operation of security_to_str.
This commit is contained in:
parent
0cb233cdde
commit
8be78588e2
17
src/common.c
17
src/common.c
@ -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;
|
||||||
|
}
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user