linklayerprotocols/pppnif/INC/PPPBASE.INL
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 //
       
    15 
       
    16 #ifndef __PPPBASE_INL__
       
    17 #define __PPPBASE_INL__
       
    18 
       
    19 #include <networking/ppplcp.h>
       
    20 
       
    21 /** @file
       
    22 @internalComponent */
       
    23 
       
    24 //
       
    25 // PPP Link Frame Checksum
       
    26 //
       
    27 
       
    28 // 16 bit CRC
       
    29 inline TPppFcs16::TPppFcs16()
       
    30 	{
       
    31 	Init();
       
    32 	}
       
    33 	
       
    34 /**
       
    35 Returns the current CRC value.
       
    36 @return CRC-16
       
    37 */	
       
    38 inline TUint16 TPppFcs16::Fcs() const
       
    39 	{
       
    40 	return (TUint16)~iFcs;
       
    41 	}
       
    42 
       
    43 /**
       
    44 Sets the CRC value to the initial state before calculation.
       
    45 */
       
    46 inline void TPppFcs16::Init()
       
    47 	{
       
    48 	iFcs = (TUint16)KPppInitFcs16;
       
    49 	}
       
    50 	
       
    51 /**
       
    52 Determines if the calculated CRC is valid.
       
    53 
       
    54 @return ETrue if the calculated CRC matches the expected value
       
    55 */
       
    56 inline TBool TPppFcs16::IsGood() const
       
    57 	{
       
    58 	return iFcs==KPppGoodFcs16;
       
    59 	}
       
    60 
       
    61 /**
       
    62 Incrementally calculates the CRC for the next message byte.
       
    63 
       
    64 @param aByte Message byte
       
    65 */
       
    66 inline void TPppFcs16::CalcByte(TUint8 aByte)
       
    67 	{
       
    68 	iFcs = (TUint16)((iFcs >> 8) ^ FcsTable[(iFcs ^ aByte) & 0xff]);
       
    69 	}
       
    70 
       
    71 
       
    72 // 32 bit CRC
       
    73 inline TPppFcs32::TPppFcs32()
       
    74 	{
       
    75 	Init();
       
    76 	}
       
    77 
       
    78 /**
       
    79 Returns the current CRC value.
       
    80 @return CRC-32
       
    81 */	
       
    82 inline TUint32 TPppFcs32::Fcs() const
       
    83 	{
       
    84 	return (TUint32)~iFcs;
       
    85 	}
       
    86 
       
    87 /**
       
    88 Sets the CRC value to the initial state before calculation.
       
    89 */
       
    90 inline void TPppFcs32::Init()
       
    91 	{
       
    92 	iFcs = (TUint32)KPppInitFcs32;
       
    93 	}
       
    94 
       
    95 /**
       
    96 Determines if the calculated CRC is valid.
       
    97 
       
    98 @return ETrue if the calculated CRC matches the expected value
       
    99 */
       
   100 inline TBool TPppFcs32::IsGood() const
       
   101 	{
       
   102 	return iFcs==KPppGoodFcs32;
       
   103 	}
       
   104 
       
   105 /**
       
   106 Incrementally calculates the CRC for the next message byte.
       
   107 
       
   108 @param aByte Message byte
       
   109 */
       
   110 inline void TPppFcs32::CalcByte(TUint8 aByte)
       
   111 	{
       
   112 	iFcs = (((iFcs) >> 8) ^ FcsTable[((iFcs) ^ aByte) & 0xff]);
       
   113 	}
       
   114 
       
   115 //
       
   116 // PPP Packet Receiver
       
   117 //
       
   118 
       
   119 inline TInt MPppRecvr::SendFrame(RMBufChain& aPacket)
       
   120 	{ return iPppLcp->PppLink()->Send(aPacket, iPppId); }
       
   121 inline void MPppRecvr::SetId(TUint aPppId)
       
   122 	{ iPppId  = aPppId; }
       
   123 inline void MPppRecvr::SetPhase(TPppPhase aPhase)
       
   124 	{ iActivePhase  = aPhase; }
       
   125 
       
   126 //
       
   127 // PPP Link Protocol Support
       
   128 //
       
   129 
       
   130 inline void CPppLinkBase::NotifyLinkUp()
       
   131 	{ iPppLcp->LinkLayerUp(); }
       
   132 inline void CPppLinkBase::NotifyLinkDown(TInt aReason)
       
   133 	{ iPppLcp->LinkLayerDown(aReason); }
       
   134 inline void CPppLinkBase::DeliverToLcp(RMBufChain& aPacket)
       
   135 	{ iPppLcp->LinkRecv(aPacket); }
       
   136 inline void CPppLinkBase::NewCompressor(const CPppCompressor* aCompressor)
       
   137 	{ 
       
   138 	  iPppCompressor = (CPppCompressor*)aCompressor;
       
   139 	}
       
   140 inline void CPppLinkBase::NewDeCompressor(const CPppDeCompressor* aDeCompressor)
       
   141 	{ 
       
   142 		iPppDecompressor = (CPppDeCompressor*)aDeCompressor; 
       
   143 	}
       
   144 
       
   145 
       
   146 //
       
   147 // PPP Options Support
       
   148 //
       
   149 
       
   150 inline RPppOption& RPppOption::Cast(RMBufChain& aChain)
       
   151 	{ return *((RPppOption*)&aChain); }
       
   152 inline const RPppOption& RPppOption::Cast(const RMBufChain& aChain)
       
   153 	{ return *((const RPppOption*)&aChain); }
       
   154 inline const RPppOption& RPppOption::operator=(const RMBufChain& aChain)
       
   155 	{ iNext = (RMBuf*)aChain.First(); return *this; }
       
   156 
       
   157 //
       
   158 // PPP FSM
       
   159 //
       
   160 
       
   161 inline TBool MPppFsm::FsmIsThisLayerOpen()
       
   162 	{ return iState==EPppFsmOpened; }
       
   163 
       
   164 #endif
       
   165