- changed signature of WriteAccessHandler: Handler now return MmsDataAccessError instead of boolean value!

This commit is contained in:
Michael Zillgith 2015-06-10 14:26:39 +02:00
parent 8c91a53ea9
commit b1eda97ab4
10 changed files with 51 additions and 17 deletions

View file

@ -1,3 +1,8 @@
Changes to version 0.8.7
------------------------
- server: changed signature of WriteAccessHandler: Handler now return MmsDataAccessError instead of boolean value!
- server: added function IedModel_setIedNameForDynamicModel
Changes to version 0.8.6
------------------------
- demos: extended beaglebone demo to use SBO control

View file

@ -11,7 +11,7 @@ project(libiec61850)
set(LIB_VERSION_MAJOR "0")
set(LIB_VERSION_MINOR "8")
set(LIB_VERSION_PATCH "6")
set(LIB_VERSION_PATCH "7")
# feature checks
include(CheckLibraryExists)

View file

@ -141,7 +141,7 @@
/* default results for MMS identify service */
#define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com"
#define CONFIG_DEFAULT_MMS_MODEL_NAME "LIBIEC61850"
#define CONFIG_DEFAULT_MMS_REVISION "0.8.6"
#define CONFIG_DEFAULT_MMS_REVISION "0.8.7"
/* MMS virtual file store base path - where file services are looking for files */
#define CONFIG_VIRTUAL_FILESTORE_BASEPATH "./vmd-filestore/"

View file

@ -21,15 +21,24 @@ void sigint_handler(int signalId)
running = 0;
}
static bool
static MmsDataAccessError
writeAccessHandler (DataAttribute* dataAttribute, MmsValue* value, ClientConnection connection)
{
if (dataAttribute == IEDMODEL_Inverter_ZINV1_OutVarSet_setMag_f) {
printf("New value for OutVarSet_setMag_f = %f\n", MmsValue_toFloat(value));
return true;
float newValue = MmsValue_toFloat(value);
printf("New value for OutVarSet_setMag_f = %f\n", newValue);
/* Check if value is inside of valid range */
if ((newValue >= 0.f) && (newValue <= 1000.1f))
return DATA_ACCESS_ERROR_SUCCESS;
else
return DATA_ACCESS_ERROR_OBJECT_VALUE_INVALID;
}
return false;
return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED;
}
int main(int argc, char** argv) {

View file

@ -15,6 +15,20 @@
#include "platform_endian.h"
#define LIBIEC61850_VERSION "0.8.7"
#ifndef CONFIG_DEFAULT_MMS_VENDOR_NAME
#define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com"
#endif
#ifndef CONFIG_DEFAULT_MMS_MODEL_NAME
#define CONFIG_DEFAULT_MMS_MODEL_NAME "LIBIEC61850"
#endif
#ifndef CONFIG_DEFAULT_MMS_REVISION
#define CONFIG_DEFAULT_MMS_REVISION LIBIEC61850_VERSION
#endif
#if (DEBUG != 1)
#define NDEBUG 1
#endif

View file

@ -18,7 +18,7 @@ DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "libIEC61850"
PROJECT_NUMBER = 0.8.6
PROJECT_NUMBER = 0.8.7
PROJECT_BRIEF = "Open-source IEC 61850 MMS/GOOSE server and client library"

View file

@ -353,5 +353,5 @@ Timestamp_getTimeInMs(Timestamp* self)
char*
LibIEC61850_getVersionString()
{
return CONFIG_DEFAULT_MMS_REVISION;
return LIBIEC61850_VERSION;
}

View file

@ -958,12 +958,13 @@ IedServer_observeDataAttribute(IedServer self, DataAttribute* dataAttribute,
* is accepted.
*
* \param the data attribute that has been written by an MMS client.
* \param the value the client want to write to the data attribtue
* \param the value the client want to write to the data attribute
* \param connection the connection object of the client connection that invoked the write operation
*
* \return true if access is accepted, false if access is denied.
*/
typedef bool (*WriteAccessHandler) (DataAttribute* dataAttribute, MmsValue* value, ClientConnection connection);
typedef MmsDataAccessError
(*WriteAccessHandler) (DataAttribute* dataAttribute, MmsValue* value, ClientConnection connection);
/**
* \brief Install a WriteAccessHandler for a data attribute.

View file

@ -1825,21 +1825,28 @@ mmsWriteHandler(void* parameter, MmsDomain* domain,
MmsValue* matchingValue = checkIfValueBelongsToModelNode(dataAttribute, cachedValue, value);
if (matchingValue != NULL) {
if (accessHandler->handler(dataAttribute, matchingValue, (ClientConnection) connection))
MmsDataAccessError handlerResult =
accessHandler->handler(dataAttribute, matchingValue, (ClientConnection) connection);
if (handlerResult == DATA_ACCESS_ERROR_SUCCESS)
handlerFound = true;
else
return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED;
return handlerResult;
}
}
else { /* if ACCESS_POLICY_DENY only allow direct access to handled data attribute */
if (dataAttribute->mmsValue == cachedValue) {
if (accessHandler->handler(dataAttribute, value, (ClientConnection) connection)) {
MmsDataAccessError handlerResult =
accessHandler->handler(dataAttribute, value, (ClientConnection) connection);
if (handlerResult == DATA_ACCESS_ERROR_SUCCESS) {
handlerFound = true;
break;
}
else
return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED;
return handlerResult;
}
}
@ -1883,8 +1890,6 @@ mmsWriteHandler(void* parameter, MmsDomain* domain,
return DATA_ACCESS_ERROR_OBJECT_VALUE_INVALID;
}
printf("WRITE ACCESS DENIED!\n");
return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED;
}

View file

@ -44,7 +44,7 @@ extern "C" {
/**@{*/
typedef enum ATTRIBUTE_PACKED {
typedef enum {
DATA_ACCESS_ERROR_NO_RESPONSE = -2, /* for server internal purposes only! */
DATA_ACCESS_ERROR_SUCCESS = -1,
DATA_ACCESS_ERROR_OBJECT_INVALIDATED = 0,