diff --git a/examples/server_example_password_auth/server_example_password_auth.c b/examples/server_example_password_auth/server_example_password_auth.c index b66b469e..46715b1b 100644 --- a/examples/server_example_password_auth/server_example_password_auth.c +++ b/examples/server_example_password_auth/server_example_password_auth.c @@ -132,8 +132,13 @@ writeAccessHandler (DataAttribute* dataAttribute, MmsValue* value, ClientConnect { void* securityToken = ClientConnection_getSecurityToken(connection); - if (securityToken != password2) + if (dataAttribute == IEDMODEL_GenericIO_LLN0_ModAuto_setVal) + printf("Write access to LLN0.ModAuto.setVal: %i\n", MmsValue_getBoolean(value)); + + if (securityToken != password2) { + printf(" Access denied\n"); return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED; + } return DATA_ACCESS_ERROR_SUCCESS; } @@ -167,6 +172,9 @@ int main(int argc, char** argv) { IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4, (ControlHandler) controlHandlerForBinaryOutput, IEDMODEL_GenericIO_GGIO1_SPCSO4); + /* Allow only write access to settings that have a handler */ + IedServer_setWriteAccessPolicy(iedServer, IEC61850_FC_SP, ACCESS_POLICY_DENY); + /* Set write access handler */ IedServer_handleWriteAccess(iedServer, IEDMODEL_GenericIO_LLN0_ModAuto_setVal, writeAccessHandler, NULL); diff --git a/src/iec61850/server/mms_mapping/mms_mapping.c b/src/iec61850/server/mms_mapping/mms_mapping.c index 04163c71..5931a1c9 100644 --- a/src/iec61850/server/mms_mapping/mms_mapping.c +++ b/src/iec61850/server/mms_mapping/mms_mapping.c @@ -2079,8 +2079,12 @@ mmsWriteHandler(void* parameter, MmsDomain* domain, } else { /* if ACCESS_POLICY_DENY only allow direct access to handled data attribute */ if (dataAttribute->mmsValue == cachedValue) { + + ClientConnection clientConnection = private_IedServer_getClientConnectionByHandle(self->iedServer, + connection); + MmsDataAccessError handlerResult = - accessHandler->handler(dataAttribute, value, (ClientConnection) connection, + accessHandler->handler(dataAttribute, value, clientConnection, accessHandler->parameter); if (handlerResult == DATA_ACCESS_ERROR_SUCCESS) {