|
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_STATE_STORE_H_) |
|
22 #define _EAP_STATE_STORE_H_ |
|
23 |
|
24 #error Do not use. |
|
25 |
|
26 #include "eap_am_memory.h" |
|
27 #include "eap_am_tools.h" |
|
28 #include "eap_tools.h" |
|
29 #include "eap_am_export.h" |
|
30 |
|
31 |
|
32 class EAP_EXPORT eap_base_type_state_c |
|
33 { |
|
34 private: |
|
35 //-------------------------------------------------- |
|
36 //-------------------------------------------------- |
|
37 public: |
|
38 //-------------------------------------------------- |
|
39 |
|
40 // |
|
41 virtual ~eap_base_type_state_c() |
|
42 { |
|
43 } |
|
44 |
|
45 // |
|
46 eap_base_type_state_c() |
|
47 { |
|
48 } |
|
49 |
|
50 //-------------------------------------------------- |
|
51 }; |
|
52 |
|
53 |
|
54 const u32_t EAP_STATE_SIZE = (u32_t)(((~0u) & 0xff)+1u); |
|
55 |
|
56 |
|
57 class EAP_EXPORT eap_state_store_c |
|
58 { |
|
59 private: |
|
60 //-------------------------------------------------- |
|
61 |
|
62 abs_eap_am_tools_c * const m_am_tools; |
|
63 |
|
64 eap_base_type_state_c *m_state[EAP_STATE_SIZE]; // Only 256 different identifier could exist. |
|
65 |
|
66 //-------------------------------------------------- |
|
67 public: |
|
68 //-------------------------------------------------- |
|
69 |
|
70 // |
|
71 virtual ~eap_state_store_c() |
|
72 { |
|
73 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
74 |
|
75 for (u32_t ind = 0; ind < EAP_STATE_SIZE; ind++) |
|
76 { |
|
77 delete m_state[ind]; |
|
78 m_state[ind] = 0; |
|
79 } |
|
80 |
|
81 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
82 } |
|
83 |
|
84 // |
|
85 eap_state_store_c(abs_eap_am_tools_c * const tools) |
|
86 : m_am_tools(tools) |
|
87 { |
|
88 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
89 |
|
90 for (u32_t ind = 0; ind < EAP_STATE_SIZE; ind++) |
|
91 { |
|
92 m_state[ind] = 0; |
|
93 } |
|
94 |
|
95 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
96 } |
|
97 |
|
98 // |
|
99 eap_status_e add(eap_base_type_state_c * const state, const u8_t identifier) |
|
100 { |
|
101 if (m_state[identifier] == 0) |
|
102 { |
|
103 m_state[identifier] = state; |
|
104 return eap_status_ok; |
|
105 } |
|
106 else |
|
107 { |
|
108 EAP_ASSERT_ALWAYS(m_state[identifier] == 0); |
|
109 } |
|
110 return eap_status_handler_does_not_exists_error; |
|
111 } |
|
112 |
|
113 // |
|
114 eap_base_type_state_c * const get(const u8_t identifier) |
|
115 { |
|
116 return m_state[identifier]; |
|
117 } |
|
118 |
|
119 // |
|
120 eap_status_e remove(const u8_t identifier) |
|
121 { |
|
122 if (m_state[identifier] != 0) |
|
123 { |
|
124 delete m_state[identifier]; |
|
125 m_state[identifier] = 0; |
|
126 return eap_status_ok; |
|
127 } |
|
128 else |
|
129 { |
|
130 EAP_ASSERT_ALWAYS(m_state[identifier] != 0); |
|
131 } |
|
132 return eap_status_handler_does_not_exists_error; |
|
133 } |
|
134 |
|
135 //-------------------------------------------------- |
|
136 }; |
|
137 |
|
138 |
|
139 #endif //#if !defined(_EAP_STATE_STORE_H_) |
|
140 |
|
141 //-------------------------------------------------- |
|
142 |
|
143 |
|
144 |
|
145 // End. |