|
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 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef INC_DROUTER_H |
|
21 #define INC_DROUTER_H |
|
22 |
|
23 #include <e32def.h> // For TUint16 |
|
24 #include <e32cmn.h> // For TDesC8 |
|
25 #include "internalapi.h" // For MIAD2ChannelApi |
|
26 //ISCE #include "mist2iadapi.h" // For TIADConnectionStatus, MIST2IADApi |
|
27 #include "iadinternaldefinitions.h" // For TIADConnectionStatus |
|
28 #include "iadnokiadefinitions.h" // For EIADSizeOfChannels |
|
29 //ISCE |
|
30 #include "isirouterlinkifs.h" // For MLinkRouterIf |
|
31 //ISCE |
|
32 #ifndef NCP_COMMON_BRIDGE_FAMILY |
|
33 class DPipeHandler; |
|
34 #endif |
|
35 //ISCE class MIAD2ISTApi; |
|
36 class DRouter; |
|
37 class DIndicationHandler; |
|
38 class MIAD2ChannelApi; |
|
39 class DQueue; |
|
40 |
|
41 static DObject* iThreadPtr = NULL; |
|
42 const TUint8 KIADEventSubscriptionObjId( 0xfc ); |
|
43 |
|
44 // TODO: own API for indicationhandler (and pipehandler allocate, deallocate, sendmessage ?) |
|
45 |
|
46 // - stores UL (APE destinated) message to receive queue |
|
47 // |
|
48 // add DL (CMT destinated) message to IST's appropriate send queue IS THIS |
|
49 // NEEDED OR FROM HANDLERS? |
|
50 // |
|
51 // route UL message from receive queue to appropriate handler |
|
52 // |
|
53 // receive DL message from LDD |
|
54 // |
|
55 // route DL message to appropriate handler |
|
56 NONSHARABLE_CLASS( DRouter ) : public MChannel2IADApi, |
|
57 // ISCE |
|
58 public MISILinkRouterIf |
|
59 // ISCE |
|
60 |
|
61 { |
|
62 |
|
63 public: |
|
64 |
|
65 DRouter(); |
|
66 |
|
67 ~DRouter(); |
|
68 |
|
69 // From MChannel2IADApi start |
|
70 IMPORT_C TDes8& AllocateBlock( const TUint16 aSize ); |
|
71 |
|
72 // Increases length of the returned descriptor to aSize + pipe header (11). |
|
73 IMPORT_C TDes8& AllocateDataBlock( const TUint16 aSize ); |
|
74 |
|
75 IMPORT_C void Close( const TUint16 aChannel ); |
|
76 |
|
77 IMPORT_C void DeAllocateBlock( TDes8& aBlock ); |
|
78 |
|
79 IMPORT_C TInt GetConnectionStatus(); |
|
80 |
|
81 IMPORT_C TInt GetFlowControlStatus(); |
|
82 |
|
83 IMPORT_C TInt GetMaxDataSize(); |
|
84 |
|
85 IMPORT_C void Open( const TUint16 aChannel, const TUint16 aRequest, MIAD2ChannelApi* aCallback ); |
|
86 |
|
87 IMPORT_C void Open( const TUint16 aChannel, const TUint16 aRequest, const TDesC8& aOpenInfo, MIAD2ChannelApi* aCallback ); |
|
88 |
|
89 IMPORT_C TInt OrderIndication( TDes8& anOrder, const TUint16 aCh, const TBool a32Bit = EFalse ); |
|
90 |
|
91 IMPORT_C TInt SendMessage( TDes8& aMessage, const TUint16 aCh ); |
|
92 |
|
93 IMPORT_C TInt SendIndication( TDes8& aMessage, const TUint16 aCh ); |
|
94 |
|
95 // From MChannel2IADApi end |
|
96 |
|
97 // For Router and it's handler DPipeHandler and DIndicationHandler |
|
98 TInt SendMsg( TDes8& aMsg ); |
|
99 |
|
100 // For PipeHandler |
|
101 MIAD2ChannelApi* GetChannel( const TUint16 aChannel ); |
|
102 // For PipeHandler |
|
103 // ISCE |
|
104 // TODO: DEF files!!! |
|
105 // From MISILinkRouterIf start |
|
106 /* |
|
107 * See comments from MISILinkRouterIf. |
|
108 */ |
|
109 void NotifyTrxPresenceEnqueDfc( TBool aPresent ); |
|
110 |
|
111 /* |
|
112 * See comments from MISILinkRouterIf. |
|
113 */ |
|
114 void Receive( TDes8& aMsg ); |
|
115 // From MISILinkRouterIf end |
|
116 IMPORT_C void DummyDoNothing(); |
|
117 |
|
118 IMPORT_C void DummyDoNothing2(); |
|
119 |
|
120 // ISCE |
|
121 |
|
122 // For internal receiving. |
|
123 void DRouter::MessageReceived( TDes8& aMsg ); |
|
124 |
|
125 #if (NCP_COMMON_SOS_VERSION_SUPPORT >= SOS_VERSION_95) |
|
126 EXPORT_C TInt Loan( const TUint16 aChannel, const TUint16 aRequest, |
|
127 MIAD2ChannelApi* aCallback ); |
|
128 EXPORT_C TInt ReturnLoan( const TUint16 aChannel, const TUint16 aRequest, |
|
129 MIAD2ChannelApi* aCallback ); |
|
130 #endif |
|
131 |
|
132 private: |
|
133 |
|
134 enum TRoutingRule |
|
135 { |
|
136 EIsiMsg = 1, |
|
137 EPipeMsg, |
|
138 EMediaMsg, |
|
139 EIndicationMsg, |
|
140 EControlMsg, |
|
141 EPnNameAddRespMsg, |
|
142 ENotKnownMsg, |
|
143 }; |
|
144 |
|
145 enum TWaitingType |
|
146 { |
|
147 ENormalOpen = 1, |
|
148 EDrmOpen, |
|
149 ENameAddOpen |
|
150 #if (NCP_COMMON_SOS_VERSION_SUPPORT >= SOS_VERSION_95) |
|
151 ,ELoan |
|
152 #endif |
|
153 }; |
|
154 |
|
155 void HandleIsiMessage( TDes8& aMsg ); |
|
156 |
|
157 void HandlePipeMessage( TDes8& aMsg ); |
|
158 |
|
159 void HandleMediaMessage( TDes8& aMsg ); |
|
160 |
|
161 void HandleControlMessage( TDes8& aMsg ); |
|
162 |
|
163 void HandlePnsNameAddResp( TDes8& aMsg ); |
|
164 |
|
165 void SendCommIsaEntityNotReachableResp( const TDesC8& aMsg ); |
|
166 |
|
167 static void CheckDfc(); |
|
168 |
|
169 TInt ValiDateIsiMessage( TDes8& aMsg ); |
|
170 |
|
171 public: |
|
172 static void CheckRouting( DRouter& aTmp, TDes8& aMsg ); |
|
173 |
|
174 private: |
|
175 static void CommonRxDfc( TAny* aPtr ); |
|
176 |
|
177 static void InitCmtDfc( TAny* aPtr ); |
|
178 #ifdef NCP_COMMON_BRIDGE_FAMILY |
|
179 void InitConnectionOk(); |
|
180 #endif |
|
181 void InitCmtConnection(); |
|
182 |
|
183 void SendDrmReq( const TUint16 aChannelId ); |
|
184 |
|
185 void SendPnsNameAddReq( const TUint16 aChannel, const TDesC8& aOpenInfo ); |
|
186 |
|
187 static void NotifyObjLayerConnStatDfc( TAny* aPtr ); |
|
188 |
|
189 void NotifyObjLayerConnStat( const TIADConnectionStatus aStatus ); |
|
190 |
|
191 void SetSenderInfo( TDes8& aMessage, const TUint16 aCh ); |
|
192 |
|
193 // Member data |
|
194 private: |
|
195 |
|
196 void CheckSameThreadContext(); |
|
197 |
|
198 // TODO |
|
199 // Needed due to opening that are waiting a response from cmt side. |
|
200 // Use iWaitingChannel to store a channel pointer then and when resp |
|
201 // received from cmt set iChannel = iWaitingChannel and complete request |
|
202 // Used also when initializing physical and datalink layers. |
|
203 class TIADChannel |
|
204 { |
|
205 public: |
|
206 |
|
207 MIAD2ChannelApi* iChannel; |
|
208 MIAD2ChannelApi* iWaitingChannel; |
|
209 TWaitingType iType; |
|
210 }; |
|
211 |
|
212 // ISCE |
|
213 TUint8 MapMediaToLinkId( const TUint8 aMedia ); |
|
214 |
|
215 enum TISIMedias |
|
216 { |
|
217 #ifndef NCP_COMMON_BRIDGE_FAMILY |
|
218 EISIMediaSOS = 0x00, |
|
219 #else |
|
220 EISIMediaHostSSI = 0x00, |
|
221 #endif |
|
222 EISIAmountOfMedias |
|
223 }; |
|
224 // ISCE |
|
225 |
|
226 // owned |
|
227 // APE <-> CMT connection status ok/nok. |
|
228 TIADConnectionStatus iConnectionStatus; |
|
229 #ifndef NCP_COMMON_BRIDGE_FAMILY |
|
230 DPipeHandler* iPipeHandler; |
|
231 #endif |
|
232 DIndicationHandler* iIndicationHandler; |
|
233 DQueue* iCommonRxQueue; |
|
234 TIADChannel iChannelTable[ EIADSizeOfChannels ]; |
|
235 //static TDfc* iConnStatusBcDfc; |
|
236 TDfc* iCommonRxDfc; |
|
237 TDfc* iInitCmtDfc; |
|
238 TDfc* iConnStatDfc; |
|
239 // Maximum size of isi/data messages to be send. |
|
240 TUint16 iMaxFrameSize; |
|
241 // not owned, just using |
|
242 // When registered !NULL when unregistered NULL. API towards IST. |
|
243 // ISCE RArray<TUint> iArray; |
|
244 TBool iBootDone; |
|
245 |
|
246 // ISCE |
|
247 MISIRouterLinkIf** iLinksArray; |
|
248 // ISCE |
|
249 |
|
250 |
|
251 }; |
|
252 |
|
253 |
|
254 |
|
255 #endif /* INC_DROUTER_H */ |