|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include <bluetooth/logger.h> |
|
22 #include "CBnepBridge.h" |
|
23 #include "CBnepLocalDevice.h" |
|
24 #include "CBTAddrSubscriber.h" |
|
25 #include <networking/ethinter.h> |
|
26 |
|
27 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
28 #include "panprovisioninfo.h" |
|
29 #endif |
|
30 |
|
31 #ifdef __FLOG_ACTIVE |
|
32 _LIT8(KLogComponent, LOG_COMPONENT_PAN_BNEP); |
|
33 #endif |
|
34 |
|
35 /** |
|
36 Constructor for the local device. |
|
37 @param aFactory CPktDrvFactory that created it. |
|
38 @param aParent pointer to the bottom of Ethint.Nif, |
|
39 @internalComponent |
|
40 */ |
|
41 CBnepLocalDevice::CBnepLocalDevice (CPktDrvFactory& aFactory, CLANLinkCommon* aParent) |
|
42 : CPktDrvBase(aFactory), iLinkLayerUp(EFalse) |
|
43 { |
|
44 LOG_FUNC |
|
45 iParent = aParent; |
|
46 } |
|
47 |
|
48 /** |
|
49 Destroy the local device node and core controller. |
|
50 @internalComponent |
|
51 */ |
|
52 CBnepLocalDevice::~CBnepLocalDevice() |
|
53 { |
|
54 LOG_FUNC |
|
55 |
|
56 delete (CBnepBridge *)iOwner; |
|
57 |
|
58 delete iSubscriber; |
|
59 } |
|
60 |
|
61 /** |
|
62 Upward notification of a change in the local bluetooth device address. |
|
63 @internalComponent |
|
64 */ |
|
65 void CBnepLocalDevice::BDADDRChanged () |
|
66 { |
|
67 LOG_FUNC |
|
68 |
|
69 iBDAddressAvailable = ETrue; |
|
70 if(iInterfaceStarted) |
|
71 { |
|
72 TRAP_IGNORE(iParent->FoundMACAddrL()); |
|
73 } |
|
74 } |
|
75 |
|
76 void CBnepLocalDevice::ConstructL (CLANLinkCommon* UNUSEDPARAMETER1) |
|
77 { |
|
78 LOG_FUNC |
|
79 iOwner = CBnepBridge::NewL(*this); |
|
80 iSubscriber = CBTAddrSubscriber::NewL(iAddr, *this); |
|
81 } |
|
82 |
|
83 void CBnepLocalDevice::RemoteDeviceReady () |
|
84 { |
|
85 LOG_FUNC |
|
86 if (!iLinkLayerUp) |
|
87 { |
|
88 iParent->LinkLayerUp(); |
|
89 iLinkLayerUp = ETrue; |
|
90 } |
|
91 } |
|
92 |
|
93 void CBnepLocalDevice::AllRemoteDevicesDisconnected () |
|
94 { |
|
95 LOG_FUNC |
|
96 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
97 iParent->LinkLayerDown(KErrNone, CLANLinkCommon::EReconnect); |
|
98 #endif |
|
99 iLinkLayerUp = EFalse; |
|
100 } |
|
101 |
|
102 /** |
|
103 Not currently supported |
|
104 @internalComponent |
|
105 */ |
|
106 TInt CBnepLocalDevice::Control (TUint UNUSEDPARAMETER1, TUint UNUSEDPARAMETER2, TDes8& UNUSEDPARAMETER3, TAny* UNUSEDPARAMETER4) |
|
107 { |
|
108 LOG_FUNC |
|
109 return(KErrNotSupported); |
|
110 } |
|
111 |
|
112 /** |
|
113 Not currently supported |
|
114 @internalComponent |
|
115 */ |
|
116 TUint8* CBnepLocalDevice::GetInterfaceAddress () const |
|
117 { |
|
118 LOG_FUNC |
|
119 return const_cast<TUint8*>(iAddr.Des().Ptr()); |
|
120 } |
|
121 |
|
122 /** |
|
123 Not currently supported |
|
124 @internalComponent |
|
125 */ |
|
126 TInt CBnepLocalDevice::GetMulticastList (const THWAddr* UNUSEDPARAMETER1, TInt& UNUSEDPARAMETER2) const |
|
127 { |
|
128 LOG_FUNC |
|
129 return KErrNotSupported; |
|
130 } |
|
131 |
|
132 /** |
|
133 Not currently supported |
|
134 @internalComponent |
|
135 */ |
|
136 TInt CBnepLocalDevice::GetRxMode () const |
|
137 { |
|
138 LOG_FUNC |
|
139 return KErrNotSupported; |
|
140 } |
|
141 |
|
142 /** |
|
143 Not currently supported |
|
144 @internalComponent |
|
145 */ |
|
146 TInt CBnepLocalDevice::InterfacePowerDown () |
|
147 { |
|
148 LOG_FUNC |
|
149 return KErrNotSupported; |
|
150 } |
|
151 |
|
152 /** |
|
153 Not currently supported |
|
154 @internalComponent |
|
155 */ |
|
156 TInt CBnepLocalDevice::InterfacePowerUp () |
|
157 { |
|
158 LOG_FUNC |
|
159 return KErrNotSupported; |
|
160 } |
|
161 |
|
162 /** |
|
163 Not currently supported |
|
164 @internalComponent |
|
165 */ |
|
166 TInt CBnepLocalDevice::InterfaceResume () |
|
167 { |
|
168 LOG_FUNC |
|
169 return KErrNotSupported; |
|
170 } |
|
171 |
|
172 /** |
|
173 Not currently supported |
|
174 @internalComponent |
|
175 */ |
|
176 TInt CBnepLocalDevice::InterfaceSleep () |
|
177 { |
|
178 LOG_FUNC |
|
179 return KErrNotSupported; |
|
180 } |
|
181 |
|
182 /** |
|
183 Create the local device node on the PAN bridge. |
|
184 This is also the top interface of the packet driver. |
|
185 @internalComponent |
|
186 */ |
|
187 CBnepLocalDevice* CBnepLocalDevice::NewL (CPktDrvFactory& aFactory, CLANLinkCommon* aParent) |
|
188 { |
|
189 LOG_STATIC_FUNC |
|
190 CBnepLocalDevice* self = new(ELeave) CBnepLocalDevice(aFactory, aParent); |
|
191 CleanupStack::PushL(self); |
|
192 self->ConstructL(aParent); |
|
193 CleanupStack::Pop(self); |
|
194 return(self); |
|
195 } |
|
196 |
|
197 /** |
|
198 General purpose notification API. |
|
199 @see TBnepAgentToNifNotification |
|
200 @param aEvent A message type interpreted as a TBnepAgentToNifNotification. |
|
201 @param aInfo An arbitrary pointer, meaning determined by aEvent. |
|
202 @internalComponent |
|
203 */ |
|
204 TInt CBnepLocalDevice::Notification (TAgentToNifEventType aEvent, TAny* aInfo) |
|
205 { |
|
206 LOG_FUNC |
|
207 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
208 TInt retval = KErrNotSupported; |
|
209 switch (aEvent) |
|
210 { |
|
211 case EPanAgentToNifGetPanProvisionInfo: |
|
212 { |
|
213 LOG(_L8("aEvent=EPanAgentToNifGetPanProvisionInfo")); |
|
214 |
|
215 // Store the connection mananger for PAN |
|
216 CPanProvisionInfo* panInfo = static_cast<CPanProvisionInfo*>(aInfo); |
|
217 CBnepBridge* bnepConnMgr = static_cast<CBnepBridge*>(iOwner); |
|
218 panInfo->SetBnepConnectionMgr(bnepConnMgr->Id()); |
|
219 |
|
220 // Store a reference to the packet driver owner for later |
|
221 bnepConnMgr->SetPacketDriverOwner(panInfo->PacketDriverOwner()); |
|
222 retval = KErrNone; |
|
223 } |
|
224 break; |
|
225 |
|
226 default: |
|
227 break; |
|
228 } |
|
229 return retval; |
|
230 |
|
231 #else |
|
232 // !SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
233 |
|
234 TBnepConnectionManager* bnepConnectionManager; |
|
235 TInt retval = KErrNotSupported; |
|
236 switch (aEvent) |
|
237 { |
|
238 case EPanAgentToNifGetConnectionManager: |
|
239 LOG(_L8("aEvent=EPanAgentToNifGetConnectionManager")); |
|
240 bnepConnectionManager = static_cast<TBnepConnectionManager*>(aInfo); |
|
241 bnepConnectionManager->iBnepConnectionManager = iOwner; |
|
242 retval = KErrNone; |
|
243 break; |
|
244 |
|
245 default: |
|
246 break; |
|
247 } |
|
248 return retval; |
|
249 #endif |
|
250 // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
251 } |
|
252 |
|
253 /** |
|
254 Called from bridge, pushing data up into Ethint.NIF |
|
255 @internalComponent |
|
256 */ |
|
257 void CBnepLocalDevice::Process (RBnepFrame& aFrame) |
|
258 { |
|
259 LOG_FUNC |
|
260 RMBufPacket chain; |
|
261 TRAPD(err, aFrame.BuildEthernetFrameL(chain)); |
|
262 if(!err) |
|
263 { |
|
264 iParent->Process(chain); |
|
265 } |
|
266 else |
|
267 { |
|
268 aFrame.Reset(); |
|
269 chain.Free(); |
|
270 } |
|
271 } |
|
272 |
|
273 /** |
|
274 Not currently implemented |
|
275 @internalComponent |
|
276 */ |
|
277 TInt CBnepLocalDevice::ResetInterface () |
|
278 { |
|
279 LOG_FUNC |
|
280 return KErrNone; |
|
281 } |
|
282 |
|
283 /** |
|
284 Push a frame into the PAN network. |
|
285 ie. Local device is trying to send a frame to a remote device. |
|
286 @internalComponent |
|
287 */ |
|
288 TInt CBnepLocalDevice::Send (RMBufChain& aPkt) |
|
289 { |
|
290 LOG_FUNC |
|
291 RBnepFrame frame; |
|
292 TInt retval; |
|
293 TRAPD(err, frame.ParseEthernetFrameL(aPkt)); |
|
294 aPkt.Free(); |
|
295 |
|
296 if (!err) |
|
297 { |
|
298 retval = iOwner->Process(frame, iAddr); |
|
299 LOG(_L8("Local device: ...frame sent")); |
|
300 } |
|
301 else |
|
302 { |
|
303 LOG(_L8("Local device: ...frame dropped - problem with parsing ethernet frame")); |
|
304 retval = KReadyForMoreData; |
|
305 } |
|
306 frame.Reset(); |
|
307 return retval; |
|
308 } |
|
309 |
|
310 /** |
|
311 Not currently supported |
|
312 @internalComponent |
|
313 */ |
|
314 TInt CBnepLocalDevice::SetInterfaceAddress (const THWAddr& UNUSEDPARAMETER1) |
|
315 { |
|
316 LOG_FUNC |
|
317 return KErrNotSupported; |
|
318 } |
|
319 |
|
320 /** |
|
321 Not currently supported |
|
322 @internalComponent |
|
323 */ |
|
324 TInt CBnepLocalDevice::SetMulticastList (const THWAddr* UNUSEDPARAMETER1, TInt UNUSEDPARAMETER2) |
|
325 { |
|
326 LOG_FUNC |
|
327 return KErrNotSupported; |
|
328 } |
|
329 |
|
330 /** |
|
331 Not currently supported |
|
332 @internalComponent |
|
333 */ |
|
334 TInt CBnepLocalDevice::SetRxMode (TRxMode UNUSEDPARAMETER1) |
|
335 { |
|
336 LOG_FUNC |
|
337 return KErrNotSupported; |
|
338 } |
|
339 |
|
340 /** |
|
341 Not currently implemented |
|
342 @internalComponent |
|
343 */ |
|
344 TInt CBnepLocalDevice::StartInterface () |
|
345 { |
|
346 LOG_FUNC |
|
347 |
|
348 iInterfaceStarted = ETrue; |
|
349 if(iBDAddressAvailable) |
|
350 { |
|
351 BDADDRChanged(); |
|
352 } |
|
353 |
|
354 return KErrNone; |
|
355 } |
|
356 |
|
357 /** |
|
358 Stops all links. This call is made on the assumption |
|
359 that the interface is going to be unloaded and no attempt |
|
360 will be made to restart in situ. |
|
361 @internalComponent |
|
362 */ |
|
363 TInt CBnepLocalDevice::StopInterface () |
|
364 { |
|
365 LOG_FUNC |
|
366 |
|
367 iInterfaceStarted = EFalse; |
|
368 if(iOwner) |
|
369 { |
|
370 iOwner->StopLinks(); |
|
371 } |
|
372 return KErrNone; |
|
373 } |
|
374 |
|
375 /** |
|
376 Consumes the event but has no other effect. |
|
377 @internalComponent |
|
378 */ |
|
379 void CBnepLocalDevice::Stop () |
|
380 { |
|
381 LOG_FUNC |
|
382 } |
|
383 |