|
1 // Copyright (c) 2004-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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef __RBNEPFRAME_H |
|
22 #define __RBNEPFRAME_H |
|
23 |
|
24 #include <e32def.h> |
|
25 #include <nifmbuf.h> |
|
26 #include "RBnepControl.h" |
|
27 #include "MLinkManager.h" |
|
28 |
|
29 class TBTDevAddr; |
|
30 class RMBufChain; |
|
31 |
|
32 /** |
|
33 * KBnep is a flag that gets set by the BNEP packet driver to indicate |
|
34 * to the PAN NAP IP hooks that the packet has come from a remote Bluetooth |
|
35 * PAN device. |
|
36 */ |
|
37 const TUint KBnep = 0x00000100; |
|
38 |
|
39 /** |
|
40 * KBnepForwardingAllowed is also set by the BNEP packet driver to |
|
41 * indicate to the PAN NAP IP hooks that the packet has come from a remote |
|
42 * Bluetooth PAN device that has been granted access to the public network. |
|
43 */ |
|
44 const TUint KBnepForwardingAllowed = 0x00000200; |
|
45 |
|
46 const TInt KGeneralEthernetHeaderLength = 13; |
|
47 const TInt KCompressedEthernetSourceOnlyHeaderLength = 7; |
|
48 const TInt KCompressedEthernetDestOnlyHeaderLength = 7; |
|
49 const TInt KCompressedEthernetHeaderLength = 1; |
|
50 |
|
51 const TInt KNetworkProtocolTypeFieldLength = 2; |
|
52 const TInt KIEEE802_1QTagFieldLength = 2; |
|
53 |
|
54 |
|
55 /** |
|
56 A BNEP frame. |
|
57 Built from one of an ethernet frame, a BNEP frame or a sequence of commands, |
|
58 this object encapsulates the data held by a BNEP frame. |
|
59 */ |
|
60 NONSHARABLE_CLASS(RBnepFrame) |
|
61 { |
|
62 public: |
|
63 enum TPacketContents |
|
64 { |
|
65 EDataFrame = 0x01, |
|
66 EControl = 0x02, |
|
67 EHas1Q = 0x04, |
|
68 EExtensionHeaders = 0x08, |
|
69 }; |
|
70 |
|
71 enum TDestAddrType |
|
72 { |
|
73 ELocal, |
|
74 EMulticast, |
|
75 ENormal |
|
76 }; |
|
77 |
|
78 RBnepFrame(); |
|
79 void BuildBnepFrameL(RMBufChain& aChain, |
|
80 const TBTDevAddr& aLocalAddr, |
|
81 const TBTDevAddr& aRemoteAddr, |
|
82 TBool aFilterEthernetPayload); |
|
83 |
|
84 void BuildEthernetFrameL (RMBufPacket& aChain); |
|
85 const TBTDevAddr& DestAddr () const; |
|
86 TDestAddrType DestinationType () const; |
|
87 TBool Includes (TPacketContents aContent) const; |
|
88 void InsertControl (RBnepControl* aCommand); |
|
89 TBnepPacketType ParseBnepFrameL (RMBufChain& aInboundChain, const TBTDevAddr& aLocalAddr, const TBTDevAddr& aRemoteAddr); |
|
90 void ParseEthernetFrameL (RMBufChain& aFrame); |
|
91 void Reset (); |
|
92 const TBTDevAddr& SrcAddr () const; |
|
93 TBool IsEmpty (); |
|
94 void ExecuteControl (MLinkManager& aController); |
|
95 TUint16 Protocol () const; |
|
96 TInt PayloadLength() const; |
|
97 void SetUplinkAccessAllowedForBnepLink(TBool aUplinkAccessAllowedForBnepLink); |
|
98 |
|
99 private: |
|
100 void BuildBnepControlFrameL (RMBufChain& aChain); |
|
101 void BuildBnepDataFrameL(RMBufChain& aChain, const TBTDevAddr& aLocalAddr, const TBTDevAddr& aRemoteAddr, TBool aFilterEthernetPayload); |
|
102 void SetContents (TPacketContents aContent); |
|
103 void TrimBTAddrL (RMBufChain& aChain, TBTDevAddr& aAddr); |
|
104 void TrimUint16L (RMBufChain& aChain, TUint16& aInt); |
|
105 void ParseL (RMBufChain& aInboundChain, TBnepPacketType aType, TBool aExt); |
|
106 TInt ParseExtensionL (RMBufChain& aInboundChain); |
|
107 void ExtractControlL (RMBufChain& aInboundChain, TInt aLength); |
|
108 |
|
109 private: |
|
110 // Data Members for Has Relationships |
|
111 TSglQue< RBnepControl > iCommandQueue; |
|
112 TBTDevAddr iDestAddr; |
|
113 TBTDevAddr iSrcAddr; |
|
114 TUint16 iProtocol; |
|
115 TUint8 iPacketContents; |
|
116 TBool iUplinkAccessAllowedForBnepLink; |
|
117 |
|
118 // This member holds the contents of the frame excluding the BT |
|
119 // addresses and the protocol and any control headers. |
|
120 RMBufChain iFramePayload; |
|
121 }; |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 // Class RBnepFrame |
|
127 |
|
128 inline void RBnepFrame::SetContents (TPacketContents aContent) |
|
129 { |
|
130 iPacketContents |= static_cast<TUint8>(aContent); |
|
131 } |
|
132 |
|
133 inline TBool RBnepFrame::IsEmpty () |
|
134 { |
|
135 return iCommandQueue.IsEmpty(); |
|
136 } |
|
137 |
|
138 inline TUint16 RBnepFrame::Protocol () const |
|
139 { |
|
140 return iProtocol; |
|
141 } |
|
142 |
|
143 #endif |