|
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 // INCLUDES |
|
20 #include <e32std.h> |
|
21 #include <implementationproxy.h> |
|
22 |
|
23 #include "abs_eap_am_tools.h" |
|
24 |
|
25 #include "eapol_message_wlan_authentication.h" |
|
26 #include "wlan_eapol_if_implementation.h" |
|
27 #include "wlan_eap_if_send_status.h" |
|
28 |
|
29 //----------------------------------------------------------------------------------------- |
|
30 |
|
31 /** |
|
32 * Pairs ECom implementation UIDs with a pointer to the instantiation |
|
33 * method for that implementation. Required for all ECom implementation |
|
34 * collections. |
|
35 */ |
|
36 const TImplementationProxy ImplementationTable[] = |
|
37 { |
|
38 {{ KCWlanEapolClientUid }, reinterpret_cast<TProxyNewLPtr>(CWlanEapolInterfaceImplementation::NewL)} |
|
39 }; |
|
40 |
|
41 //----------------------------------------------------------------------------------------- |
|
42 |
|
43 /** |
|
44 * Static constructor. |
|
45 * @param aPartner Pointer to callback instance. |
|
46 * @return Pointer to the constructed instance. |
|
47 */ |
|
48 CWlanEapolInterfaceImplementation* CWlanEapolInterfaceImplementation::NewL(MWlanEapolCallbackInterface * aPartner) |
|
49 { |
|
50 CWlanEapolInterfaceImplementation* self = new (ELeave) CWlanEapolInterfaceImplementation; |
|
51 |
|
52 CleanupStack::PushL(self); |
|
53 |
|
54 self->ConstructL(aPartner); |
|
55 |
|
56 if (self->get_is_valid() != true) |
|
57 { |
|
58 User::Leave(KErrGeneral); |
|
59 } |
|
60 |
|
61 CleanupStack::Pop(self); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 //----------------------------------------------------------------------------------------- |
|
67 |
|
68 /** |
|
69 * C++ default constructor. |
|
70 */ |
|
71 CWlanEapolInterfaceImplementation::CWlanEapolInterfaceImplementation() |
|
72 : m_am_tools(0) |
|
73 , m_partner(0) |
|
74 , m_wauth(0) |
|
75 , m_is_valid(true) |
|
76 { |
|
77 } |
|
78 |
|
79 //----------------------------------------------------------------------------------------- |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 CWlanEapolInterfaceImplementation::~CWlanEapolInterfaceImplementation() |
|
85 { |
|
86 m_partner = 0; |
|
87 |
|
88 delete m_wauth; |
|
89 m_wauth = 0; |
|
90 m_am_tools->am_cancel_all_timers(); |
|
91 abs_eap_am_tools_c::delete_abs_eap_am_tools_c(m_am_tools); |
|
92 m_am_tools = 0; |
|
93 |
|
94 } |
|
95 |
|
96 //----------------------------------------------------------------------------------------- |
|
97 |
|
98 /** |
|
99 * Configure plugin implementation. |
|
100 * |
|
101 * @since S60 v3.2 |
|
102 * @param aHeaderOffset Offset of EAP-header in packet_send. |
|
103 * @param aMTU Maximum transfer unit (MTU). |
|
104 * @param aTrailerLength Length of trailer needed by lower levels.. |
|
105 * @return Return value is specified in interface specification. |
|
106 */ |
|
107 TInt CWlanEapolInterfaceImplementation::Configure( |
|
108 const TInt aHeaderOffset, |
|
109 const TInt aMTU, |
|
110 const TInt aTrailerLength) |
|
111 { |
|
112 m_am_tools = abs_eap_am_tools_c::new_abs_eap_am_tools_c(); |
|
113 |
|
114 if (m_am_tools == 0) |
|
115 { |
|
116 return wlan_eap_if_send_status_conversion_c::convert(eap_status_allocation_error); |
|
117 } |
|
118 |
|
119 // eapol_message_wlan_authentication_c object uses the tools object. |
|
120 m_wauth = new eapol_message_wlan_authentication_c( |
|
121 m_am_tools, |
|
122 this); |
|
123 |
|
124 if (m_wauth != 0 |
|
125 && m_wauth->get_is_valid() == true) |
|
126 { |
|
127 eap_status_e status = m_wauth->configure( |
|
128 aHeaderOffset, |
|
129 aMTU, |
|
130 aTrailerLength); |
|
131 if (status != eap_status_ok) |
|
132 { |
|
133 return wlan_eap_if_send_status_conversion_c::convert( |
|
134 EAP_STATUS_RETURN(m_am_tools, status)); |
|
135 } |
|
136 } |
|
137 else |
|
138 { |
|
139 return wlan_eap_if_send_status_conversion_c::convert( |
|
140 EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); |
|
141 } |
|
142 |
|
143 return wlan_eap_if_send_status_ok; |
|
144 } |
|
145 |
|
146 //----------------------------------------------------------------------------------------- |
|
147 |
|
148 /** |
|
149 * Shutdown plugin implementation. |
|
150 * |
|
151 * @since S60 v3.2 |
|
152 * @return Return value is specified in interface specification. |
|
153 */ |
|
154 TInt CWlanEapolInterfaceImplementation::Shutdown() |
|
155 { |
|
156 eap_status_e status = m_wauth->shutdown(); |
|
157 |
|
158 return wlan_eap_if_send_status_conversion_c::convert( |
|
159 EAP_STATUS_RETURN(m_am_tools, status)); |
|
160 } |
|
161 |
|
162 //----------------------------------------------------------------------------------------- |
|
163 |
|
164 /** |
|
165 * Send data to EAPOL. |
|
166 * |
|
167 * @since S60 v3.2 |
|
168 * @param aData Pointer to the data to be sent. |
|
169 * @param aLength Length of the data to be sent. |
|
170 * @return Return value is specified in interface specification. |
|
171 */ |
|
172 TInt CWlanEapolInterfaceImplementation::ProcessData( |
|
173 const void * const aData, |
|
174 const TInt aLength ) |
|
175 { |
|
176 return m_wauth->process_data(aData, aLength); |
|
177 } |
|
178 |
|
179 //----------------------------------------------------------------------------------------- |
|
180 |
|
181 /** |
|
182 * Symbian 2nd phase constructor. |
|
183 */ |
|
184 void CWlanEapolInterfaceImplementation::ConstructL(MWlanEapolCallbackInterface * aPartner) |
|
185 { |
|
186 m_partner = aPartner; |
|
187 } |
|
188 |
|
189 //----------------------------------------------------------------------------------------- |
|
190 |
|
191 bool CWlanEapolInterfaceImplementation::get_is_valid() |
|
192 { |
|
193 return m_is_valid; |
|
194 } |
|
195 |
|
196 //----------------------------------------------------------------------------------------- |
|
197 |
|
198 /// Function sends the data message to lower layer. |
|
199 /// Data is formatted to Attribute-Value Pairs. |
|
200 /// Look at eap_tlv_header_c and eap_tlv_message_data_c. |
|
201 wlan_eap_if_send_status_e CWlanEapolInterfaceImplementation::send_data(const void * const data, const u32_t length) |
|
202 { |
|
203 return static_cast<wlan_eap_if_send_status_e>(m_partner->SendData( |
|
204 data, |
|
205 length)); |
|
206 } |
|
207 |
|
208 //----------------------------------------------------------------------------------------- |
|
209 |
|
210 // ======== GLOBAL FUNCTIONS ======== |
|
211 |
|
212 // --------------------------------------------------------- |
|
213 // Returns an instance of the proxy table. |
|
214 // Returns: KErrNone |
|
215 // --------------------------------------------------------- |
|
216 // |
|
217 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
218 { |
|
219 aTableCount = sizeof( ImplementationTable) / sizeof( TImplementationProxy ); |
|
220 return ImplementationTable; |
|
221 } |
|
222 |
|
223 //----------------------------------------------------------------------------------------- |
|
224 |
|
225 // End of file. |
|
226 |