|
1 /* |
|
2 * Copyright (c) 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 "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 #ifndef _LEGACY_LOOPBACK_DEVICE_H_ |
|
20 #define _LEGACY_LOOPBACK_DEVICE_H_ |
|
21 |
|
22 enum { KLoopbackMTU = 1600, KLoopbackQueueLen = 32 }; |
|
23 |
|
24 /** |
|
25 Physical Device (factory class) for 'ESockLoopback' |
|
26 */ |
|
27 class DESockLoopbackPddFactory : public DPhysicalDevice |
|
28 { |
|
29 public: |
|
30 DESockLoopbackPddFactory(); |
|
31 ~DESockLoopbackPddFactory(); |
|
32 // Inherited from DPhysicalDevice |
|
33 virtual TInt Install(); |
|
34 virtual void GetCaps(TDes8& aDes) const; |
|
35 virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer); |
|
36 virtual TInt Validate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer); |
|
37 public: |
|
38 TInt iHardwareInUse; |
|
39 private: |
|
40 enum TMinimumLDDVersion |
|
41 { |
|
42 EMinimumLddMajorVersion=1, |
|
43 EMinimumLddMinorVersion=0, |
|
44 EMinimumLddBuild=0 //Not used |
|
45 }; |
|
46 public: |
|
47 TDynamicDfcQue* iDfcQ; |
|
48 }; |
|
49 |
|
50 /** |
|
51 Logical Device (factory class) for 'ESockLoopback' |
|
52 */ |
|
53 class DESockLoopbackFactory : public DLogicalDevice |
|
54 { |
|
55 public: |
|
56 DESockLoopbackFactory(); |
|
57 ~DESockLoopbackFactory(); |
|
58 // Inherited from DLogicalDevice |
|
59 virtual TInt Install(); |
|
60 virtual void GetCaps(TDes8& aDes) const; |
|
61 virtual TInt Create(DLogicalChannelBase*& aChannel); |
|
62 }; |
|
63 |
|
64 class DESockLoopback; |
|
65 |
|
66 |
|
67 static const TInt KMaxLddProbePoints = 16; |
|
68 |
|
69 /** |
|
70 Logical Channel class for 'ESockLoopback' |
|
71 */ |
|
72 class DESockLoopbackChannel : public DLogicalChannel |
|
73 { |
|
74 public: |
|
75 DESockLoopbackChannel(); |
|
76 virtual ~DESockLoopbackChannel(); |
|
77 // Inherited from DObject |
|
78 virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType); |
|
79 // Inherited from DLogicalChannelBase |
|
80 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
81 // Inherited from DLogicalChannel |
|
82 virtual void HandleMsg(TMessageBase* aMsg); |
|
83 private: |
|
84 // Panic reasons |
|
85 enum TPanic |
|
86 { |
|
87 ERequestAlreadyPending = 1 |
|
88 }; |
|
89 // Implementation for the differnt kinds of messages sent through RBusLogicalChannel |
|
90 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2); |
|
91 TInt DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2); |
|
92 void DoCancel(TUint aMask); |
|
93 // Accessor for the PDD |
|
94 inline DESockLoopback* Pdd(); |
|
95 // Methods for configuration |
|
96 TInt GetConfig(TDes8* aConfigBuf); |
|
97 TInt SetConfig(const TDesC8* aConfigBuf); |
|
98 void CurrentConfig(RLegacyLoopbackDriver::TConfig& aConfig); |
|
99 // Methods for processing a SendData request |
|
100 TInt SendData(TRequestStatus* aStatus,const TDesC8* aData); |
|
101 void SendDataCancel(); |
|
102 void DoSendDataComplete(); |
|
103 static void SendDataDfc(TAny* aPtr); |
|
104 // Methods for processing a ReceiveData request |
|
105 TInt ReceiveData(TRequestStatus* aStatus,TDes8* aBuffer); |
|
106 void ReceiveDataCancel(); |
|
107 void DoReceiveDataComplete(); |
|
108 static void ReceiveDataDfc(TAny* aPtr); |
|
109 public: |
|
110 // Interface methods for use by PDD |
|
111 virtual void SendDataComplete(TInt aResult); |
|
112 virtual void ReceiveDataComplete(TInt aResult); |
|
113 private: |
|
114 |
|
115 DThread* iClient; |
|
116 // Members used for processing a SendData request |
|
117 TRequestStatus* iSendDataStatus; |
|
118 TDfc iSendDataDfc; |
|
119 TInt iSendDataResult; |
|
120 // TBuf8<KLoopbackMTU> iSendDataBuffer; |
|
121 // Members used for processing a ReceiveData request |
|
122 TDes8* iReceiveDataDescriptor; |
|
123 TRequestStatus* iReceiveDataStatus; |
|
124 TDfc iReceiveDataDfc; |
|
125 TInt iReceiveDataResult; |
|
126 // TBuf8<KLoopbackMTU> iReceiveDataBuffer[KLoopbackRxQueue]; |
|
127 TInt iDebugProbes[KMaxLddProbePoints]; |
|
128 }; |
|
129 |
|
130 inline DESockLoopback* DESockLoopbackChannel::Pdd() |
|
131 { return (DESockLoopback*)iPdd; } |
|
132 |
|
133 /** |
|
134 Interface to 'ESockLoopback' physical device |
|
135 */ |
|
136 class DESockLoopback : public DBase |
|
137 { |
|
138 public: |
|
139 /** |
|
140 Structure for holding PDD capabilities information |
|
141 */ |
|
142 class TCaps |
|
143 { |
|
144 public: |
|
145 TVersion iVersion; |
|
146 }; |
|
147 public: |
|
148 virtual TInt BufferSize() const =0; |
|
149 virtual TInt Speed() const =0; |
|
150 virtual TInt SetSpeed(TInt aSpeed) =0; |
|
151 virtual TDes8& SendBuffer() = 0; |
|
152 virtual TInt RequestDataSend() =0; |
|
153 virtual void SendDataCancel() =0; |
|
154 virtual TDesC8& ReceiveBuffer() = 0; |
|
155 virtual TInt RequestDataReceipt() =0; |
|
156 virtual void ReceiveDataCancel() =0; |
|
157 virtual TBool ReceivedQueueLen() =0; |
|
158 virtual void AdvanceReceiveQueue() = 0; |
|
159 |
|
160 public: |
|
161 DESockLoopbackChannel* iLdd; |
|
162 }; |
|
163 |
|
164 #endif |
|
165 |