telephonyprotocols/qosextnapi/src/sblpextn.cpp
branchRCL_3
changeset 19 630d2f34d719
parent 17 1ac40e087278
child 20 07a122eea281
equal deleted inserted replaced
18:17af172ffa5f 19:630d2f34d719
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // sblpapi.cpp - SBLP QoS API
    14 // sblpapi.cpp - SBLP QoS API
    15 //
    15 //
    16 
    16 
       
    17 
       
    18 #include "OstTraceDefinitions.h"
       
    19 #ifdef OST_TRACE_COMPILER_IN_USE
       
    20 #include "sblpextnTraces.h"
       
    21 #endif
       
    22 
    17 #include "sblpextn.h"
    23 #include "sblpextn.h"
    18 #include "qosextn_constants.h"
    24 #include "qosextn_constants.h"
    19 #include "qosextn_log.h"
       
    20 #include <networking/qosparameters.h>
    25 #include <networking/qosparameters.h>
    21 
    26 
    22 // Buffer size
    27 // Buffer size
    23 const TUint KSblpApiBufSize = 8192;
    28 const TUint KSblpApiBufSize = 8192;
    24 const TUint KNumberOfElementsPerFlowId = 2;
    29 const TUint KNumberOfElementsPerFlowId = 2;
    62 	iAuthorizationToken = aAuthToken;
    67 	iAuthorizationToken = aAuthToken;
    63 	}
    68 	}
    64 
    69 
    65 EXPORT_C CSblpParameters::TFlowIdentifier& CSblpParameters::GetFlowId(TInt aIndex)
    70 EXPORT_C CSblpParameters::TFlowIdentifier& CSblpParameters::GetFlowId(TInt aIndex)
    66 	{
    71 	{
    67 	__ASSERT_DEBUG(aIndex<iFlowIds.Count(),User::Panic(_L("Sblp"),KErrArgument));
    72 	__ASSERT_DEBUG(aIndex<iFlowIds.Count(),User::Panic(_L("CSblpParameters::GetFlowId"),KErrArgument));
    68 	return iFlowIds[aIndex];
    73 	return iFlowIds[aIndex];
    69 	}
    74 	}
    70 
    75 
    71 EXPORT_C void CSblpParameters::SetFlowIds(const RArray<TFlowIdentifier> &aFlowIds)
    76 EXPORT_C void CSblpParameters::SetFlowIds(const RArray<TFlowIdentifier> &aFlowIds)
    72 	{
    77 	{
    76 	for(i=0; i<aFlowIds.Count();i++)
    81 	for(i=0; i<aFlowIds.Count();i++)
    77 		{
    82 		{
    78 		TInt errorCode = this->iFlowIds.Append(aFlowIds[i]);
    83 		TInt errorCode = this->iFlowIds.Append(aFlowIds[i]);
    79 		if (errorCode != KErrNone) 
    84 		if (errorCode != KErrNone) 
    80 		    {
    85 		    {
    81             LOG(Log::Printf(_L("CSblpParameters::SetFlowIds - Not Enough Memory!!!\n"));)
    86             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPARAMETERS_SETFLOWID, "Not Enough Memory");
    82 		    }
    87 		    }
    83 		}
    88 		}
    84 	}
    89 	}
    85 
    90 
    86 EXPORT_C TInt CSblpParameters::GetFlowIds(RArray<TFlowIdentifier>& aFlowIds)
    91 EXPORT_C TInt CSblpParameters::GetFlowIds(RArray<TFlowIdentifier>& aFlowIds)
    92 	for(i=0; i<iFlowIds.Count();i++)
    97 	for(i=0; i<iFlowIds.Count();i++)
    93 		{
    98 		{
    94         errorCode = aFlowIds.Append(this->iFlowIds[i]);
    99         errorCode = aFlowIds.Append(this->iFlowIds[i]);
    95         if (errorCode != KErrNone) 
   100         if (errorCode != KErrNone) 
    96             {
   101             {
    97             LOG(Log::Printf(_L("CSblpParameters::GetFlowIds - Not Enough Memory!!!\n"));)
   102             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPARAMETERS_GETFLOWID, "Not Enough Memory");
    98             return errorCode;
   103             return errorCode;
    99             }
   104             }
   100 		}
   105 		}
   101 	return KErrNone;
   106 	return KErrNone;
   102 	}
   107 	}
   173 	header.pfqos_configure_len = (TUint16)((byte_len + 7) / 8);
   178 	header.pfqos_configure_len = (TUint16)((byte_len + 7) / 8);
   174 	header.pfqos_ext_type = EPfqosExtExtension;
   179 	header.pfqos_ext_type = EPfqosExtExtension;
   175 	header.reserved = 0;
   180 	header.reserved = 0;
   176 	header.protocol_id = 0;
   181 	header.protocol_id = 0;
   177 	bufPtr.Append((TUint8*)&header, sizeof(pfqos_configure));
   182 	bufPtr.Append((TUint8*)&header, sizeof(pfqos_configure));
   178 
   183 	
   179 	pfqos_extension extensionType;
   184 	pfqos_extension extensionType;
   180 	extensionType.pfqos_ext_len = 0;
   185 	extensionType.pfqos_ext_len = 0;
   181 	extensionType.pfqos_ext_type = EPfqosExtExtension;
   186 	extensionType.pfqos_ext_type = EPfqosExtExtension;
   182 	extensionType.pfqos_extension_type = KPfqosExtensionSBLP;
   187 	extensionType.pfqos_extension_type = KPfqosExtensionSBLP;
   183 	bufPtr.Append((TUint8*)&extensionType, sizeof(pfqos_extension));
   188 	bufPtr.Append((TUint8*)&extensionType, sizeof(pfqos_extension));
   192 	TAuthorizationToken authToken; 
   197 	TAuthorizationToken authToken; 
   193 	pfqos_configblock stringBlock;
   198 	pfqos_configblock stringBlock;
   194 	iSblp->GetMAT(authToken);
   199 	iSblp->GetMAT(authToken);
   195 	SetStringBlockHeader(stringBlock,authToken,KDescSblpMediaAuthorizationToken);
   200 	SetStringBlockHeader(stringBlock,authToken,KDescSblpMediaAuthorizationToken);
   196 	bufPtr.Append((TUint8*)&stringBlock, sizeof(pfqos_configblock));
   201 	bufPtr.Append((TUint8*)&stringBlock, sizeof(pfqos_configblock));
       
   202 
   197 	// put the string now
   203 	// put the string now
   198 	authToken.ZeroTerminate();
   204 	authToken.ZeroTerminate();
   199 	bufPtr.Append((TUint8*)authToken.Ptr(),KAuthorizationTokenAdjustedStringLength);
   205 	bufPtr.Append((TUint8*)authToken.Ptr(),KAuthorizationTokenAdjustedStringLength);
   200 
   206 
   201 
       
   202 	// Flowids
   207 	// Flowids
   203 	pfqos_configblock_int ext;
   208 	pfqos_configblock_int ext;
   204 	TInt i;
   209 	TInt i;
   205 	for(i=0; i<iSblp->NrOfFlowIds();i++)
   210 	for(i=0; i<iSblp->NrOfFlowIds();i++)
   206 		{
   211 		{
   207 		CSblpParameters::TFlowIdentifier& flowId = iSblp->GetFlowId(i);
   212 		CSblpParameters::TFlowIdentifier& flowId = iSblp->GetFlowId(i);
   208 		SetIntValue(ext,flowId.iMediaComponentNumber,KDescSblpMediaComponentNumber);
   213 		SetIntValue(ext,flowId.iMediaComponentNumber,KDescSblpMediaComponentNumber);
   209 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
   214 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
       
   215 
   210 		SetIntValue(ext,flowId.iIPFlowNumber,KDescSblpIPFlowNumber);
   216 		SetIntValue(ext,flowId.iIPFlowNumber,KDescSblpIPFlowNumber);
   211 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
   217 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
   212 		}
   218 		}
   213 
   219 
   214 	bufPtr.AppendFill(0, header.pfqos_configure_len * 8 - byte_len);
   220 	bufPtr.AppendFill(0, header.pfqos_configure_len * 8 - byte_len);
       
   221 
   215 	return *iData;
   222 	return *iData;
   216 	}
   223 	}
   217 
   224 
   218 EXPORT_C TInt CSblpPolicy::ParseMessage(const TDesC8& /*aData*/)
   225 EXPORT_C TInt CSblpPolicy::ParseMessage(const TDesC8& /*aData*/)
   219 	{
   226 	{
   238 EXPORT_C void CSblpPolicy::SetSblpParameters(const CSblpParameters& aSblp)
   245 EXPORT_C void CSblpPolicy::SetSblpParameters(const CSblpParameters& aSblp)
   239 	{
   246 	{
   240 	
   247 	
   241 	*iSblp = aSblp;
   248 	*iSblp = aSblp;
   242 
   249 
   243 	LOG(
   250 
   244 	// following code is to create logs
   251 	// following code is to create logs
   245 	TAuthorizationToken authToken;
   252 	TAuthorizationToken authToken;
   246 	iSblp->GetMAT (authToken);
   253 	iSblp->GetMAT (authToken);
   247 	RArray<CSblpParameters::TFlowIdentifier> flowIds;
   254     RArray<CSblpParameters::TFlowIdentifier> flowIds;
   248 	iSblp->GetFlowIds(flowIds);
   255 	iSblp->GetFlowIds(flowIds);
   249 	// in case of low memory GetFlowIds might return an error and flowIds might not have all the ids, but we still try to log as much as we can
   256 	// in case of low memory GetFlowIds might return an error and flowIds might not have all the ids, but we still try to log as much as we can
   250 	TBuf<KAuthorizationTokenSize> label;
   257 	TBuf<KAuthorizationTokenSize> label;
   251 	label.Copy(authToken);
   258 	label.Copy(authToken);
   252 		
   259 		
   253 	Log::Printf(_L("<------------------------------------------------\n"));
   260 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_1, "<------------------------------------------------\n");
   254 	Log::Printf(_L("CSblpPolicy::SetSblpParameters"));
   261 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_2, "CSblpPolicy::SetSblpParameters");
   255 	Log::Printf(_L("\n"));
   262 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_3, "\n");
   256 	Log::Printf(_L("SBLP VALUES SUPPLIED BY CLIENT IS \n"));
   263 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_4, "SBLP VALUES SUPPLIED BY CLIENT IS \n");
   257 	Log::Printf(_L("\n"));
   264 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_5, "\n");
   258 	Log::Printf(_L("[MAT string			 :	 = %S]\n"),&label);
   265 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_6, "[MAT string           :   = %S]\n",label);
   259 	
   266 	
   260 	TInt i;
   267 	TInt i;
   261 	for(i=0; i<flowIds.Count();i++)
   268 	for(i=0; i<flowIds.Count();i++)
   262 		{
   269 		{
   263 		Log::Printf(_L("Media component number  :	 = %d]\n"),flowIds[i].iMediaComponentNumber);
   270 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_7, "Media component number  :   = %d]\n",flowIds[i].iMediaComponentNumber);
   264 		Log::Printf(_L("IP flow number		  :	 = %d]\n"),flowIds[i].iIPFlowNumber);
   271 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_8, "IP flow number       :  = %d]\n",flowIds[i].iIPFlowNumber);
   265 		}
   272 		}
   266 	Log::Printf(_L("------------------------------------------------>\n"));
   273 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_9, "------------------------------------------------>\n");
   267 	flowIds.Close();
   274 	flowIds.Close();
   268 	)
   275 	
   269 	
   276 	
   270 	}
   277 	}
   271 
   278 
   272 EXPORT_C void CSblpPolicy::GetSblpParameters(CSblpParameters& aSblp) const
   279 EXPORT_C void CSblpPolicy::GetSblpParameters(CSblpParameters& aSblp) const
   273 	{
   280 	{