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 |
|
23 #ifndef NCMDATAINTERFACE_H |
|
24 #define NCMDATAINTERFACE_H |
|
25 |
|
26 #include <e32base.h> |
|
27 #ifndef __OVER_DUMMYUSBSCLDD__ |
|
28 #include <nifmbuf.h> |
|
29 #include <networking/ethinter.h> |
|
30 #include <d32usbcsc.h> |
|
31 #else |
|
32 #include <dummyusbsclddapi.h> |
|
33 #include <usb/testncm/ethinter.h> |
|
34 #endif |
|
35 |
|
36 #include "ncmpktdrvcommon.h" |
|
37 |
|
38 class CNcmDataSender; |
|
39 class CNcmDataReceiver; |
|
40 |
|
41 /** |
|
42 The interface to NCM data channel. |
|
43 */ |
|
44 NONSHARABLE_CLASS(MNcmDataObserver) |
|
45 { |
|
46 public: |
|
47 /** |
|
48 Process received datagram parsed from NCM. |
|
49 @param[in] aPacket, contains the datagram(ethernet frame) to be dealed with. |
|
50 */ |
|
51 virtual void ProcessReceivedDatagram(RMBufPacket& aPacket) = 0; |
|
52 /** |
|
53 Notify the upper layer(TCP/IP stack) to continue to send data. |
|
54 */ |
|
55 virtual void ResumeSending() = 0; |
|
56 /** |
|
57 Notify unrecoverable error in data channel. |
|
58 */ |
|
59 virtual void DataError(TInt aError) = 0; |
|
60 /** |
|
61 Notify the Data Interface's alt-setting changes, which commonly from 0 to 1, or vice versa. |
|
62 @param[in] aIfAltSet, the alt-setting number. |
|
63 */ |
|
64 virtual void HandleAltSetting(TInt aIfAltSet) = 0; |
|
65 }; |
|
66 |
|
67 /** |
|
68 Maintain the logic of Ncm data channel |
|
69 */ |
|
70 NONSHARABLE_CLASS(CNcmDataInterface) : public CActive |
|
71 { |
|
72 public: |
|
73 static CNcmDataInterface* NewL(MNcmDataObserver& aEngine, RDevUsbcScClient& aLdd); |
|
74 ~CNcmDataInterface(); |
|
75 |
|
76 inline TBool IsStarted() const; |
|
77 void Start(); |
|
78 void Stop(); |
|
79 TInt Send(RMBufChain& aPacket); |
|
80 |
|
81 TInt GetSpeed(TInt& aSpeed); |
|
82 TInt GetNtbInputSize(TDes8& aSize); |
|
83 TInt SetNtbInputSize(TDesC8& aSize); |
|
84 TInt GetNtbParam(TDes8& aParam); |
|
85 TInt SetInEpBufferSize(TUint aSize); |
|
86 |
|
87 void ActivateLdd(); |
|
88 inline void DataError(TInt aErroCode) const; |
|
89 inline void ResumeSending() const; |
|
90 inline void ProcessDatagram(RMBufPacket& aPacket) const; |
|
91 inline TInt AltSetting() const; |
|
92 |
|
93 private: |
|
94 CNcmDataInterface(MNcmDataObserver& aEngine, RDevUsbcScClient& aLdd); |
|
95 void ConstructL(); |
|
96 |
|
97 //From CActive |
|
98 void RunL(); |
|
99 void DoCancel(); |
|
100 |
|
101 private: |
|
102 TBool iStarted; |
|
103 CNcmDataSender* iSender; |
|
104 CNcmDataReceiver* iReceiver; |
|
105 MNcmDataObserver& iEngine; |
|
106 |
|
107 RDevUsbcScClient& iLdd; |
|
108 TInt iAltSetting; |
|
109 TUint iIfState; |
|
110 }; |
|
111 |
|
112 // inline functions |
|
113 #include "ncmdatainterface.inl" |
|
114 |
|
115 #endif // NCMDATAINTERFACE_H |
|