|
1 // Copyright (c) 2003-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 #if (!defined __DUMMYNIF_H__) |
|
17 #define __DUMMYNIF_H__ |
|
18 |
|
19 #include <comms-infras/nifif.h> |
|
20 #include <nifutl.h> |
|
21 #include <ip4_hdr.h> |
|
22 #include <ip6_hdr.h> |
|
23 #include <udp_hdr.h> |
|
24 #include <in_iface.h> |
|
25 #include <eui_addr.h> // TE64Addr |
|
26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
27 #include <comms-infras/nifprvar_internal.h> |
|
28 #endif |
|
29 |
|
30 class RMBuf; |
|
31 |
|
32 // Delay pipe is implemented is implemented as circ buffer of RMBuf*, each being the start of chain that |
|
33 // the stack transmitted. A NULL terminates a series considered to be simultaneous, the whole queue being |
|
34 // primed with a few NULLs to get things slow starting (maybe) |
|
35 const TInt KDelayQuantum = 100 * 1000; |
|
36 const TInt KDelaySlots = 0; |
|
37 const TInt KDelayQueueSize = 1000; |
|
38 |
|
39 |
|
40 class CDummyIfLink; |
|
41 |
|
42 class CDummyIf4 : public CNifIfBase |
|
43 /** |
|
44 IPv4 interface binder |
|
45 @internalComponent |
|
46 */ |
|
47 { |
|
48 friend class CDummyIfLink; |
|
49 public: |
|
50 CDummyIf4(CDummyIfLink& aLink); |
|
51 ~CDummyIf4(); |
|
52 virtual void BindL(TAny *aId); |
|
53 virtual TInt Send(RMBufChain& aPdu, TAny* aSource=0); |
|
54 virtual void Info(TNifIfInfo& aInfo) const; |
|
55 virtual TInt Control(TUint, TUint, TDes8&, TAny*); |
|
56 virtual TInt Notification(TAgentToNifEventType aEvent, void * aInfo); |
|
57 virtual void Recv(RMBufChain& aPdu); |
|
58 virtual TInt State(); |
|
59 private: |
|
60 void UpdateHeaders(TInet6HeaderIP4* aIp4, TInet6HeaderUDP* aUdp); |
|
61 |
|
62 static TInt DrainNextDrips(TAny* aSelf); |
|
63 protected: |
|
64 TUint32 iLocalAddressBase; |
|
65 TUint32 iLocalAddress; |
|
66 CProtocolBase* iProtocol; |
|
67 TInterfaceName iIfName; |
|
68 private: |
|
69 CDummyIfLink* iLink; |
|
70 }; |
|
71 |
|
72 class CDummyIf6 : public CNifIfBase |
|
73 /** |
|
74 IPv6 interface binder |
|
75 @internalComponent |
|
76 */ |
|
77 { |
|
78 friend class CDummyIfLink; |
|
79 public: |
|
80 CDummyIf6(CDummyIfLink& aLink); |
|
81 // Inherited virtual methods from CNifIfBase |
|
82 virtual void BindL(TAny *aId); |
|
83 virtual TInt Send(RMBufChain& aPdu, TAny* aSource=0); |
|
84 virtual void Info(TNifIfInfo& aInfo) const; |
|
85 virtual TInt Control(TUint, TUint, TDes8&, TAny*); |
|
86 virtual TInt Notification(TAgentToNifEventType aEvent, void * aInfo); |
|
87 virtual void Recv(RMBufChain& aPdu); |
|
88 virtual TInt State(); |
|
89 private: |
|
90 void UpdateHeaders(TInet6HeaderIP* aIp6, TInet6HeaderUDP* aUdp); |
|
91 void StaticDnsConfiguration(); |
|
92 TInt PresetAddr(TIp6Addr& aAddr, const TDesC& aVarName); |
|
93 protected: |
|
94 TE64Addr iLocalIfId; |
|
95 TE64Addr iRemoteIfId; |
|
96 TIp6Addr iPrimaryDns; |
|
97 TIp6Addr iSecondaryDns; |
|
98 CProtocolBase* iProtocol; |
|
99 TInterfaceName iIfName; |
|
100 private: |
|
101 CDummyIfLink* iLink; |
|
102 }; |
|
103 |
|
104 class CDummyIfFactory; |
|
105 class CDummyIfLink : public CNifIfLink, public MTimer |
|
106 /** |
|
107 Common link layer class |
|
108 @internalComponent |
|
109 */ |
|
110 { |
|
111 public: |
|
112 CDummyIfLink(CNifIfFactory& aFactory); |
|
113 ~CDummyIfLink(); |
|
114 virtual TInt Send(RMBufChain& aPdu, TAny* aSource=0); |
|
115 virtual TInt Start(); |
|
116 virtual void Stop(TInt aReason, MNifIfNotify::TAction aAction); |
|
117 virtual void AuthenticateComplete(TInt aResult); |
|
118 virtual void BindL(TAny *aId); |
|
119 virtual CNifIfBase* GetBinderL(const TDesC& aName); |
|
120 virtual void TimerComplete(TInt aStatus); |
|
121 virtual void Info(TNifIfInfo& aInfo) const; |
|
122 virtual TInt Notification(TAgentToNifEventType aEvent, void * aInfo); |
|
123 virtual void Restart(CNifIfBase* aIf); |
|
124 static void FillInInfo(TNifIfInfo& aInfo, TAny* aPtr); |
|
125 virtual TInt Control(TUint aLevel, TUint aName, TDes8& aOption, TAny* aSource=0); |
|
126 |
|
127 CDummyIfFactory& Factory(); |
|
128 public: |
|
129 //CProtocolBase* iProtocol; |
|
130 CDummyIf4* iNifIf4; |
|
131 CDummyIf6* iNifIf6; |
|
132 CNifIfFactory* iFactory; |
|
133 |
|
134 private: |
|
135 TInt SetNifmanIdleTimeout(const TDesC& aTimeoutToSet, const TDes8& aTimeoutValueBuf); |
|
136 }; |
|
137 |
|
138 class CDummyIfFactory : public CNifIfFactory |
|
139 /** |
|
140 Dummy NIF factory class |
|
141 @internalComponent |
|
142 */ |
|
143 { |
|
144 public: |
|
145 virtual ~CDummyIfFactory(); |
|
146 void SetDripReceiver(TCallBack aReceiver); |
|
147 RMBuf* GetDrip(); |
|
148 void AddDrip(RMBuf* aDrip); |
|
149 protected: |
|
150 virtual void InstallL(); |
|
151 virtual CNifIfBase* NewInterfaceL(const TDesC& aName); |
|
152 virtual TInt Info(TNifIfInfo& aInfo, TInt aIndex) const; |
|
153 private: |
|
154 static TInt DripCallback(TAny* aSelf); |
|
155 protected: |
|
156 CPeriodic* iNetDelayTimer; |
|
157 CCirBuf<RMBuf*> iDelayPipe; |
|
158 TCallBack iDripReceiver; |
|
159 }; |
|
160 /** |
|
161 @internalComponent |
|
162 */ |
|
163 const TInt KHexDumpWidth = 16; |
|
164 |
|
165 class CDummyIfLog : public CBase |
|
166 /** |
|
167 @internalComponent |
|
168 */ |
|
169 { |
|
170 public: |
|
171 static void Write(const TDesC& aDes); |
|
172 static void Printf(TRefByValue<const TDesC> aFmt, ...); |
|
173 static void HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen, TInt aWidth = KHexDumpWidth); |
|
174 }; |
|
175 |
|
176 // various things that will get set up on each interface by dummy nifs |
|
177 // obviously this is a common network mask.... |
|
178 _LIT(KNetworkMask, "255.255.255.0"); |
|
179 // will be added to the address base to make the broadcast address... |
|
180 const TUint KBroadcastAddressSuffix = 255; |
|
181 // some arbitrary num to add to the base to give the default gateway machine... |
|
182 const TUint KDefaultGatewayAddressSuffix = 10; |
|
183 // some arbitrary num to add to the base to give the secondary dns server... |
|
184 const TUint KSecondaryDnsAddressSuffix = 11; |
|
185 // obviously all the above addresses are totally arbitrary to a certain extent... :-) |
|
186 |
|
187 #endif |