networksecurity/ipsec/ipseccrypto/src/ipseccrypto.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2004-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 <e32std.h>
       
    17 #include <es_prot_internal.h>
       
    18 #include "ipseccrypto.h"
       
    19 
       
    20 //
       
    21 // Local declarations, not needed by anyone else but this module
       
    22 //
       
    23 
       
    24 class CProtocolFamilyCryptoEay : public CProtocolFamilyBase
       
    25 	{
       
    26     public:
       
    27         CProtocolFamilyCryptoEay();
       
    28         ~CProtocolFamilyCryptoEay();
       
    29     public: 
       
    30         TInt Install();
       
    31         TInt Remove();
       
    32         CProtocolBase *NewProtocolL(TUint aSockType, TUint aProtocol);
       
    33         TUint ProtocolList(TServerProtocolDesc *& aProtocolList);
       
    34 	};
       
    35 
       
    36 // Force export of non-mangled name
       
    37 extern "C" { IMPORT_C CProtocolFamilyBase *Install(); }
       
    38 EXPORT_C CProtocolFamilyBase *Install()
       
    39 	{
       
    40     return new CProtocolFamilyCryptoEay;
       
    41 	}
       
    42 
       
    43 //
       
    44 // Protocol Stub
       
    45 //
       
    46 
       
    47 CProtocolEay::CProtocolEay()
       
    48 	{
       
    49     __DECLARE_NAME(_S("CProtocolIpsecCrypto"));
       
    50 	}
       
    51 
       
    52 //
       
    53 // This FillinInfo is total guesswork (as this is not a "real"
       
    54 // protocol, most (all?) of these are totally useless. The
       
    55 // key is to choose neutral values that won't cause the
       
    56 // socket manager to assume any special functionality of this
       
    57 // protocol.
       
    58 //
       
    59 // (declared as "pure" static to avoid cluttering the
       
    60 // CProtocolEay with unnecessary methods)
       
    61 //
       
    62 static void FillinInfo(TServerProtocolDesc &anEntry)
       
    63 	{
       
    64     anEntry.iName=_S("ipseccrypto");
       
    65     anEntry.iAddrFamily=KAfCrypto;
       
    66     anEntry.iSockType=KSockRaw;
       
    67     anEntry.iProtocol=KProtocolCrypto;
       
    68     anEntry.iVersion=TVersion(1, 0, 0);
       
    69     anEntry.iByteOrder=ELittleEndian;
       
    70     anEntry.iServiceInfo=KSIStreamBased;
       
    71     anEntry.iNamingServices = 0;
       
    72     anEntry.iSecurity=KSocketNoSecurity;
       
    73     anEntry.iMessageSize = KSocketMessageSizeIsStream;
       
    74     anEntry.iServiceTypeInfo=ENeedMBufs;
       
    75     anEntry.iNumSockets=KUnlimitedSockets;
       
    76 	}
       
    77 
       
    78 void CProtocolEay::Identify(TServerProtocolDesc *aInfo) const
       
    79 	{
       
    80     FillinInfo(*aInfo);
       
    81 	}
       
    82 
       
    83 
       
    84 //
       
    85 // Protocol Family Stub
       
    86 //
       
    87 
       
    88 CProtocolFamilyCryptoEay::CProtocolFamilyCryptoEay()
       
    89 	{
       
    90     __DECLARE_NAME(_S("CProtocolFamilyCryptoIpsecCrypto"));
       
    91 	}
       
    92 
       
    93 
       
    94 CProtocolFamilyCryptoEay::~CProtocolFamilyCryptoEay()
       
    95 	{
       
    96 	}
       
    97 
       
    98 
       
    99 TInt CProtocolFamilyCryptoEay::Install()
       
   100 	{
       
   101     return KErrNone;
       
   102 	}
       
   103 
       
   104 
       
   105 TInt CProtocolFamilyCryptoEay::Remove()
       
   106 	{
       
   107     return KErrNone;
       
   108 	}
       
   109 
       
   110 
       
   111 TUint CProtocolFamilyCryptoEay::ProtocolList(TServerProtocolDesc *& aProtocolList)
       
   112 	{
       
   113     // This function should be a leaving fn
       
   114     // apparently it is OK for it to leave
       
   115     TServerProtocolDesc *p = new (ELeave) TServerProtocolDesc[1];
       
   116 
       
   117     FillinInfo(p[0]);
       
   118     // There should be no need for this below...
       
   119     // TRAPD(res, Nif::CheckInstalledMBufManagerL();)
       
   120     aProtocolList = p;
       
   121     return 1;
       
   122 	}
       
   123 
       
   124 
       
   125 CProtocolBase* CProtocolFamilyCryptoEay::NewProtocolL(TUint /*aSockType*/, TUint aProtocol)
       
   126 	{
       
   127     CProtocolBase *inprt = NULL;
       
   128     if (aProtocol == KProtocolCrypto)
       
   129         inprt = new (ELeave) CProtocolEay;
       
   130     return inprt;
       
   131 	}
       
   132