|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #if !defined(_EAP_SIMPLE_CONFIG_HEADER_H_) |
|
22 #define _EAP_SIMPLE_CONFIG_HEADER_H_ |
|
23 |
|
24 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
25 |
|
26 #include "eap_tools.h" |
|
27 #include "eap_header.h" |
|
28 #include "simple_config_types.h" |
|
29 |
|
30 /** @file */ |
|
31 |
|
32 const u8_t SIMPLE_CONFIG_NAI_AT_BYTE = '@'; |
|
33 |
|
34 #if !defined(USE_EAP_EXPANDED_TYPES) |
|
35 #error You MUST define USE_EAP_EXPANDED_TYPES compiler flag. WFA Simple Config uses that. |
|
36 #endif //#if !defined(USE_EAP_EXPANDED_TYPES) |
|
37 |
|
38 //---------------------------------------------------------------------------- |
|
39 |
|
40 |
|
41 /// This class defines header of SIMPLE_CONFIG EAP-type. |
|
42 /** |
|
43 * Here is a figure of header of SIMPLE_CONFIG EAP-type. |
|
44 * Subtype-Data is m_length-sizeof(eap_simple_config_header_c) data octets that follows eap_simple_config_header_c. |
|
45 * @code |
|
46 * EAP/SIMPLE_CONFIG-header: |
|
47 * 0 1 2 3 |
|
48 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
|
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
50 * | Code | Identifier | Length | |
|
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
52 * | Type | Vendor-Id | |
|
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
54 * | Vendor-Type | |
|
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
56 * | Op-Code | Flags | Message Length | |
|
57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
58 * | Message Data... |
|
59 * +-+-+-+-+-+-+-+-+-+ |
|
60 * @endcode |
|
61 * |
|
62 */ |
|
63 class EAP_EXPORT eap_simple_config_header_c |
|
64 : public eap_header_base_c |
|
65 { |
|
66 private: |
|
67 //-------------------------------------------------- |
|
68 |
|
69 /// This is pointer to the tools class. |
|
70 abs_eap_am_tools_c * const m_am_tools; |
|
71 |
|
72 enum message_fields |
|
73 { |
|
74 SIMPLE_CONFIG_MESSAGE_LENGTH_FIELD_SIZE = 2u, |
|
75 }; |
|
76 |
|
77 enum bit_shifts |
|
78 { |
|
79 m_flag_shift_reserved = 0x02, |
|
80 }; |
|
81 |
|
82 //-------------------------------------------------- |
|
83 protected: |
|
84 //-------------------------------------------------- |
|
85 |
|
86 enum delta_offsets |
|
87 { |
|
88 m_op_code_delta_offset = 0, |
|
89 m_flag_delta_offset = m_op_code_delta_offset+sizeof(u8_t), |
|
90 m_data_or_message_length_delta_offset = m_flag_delta_offset+sizeof(u8_t), |
|
91 }; |
|
92 |
|
93 //-------------------------------------------------- |
|
94 public: |
|
95 //-------------------------------------------------- |
|
96 |
|
97 enum bit_masks |
|
98 { |
|
99 m_flag_mask_more_fragments = 0x01, |
|
100 m_flag_mask_simple_config_length_included = 0x02, |
|
101 m_flag_mask_reserved = 0xfc, |
|
102 }; |
|
103 |
|
104 enum op_code_e |
|
105 { |
|
106 op_code_none = 0x00, |
|
107 op_code_WSC_Start = 0x01, |
|
108 op_code_WSC_ACK = 0x02, |
|
109 op_code_WSC_NACK = 0x03, |
|
110 op_code_WSC_MSG = 0x04, |
|
111 op_code_WSC_Done = 0x05, |
|
112 op_code_FRAG_ACK = 0x06, |
|
113 }; |
|
114 |
|
115 |
|
116 EAP_FUNC_IMPORT virtual ~eap_simple_config_header_c(); |
|
117 |
|
118 // |
|
119 EAP_FUNC_IMPORT eap_simple_config_header_c( |
|
120 abs_eap_am_tools_c * const tools, |
|
121 u8_t * const header_begin, |
|
122 const u32_t header_buffer_length); |
|
123 |
|
124 EAP_FUNC_IMPORT eap_code_value_e get_eap_code() const; |
|
125 |
|
126 EAP_FUNC_IMPORT u8_t get_eap_identifier() const; |
|
127 |
|
128 EAP_FUNC_IMPORT u16_t get_eap_length() const; |
|
129 |
|
130 EAP_FUNC_IMPORT eap_type_value_e get_eap_type() const; |
|
131 |
|
132 EAP_FUNC_IMPORT u16_t get_data_length() const; |
|
133 |
|
134 EAP_FUNC_IMPORT u32_t get_simple_config_min_header_length() const; |
|
135 |
|
136 EAP_FUNC_IMPORT static u32_t get_simple_config_max_header_length(); |
|
137 |
|
138 EAP_FUNC_IMPORT u32_t get_header_length() const; |
|
139 |
|
140 EAP_FUNC_IMPORT u32_t get_start_offset_of_data() const; |
|
141 |
|
142 EAP_FUNC_IMPORT u8_t * get_data_offset( |
|
143 abs_eap_am_tools_c * const m_am_tools, |
|
144 const u32_t offset, |
|
145 const u32_t contignuous_bytes) const; |
|
146 |
|
147 |
|
148 EAP_FUNC_IMPORT u8_t * get_data( |
|
149 abs_eap_am_tools_c * const m_am_tools, |
|
150 const u32_t contignuous_bytes) const; |
|
151 |
|
152 |
|
153 EAP_FUNC_IMPORT u32_t get_sc_op_code_offset() const; |
|
154 |
|
155 EAP_FUNC_IMPORT u32_t get_sc_flags_offset() const; |
|
156 |
|
157 EAP_FUNC_IMPORT u32_t get_sc_length_offset() const; |
|
158 |
|
159 |
|
160 EAP_FUNC_IMPORT op_code_e get_sc_op_code() const; |
|
161 |
|
162 |
|
163 EAP_FUNC_IMPORT u8_t * get_simple_config_flags() const; |
|
164 |
|
165 EAP_FUNC_IMPORT bool get_simple_config_flag_bit( |
|
166 const u32_t mask) const; |
|
167 |
|
168 EAP_FUNC_IMPORT u8_t get_simple_config_flag_value( |
|
169 const u32_t mask, |
|
170 const u32_t shift) const; |
|
171 |
|
172 EAP_FUNC_IMPORT bool get_flag_simple_config_length_included() const; |
|
173 |
|
174 EAP_FUNC_IMPORT bool get_flag_more_fragments() const; |
|
175 |
|
176 EAP_FUNC_IMPORT u8_t get_flag_reserved() const; |
|
177 |
|
178 EAP_FUNC_IMPORT eap_status_e get_simple_config_message_length( |
|
179 u32_t * const simple_config_length) const; |
|
180 |
|
181 |
|
182 EAP_FUNC_IMPORT eap_status_e check_header( |
|
183 abs_eap_am_tools_c * const tools, |
|
184 const bool is_client_when_true) const; |
|
185 |
|
186 EAP_FUNC_IMPORT eap_const_string get_code_string() const; |
|
187 |
|
188 EAP_FUNC_IMPORT eap_const_string get_eap_type_string() const; |
|
189 |
|
190 EAP_FUNC_IMPORT eap_const_string get_sc_op_code_string() const; |
|
191 |
|
192 |
|
193 EAP_FUNC_IMPORT void set_eap_code(const eap_code_value_e p_code); |
|
194 |
|
195 EAP_FUNC_IMPORT void set_eap_identifier(const u8_t p_identifier); |
|
196 |
|
197 EAP_FUNC_IMPORT void set_eap_length( |
|
198 const u16_t p_length, |
|
199 const bool expanded_type_when_true); |
|
200 |
|
201 EAP_FUNC_IMPORT void set_eap_type( |
|
202 const eap_type_value_e p_type, |
|
203 const bool expanded_type_when_true); |
|
204 |
|
205 |
|
206 EAP_FUNC_IMPORT void set_sc_op_code(const op_code_e op_code); |
|
207 |
|
208 |
|
209 EAP_FUNC_IMPORT void set_simple_config_flag_value( |
|
210 const u8_t value, |
|
211 const u32_t mask, |
|
212 const u32_t shift) const; |
|
213 |
|
214 EAP_FUNC_IMPORT void set_simple_config_flag_bit(const bool flag, u32_t mask) const; |
|
215 |
|
216 EAP_FUNC_IMPORT void set_flag_reserved(const u8_t reserved); |
|
217 |
|
218 EAP_FUNC_IMPORT void set_flag_simple_config_length_included(const bool simple_config_length_included); |
|
219 |
|
220 EAP_FUNC_IMPORT void set_flag_more_fragments(const bool more_fragments); |
|
221 |
|
222 |
|
223 EAP_FUNC_IMPORT void set_data_length( |
|
224 const u32_t p_data_length, |
|
225 const bool expanded_type_when_true); |
|
226 |
|
227 EAP_FUNC_IMPORT void set_simple_config_message_length(const u32_t simple_config_length); |
|
228 |
|
229 |
|
230 EAP_FUNC_IMPORT void reset_header( |
|
231 abs_eap_am_tools_c * const m_am_tools, |
|
232 const u32_t buffer_length, |
|
233 const bool expanded_type_when_true); |
|
234 |
|
235 // |
|
236 //-------------------------------------------------- |
|
237 }; // class eap_simple_config_header_c |
|
238 |
|
239 |
|
240 //-------------------------------------------------- |
|
241 |
|
242 #endif //#if defined(USE_EAP_SIMPLE_CONFIG) |
|
243 |
|
244 #endif //#if !defined(_EAP_SIMPLE_CONFIG_HEADER_H_) |
|
245 |
|
246 |
|
247 |
|
248 // End. |