tcpiputils/networkaddressandporttranslation/src/family.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2007-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 #include "family.h"
       
    17 #include "hookdefs.h"
       
    18 #include <in_chk.h>
       
    19 
       
    20 
       
    21 class CProtocolNapt; 
       
    22  
       
    23 CProtocolFamilyNapt::CProtocolFamilyNapt()
       
    24 	{
       
    25 	__DECLARE_NAME(_S("CProtocolFamilyNapt"));
       
    26 	}
       
    27 
       
    28 CProtocolFamilyNapt::~CProtocolFamilyNapt()
       
    29 //Destructor
       
    30 	{
       
    31 	}
       
    32 
       
    33 TInt CProtocolFamilyNapt::Install()
       
    34 	{
       
    35 	return KErrNone;
       
    36 	}
       
    37 
       
    38 TInt CProtocolFamilyNapt::Remove()
       
    39 	{
       
    40 	return KErrNone;
       
    41 	}
       
    42 
       
    43 TUint CProtocolFamilyNapt::ProtocolList(TServerProtocolDesc* &aProtocolList)
       
    44 	{
       
    45 	TServerProtocolDesc *p = new (ELeave) TServerProtocolDesc[1]; // Esock catches this leave
       
    46 	CProtocolNapt::Describe(p[0]);
       
    47 	aProtocolList = p;
       
    48 	return 1;
       
    49 	}
       
    50 
       
    51 CProtocolBase* CProtocolFamilyNapt::NewProtocolL(TUint /*aSockType*/,
       
    52 												   TUint aProtocol)
       
    53 	{
       
    54 	if (aProtocol != KProtocolNAPT)
       
    55 		{
       
    56 		User::Leave(KErrNotSupported);
       
    57 		}
       
    58 	CProtocolNapt* napt = CProtocolNapt::NewL();
       
    59 
       
    60 #ifdef __DEBUG
       
    61 //this is to check memory leaks.This macro will be enables in debug build only.
       
    62 //This will macro when protocol is loaded and will be unmarked when it is unloaded.
       
    63 __UHEAP_MARK;
       
    64 #endif
       
    65 
       
    66 	return napt; 
       
    67 	}
       
    68 
       
    69 
       
    70 
       
    71 //
       
    72 // Entrypoint
       
    73 //
       
    74 #ifndef EKA2
       
    75 GLDEF_C TInt E32Dll()
       
    76 	{
       
    77 	return KErrNone;
       
    78 	}
       
    79 #endif //#ifndef EKA2
       
    80 
       
    81 // Force export of non-mangled name
       
    82 extern "C" { IMPORT_C CProtocolFamilyBase* Install(void); }
       
    83 EXPORT_C CProtocolFamilyBase* Install(void)
       
    84 	{
       
    85 	CProtocolFamilyNapt* protocol = new CProtocolFamilyNapt();
       
    86 	if (protocol)
       
    87 		{
       
    88 		return protocol;
       
    89 		}
       
    90 	else 
       
    91 		{
       
    92 		return NULL;
       
    93 		}
       
    94 	}
       
    95