tcpiputils/tun/src/tunfamily.cpp
branchRCL_3
changeset 63 425d8f4f7fa5
equal deleted inserted replaced
58:8d540f55e491 63:425d8f4f7fa5
       
     1 // Copyright (c) 2010 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 #include "tunfamily.h"
       
    17 #include "tun.h"
       
    18 #include <in_chk.h>
       
    19 #include <es_prot.h>
       
    20 
       
    21 
       
    22 CProtocolFamilyTun::CProtocolFamilyTun()
       
    23     {
       
    24     __DECLARE_NAME(_S("CProtocolFamilyTun"));
       
    25     }
       
    26 
       
    27 CProtocolFamilyTun::~CProtocolFamilyTun()
       
    28 //Destructor
       
    29     {}
       
    30 
       
    31 TInt CProtocolFamilyTun::Install()
       
    32     {
       
    33     return KErrNone;
       
    34     }
       
    35 
       
    36 TInt CProtocolFamilyTun::Remove()
       
    37     {
       
    38     return KErrNone;
       
    39     }
       
    40 
       
    41 TUint CProtocolFamilyTun::ProtocolList(TServerProtocolDesc* &aProtocolList)
       
    42     {
       
    43     const TInt KArraySize = 1;
       
    44     // Esock catches this leave; hence TRAP is not needed
       
    45     TServerProtocolDesc *p = new (ELeave) TServerProtocolDesc[KArraySize]; 
       
    46     CProtocolTun::Identify(p[KArraySize-1]);
       
    47     aProtocolList = p;
       
    48     return 1;
       
    49     }
       
    50 
       
    51 CProtocolBase* CProtocolFamilyTun::NewProtocolL(TUint /*aSockType*/,
       
    52                                                    TUint aProtocol)
       
    53     {
       
    54     if (aProtocol != KProtocolTUN)
       
    55         {
       
    56         Panic(ETunPanic_BadBind);
       
    57         }
       
    58 
       
    59     CProtocolTun* instance = CProtocolTun::NewL(); 
       
    60     return instance;
       
    61 
       
    62     }
       
    63 
       
    64 
       
    65 
       
    66 //
       
    67 // Entrypoint
       
    68 //
       
    69 #ifndef EKA2
       
    70 GLDEF_C TInt E32Dll()
       
    71     {
       
    72     return KErrNone;
       
    73     }
       
    74 #endif //#ifndef EKA2
       
    75 
       
    76 // Force export of non-mangled name
       
    77 extern "C" { IMPORT_C CProtocolFamilyBase* Install(void); }
       
    78 EXPORT_C CProtocolFamilyBase* Install(void)
       
    79     {
       
    80     CProtocolFamilyTun* protocol = new CProtocolFamilyTun();
       
    81     if (protocol)
       
    82         {
       
    83         return protocol;
       
    84         }
       
    85     else 
       
    86         {
       
    87         return NULL;
       
    88         }
       
    89     }
       
    90