usbmgmt/usbmgr/device/classdrivers/ncm/classimplementation/ncmpktdrv/pktdrv/src/ncmcommunicationinterface.cpp
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
equal deleted inserted replaced
15:f92a4f87e424 16:012cc2ee6408
     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 * implementation of NCM communication interface class 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <es_sock.h>
       
    21 #include "ncmcommunicationinterface.h"
       
    22 #include "ncmnotificationdescriptor.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "ncmcommunicationinterfaceTraces.h"
       
    26 #endif
       
    27 
       
    28 
       
    29 
       
    30 const TUint KUsbRequestLengthIdx = 6;
       
    31 const TUint KUsbRequestTypeIdx = 1;
       
    32 const TInt  KIntEndpoint = 1;
       
    33 const TInt  KNotificationRequestType = 0xA1;
       
    34 
       
    35 
       
    36 #if defined(_DEBUG)
       
    37 _LIT(KNcmCommInterfacePanic, "UsbNcmComm"); // must be <=16 chars
       
    38 #endif
       
    39 
       
    40 
       
    41 // Panic codes
       
    42 enum TNcmCommPanicCode
       
    43     {
       
    44     ENcmCommWrongSetupLength = 1,
       
    45     ENcmCommWrongDataLength,
       
    46     ENcmCommWriteError,
       
    47     ENcmCMEndMark
       
    48     };
       
    49 
       
    50 
       
    51 // ======== MEMBER FUNCTIONS ========
       
    52 //
       
    53 
       
    54 CNcmCommunicationInterface::CNcmCommunicationInterface(MNcmControlObserver& aEngine, RDevUsbcScClient& aLdd) : CActive(CActive::EPriorityHigh),
       
    55                             iEngine(aEngine), iPort(aLdd)
       
    56     {
       
    57     CActiveScheduler::Add(this);
       
    58     }
       
    59 
       
    60 void CNcmCommunicationInterface::ConstructL()
       
    61     {
       
    62     iSenderAndReceiver = CNcmCommInterfaceSenderAndReceiver::NewL(iPort, *this);
       
    63     }
       
    64 
       
    65 CNcmCommunicationInterface* CNcmCommunicationInterface::NewL(MNcmControlObserver& aEngine, RDevUsbcScClient& aLdd)
       
    66     {
       
    67     OstTraceFunctionEntry0( CNCMCOMMUNICATIONINTERFACE_NEWL_ENTRY );
       
    68     CNcmCommunicationInterface *self=new (ELeave) CNcmCommunicationInterface(aEngine, aLdd);
       
    69     CleanupStack::PushL(self);
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop();
       
    72     OstTraceFunctionExit0( CNCMCOMMUNICATIONINTERFACE_NEWL_EXIT );
       
    73     return self;
       
    74     }
       
    75 
       
    76 CNcmCommunicationInterface::~CNcmCommunicationInterface()
       
    77     {
       
    78     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_CNCMCOMMUNICATIONINTERFACE_ENTRY, this );
       
    79     
       
    80     Cancel();
       
    81     delete iSenderAndReceiver;
       
    82     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_CNCMCOMMUNICATIONINTERFACE_EXIT, this );
       
    83     }
       
    84 
       
    85 //
       
    86 //Start the control channel of NCM
       
    87 //
       
    88 TInt CNcmCommunicationInterface::Start()
       
    89     {
       
    90     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_START_ENTRY, this );
       
    91     if (iStarted)
       
    92         {
       
    93         OstTrace0( TRACE_WARNING, CNCMCOMMUNICATIONINTERFACE_START, "CNcmCommunicationInterface, already started!" );        
       
    94         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_START_EXIT, this );
       
    95         return KErrInUse;
       
    96         }
       
    97 
       
    98     TInt ret = GetInterfaceNumber();
       
    99     if (ret != KErrNone)
       
   100         {        
       
   101         OstTrace1( TRACE_FATAL, CNCMCOMMUNICATIONINTERFACE_START1, "GetInterfaceNumber failed ret=%d", ret);
       
   102         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_START_EXIT_DUP1, this );
       
   103         return ret;
       
   104         }
       
   105     
       
   106     iStarted = ETrue;
       
   107     iRWState = EStateInitial;
       
   108 
       
   109     iSenderAndReceiver->Start();
       
   110 
       
   111     //force a call to RunL
       
   112     SetActive();
       
   113     TRequestStatus* status=&iStatus;
       
   114     User::RequestComplete(status, KErrNone);
       
   115     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_START_EXIT_DUP2, this );
       
   116     return KErrNone;
       
   117     }
       
   118 
       
   119 //
       
   120 //Listen on the ep0 to receive the NCM control message from host
       
   121 //
       
   122 void CNcmCommunicationInterface::ReadSetup()
       
   123     {
       
   124     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_READSETUP_ENTRY, this );
       
   125     iRWState = EStateReadSetup;
       
   126     iRequestType = 0;
       
   127     iDataStageLength = 0;
       
   128     TInt ret = iSenderAndReceiver->Read(iStatus, iSetupPacket, KSetupPacketLength);
       
   129 
       
   130     if (ret != KErrNone)
       
   131         {
       
   132         OstTrace1( TRACE_FATAL, CNCMCOMMUNICATIONINTERFACE_READSETUP, "read setup packet error %d", ret);        
       
   133         ControlMsgError(EInternalError);
       
   134         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_READSETUP_EXIT, this );
       
   135         return;
       
   136         }
       
   137     SetActive();
       
   138     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_READSETUP_EXIT_DUP1, this );
       
   139     }
       
   140 
       
   141 
       
   142 //
       
   143 //decode the setup packet to get command information.
       
   144 //
       
   145 void CNcmCommunicationInterface::DecodeSetup()
       
   146     {
       
   147     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_DECODESETUP_ENTRY, this );
       
   148     
       
   149     __ASSERT_DEBUG(iSetupPacket.Length()==KSetupPacketLength, 
       
   150         User::Panic(KNcmCommInterfacePanic, ENcmCommWrongSetupLength));
       
   151 		
       
   152     iRequestType = iSetupPacket[KUsbRequestTypeIdx];
       
   153     iDataStageLength = LittleEndian::Get16(&iSetupPacket[KUsbRequestLengthIdx]);
       
   154 	
       
   155     switch (iRequestType)
       
   156         {
       
   157         case EGetNtbParameters:	
       
   158             if (iDataStageLength != KNtbParamStructLength)
       
   159                 {
       
   160                 ControlMsgError(EInvalidLengthToRead);
       
   161                 break;
       
   162                 }
       
   163             iEngine.HandleGetNtbParam(iDataBuffer);
       
   164             __ASSERT_DEBUG(iDataBuffer.Length()==KNtbParamStructLength, 
       
   165                 User::Panic(KNcmCommInterfacePanic, ENcmCommWrongDataLength));			
       
   166             WriteDataIn();
       
   167             break;
       
   168           
       
   169         case EGetNtbInputSize:
       
   170             if (iDataStageLength != KNtbInputSizeStructLength)
       
   171                 {
       
   172                 ControlMsgError(EInvalidLengthToRead);
       
   173                 break;
       
   174                 }			
       
   175             iEngine.HandleGetNtbInputSize(iDataBuffer);
       
   176             __ASSERT_DEBUG(iDataBuffer.Length()==KNtbInputSizeStructLength, 
       
   177                 User::Panic(KNcmCommInterfacePanic, ENcmCommWrongDataLength));						
       
   178             WriteDataIn();
       
   179             break;
       
   180 			
       
   181         case ESetNtbInputSize:
       
   182             if (iDataStageLength != KNtbInputSizeStructLength)
       
   183                 {
       
   184                 ControlMsgError(EInvalidLengthToRead);
       
   185                 break;
       
   186                 }		
       
   187             ReadDataOut();
       
   188             break;
       
   189         default:
       
   190             TInt ret = iPort.EndpointZeroRequestError();
       
   191             OstTrace1( TRACE_ERROR, CNCMCOMMUNICATIONINTERFACE_DECODESETUP, "unsupport request, halt endpoint with EndpointZeroRequestError %d", ret);
       
   192             ReadSetup();
       
   193             break;
       
   194         }
       
   195     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_DECODESETUP_EXIT, this );
       
   196     }
       
   197 
       
   198 
       
   199 
       
   200 //
       
   201 //Read the raw data of a control request message from host
       
   202 //
       
   203 void CNcmCommunicationInterface::ReadDataOut()
       
   204     {
       
   205     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_READDATAOUT_ENTRY, this );
       
   206     iRWState = EStateReadDataout;
       
   207     iSenderAndReceiver->Read(iStatus, iDataBuffer, iDataStageLength);
       
   208     SetActive();
       
   209     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_READDATAOUT_EXIT, this );
       
   210     }
       
   211 
       
   212 
       
   213 
       
   214 
       
   215 //
       
   216 //Parse the data out from host to specific NCM control message
       
   217 //
       
   218 void CNcmCommunicationInterface::ParseDataOut()
       
   219     {
       
   220     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_PARSEDATAOUT_ENTRY, this );
       
   221 
       
   222     __ASSERT_DEBUG(iDataBuffer.Length()>0, 
       
   223         User::Panic(KNcmCommInterfacePanic, ENcmCommWrongDataLength));			
       
   224 
       
   225     TInt ret = KErrNone;
       
   226     switch (iRequestType)
       
   227         {
       
   228         case ESetNtbInputSize:
       
   229             ret = iEngine.HandleSetNtbInputSize(iDataBuffer);    
       
   230             break;
       
   231         default:
       
   232             ret = KErrNotSupported;
       
   233             break;
       
   234         }
       
   235     
       
   236     if (ret == KErrNone)
       
   237         {
       
   238         iPort.SendEp0StatusPacket();
       
   239         }
       
   240     else
       
   241         {
       
   242         OstTrace1( TRACE_WARNING, CNCMCOMMUNICATIONINTERFACE_PARSEDATAOUT, "handle request iRequestType error %d stall endpoint", ret);
       
   243         iPort.EndpointZeroRequestError();
       
   244         }
       
   245     ReadSetup();
       
   246     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_PARSEDATAOUT_EXIT, this );
       
   247     }
       
   248     
       
   249 //
       
   250 // send connection status notification, aConnected = ETrue if connection up, otherwise EFalse if connection discnnected
       
   251 //
       
   252 TInt CNcmCommunicationInterface::SendConnectionNotification(TBool aConnected)
       
   253     {
       
   254     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_SENDCONNECTIONNOTIFICATION_ENTRY, this );
       
   255     const TUint8 KConnectionNotificationCode = 0x00;
       
   256     const TUint16 KConnectedCode = 0x0001;
       
   257     const TUint16 KDisconnectCode = 0x0000;    
       
   258 
       
   259     TUSBNotificationNetworkConnection netNotify;
       
   260     netNotify.iRequestType = KNotificationRequestType;
       
   261     netNotify.iNotification = KConnectionNotificationCode;
       
   262     netNotify.iValue = (aConnected)?KConnectedCode:KDisconnectCode; 
       
   263     netNotify.iIndex = iInterfaceNumber;
       
   264     netNotify.iLength = 0;
       
   265 
       
   266     return WriteInterruptData(KIntEndpoint, netNotify.Des(), 
       
   267         netNotify.Des().Length());            
       
   268     }
       
   269 
       
   270 //
       
   271 // send speed notification
       
   272 //
       
   273 TInt CNcmCommunicationInterface::SendSpeedNotification(TInt aUSBitRate, TInt aDSBitRate)
       
   274     {
       
   275     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_SENDSPEEDNOTIFICATION_ENTRY, this );
       
   276     const TUint8 KSpeedNotificationCode = 0x2A;
       
   277         
       
   278     TUSBNotificationConnectionSpeedChange speedNotify;
       
   279     speedNotify.iRequestType = KNotificationRequestType;
       
   280     speedNotify.iNotification = KSpeedNotificationCode;
       
   281     speedNotify.iValue = 0x00; 
       
   282     speedNotify.iIndex = iInterfaceNumber;
       
   283     speedNotify.iLength = 0x08;
       
   284     speedNotify.iUSBitRate = aUSBitRate;
       
   285     speedNotify.iDSBitRate = aDSBitRate;
       
   286 
       
   287     return WriteInterruptData(KIntEndpoint, speedNotify.Des(), 
       
   288         speedNotify.Des().Length());    
       
   289     }
       
   290 
       
   291 
       
   292 //
       
   293 //According to the receving request message, send back a response to the host
       
   294 //
       
   295 void CNcmCommunicationInterface::WriteDataIn()
       
   296     {
       
   297     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_WRITEDATAIN_ENTRY, this );
       
   298 
       
   299     iRWState = EStateWriteDatain;
       
   300     TInt ret = iSenderAndReceiver->Write(iStatus, iDataBuffer, iDataBuffer.Length());
       
   301     __ASSERT_DEBUG(ret==KErrNone, User::Panic(KNcmCommInterfacePanic, ENcmCommWriteError));		
       
   302     SetActive();
       
   303     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEDATAIN_EXIT, this );
       
   304     }
       
   305 
       
   306 //
       
   307 //Cancel the outgoing request
       
   308 //
       
   309 void CNcmCommunicationInterface::DoCancel()
       
   310     {
       
   311     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_DOCANCEL_ENTRY, this );
       
   312     TRequestStatus* status = &iStatus;    
       
   313     User::RequestComplete(status, KErrCancel); 
       
   314     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_DOCANCEL_EXIT, this );
       
   315     }
       
   316 
       
   317 //
       
   318 //Stop the control channel to stop the NCM
       
   319 //
       
   320 void CNcmCommunicationInterface::Stop()
       
   321     {
       
   322     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_STOP_ENTRY, this );
       
   323     iStarted = EFalse;
       
   324     iSenderAndReceiver->Stop();
       
   325     Cancel();
       
   326     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_STOP_EXIT, this );
       
   327     }
       
   328 
       
   329 //
       
   330 //AO RunL
       
   331 //
       
   332 void CNcmCommunicationInterface::RunL()
       
   333     {
       
   334     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_RUNL_ENTRY, this );
       
   335     if(iStatus.Int() != KErrNone)
       
   336         {
       
   337         if (KErrCancel == iStatus.Int() )
       
   338             {
       
   339             }
       
   340         else
       
   341             {
       
   342             ControlMsgError(EInternalError);
       
   343             }
       
   344         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_RUNL_EXIT, this );
       
   345         return;
       
   346         }
       
   347 
       
   348     switch(iRWState)
       
   349         {
       
   350         case EStateInitial:
       
   351             {
       
   352             ReadSetup();
       
   353             break;
       
   354             }
       
   355             
       
   356         case EStateReadSetup:
       
   357             {
       
   358             DecodeSetup();
       
   359             break;
       
   360             }
       
   361             
       
   362         case EStateReadDataout:
       
   363             {
       
   364             ParseDataOut();
       
   365             break;
       
   366             }
       
   367 
       
   368         case EStateWriteDatain:
       
   369             {
       
   370             ReadSetup();
       
   371             break;
       
   372             }    
       
   373         }
       
   374     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_RUNL_EXIT_DUP1, this );
       
   375     }
       
   376 
       
   377   
       
   378 //
       
   379 //Any fatal error occurs when reading/sending a NCM control message via USB interface
       
   380 //
       
   381 void CNcmCommunicationInterface::ControlMsgError(TNcmCommErrorCode aCode)
       
   382     {
       
   383     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_CONTROLMSGERROR_ENTRY, this );
       
   384     OstTrace1( TRACE_NORMAL, CNCMCOMMUNICATIONINTERFACE_CONTROLMSGERROR, "CNcmCommunicationInterface, Handle Ncm Control Message with err=%d", aCode);
       
   385     
       
   386     // Stall bus, there's nothing else we can do 
       
   387     iPort.EndpointZeroRequestError();  
       
   388     iEngine.ControlError(aCode);
       
   389     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_CONTROLMSGERROR_EXIT, this );
       
   390     }
       
   391 
       
   392 
       
   393 TInt CNcmCommunicationInterface::WriteInterruptData(TInt aEndPoint, 
       
   394                                TDesC8& aDes, 
       
   395                                TInt aLength)
       
   396 
       
   397     {
       
   398     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_ENTRY, this );
       
   399 
       
   400     TInt ret;
       
   401     RTimer timer;
       
   402     ret = timer.CreateLocal();
       
   403     if ( ret )
       
   404         {
       
   405         OstTrace1( TRACE_FATAL, CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA, "\ttimer.CreateLocal = %d- returning", ret);        
       
   406         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT, this );
       
   407         return ret;
       
   408         }
       
   409     TRequestStatus status;
       
   410     TRequestStatus timerStatus;
       
   411 
       
   412     TEndpointBuffer epBuffer;
       
   413     ret = iPort.OpenEndpoint(epBuffer, aEndPoint);
       
   414     if (ret != KErrNone)
       
   415         {
       
   416         timer.Close();
       
   417         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP1, this );
       
   418         return ret;
       
   419         }
       
   420 
       
   421     TAny *buf;
       
   422     TUint size;
       
   423     ret = epBuffer.GetInBufferRange(buf, size);
       
   424     if (ret != KErrNone)
       
   425         {        
       
   426         timer.Close();
       
   427         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP2, this );
       
   428         return ret;
       
   429         }
       
   430     else if (size < aLength)
       
   431         {
       
   432         timer.Close();
       
   433         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP3, this );
       
   434         return KErrArgument;
       
   435         }
       
   436     
       
   437     TPtr8 writeBuf((TUint8 *)buf, size);
       
   438     writeBuf.Copy(aDes.Ptr(), aLength);
       
   439     ret = epBuffer.WriteBuffer(buf, writeBuf.Size(), ETrue, status);
       
   440     if (ret != KErrNone)
       
   441         {
       
   442         timer.Close();
       
   443         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP4, this );
       
   444         return ret;
       
   445         }
       
   446 
       
   447     const TInt KWriteDataTimeout = 1000000;
       
   448     timer.After(timerStatus, KWriteDataTimeout);
       
   449     User::WaitForRequest(status, timerStatus);
       
   450     if ( timerStatus != KRequestPending )
       
   451         {
       
   452         // Timeout occurred, silently ignore error condition.
       
   453         // Assuming that the line has been disconnected
       
   454         OstTrace0( TRACE_ERROR, CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA1, "CNcmCommunicationInterface::WriteInterruptData() - Timeout occurred");
       
   455         iPort.WriteCancel(epBuffer.BufferNumber());
       
   456         User::WaitForRequest(status);
       
   457         ret = timerStatus.Int();
       
   458         }
       
   459     else
       
   460         {
       
   461         OstTrace0( TRACE_ERROR, CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA2, "CNcmCommunicationInterface::WriteInterruptData() - Write completed");
       
   462         timer.Cancel();
       
   463         User::WaitForRequest(timerStatus);
       
   464         ret = status.Int();
       
   465         }
       
   466     
       
   467     epBuffer.Close();
       
   468     timer.Close();
       
   469     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_WRITEINTERRUPTDATA_EXIT_DUP5, this );
       
   470     return ret;
       
   471     }
       
   472 
       
   473 
       
   474 //
       
   475 // Get interface number
       
   476 //
       
   477 TInt CNcmCommunicationInterface::GetInterfaceNumber()
       
   478     {
       
   479     OstTraceFunctionEntry1( CNCMCOMMUNICATIONINTERFACE_GETINTERFACENUMBER_ENTRY, this );
       
   480 
       
   481     TInt interfaceSize = 0;
       
   482     // 2 is where the interface number is, according to the LDD API
       
   483     const TInt intNumOffsetInDes = 2;
       
   484 
       
   485     // 0 means the main interface in the LDD API
       
   486     TInt res = iPort.GetInterfaceDescriptorSize(0, interfaceSize);
       
   487 
       
   488     if ( res )
       
   489         {
       
   490         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_GETINTERFACENUMBER_EXIT, this );
       
   491         return res;
       
   492         }
       
   493 
       
   494     HBufC8* interfaceBuf = HBufC8::New(interfaceSize);
       
   495     if ( !interfaceBuf )
       
   496         {
       
   497         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_GETINTERFACENUMBER_EXIT_DUP1, this );
       
   498         return KErrNoMemory;
       
   499         }
       
   500 
       
   501     TPtr8 interfacePtr = interfaceBuf->Des();
       
   502     interfacePtr.SetLength(0);
       
   503     // 0 means the main interface in the LDD API
       
   504     res = iPort.GetInterfaceDescriptor(0, interfacePtr); 
       
   505 
       
   506     if ( res )
       
   507         {
       
   508         delete interfaceBuf;
       
   509         OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_GETINTERFACENUMBER_EXIT_DUP2, this );
       
   510         return res;
       
   511         }
       
   512 
       
   513     const TUint8* buffer = reinterpret_cast<const TUint8*>(interfacePtr.Ptr());
       
   514     iInterfaceNumber = buffer[intNumOffsetInDes]; 
       
   515 
       
   516     delete interfaceBuf;
       
   517     OstTraceFunctionExit1( CNCMCOMMUNICATIONINTERFACE_GETINTERFACENUMBER_EXIT_DUP3, this );
       
   518     return KErrNone;
       
   519     }
       
   520 
       
   521 
       
   522