telephonyprotocols/qosextnapi/src/sblpextn.cpp
changeset 44 8b72faa1200f
parent 0 3553901f7fa8
equal deleted inserted replaced
39:2473f5e227f9 44:8b72faa1200f
     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 	{
       
    78     //in case of low memory the function might not set all the ids
    73 	iFlowIds.Reset();
    79 	iFlowIds.Reset();
    74 	TInt i;
    80 	TInt i;
    75 	for(i=0; i<aFlowIds.Count();i++)
    81 	for(i=0; i<aFlowIds.Count();i++)
    76 		{
    82 		{
    77 		this->iFlowIds.Append(aFlowIds[i]);
    83 		TInt errorCode = this->iFlowIds.Append(aFlowIds[i]);
       
    84 		if (errorCode != KErrNone) 
       
    85 		    {
       
    86             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPARAMETERS_SETFLOWID, "Not Enough Memory");
       
    87 		    }
    78 		}
    88 		}
    79 	}
    89 	}
    80 
    90 
    81 EXPORT_C TInt CSblpParameters::GetFlowIds(RArray<TFlowIdentifier>& aFlowIds)
    91 EXPORT_C TInt CSblpParameters::GetFlowIds(RArray<TFlowIdentifier>& aFlowIds)
    82 	{
    92 	{
       
    93     //in case of low memory the function might not get all the ids and returns an error code
    83 	aFlowIds.Reset();
    94 	aFlowIds.Reset();
    84 	TInt i;
    95 	TInt i;
       
    96 	TInt errorCode = KErrNone;
    85 	for(i=0; i<iFlowIds.Count();i++)
    97 	for(i=0; i<iFlowIds.Count();i++)
    86 		{
    98 		{
    87 		aFlowIds.Append(this->iFlowIds[i]);
    99         errorCode = aFlowIds.Append(this->iFlowIds[i]);
       
   100         if (errorCode != KErrNone) 
       
   101             {
       
   102             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPARAMETERS_GETFLOWID, "Not Enough Memory");
       
   103             return errorCode;
       
   104             }
    88 		}
   105 		}
    89 	return KErrNone;
   106 	return KErrNone;
    90 	}
   107 	}
    91 
   108 
    92 EXPORT_C TInt CSblpParameters::NrOfFlowIds()
   109 EXPORT_C TInt CSblpParameters::NrOfFlowIds()
   161 	header.pfqos_configure_len = (TUint16)((byte_len + 7) / 8);
   178 	header.pfqos_configure_len = (TUint16)((byte_len + 7) / 8);
   162 	header.pfqos_ext_type = EPfqosExtExtension;
   179 	header.pfqos_ext_type = EPfqosExtExtension;
   163 	header.reserved = 0;
   180 	header.reserved = 0;
   164 	header.protocol_id = 0;
   181 	header.protocol_id = 0;
   165 	bufPtr.Append((TUint8*)&header, sizeof(pfqos_configure));
   182 	bufPtr.Append((TUint8*)&header, sizeof(pfqos_configure));
   166 
   183 	
   167 	pfqos_extension extensionType;
   184 	pfqos_extension extensionType;
   168 	extensionType.pfqos_ext_len = 0;
   185 	extensionType.pfqos_ext_len = 0;
   169 	extensionType.pfqos_ext_type = EPfqosExtExtension;
   186 	extensionType.pfqos_ext_type = EPfqosExtExtension;
   170 	extensionType.pfqos_extension_type = KPfqosExtensionSBLP;
   187 	extensionType.pfqos_extension_type = KPfqosExtensionSBLP;
   171 	bufPtr.Append((TUint8*)&extensionType, sizeof(pfqos_extension));
   188 	bufPtr.Append((TUint8*)&extensionType, sizeof(pfqos_extension));
   180 	TAuthorizationToken authToken; 
   197 	TAuthorizationToken authToken; 
   181 	pfqos_configblock stringBlock;
   198 	pfqos_configblock stringBlock;
   182 	iSblp->GetMAT(authToken);
   199 	iSblp->GetMAT(authToken);
   183 	SetStringBlockHeader(stringBlock,authToken,KDescSblpMediaAuthorizationToken);
   200 	SetStringBlockHeader(stringBlock,authToken,KDescSblpMediaAuthorizationToken);
   184 	bufPtr.Append((TUint8*)&stringBlock, sizeof(pfqos_configblock));
   201 	bufPtr.Append((TUint8*)&stringBlock, sizeof(pfqos_configblock));
       
   202 
   185 	// put the string now
   203 	// put the string now
   186 	authToken.ZeroTerminate();
   204 	authToken.ZeroTerminate();
   187 	bufPtr.Append((TUint8*)authToken.Ptr(),KAuthorizationTokenAdjustedStringLength);
   205 	bufPtr.Append((TUint8*)authToken.Ptr(),KAuthorizationTokenAdjustedStringLength);
   188 
   206 
   189 
       
   190 	// Flowids
   207 	// Flowids
   191 	pfqos_configblock_int ext;
   208 	pfqos_configblock_int ext;
   192 	TInt i;
   209 	TInt i;
   193 	for(i=0; i<iSblp->NrOfFlowIds();i++)
   210 	for(i=0; i<iSblp->NrOfFlowIds();i++)
   194 		{
   211 		{
   195 		CSblpParameters::TFlowIdentifier& flowId = iSblp->GetFlowId(i);
   212 		CSblpParameters::TFlowIdentifier& flowId = iSblp->GetFlowId(i);
   196 		SetIntValue(ext,flowId.iMediaComponentNumber,KDescSblpMediaComponentNumber);
   213 		SetIntValue(ext,flowId.iMediaComponentNumber,KDescSblpMediaComponentNumber);
   197 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
   214 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
       
   215 
   198 		SetIntValue(ext,flowId.iIPFlowNumber,KDescSblpIPFlowNumber);
   216 		SetIntValue(ext,flowId.iIPFlowNumber,KDescSblpIPFlowNumber);
   199 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
   217 		bufPtr.Append((TUint8*)&ext, sizeof(pfqos_configblock_int));
   200 		}
   218 		}
   201 
   219 
   202 	bufPtr.AppendFill(0, header.pfqos_configure_len * 8 - byte_len);
   220 	bufPtr.AppendFill(0, header.pfqos_configure_len * 8 - byte_len);
       
   221 
   203 	return *iData;
   222 	return *iData;
   204 	}
   223 	}
   205 
   224 
   206 EXPORT_C TInt CSblpPolicy::ParseMessage(const TDesC8& /*aData*/)
   225 EXPORT_C TInt CSblpPolicy::ParseMessage(const TDesC8& /*aData*/)
   207 	{
   226 	{
   226 EXPORT_C void CSblpPolicy::SetSblpParameters(const CSblpParameters& aSblp)
   245 EXPORT_C void CSblpPolicy::SetSblpParameters(const CSblpParameters& aSblp)
   227 	{
   246 	{
   228 	
   247 	
   229 	*iSblp = aSblp;
   248 	*iSblp = aSblp;
   230 
   249 
   231 	LOG(
   250 
   232 	// following code is to create logs
   251 	// following code is to create logs
   233 	TAuthorizationToken authToken;
   252 	TAuthorizationToken authToken;
   234 	iSblp->GetMAT (authToken);
   253 	iSblp->GetMAT (authToken);
   235 	RArray<CSblpParameters::TFlowIdentifier> flowIds;
   254     RArray<CSblpParameters::TFlowIdentifier> flowIds;
   236 	iSblp->GetFlowIds(flowIds);
   255 	iSblp->GetFlowIds(flowIds);
       
   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
   237 	TBuf<KAuthorizationTokenSize> label;
   257 	TBuf<KAuthorizationTokenSize> label;
   238 	label.Copy(authToken);
   258 	label.Copy(authToken);
   239 		
   259 		
   240 	Log::Printf(_L("<------------------------------------------------\n"));
   260 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_1, "<------------------------------------------------\n");
   241 	Log::Printf(_L("CSblpPolicy::SetSblpParameters"));
   261 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_2, "CSblpPolicy::SetSblpParameters");
   242 	Log::Printf(_L("\n"));
   262 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_3, "\n");
   243 	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");
   244 	Log::Printf(_L("\n"));
   264 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_5, "\n");
   245 	Log::Printf(_L("[MAT string			 :	 = %S]\n"),&label);
   265 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_6, "[MAT string           :   = %S]\n",label);
   246 	
   266 	
   247 	TInt i;
   267 	TInt i;
   248 	for(i=0; i<flowIds.Count();i++)
   268 	for(i=0; i<flowIds.Count();i++)
   249 		{
   269 		{
   250 		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);
   251 		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);
   252 		}
   272 		}
   253 	Log::Printf(_L("------------------------------------------------>\n"));
   273 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSBLPPOLICY_SETSBLPPARAMETERS_9, "------------------------------------------------>\n");
   254 	flowIds.Close();
   274 	flowIds.Close();
   255 	)
   275 	
   256 	
   276 	
   257 	}
   277 	}
   258 
   278 
   259 EXPORT_C void CSblpPolicy::GetSblpParameters(CSblpParameters& aSblp) const
   279 EXPORT_C void CSblpPolicy::GetSblpParameters(CSblpParameters& aSblp) const
   260 	{
   280 	{