28
|
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 |
* header file for NTB build base class
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file
|
|
23 |
@internalComponent
|
|
24 |
*/
|
|
25 |
|
|
26 |
|
|
27 |
#ifndef NCMNTBBUILDER_H
|
|
28 |
#define NCMNTBBUILDER_H
|
|
29 |
|
|
30 |
#include <e32base.h>
|
|
31 |
|
|
32 |
#include "ncmpktdrvcommon.h"
|
|
33 |
|
|
34 |
|
|
35 |
class MNcmNtbBuildObserver;
|
|
36 |
class RMBufChain;
|
|
37 |
class CNcmNtbBuildPolicy;
|
|
38 |
class TNcmNtbInParam;
|
|
39 |
|
|
40 |
|
|
41 |
const TInt KErrBufferFull = -6667;
|
|
42 |
|
|
43 |
|
|
44 |
/**
|
|
45 |
Base class for build NTB
|
|
46 |
*/
|
|
47 |
|
|
48 |
NONSHARABLE_CLASS(CNcmNtbBuilder) : public CBase
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
/**
|
|
52 |
* append a ethernet frame to current NTB
|
|
53 |
*
|
|
54 |
* @param aPacket ethernet packet buffer
|
|
55 |
* @return KErrNone if success
|
|
56 |
* KErrBufferFull if current NTB is full and can't insert the new packet to NTB and send the current NTB immediately
|
|
57 |
*/
|
|
58 |
virtual TInt AppendPacket(const RMBufChain& aPacket) = 0;
|
|
59 |
/**
|
|
60 |
* complete the current NTB
|
|
61 |
*
|
|
62 |
*/
|
|
63 |
virtual void CompleteNtbBuild();
|
|
64 |
/**
|
|
65 |
* change the NtbInMaxSize
|
|
66 |
*
|
|
67 |
* @param aSize new size
|
|
68 |
* @return KErrNone if success
|
|
69 |
* KErrArgument if the size is bigger than allowed size in NCM spec.
|
|
70 |
*/
|
|
71 |
virtual TInt SetNtbInMaxSize(TInt aSize) = 0;
|
|
72 |
/**
|
|
73 |
* prepare build a new NTB
|
|
74 |
*
|
|
75 |
* @param aBuffer buffer to construct NTB
|
|
76 |
*/
|
|
77 |
virtual void StartNewNtb(const TNcmBuffer& aBuffer);
|
|
78 |
/**
|
|
79 |
* reset builder to intial state.
|
|
80 |
*/
|
|
81 |
virtual void Reset();
|
|
82 |
|
|
83 |
public:
|
|
84 |
~CNcmNtbBuilder();
|
|
85 |
void GetNtbParam(TNcmNtbInParam& aParam);
|
|
86 |
inline void SetBuildPolicy(CNcmNtbBuildPolicy& aPolicy);
|
|
87 |
/**
|
|
88 |
* @return ETrue if has called StartNewNtb for current NTB
|
|
89 |
* EFalse otherwise
|
|
90 |
*/
|
|
91 |
inline TBool IsNtbStarted();
|
|
92 |
inline TInt NtbInMaxSize();
|
|
93 |
inline TInt MinNtbInMaxSize();
|
|
94 |
|
|
95 |
protected:
|
|
96 |
CNcmNtbBuilder(MNcmNtbBuildObserver&);
|
|
97 |
void SendNtbPayload();
|
|
98 |
|
|
99 |
protected:
|
|
100 |
/**
|
|
101 |
* refer to NCM spec for following five variable meaning.
|
|
102 |
*/
|
|
103 |
TInt iNtbInMaxSize;
|
|
104 |
TInt iNdpInDivisor;
|
|
105 |
TInt iNdpInPayloadRemainder;
|
|
106 |
TInt iNdpInAlignment;
|
|
107 |
TUint16 iSequence;
|
|
108 |
|
|
109 |
MNcmNtbBuildObserver& iObserver;
|
|
110 |
/**
|
|
111 |
* buffer contains NTB
|
|
112 |
*/
|
|
113 |
TNcmBuffer iBuffer;
|
|
114 |
/**
|
|
115 |
* point to builder policy, this is not ownership
|
|
116 |
*/
|
|
117 |
CNcmNtbBuildPolicy* iBuildPolicy;
|
|
118 |
/**
|
|
119 |
* a NTB is started or not.
|
|
120 |
*/
|
|
121 |
TBool iNtbStarted;
|
|
122 |
};
|
|
123 |
|
|
124 |
|
|
125 |
// Inline functions
|
|
126 |
#include "ncmntbbuilder.inl"
|
|
127 |
|
|
128 |
|
|
129 |
#endif /* NCMNTBBUILDER_H */
|