|
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 // The DHCPIP6StateMachine header file |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file DHCPIP6StateMachine.h |
|
20 */ |
|
21 |
|
22 #ifndef DHCPIP6STATEMACHINE_H |
|
23 #define DHCPIP6STATEMACHINE_H |
|
24 |
|
25 #include "DHCPStateMachine.h" |
|
26 #include "DHCPIP6MsgSender.h" |
|
27 #include "DHCPIP6IA.h" |
|
28 |
|
29 class CDHCPIP6State; |
|
30 class CDHCPIP6MessageSender; |
|
31 class CDhcpIP6MessageReader; |
|
32 #ifdef SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
33 class CDhcpHwAddrManager; |
|
34 #endif //SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
35 class CDHCPIP6StateMachine : public CDHCPStateMachine |
|
36 /** |
|
37 * Implements helper function & starts DHCPv6 tasks (SOLICITATION,INFORM,....) |
|
38 * |
|
39 * @internalTechnology |
|
40 */ |
|
41 { |
|
42 friend class CDHCPIP6Control; |
|
43 friend class CDHCPIP6ListenToNeighbor; |
|
44 friend class CDHCPIP6Select; |
|
45 friend class CDHCPIP6ReplyNoBinding; |
|
46 friend class CDHCPIP6Renew; |
|
47 friend class CDHCPIP6Reconfigure; |
|
48 friend class CDHCPIP6Rebind; |
|
49 |
|
50 public: |
|
51 /*tasks the statemachine could be started for |
|
52 enum ETask |
|
53 { //Initiated by: Reason: |
|
54 ESolicitation, //Client IP Address & Info (DNS servers,..... |
|
55 EInformRequest, //Client Info only |
|
56 EConfirm, //Client Using the same address after reboot, return from sleep, change IAP,.... |
|
57 EConfigExchange, //Client After lease time expired |
|
58 EReconfigure, //Server Information given to client's changed |
|
59 ERebind, //Client Renew message didn't work |
|
60 EDecline, //Client IP Address not suitable |
|
61 ERelease //Client IP Address not needed any more |
|
62 }; |
|
63 */ |
|
64 |
|
65 public: |
|
66 ~CDHCPIP6StateMachine(); |
|
67 #ifdef SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
68 static CDHCPIP6StateMachine* NewL(RSocketServ& aEsock, RConnection& aConnection, const TName& aInterfaceName, CDhcpHwAddrManager* aDhcpHwAddrManager); |
|
69 #else |
|
70 static CDHCPIP6StateMachine* NewL(RSocketServ& aEsock, RConnection& aConnection, const TName& aInterfaceName); |
|
71 #endif //SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
72 //interface used by CDHCPIP6Control |
|
73 virtual void GetServerAddress( TInetAddr& aAddress ); |
|
74 virtual void SetCurrentAddress(const TInetAddr& aCurrentAddress, const TInetAddr& aSubnetMask); |
|
75 |
|
76 #ifdef SYMBIAN_NETWORKING_DHCPSERVER |
|
77 virtual void CreateOfferMsgL(); |
|
78 virtual void HandleRequestMsgL(); |
|
79 virtual void HandleInformMsgL(); |
|
80 virtual CDHCPState* ReceiveOnPort67L( TRequestStatus* aStatus ); |
|
81 virtual void CloseNSendServerMsgL(TRequestStatus& aStatus, CDHCPStateMachine::EAddressType aEAddressType); |
|
82 virtual void InitialiseServerSocketL(); |
|
83 #endif // SYMBIAN_NETWORKING_DHCPSERVER |
|
84 //dhcpIPX tasks |
|
85 virtual void StartInitL(MStateMachineNotify* aStateMachineNotify, EInitialisationContext aInitialisationContext, TInt aUserTimeOut = 0 );//Starts Solicitation |
|
86 virtual void StartInformL(MStateMachineNotify* aStateMachineNotify, TBool aStaticAddress);//Starts InformRequest |
|
87 virtual void StartRebootL(MStateMachineNotify* aStateMachineNotify);//Starts Confirm |
|
88 virtual void StartRenewL(MStateMachineNotify* aStateMachineNotify, TInt aUserTimeOut); |
|
89 virtual void StartRebindL(MStateMachineNotify* aStateMachineNotify); |
|
90 virtual void StartDeclineL(MStateMachineNotify* aStateMachineNotify); |
|
91 virtual void StartReleaseL(MStateMachineNotify* aStateMachineNotify); |
|
92 //dhcpIP6 special task |
|
93 void StartReconfigureL(MStateMachineNotify* aStateMachineNotify); |
|
94 |
|
95 virtual void RemoveConfiguredAddress(const TInetAddr *aInetAddr = NULL); |
|
96 virtual CDHCPState* ReceiveL( TRequestStatus* aStatus ); |
|
97 void CancelMessageReceiver(); |
|
98 virtual void CloseNSendMsgL(TRequestStatus& aStatus, CDHCPStateMachine::EAddressType aEAddressType); |
|
99 |
|
100 //interface used by CDHCPIP6States derivatives |
|
101 void CreateMessageL(); |
|
102 void CreateCommonMsgStart(); |
|
103 void CreateCommonMsgEndL(); |
|
104 virtual void InitialiseSocketL(); |
|
105 //message creation functions //IP6 naming |
|
106 //-------------------------------------------------------------------- |
|
107 virtual void CreateDiscoverMsgL(); //solicit message |
|
108 virtual void CreateOfferAcceptanceRequestMsgL(); //request |
|
109 virtual void CreateRebootRequestMsgL(); //confirm |
|
110 virtual void CreateInformMsgL(); //inform-request |
|
111 virtual void CreateDeclineMsgL(); //decline |
|
112 virtual void CreateRenewRequestMsgL(); //renew |
|
113 virtual void CreateRebindRequestMsgL(); //rebind |
|
114 virtual void CreateReleaseMsgL(); //release |
|
115 virtual void HandleOfferL(); //handle advertisement |
|
116 virtual CDHCPState* HandleReplyL( TRequestStatus* aStatus );//handle final reply |
|
117 |
|
118 virtual void BindSocketForUnicastL(); |
|
119 |
|
120 TUint GetMessageType() const; |
|
121 TBool CheckXid() const; |
|
122 |
|
123 CDHCPIP6MessageSender* MessageSender() const; |
|
124 DHCPv6::CDHCPMessageHeaderIP6* DhcpMessage() const; |
|
125 |
|
126 void ConfigureInterfaceL( TInt aPos ); |
|
127 #ifdef SYMBIAN_TCPIPDHCP_UPDATE |
|
128 void StartInformL(MStateMachineNotify* aStateMachineNotify); |
|
129 #endif //SYMBIAN_TCPIPDHCP_UPDATE |
|
130 /*the below are values from the base class initialised from the IA (iInterfaceConfigInfo) |
|
131 used in current transanction (renew or rebind) so that they can be accessed from within the |
|
132 CDHCPIP6Renew and CDHCPIP6Rebind classes |
|
133 TUint32 iRenewalTimeT1; |
|
134 TUint32 iRebindTimeT2; |
|
135 TUint32 iLeaseTime; |
|
136 */ |
|
137 |
|
138 protected: |
|
139 CDHCPIP6StateMachine(RSocketServ& aEsock, RConnection& aConnection, const TName& aInterfaceName); |
|
140 void ConstructL(); |
|
141 |
|
142 virtual void AssembleClientIDsL(); |
|
143 virtual void PrepareToSendL(CDHCPStateMachine::EAddressType aEAddressType); |
|
144 #ifdef SYMBIAN_NETWORKING_DHCPSERVER |
|
145 #ifdef SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
146 CDHCPIP6StateMachine(RSocketServ& aEsock, RConnection& aConnection, const TName& aInterfaceName, CDhcpHwAddrManager* aDhcpHwAddrManager); |
|
147 #endif //SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
148 virtual void PrepareToSendServerMsgL(CDHCPStateMachine::EAddressType aEAddressType); |
|
149 #endif // SYMBIAN_NETWORKING_DHCPSERVER |
|
150 virtual void AssignAddresses( TInetAddr& aDest, const TInetAddr& aSrc ) const; |
|
151 |
|
152 virtual void OnCompletion(); |
|
153 |
|
154 // virtual void DoCancel(); |
|
155 |
|
156 protected: |
|
157 void SetMessageHeaderL( DHCPv6::TMessageType aMsgType ); |
|
158 void HandleAckL(); |
|
159 |
|
160 public: |
|
161 DHCPv6::TInterfaceConfigInfo iInterfaceConfigInfo; |
|
162 |
|
163 private: |
|
164 CDhcpIP6MessageReader* iMessageReader; |
|
165 mutable RBuf8 iServerId; |
|
166 TInt iUserRebindTimeout; |
|
167 EInitialisationContext iStartInitCalls; //We need to know when StartInitL is called for the second time. |
|
168 //On the second time we will try once to solicit a DHCP server. |
|
169 //If it fails we will complete the client and try harder on subsequent |
|
170 |
|
171 }; |
|
172 |
|
173 #ifdef SYMBIAN_NETWORKING_DHCPSERVER |
|
174 #ifndef SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
175 inline CDHCPIP6StateMachine::CDHCPIP6StateMachine(RSocketServ& aEsock, RConnection& aConnection, const TName& aInterfaceName): |
|
176 CDHCPStateMachine( aEsock, aConnection, aInterfaceName,EFalse ), iStartInitCalls(EFirstCall) |
|
177 /** |
|
178 * Constructor of the DHCPIP6StateMachine |
|
179 * |
|
180 * @internalTechnology |
|
181 * |
|
182 */ |
|
183 { |
|
184 } |
|
185 #else |
|
186 inline CDHCPIP6StateMachine::CDHCPIP6StateMachine(RSocketServ& aEsock, RConnection& aConnection, const TName& aInterfaceName, CDhcpHwAddrManager* aDhcpHwAddrManager): |
|
187 CDHCPStateMachine( aEsock, aConnection, aInterfaceName, aDhcpHwAddrManager, EFalse ), iStartInitCalls(EFirstCall) |
|
188 /** |
|
189 * Constructor of the DHCPIP6StateMachine |
|
190 * |
|
191 * @internalTechnology |
|
192 * |
|
193 */ |
|
194 { |
|
195 } |
|
196 #endif //SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
197 #else // SYMBIAN_NETWORKING_DHCPSERVER |
|
198 |
|
199 inline CDHCPIP6StateMachine::CDHCPIP6StateMachine(RSocketServ& aEsock, RConnection& aConnection, const TName& aInterfaceName): |
|
200 CDHCPStateMachine( aEsock, aConnection, aInterfaceName ), iStartInitCalls(EFirstCall) |
|
201 /** |
|
202 * Constructor of the DHCPIP6StateMachine |
|
203 * |
|
204 * @internalTechnology |
|
205 * |
|
206 */ |
|
207 { |
|
208 } |
|
209 #endif // SYMBIAN_NETWORKING_DHCPSERVER |
|
210 |
|
211 inline CDHCPIP6MessageSender* CDHCPIP6StateMachine::MessageSender() const |
|
212 { |
|
213 return static_cast<CDHCPIP6MessageSender*>(iMessageSender); |
|
214 } |
|
215 |
|
216 /** |
|
217 * Accessor method for the current DHCP message |
|
218 * |
|
219 * @internalTechnology |
|
220 * |
|
221 */ |
|
222 inline DHCPv6::CDHCPMessageHeaderIP6* CDHCPIP6StateMachine::DhcpMessage() const |
|
223 { |
|
224 return static_cast<DHCPv6::CDHCPMessageHeaderIP6*>(iDhcpMessage); |
|
225 } |
|
226 |
|
227 |
|
228 #endif |
|
229 |