linklayerprotocols/pppnif/SPPP/PppUmts.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2002-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 // This module contains the code for the PPP "proxy" class which communicates with the lower Nif.
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "PppUmts.h"
       
    19 #include "PppUmts.inl"
       
    20 #include "in_iface.h"
       
    21 
       
    22 /****************/
       
    23 /* CProtocolPpp */
       
    24 /****************/
       
    25 
       
    26 CProtocolPpp::CProtocolPpp()
       
    27 {
       
    28 }
       
    29 
       
    30 CProtocolPpp* CProtocolPpp::NewL()
       
    31 {
       
    32 	return new(ELeave) CProtocolPpp();
       
    33 }
       
    34 
       
    35 CProtocolPpp::~CProtocolPpp()
       
    36 {
       
    37 }
       
    38 
       
    39 void CProtocolPpp::SetValue(CPppUmtsLink* aPppUmtsLink)
       
    40 {
       
    41 	iPppUmtsLink = aPppUmtsLink;
       
    42 }
       
    43 
       
    44 /****************/
       
    45 /* CPppUmtsLink */
       
    46 /****************/
       
    47 
       
    48 CPppUmtsLink::CPppUmtsLink(CPppLcp* aLcp, const TDesC& aParams)
       
    49 : CPppLinkBase(aLcp)
       
    50 	{
       
    51 	iNifName.Copy(aParams);						// save away the lower layer Nif name
       
    52 	}
       
    53 
       
    54 CPppUmtsLink::~CPppUmtsLink()
       
    55 /**
       
    56  * Close lower layer Nif.
       
    57  */
       
    58 	{
       
    59 	// Close the Link layer of the lower Nif.
       
    60 	if(iUmtsNif)
       
    61 		iUmtsNif->Close();
       
    62 
       
    63 	delete iProtocolPpp;
       
    64 	
       
    65 	// Close the NCP layer of the lower Nif.  Note: this causes the factory to be closed.
       
    66 	if(iUmtsNifPppBinder)
       
    67 		iUmtsNifPppBinder->Close();
       
    68 	}
       
    69 
       
    70 void CPppUmtsLink::CreateL()
       
    71 /**
       
    72  * Construct the lower layer Nif and bind it to PPP.
       
    73  *
       
    74  * Called on PPP startup if CommDb indicates a lower layer Nif is to be used
       
    75  * (otherwise HDLC link class is created).
       
    76  *
       
    77  * @exception leaves if could not allocate memory opr create the Nif.
       
    78  */
       
    79 	{
       
    80 	iProtocolPpp = CProtocolPpp::NewL();
       
    81 
       
    82 	iUmtsNif = (CNifIfLink*)Nif::CreateInterfaceL(iNifName,this);
       
    83 	iUmtsNif->Open();
       
    84 	_LIT(Kppp,"ppp");
       
    85 	iUmtsNifPppBinder = iUmtsNif->GetBinderL(Kppp);
       
    86 	iUmtsNifPppBinder->Open();
       
    87 	iUmtsNifPppBinder->BindL(iProtocolPpp);
       
    88 	iProtocolPpp->SetValue(this);
       
    89 	}
       
    90 
       
    91 void CPppUmtsLink::Stop(TInt aReason, TBool aLinkDown)
       
    92 /**
       
    93  * Called from PPP to terminate the lower Nif.
       
    94  */
       
    95 	{
       
    96 	iUmtsNif->Stop(aReason,MNifIfNotify::EDisconnect);
       
    97 	if(aLinkDown)
       
    98 		iPppLcp->LinkLayerDown(aReason);
       
    99 	}
       
   100 
       
   101 TInt CPppUmtsLink::SpeedMetric()
       
   102 	{
       
   103 	TPckgBuf<TSoIfInfo> info_buf;
       
   104 	TInt err = iUmtsNif->Control(KSOLInterface, KSoIfInfo, info_buf);
       
   105 	if (err != KErrNone)
       
   106 		return err;	// No IPv4 support (no change)
       
   107 	else
       
   108 		{
       
   109 		const TSoIfInfo &info = info_buf();
       
   110 		return info.iSpeedMetric;
       
   111 		}
       
   112 	}
       
   113 
       
   114 void CPppUmtsLink::BinderLayerDown(CNifIfBase*, TInt, TAction)
       
   115 	{ }