linklayerprotocols/pppnif/INC/PPPLCP.H
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 /**
       
     2 * Copyright (c) 2005-2009 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 the Default SubConnection Flow
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file PPPLCP.h
       
    24  @internalComponent 
       
    25 */
       
    26 
       
    27 #ifndef PPPLCP_H_INCLUDED_
       
    28 #define PPPLCP_H_INCLUDED_
       
    29 
       
    30 #include <e32base.h>
       
    31 #include <e32std.h>
       
    32 #include <comms-infras/ss_subconnflow.h>
       
    33 #include <comms-infras/nifif.h>
       
    34 #include <comms-infras/ss_protflow.h>
       
    35 #include <comms-infras/ss_flowbinders.h>
       
    36 #include <networking/pppdef.h>
       
    37 #include <networking/pppconfig.h>		// for CCPppLcpConfig::TPppLinkMode
       
    38 #include <comms-infras/agentmessages.h>	// for CAgentProvisionInfo
       
    39 #include <comms-infras/commsdebugutility.h>
       
    40 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    41 #include <nifvar_internal.h>
       
    42 #endif
       
    43 
       
    44 
       
    45 ////////////////////////////////////////////////////////////////////////////////
       
    46 // PPP LCP - The heart of PPP
       
    47 ////////////////////////////////////////////////////////////////////////////////
       
    48 
       
    49 //const TUint KPppIdEsocl = 0x10000; // outside PPP range and Esock forbids zero.
       
    50 
       
    51 class CPppAcp;
       
    52 class CPppAuthentication;
       
    53 class CPppMsCbcpClient;	// CSW
       
    54 
       
    55 // Callback IETF request types (see draft RFC for PPP-callback)
       
    56 typedef enum	// CSW
       
    57 	{
       
    58 	ECallbackIETFRequestType0=0,	// defined by IETF draft RFC
       
    59 	ECallbackIETFRequestType1=1,
       
    60 	ECallbackIETFRequestType2=2,
       
    61 	ECallbackIETFRequestType3=3,
       
    62 	ECallbackIETFRequestType4=4,
       
    63 	ECallbackIETFRequestType5=5,
       
    64 	// and also
       
    65 	ECallbackIETFRequestTypeMSCBCP=6	// from MS rejected draft
       
    66 	} TCallbackIETFRequestType;
       
    67 
       
    68 // String literals for protocol name used during flow binding
       
    69 _LIT8(KProtocol4, "ip");
       
    70 _LIT8(KDescIcmp, "icmp");
       
    71 _LIT8(KProtocol6, "ip6");
       
    72 
       
    73 class CPppCcp;
       
    74 class CPppLrd;
       
    75 class CPppFlowBase;
       
    76 class MPppRecvr;
       
    77 class CPppCompressor;
       
    78 class CPppDeCompressor;
       
    79 class RPppOptionList;
       
    80 #if defined (__FLOG_ACTIVE)
       
    81 class CPppLog;
       
    82 #endif
       
    83 
       
    84 class CPppBinderIp4;
       
    85 class CPppBinderIp6;
       
    86 class CPppLinkBase;
       
    87 class TSigLinkSubType;
       
    88 class CIPConfig;
       
    89 class CPppLcpConfig;
       
    90 class CHDLCConfig;
       
    91 class CCredentialsConfig;
       
    92 class CPPPAuthConfig;
       
    93 class CPppConfig;
       
    94 class CAgentProvisionInfo;
       
    95 class CPppProvisionInfo;
       
    96 
       
    97 class CPppLcp : public ESock::CSubConnectionFlowBase, public ESock::MFlowBinderControl,
       
    98                 public ESock::MUpperDataReceiver, public ESock::MUpperControl,
       
    99                 public MPppFsm, public MPppOptionsExtender
       
   100 /**
       
   101 PPP Link Control Protocol class.
       
   102 This class oversees all the other PPP protocol classes, in addition to
       
   103 implementing the LCP state machine. Objects are instantiated at initialization
       
   104 or as necessary to implement the protocols:
       
   105     CCP, authentication, CBCP, IPCP, IPV6CP
       
   106 @internalComponent
       
   107 */
       
   108 	{
       
   109     friend class CPppLcpFactory;
       
   110 public:
       
   111 	enum TPppProtocol { EPppProtocolBegin = 1, EPppProtoNone = EPppProtocolBegin, EPppIp4 , EPppIp6, EPppAuth, EPppProtocolEnd };
       
   112 
       
   113 	IMPORT_C static CPppLcp* NewL(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf);
       
   114 
       
   115     //-=========================================================
       
   116     // Methods for handling SCPR messages
       
   117     //-=========================================================
       
   118 	IMPORT_C virtual void SubConnectionGoingDown();
       
   119 	IMPORT_C virtual void SubConnectionError(TInt aError);
       
   120 	IMPORT_C virtual void StartFlowL();
       
   121 	IMPORT_C virtual void StopFlow(TInt aError);
       
   122 
       
   123     IMPORT_C virtual void ProvisionConfig(const ESock::RMetaExtensionContainerC& aConfigData);
       
   124     IMPORT_C virtual void Destroy();
       
   125     IMPORT_C virtual void AuthenticateResponseMessage();
       
   126     IMPORT_C virtual void AgentToFlowNotification(TInt aNotificationId);
       
   127 
       
   128     //-=========================================================
       
   129     // MFlowBinderControl methods
       
   130     //-=========================================================
       
   131 	IMPORT_C virtual ESock::MLowerControl* GetControlL(const TDesC8& aProtocol);
       
   132 	IMPORT_C virtual ESock::MLowerDataSender* BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
   133 	IMPORT_C virtual void Unbind(ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
   134 	IMPORT_C virtual ESock::CSubConnectionFlowBase* Flow(); //returns its own flow
       
   135 
       
   136 protected:
       
   137 	IMPORT_C CPppLcp(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf);
       
   138 	IMPORT_C virtual ~CPppLcp();
       
   139 
       
   140     //-=========================================================
       
   141     // FSM upcalls
       
   142     //-=========================================================
       
   143 	IMPORT_C virtual TInt FsmLayerStarted();
       
   144 	IMPORT_C virtual void FsmLayerFinished(TInt aReason=KErrNone);
       
   145 	IMPORT_C virtual void FsmLayerUp();
       
   146 	IMPORT_C virtual void FsmLayerDown(TInt aReason=KErrNone);
       
   147 	IMPORT_C virtual void FsmFillinConfigRequestL(RPppOptionList& aRequestList);
       
   148 	IMPORT_C virtual void FsmCheckConfigRequest(RPppOptionList& aRequestList, RPppOptionList& aAckList, RPppOptionList& aNakList, RPppOptionList& aRejList);
       
   149 	IMPORT_C virtual void FsmApplyConfigRequest(RPppOptionList& aRequestList);
       
   150 	IMPORT_C virtual void FsmRecvConfigAck(RPppOptionList& aReplyList);
       
   151 	IMPORT_C virtual void FsmRecvConfigNak(RPppOptionList& aReplyList, RPppOptionList& aReqList);
       
   152 	IMPORT_C virtual void FsmRecvConfigReject(RPppOptionList& aReplyList, RPppOptionList& aReqList);
       
   153 	IMPORT_C virtual void FsmTerminationPhaseComplete();
       
   154 	IMPORT_C virtual TBool FsmRecvUnknownCode(TUint8 aCode, TUint8 aId, TInt aLength, RMBufChain& aPacket);
       
   155 	IMPORT_C virtual TBool FsmConfigRequestOptionsValid(RPppOptionList& aList);
       
   156 	IMPORT_C virtual TBool FsmAckOptionsValid(RPppOptionList& aList, RPppOptionList& aRequestList);
       
   157 	IMPORT_C virtual TBool FsmRejectOptionsValid(RPppOptionList& aList, RPppOptionList& aRequestList);
       
   158 
       
   159     //-=========================================================
       
   160 	// Messages::ANode methods
       
   161     //-=========================================================
       
   162 	IMPORT_C void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
       
   163 
       
   164     //-=========================================================
       
   165     // CSubConnectionFlowBase methods
       
   166     //-=========================================================
       
   167 	IMPORT_C virtual ESock::MFlowBinderControl* DoGetBinderControlL();
       
   168 
       
   169 public:
       
   170 
       
   171     //-=========================================================
       
   172     // MUpperDataReceiver methods
       
   173     //-=========================================================
       
   174 	IMPORT_C virtual void Process(RMBufChain& aData);
       
   175 
       
   176     //-=========================================================
       
   177     // MUpperControl methods
       
   178     //-=========================================================
       
   179     IMPORT_C virtual void StartSending();
       
   180     IMPORT_C virtual void Error(TInt aError);
       
   181 
       
   182     //-=========================================================
       
   183     // Custom methods
       
   184     //-=========================================================
       
   185     // provide compatability for classes using old CNifIfLink style API and PPP Internal Stop() calls
       
   186     void Stop(TInt aReason, MNifIfNotify::TAction aAction);
       
   187     // call from Binder - MLowerDataSender
       
   188 	ESock::MLowerDataSender::TSendResult Send(RMBufChain& aPdu, TUint aProtocol);
       
   189 
       
   190 	//
       
   191     // Calls from Binder
       
   192     //
       
   193 
       
   194 	IMPORT_C virtual void BinderLinkUp(TPppProtocol aProtocol);		// overriden by CFProtocols derived from CPppLcp
       
   195 
       
   196     void Progress(TInt aStage, TInt aError);
       
   197 	void FlowUp();
       
   198 	void FlowDown(TInt aError, MNifIfNotify::TAction aAction);
       
   199 
       
   200 	// Utility methods for retrieving different provisioning information structures
       
   201 	inline const CIPConfig* GetNcpConfig() const;
       
   202 	inline const CPppLcpConfig* GetLcpConfig() const;
       
   203 	inline const CBCAProvision* GetBCAProvision() const;
       
   204     inline const CPppAuthConfig* GetAuthConfig() const;
       
   205 	inline const CAgentProvisionInfo* GetAgentConfig() const;
       
   206 	inline const CPppProvisionInfo* GetPppAgentConfig() const;
       
   207 
       
   208 	inline const TDesC8& GetExcessData() const;
       
   209 
       
   210 	// Retrieve pointer to locally held credentials object
       
   211 	inline const CCredentialsConfig* GetCredentials() const;
       
   212 
       
   213     //-=========================================================
       
   214     // For CPPPAuthenticate methods - might be worth moving them elsewhere.
       
   215     //-=========================================================
       
   216 	void Authenticate(CPppAuthentication* aAp);
       
   217 	void CancelAuthenticate(CPppAuthentication* aAp);
       
   218 
       
   219 private:
       
   220 	CPppAuthentication* iAuthenticate;
       
   221 
       
   222 protected:
       
   223 	void InitL();
       
   224 
       
   225     //-=========================================================
       
   226     // Custom methods
       
   227     //-=========================================================
       
   228 	TInt DoStartFlow();
       
   229 	void DoStopFlow(TInt aReason, MNifIfNotify::TAction aAction);
       
   230     void ProvisionConfigL(const ESock::RMetaExtensionContainerC& aConfigData);
       
   231 
       
   232 private:
       
   233 	CPppBinderIp4 *iBinder4;
       
   234 	CPppBinderIp6* iBinder6;
       
   235 
       
   236     //-=========================================================
       
   237     // PPP Configs cached
       
   238     //-=========================================================
       
   239 
       
   240 	//
       
   241 	// Pointers to provisioning information objects retrieved from CAccessPointConfig
       
   242 	//
       
   243   	const CBCAProvision* iBCAProvision;
       
   244   	const CIPConfig* iPppNcpConfig;
       
   245   	const CPppLcpConfig* iPppLcpConfig;
       
   246   	const CPppAuthConfig* iPppAuthConfig;
       
   247 	const CAgentProvisionInfo* iAgentProvision;
       
   248 	const CPppProvisionInfo* iPppAgentProvision;
       
   249 	const CCredentialsConfig* iCredentials;
       
   250 
       
   251     TBool iInitialised;
       
   252     TInt iSavedError;				// saved error (if any) from processing ProvisionConfig message
       
   253 
       
   254 public:
       
   255     //-=========================================================
       
   256     // PPP Legacy methods
       
   257     //-=========================================================
       
   258 	inline CPppLinkBase*  PppLink() { return iPppLink; }
       
   259 	void RegisterRecvr(MPppRecvr* aRecvr);
       
   260 	void ReregisterRecvr(MPppRecvr* aRecvr);
       
   261 	void DeregisterRecvr(MPppRecvr* aRecvr);
       
   262 	void LinkFlowOn();
       
   263 	void LinkLayerUp();
       
   264 	void LinkLayerDown(TInt aStatus);
       
   265 	void PhaseComplete();
       
   266 	void PhaseAborted(TInt aStatus);
       
   267 	void PhaseAdvance(TPppPhase aNewPhase);
       
   268 	void PhaseRetard(TPppPhase aNewPhase, TInt aReason);
       
   269 	TUint8 SendEchoRequest();
       
   270 	void SendIdentification();
       
   271 	inline CPppLcpConfig::TPppLinkMode PppLinkMode() const;
       
   272 	void NcpUp();
       
   273 	//
       
   274 	TInt PppOpen();
       
   275 	void PppClose(TInt aReason);
       
   276 
       
   277 	inline TBool DoLcpExts() const { return iDoLcpExts; }
       
   278 	inline void CallbackRequestGranted();	// CSW
       
   279 	void TerminateLink(MNifIfNotify::TAction aAction=MNifIfNotify::EDisconnect, TInt aError=KErrNone);
       
   280 	void PppNewCompressor(const CPppCompressor* aCompressor);
       
   281 	void PppUnloadCompressor();
       
   282 	void PppNewDeCompressor(const CPppDeCompressor* aDeCompressor);
       
   283 	void StopProtocol(TUint aProtocol);
       
   284 	TBool DoesDllExist(const TDesC& aFilename);
       
   285 	inline CObjectConIx*	ContainerForDlls() const { return iContainerForDlls; }
       
   286 
       
   287 	TInt Notification(TAgentToNifEventType aEvent, void * aInfo);
       
   288 
       
   289 	// Added for callback July 99
       
   290 	inline TCallbackIETFRequestType CallbackRequestType(){return iCallbackIETFRequestType;}
       
   291 	inline TBool CallbackEnabled(){return iCallbackEnabled;}
       
   292 
       
   293 	inline void SetMaxTransferSize(TInt aLength);
       
   294 	inline TInt MaxTransferSize() const;
       
   295 	inline void SetMaxReceiveSize(TInt aSize);
       
   296 	inline TInt MaxReceiveSize() const;
       
   297 
       
   298 	void CancelRead();
       
   299 
       
   300 	void CallbackGrantedAndAuthenticated();
       
   301 
       
   302 	// Returns true if an external IP configuration agent (MIP, DHCP) is active
       
   303 	TBool QueryExternalIPConfiguration();
       
   304 
       
   305    	void LinkRecv(RMBufChain& aPacket);
       
   306 
       
   307 private:
       
   308 	static void NewMagicNumberL(TUint& aMagicNumber);
       
   309 	INLINE void AppendCallbackRequestL(RPppOptionList&  aRequestList );
       
   310 	INLINE void InitCallbackInfoL();
       
   311 	INLINE void PhaseAdvancesBeyondAuthenticate();
       
   312 	INLINE void GetCallbackInfoL();
       
   313 	INLINE void NewCallbackRequestInfoL( TCallbackIETFRequestType aRequestType );	// CSW
       
   314 
       
   315 	// Utility functions for posting messages to SCPR
       
   316 
       
   317 	void PostProgressMessage(TInt aStage, TInt aError);
       
   318 	void PostDataClientStartedMessage();
       
   319 	void PostFlowDownMessage(TInt aError);
       
   320 	void PostErrorMessage(TInt aError);
       
   321 	void MaybePostDataClientIdle();
       
   322 	TBool AllNcpsUp();
       
   323 	// Utility functions for processing incoming SCPR messages
       
   324 	TInt NotificationMessage(TAgentToNifEventType aNotificationId);
       
   325 
       
   326 	// Utilities for retrieval of SCPr Provisioning Information
       
   327 	TInt RetrieveDynamicProvisionInfo();
       
   328 
       
   329     // Flogging mechanism
       
   330     __FLOG_DECLARATION_MEMBER;
       
   331 private:
       
   332 
       
   333     /** IP Protocol */
       
   334 
       
   335     /** The Compression Control Protocol object */
       
   336 	CPppCcp* iPppCcp;
       
   337 
       
   338 	/** Number of times PppOpen has been called without a corresponding PppClose */
       
   339 	TInt iOpenCount;
       
   340 
       
   341 	/** Current PPP phase */
       
   342 	TPppPhase iPhase;
       
   343 
       
   344 	/** Authentication protocol framework object */
       
   345 	CPppAcp* iPppAcp;
       
   346 
       
   347 	/** Link quality checking object */
       
   348 	CPppLrd* iPppLrd;
       
   349 
       
   350 	/** Lower link-layer object */
       
   351 	CPppLinkBase* iPppLink;
       
   352 
       
   353 	/** List of objects that can receive incoming packets */
       
   354 	TDblQue<MPppRecvr> iRecvrList;
       
   355 
       
   356 	TUint iLocMagicNumber;
       
   357 	TUint iRemMagicNumber;	// Or last NAK sent to peer
       
   358 	TInt iConsecMagic;
       
   359 	TInt iMaxSendSize;
       
   360 	TInt iMaxRecvSize;
       
   361 	HBufC8* iRecvIdentification;
       
   362 	TTimeIntervalSeconds iRecvTimeRemaining;
       
   363 	TTime iRecvTimeNotification;
       
   364 	HBufC8* iRecvTimeRemMessage;
       
   365 	/** Authentication protocol object */
       
   366 
       
   367 
       
   368 	/** Whether CBCP configuration has been read */
       
   369 	TBool	iGotCallbackInfo;
       
   370 
       
   371 	/** Whether CBCP is enabled */
       
   372 	TBool	iCallbackEnabled;
       
   373 
       
   374 	TCallbackAction iCallbackAction;
       
   375 	TCallbackIETFRequestType iCallbackIETFRequestType;
       
   376 	TUint8* iCallbackInfo;
       
   377 	TInt	iCallbackInfoLen;
       
   378 	TUint8* iCallbackIETFRequestPacket;
       
   379 	TInt	iCallbackIETFRequestPacketLen;
       
   380 	TBool	iCallbackRequestGranted;
       
   381 
       
   382 	/* Callback Control Protocol object */
       
   383 	CPppMsCbcpClient* iPppMsCbcp;
       
   384 
       
   385 	/** The action to take once the link goes down */
       
   386 	MNifIfNotify::TAction iTerminateAction;
       
   387 
       
   388 	/** The reason the link is going down */
       
   389 	TInt	iError;
       
   390 
       
   391 	/** Whether certain extended PPP options from RFC 1570 are to be handled */
       
   392 	TBool iDoLcpExts;
       
   393 
       
   394 	TBool iRecursive;
       
   395 	CObjectConIx*	iContainerForDlls;
       
   396 
       
   397 	/** Whether authentication has been completed */
       
   398 	TBool iAuthenticateDone;
       
   399 
       
   400 	/** The last request received */
       
   401 	Messages::TNodeSignal::TMessageId iLastRequest;
       
   402 	TBool iLastRequestErrored;
       
   403 
       
   404 	/** Whether we are configured to do Mobile IP */
       
   405 	TBool iDoExternalIPConfiguration;
       
   406 
       
   407   	/** Whether we are configured for client or server mode */
       
   408   	CPppLcpConfig::TPppLinkMode iLinkMode;
       
   409 
       
   410 	/*The number of Ncps that have reported being up*/
       
   411 	TInt iNcpUpCount;
       
   412 
       
   413   	enum TMeshMachineFlowState
       
   414       	{
       
   415       	EStopped,
       
   416       	EStarting,
       
   417       	EStarted,
       
   418       	EStopping,
       
   419       	};
       
   420 	TMeshMachineFlowState iMMState;
       
   421 	Elements::TStateChange iLastStateChange; //To avoid double reporting
       
   422 	TBool iSentIdle;
       
   423 
       
   424 #ifdef __FLOG_ACTIVE
       
   425 public:
       
   426 	CPppLog* iLogger;
       
   427 	TInt iLogLevel;
       
   428 	
       
   429 private:
       
   430 	const TText8* GetMMStateName() const;
       
   431 #endif
       
   432 	};
       
   433 
       
   434 #include <networking/ppplcp.inl>
       
   435 #endif