|
1 /* |
|
2 * Copyright (c) 2005-2009 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 WlanDot11IbssNormalMode class. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 14 % |
|
20 */ |
|
21 |
|
22 #include "config.h" |
|
23 #include "umacdot11ibssnormalmode.h" |
|
24 #include "UmacContextImpl.h" |
|
25 |
|
26 #ifndef NDEBUG |
|
27 const TInt8 WlanDot11IbssNormalMode::iName[] = "dot11ibss::dot11-normalmode"; |
|
28 #endif |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 void WlanDot11IbssNormalMode::Entry( |
|
37 WlanContextImpl& /*aCtxImpl*/ ) |
|
38 { |
|
39 // nothing here |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 void WlanDot11IbssNormalMode::Exit( |
|
47 WlanContextImpl& /*aCtxImpl*/ ) |
|
48 { |
|
49 // nothing here |
|
50 } |
|
51 |
|
52 #ifndef NDEBUG |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 const TInt8* WlanDot11IbssNormalMode::GetStateName( |
|
58 TUint8& aLength ) const |
|
59 { |
|
60 aLength = sizeof( iName ); |
|
61 return iName; |
|
62 } |
|
63 #endif |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 TBool WlanDot11IbssNormalMode::Disconnect( |
|
70 WlanContextImpl& aCtxImpl ) |
|
71 { |
|
72 // set completion code to idle state |
|
73 // as it does the request completion |
|
74 aCtxImpl.iStates.iIdleState.Set( KErrNone ); |
|
75 ChangeState( aCtxImpl, |
|
76 *this, // prev state |
|
77 aCtxImpl.iStates.iSoftResetState // next state |
|
78 ); |
|
79 |
|
80 // notify of state transition |
|
81 return ETrue; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 TBool WlanDot11IbssNormalMode::Connect( |
|
89 WlanContextImpl& aCtxImpl, |
|
90 const TSSID& aSSID, |
|
91 const TMacAddress& aBSSID, |
|
92 TUint16 /*aAuthAlgorithmNbr*/, |
|
93 TEncryptionStatus aEncryptionStatus, |
|
94 TBool /*aIsInfra*/, |
|
95 TUint16 aScanResponseFrameBodyLength, |
|
96 const TUint8* aScanResponseFrameBody, |
|
97 const TUint8* aIeData, |
|
98 TUint16 aIeDataLength ) |
|
99 { |
|
100 TBool ret( ETrue ); |
|
101 |
|
102 (aCtxImpl.GetBssId())= aBSSID; |
|
103 (aCtxImpl.GetSsId()) = aSSID; |
|
104 (aCtxImpl.EncryptionStatus()) = aEncryptionStatus; |
|
105 aCtxImpl.NetworkOperationMode( WHA::EIBSS ); |
|
106 |
|
107 // store Tx IE data for later access |
|
108 // pointers supplied are valid to the point the |
|
109 // corresponding completion method is called |
|
110 aCtxImpl.IeData( aIeData ); |
|
111 aCtxImpl.IeDataLength( aIeDataLength ); |
|
112 |
|
113 |
|
114 // check do we meet the requirements for the network |
|
115 // and construct necessary objects for establishing the connection |
|
116 if ( InitNetworkConnect( |
|
117 aCtxImpl, |
|
118 aScanResponseFrameBodyLength, |
|
119 aScanResponseFrameBody ) ) |
|
120 { |
|
121 // continue |
|
122 |
|
123 // make WHA types |
|
124 WHA::SSSID ssid; |
|
125 ssid.iSSIDLength = aSSID.ssidLength; |
|
126 os_memcpy( ssid.iSSID, aSSID.ssid, ssid.iSSIDLength ); |
|
127 |
|
128 ChangeState( aCtxImpl, |
|
129 *this, // prev state |
|
130 aCtxImpl.iStates.iPrepareForIbssMode // next state |
|
131 ); |
|
132 } |
|
133 else // --- InitNetworkConnect failure --- |
|
134 { |
|
135 // abort |
|
136 ret = EFalse; |
|
137 OnOidComplete( aCtxImpl, KErrGeneral ); |
|
138 } |
|
139 |
|
140 return ret; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 TBool WlanDot11IbssNormalMode::RealScan( |
|
148 WlanContextImpl& aCtxImpl, |
|
149 TScanMode aMode, |
|
150 const TSSID& aSSID, |
|
151 TUint32 aScanRate, |
|
152 SChannels& aChannels, |
|
153 TUint32 aMinChannelTime, |
|
154 TUint32 aMaxChannelTime, |
|
155 TBool aSplitScan ) |
|
156 { |
|
157 // scanning mode requested |
|
158 // set parameters |
|
159 // NOTE: OID command parameters are guaranteed to be valid |
|
160 // to the point a correcponding completion method is called |
|
161 |
|
162 aCtxImpl.iStates.iIbssScanningMode.Set( |
|
163 aCtxImpl, aMode, aSSID, aScanRate, aChannels, |
|
164 aMinChannelTime, aMaxChannelTime, aSplitScan ); |
|
165 |
|
166 ChangeState( aCtxImpl, |
|
167 *this, // prev state |
|
168 aCtxImpl.iStates.iIbssScanningMode // next state |
|
169 ); |
|
170 return ETrue; // global statemachine transition will occur |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void WlanDot11IbssNormalMode::OnBeaconFrameRx( |
|
178 WlanContextImpl& aCtxImpl, |
|
179 const TAny* aFrame, |
|
180 const TUint32 aLength, |
|
181 WHA::TRcpi aRcpi, |
|
182 TUint8* aBuffer ) |
|
183 { |
|
184 OsTracePrint( KWlmIndication | KRxFrame, (TUint8*) |
|
185 ("UMAC: WlanDot11IbssNormalMode::OnBeaconFrameRx")); |
|
186 |
|
187 // pass the frame to the mgmt client |
|
188 XferDot11FrameToMgmtClient( aCtxImpl, aFrame, aLength, aRcpi, aBuffer ); |
|
189 } |