Implemented PT-EAP protocol (RFC 7171)
[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_PT_EAP = 54,
71 EAP_EXPANDED = 254,
72 EAP_EXPERIMENTAL = 255,
73 /** not a method, but an implementation providing different methods */
74 EAP_RADIUS = 256,
75 /** not a method, select method dynamically based on client selection */
76 EAP_DYNAMIC = 257,
77 };
78
79 /**
80 * enum names for eap_type_t.
81 */
82 extern enum_name_t *eap_type_names;
83
84 /**
85 * short string enum names for eap_type_t.
86 */
87 extern enum_name_t *eap_type_short_names;
88
89 /**
90 * Struct that stores EAP type and vendor ID
91 */
92 struct eap_vendor_type_t {
93
94 /**
95 * EAP type
96 */
97 eap_type_t type;
98
99 /**
100 * Vendor Id
101 */
102 u_int32_t vendor;
103 };
104
105 /**
106 * EAP packet format
107 */
108 typedef struct __attribute__((packed)) {
109 u_int8_t code;
110 u_int8_t identifier;
111 u_int16_t length;
112 u_int8_t type;
113 u_int8_t data;
114 } eap_packet_t;
115
116 /**
117 * Lookup the EAP method type from a string.
118 *
119 * @param name EAP method name (such as "md5", "aka")
120 * @return method type, 0 if unknown
121 */
122 eap_type_t eap_type_from_string(char *name);
123
124 /**
125 * Parse a string of the form [eap-]type[-vendor].
126 *
127 * @param str EAP method string
128 * @return parsed type (gets allocated), NULL if unknown or failed
129 */
130 eap_vendor_type_t *eap_vendor_type_from_string(char *str);
131
132 #endif /** EAP_H_ @}*/