- added support for VMD scope named variable lists

pull/6/head
Michael Zillgith 10 years ago
parent 108332774f
commit b9c520240a

@ -116,7 +116,7 @@ void
MmsDomain_deleteNamedVariableList(MmsDomain* self, char* variableListName); MmsDomain_deleteNamedVariableList(MmsDomain* self, char* variableListName);
MmsNamedVariableList MmsNamedVariableList
MmsDomain_getNamedVariableList(MmsDomain* self, char* variableListName); MmsDomain_getNamedVariableList(MmsDomain* self, const char* variableListName);
LinkedList LinkedList
MmsDomain_getNamedVariableLists(MmsDomain* self); MmsDomain_getNamedVariableLists(MmsDomain* self);

@ -272,6 +272,9 @@ mmsServer_getLowIndex(AlternateAccess_t* alternateAccess);
int int
mmsServer_getNumberOfElements(AlternateAccess_t* alternateAccess); mmsServer_getNumberOfElements(AlternateAccess_t* alternateAccess);
MmsNamedVariableList
mmsServer_getNamedVariableListWithName(LinkedList namedVariableLists, const char* variableListName);
void void
mmsServer_deleteVariableList(LinkedList namedVariableLists, char* variableListName); mmsServer_deleteVariableList(LinkedList namedVariableLists, char* variableListName);

@ -77,26 +77,14 @@ MmsDomain_addNamedVariableList(MmsDomain* self, MmsNamedVariableList variableLis
} }
MmsNamedVariableList MmsNamedVariableList
MmsDomain_getNamedVariableList(MmsDomain* self, char* variableListName) MmsDomain_getNamedVariableList(MmsDomain* self, const char* variableListName)
{ {
MmsNamedVariableList variableList = NULL; MmsNamedVariableList variableList = NULL;
if (self == NULL) if (self == NULL)
goto exit_function; goto exit_function;
LinkedList element = LinkedList_getNext(self->namedVariableLists); variableList = mmsServer_getNamedVariableListWithName(self->namedVariableLists, variableListName);
while (element != NULL) {
MmsNamedVariableList varList = (MmsNamedVariableList) element->data;
if (strcmp(MmsNamedVariableList_getName(varList), variableListName) == 0) {
variableList = varList;
break;
}
element = LinkedList_getNext(element);
}
exit_function: exit_function:
return variableList; return variableList;

@ -266,7 +266,7 @@ getNamedVariableListsDomainSpecific(MmsServerConnection connection, char* domain
} }
static LinkedList static LinkedList
getnamedVariableListsVMDSpecific(MmsServerConnection connection) getNamedVariableListsVMDSpecific(MmsServerConnection connection)
{ {
MmsDevice* device = MmsServer_getDevice(connection->server); MmsDevice* device = MmsServer_getDevice(connection->server);
@ -555,7 +555,7 @@ mmsServer_handleGetNameListRequest(
#if (MMS_DATA_SET_SERVICE == 1) #if (MMS_DATA_SET_SERVICE == 1)
else if (objectClass == OBJECT_CLASS_NAMED_VARIABLE_LIST) { else if (objectClass == OBJECT_CLASS_NAMED_VARIABLE_LIST) {
LinkedList nameList = getnamedVariableListsVMDSpecific(connection); LinkedList nameList = getNamedVariableListsVMDSpecific(connection);
#if (CONFIG_MMS_SORT_NAME_LIST == 1) #if (CONFIG_MMS_SORT_NAME_LIST == 1)
StringUtils_sortList(nameList); StringUtils_sortList(nameList);

@ -179,6 +179,24 @@ mmsServer_handleDeleteNamedVariableListRequest(MmsServerConnection connection,
} }
} }
} }
else if (request->listOfVariableListName->list.array[i]->present == ObjectName_PR_vmdspecific) {
char listName[65];
mmsMsg_copyAsn1IdentifierToStringBuffer(request->listOfVariableListName->list.array[i]->choice.vmdspecific,
listName, 65);
MmsNamedVariableList variableList = mmsServer_getNamedVariableListWithName(device->namedVariableLists, listName);
if (variableList != NULL) {
numberMatched++;
if (mmsServer_callVariableListChangedHandler(false, MMS_VMD_SPECIFIC, NULL, listName, connection)
== MMS_ERROR_NONE) {
numberDeleted++;
mmsServer_deleteVariableList(device->namedVariableLists, listName);
}
}
}
} }
createDeleteNamedVariableListResponse(invokeId, response, numberMatched, numberDeleted); createDeleteNamedVariableListResponse(invokeId, response, numberMatched, numberDeleted);
@ -451,6 +469,7 @@ mmsServer_handleDefineNamedVariableListRequest(
char variableListName[65]; char variableListName[65];
if (request->variableListName.choice.aaspecific.size > 64) { if (request->variableListName.choice.aaspecific.size > 64) {
//TODO send reject PDU instead?
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
goto exit_free_struct; goto exit_free_struct;
} }
@ -487,6 +506,48 @@ mmsServer_handleDefineNamedVariableListRequest(
else else
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_RESOURCE_CAPABILITY_UNAVAILABLE); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_RESOURCE_CAPABILITY_UNAVAILABLE);
} }
else if (request->variableListName.present == ObjectName_PR_vmdspecific) {
LinkedList vmdScopeNVLs = MmsDevice_getNamedVariableLists(connection->server->device);
if (LinkedList_size(vmdScopeNVLs) < CONFIG_MMS_MAX_NUMBER_OF_VMD_SPECIFIC_DATA_SETS) {
char variableListName[65];
if (request->variableListName.choice.vmdspecific.size > 64) {
//TODO send reject PDU instead?
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
goto exit_free_struct;
}
StringUtils_createStringFromBufferInBuffer(variableListName,
request->variableListName.choice.vmdspecific.buf,
request->variableListName.choice.vmdspecific.size);
if (mmsServer_getNamedVariableListWithName(MmsDevice_getNamedVariableLists(connection->server->device), variableListName) != NULL) {
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_DEFINITION_OBJECT_EXISTS);
}
else {
MmsError mmsError;
MmsNamedVariableList namedVariableList = createNamedVariableList(NULL, device,
request, variableListName, &mmsError);
if (namedVariableList != NULL) {
if (mmsServer_callVariableListChangedHandler(true, MMS_VMD_SPECIFIC, NULL, variableListName, connection)
== MMS_ERROR_NONE) {
LinkedList_add(vmdScopeNVLs, (void*) namedVariableList);
createDefineNamedVariableListResponse(invokeId, response);
}
else {
MmsNamedVariableList_destroy(namedVariableList);
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_DENIED);
}
}
}
}
}
else else
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_DEFINITION_TYPE_UNSUPPORTED); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_DEFINITION_TYPE_UNSUPPORTED);
@ -635,6 +696,26 @@ mmsServer_handleGetNamedVariableListAttributesRequest(
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
} }
#endif /* (MMS_DYNAMIC_DATA_SETS == 1) */ #endif /* (MMS_DYNAMIC_DATA_SETS == 1) */
else if (request->present == ObjectName_PR_vmdspecific) {
char listName[65];
if (request->choice.vmdspecific.size > 64) {
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OTHER);
goto exit_function;
}
StringUtils_createStringFromBufferInBuffer(listName, request->choice.vmdspecific.buf,
request->choice.vmdspecific.size);
MmsDevice* mmsDevice = MmsServer_getDevice(connection->server);
MmsNamedVariableList varList = mmsServer_getNamedVariableListWithName(mmsDevice->namedVariableLists, listName);
if (varList != NULL)
createGetNamedVariableListAttributesResponse(invokeId, response, varList);
else
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
}
else { else {
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED);
} }

@ -663,6 +663,29 @@ handleReadNamedVariableListRequest(
} }
} }
} }
else if (read->variableAccessSpecification.choice.variableListName.present == ObjectName_PR_vmdspecific)
{
char listName[65];
mmsMsg_copyAsn1IdentifierToStringBuffer(read->variableAccessSpecification.choice.variableListName.choice.vmdspecific,
listName, 65);
MmsNamedVariableList namedList = mmsServer_getNamedVariableListWithName(connection->server->device->namedVariableLists, listName);
if (namedList == NULL)
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
else {
VarAccessSpec accessSpec;
accessSpec.isNamedVariableList = true;
accessSpec.specific = 0;
accessSpec.domainId = NULL;
accessSpec.itemId = listName;
createNamedVariableListResponse(connection, namedList, invokeId, response, read, &accessSpec);
}
}
#if (MMS_DYNAMIC_DATA_SETS == 1) #if (MMS_DYNAMIC_DATA_SETS == 1)
else if (read->variableAccessSpecification.choice.variableListName.present == else if (read->variableAccessSpecification.choice.variableListName.present ==
ObjectName_PR_aaspecific) ObjectName_PR_aaspecific)
@ -674,17 +697,18 @@ handleReadNamedVariableListRequest(
MmsNamedVariableList namedList = MmsServerConnection_getNamedVariableList(connection, listName); MmsNamedVariableList namedList = MmsServerConnection_getNamedVariableList(connection, listName);
VarAccessSpec accessSpec;
accessSpec.isNamedVariableList = true;
accessSpec.specific = 2;
accessSpec.domainId = NULL;
accessSpec.itemId = listName;
if (namedList == NULL) if (namedList == NULL)
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
else else {
VarAccessSpec accessSpec;
accessSpec.isNamedVariableList = true;
accessSpec.specific = 2;
accessSpec.domainId = NULL;
accessSpec.itemId = listName;
createNamedVariableListResponse(connection, namedList, invokeId, response, read, &accessSpec); createNamedVariableListResponse(connection, namedList, invokeId, response, read, &accessSpec);
}
} }
#endif /* (MMS_DYNAMIC_DATA_SETS == 1) */ #endif /* (MMS_DYNAMIC_DATA_SETS == 1) */
else else

@ -201,6 +201,28 @@ mmsServer_getNumberOfElements(AlternateAccess_t* alternateAccess)
return 0; return 0;
} }
MmsNamedVariableList
mmsServer_getNamedVariableListWithName(LinkedList namedVariableLists, const char* variableListName)
{
MmsNamedVariableList variableList = NULL;
LinkedList element = LinkedList_getNext(namedVariableLists);
while (element != NULL) {
MmsNamedVariableList varList = (MmsNamedVariableList) element->data;
if (strcmp(MmsNamedVariableList_getName(varList), variableListName) == 0) {
variableList = varList;
break;
}
element = LinkedList_getNext(element);
}
return variableList;
}
void void
mmsServer_deleteVariableList(LinkedList namedVariableLists, char* variableListName) mmsServer_deleteVariableList(LinkedList namedVariableLists, char* variableListName)
{ {

@ -355,23 +355,7 @@ MmsServerConnection_deleteNamedVariableList(MmsServerConnection self, char* list
MmsNamedVariableList MmsNamedVariableList
MmsServerConnection_getNamedVariableList(MmsServerConnection self, const char* variableListName) MmsServerConnection_getNamedVariableList(MmsServerConnection self, const char* variableListName)
{ {
//TODO remove code duplication - similar to MmsDomain_getNamedVariableList ! return mmsServer_getNamedVariableListWithName(self->namedVariableLists, variableListName);
MmsNamedVariableList variableList = NULL;
LinkedList element = LinkedList_getNext(self->namedVariableLists);
while (element != NULL) {
MmsNamedVariableList varList = (MmsNamedVariableList) element->data;
if (strcmp(MmsNamedVariableList_getName(varList), variableListName) == 0) {
variableList = varList;
break;
}
element = LinkedList_getNext(element);
}
return variableList;
} }
#endif /* (MMS_DYNAMIC_DATA_SETS == 1) */ #endif /* (MMS_DYNAMIC_DATA_SETS == 1) */

Loading…
Cancel
Save