- added support for GetNamedVariableListRequests with aa-specific scope to server

pull/6/head
Michael Zillgith 11 years ago
parent 993d81116a
commit c1c60b6a24

@ -47,11 +47,14 @@ createString(int count, ...);
* to concatenate. * to concatenate.
*/ */
char* char*
createStringInBuffer(char* buffer, int count, ...); StringUtils_createStringInBuffer(char* buffer, int count, ...);
char* char*
createStringFromBuffer(const uint8_t* buf, int size); createStringFromBuffer(const uint8_t* buf, int size);
char*
StringUtils_createStringFromBufferInBuffer(char* newString, const uint8_t* buf, int size);
void void
StringUtils_replace(char* string, char oldChar, char newChar); StringUtils_replace(char* string, char oldChar, char newChar);

@ -71,9 +71,18 @@ createStringFromBuffer(const uint8_t* buf, int size)
return newStr; return newStr;
} }
char*
StringUtils_createStringFromBufferInBuffer(char* newString, const uint8_t* buf, int size)
{
memcpy(newString, buf, size);
newString[size] = 0;
return newString;
}
char* char*
createStringInBuffer(char* newStr, int count, ...) StringUtils_createStringInBuffer(char* newStr, int count, ...)
{ {
va_list ap; va_list ap;
char* currentPos = newStr; char* currentPos = newStr;

@ -207,7 +207,7 @@ initialize(ControlObject* self)
self->ctlObjectName = (char*) GLOBAL_MALLOC(130); self->ctlObjectName = (char*) GLOBAL_MALLOC(130);
createStringInBuffer(self->ctlObjectName, 5, MmsDomain_getName(self->mmsDomain), "/", StringUtils_createStringInBuffer(self->ctlObjectName, 5, MmsDomain_getName(self->mmsDomain), "/",
self->lnName, "$CO$", self->name); self->lnName, "$CO$", self->name);
self->error = MmsValue_newIntegerFromInt32(0); self->error = MmsValue_newIntegerFromInt32(0);
@ -845,7 +845,7 @@ ControlObject_sendCommandTerminationPositive(ControlObject* self)
{ {
char itemId[68]; /* 64 characters + space for FC + separator + string terminator */ char itemId[68]; /* 64 characters + space for FC + separator + string terminator */
createStringInBuffer(itemId, 4, self->lnName, "$CO$", self->name, "$Oper"); StringUtils_createStringInBuffer(itemId, 4, self->lnName, "$CO$", self->name, "$Oper");
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("IED_SERVER: send CommandTermination+: %s\n", itemId); printf("IED_SERVER: send CommandTermination+: %s\n", itemId);
@ -889,7 +889,7 @@ ControlObject_sendCommandTerminationNegative(ControlObject* self)
char ctlObj[130]; char ctlObj[130];
createStringInBuffer(ctlObj, 2, self->ctlObjectName, "$Oper"); StringUtils_createStringInBuffer(ctlObj, 2, self->ctlObjectName, "$Oper");
MmsValue ctlObjValueMemory; MmsValue ctlObjValueMemory;
@ -917,7 +917,7 @@ ControlObject_sendCommandTerminationNegative(ControlObject* self)
char itemId[130]; char itemId[130];
createStringInBuffer(itemId, 4, self->lnName, "$CO$", self->name, "$Oper"); StringUtils_createStringInBuffer(itemId, 4, self->lnName, "$CO$", self->name, "$Oper");
char* domainId = MmsDomain_getName(self->mmsDomain); char* domainId = MmsDomain_getName(self->mmsDomain);
@ -964,7 +964,7 @@ ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connec
char ctlObj[130]; char ctlObj[130];
createStringInBuffer(ctlObj, 3, self->ctlObjectName, "$", ctlVariable); StringUtils_createStringInBuffer(ctlObj, 3, self->ctlObjectName, "$", ctlVariable);
if (DEBUG_IED_SERVER) { if (DEBUG_IED_SERVER) {
printf("IED_SERVER: sendLastApplError:\n"); printf("IED_SERVER: sendLastApplError:\n");

@ -418,7 +418,7 @@ mmsServer_handleDefineNamedVariableListRequest(
static void static void
createGetNamedVariableListAttributesResponse(int invokeId, ByteBuffer* response, createGetNamedVariableListAttributesResponse(int invokeId, ByteBuffer* response,
MmsNamedVariableList variableList, char* domainName) MmsNamedVariableList variableList)
{ {
MmsPdu_t* mmsPdu = mmsServer_createConfirmedResponse(invokeId); MmsPdu_t* mmsPdu = mmsServer_createConfirmedResponse(invokeId);
@ -497,12 +497,19 @@ mmsServer_handleGetNamedVariableListAttributesRequest(
if (request->present == ObjectName_PR_domainspecific) { if (request->present == ObjectName_PR_domainspecific) {
char* domainName = createStringFromBuffer( char domainName[65];
request->choice.domainspecific.domainId.buf, char itemName[65];
if ((request->choice.domainspecific.domainId.size > 64) ||
(request->choice.domainspecific.itemId.size > 64)) {
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OTHER);
goto exit_function;
}
StringUtils_createStringFromBufferInBuffer(domainName, request->choice.domainspecific.domainId.buf,
request->choice.domainspecific.domainId.size); request->choice.domainspecific.domainId.size);
char* itemName = createStringFromBuffer( StringUtils_createStringFromBufferInBuffer(itemName, request->choice.domainspecific.itemId.buf,
request->choice.domainspecific.itemId.buf,
request->choice.domainspecific.itemId.size); request->choice.domainspecific.itemId.size);
MmsDevice* mmsDevice = MmsServer_getDevice(connection->server); MmsDevice* mmsDevice = MmsServer_getDevice(connection->server);
@ -514,21 +521,41 @@ mmsServer_handleGetNamedVariableListAttributesRequest(
MmsDomain_getNamedVariableList(domain, itemName); MmsDomain_getNamedVariableList(domain, itemName);
if (variableList != NULL) if (variableList != NULL)
createGetNamedVariableListAttributesResponse(invokeId, response, variableList, domainName); createGetNamedVariableListAttributesResponse(invokeId, response, variableList);
else else
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
} }
else else
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT); mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT);
}
else if (request->present == ObjectName_PR_aaspecific) {
GLOBAL_FREEMEM(domainName); char listName[65];
GLOBAL_FREEMEM(itemName);
if (request->choice.aaspecific.size > 64) {
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_ACCESS_OTHER);
goto exit_function;
}
StringUtils_createStringFromBufferInBuffer(listName, request->choice.aaspecific.buf,
request->choice.aaspecific.size);
MmsDevice* mmsDevice = MmsServer_getDevice(connection->server);
MmsNamedVariableList varList = MmsServerConnection_getNamedVariableList(connection, 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);
} }
exit_function:
asn_DEF_GetVariableAccessAttributesRequest.free_struct(&asn_DEF_GetNamedVariableListAttributesRequest, asn_DEF_GetVariableAccessAttributesRequest.free_struct(&asn_DEF_GetNamedVariableListAttributesRequest,
request, 0); request, 0);
} }

@ -71,7 +71,7 @@ addNamedVariableValue(MmsVariableSpecification* namedVariable, MmsServerConnecti
for (i = 0; i < componentCount; i++) { for (i = 0; i < componentCount; i++) {
char newNameIdStr[65]; char newNameIdStr[65];
createStringInBuffer(newNameIdStr, 3, itemId, "$", StringUtils_createStringInBuffer(newNameIdStr, 3, itemId, "$",
namedVariable->typeSpec.structure.elements[i]->name); namedVariable->typeSpec.structure.elements[i]->name);
MmsValue* element = MmsValue* element =

Loading…
Cancel
Save