|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Implementation of the UmacDot11DisassociationPending class |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 22 % |
|
20 */ |
|
21 |
|
22 #include "config.h" |
|
23 #include "UmacDot11DisassociationPending.h" |
|
24 #include "UmacContextImpl.h" |
|
25 |
|
26 #ifndef NDEBUG |
|
27 const TInt8 WlanDot11DisassociationPending::iName[] = "dot11-disassociationpending"; |
|
28 |
|
29 const TUint8 WlanDot11DisassociationPending::iStateName |
|
30 [ESTATEMAX][KMaxStateStringLength] = |
|
31 { |
|
32 {"EINIT"}, |
|
33 {"ETXDISASSOCIATIONFRAME"}, |
|
34 {"EWAIT4PUSHPACKET"}, |
|
35 {"ECONTINUEDOT11TRAVERSE"} |
|
36 }; |
|
37 |
|
38 const TUint8 WlanDot11DisassociationPending::iEventName |
|
39 [EEVENTMAX][KMaxEventStringLength] = |
|
40 { |
|
41 {"ESTATEENTRY"}, |
|
42 {"ETXPACKETCOMPLETE"}, |
|
43 {"ETX_SCHEDULER_FULL"}, |
|
44 {"EPUSHPACKET"} |
|
45 }; |
|
46 #endif |
|
47 |
|
48 // ================= MEMBER FUNCTIONS ======================= |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 WlanDot11DisassociationPending::WlanDot11DisassociationPending() |
|
55 : iState( EINIT ) |
|
56 { |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 WlanDot11DisassociationPending::~WlanDot11DisassociationPending() |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void WlanDot11DisassociationPending::Entry( |
|
72 WlanContextImpl& aCtxImpl ) |
|
73 { |
|
74 OsTracePrint( |
|
75 KUmacProtocolState | KUmacAssoc, |
|
76 (TUint8*)("UMAC: WlanDot11DisassociationPending::Entry()")); |
|
77 |
|
78 if ( aCtxImpl.WsaCmdActive() ) |
|
79 { |
|
80 // sanity checking code |
|
81 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
82 } |
|
83 |
|
84 // no need to do event dispatching as this |
|
85 // thing is triggered by the user and |
|
86 // is executed synchronously as we only do OID completion |
|
87 // at the end of reassociation process |
|
88 // Additionally we don't execute any asynchronous WHA commands |
|
89 // from here so disassociation protocol does not include multiple |
|
90 // this object entry method executions |
|
91 |
|
92 if ( iState == EINIT ) |
|
93 { |
|
94 // this is the start of the the FSM actions |
|
95 Fsm( aCtxImpl, ESTATEENTRY ); |
|
96 } |
|
97 else |
|
98 { |
|
99 // implementation error see comment block above why |
|
100 #ifndef NDEBUG |
|
101 OsTracePrint( KErrorLevel, (TUint8*)("UMAC: state:")); |
|
102 OsTracePrint( KErrorLevel, iStateName[iState] ); |
|
103 #endif |
|
104 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
105 } |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // completion method called when packet has been sent from the WLAN device |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void WlanDot11DisassociationPending::OnPacketSendComplete( |
|
113 WlanContextImpl& aCtxImpl, |
|
114 WHA::TStatus aStatus, |
|
115 TUint32 aPacketId, |
|
116 WHA::TRate aRate, |
|
117 TUint32 /*aPacketQueueDelay*/, |
|
118 TUint32 /*aMediaDelay*/, |
|
119 TUint /*aTotalTxDelay*/, |
|
120 TUint8 /*aAckFailures*/, |
|
121 WHA::TQueueId aQueueId, |
|
122 WHA::TRate aRequestedRate, |
|
123 TBool /*aMulticastData*/ ) |
|
124 { |
|
125 OsTracePrint( |
|
126 KUmacAssoc, |
|
127 (TUint8*)("UMAC: WlanDot11DisassociationPending::OnPacketSendComplete")); |
|
128 |
|
129 aCtxImpl.OnTxCompleted( aRate, |
|
130 static_cast<TBool>(aStatus == WHA::KSuccess), |
|
131 aQueueId, |
|
132 aRequestedRate ); |
|
133 |
|
134 if ( aPacketId == E802Dot11FrameTypeDisassociation ) |
|
135 { |
|
136 // disassociation tx message has been sent from the WLAN device |
|
137 // No matter whether the sending was successful or not we will proceed |
|
138 // with our roaming actions |
|
139 |
|
140 Fsm( aCtxImpl, ETXPACKETCOMPLETE ); |
|
141 } |
|
142 } |
|
143 |
|
144 #ifndef NDEBUG |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 const TInt8* WlanDot11DisassociationPending::GetStateName( TUint8& aLength ) const |
|
150 { |
|
151 aLength = sizeof( iName ); |
|
152 return iName; |
|
153 } |
|
154 #endif |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void WlanDot11DisassociationPending::Exit( WlanContextImpl& /*aCtxImpl*/ ) |
|
161 { |
|
162 OsTracePrint( |
|
163 KUmacProtocolState, |
|
164 (TUint8*)("UMAC: WlanDot11DisassociationPending::Exit()")); |
|
165 |
|
166 // we are departing this dot11state to another dot11state (dot11synchronize) |
|
167 // we simple reset our local FSM for the next time... |
|
168 iState = EINIT; |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void WlanDot11DisassociationPending::Fsm( |
|
176 WlanContextImpl& aCtxImpl, |
|
177 TEvent aEvent ) |
|
178 { |
|
179 #ifndef NDEBUG |
|
180 OsTracePrint( |
|
181 KUmacAssoc, |
|
182 (TUint8*)("UMAC: WlanDot11DisassociationPending::Fsm(): event: ")); |
|
183 OsTracePrint( KUmacAssoc, iEventName[aEvent] ); |
|
184 OsTracePrint( |
|
185 KUmacAssoc, |
|
186 (TUint8*)("UMAC: WlanDot11DisassociationPending::Fsm(): state: ")); |
|
187 OsTracePrint( KUmacAssoc, iStateName[iState] ); |
|
188 #endif |
|
189 |
|
190 switch ( aEvent ) |
|
191 { |
|
192 case ESTATEENTRY: |
|
193 OnStateEntryEvent( aCtxImpl ); |
|
194 break; |
|
195 case ETXPACKETCOMPLETE: |
|
196 OnTxCompleteEvent( aCtxImpl ); |
|
197 break; |
|
198 case ETX_SCHEDULER_FULL: |
|
199 OnTxSchedulerFullEvent( aCtxImpl ); |
|
200 break; |
|
201 case EPUSHPACKET: |
|
202 OnPushPacketEvent( aCtxImpl ); |
|
203 break; |
|
204 default: |
|
205 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
206 } |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // Handler for state entry event. |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void WlanDot11DisassociationPending::OnStateEntryEvent( |
|
214 WlanContextImpl& aCtxImpl ) |
|
215 { |
|
216 OsTracePrint( |
|
217 KUmacAssoc, |
|
218 (TUint8*)("UMAC: WlanDot11DisassociationPending::OnStateEntryEvent()")); |
|
219 |
|
220 switch ( iState ) |
|
221 { |
|
222 case EINIT: |
|
223 // continue with the state traversal |
|
224 ChangeInternalState( aCtxImpl, ETXDISASSOCIATIONFRAME ); |
|
225 break; |
|
226 case ETXDISASSOCIATIONFRAME: |
|
227 if ( !TxDisassociate( |
|
228 aCtxImpl, |
|
229 E802Dot11ReasonDisAssocStationLeft, |
|
230 ETrue ) ) |
|
231 { |
|
232 // tx of dot11 disassociate frame failed |
|
233 // because packet scheduler was full |
|
234 // or because we didn't get a Tx buffer |
|
235 // so we enter to a wait state |
|
236 Fsm( aCtxImpl, ETX_SCHEDULER_FULL ); |
|
237 } |
|
238 break; |
|
239 case EWAIT4PUSHPACKET: |
|
240 // nothing to do here than wait |
|
241 break; |
|
242 case ECONTINUEDOT11TRAVERSE: |
|
243 ContinueDot11StateTraversal( aCtxImpl ); |
|
244 break; |
|
245 default: |
|
246 // programming error |
|
247 OsTracePrint( KErrorLevel, |
|
248 (TUint8*)("UMAC: state: %d"), iState); |
|
249 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
250 break; |
|
251 } |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // Handler for tx complete event. |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void WlanDot11DisassociationPending::OnTxCompleteEvent( |
|
259 WlanContextImpl& aCtxImpl ) |
|
260 { |
|
261 OsTracePrint( |
|
262 KUmacAssoc, |
|
263 (TUint8*)("UMAC: WlanDot11DisassociationPending::OnTxCompleteEvent()")); |
|
264 |
|
265 if ( iState == ETXDISASSOCIATIONFRAME ) |
|
266 { |
|
267 |
|
268 // disassociate frame has been sent |
|
269 // continue state traversal |
|
270 ChangeInternalState( aCtxImpl, ECONTINUEDOT11TRAVERSE ); |
|
271 } |
|
272 else |
|
273 { |
|
274 // programming error |
|
275 OsTracePrint( KErrorLevel, (TUint8*)("UMAC: state: %d"), iState); |
|
276 OsAssert( (TUint8*)("UMAC: panic"), (TUint8*)(WLAN_FILE), __LINE__ ); |
|
277 } |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // Handler for scheduler full event upon trying to tx dot11 disassociate frame |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void WlanDot11DisassociationPending::OnTxSchedulerFullEvent( |
|
285 WlanContextImpl& aCtxImpl ) |
|
286 { |
|
287 // change state |
|
288 OsTracePrint( KWarningLevel | KUmacAssoc, (TUint8*) |
|
289 ("UMAC: WlanDot11DisassociationPending::OnTxSchedulerFullEvent:packet scheduler full during disassociation process") ); |
|
290 |
|
291 ChangeInternalState( aCtxImpl, EWAIT4PUSHPACKET ); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // Handler for push packet to packet scheduler possible event |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void WlanDot11DisassociationPending::OnPushPacketEvent( |
|
299 WlanContextImpl& aCtxImpl ) |
|
300 { |
|
301 if ( iState == EWAIT4PUSHPACKET ) |
|
302 { |
|
303 ChangeInternalState( aCtxImpl, ETXDISASSOCIATIONFRAME ); |
|
304 } |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 void WlanDot11DisassociationPending::ContinueDot11StateTraversal( |
|
312 WlanContextImpl& aCtxImpl ) |
|
313 { |
|
314 OsTracePrint( |
|
315 KUmacAssoc, |
|
316 (TUint8*) |
|
317 ("UMAC: WlanDot11DisassociationPending::ContinueDot11StateTraversal()")); |
|
318 |
|
319 // proceed to synchronize state... |
|
320 ChangeState( aCtxImpl, |
|
321 *this, // prev state |
|
322 aCtxImpl.iStates.iSynchronizeState // next state |
|
323 ); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void WlanDot11DisassociationPending::ChangeInternalState( |
|
331 WlanContextImpl& aCtxImpl, |
|
332 TState aNewState ) |
|
333 { |
|
334 #ifndef NDEBUG |
|
335 OsTracePrint( |
|
336 KUmacDetails, |
|
337 (TUint8*) |
|
338 ("UMAC: WlanDot11DisassociationPending::ChangeInternalState(): old state:")); |
|
339 OsTracePrint( KUmacAssoc, iStateName[iState] ); |
|
340 OsTracePrint( |
|
341 KUmacDetails, |
|
342 (TUint8*) |
|
343 ("UMAC: WlanDot11DisassociationPending::ChangeInternalState(): new state:")); |
|
344 OsTracePrint( KUmacAssoc, iStateName[aNewState] ); |
|
345 #endif |
|
346 |
|
347 iState = aNewState; |
|
348 Fsm( aCtxImpl, ESTATEENTRY ); |
|
349 } |
|
350 |
|
351 // ----------------------------------------------------------------------------- |
|
352 // packet sceduler notification that a packet push is guaranteed to succeed |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 void WlanDot11DisassociationPending::OnPacketPushPossible( |
|
356 WlanContextImpl& aCtxImpl ) |
|
357 { |
|
358 // feed a critter to the fsm |
|
359 Fsm( aCtxImpl, EPUSHPACKET ); |
|
360 } |