From b1eda97ab4494dd48d014e45c09373b0eb89f208 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Wed, 10 Jun 2015 14:26:39 +0200 Subject: [PATCH] - changed signature of WriteAccessHandler: Handler now return MmsDataAccessError instead of boolean value! --- CHANGELOG | 5 +++++ CMakeLists.txt | 2 +- config/stack_config.h | 2 +- examples/server_example5/server_example5.c | 17 +++++++++++++---- src/common/inc/libiec61850_platform_includes.h | 14 ++++++++++++++ src/doxygen.config | 2 +- src/iec61850/common/iec61850_common.c | 2 +- src/iec61850/inc/iec61850_server.h | 5 +++-- src/iec61850/server/mms_mapping/mms_mapping.c | 17 +++++++++++------ src/mms/inc/mms_value.h | 2 +- 10 files changed, 51 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1813db08..9b7a70c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6419c64d..13296b57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/config/stack_config.h b/config/stack_config.h index c5c9fd1a..49fb2e5c 100644 --- a/config/stack_config.h +++ b/config/stack_config.h @@ -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/" diff --git a/examples/server_example5/server_example5.c b/examples/server_example5/server_example5.c index c34f742b..21f5207a 100644 --- a/examples/server_example5/server_example5.c +++ b/examples/server_example5/server_example5.c @@ -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) { diff --git a/src/common/inc/libiec61850_platform_includes.h b/src/common/inc/libiec61850_platform_includes.h index 435b044c..9a9f9097 100644 --- a/src/common/inc/libiec61850_platform_includes.h +++ b/src/common/inc/libiec61850_platform_includes.h @@ -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 diff --git a/src/doxygen.config b/src/doxygen.config index 0d8fbf08..f6275955 100644 --- a/src/doxygen.config +++ b/src/doxygen.config @@ -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" diff --git a/src/iec61850/common/iec61850_common.c b/src/iec61850/common/iec61850_common.c index 9babce8e..53f8194b 100644 --- a/src/iec61850/common/iec61850_common.c +++ b/src/iec61850/common/iec61850_common.c @@ -353,5 +353,5 @@ Timestamp_getTimeInMs(Timestamp* self) char* LibIEC61850_getVersionString() { - return CONFIG_DEFAULT_MMS_REVISION; + return LIBIEC61850_VERSION; } diff --git a/src/iec61850/inc/iec61850_server.h b/src/iec61850/inc/iec61850_server.h index 617cb90c..263f6f52 100644 --- a/src/iec61850/inc/iec61850_server.h +++ b/src/iec61850/inc/iec61850_server.h @@ -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. diff --git a/src/iec61850/server/mms_mapping/mms_mapping.c b/src/iec61850/server/mms_mapping/mms_mapping.c index 8ee61286..c3fcc93c 100644 --- a/src/iec61850/server/mms_mapping/mms_mapping.c +++ b/src/iec61850/server/mms_mapping/mms_mapping.c @@ -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; } diff --git a/src/mms/inc/mms_value.h b/src/mms/inc/mms_value.h index 7f11956c..4c07e1a3 100644 --- a/src/mms/inc/mms_value.h +++ b/src/mms/inc/mms_value.h @@ -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,