0e144b1236f54e5157f3b2c51181a4e53d9811a0
[strongswan.git] / src / libstrongswan / eap / eap.h
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Copyright (C) 2010 Martin Willi
4 * Copyright (C) 2010 revosec AG
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 /**
19 * @defgroup leap eap
20 * @{ @ingroup libstrongswan
21 */
22
23 #ifndef EAP_H_
24 #define EAP_H_
25
26 typedef enum eap_code_t eap_code_t;
27 typedef enum eap_type_t eap_type_t;
28 typedef struct eap_vendor_type_t eap_vendor_type_t;
29
30 #include <library.h>
31
32 /**
33 * EAP code, type of an EAP message
34 */
35 enum eap_code_t {
36 EAP_REQUEST = 1,
37 EAP_RESPONSE = 2,
38 EAP_SUCCESS = 3,
39 EAP_FAILURE = 4,
40 };
41
42 /**
43 * enum names for eap_code_t.
44 */
45 extern enum_name_t *eap_code_names;
46
47 /**
48 * short string enum names for eap_code_t.
49 */
50 extern enum_name_t *eap_code_short_names;
51
52 /**
53 * EAP types, defines the EAP method implementation
54 */
55 enum eap_type_t {
56 EAP_IDENTITY = 1,
57 EAP_NOTIFICATION = 2,
58 EAP_NAK = 3,
59 EAP_MD5 = 4,
60 EAP_OTP = 5,
61 EAP_GTC = 6,
62 EAP_TLS = 13,
63 EAP_SIM = 18,
64 EAP_TTLS = 21,
65 EAP_AKA = 23,
66 EAP_PEAP = 25,
67 EAP_MSCHAPV2 = 26,
68 EAP_MSTLV = 33,
69 EAP_TNC = 38,
70 EAP_EXPANDED = 254,
71 EAP_EXPERIMENTAL = 255,
72 /** not a method, but an implementation providing different methods */
73 EAP_RADIUS = 256,
74 /** not a method, select method dynamically based on client selection */
75 EAP_DYNAMIC = 257,
76 };
77
78 /**
79 * enum names for eap_type_t.
80 */
81 extern enum_name_t *eap_type_names;
82
83 /**
84 * short string enum names for eap_type_t.
85 */
86 extern enum_name_t *eap_type_short_names;
87
88 /**
89 * Struct that stores EAP type and vendor ID
90 */
91 struct eap_vendor_type_t {
92
93 /**
94 * EAP type
95 */
96 eap_type_t type;
97
98 /**
99 * Vendor Id
100 */
101 u_int32_t vendor;
102 };
103
104 /**
105 * EAP packet format
106 */
107 typedef struct __attribute__((packed)) {
108 u_int8_t code;
109 u_int8_t identifier;
110 u_int16_t length;
111 u_int8_t type;
112 u_int8_t data;
113 } eap_packet_t;
114
115 /**
116 * Lookup the EAP method type from a string.
117 *
118 * @param name EAP method name (such as "md5", "aka")
119 * @return method type, 0 if unknown
120 */
121 eap_type_t eap_type_from_string(char *name);
122
123 /**
124 * Parse a string of the form [eap-]type[-vendor].
125 *
126 * @param str EAP method string
127 * @return parsed type (gets allocated), NULL if unknown or failed
128 */
129 eap_vendor_type_t *eap_vendor_type_from_string(char *str);
130
131 #endif /** EAP_H_ @}*/