Exemplo n.º 1
0
static void
handleReadNamedVariableListRequest(
		MmsServerConnection* connection,
		ReadRequest_t* read,
		int invokeId,
		ByteBuffer* response)
{
	if (read->variableAccessSpecification.choice.variableListName.present ==
			ObjectName_PR_domainspecific)
	{
		char* domainId = mmsMsg_createStringFromAsnIdentifier(
				read->variableAccessSpecification.choice.variableListName.choice.domainspecific.domainId);

		char* listName = mmsMsg_createStringFromAsnIdentifier(
				read->variableAccessSpecification.choice.variableListName.choice.domainspecific.itemId);

		VarAccessSpec accessSpec;

		accessSpec.isNamedVariableList = true;
		accessSpec.specific = 1;
		accessSpec.domainId = domainId;
		accessSpec.itemId = listName;

		MmsDomain* domain = MmsDevice_getDomain(MmsServer_getDevice(connection->server), domainId);

		if (domain == NULL) {
			if (DEBUG) printf("MMS read: domain %s not found!\n", domainId);
			mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_TYPE_OBJECT_NON_EXISTENT);
		}
		else {
			MmsNamedVariableList namedList = MmsDomain_getNamedVariableList(domain, listName);

			if (namedList != NULL) {
				createNamedVariableListResponse(connection, namedList, invokeId, response, read,
						&accessSpec);
			}
			else {
				if (DEBUG) printf("MMS read: named variable list %s not found!\n", listName);
				mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_TYPE_OBJECT_NON_EXISTENT);
			}
		}

		free(domainId);
		free(listName);
	}
	else if (read->variableAccessSpecification.choice.variableListName.present ==
				ObjectName_PR_aaspecific)
	{
		char* listName = mmsMsg_createStringFromAsnIdentifier(read->variableAccessSpecification.
				choice.variableListName.choice.aaspecific);

		MmsNamedVariableList namedList = MmsServerConnection_getNamedVariableList(connection, listName);

		VarAccessSpec accessSpec;

		accessSpec.isNamedVariableList = true;
		accessSpec.specific = 2;
		accessSpec.domainId = NULL;
		accessSpec.itemId = listName;

		if (namedList == NULL)
			mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_TYPE_OBJECT_NON_EXISTENT);
		else {
			createNamedVariableListResponse(connection, namedList, invokeId, response, read, &accessSpec);
		}

		free(listName);
	}
	else
		mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_TYPE_OBJECT_ACCESS_UNSUPPORTED);
}
Exemplo n.º 2
0
static void
handleReadNamedVariableListRequest(
		MmsServerConnection connection,
		ReadRequest_t* read,
		int invokeId,
		ByteBuffer* response)
{
	if (read->variableAccessSpecification.choice.variableListName.present ==
			ObjectName_PR_domainspecific)
	{
        char domainIdStr[65];
        char nameIdStr[65];

        mmsMsg_copyAsn1IdentifierToStringBuffer(read->variableAccessSpecification.choice.variableListName.choice.domainspecific.domainId,
                domainIdStr, 65);

        mmsMsg_copyAsn1IdentifierToStringBuffer(read->variableAccessSpecification.choice.variableListName.choice.domainspecific.itemId,
                nameIdStr, 65);

		VarAccessSpec accessSpec;

		accessSpec.isNamedVariableList = true;
		accessSpec.specific = 1;
		accessSpec.domainId = domainIdStr;
		accessSpec.itemId = nameIdStr;

		MmsDomain* domain = MmsDevice_getDomain(MmsServer_getDevice(connection->server), domainIdStr);

		if (domain == NULL) {
			if (DEBUG_MMS_SERVER) printf("MMS read: domain %s not found!\n", domainIdStr);
			mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
		}
		else {
			MmsNamedVariableList namedList = MmsDomain_getNamedVariableList(domain, nameIdStr);

			if (namedList != NULL) {
				createNamedVariableListResponse(connection, namedList, invokeId, response, read,
						&accessSpec);
			}
			else {
				if (DEBUG_MMS_SERVER) printf("MMS read: named variable list %s not found!\n", nameIdStr);
				mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
			}
		}
	}
#if (MMS_DYNAMIC_DATA_SETS == 1)
	else if (read->variableAccessSpecification.choice.variableListName.present ==
				ObjectName_PR_aaspecific)
	{
        char listName[65];

        mmsMsg_copyAsn1IdentifierToStringBuffer(read->variableAccessSpecification.choice.variableListName.choice.aaspecific,
                listName, 65);

		MmsNamedVariableList namedList = MmsServerConnection_getNamedVariableList(connection, listName);

		VarAccessSpec accessSpec;

		accessSpec.isNamedVariableList = true;
		accessSpec.specific = 2;
		accessSpec.domainId = NULL;
		accessSpec.itemId = listName;

		if (namedList == NULL)
			mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
		else
			createNamedVariableListResponse(connection, namedList, invokeId, response, read, &accessSpec);
	}
#endif /* (MMS_DYNAMIC_DATA_SETS == 1) */
	else
		mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED);
}