From 924b4ef5c14a4da9d4bccd9a145a70ecdf6e0f4e Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Tue, 12 Dec 2017 06:24:29 +0100 Subject: [PATCH] - IEC 61850/MMS server: removed deprecated AttributeChangedHandler --- CHANGELOG | 2 + src/iec61850/inc/iec61850_server.h | 30 ---------- src/iec61850/inc_private/ied_server_private.h | 1 - src/iec61850/inc_private/mms_mapping.h | 4 -- .../inc_private/mms_mapping_internal.h | 2 +- src/iec61850/server/impl/ied_server.c | 9 --- src/iec61850/server/mms_mapping/mms_mapping.c | 58 +++++-------------- src/vs/libiec61850-wo-goose.def | 1 - src/vs/libiec61850.def | 1 - 9 files changed, 18 insertions(+), 90 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 361d2173..6fc41699 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ Changes to version 1.2.0 ------------------------ +- IEC 61850/MMS client/server: Added TLS support (TLS API and implementation for mbedtls) +- IEC 61850/MMS server: removed deprecated AttributeChangedHandler - Added pkg-config file - The Sampled Values APIs have been renamed. The old version of the API is deprecated but still supported and will be removed in the next major version of the library. diff --git a/src/iec61850/inc/iec61850_server.h b/src/iec61850/inc/iec61850_server.h index bf63215c..5a5c66d1 100644 --- a/src/iec61850/inc/iec61850_server.h +++ b/src/iec61850/inc/iec61850_server.h @@ -1001,36 +1001,6 @@ IedServer_setSVCBHandler(IedServer self, SVControlBlock* svcb, SVCBEventHandler * @{ */ -/** - * \brief callback handler to monitor client access to data attributes - * - * User provided callback function to observe (monitor) MMS client access to - * IEC 61850 data attributes. The application can install the same handler - * multiple times and distinguish data attributes by the dataAttribute parameter. - * - * \param the data attribute that has been written by an MMS client. - * \param connection the connection object of the client connection that invoked the write operation - */ -typedef void (*AttributeChangedHandler) (DataAttribute* dataAttribute, ClientConnection connection); - -/** - * \deprecated Please use IedServer_handleWriteAccess instead! - * \brief Install an observer for a data attribute. - * - * This instructs the server to monitor write attempts by MMS clients to specific - * data attributes. If a successful write attempt happens the server will call - * the provided callback function to inform the application. This can be used to - * monitor important configuration values. - * - * \param self the instance of IedServer to operate on. - * \param dataAttribute the data attribute to monitor - * \param handler the callback function that is invoked if a client has written to - * the monitored data attribute. - */ -void -IedServer_observeDataAttribute(IedServer self, DataAttribute* dataAttribute, - AttributeChangedHandler handler); - /*************************************************************************** * Access control **************************************************************************/ diff --git a/src/iec61850/inc_private/ied_server_private.h b/src/iec61850/inc_private/ied_server_private.h index 07e2633b..32bf68d2 100644 --- a/src/iec61850/inc_private/ied_server_private.h +++ b/src/iec61850/inc_private/ied_server_private.h @@ -38,7 +38,6 @@ struct sIedServer IedModel* model; MmsDevice* mmsDevice; MmsServer mmsServer; - // IsoServer isoServer; char* localIpAddress; MmsMapping* mmsMapping; LinkedList clientConnections; diff --git a/src/iec61850/inc_private/mms_mapping.h b/src/iec61850/inc_private/mms_mapping.h index 0a1bb5a2..cff0969f 100644 --- a/src/iec61850/inc_private/mms_mapping.h +++ b/src/iec61850/inc_private/mms_mapping.h @@ -113,10 +113,6 @@ MmsMapping_addControlObject(MmsMapping* self, ControlObject* controlObject); char* MmsMapping_createMmsVariableNameFromObjectReference(const char* objectReference, FunctionalConstraint fc, char* buffer); -void -MmsMapping_addObservedAttribute(MmsMapping* self, DataAttribute* dataAttribute, - AttributeChangedHandler handler); - char* MmsMapping_getNextNameElement(char* name); diff --git a/src/iec61850/inc_private/mms_mapping_internal.h b/src/iec61850/inc_private/mms_mapping_internal.h index b5c193e6..52b7cf2d 100644 --- a/src/iec61850/inc_private/mms_mapping_internal.h +++ b/src/iec61850/inc_private/mms_mapping_internal.h @@ -51,7 +51,7 @@ struct sMmsMapping { #endif LinkedList controlObjects; - LinkedList observedObjects; + LinkedList attributeAccessHandlers; #if (CONFIG_IEC61850_SETTING_GROUPS == 1) diff --git a/src/iec61850/server/impl/ied_server.c b/src/iec61850/server/impl/ied_server.c index 76cbdf1a..3b9f7dc1 100644 --- a/src/iec61850/server/impl/ied_server.c +++ b/src/iec61850/server/impl/ied_server.c @@ -417,8 +417,6 @@ IedServer_createWithTlsSupport(IedModel* dataModel, TLSConfiguration tlsConfigur self->mmsDevice = MmsMapping_getMmsDeviceModel(self->mmsMapping); - // self->isoServer = IsoServer_create(); - self->mmsServer = MmsServer_create(self->mmsDevice, tlsConfiguration); MmsMapping_setMmsServer(self->mmsMapping, self->mmsServer); @@ -1238,13 +1236,6 @@ IedServer_disableGoosePublishing(IedServer self) #endif /* (CONFIG_INCLUDE_GOOSE_SUPPORT == 1) */ } -void -IedServer_observeDataAttribute(IedServer self, DataAttribute* dataAttribute, - AttributeChangedHandler handler) -{ - MmsMapping_addObservedAttribute(self->mmsMapping, dataAttribute, handler); -} - void IedServer_setWriteAccessPolicy(IedServer self, FunctionalConstraint fc, AccessPolicy policy) { diff --git a/src/iec61850/server/mms_mapping/mms_mapping.c b/src/iec61850/server/mms_mapping/mms_mapping.c index b3dab218..fd126193 100644 --- a/src/iec61850/server/mms_mapping/mms_mapping.c +++ b/src/iec61850/server/mms_mapping/mms_mapping.c @@ -1,7 +1,7 @@ /* * mms_mapping.c * - * Copyright 2013-2016 Michael Zillgith + * Copyright 2013-2017 Michael Zillgith * * This file is part of libIEC61850. * @@ -42,12 +42,6 @@ #define DEBUG_IED_SERVER 0 #endif -typedef struct -{ - DataAttribute* attribute; - AttributeChangedHandler handler; -} AttributeObserver; - typedef struct { DataAttribute* attribute; @@ -55,7 +49,6 @@ typedef struct void* parameter; } AttributeAccessHandler; - typedef struct { SettingGroupControlBlock* sgcb; @@ -1190,8 +1183,13 @@ createDataSets(MmsDevice* mmsDevice, IedModel* iedModel) int iedModelNameLength = strlen(iedModel->name); - if (iedModelNameLength > 64) - goto exit_function; //TODO call exception handler! + if (iedModelNameLength > 64) { + + if (DEBUG_IED_SERVER) + printf("IED_SERVER: IED model name too long!\n"); + + goto exit_function; + } while (dataset != NULL) { strncpy(domainName, iedModel->name, 64); @@ -1199,8 +1197,13 @@ createDataSets(MmsDevice* mmsDevice, IedModel* iedModel) MmsDomain* dataSetDomain = MmsDevice_getDomain(mmsDevice, domainName); - if (dataSetDomain == NULL) - goto exit_function; //TODO call exception handler! + if (dataSetDomain == NULL) { + + if (DEBUG_IED_SERVER) + printf("IED_SERVER: LD for dataset does not exist!\n"); + + goto exit_function; + } MmsNamedVariableList varList = MmsNamedVariableList_create(dataSetDomain, dataset->name, false); @@ -1289,8 +1292,6 @@ MmsMapping_create(IedModel* model) self->settingGroups = LinkedList_create(); #endif - self->observedObjects = LinkedList_create(); - self->attributeAccessHandlers = LinkedList_create(); self->mmsDevice = createMmsModelFromIedModel(self, model); @@ -1337,8 +1338,6 @@ MmsMapping_destroy(MmsMapping* self) LinkedList_destroyDeep(self->logInstances, (LinkedListValueDeleteFunction) LogInstance_destroy); #endif - LinkedList_destroy(self->observedObjects); - LinkedList_destroy(self->attributeAccessHandlers); IedModel_setAttributeValuesToNull(self->model); @@ -2093,21 +2092,6 @@ mmsWriteHandler(void* parameter, MmsDomain* domain, else return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED; - /* Call observer callback */ - LinkedList observerListElement = LinkedList_getNext(self->observedObjects); - - while (observerListElement != NULL) { - AttributeObserver* observer = (AttributeObserver*) observerListElement->data; - DataAttribute* dataAttribute = observer->attribute; - - if (checkIfValueBelongsToModelNode(dataAttribute, cachedValue, value) != NULL) { - observer->handler(dataAttribute, (ClientConnection) connection); - break; /* only all one handler per data attribute */ - } - - observerListElement = LinkedList_getNext(observerListElement); - } - return DATA_ACCESS_ERROR_SUCCESS; } else @@ -2117,18 +2101,6 @@ mmsWriteHandler(void* parameter, MmsDomain* domain, return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED; } -void -MmsMapping_addObservedAttribute(MmsMapping* self, DataAttribute* dataAttribute, - AttributeChangedHandler handler) -{ - AttributeObserver* observer = (AttributeObserver*) GLOBAL_MALLOC(sizeof(AttributeObserver)); - - observer->attribute = dataAttribute; - observer->handler = handler; - - LinkedList_add(self->observedObjects, observer); -} - static AttributeAccessHandler* getAccessHandlerForAttribute(MmsMapping* self, DataAttribute* dataAttribute) { diff --git a/src/vs/libiec61850-wo-goose.def b/src/vs/libiec61850-wo-goose.def index 804f4fea..d2defa15 100644 --- a/src/vs/libiec61850-wo-goose.def +++ b/src/vs/libiec61850-wo-goose.def @@ -167,7 +167,6 @@ EXPORTS IedServer_handleWriteAccess @421 IedServer_isRunning @422 IedServer_lockDataModel @423 - IedServer_observeDataAttribute @424 IedServer_setAuthenticator @425 IedServer_setConnectionIndicationHandler @426 IedServer_setControlHandler @427 diff --git a/src/vs/libiec61850.def b/src/vs/libiec61850.def index a5324701..909a3511 100644 --- a/src/vs/libiec61850.def +++ b/src/vs/libiec61850.def @@ -191,7 +191,6 @@ EXPORTS IedServer_handleWriteAccess @421 IedServer_isRunning @422 IedServer_lockDataModel @423 - IedServer_observeDataAttribute @424 IedServer_setAuthenticator @425 IedServer_setConnectionIndicationHandler @426 IedServer_setControlHandler @427