|
1 /* |
|
2 * Copyright (c) 2010 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 "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 #ifndef NCMENGINE_H |
|
23 #define NCMENGINE_H |
|
24 |
|
25 |
|
26 #ifndef __OVER_DUMMYUSBSCLDD__ |
|
27 #include <es_mbuf.h> |
|
28 #else |
|
29 #include <usb/testncm/ethinter.h> |
|
30 #endif |
|
31 |
|
32 #include <random.h> |
|
33 |
|
34 #include "ncmpktdrvcommon.h" |
|
35 #include "ncmcommunicationinterface.h" |
|
36 #include "ncmdatainterface.h" |
|
37 #include "ncmsharedstatemanager.h" |
|
38 |
|
39 class CNcmPktDrv; |
|
40 |
|
41 /** |
|
42 NCM Engine: coordinate with Data Interface, Comm Interface and Shared State Manager. |
|
43 */ |
|
44 NONSHARABLE_CLASS(CNcmEngine) : public CActive, |
|
45 public MNcmDataObserver, |
|
46 public MNcmControlObserver, |
|
47 public MShareStateObserver |
|
48 { |
|
49 public: |
|
50 static CNcmEngine* NewL(CNcmPktDrv& aPktDrv); |
|
51 ~CNcmEngine(); |
|
52 |
|
53 //Start the engine, called by TransferHandle after PktDrvBase's StartInterface; |
|
54 TInt Start(RMessagePtr2& aMsg); |
|
55 //Stop the engine, called by PktDrvBase's StopInterface; |
|
56 void Stop(); |
|
57 |
|
58 //Send a Packet to USB Host. |
|
59 TInt Send(RMBufChain &aPacket); |
|
60 //Get the Interface Mac Address; |
|
61 TUint8* InterfaceAddress(); |
|
62 |
|
63 //From MNcmControlObserver |
|
64 TInt HandleSetNtbInputSize(TDes8&); |
|
65 TInt HandleGetNtbParam(TDes8&); |
|
66 TInt HandleGetNtbInputSize(TDes8&); |
|
67 void ControlError(TInt aError); |
|
68 |
|
69 //From MNcmDataObserver |
|
70 void ProcessReceivedDatagram(RMBufPacket&); |
|
71 void ResumeSending(); |
|
72 void DataError(TInt aError); |
|
73 void HandleAltSetting(TInt aIfNum); |
|
74 TInt SetInEpBufferSize(TUint aSize); |
|
75 |
|
76 //From MShareStateObserver |
|
77 void NotifyDhcpStarted(); |
|
78 |
|
79 inline TInt SetStateToWatcher(TInt aType, TInt aValue) const; |
|
80 inline TInt RegisterNotify(const RMessage2& aMsg) const; |
|
81 inline TInt DeRegisterNotify() const; |
|
82 |
|
83 #ifdef __OVER_DUMMYUSBSCLDD__ |
|
84 public: |
|
85 TInt State() const {return iEngineState;} |
|
86 #endif |
|
87 |
|
88 private: |
|
89 //From CActive |
|
90 void RunL(); |
|
91 void DoCancel(); |
|
92 |
|
93 CNcmEngine(); |
|
94 CNcmEngine(CNcmPktDrv& aPktDrv); |
|
95 void ConstructL(); |
|
96 |
|
97 void InitLddL(const RMessagePtr2& aMsg); |
|
98 void RandomMacAddressL(TNcmMacAddress& aMacAddress); |
|
99 void DoNcmStarted(); |
|
100 void StartDataLayer(); |
|
101 void StopDataLayer(); |
|
102 |
|
103 private: |
|
104 enum TNcmEngineState |
|
105 { |
|
106 ENcmStateUninitialized = 0, |
|
107 ENcmStateStarting, |
|
108 ENcmStateStarted, |
|
109 ENcmStatePaused, |
|
110 ENcmStateStopped, |
|
111 ENcmStateMax |
|
112 }; |
|
113 |
|
114 private: |
|
115 CNcmPktDrv& iPktDrv; |
|
116 |
|
117 CNcmDataInterface* iDataInterface; |
|
118 CNcmCommunicationInterface* iCommInterface; |
|
119 CNcmSharedStateManager* iSharedStateManager; |
|
120 |
|
121 TNcmEngineState iEngineState; |
|
122 TUint iDeviceState; |
|
123 |
|
124 TNcmMacAddress iSymbianMacAddress; |
|
125 |
|
126 RDevUsbcScClient iDataLdd; |
|
127 RDevUsbcScClient iCommLdd; |
|
128 }; |
|
129 |
|
130 //inline functions |
|
131 #include "ncmengine.inl" |
|
132 |
|
133 #endif // NCMENGINE_H |