45c7a8ca6f972c15ec981083c776bd6edee877b2
[strongswan.git] / src / libcharon / sa / authenticators / eap / eap_method.c
1 /*
2 * Copyright (C) 2006 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "eap_method.h"
17
18 /*
19 * See header
20 */
21 eap_type_t eap_type_from_string(char *name)
22 {
23 int i;
24 static struct {
25 char *name;
26 eap_type_t type;
27 } types[] = {
28 {"identity", EAP_IDENTITY},
29 {"md5", EAP_MD5},
30 {"otp", EAP_OTP},
31 {"gtc", EAP_GTC},
32 {"tls", EAP_TLS},
33 {"ttls", EAP_TTLS},
34 {"sim", EAP_SIM},
35 {"aka", EAP_AKA},
36 {"mschapv2", EAP_MSCHAPV2},
37 {"radius", EAP_RADIUS},
38 };
39
40 for (i = 0; i < countof(types); i++)
41 {
42 if (strcaseeq(name, types[i].name))
43 {
44 return types[i].type;
45 }
46 }
47 return 0;
48 }
49
50 ENUM(eap_code_names, EAP_REQUEST, EAP_FAILURE,
51 "EAP_REQUEST",
52 "EAP_RESPONSE",
53 "EAP_SUCCESS",
54 "EAP_FAILURE",
55 );
56
57 ENUM(eap_code_short_names, EAP_REQUEST, EAP_FAILURE,
58 "REQ",
59 "RES",
60 "SUCC",
61 "FAIL",
62 );
63
64 ENUM(eap_role_names, EAP_SERVER, EAP_PEER,
65 "EAP_SERVER",
66 "EAP_PEER",
67 );
68
69
70
71