Skip to content

Commit

Permalink
- IED SERVER: fixed bug when calling write access handler (wrong poin…
Browse files Browse the repository at this point in the history
…ter for ClientConnection object)
  • Loading branch information
mzillgith committed Jul 18, 2018
1 parent 47d3470 commit eacdfa9
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/beaglebone/beagle_demo.icd
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
</DOType>

<DOType cdc="SPG" id="SPG_0">
<DA name="setVal" bType="BOOLEAN" fc="SG" dchg="true" />
<DA name="setVal" bType="BOOLEAN" fc="SP" dchg="true" />
</DOType>

<DOType cdc="TSG" id="TSG_0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ controlHandlerForBinaryOutput(void* parameter, MmsValue* value, bool test)
MmsValue_delete(timeStamp);
}


static MmsDataAccessError
writeAccessHandler (DataAttribute* dataAttribute, MmsValue* value, ClientConnection connection, void* parameter)
{
void* securityToken = ClientConnection_getSecurityToken(connection);

if (securityToken != password2)
return DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED;

return DATA_ACCESS_ERROR_SUCCESS;
}



int main(int argc, char** argv) {

iedServer = IedServer_create(&iedModel);
Expand Down Expand Up @@ -153,6 +167,9 @@ int main(int argc, char** argv) {
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4,
(ControlHandler) controlHandlerForBinaryOutput, IEDMODEL_GenericIO_GGIO1_SPCSO4);

/* Set write access handler */
IedServer_handleWriteAccess(iedServer, IEDMODEL_GenericIO_LLN0_ModAuto_setVal, writeAccessHandler, NULL);

/* MMS server will be instructed to start listening to client connections. */
IedServer_start(iedServer, 102);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<DO name="Beh" type="INS_1_Beh" />
<DO name="Health" type="INS_1_Beh" />
<DO name="NamPlt" type="LPL_1_NamPlt" />
<DO name="ModAuto" type="SPG_0" />
</LNodeType>
<LNodeType id="LPHD1" lnClass="LPHD">
<DO name="PhyNam" type="DPL_1_PhyNam" />
Expand Down Expand Up @@ -186,6 +187,9 @@
<DA name="ctlModel" type="CtlModels" bType="Enum" fc="CF" />
<DA name="t" bType="Timestamp" fc="ST" />
</DOType>
<DOType cdc="SPG" id="SPG_0">
<DA name="setVal" bType="BOOLEAN" fc="SP" dchg="true" />
</DOType>
<DAType id="AnalogueValue_1">
<BDA name="f" bType="FLOAT32" />
</DAType>
Expand Down
28 changes: 25 additions & 3 deletions examples/server_example_password_auth/static_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* automatically generated from simpleIO_direct_control.icd
*/
#include "../server_example_password_auth/static_model.h"
#include "static_model.h"

static void initializeValues();

Expand Down Expand Up @@ -227,7 +227,7 @@ DataObject iedModel_GenericIO_LLN0_NamPlt = {
DataObjectModelType,
"NamPlt",
(ModelNode*) &iedModel_GenericIO_LLN0,
NULL,
(ModelNode*) &iedModel_GenericIO_LLN0_ModAuto,
(ModelNode*) &iedModel_GenericIO_LLN0_NamPlt_vendor,
0
};
Expand Down Expand Up @@ -297,6 +297,28 @@ DataAttribute iedModel_GenericIO_LLN0_NamPlt_ldNs = {
NULL,
0};

DataObject iedModel_GenericIO_LLN0_ModAuto = {
DataObjectModelType,
"ModAuto",
(ModelNode*) &iedModel_GenericIO_LLN0,
NULL,
(ModelNode*) &iedModel_GenericIO_LLN0_ModAuto_setVal,
0
};

DataAttribute iedModel_GenericIO_LLN0_ModAuto_setVal = {
DataAttributeModelType,
"setVal",
(ModelNode*) &iedModel_GenericIO_LLN0_ModAuto,
NULL,
NULL,
0,
IEC61850_FC_SP,
IEC61850_BOOLEAN,
0 + TRG_OPT_DATA_CHANGED,
NULL,
0};

LogicalNode iedModel_GenericIO_LPHD1 = {
LogicalNodeModelType,
"LPHD1",
Expand Down Expand Up @@ -1773,7 +1795,7 @@ DataAttribute iedModel_GenericIO_GGIO1_Ind4_t = {

extern ReportControlBlock iedModel_GenericIO_LLN0_report0;

ReportControlBlock iedModel_GenericIO_LLN0_report0 = {&iedModel_GenericIO_LLN0, "EventsRCB01", "Events", false, "Events", 1, 24, 111, 50, 1000, NULL};
ReportControlBlock iedModel_GenericIO_LLN0_report0 = {&iedModel_GenericIO_LLN0, "EventsRCB01", "Events", false, "Events", 1, 24, 239, 50, 1000, NULL};



Expand Down
4 changes: 4 additions & 0 deletions examples/server_example_password_auth/static_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extern DataAttribute iedModel_GenericIO_LLN0_NamPlt_swRev;
extern DataAttribute iedModel_GenericIO_LLN0_NamPlt_d;
extern DataAttribute iedModel_GenericIO_LLN0_NamPlt_configRev;
extern DataAttribute iedModel_GenericIO_LLN0_NamPlt_ldNs;
extern DataObject iedModel_GenericIO_LLN0_ModAuto;
extern DataAttribute iedModel_GenericIO_LLN0_ModAuto_setVal;
extern LogicalNode iedModel_GenericIO_LPHD1;
extern DataObject iedModel_GenericIO_LPHD1_PhyNam;
extern DataAttribute iedModel_GenericIO_LPHD1_PhyNam_vendor;
Expand Down Expand Up @@ -174,6 +176,8 @@ extern DataAttribute iedModel_GenericIO_GGIO1_Ind4_t;
#define IEDMODEL_GenericIO_LLN0_NamPlt_d (&iedModel_GenericIO_LLN0_NamPlt_d)
#define IEDMODEL_GenericIO_LLN0_NamPlt_configRev (&iedModel_GenericIO_LLN0_NamPlt_configRev)
#define IEDMODEL_GenericIO_LLN0_NamPlt_ldNs (&iedModel_GenericIO_LLN0_NamPlt_ldNs)
#define IEDMODEL_GenericIO_LLN0_ModAuto (&iedModel_GenericIO_LLN0_ModAuto)
#define IEDMODEL_GenericIO_LLN0_ModAuto_setVal (&iedModel_GenericIO_LLN0_ModAuto_setVal)
#define IEDMODEL_GenericIO_LPHD1 (&iedModel_GenericIO_LPHD1)
#define IEDMODEL_GenericIO_LPHD1_PhyNam (&iedModel_GenericIO_LPHD1_PhyNam)
#define IEDMODEL_GenericIO_LPHD1_PhyNam_vendor (&iedModel_GenericIO_LPHD1_PhyNam_vendor)
Expand Down
6 changes: 5 additions & 1 deletion src/iec61850/server/mms_mapping/mms_mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -2062,8 +2062,12 @@ mmsWriteHandler(void* parameter, MmsDomain* domain,
MmsValue* matchingValue = checkIfValueBelongsToModelNode(dataAttribute, cachedValue, value);

if (matchingValue != NULL) {

ClientConnection clientConnection = private_IedServer_getClientConnectionByHandle(self->iedServer,
connection);

MmsDataAccessError handlerResult =
accessHandler->handler(dataAttribute, matchingValue, (ClientConnection) connection,
accessHandler->handler(dataAttribute, matchingValue, clientConnection,
accessHandler->parameter);

if (handlerResult == DATA_ACCESS_ERROR_SUCCESS)
Expand Down

0 comments on commit eacdfa9

Please sign in to comment.