|
1 // Copyright (c) 2001-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 #ifndef RFCOMMFLOW_H |
|
17 #define RFCOMMFLOW_H |
|
18 |
|
19 #include <es_prot.h> |
|
20 #include <bttypes.h> |
|
21 class CRfcommSAP; |
|
22 class CRfcommMuxer; |
|
23 class CRfcommDataFrame; |
|
24 class TRfcommFlowStrategy; |
|
25 |
|
26 /** |
|
27 CRfcommFlowStrategyFactory factory for flow strategies (ways to control flow |
|
28 of packets in and out of Rfcomm). |
|
29 **/ |
|
30 NONSHARABLE_CLASS(CRfcommFlowStrategyFactory) : public CBase |
|
31 { |
|
32 friend class CRfcommProtocol; |
|
33 public: |
|
34 enum TFlowStrategies |
|
35 { |
|
36 EFlowInitial, |
|
37 EFlowCreditBased, //CBFC accepted |
|
38 EFlowNonCreditBased, //CBFC rejected |
|
39 //... |
|
40 EMaxFlowStrategy |
|
41 }; |
|
42 TRfcommFlowStrategy& GetFlowStrategy(const TFlowStrategies aFlowStrategy) const; |
|
43 |
|
44 ~CRfcommFlowStrategyFactory(); |
|
45 private: |
|
46 static CRfcommFlowStrategyFactory* NewL(); |
|
47 CRfcommFlowStrategyFactory(); |
|
48 |
|
49 // Horrible hacky workround for buggy VC6. |
|
50 enum {MaxFlowStrategies=3}; // Must be equal to number of flow strategies in TFlowStrategies above |
|
51 |
|
52 TFixedArray<TRfcommFlowStrategy*, MaxFlowStrategies> iFlowStrategies; |
|
53 }; |
|
54 |
|
55 |
|
56 |
|
57 /** |
|
58 Flow control strategy class |
|
59 **/ |
|
60 NONSHARABLE_CLASS(TRfcommFlowStrategy) : public CBase |
|
61 { |
|
62 public: |
|
63 // Create/destroy |
|
64 TRfcommFlowStrategy(CRfcommFlowStrategyFactory* aFactory=0); |
|
65 ~TRfcommFlowStrategy(); |
|
66 |
|
67 virtual TInt DataBufferMultiple() = 0; |
|
68 virtual TUint16 UsableMTU(const CRfcommSAP& aSAP, TUint8 aCredit) const = 0; |
|
69 virtual TBool AllowWrite(CRfcommSAP& aSAP) = 0; |
|
70 virtual TBool AllowFCOnOff(TBool aCommand) = 0; |
|
71 virtual TInt PNConvergenceLayer(TBool aCommand) = 0; |
|
72 virtual TUint8 PNFinalOctet() = 0; |
|
73 virtual TUint8 WriteCredit(CRfcommSAP& aSAP) = 0; |
|
74 virtual void OutgoingMSCReviseSignals(TBool aCommand, TUint8& aSignals) = 0; |
|
75 virtual void ReviseDonatedCredits(CRfcommSAP& aSAP, TUint8 aCredit) = 0; |
|
76 virtual void ReviseTransmittedCredits(CRfcommSAP& aSAP) = 0; |
|
77 virtual CRfcommDataFrame* NewDataFrame(CRfcommMuxer& aMuxer, TUint8 aAddr, TInt aLen, |
|
78 TUint8 aCredit, CRfcommSAP* aSAP) = 0; |
|
79 virtual TBool CanProcessNewData(const TBool aAllowProcessNewData) const = 0; |
|
80 virtual void DecodeLength(TBool aCBFC, TDesC8& aPacket, |
|
81 TInt& aCreditBuffer, |
|
82 TInt& aHeaderLengthBuffer) = 0; |
|
83 virtual TBool ProcessDataFrameReviseCredits(CRfcommSAP& aSAP, TBool aPoll, |
|
84 TUint8 aCredit) = 0; |
|
85 virtual TBool MSC(CRfcommSAP& aSAP, TUint8 aSignals) = 0; |
|
86 virtual void UpdateRxFlowControlState(CRfcommSAP& aSAP) = 0; |
|
87 virtual TBool NewDataReviseCredits(CRfcommSAP& aSAP, const TDesC8& aData) = 0; |
|
88 virtual void NewData(CRfcommSAP& aSAP) = 0; |
|
89 virtual CRfcommFlowStrategyFactory::TFlowStrategies FlowType() = 0; |
|
90 |
|
91 protected: |
|
92 CRfcommFlowStrategyFactory* iFactory; |
|
93 }; |
|
94 |
|
95 |
|
96 /** |
|
97 Flow control strategy class before decision has been made (1st PN transaction) |
|
98 **/ |
|
99 NONSHARABLE_CLASS(TRfcommFlowStrategyInitial) : public TRfcommFlowStrategy |
|
100 { |
|
101 public: |
|
102 // Create/destroy |
|
103 TRfcommFlowStrategyInitial(CRfcommFlowStrategyFactory* aFactory); |
|
104 ~TRfcommFlowStrategyInitial(); |
|
105 |
|
106 TInt DataBufferMultiple(); |
|
107 TUint16 UsableMTU(const CRfcommSAP& aSAP, TUint8 aCredit) const; |
|
108 TBool AllowWrite(CRfcommSAP& aSAP); |
|
109 TBool AllowFCOnOff(TBool aCommand); |
|
110 TInt PNConvergenceLayer(TBool aCommand); |
|
111 TUint8 PNFinalOctet(); |
|
112 TUint8 WriteCredit(CRfcommSAP& aSAP); |
|
113 void OutgoingMSCReviseSignals(TBool aCommand, TUint8& aSignals); |
|
114 void ReviseDonatedCredits(CRfcommSAP& aSAP, TUint8 aCredit); |
|
115 void ReviseTransmittedCredits(CRfcommSAP& aSAP); |
|
116 CRfcommDataFrame* NewDataFrame(CRfcommMuxer& aMuxer, TUint8 aAddr, TInt aLen, |
|
117 TUint8 aCredit, CRfcommSAP* aSAP); |
|
118 TBool CanProcessNewData(const TBool AllowProcessNewData) const; |
|
119 void DecodeLength(TBool aCBFC, TDesC8& aPacket, |
|
120 TInt& aCreditBuffer, TInt& aHeaderLengthBuffer); |
|
121 TBool ProcessDataFrameReviseCredits(CRfcommSAP& aSAP, TBool aPoll, TUint8 aCredit); |
|
122 TBool MSC(CRfcommSAP& aSAP, TUint8 aSignals); |
|
123 void UpdateRxFlowControlState(CRfcommSAP& aSAP); |
|
124 TBool NewDataReviseCredits(CRfcommSAP& aSAP, const TDesC8& aData); |
|
125 void NewData(CRfcommSAP& aSAP); |
|
126 CRfcommFlowStrategyFactory::TFlowStrategies FlowType(); |
|
127 }; |
|
128 |
|
129 |
|
130 /** |
|
131 Flow control strategy class for "Credit Based Flow Control" |
|
132 **/ |
|
133 NONSHARABLE_CLASS(TRfcommFlowStrategyCreditBased) : public TRfcommFlowStrategyInitial |
|
134 { |
|
135 public: |
|
136 // Create/destroy |
|
137 |
|
138 TRfcommFlowStrategyCreditBased(CRfcommFlowStrategyFactory* aFactory); |
|
139 ~TRfcommFlowStrategyCreditBased(); |
|
140 |
|
141 TInt DataBufferMultiple(); |
|
142 TUint16 UsableMTU(const CRfcommSAP& aSAP, TUint8 aCredit) const; |
|
143 TBool AllowWrite(CRfcommSAP& aSAP); |
|
144 TBool AllowFCOnOff(TBool aCommand); |
|
145 TUint8 WriteCredit(CRfcommSAP& aSAP); |
|
146 void OutgoingMSCReviseSignals(TBool aCommand, TUint8& aSignals); |
|
147 void ReviseDonatedCredits(CRfcommSAP& aSAP, TUint8 aCredit); |
|
148 void ReviseTransmittedCredits(CRfcommSAP& aSAP); |
|
149 CRfcommDataFrame* NewDataFrame(CRfcommMuxer& aMuxer, TUint8 aAddr, TInt aLen, |
|
150 TUint8 aCredit, CRfcommSAP* aSAP); |
|
151 TBool CanProcessNewData(const TBool aAllowProcessNewData) const; |
|
152 void DecodeLength(TBool aCBFC, TDesC8& aPacket, |
|
153 TInt& aCreditBuffer, TInt& aHeaderLengthBuffer); |
|
154 TBool ProcessDataFrameReviseCredits(CRfcommSAP& aSAP, TBool aPoll, TUint8 aCredit); |
|
155 TBool MSC(CRfcommSAP& aSAP, TUint8 aSignals); |
|
156 void UpdateRxFlowControlState(CRfcommSAP& aSAP); |
|
157 TBool NewDataReviseCredits(CRfcommSAP& aSAP, const TDesC8& aData); |
|
158 void NewData(CRfcommSAP& aSAP); |
|
159 CRfcommFlowStrategyFactory::TFlowStrategies FlowType(); |
|
160 }; |
|
161 |
|
162 /** |
|
163 Flow control strategy class for FOn/FOff ... which is per muxer |
|
164 **/ |
|
165 NONSHARABLE_CLASS(TRfcommFlowStrategyNonCreditBased) : public TRfcommFlowStrategyInitial |
|
166 { |
|
167 public: |
|
168 // Create/destroy |
|
169 |
|
170 TRfcommFlowStrategyNonCreditBased(CRfcommFlowStrategyFactory* aFactory); |
|
171 ~TRfcommFlowStrategyNonCreditBased(); |
|
172 |
|
173 |
|
174 TInt PNConvergenceLayer(TBool aCommand); |
|
175 TUint8 PNFinalOctet(); |
|
176 CRfcommFlowStrategyFactory::TFlowStrategies FlowType(); |
|
177 }; |
|
178 |
|
179 |
|
180 |
|
181 #endif |