ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/marvell/services/mbim/mbim_basic.c b/marvell/services/mbim/mbim_basic.c
new file mode 100644
index 0000000..08e9f6a
--- /dev/null
+++ b/marvell/services/mbim/mbim_basic.c
@@ -0,0 +1,1835 @@
+/******************************************************************************
+*(C) Copyright 2014 Marvell International Ltd.
+* All Rights Reserved
+******************************************************************************/
+/* -------------------------------------------------------------------------------------------------------------------
+ *
+ *  Filename: mbim_util.c
+ *
+ *  Authors:  Adrian Zelezniak
+ *
+ *  Description: all utiliy functions and macros needed for the MIBM translator
+ *
+ *  HISTORY:
+ *   Jan 7, 2014 - Initial Version
+ *
+ *  Notes:
+ *
+ ******************************************************************************/
+
+#define LOG_TAG	"MBIM"
+
+/******************************************************************************
+ *   Include files
+ ******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+#include "mbim_types.h"
+#include "mbim_basic.h"
+#include "mbim_sms.h"
+#include "mbim_ussd.h"
+#include "mbim_util.h"
+#include "mbim_protocol.h"
+#if defined (MBIM_MTIL)
+#include "mbim_mtil.h"
+#include "mbim_mtil_ind.h"
+#include "MtilAPI.h"
+#include "mbim_cm.h"
+#else
+#include "mbim_ril.h"
+#endif
+
+
+#ifndef MBIM_BASIC_UNUSEDPARAM
+#define MBIM_BASIC_UNUSEDPARAM() ((void) cid);((void) transactionId);((void) commandType);((void) infoBufLen);((void) infoBuf_p)
+#endif
+
+extern int property_get(const char *name, const char* value, const char* default_value);
+
+
+/******************************************************************************
+ *   Macros
+ ******************************************************************************/
+#define CREATE_BASIC_CONNECT_CONTEXT(pContext, mBuf)														\
+			pContext = (P_MBIM_MESSAGE_CONTEXT)MBIM_MALLOC(sizeof(MBIM_MESSAGE_CONTEXT));					\
+			if (pContext != NULL) {																			\
+				pContext->hdr.cid		= cid;																\
+				pContext->hdr.transId	= transactionId;													\
+				pContext->hdr.uuidIndex	= UUID_BASIC_CONNECT_INDEX;											\
+				pContext->hdr.indication= MBIM_REQUEST;														\
+				pContext->body 			= mBuf;																\
+				pContext->cmd			= NULL;																\
+			}																								\
+			else {																							\
+				if (mBuf != NULL)																			\
+					MBIM_FREE(mBuf);																		\
+				MBIM_LOGE("BASIC UUID: OUT OF MEMORY CID %d (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType);	\
+				return MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); 						\
+			}
+
+
+#define ALLOCATE_RESPONSE_BUFFER(mBuf_p, mSize) 																			\
+	mBuf_p = (char *)MBIM_MALLOC(mSize);																					\
+	if (mBuf_p == NULL) {																									\
+		MBIM_LOGE("BASIC UUID: OUT OF MEMORY CID %d (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType);	\
+		return MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); 												\
+	} else																													\
+	{ memset(mBuf_p, 0, mSize); }
+
+
+#define ALLOCATE_CMD_BUFFER(context_p, mBuf_p, mSize) 																		\
+	mBuf_p = (char *)MBIM_MALLOC(mSize);																					\
+	if (mBuf_p == NULL) {																									\
+		if (context_p->body != NULL)																						\
+			MBIM_FREE(context_p->body);																						\
+		MBIM_LOGE("BASIC UUID: OUT OF MEMORY CID %d (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType);	\
+		return MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); 												\
+	} else {																												\
+		memset(mBuf_p, 0, mSize);																							\
+		context_p->cmd =  mBuf_p;																							\
+	}
+
+
+#define ADD_DEVICE_SERVICES(service)		*pCidSupported 			= service;		\
+											pCidSupported++;						\
+											pBuf->cidCount++;
+
+
+/******************************************************************************
+ *   #defines
+ ******************************************************************************/
+#define DEFAULT_CONTEXT_ALLOC_SIZE	(4000)
+
+
+/******************************************************************************
+ *   Global Variables
+ ******************************************************************************/
+extern MBIM_DATABASE				mbimDb;
+Boolean								ConfigureAzw = TRUE;
+
+/* services filer arrays */
+char	basicFilterArray[UUID_BASIC_CID_MAX];
+char	smsFilterArray[UUID_SMS_CID_MAX];
+char	ussdFilterArray[UUID_USSD_CID_MAX];
+
+UINT32 cidsFilterArray[UUID_MAX_SERVICE_INDEX][2]	=
+{
+	{(UINT32)&basicFilterArray,sizeof(basicFilterArray)},
+	{(UINT32)&smsFilterArray,sizeof(smsFilterArray)},
+	{(UINT32)&ussdFilterArray,sizeof(ussdFilterArray)},
+	{0,0},
+	{0,0},
+	{0,0},
+	{0,0}
+};
+
+//BS:
+Boolean								disableUnsolCidConnect	=	FALSE;
+
+/******************************************************************************
+ *  Function prototypes
+ ******************************************************************************/
+static int addBasicConnectServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addSmsServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addUssdServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addPhonebookServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addStkServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addAuthServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addDssServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addBasicExtServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static int addUICCServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf);
+static void	MbimSetDeviceServiceSubscribeList	(P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST	pDevServSubsList);
+
+//static int validateCidConnectSetCommand(P_MBIM_SET_CONNECT pSetConnect);
+
+
+int CID_DeviceCaps(BASIC_CID_PARAMS);
+int CID_SubscriberReadyStatus(BASIC_CID_PARAMS);
+int CID_RadioState(BASIC_CID_PARAMS);
+int CID_Pin(BASIC_CID_PARAMS);
+int CID_PinList(BASIC_CID_PARAMS);
+int CID_HomeProvider(BASIC_CID_PARAMS);
+int CID_PreferedProviders(BASIC_CID_PARAMS);
+int CID_VisibleProviders(BASIC_CID_PARAMS);
+int CID_RegisterState(BASIC_CID_PARAMS);
+int CID_PacketService(BASIC_CID_PARAMS);
+int CID_SignalState(BASIC_CID_PARAMS);
+int CID_Connect(BASIC_CID_PARAMS);
+int CID_ProvisionedContexts(BASIC_CID_PARAMS);
+int CID_ServiceActivation(BASIC_CID_PARAMS);
+int CID_IpConfiguration(BASIC_CID_PARAMS);
+int CID_DeviceServices(BASIC_CID_PARAMS);
+int CID_DeviceServicesSubscribeList(BASIC_CID_PARAMS);
+int CID_PacketStatistics(BASIC_CID_PARAMS);
+int CID_NetworkIdleHint(BASIC_CID_PARAMS);
+int CID_EmergencyMode(BASIC_CID_PARAMS);
+int CID_IpPacketFilters(BASIC_CID_PARAMS);
+int CID_MultiCarrierProviders(BASIC_CID_PARAMS);
+int CID_NotSupported(BASIC_CID_PARAMS);
+
+/******************************************************************************
+ *   External variables
+ ******************************************************************************/
+basicUuidProcessors basicCidProcessor[UUID_BASIC_CID_MAX] = {
+	CID_NotSupported,	//0
+	CID_DeviceCaps,
+	CID_SubscriberReadyStatus,
+	CID_RadioState,
+	CID_Pin,
+	CID_PinList,
+	CID_HomeProvider,
+	CID_PreferedProviders,
+	CID_VisibleProviders,
+	CID_RegisterState,
+	CID_PacketService,		//10
+	CID_SignalState,
+	CID_Connect,
+	CID_ProvisionedContexts,
+	CID_ServiceActivation,
+	CID_IpConfiguration,
+	CID_DeviceServices,
+	CID_NotSupported, //17
+	CID_NotSupported,//18
+	CID_DeviceServicesSubscribeList,
+	CID_PacketStatistics,
+	CID_NetworkIdleHint,
+	CID_EmergencyMode,
+	CID_IpPacketFilters,
+	CID_MultiCarrierProviders,
+};
+
+
+
+/******************************************************************************
+ *  Code
+ ******************************************************************************/
+
+
+/*******************************************************************************\
+*	Function:		CID_NotSupported
+*	Description:	This function sends Error to HOST when a unknown command is received
+*	Parameters:   dataBuf - String
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_NotSupported(BASIC_CID_PARAMS)
+{
+	int rc = MBIM_OK;
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+
+	MBIM_LOGE("BASIC UUID: Command %d not supported (TransactionId = %d, Cmd Type = %d)", cid, transactionId, commandType);
+	//rc = MbimSendFunctionErrorMsg(transactionId, MBIM_ERROR_UNKNOWN); //Send Error to MBIM
+	rc = MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, 
+			cid, MBIM_STATUS_NO_DEVICE_SUPPORT, 0 , NULL);
+
+	return rc;
+}
+
+#define NUMBER_OF_MAX_DSS_SERVICES	7
+#define NUMBER_OF_MAX_CID 18
+/*******************************************************************************\
+*	Function:		CID_DeviceServices
+*	Description:	MBIM_CID_DEVEICE_SERVICES (Chapter 10.5.29)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_DeviceServices(BASIC_CID_PARAMS)
+{
+	int 							rc 		= MBIM_OK;
+	char 							*buf 	= NULL;
+	P_MBIM_DEVICE_SERVICE_INFO		serviecInfo_p;
+	P_OL_PAIR_LIST					pairList_p;
+	P_OL_PAIR_LIST					prevPairList_p;
+	int								serviceIndex;
+
+
+
+	//We only support Query for this command
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+	//This command is HC
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Pickup pointer to header
+	serviecInfo_p = (P_MBIM_DEVICE_SERVICE_INFO)&buf[0];
+	serviecInfo_p->deviceServicesCount	= UUID_MAX_SERVICE_INDEX;
+	serviecInfo_p->maxDssSessions		= 1;	// Number of Session supported (We start with 1, need to change in the future).
+
+
+	//////////////////////////////////////////
+	//Add BASIC-CONNECT Cid elements
+	//////////////////////////////////////////
+
+	//Add BASIC CID supported Services
+	pairList_p			= (P_OL_PAIR_LIST)&buf[sizeof(MBIM_DEVICE_SERVICE_INFO)];
+	pairList_p->offset  = sizeof(MBIM_DEVICE_SERVICE_INFO) + serviecInfo_p->deviceServicesCount*sizeof(OL_PAIR_LIST);
+	pairList_p->size    = addBasicConnectServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+
+	for (serviceIndex = 1 ; serviceIndex < (int)serviecInfo_p->deviceServicesCount ; serviceIndex++)
+	{
+		//Add supported services
+		prevPairList_p = pairList_p;
+		pairList_p++;
+		pairList_p->offset  = prevPairList_p->offset + prevPairList_p->size;
+
+		switch(serviceIndex)
+		{
+			case UUID_SMS_INDEX:
+				pairList_p->size	= addSmsServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+			case UUID_USSD_INDEX:
+				pairList_p->size	= addUssdServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+			case UUID_PHONEBOOK_INDEX:
+				pairList_p->size	= addPhonebookServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+			case UUID_STK_INDEX:
+				pairList_p->size	= addStkServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+			case UUID_AUTH_INDEX:
+				pairList_p->size	= addAuthServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+			case UUID_DSS_INDEX:
+				pairList_p->size	= addDssServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+            case UUID_BASIC_CONNECT_EXTENSIONS_INDEX:
+				pairList_p->size	= addBasicExtServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+			case UUID_MS_UICC_LOW_LEVEL_INDEX:
+				pairList_p->size	= addUICCServiceElements((P_MBIM_DEVICE_SERVICE_ELEMENT)(&buf[pairList_p->offset]));
+				break;
+            default:
+				break;
+		}
+	}
+
+	//Send the Command Done back to MBIM Host
+	MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, MBIM_STATUS_SUCCESS, (pairList_p->offset+pairList_p->size) , buf);
+
+	//Free the buffer
+	MBIM_FREE(buf);
+
+	return rc;
+}
+
+
+/*******************************************************************************\
+*	Function:		addBasicConnectServiceElements
+*	Description:	Adds the supported BASIC_CONNECT CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addBasicConnectServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_BASIC_CONNECT_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(UUID_BASIC_CID_DEVICE_CAPS);
+	ADD_DEVICE_SERVICES(UUID_SUBSCRIBER_READY_STATUS);
+	ADD_DEVICE_SERVICES(UUID_RADIO_STATE);
+	ADD_DEVICE_SERVICES(UUID_PIN);
+	ADD_DEVICE_SERVICES(UUID_PIN_LIST);
+	ADD_DEVICE_SERVICES(UUID_HOME_PROVIDER);
+	ADD_DEVICE_SERVICES(UUID_PREFERRED_PROVIDERS);
+	ADD_DEVICE_SERVICES(UUID_VISIBLE_PROVIDERS);
+	ADD_DEVICE_SERVICES(UUID_REGISTER_STATE);
+	ADD_DEVICE_SERVICES(UUID_PACKET_SERVICE);
+	ADD_DEVICE_SERVICES(UUID_SIGNAL_STATE);
+	ADD_DEVICE_SERVICES(UUID_CONNECT);
+	ADD_DEVICE_SERVICES(UUID_PROVISIONED_CONTEXTS);
+	ADD_DEVICE_SERVICES(UUID_SERVICE_ACTIVATION);
+	ADD_DEVICE_SERVICES(UUID_IP_CONFIGURATION);
+	ADD_DEVICE_SERVICES(UUID_DEVICE_SERVICES);
+	ADD_DEVICE_SERVICES(UUID_DEVICE_SERVICE_SUBSCRIBE_LIST);
+	ADD_DEVICE_SERVICES(UUID_PACKET_STATISTICS);
+	ADD_DEVICE_SERVICES(UUID_NETWORK_IDLE_HINT);
+	ADD_DEVICE_SERVICES(UUID_EMERGENCY_MODE);
+	ADD_DEVICE_SERVICES(UUID_IP_PACKET_FILTERS);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+/*******************************************************************************\
+*	Function:		addSmsServiceElements
+*	Description:	Adds the supported SMS CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addSmsServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_SMS_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(UUID_SMS_CONFIGURATION);
+	ADD_DEVICE_SERVICES(UUID_SMS_READ);
+	ADD_DEVICE_SERVICES(UUID_SMS_SEND);
+	ADD_DEVICE_SERVICES(UUID_SMS_DELETE);
+	ADD_DEVICE_SERVICES(UUID_SMS_MESSAGE_STORE_STATUS);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+
+/*******************************************************************************\
+*	Function:		addUssdServiceElements
+*	Description:	Adds the supported USSD CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addUssdServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_USSD_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(MBIM_CID_USSD);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+
+/*******************************************************************************\
+*	Function:		addPhonebookServiceElements
+*	Description:	Adds the supported PHONEBOOK CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addPhonebookServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_PHONEBOOK_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_CONFIGURATION);
+	ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_READ);
+	ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_DELETE);
+	ADD_DEVICE_SERVICES(MBIM_CID_PHONEBOOK_WRITE);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+
+/*******************************************************************************\
+*	Function:		addStkServiceElements
+*	Description:	Adds the supported STK CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addStkServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_STK_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(MBIM_CID_STK_PAC);
+	ADD_DEVICE_SERVICES(MBIM_CID_STK_TERMINAL_RESPONSE);
+	ADD_DEVICE_SERVICES(MBIM_CID_STK_ENVELOPE);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+
+/*******************************************************************************\
+*	Function:		addAuthServiceElements
+*	Description:	Adds the supported AUTH CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addAuthServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_AUTH_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+//	ADD_DEVICE_SERVICES(MBIM_CID_AKA_AUTH);
+//	ADD_DEVICE_SERVICES(MBIM_CID_AKAP_AUTH);
+//	ADD_DEVICE_SERVICES(MBIM_CID_SIM_AUTH);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+
+
+/*******************************************************************************\
+*	Function:		addDssServiceElements
+*	Description:	Adds the supported DSS CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addDssServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_DSS_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(MBIM_CID_DSS_CONNECT);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+
+/*******************************************************************************\
+*	Function:		addBasicExtServiceElements
+*	Description:	Adds the supported Basic connect extension CID to the Service Element
+*	Parameters:   P_MBIM_DEVICE_SERVICE_ELEMENT pBuf - Pointer to the beggining of the service Element
+*
+*	Returns:		the size of the current element
+\*******************************************************************************/
+static int addBasicExtServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_BASIC_CONNECT_EXTENSIONS_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(MBIM_MS_PROVISIONED_CONTEXT_V2);
+	ADD_DEVICE_SERVICES(MBIM_CID_VERSION);
+    ADD_DEVICE_SERVICES(MBIM_CID_MS_MODEM_CONFIG);
+    ADD_DEVICE_SERVICES(MBIM_CID_MS_REGISTRATION_PARAMS);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+
+static int addUICCServiceElements(P_MBIM_DEVICE_SERVICE_ELEMENT pBuf)
+{
+	UINT32		*pCidSupported;
+
+	Index2UUID((P_MBIM_UUID)&pBuf->deviceServiceId.uuid[0], UUID_MS_UICC_LOW_LEVEL_INDEX);
+	pBuf->dssPayload 		= 0;
+	pBuf->maxDssInstaces 	= 0;
+	pBuf->cidCount			= 0;		//This grows each time a command CID is added (See macro ADD_DEVICE_SERVICES)
+	pCidSupported			= (UINT32 *)&pBuf->dataBuffer[0];
+
+	ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_ATR);
+	ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_OPEN_CHANNEL);
+    ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_CLOSE_CHANNEL);
+    ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_APDU);
+	ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_TERMINAL_CAPABILITY);
+	ADD_DEVICE_SERVICES(MBIM_CID_MS_UICC_RESET);
+
+	//return the size of the service element
+	return ((UINT32)pCidSupported - (UINT32)pBuf );
+}
+
+/*******************************************************************************\
+*	Function:		CID_DeviceCaps
+*	Description:	MBIM_CID_DEVICE_CAPS (Chapter 10.5.1)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_DeviceCaps(BASIC_CID_PARAMS)
+{
+	int						rc			= MBIM_OK;
+	char					*buf		= NULL;
+	P_MBIM_MESSAGE_CONTEXT	mContext	= NULL;
+	
+	//We only support Query for this command
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	/////////////////////////////////////////
+	//Fill the static data
+	/////////////////////////////////////////
+	if (mbimDb.mbimNegVersion >= MBIMEx_v4)
+    {
+        P_MBIM_DEVICE_CAPS_INFO_V3 pCapsInfo 	= NULL;
+        
+    	pCapsInfo = (P_MBIM_DEVICE_CAPS_INFO_V3)buf;
+    	pCapsInfo->deviceType			= MBIMDeviceTypeRemovable;
+    	pCapsInfo->cellularClass		= MBIMCellularClassGsm;
+    	pCapsInfo->voiceClass			= MBIMVoiceClassNoVoice; //MBIMVoiceClassSimultaneousVoiceData; 
+    	pCapsInfo->simClass				= MBIMSimClassSimRemovable;
+    	pCapsInfo->dataClass			= (MBIMDataClassLTE | MBIMDataClass5G);
+    	pCapsInfo->smsCaps				= MBIMSmsCapsNone;//(MBIMSmsCapsPduReceive | MBIMSmsCapsPduSend);
+    	pCapsInfo->controlCaps			= MBIMCtrlCapsRegManual;
+		pCapsInfo->DataSubClass			= MBIMDataSubClass5GNR | MBIMDataSubClass5GENDC;
+    	pCapsInfo->maxSessions			= 1;
+        pCapsInfo->ExecutorIndex        = 0;
+        pCapsInfo->WcdmaBandClass       = 0;
+    }
+    else
+    {   
+        P_MBIM_DEVICE_CAPS_INFO pCapsInfo 	= NULL;
+    	pCapsInfo = (P_MBIM_DEVICE_CAPS_INFO)buf;
+    	pCapsInfo->deviceType			= MBIMDeviceTypeRemovable;
+    	pCapsInfo->cellularClass		= MBIMCellularClassGsm;
+    	pCapsInfo->voiceClass			= MBIMVoiceClassNoVoice; //MBIMVoiceClassSimultaneousVoiceData;
+    	pCapsInfo->simClass				= MBIMSimClassSimRemovable;
+    	pCapsInfo->dataClass			= (MBIMDataClassLTE | MBIMDataClass5G);
+    	pCapsInfo->smsCaps				= MBIMSmsCapsNone;//(MBIMSmsCapsPduReceive | MBIMSmsCapsPduSend);
+    	pCapsInfo->controlCaps			= MBIMCtrlCapsRegManual;
+    	pCapsInfo->maxSessions			= 1;//MAX_NUM_OF_SESSIONS; --> Adrian
+
+    	pCapsInfo->CustomDataClassOffset = 0;
+    	pCapsInfo->CustomDataClassSize	 = 0;
+    	pCapsInfo->deviceIdOffset		 = offsetof(MBIM_DEVICE_CAPS_INFO, dataBuffer[0]);
+   }
+
+#if defined (MBIM_MTIL)
+	MBIM_LOGD("Sending CGSN. Context = %d", mContext);
+
+	//send MTIL GET command
+	rc = MtilSendGetNoParams(mContext, MTIL_CODE_AT_CGSN_GET);
+#else
+	rc = MbimTelRequestDeviceId(mContext);
+#endif
+	return rc;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_SubscriberReadyStatus
+*	Description:	MBIM_CID_SUBSCRIBER_READY_STATUS (Chapter 10.5.2)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_SubscriberReadyStatus(BASIC_CID_PARAMS)
+{
+	int								rc						= MBIM_OK;
+	char							*buf					= NULL;
+	P_MBIM_MESSAGE_CONTEXT			mContext				= NULL;
+
+	//We only support Query for this command
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+#if defined (MBIM_MTIL)
+	MtilSendGetNoParams(mContext, MTIL_CODE_AT_SIM_DEV_STATUS_GET);
+#else
+	MbimTelRequestSimStatus(mContext);
+#endif
+	return rc;
+}
+
+
+
+/*******************************************************************************\
+*	Function:		CID_RadioState
+*	Description:	MBIM_CID_RADIO_STATE (Chapter 10.5.3)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_RadioState(BASIC_CID_PARAMS)
+{
+	int						rc				= MBIM_OK;
+	char					*buf			= NULL;
+	P_MBIM_MESSAGE_CONTEXT	mContext		= NULL;
+	P_MBIM_SET_RADIO_STATE	pSetRadioState	= NULL;
+	P_MBIM_RADIO_STATE_INFO pRadioStateInfo	= NULL;
+#if defined (MBIM_MTIL)
+	char 					prop [255];		//Added for testing LTE configuration in 3G NW (Will open 3 pdp's as VZN)
+#endif
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+
+	//////////////////////////////////////////////////////
+	//Take care SET
+	/////////////////////////////////////////////////////
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		pSetRadioState = (P_MBIM_SET_RADIO_STATE)infoBuf_p;
+
+		MBIM_LOGD("MBIM_CID_RADIO_STATE --> Set. RadioState = %d", pSetRadioState->RadioState);
+
+		pRadioStateInfo = (P_MBIM_RADIO_STATE_INFO)buf;
+		pRadioStateInfo->HwRadioState = MBIMRadioOn;
+		pRadioStateInfo->SwRadioState = (pSetRadioState->RadioState?1:4);
+
+#if defined (MBIM_MTIL)
+		//If we are turning radio ON, check if we are in 3G Debug Mode
+		if (pSetRadioState->RadioState != 0)
+		{
+			//check if we are in test mode
+			property_get(MBIM_VZN_APN_RULE_PROPERTY, (const char *)prop, "replace");
+			if (strcmp(prop, MBIM_VZN_APN_RULE_3G_VZN_TEST) == 0)
+			{
+				//Send Simulated PLMN Indication
+				simulatePlmnInfoInd();
+			}
+		}
+#endif
+
+		//save in context the requested configuration.	(Need to free buffer in failure below)
+		ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, infoBufLen);
+		memcpy( mContext->cmd, (char *)infoBuf_p, infoBufLen);
+	}
+	//////////////////////////////////////////////////////
+	//Take care QUERY
+	/////////////////////////////////////////////////////
+	else
+	{
+		MBIM_LOGD("MBIM_CID_RADIO_STATE --> Get");
+	}
+
+#if defined (MBIM_MTIL)
+	rc = MtilSendGetNoParams(mContext, MTIL_CODE_AT_CFUN_GET);
+#else
+	rc = MbimTelRequestRadioState(mContext);
+#endif
+	return rc;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_Pin
+*	Description:	MBIM_CID_PIN(Chapter 10.5.4)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_Pin(BASIC_CID_PARAMS)
+{
+	int 					rc				= MBIM_OK;
+	char					*buf			= NULL;
+	P_MBIM_MESSAGE_CONTEXT	mContext		= NULL;
+	P_MBIM_SET_PIN			pPinSet			= NULL;
+	char					pin[16+1]			= {0};
+	char					newPin[16+1]		= {0};
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, sizeof(MBIM_PIN_INFO));
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	//save in context the requested configuration
+	ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, sizeof(MBIM_SET_PIN));
+	memset(mContext->cmd, 0, sizeof(MBIM_SET_PIN));
+
+	//////////////////////////////////////////////////////
+	//Take care of SET
+	/////////////////////////////////////////////////////
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		pPinSet = (P_MBIM_SET_PIN)infoBuf_p;
+        memcpy(mContext->cmd, pPinSet, sizeof(MBIM_SET_PIN));
+
+		//Get Pin
+		copyUtf16ToStr(pin, infoBuf_p + pPinSet->pinOffset, pPinSet->pinSize);
+		pin[pPinSet->pinSize / 2] = 0;
+
+		copyUtf16ToStr(newPin, infoBuf_p + pPinSet->newPinOffset, pPinSet->newPinSize);
+		newPin[pPinSet->newPinSize / 2] = 0;
+
+		switch (pPinSet->pinOperation)
+		{
+			case MBIMPinOperationEnter:
+				// here we suppose that host knows current PIN state and performs correct operation
+#if defined (MBIM_MTIL)
+				MtilSendCpinSet(mContext, pin, newPin);
+#else
+				MbimTelRequestPinSet(mContext, pin, newPin);
+#endif
+				break;
+
+			case MBIMPinOperationEnable:
+#if defined (MBIM_MTIL)
+				MtilSendClckSet(mContext, MTIL_FAC_SC, 1, pin);
+#else
+				MbimTelRequestPinEnable(mContext, pin);
+#endif
+				break;
+
+			case MBIMPinOperationDisable:
+#if defined (MBIM_MTIL)
+				MtilSendClckSet(mContext, MTIL_FAC_SC, 0, pin);
+#else
+				MbimTelRequestPinDisable(mContext, pin);
+#endif
+				break;
+
+			case MBIMPinOperationChange:
+				//Get the newPin number
+				copyUtf16ToStr(newPin, infoBuf_p + pPinSet->newPinOffset, pPinSet->newPinSize);
+				newPin[pPinSet->newPinSize / 2] = 0;
+
+#if defined (MBIM_MTIL)
+				MtilSendCpwdSet(mContext, MTIL_FAC_SC, pin, newPin);
+#else
+				MbimTelRequestPinModify(mContext, pin, newPin);
+#endif
+				break;
+		}//end of switch
+	}
+
+	//////////////////////////////////////////////////////
+	//Take care of Query
+	/////////////////////////////////////////////////////
+	else
+	{
+#if defined (MBIM_MTIL)
+		MtilSendGetNoParams(mContext, MTIL_CODE_AT_SIM_DEV_STATUS_GET);
+#else
+		MbimTelRequestSimStatus(mContext);
+#endif
+	}
+
+	return rc;
+}
+
+
+
+
+/*******************************************************************************\
+*	Function:		CID_PinList
+*	Description:	MBIM_CID_PIN_LIST(Chapter 10.5.5)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_PinList(BASIC_CID_PARAMS)
+{
+
+	int 					rc				= MBIM_OK;
+	char					*buf			= NULL;
+	P_MBIM_MESSAGE_CONTEXT	mContext		= NULL;
+
+
+	//We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER).
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	//Get CPIN information
+#if defined (MBIM_MTIL)
+		MtilSendGetNoParams(mContext, MTIL_CODE_AT_SIM_DEV_STATUS_GET);
+#else
+	MbimTelRequestPinList(mContext);
+#endif
+
+	return rc;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_HomeProvider
+*	Description:	MBIM_CID_HOME_PROVIDER (Chapter 10.5.6)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_HomeProvider(BASIC_CID_PARAMS)
+{
+	int 					rc				= MBIM_OK;
+	char					*buf			= NULL;
+	P_MBIM_MESSAGE_CONTEXT	mContext		= NULL;
+	P_MBIM_PROVIDER			pMbimProvider	= NULL;
+	UINT32					mbimStatus		= MBIM_STATUS_SUCCESS;
+
+	//We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER).
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	pMbimProvider = (P_MBIM_PROVIDER)buf;
+	pMbimProvider->errorRate 		= 0;								//Set to Zero if we don't support MBIM_CTRL_CAPS_MULTI_CARRIER;
+	pMbimProvider->rssi				= CID_SIGNAL_STRENGTH_RSSI_UNKOWN;	//Set to Zero if we don't support MBIM_CTRL_CAPS_MULTI_CARRIER;
+	pMbimProvider->cellularClass	= MBIMCellularClassGsm;				//(set 1 as reference)Set to Zero if we don't support MBIM_CTRL_CAPS_MULTI_CARRIER;
+
+
+	if (mbimDb.HomeProviderIdSize == 0)
+	{
+#if defined (MBIM_MTIL)
+		//Call the next AT command
+		MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CIMI_GET);
+#else
+		MbimTelRequestHomeProviderId(mContext);
+#endif
+	}
+	else
+	{
+
+		//set the correct provider Id,with the correct size
+		pMbimProvider->providerIdState	 	= MBIM_PROVIDER_STATE_HOME;
+		pMbimProvider->providerIdOffset		= offsetof(MBIM_PROVIDER, dataBuffer[0]);
+		pMbimProvider->providerIdSize 		= copyStrToUtf16(((char *)pMbimProvider) + pMbimProvider->providerIdOffset, mbimDb.HomeProviderMccMnc, mbimDb.HomeProviderIdSize);
+
+		//Set provider ID name
+		pMbimProvider->providerNameOffset = (pMbimProvider->providerIdOffset + pMbimProvider->providerIdSize + 3)&~3; /* account for padding */
+		pMbimProvider->providerNameSize		= copyStrToUtf16(((char *)pMbimProvider) + pMbimProvider->providerNameOffset, mbimDb.HomeProviderName, strlen(mbimDb.HomeProviderName));
+
+		//Add Zero termination (UTF-16)
+		/* Again, padding, and it should not affect the Size */
+		//memset((char *)pMbimProvider + pMbimProvider->providerNameOffset + pMbimProvider->providerNameSize, 0, 2);
+		//pMbimProvider->providerNameSize += 2;
+
+
+		if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted)
+			mbimStatus = MBIM_STATUS_SIM_NOT_INSERTED;
+		else if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateBadSim)
+			mbimStatus = MBIM_STATUS_BAD_SIM;
+
+		//Send answer here until next AT command is implemented [TBD ADRIAN - Need to get provider name from SIM]
+		MbimSendCommandDone(	mContext->hdr.transId,
+								mContext->hdr.uuidIndex,
+								mContext->hdr.cid,
+								mbimStatus,
+								ALIGN32(pMbimProvider->providerNameOffset+pMbimProvider->providerNameSize),
+								mContext->body );
+
+		MBIM_FREE_CONTEXT(mContext);
+
+	}
+	return rc;
+}
+
+
+
+/*******************************************************************************\
+*	Function:		CID_PreferedProviders
+*	Description:	MBIM_CID_PREFERRED_PROVIDERS (Chapter 10.5.7)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_PreferedProviders(BASIC_CID_PARAMS)
+{
+	int 							rc					= MBIM_OK;
+	char							*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT			mContext			= NULL;
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+
+	//We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER).
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		//send Error to Host
+		rc = MbimSendCommandDone(mContext->hdr.transId,
+								 mContext->hdr.uuidIndex,
+								 mContext->hdr.cid,
+								 MBIM_STATUS_OPERATION_NOT_ALLOWED,
+								 0, NULL);
+		MBIM_FREE_CONTEXT(mContext);
+	}
+	else
+	{
+		//Get prefered providers
+#if defined (MBIM_MTIL)
+		MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CPOL_GET);
+#else
+		MbimTelRequestPreferredProviders(mContext);
+#endif
+	}
+
+	return rc;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_VisibleProviders
+*	Description:	MBIM_CID_VISIBLE_PROVIDERS (Chapter 10.5.8)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_VisibleProviders(BASIC_CID_PARAMS)
+{
+	int 							rc					= MBIM_OK;
+	char							*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT			mContext			= NULL;
+#if defined (MBIM_MTIL)
+	P_MBIM_VISIBLE_PROVIDERS_REQ	pVisibleProvReq		= NULL;
+#endif
+	P_MBIM_PROVIDERS				pMbimProviders		= NULL;
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//We only support Query for this command (Set is supported only if we support MBIM_CTRL_CAPS_MULTI_CARRIER).
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted)
+	{
+		pMbimProviders = (P_MBIM_PROVIDERS)buf;
+		pMbimProviders->elementCount = 0;
+
+		//send Error to Host
+		MbimSendCommandDone( mContext->hdr.transId,
+							 mContext->hdr.uuidIndex,
+							 mContext->hdr.cid,
+							 MBIM_STATUS_SIM_NOT_INSERTED,
+							 sizeof(MBIM_RADIO_STATE_INFO),
+							 mContext->body );
+		MBIM_FREE_CONTEXT(mContext);
+	}
+	else
+	{
+		//Pick up pointer to request
+#if defined (MBIM_MTIL)
+		pVisibleProvReq = (P_MBIM_VISIBLE_PROVIDERS_REQ)infoBuf_p;
+		if (pVisibleProvReq->action == MBIMVisibleProvidersActionFullScan)
+		{
+			MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_COPS_OPT);
+
+			MBIM_LOGD("MBIM_CID_VISIBLE_PROVIDERS: CID_VisibleProviders Full scan");
+		}
+		else
+		{
+			MBIM_LOGD("MBIM_CID_VISIBLE_PROVIDERS: CID_VisibleProviders Prefered Scan");
+
+			//[TBD];
+			//MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CPOL_OPT);  //This return prefered Providers
+			MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_COPS_OPT); //[WorkAround] Adrian need to fix
+
+			//MBIM_FREE_CONTEXT(mContext);
+		}
+#else
+		MbimTelRequestVisibleProviders(mContext);
+		MBIM_LOGD("MBIM_CID_VISIBLE_PROVIDERS: CID_VisibleProviders Full scan");
+#endif
+	}
+
+	return rc;
+}
+
+
+
+/*******************************************************************************\
+*	Function:		CID_RegisterState
+*	Description:	MBIM_CID_REGISTER_STATE (Chapter 10.5.9)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_RegisterState(BASIC_CID_PARAMS)
+{
+	int 							rc					= MBIM_OK;
+	char							*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT			mContext			= NULL;
+	P_MBIM_SET_REGISTRATION_STATE	pSetRegisterState	= NULL;
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	//////////////////////////////////////////////////////
+	//Take care SET
+	/////////////////////////////////////////////////////
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		char		providerId[9] = {0};
+		int			mode, accessTechnology;
+
+		MBIM_LOGD("CID_RegisterState - SET");
+
+		pSetRegisterState = (P_MBIM_SET_REGISTRATION_STATE)infoBuf_p;
+		if (pSetRegisterState->registerAction == MBIMRegisterActionManual)
+		{
+			mode = TEL_REG_MODE_MANUAL;
+			copyUtf16ToStr(providerId, (infoBuf_p + pSetRegisterState->providerIdOffset), MIN(pSetRegisterState->providerIdSize,16));
+		}
+		else
+		{
+			mode = TEL_REG_MODE_AUTO;
+		}
+		accessTechnology = getRegisterTech(pSetRegisterState->dataClass);
+
+		MBIM_LOGD("CID_RegisterState - Mode = %d, providerId = %s, accessTechnology = %d",mode, providerId, accessTechnology );
+
+		//Send Command to server
+#if defined (MBIM_MTIL)
+		mtilSendCopsSet((void *)mContext, mode, accessTechnology, providerId);
+#else
+		MbimTelRequestNetworkSelection(mContext, mode, accessTechnology, providerId);
+#endif
+	}
+
+	//////////////////////////////////////////////////////
+	//Take care Get
+	/////////////////////////////////////////////////////
+	else
+	{
+		MBIM_LOGD("CID_RegisterState - GET");
+
+#if defined (MBIM_MTIL)
+		//Call the next AT command
+		MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGREG_GET);
+#else
+		MbimTelRequestRegistrationStatus(mContext);
+#endif
+	}
+
+	return rc;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_PacketService
+*	Description:	MBIM_CID_PACKET_SERVICE (Chapter 10.5.10)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_PacketService(BASIC_CID_PARAMS)
+{
+	int 						rc					= MBIM_OK;
+	char						*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT		mContext			= NULL;
+	P_MBIM_SET_PACKET_SERVICE	pSetPacketService	= NULL;
+#if defined (MBIM_MTIL)
+	UINT32						action;
+#endif
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+//ToDo - find alternative to packet service set and query
+
+	//////////////////////////////////////////////////////
+	//Take care SET
+	/////////////////////////////////////////////////////
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		pSetPacketService = (P_MBIM_SET_PACKET_SERVICE)infoBuf_p;
+
+		MBIM_LOGD("MBIM_CID_PACKET_SERVICE: SET. Action = %d", pSetPacketService->packetServiceAction);
+
+#if defined (MBIM_MTIL)
+		//Need to send command to Attach or detach
+		if (pSetPacketService->packetServiceAction == MBIMPacketServiceActionAttach)
+			action = 1;
+		else
+			action = 0;
+
+		MtilSendAtCgattSet((void *)mContext, action);
+#else
+		MbimTelRequestPacketService(mContext);
+#endif
+	}
+	else
+	{
+		MBIM_LOGD("MBIM_CID_PACKET_SERVICE: GET");
+
+#if defined (MBIM_MTIL)
+		//Call the next AT command
+		MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGATT_GET);
+#else
+		MbimTelRequestPacketServiceStatus(mContext);
+#endif
+	}
+
+
+	return rc;
+}
+
+
+
+/*******************************************************************************\
+*	Function:		CID_SignalState
+*	Description:	MBIM_CID_SIGNAL_STATE (Chapter 10.5.11)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_SignalState(BASIC_CID_PARAMS)
+{
+	P_MBIM_SET_SIGNAL_STATE		pSetSignalState	 = NULL;
+	MBIM_SIGNAL_STATE_INFO		signalStateInfo;
+	P_MBIM_MESSAGE_CONTEXT		mContext			= NULL;
+	char						*buf				= NULL;
+
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//If we received command we update the configuration
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		signalStateInfo.signalStrengthInterval	= (mbimDb.signalState.signalStrengthInterval?mbimDb.signalState.signalStrengthInterval:1);
+		signalStateInfo.RssiThreshold			= 0;//mbimDb.signalState.rssiThreshold;
+		signalStateInfo.errorRateThreshold		= CID_SIGNAL_STRENGTH_ERROR_RATE_THR_DONT_CARE;
+		signalStateInfo.rssi					= mbimDb.signalState.rssiDb;
+		signalStateInfo.errorRate				= CID_SIGNAL_STRENGTH_ERROR_RATE_UNKOWN;//CodeBer2MbimCodedValue(mbimDb.signalState.errorRate);
+
+		pSetSignalState	= (P_MBIM_SET_SIGNAL_STATE)infoBuf_p;
+		mbimDb.signalState.signalStrengthInterval 	= pSetSignalState->signalStrengthInterval;
+		mbimDb.signalState.rssiThreshold 			= pSetSignalState->rssiThreshold;
+		mbimDb.signalState.errorRateThreshold 		= pSetSignalState->errorRateThreshold;
+
+		//Send command done to host
+		MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, MBIM_STATUS_SUCCESS, sizeof(MBIM_SIGNAL_STATE_INFO), (char *)&signalStateInfo);
+	}
+	else
+	{
+		//Allocate buffer for response
+		ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+		//Creat the context for this command
+		CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+		MbimTelRequestSignalStrength(mContext);
+	}
+
+	return 0;
+}
+
+/*******************************************************************************\
+*	Function:		CID_Connect
+*	Description:	MBIM_CID_CONNECT (Chapter 10.5.12)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_Connect(BASIC_CID_PARAMS)
+{
+	int 						rc					= MBIM_OK;
+	char						*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT		mContext			= NULL;
+	P_MBIM_SET_CONNECT			pSetConnect			= NULL;
+	P_MBIM_CONNECT_INFO			connectInfoRsp;
+	int							mbimStatus 			= MBIM_STATUS_SUCCESS;
+
+	//////////////////////////////////////////////////////
+	//Take care of SET command
+	/////////////////////////////////////////////////////
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		//Allocate buffer for response
+		ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+		//Creat the context for this command
+		CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+		//save in context the requested configuration.	(Need to free buffer in failure below)
+		ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, infoBufLen);
+		memcpy( mContext->cmd, (char *)infoBuf_p, infoBufLen);
+
+		//BS: Turn off CID_CONNECT unsolicitate indication until COMMAND_DONE
+		disableUnsolCidConnect	=	TRUE;
+		MBIM_LOGD("MBIM_CID_CONNECT: disableUnsolCidConnect = %d", disableUnsolCidConnect);
+
+#if defined (MBIM_MTIL)
+		//Send Get
+		MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGDCONT_GET);
+#else
+		MbimTelRequestSetupDataCall(mContext);
+#endif
+	}
+
+	//////////////////////////////////////////////////////
+	//Take care of GET command
+	/////////////////////////////////////////////////////
+	else
+	{
+		P_MBIM_CONNECT_QUERY_INFO_EX3 pQuery = NULL;
+        int len = 0;
+        int sessionId = 0;
+
+        //Allocate buffer for response
+        ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+        
+        //Creat the context for this command
+        CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+        
+		connectInfoRsp = (P_MBIM_CONNECT_INFO)mContext->body;
+
+		if (mbimDb.mbimNegVersion >= MBIMEx_v3)
+        {      
+            pQuery = (P_MBIM_CONNECT_QUERY_INFO_EX3)infoBuf_p;
+            sessionId = pQuery->SessionId;
+            len = offsetof(MBIM_CONNECT_INFO, dataBuffer);
+        }
+        else
+        {
+		    pSetConnect = (P_MBIM_SET_CONNECT)infoBuf_p;
+            sessionId = pSetConnect->sessionId;
+            len = sizeof(MBIM_CONNECT_INFO_V1);
+        }
+
+		if (sessionId < MAX_NUM_OF_SESSIONS)
+		{
+			MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Cid = %d", sessionId, mbimDb.session[sessionId].cid);
+
+			if (mbimDb.session[sessionId].cid == 0)
+			{
+				memset(connectInfoRsp, 0, sizeof(MBIM_CONNECT_INFO));
+				connectInfoRsp->sessionId		= sessionId;
+				connectInfoRsp->activationState	= MBIMActivationStateDeactivated;
+				connectInfoRsp->ipType			= MBIMContextIPTypeIPv4;
+				connectInfoRsp->nwError			= CID_CONNECT_MBIM_STATUS_SUCCESS;
+                memcpy( (char *)connectInfoRsp->contextType.uuid, MBIMContextTypeNone, sizeof(MBIM_UUID));
+			}
+			else
+			{
+				connectInfoRsp->sessionId		= sessionId;
+
+				MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Activation State = %d", sessionId, mbimDb.session[sessionId].sessionState);
+				connectInfoRsp->activationState 	= mbimDb.session[sessionId].sessionState;
+
+				MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Voice Call State = %d", sessionId, mbimDb.session[sessionId].voiceCallState);
+				connectInfoRsp->voiceCallState		= mbimDb.session[sessionId].voiceCallState;
+
+				MBIM_LOGD("MBIM_CID_CONNECT: Session Id: %d, Ip type = %d", sessionId, mbimDb.session[sessionId].ipType);
+				connectInfoRsp->ipType			= mbimDb.session[sessionId].ipType;
+				connectInfoRsp->ipType			= MBIMContextIPTypeIPv4;	//adrian debug
+
+				memcpy( (char *)connectInfoRsp->contextType.uuid, (char *)&mbimDb.session[sessionId].contextType, sizeof(MBIM_UUID));
+				connectInfoRsp->nwError 			= CID_CONNECT_MBIM_STATUS_SUCCESS;
+
+				mbimDb.internetSessionId = sessionId;
+			}
+
+            if (mbimDb.mbimNegVersion >= MBIMEx_v3)
+            {
+            	if (mbimDb.session[sessionId].cid == 0)
+            	{
+	            	connectInfoRsp->AccessMedia = MBIMAccessMediaTypeNone;				
+					len += mbim_tlv_new((UINT8 *)connectInfoRsp + len, MBIM_TLV_TYPE_WCHAR_STR, NULL, 0);
+            	}
+				else
+				{
+                	connectInfoRsp->AccessMedia = MBIMAccessMediaType3GPP;                
+                	len += mbim_tlv_new_str((UINT8 *)connectInfoRsp + len, (UINT8 *)mbimDb.session[sessionId].APN, strlen(mbimDb.session[sessionId].APN));
+				}
+            } 
+		}
+		else
+		{
+			memset((char *)connectInfoRsp, 0, sizeof(MBIM_CONNECT_INFO));
+			connectInfoRsp->sessionId	= sessionId;
+ 			connectInfoRsp->nwError		= 0;
+            mbimStatus                  = (MBIM_STATUS_CODE_ENUM)CID_CONNECT_MBIM_STATUS_MAX_ACTIVATED_CONTEXTS;
+		}
+
+
+		//if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted)
+		//	mbimStatus = MBIM_STATUS_SIM_NOT_INSERTED;
+
+		//Send reponse to host
+		MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, mbimStatus, len, (char *)mContext->body);
+
+        MBIM_FREE_CONTEXT(mContext);
+	}
+
+	return rc;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_ProvisionedContexts
+*	Description:	MBIM_CID_PROVISIONED_CONTEXTS(Chapter 10.5.13)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_ProvisionedContexts(BASIC_CID_PARAMS)
+{
+	char								*buf						= NULL;
+	P_MBIM_MESSAGE_CONTEXT				mContext					= NULL;
+	int									rc 							= MBIM_STATUS_SUCCESS;
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	MBIM_LOGD("MBIM_CID_PROVISIONED_CONTEXTS:commandType = %d", commandType);
+
+
+	//save in context the requested configuration.	(Need to free buffer in failure below)
+	ALLOCATE_CMD_BUFFER(mContext, mContext->cmd, infoBufLen);
+	memcpy( mContext->cmd, (char *)infoBuf_p, infoBufLen);
+
+#if defined (MBIM_MTIL)
+	//Send Get
+	MtilSendGetNoParams((void *)mContext, MTIL_CODE_AT_CGDCONT_GET);
+#else
+	MbimTelRequestDataCallList((void *)mContext);
+#endif
+	return rc;
+}
+int	CID_ServiceActivation(BASIC_CID_PARAMS)
+{
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+	return 0;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_IpConfiguration
+*	Description:	MBIM_CID_IP_CONFIGURATION(Chapter 10.5.20)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int CID_IpConfiguration(BASIC_CID_PARAMS)
+{
+	char							*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT			mContext			= NULL;
+	P_MBIM_IP_CONFIGURATION_INFO	pIpConfigInfoCmd	= NULL;
+    int								rc 					= MBIM_STATUS_SUCCESS;
+#if 0
+	P_MBIM_IPV4_ELEMENT				pIpv4Element		= NULL;
+	P_MBIM_IPV4_ADDRESS				pIpv4Address		= NULL;
+	int								dataLen				= 0;   
+	P_MBIM_IP_CONFIGURATION_INFO	pIpConfigInfoRsp	= NULL;
+#endif
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//////////////////////////////////////////////////////
+	//We dont support SET command
+	/////////////////////////////////////////////////////
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+	//////////////////////////////////////////////////////
+	//Take care of QUERY command
+	/////////////////////////////////////////////////////
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	pIpConfigInfoCmd = (P_MBIM_IP_CONFIGURATION_INFO)infoBuf_p;
+
+	///////////////////////////////////////
+	//check for errors
+	///////////////////////////////////////
+	if (pIpConfigInfoCmd->sessionId > MAX_NUM_OF_SESSIONS)
+	{
+		MBIM_LOGE("IP Configuration: Received invalid Session ID = %d", pIpConfigInfoCmd->sessionId);
+		rc = MBIM_STATUS_CONTEXT_NOT_ACTIVATED;
+	}
+	if (rc != MBIM_STATUS_SUCCESS)
+	{
+		MbimSendFunctionErrorMsg(transactionId, rc);
+		MBIM_FREE_CONTEXT(mContext);
+		return 0;
+	}
+
+    MbimTelRequestIpConfig(mContext);
+
+	return rc;
+}
+
+/*******************************************************************************\
+*	Function:		MbimSetDeviceServiceSubscribeList
+*	Description:	ToDo - move to static functions....
+*	Parameters:
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+static void	MbimSetDeviceServiceSubscribeList	(P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST	pDevServSubsList)
+{
+	P_MBIM_EVENT_ENTRY	pMbimServiceElement;
+	UINT32				elementIdx, elementCount;
+	int					serviceIdx;
+	UINT32				cidCount,cidIdx;
+    char				filterArrayString1	[64];
+	char				filterArrayString	[256];
+	char				*pFilterArray;
+	UINT32				deviceServiceSubscribeRefListAddr;
+
+	elementCount	=	pDevServSubsList->elementCount;
+	MBIM_LOGD("%s: element count = %d", __FUNCTION__, elementCount);
+
+	if (elementCount > 0)
+	{
+		deviceServiceSubscribeRefListAddr	=	(UINT32)&pDevServSubsList->deviceServiceSubscribeRefList;
+		pMbimServiceElement	=	(P_MBIM_EVENT_ENTRY)(deviceServiceSubscribeRefListAddr + 8 * elementCount);
+
+		for (elementIdx = 0 ; elementIdx < elementCount ; elementIdx++)
+		{
+			serviceIdx	=	UUID2Index(&pMbimServiceElement->deviceServiceId);
+			MBIM_LOGD("%s: serviceIdx = %d", __FUNCTION__, serviceIdx);
+			if (cidsFilterArray[serviceIdx][0] == 0)
+			{
+				pMbimServiceElement	=	(P_MBIM_EVENT_ENTRY)((char *)pMbimServiceElement +
+										sizeof(pMbimServiceElement->deviceServiceId) +
+										sizeof(pMbimServiceElement->cidCount) +
+										(pMbimServiceElement->cidCount * sizeof(*pMbimServiceElement->dataBuffer)));
+				continue;
+			}
+
+			pFilterArray	=	(char *)cidsFilterArray[serviceIdx][0];
+			cidCount	=	pMbimServiceElement->cidCount;
+			MBIM_LOGD("%s: cidCount = %d, max = %d", __FUNCTION__, cidCount, cidsFilterArray[serviceIdx][1]);
+
+			if ((serviceIdx >= 0) && (cidCount > 0) && (cidCount < cidsFilterArray[serviceIdx][1]))
+			{
+				memset((void *)pFilterArray, 0, cidsFilterArray[serviceIdx][1]);
+				for (cidIdx = 0; cidIdx < cidCount; cidIdx++)
+				{
+					pFilterArray[pMbimServiceElement->dataBuffer[cidIdx]] = 1;
+				}
+
+				//Debug
+				sprintf (filterArrayString1, "service %d filter: ", serviceIdx);
+				for (cidIdx = 0; cidIdx < cidsFilterArray[serviceIdx][1]; cidIdx++)
+				{
+					sprintf (filterArrayString, "%s %u=%u ", filterArrayString1,
+							 (unsigned char)cidIdx, (unsigned char)pFilterArray[cidIdx]);
+				}
+				MBIM_LOGD("%s: %s", __FUNCTION__, filterArrayString);
+			}
+
+			pMbimServiceElement	=	(P_MBIM_EVENT_ENTRY)((char *)pMbimServiceElement +
+									sizeof(pMbimServiceElement->deviceServiceId) +
+									sizeof(pMbimServiceElement->cidCount) +
+									(pMbimServiceElement->cidCount * sizeof(*pMbimServiceElement->dataBuffer)));
+
+		}
+	}
+}
+
+/*******************************************************************************\
+*	Function:		CID_DeviceServicesSubscribeList
+*	Description:	MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST (Chapter 10.5.30)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_DeviceServicesSubscribeList(BASIC_CID_PARAMS)
+{
+	int										rc 					= MBIM_STATUS_SUCCESS;
+	char									*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT					mContext			= NULL;
+	P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST	pDevServSubsList	= NULL;
+
+	//////////////////////////////////////////////////////
+	//GET is not supported by this command
+	/////////////////////////////////////////////////////
+	if (commandType != MBIM_SET_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+
+	//////////////////////////////////////////////////////
+	//SET which Indications we want to receive
+	/////////////////////////////////////////////////////
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	//Copy request to context (we return the same request we received for now).
+	memcpy(buf, infoBuf_p, infoBufLen);
+
+	//MtilSendInden(mContext, TRUE);
+
+	pDevServSubsList = (P_MBIM_DEVICE_SERVICE_SUBSCRIBE_LIST)infoBuf_p;
+
+	MbimSetDeviceServiceSubscribeList(pDevServSubsList);
+
+	MbimSendCommandDone(transactionId, UUID_BASIC_CONNECT_INDEX, cid, MBIM_STATUS_SUCCESS, infoBufLen, (char *)pDevServSubsList);
+
+	MBIM_FREE_CONTEXT(mContext);
+
+	return rc;
+}
+
+
+int	CID_PacketStatistics(BASIC_CID_PARAMS)
+{
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+	return 0;
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_NetworkIdleHint
+*	Description:	MBIM_CID_NETWORK_IDLE_HINT (Chapter 10.5.35)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_NetworkIdleHint(BASIC_CID_PARAMS)
+{
+	int							rc = MBIM_STATUS_SUCCESS;
+	MBIM_NETWORK_IDLE_HINT		networkIdleHint;
+	P_MBIM_NETWORK_IDLE_HINT	pNetworkIdleHint;
+
+	MBIM_BASIC_UNUSEDPARAM();
+
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		//Pick up pointer to buffer
+		pNetworkIdleHint = (P_MBIM_NETWORK_IDLE_HINT)infoBuf_p;
+
+#if 0
+		if (pNetworkIdleHint->networkIdleHintState == MBIMNetworkIdleHintEnabled)
+			; //Check if we can enter Fast dormancy mode
+		else
+			; //Wake up
+#endif
+
+		//[TBD what to do --> Need to talk to power people] For now we just return the value
+		MbimSendCommandDone( transactionId,
+							 UUID_BASIC_CONNECT_INDEX,
+							 cid,
+							 MBIM_STATUS_SUCCESS,
+							 sizeof(MBIM_NETWORK_IDLE_HINT),
+							 (char *)pNetworkIdleHint);
+
+	}
+	else
+	{
+		//[TBD] We need to query the fast dormancy
+		networkIdleHint.networkIdleHintState = MBIMNetworkIdleHintDisabled;
+		MbimSendCommandDone( transactionId,
+							 UUID_BASIC_CONNECT_INDEX,
+							 cid,
+							 MBIM_STATUS_SUCCESS,
+							 sizeof(MBIM_NETWORK_IDLE_HINT),
+							 (char *)&networkIdleHint);
+	}
+
+	return rc;
+
+}
+
+
+/*******************************************************************************\
+*	Function:		CID_EmergencyMode
+*	Description:	MBIM_CID_EMERGENCY_MODE (Chapter 10.5.36)
+*	Parameters:   BASIC_CID_PARAMS - See description at the start of file
+*
+*	Returns:		0=OK, <0=Error Code
+\*******************************************************************************/
+int	CID_EmergencyMode(BASIC_CID_PARAMS)
+{
+	int							rc 				= MBIM_STATUS_SUCCESS;
+	char						*buf			= NULL;
+	P_MBIM_MESSAGE_CONTEXT		mContext		= NULL;
+	P_MBIM_EMERGENCY_MODE_INFO	pEmergencyMode	= NULL;
+	UINT32						mbimStatus		= MBIM_STATUS_SUCCESS;
+
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+
+	//////////////////////////////////////////////////////
+	//We dont support SET command
+	/////////////////////////////////////////////////////
+	if (commandType != MBIM_QUERY_COMMAND)
+	{
+		return CID_NotSupported(BASIC_CID_PARAMS_USAGE);
+	}
+
+#ifdef DUMMY
+	{
+		static int first = 0;
+
+		if (!first)
+		{
+			first = 1;
+			sendMbimSmsConfigurationInd();
+		}
+	}
+#endif
+
+	//Allocate buffer for response
+	ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+
+	//Creat the context for this command
+	CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+	//Pick up pointer to buffer
+	pEmergencyMode = (P_MBIM_EMERGENCY_MODE_INFO)buf;
+	pEmergencyMode->EmergencyMode = MBIMEmergencyModeOff;
+
+	if (mbimDb.sim.simReadyState == MBIMSubscriberReadyStateSimNotInserted)
+		mbimStatus = MBIM_STATUS_SIM_NOT_INSERTED;
+
+	MbimSendCommandDone( transactionId,
+						 UUID_BASIC_CONNECT_INDEX,
+						 cid,
+						 mbimStatus,
+						 sizeof(MBIM_EMERGENCY_MODE_INFO),
+						 (char *)pEmergencyMode);
+
+	MBIM_FREE_CONTEXT(mContext);
+	return rc;
+
+}
+
+int	CID_IpPacketFilters(BASIC_CID_PARAMS)
+{
+	int							rc = MBIM_STATUS_SUCCESS;
+	char						*buf				= NULL;
+	P_MBIM_MESSAGE_CONTEXT		mContext			= NULL;
+
+	P_MBIM_IP_PACKET_FILTER		pIpFilter;
+
+	//MBIM_BASIC_UNUSEDPARAM();
+
+	if (commandType == MBIM_SET_COMMAND)
+	{
+		pIpFilter	=	(P_MBIM_IP_PACKET_FILTER)infoBuf_p;
+		MbimSendCommandDone( transactionId,
+							 UUID_BASIC_CONNECT_INDEX,
+							 cid,
+							 MBIM_STATUS_SUCCESS,
+							 infoBufLen,
+							 (char *)pIpFilter);
+
+	}
+	else
+	{
+		ALLOCATE_RESPONSE_BUFFER(buf, DEFAULT_CONTEXT_ALLOC_SIZE);
+		CREATE_BASIC_CONNECT_CONTEXT(mContext, buf);
+
+		pIpFilter	=	(P_MBIM_IP_PACKET_FILTER)buf;
+		pIpFilter->packetFilterCount	=	0;
+
+		MbimSendCommandDone( transactionId,
+							 UUID_BASIC_CONNECT_INDEX,
+							 cid,
+							 MBIM_STATUS_SUCCESS,
+							 sizeof(MBIM_IP_PACKET_FILTER),
+							 (char *)pIpFilter);
+
+		MBIM_FREE_CONTEXT(mContext);
+	}
+
+	return rc;
+
+}
+
+int	CID_MultiCarrierProviders(BASIC_CID_PARAMS)
+{
+	//Added for compilation uof unused parameters on Codeline
+	MBIM_BASIC_UNUSEDPARAM();
+	return 0;
+}
+