hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CProtocolUDP.cpp
branchRCL_3
changeset 4 73ff0d268e1d
parent 0 a03f92240627
equal deleted inserted replaced
1:28c1bd28d474 4:73ff0d268e1d
   130     {
   130     {
   131     DEBUG_PRINT( DEBUG_STRING(
   131     DEBUG_PRINT( DEBUG_STRING(
   132         "CProtocolUDP::WriteFrameL(), peer port=%d, original port=%d" ),
   132         "CProtocolUDP::WriteFrameL(), peer port=%d, original port=%d" ),
   133         aPeerPort, aOriginalPort );
   133         aPeerPort, aOriginalPort );
   134 
   134 
   135     aSocketWriter.WriteL( KUDPPrefix );
   135     TInt bufSize = 0;
       
   136     bufSize += KUDPPrefix().Length();
       
   137     bufSize += KHexDecimalLength;
       
   138     bufSize += KPortSuffix().Length();
       
   139     bufSize += KHexDecimalLength;
       
   140     bufSize += KLengthSuffix().Length();
       
   141     bufSize += aData.Length();
       
   142     bufSize += KDataSuffix().Length();
       
   143     bufSize += KMessageSuffix().Length();
       
   144     
       
   145     TBuf8<KHexDecimalLength> hexbuf;
       
   146     HBufC8* buf = HBufC8::NewLC( bufSize );
       
   147     TPtr8 ptr( buf->Des() );
       
   148     
       
   149     // Append UDP prefix
       
   150     ptr.Append( KUDPPrefix );
   136 
   151 
   137     TBuf8<KHexDecimalLength> portBuf;
   152     // Append peer port
   138     portBuf.Format( KHexFormat, aPeerPort );
   153     hexbuf.Format( KHexFormat, aPeerPort );
   139     aSocketWriter.WriteL( portBuf );
   154     ptr.Append( hexbuf );
   140     aSocketWriter.WriteL( KPortSuffix );
   155     ptr.Append( KPortSuffix );
   141 
   156 
   142     TBuf8<KHexDecimalLength> lengthBuf;
   157     // Append data length
   143     lengthBuf.Format( KHexFormat, aData.Length() );
   158     hexbuf.Format( KHexFormat, aData.Length() );
   144     aSocketWriter.WriteL( lengthBuf );
   159     ptr.Append( hexbuf );
       
   160     ptr.Append( KLengthSuffix );
   145 
   161 
   146     aSocketWriter.WriteL( KLengthSuffix );
   162     // Append data
   147     aSocketWriter.WriteL( aData );
   163     ptr.Append( aData );
   148     aSocketWriter.WriteL( KDataSuffix );
   164     ptr.Append( KDataSuffix );
       
   165     ptr.Append( KMessageSuffix );
       
   166     
       
   167     // Write to socket
       
   168     aSocketWriter.WriteL( *buf );
   149 
   169 
   150     aSocketWriter.WriteL( KMessageSuffix );
   170     CleanupStack::PopAndDestroy( buf );
   151     }
   171     }
   152 
   172 
   153 // -----------------------------------------------------------------------------
   173 // -----------------------------------------------------------------------------
   154 // CProtocolUDP::HandleReceivedDataL
   174 // CProtocolUDP::HandleReceivedDataL
   155 // -----------------------------------------------------------------------------
   175 // -----------------------------------------------------------------------------