linklayerprotocols/tundriver/inc/tundriverbinder.h
branchRCL_3
changeset 63 425d8f4f7fa5
equal deleted inserted replaced
58:8d540f55e491 63:425d8f4f7fa5
       
     1 /**
       
     2 *   Copyright (c) 2010 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 Ip4 and Ip6 Binder Configuration.
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 /**
       
    21  @file tundriverbinder.h
       
    22  @internalTechnology
       
    23 */
       
    24 
       
    25 #ifndef _TUNDRIVERBINDER_H
       
    26 #define _TUNDRIVERBINDER_H
       
    27 
       
    28 #include <ip4_hdr.h>
       
    29 #include <ip6_hdr.h>
       
    30 #include <udp_hdr.h>
       
    31 #include <comms-infras/ss_protflow.h>
       
    32 #include <comms-infras/ss_flowbinders.h>
       
    33 #include <comms-infras/commsdebugutility.h>
       
    34 #include <nifmbuf.h>
       
    35 #include "es_protbinder.h"
       
    36 #include "tundriverflow.h"
       
    37 
       
    38 const TInt KMTU = 1500;
       
    39 
       
    40 const TInt KSpeedMetric = 0;
       
    41 
       
    42 const TUint KTUNDriverTos      = 192; // 0xC0; uses the UNUSED 7,8 MSB of Differentiated Services
       
    43 
       
    44 class CTunDriverSubConnectionFlow;
       
    45 
       
    46 class CTunDriverBinder : public CBase, public ESock::MLowerDataSender, public ESock::MLowerControl
       
    47 /**
       
    48 Common Binder for the tunnel driver binder. This binder will be inherited by IPv4 or IPv6 Binder classes.
       
    49 */
       
    50     {
       
    51 public:
       
    52     virtual MLowerDataSender* Bind(ESock::MUpperDataReceiver& aUpperReceiver , ESock::MUpperControl& aUpperControl);
       
    53     virtual void Unbind (ESock::MUpperDataReceiver& aUpperReceiver, ESock::MUpperControl& aUpperControl);
       
    54     virtual TBool MatchesUpperControl(ESock::MUpperControl* aUpperControl) const;
       
    55     virtual TInt Control(TUint, TUint, TDes8&);
       
    56     void SetPort(TUint aPort);
       
    57     TUint GetPort();
       
    58 protected:
       
    59     CTunDriverBinder(CTunDriverSubConnectionFlow& aTunDriverSubConnectionFlow);
       
    60 protected:
       
    61     __FLOG_DECLARATION_MEMBER;
       
    62 private:
       
    63     CTunDriverSubConnectionFlow& iTunDriverSubConnectionFlow;
       
    64     TUint iPort;
       
    65     };
       
    66 
       
    67 class CTunDriverBinder4 : public CTunDriverBinder
       
    68     {
       
    69 public:
       
    70     static CTunDriverBinder4* NewL(CTunDriverSubConnectionFlow& aLink);
       
    71     ~CTunDriverBinder4();
       
    72     // from MLowerDataSender
       
    73     virtual TInt GetName(TDes& aName);
       
    74     virtual TInt GetConfig(TBinderConfig& aConfig);
       
    75     MLowerDataSender* Bind(ESock::MUpperDataReceiver& aUpperReceiver , ESock::MUpperControl& aUpperControl);
       
    76     void Unbind (ESock::MUpperDataReceiver& aUpperReceiver, ESock::MUpperControl& aUpperControl);
       
    77     TBool MatchesUpperControl(ESock::MUpperControl* aUpperControl) const;
       
    78     ESock::MLowerDataSender::TSendResult Send(RMBufChain& aData);
       
    79     void StartSending();
       
    80 private:
       
    81     CTunDriverBinder4(CTunDriverSubConnectionFlow& aLink);
       
    82     void ConstructL();
       
    83     void TunnelProcessing(RMBufPacket& aPacket, RMBufPacket& aRecv);
       
    84     inline CTunDriverSubConnectionFlow* Flow();
       
    85     virtual void DoSend();
       
    86     virtual void DoProcess();
       
    87     static TInt RecvCallBack(TAny* aCProtocol);
       
    88     static TInt SendCallBack(TAny* aCProtocol);
       
    89 private:
       
    90     TInetAddr iLocalAddress;
       
    91     CTunDriverSubConnectionFlow& iTunDriverSubConnectionFlow;
       
    92     ESock::MUpperDataReceiver* iUpperReceiver;
       
    93     ESock::MUpperControl* iUpperControl;
       
    94     RMBufPktQ iSendQ;
       
    95     RMBufPktQ iRecvQ;
       
    96     CAsyncCallBack* iSendCallBack;
       
    97     CAsyncCallBack* iRecvCallBack;
       
    98     };
       
    99 
       
   100 CTunDriverSubConnectionFlow* CTunDriverBinder4::Flow()
       
   101     {
       
   102     return &iTunDriverSubConnectionFlow;
       
   103     }
       
   104 
       
   105 #ifdef IPV6SUPPORT
       
   106 class CTunDriverBinder6 : public CTunDriverBinder
       
   107     {
       
   108 public:
       
   109     static CTunDriverBinder6* NewL(CTunDriverSubConnectionFlow& aLink);
       
   110     ~CTunDriverBinder6();
       
   111     // from MLowerDataSender
       
   112     virtual TInt GetName(TDes& aName);
       
   113     virtual TInt GetConfig(TBinderConfig& aConfig);
       
   114     MLowerDataSender* Bind(ESock::MUpperDataReceiver& aUpperReceiver , ESock::MUpperControl& aUpperControl);
       
   115     void Unbind (ESock::MUpperDataReceiver& aUpperReceiver, ESock::MUpperControl& aUpperControl);
       
   116     TBool MatchesUpperControl(ESock::MUpperControl* aUpperControl) const;
       
   117     ESock::MLowerDataSender::TSendResult Send(RMBufChain& aData);
       
   118     void StartSending();
       
   119 private:
       
   120     CTunDriverBinder6(CTunDriverSubConnectionFlow& aLink);
       
   121     void ConstructL();
       
   122     void TunnelProcessing(RMBufPacket& aPacket, RMBufPacket& aRecv);
       
   123     inline CTunDriverSubConnectionFlow* Flow();
       
   124     virtual void DoSend();
       
   125     virtual void DoProcess();
       
   126     static TInt RecvCallBack(TAny* aCProtocol);
       
   127     static TInt SendCallBack(TAny* aCProtocol);
       
   128 private:
       
   129     TInetAddr iLocalAddress;
       
   130     CTunDriverSubConnectionFlow& iTunDriverSubConnectionFlow;
       
   131     ESock::MUpperDataReceiver* iUpperReceiver;
       
   132     ESock::MUpperControl* iUpperControl;
       
   133     RMBufPktQ iSendQ;
       
   134     RMBufPktQ iRecvQ;
       
   135     CAsyncCallBack* iSendCallBack;
       
   136     CAsyncCallBack* iRecvCallBack;
       
   137     };
       
   138 #endif 
       
   139 #endif // _TUNDRIVERBINDER_H