linklayerprotocols/pppnif/INC/ncpip.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 1997-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 // ncpip4.H
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent 
       
    21 */
       
    22 
       
    23 #if !defined(__NCPIP4_H__)
       
    24 #define __NCPIP4_H__
       
    25 
       
    26 #include <in_iface.h>
       
    27 #include <comms-infras/ss_protflow.h>
       
    28 #include <comms-infras/commsdebugutility.h>
       
    29 #include <comms-infras/es_protbinder.h>
       
    30 #include <networking/ppplcp.h>
       
    31 #include <networking/pppbase.h>
       
    32 
       
    33 const TUint KPppIpIfaceFeatures =
       
    34 //		KIfIsLoopback |
       
    35 		KIfIsPointToPoint |
       
    36 //		KIfCanBroadcast |
       
    37 //		KIfCanMulticast	|
       
    38 //		KIfCanSetMTU |
       
    39 //		KIfHasHardwareAddr |
       
    40 //		KIfCanSetHardwareAddr |
       
    41 		0;
       
    42 
       
    43 const TUint KIpcpSendPriority = 10;
       
    44 //const TUint KPppIdIp = 0x0021;	// MOVED TO VJ.H
       
    45 
       
    46 const TUint KPppIdIpcp = 0x8021;
       
    47 const TUint KPppIdCompressed = 0x00fd;
       
    48 const TUint KPppIdHeadComp = 0x004f;
       
    49 const TUint KPppIdHeadCompCp = 0x804f;
       
    50 
       
    51 const TUint8 KPppIpcpOptIpAddresses = 1;
       
    52 const TUint8 KPppIpcpOptIpCompressionProtocol = 2;
       
    53 const TUint8 KPppIpcpOptIpAddress = 3;
       
    54 const TUint8 KPppIpcpOptPrimaryDnsAddress = 129;
       
    55 const TUint8 KPppIpcpOptSecondaryDnsAddress = 131;
       
    56 // NetBios
       
    57 const TUint8 KPppIpcpOptPrimaryNbnsAddress = 130;
       
    58 const TUint8 KPppIpcpOptSecondaryNbnsAddress = 132;
       
    59 
       
    60 const TUint KSlashChar='\\';
       
    61 
       
    62 class MIpcpIpRecvr : public MPppRecvr
       
    63 	{
       
    64 public:
       
    65 	MIpcpIpRecvr(CPppLcp* aLcp);
       
    66 	virtual TBool RecvFrame(RMBufChain& aPacket);
       
    67 	virtual void  FrameError();
       
    68 	virtual void  KillProtocol();
       
    69 	};
       
    70 
       
    71 class MIpcpTcpVjCompRecvr : public MPppRecvr
       
    72 	{
       
    73 public:
       
    74 	MIpcpTcpVjCompRecvr(CPppLcp* aLcp);
       
    75 	virtual TBool RecvFrame(RMBufChain& aPacket);
       
    76 	virtual void  FrameError();
       
    77 	virtual void  KillProtocol();
       
    78 	};
       
    79 
       
    80 class MIpcpTcpVjUncompRecvr : public MPppRecvr
       
    81 	{
       
    82 public:
       
    83 	MIpcpTcpVjUncompRecvr(CPppLcp* aLcp);
       
    84 	virtual TBool RecvFrame(RMBufChain& aPacket);
       
    85 	virtual void  FrameError();
       
    86 	virtual void  KillProtocol();
       
    87 	};
       
    88 
       
    89 class CVJCompressorIf;
       
    90 class CVJDeCompressorIf;
       
    91 
       
    92 class CPppLcp;
       
    93 class CPppNifSubConnectionFlow;
       
    94 
       
    95 NONSHARABLE_CLASS(CPppBinderIp4) : public CBase, public MPppFsm,
       
    96 								   public ESock::MLowerDataSender, public ESock::MLowerControl
       
    97 /**
       
    98 Implements IPCP and support for IP datagrams (RFC 1332)
       
    99 
       
   100 @internalComponent
       
   101 */
       
   102 	{
       
   103 public:
       
   104    	static CPppBinderIp4* NewL(CPppLcp* aLcp);
       
   105 	~CPppBinderIp4();
       
   106 
       
   107     //-=========================================================
       
   108     // MLowerDataSender methods
       
   109     //-=========================================================
       
   110 	virtual ESock::MLowerDataSender::TSendResult Send(RMBufChain& aPdu);
       
   111 	
       
   112     //-=========================================================
       
   113 	// MLowerControl methods
       
   114     //-=========================================================
       
   115 	virtual TInt GetName(TDes& aName);
       
   116 	virtual TInt BlockFlow(ESock::MLowerControl::TBlockOption /*aOption*/);
       
   117     virtual TInt GetConfig(TBinderConfig& aConfig);
       
   118     virtual TInt Control(TUint aLevel, TUint aName, TDes8& aOption);
       
   119 
       
   120     //-=========================================================
       
   121     // Callthrough from MFlowBinderControl instance
       
   122     //-=========================================================
       
   123     MLowerDataSender* BindL(ESock::MUpperDataReceiver& aUpperReceiver, ESock::MUpperControl& aControl);
       
   124     void UnBind(ESock::MUpperDataReceiver& aUpperReceiver, ESock::MUpperControl& aControl);
       
   125 
       
   126 	//
       
   127 	TBool MatchesUpperControl(const ESock::MUpperControl* aUpperControl) const;
       
   128 	
       
   129 	void SendFlowOn();
       
   130     void Error(TInt aError);
       
   131 	TInt Notification(TAgentToNifEventType aEvent);
       
   132 
       
   133 	//
       
   134 	void RecvIp(RMBufChain& aPacket);
       
   135 	void RecvVjCompTcp(RMBufChain& aPacket);
       
   136 	void RecvVjUncompTcp(RMBufChain& aPacket);
       
   137 	void IpFrameError();
       
   138 	void VjCompTcpFrameError();
       
   139 	void VjUncompTcpFrameError();
       
   140 	void IpKillProtocol();
       
   141 	void VjCompTcpKillProtocol();
       
   142 	void VjUncompTcpKillProtocol();
       
   143 
       
   144 	//
       
   145 
       
   146 protected:
       
   147 
       
   148 	// PPP FSM Upcalls
       
   149 	virtual TInt FsmLayerStarted();
       
   150 	virtual void FsmLayerFinished(TInt aReason=KErrNone);
       
   151 	virtual void FsmLayerUp();
       
   152 	virtual void FsmLayerDown(TInt aReason=KErrNone);
       
   153 	virtual void FsmFillinConfigRequestL(RPppOptionList& aRequestList);
       
   154 	virtual void FsmCheckConfigRequest(RPppOptionList& aRequestList, RPppOptionList& aAckList, RPppOptionList& aNakList, RPppOptionList& aRejList);
       
   155 	virtual void FsmApplyConfigRequest(RPppOptionList& aRequestList);
       
   156 	virtual void FsmRecvConfigAck(RPppOptionList& aReplyList);
       
   157 	virtual void FsmRecvConfigNak(RPppOptionList& aReplyList, RPppOptionList& aReqList);
       
   158 	virtual void FsmRecvConfigReject(RPppOptionList& aReplyList, RPppOptionList& aReqList);
       
   159 	virtual void FsmTerminationPhaseComplete();
       
   160 	virtual TBool FsmRecvUnknownCode(TUint8 aCode, TUint8 aId, TInt aLength, RMBufChain& aPacket);
       
   161 	virtual void KillProtocol();
       
   162 private:
       
   163    	void  ConstructL();
       
   164    	CPppBinderIp4(CPppLcp* aLcp);
       
   165 
       
   166 	MLowerDataSender::TSendResult SendProtFrame(RMBufChain& aPacket, TUint aProtocol);
       
   167 	static TInt SendCallBack(TAny* aCProtocol);
       
   168 	void DoSend();
       
   169 	CVJCompressorIf*	LoadVJCompressorL();
       
   170 	CVJDeCompressorIf*	LoadVJDeCompressorL();
       
   171 	
       
   172 	inline CPppLcp* Flow();
       
   173 
       
   174     __FLOG_DECLARATION_MEMBER;
       
   175 private:
       
   176 	//
       
   177     CPppLcp* iPppNifSubConnectionFlow;
       
   178 
       
   179 	ESock::MUpperDataReceiver* iUpperReceiver;
       
   180     ESock::MUpperControl* iUpperControl;
       
   181 
       
   182     TBool iAuthenticated;
       
   183 	RMBufPktQ iSendQ;
       
   184 	CAsyncCallBack* iSendCallBack;
       
   185 
       
   186 	TInterfaceName iIfName;
       
   187 
       
   188 	//
       
   189 	ESock::MLowerDataSender::TSendResult iLowerFlowOn;
       
   190 	ESock::MLowerDataSender::TSendResult iUpperFlowOn;
       
   191 	//
       
   192 	TPppExtraRecvr<CPppBinderIp4> iIpRecvr;
       
   193 	TPppExtraRecvr<CPppBinderIp4> iVjCompTcpRecvr;
       
   194 	TPppExtraRecvr<CPppBinderIp4> iVjUncompTcpRecvr;
       
   195 
       
   196 	// Negotiated information
       
   197 	TUint32 iPrimaryDns;
       
   198 	TUint32 iSecondaryDns;
       
   199 
       
   200 	/** Held in case of a future NetBios protocol */
       
   201 	TUint32 iPrimaryNbns;
       
   202 	
       
   203 	/** Held in case of a future NetBios protocol */
       
   204 	TUint32 iSecondaryNbns;
       
   205 
       
   206 	TUint32 iRemoteAddr;
       
   207 	TUint32 iLocalAddr;
       
   208 	TUint32 iNetworkMask;
       
   209 	CVJDeCompressorIf*	iVJDecompressor;
       
   210 	CVJCompressorIf*	iVJCompressor;
       
   211 	CObjectCon*			iVJCompressorCon;
       
   212 	CObjectCon*			iVJDeCompressorCon;
       
   213 	
       
   214 	/** ETrue if the user enabled VJ compression */
       
   215 	TBool				iVJCompressionOn;
       
   216 	
       
   217 	TUint				iMaxVJSlots;
       
   218 	TBool				iCompressConnId;
       
   219 	};
       
   220 
       
   221 //
       
   222 // Inline functions
       
   223 //
       
   224 
       
   225 CPppLcp* CPppBinderIp4::Flow()
       
   226 	{
       
   227 	return iPppNifSubConnectionFlow;
       
   228 	}
       
   229 
       
   230 
       
   231 #endif // __PPPBINDERIP4_H__