From 5bc9834b74140e06d96221ed087f78b1d8e5d571 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Wed, 21 Jan 2015 17:50:43 +0100 Subject: [PATCH 1/6] - client updates internal ctlVal on operate and SBOw, and opertime on operate --- src/iec61850/client/client_control.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/iec61850/client/client_control.c b/src/iec61850/client/client_control.c index 9a24e2f..dc662a8 100644 --- a/src/iec61850/client/client_control.c +++ b/src/iec61850/client/client_control.c @@ -423,6 +423,9 @@ ControlObjectClient_operate(ControlObjectClient self, MmsValue* ctlVal, uint64_t goto exit_function; } + MmsValue_update(self->ctlVal, ctlVal); + self->opertime = operTime; + success = true; exit_function: @@ -503,6 +506,8 @@ ControlObjectClient_selectWithValue(ControlObjectClient self, MmsValue* ctlVal) return false; } + MmsValue_update(self->ctlVal, ctlVal); + return true; } From 1450d84eaf612ef73f150d37fd7469a219222651 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 22 Jan 2015 11:13:39 +0100 Subject: [PATCH 2/6] - removed remaining calls to malloc, calloc, free. Replaced by GLOBAL_.. macros. --- src/iec61850/server/mms_mapping/control.c | 22 +++++++++++----------- src/mms/iso_mms/client/mms_client_read.c | 4 ++-- src/mms/iso_mms/client/mms_client_write.c | 6 +----- src/mms/iso_mms/server/mms_device.c | 2 +- src/mms/iso_server/iso_server.c | 2 +- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/iec61850/server/mms_mapping/control.c b/src/iec61850/server/mms_mapping/control.c index 84c4387..227b2fc 100644 --- a/src/iec61850/server/mms_mapping/control.c +++ b/src/iec61850/server/mms_mapping/control.c @@ -197,15 +197,15 @@ initialize(ControlObject* self) printf("No control model found for variable %s\n", ctlModelName); } - free(ctlModelName); + GLOBAL_FREEMEM(ctlModelName); char* sboClassName = createString(4, self->lnName, "$CF$", self->name, "$sboClass"); self->sboClass = MmsServer_getValueFromCache(mmsServer, self->mmsDomain, sboClassName); - free(sboClassName); + GLOBAL_FREEMEM(sboClassName); - self->ctlObjectName = (char*) malloc(130); + self->ctlObjectName = (char*) GLOBAL_MALLOC(130); createStringInBuffer(self->ctlObjectName, 5, MmsDomain_getName(self->mmsDomain), "/", self->lnName, "$CO$", self->name); @@ -239,8 +239,8 @@ initialize(ControlObject* self) if (DEBUG_IED_SERVER) printf("timeout for %s is %i\n", sboTimeoutName, self->selectTimeout); - free(controlObjectReference); - free(sboTimeoutName); + GLOBAL_FREEMEM(controlObjectReference); + GLOBAL_FREEMEM(sboTimeoutName); } else { self->sbo = MmsValue_newVisibleString(NULL); @@ -475,7 +475,7 @@ ControlObject_destroy(ControlObject* self) MmsValue_delete(self->emptyString); if (self->ctlObjectName != NULL) - free(self->ctlObjectName); + GLOBAL_FREEMEM(self->ctlObjectName); if (self->error != NULL) MmsValue_delete(self->error); @@ -493,14 +493,14 @@ ControlObject_destroy(ControlObject* self) MmsValue_delete(self->origin); if (self->name != NULL) - free(self->name); + GLOBAL_FREEMEM(self->name); #if (CONFIG_MMS_THREADLESS_STACK != 1) if (self->stateLock != NULL) Semaphore_destroy(self->stateLock); #endif - free(self); + GLOBAL_FREEMEM(self); } void @@ -1214,10 +1214,10 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari if (DEBUG_IED_SERVER) printf("IED_SERVER: writeAccessControlObject: %s\n", variableIdOrig); - char variableId[129]; + char variableId[65]; - strncpy(variableId, variableIdOrig, 128); - variableId[128] = 0; + strncpy(variableId, variableIdOrig, 64); + variableId[64] = 0; char* separator = strchr(variableId, '$'); diff --git a/src/mms/iso_mms/client/mms_client_read.c b/src/mms/iso_mms/client/mms_client_read.c index fdeab19..c1f0aae 100644 --- a/src/mms/iso_mms/client/mms_client_read.c +++ b/src/mms/iso_mms/client/mms_client_read.c @@ -299,7 +299,7 @@ mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* doma ReadRequest_t* readRequest = createReadRequest(mmsPdu); if (specWithResult) { - readRequest->specificationWithResult = (BOOLEAN_t*) calloc(1, sizeof(BOOLEAN_t)); + readRequest->specificationWithResult = (BOOLEAN_t*) GLOBAL_CALLOC(1, sizeof(BOOLEAN_t)); (*(readRequest->specificationWithResult)) = true; } else @@ -339,7 +339,7 @@ mmsClient_createReadAssociationSpecificNamedVariableListRequest( ReadRequest_t* readRequest = createReadRequest(mmsPdu); if (specWithResult) { - readRequest->specificationWithResult = (BOOLEAN_t*) calloc(1, sizeof(BOOLEAN_t)); + readRequest->specificationWithResult = (BOOLEAN_t*) GLOBAL_CALLOC(1, sizeof(BOOLEAN_t)); (*(readRequest->specificationWithResult)) = true; } else diff --git a/src/mms/iso_mms/client/mms_client_write.c b/src/mms/iso_mms/client/mms_client_write.c index 5657ef4..a32a07f 100644 --- a/src/mms/iso_mms/client/mms_client_write.c +++ b/src/mms/iso_mms/client/mms_client_write.c @@ -176,8 +176,6 @@ createNewDomainVariableSpecification(const char* domainId, const char* itemId) { VariableSpecification_t* varSpec = (VariableSpecification_t*) GLOBAL_CALLOC(1, sizeof(ListOfVariableSeq_t)); - //VariableSpecification_t* varSpec = (VariableSpecification_t*) calloc(1, sizeof(VariableSpecification_t)); - varSpec->present = VariableSpecification_PR_name; varSpec->choice.name.present = ObjectName_PR_domainspecific; varSpec->choice.name.choice.domainspecific.domainId.buf = (uint8_t*) domainId; @@ -191,10 +189,8 @@ createNewDomainVariableSpecification(const char* domainId, const char* itemId) static void deleteDataElement(Data_t* dataElement) { - if (dataElement == NULL ) { - printf("deleteDataElement NULL argument\n"); + if (dataElement == NULL) return; - } if (dataElement->present == Data_PR_structure) { int elementCount = dataElement->choice.structure->list.count; diff --git a/src/mms/iso_mms/server/mms_device.c b/src/mms/iso_mms/server/mms_device.c index f071a63..1f2e0cf 100644 --- a/src/mms/iso_mms/server/mms_device.c +++ b/src/mms/iso_mms/server/mms_device.c @@ -51,7 +51,7 @@ MmsDevice_destroy(MmsDevice* self) MmsVariableSpecification_destroy(self->namedVariables[i]); } - free (self->namedVariables); + GLOBAL_FREEMEM(self->namedVariables); } #endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */ diff --git a/src/mms/iso_server/iso_server.c b/src/mms/iso_server/iso_server.c index 7bdbbba..7bcb8f0 100644 --- a/src/mms/iso_server/iso_server.c +++ b/src/mms/iso_server/iso_server.c @@ -526,7 +526,7 @@ IsoServer_waitReady(IsoServer self, unsigned int timeoutMs) } else { IsoConnection_destroy(isoConnection); lastConnection->next = openConnection->next; - free(openConnection); + GLOBAL_FREEMEM(openConnection); openConnection = lastConnection->next; } From a3ae9cb589588d940847d03a000baf5563833dc6 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 22 Jan 2015 12:26:09 +0100 Subject: [PATCH 3/6] - added additional "const" modifiers to API functions --- examples/server_example1/static_model.c | 3 ++ examples/server_example2/static_model.c | 5 +++ examples/server_example3/static_model.c | 16 ++++++++++ examples/server_example4/static_model.c | 4 +++ examples/server_example5/static_model.c | 4 +++ examples/server_example_goose/static_model.c | 8 +++++ .../server_example_threadless/static_model.c | 8 +++++ src/iec61850/client/client_control.c | 4 +-- src/iec61850/client/client_goose_control.c | 10 +++--- src/iec61850/client/client_report.c | 8 ++--- src/iec61850/client/client_report_control.c | 10 +++--- src/iec61850/client/ied_connection.c | 2 +- src/iec61850/common/iec61850_common.c | 6 ++-- src/iec61850/inc/iec61850_client.h | 26 +++++++-------- src/iec61850/inc/iec61850_common.h | 6 ++-- src/mms/inc/mms_value.h | 22 ++++++------- src/mms/iso_mms/common/mms_value.c | 32 +++++++++---------- 17 files changed, 111 insertions(+), 63 deletions(-) diff --git a/examples/server_example1/static_model.c b/examples/server_example1/static_model.c index 3abfe08..a5f5dcf 100644 --- a/examples/server_example1/static_model.c +++ b/examples/server_example1/static_model.c @@ -149,6 +149,7 @@ extern DataSetEntry ds_Device1_LLN0_dataset1_fcda2; DataSetEntry ds_Device1_LLN0_dataset1_fcda0 = { "Device1", + false, "LLN0$ST$Mod$q", -1, NULL, @@ -158,6 +159,7 @@ DataSetEntry ds_Device1_LLN0_dataset1_fcda0 = { DataSetEntry ds_Device1_LLN0_dataset1_fcda1 = { "Device1", + false, "MMXU1$ST$Mod$q", -1, NULL, @@ -167,6 +169,7 @@ DataSetEntry ds_Device1_LLN0_dataset1_fcda1 = { DataSetEntry ds_Device1_LLN0_dataset1_fcda2 = { "Device1", + false, "MMXU1$CF$Mod$ctlModel", -1, NULL, diff --git a/examples/server_example2/static_model.c b/examples/server_example2/static_model.c index fbc3cfa..a483753 100644 --- a/examples/server_example2/static_model.c +++ b/examples/server_example2/static_model.c @@ -315,6 +315,7 @@ extern DataSetEntry ds_Inverter_LLN0_dataset1_fcda4; DataSetEntry ds_Inverter_LLN0_dataset1_fcda0 = { "Inverter", + false, "LLN0$ST$Mod$q", -1, NULL, @@ -324,6 +325,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda0 = { DataSetEntry ds_Inverter_LLN0_dataset1_fcda1 = { "Battery", + false, "LLN0$ST$Mod$q", -1, NULL, @@ -333,6 +335,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda1 = { DataSetEntry ds_Inverter_LLN0_dataset1_fcda2 = { "Inverter", + false, "MMXU1$ST$Mod$q", -1, NULL, @@ -342,6 +345,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda2 = { DataSetEntry ds_Inverter_LLN0_dataset1_fcda3 = { "Inverter", + false, "MMXU1$CF$Mod$ctlModel", -1, NULL, @@ -351,6 +355,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda3 = { DataSetEntry ds_Inverter_LLN0_dataset1_fcda4 = { "Inverter", + false, "MMXU1$MX$TotW$mag", -1, NULL, diff --git a/examples/server_example3/static_model.c b/examples/server_example3/static_model.c index 90a4eb5..eb1941b 100644 --- a/examples/server_example3/static_model.c +++ b/examples/server_example3/static_model.c @@ -162,6 +162,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3; DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { "GenericIO", + false, "GGIO1$ST$SPCSO1$stVal", -1, NULL, @@ -171,6 +172,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { "GenericIO", + false, "GGIO1$ST$SPCSO2$stVal", -1, NULL, @@ -180,6 +182,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { "GenericIO", + false, "GGIO1$ST$SPCSO3$stVal", -1, NULL, @@ -189,6 +192,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = { "GenericIO", + false, "GGIO1$ST$SPCSO4$stVal", -1, NULL, @@ -211,6 +215,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events2_fcda3; DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = { "GenericIO", + false, "GGIO1$ST$SPCSO1", -1, NULL, @@ -220,6 +225,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = { "GenericIO", + false, "GGIO1$ST$SPCSO2", -1, NULL, @@ -229,6 +235,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = { "GenericIO", + false, "GGIO1$ST$SPCSO3", -1, NULL, @@ -238,6 +245,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Events2_fcda3 = { "GenericIO", + false, "GGIO1$ST$SPCSO4", -1, NULL, @@ -264,6 +272,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Measurements_fcda7; DataSetEntry ds_GenericIO_LLN0_Measurements_fcda0 = { "GenericIO", + false, "GGIO1$MX$AnIn1$mag$f", -1, NULL, @@ -273,6 +282,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Measurements_fcda1 = { "GenericIO", + false, "GGIO1$MX$AnIn1$q", -1, NULL, @@ -282,6 +292,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Measurements_fcda2 = { "GenericIO", + false, "GGIO1$MX$AnIn2$mag$f", -1, NULL, @@ -291,6 +302,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Measurements_fcda3 = { "GenericIO", + false, "GGIO1$MX$AnIn2$q", -1, NULL, @@ -300,6 +312,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda3 = { DataSetEntry ds_GenericIO_LLN0_Measurements_fcda4 = { "GenericIO", + false, "GGIO1$MX$AnIn3$mag$f", -1, NULL, @@ -309,6 +322,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda4 = { DataSetEntry ds_GenericIO_LLN0_Measurements_fcda5 = { "GenericIO", + false, "GGIO1$MX$AnIn3$q", -1, NULL, @@ -318,6 +332,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda5 = { DataSetEntry ds_GenericIO_LLN0_Measurements_fcda6 = { "GenericIO", + false, "GGIO1$MX$AnIn4$mag$f", -1, NULL, @@ -327,6 +342,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda6 = { DataSetEntry ds_GenericIO_LLN0_Measurements_fcda7 = { "GenericIO", + false, "GGIO1$MX$AnIn4$q", -1, NULL, diff --git a/examples/server_example4/static_model.c b/examples/server_example4/static_model.c index 0897448..6bee7ce 100644 --- a/examples/server_example4/static_model.c +++ b/examples/server_example4/static_model.c @@ -159,6 +159,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3; DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { "GenericIO", + false, "GGIO1$ST$SPCSO1$stVal", -1, NULL, @@ -168,6 +169,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { "GenericIO", + false, "GGIO1$ST$SPCSO2$stVal", -1, NULL, @@ -177,6 +179,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { "GenericIO", + false, "GGIO1$ST$SPCSO3$stVal", -1, NULL, @@ -186,6 +189,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = { "GenericIO", + false, "GGIO1$ST$SPCSO4$stVal", -1, NULL, diff --git a/examples/server_example5/static_model.c b/examples/server_example5/static_model.c index 0897448..6bee7ce 100644 --- a/examples/server_example5/static_model.c +++ b/examples/server_example5/static_model.c @@ -159,6 +159,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3; DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { "GenericIO", + false, "GGIO1$ST$SPCSO1$stVal", -1, NULL, @@ -168,6 +169,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { "GenericIO", + false, "GGIO1$ST$SPCSO2$stVal", -1, NULL, @@ -177,6 +179,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { "GenericIO", + false, "GGIO1$ST$SPCSO3$stVal", -1, NULL, @@ -186,6 +189,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = { "GenericIO", + false, "GGIO1$ST$SPCSO4$stVal", -1, NULL, diff --git a/examples/server_example_goose/static_model.c b/examples/server_example_goose/static_model.c index 2beaeac..e1bcf92 100644 --- a/examples/server_example_goose/static_model.c +++ b/examples/server_example_goose/static_model.c @@ -160,6 +160,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3; DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { "GenericIO", + false, "GGIO1$ST$SPCSO1$stVal", -1, NULL, @@ -169,6 +170,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { "GenericIO", + false, "GGIO1$ST$SPCSO2$stVal", -1, NULL, @@ -178,6 +180,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { "GenericIO", + false, "GGIO1$ST$SPCSO3$stVal", -1, NULL, @@ -187,6 +190,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = { "GenericIO", + false, "GGIO1$ST$SPCSO4$stVal", -1, NULL, @@ -209,6 +213,7 @@ extern DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda3; DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda0 = { "GenericIO", + false, "GGIO1$MX$AnIn1", -1, NULL, @@ -218,6 +223,7 @@ DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda0 = { DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda1 = { "GenericIO", + false, "GGIO1$MX$AnIn2", -1, NULL, @@ -227,6 +233,7 @@ DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda1 = { DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda2 = { "GenericIO", + false, "GGIO1$MX$AnIn3", -1, NULL, @@ -236,6 +243,7 @@ DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda2 = { DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda3 = { "GenericIO", + false, "GGIO1$MX$AnIn4", -1, NULL, diff --git a/examples/server_example_threadless/static_model.c b/examples/server_example_threadless/static_model.c index 9001748..f63c227 100644 --- a/examples/server_example_threadless/static_model.c +++ b/examples/server_example_threadless/static_model.c @@ -161,6 +161,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3; DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { "GenericIO", + false, "GGIO1$ST$SPCSO1$stVal", -1, NULL, @@ -170,6 +171,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { "GenericIO", + false, "GGIO1$ST$SPCSO2$stVal", -1, NULL, @@ -179,6 +181,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { "GenericIO", + false, "GGIO1$ST$SPCSO3$stVal", -1, NULL, @@ -188,6 +191,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = { "GenericIO", + false, "GGIO1$ST$SPCSO4$stVal", -1, NULL, @@ -210,6 +214,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events2_fcda3; DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = { "GenericIO", + false, "GGIO1$ST$SPCSO1", -1, NULL, @@ -219,6 +224,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = { DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = { "GenericIO", + false, "GGIO1$ST$SPCSO2", -1, NULL, @@ -228,6 +234,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = { DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = { "GenericIO", + false, "GGIO1$ST$SPCSO3", -1, NULL, @@ -237,6 +244,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = { DataSetEntry ds_GenericIO_LLN0_Events2_fcda3 = { "GenericIO", + false, "GGIO1$ST$SPCSO4", -1, NULL, diff --git a/src/iec61850/client/client_control.c b/src/iec61850/client/client_control.c index dc662a8..ff8c346 100644 --- a/src/iec61850/client/client_control.c +++ b/src/iec61850/client/client_control.c @@ -65,7 +65,7 @@ struct sControlObjectClient }; static void -convertToMmsAndInsertFC(char* newItemId, char* originalObjectName, char* fc) +convertToMmsAndInsertFC(char* newItemId, const char* originalObjectName, const char* fc) { int originalLength = strlen(originalObjectName); @@ -106,7 +106,7 @@ resetLastApplError(ControlObjectClient self) } ControlObjectClient -ControlObjectClient_create(char* objectReference, IedConnection connection) +ControlObjectClient_create(const char* objectReference, IedConnection connection) { ControlObjectClient self = NULL; diff --git a/src/iec61850/client/client_goose_control.c b/src/iec61850/client/client_goose_control.c index e61a2ec..67b1e9b 100644 --- a/src/iec61850/client/client_goose_control.c +++ b/src/iec61850/client/client_goose_control.c @@ -45,7 +45,7 @@ struct sClientGooseControlBlock { }; ClientGooseControlBlock -ClientGooseControlBlock_create(char* objectReference) +ClientGooseControlBlock_create(const char* objectReference) { ClientGooseControlBlock self = (ClientGooseControlBlock) GLOBAL_CALLOC(1, sizeof(struct sClientGooseControlBlock)); @@ -100,7 +100,7 @@ ClientGooseControlBlock_getGoID(ClientGooseControlBlock self) } void -ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, char* goID) +ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID) { if (self->goID == NULL) self->goID = MmsValue_newVisibleString(goID); @@ -118,7 +118,7 @@ ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self) } void -ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, char* datSet) +ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, const char* datSet) { if (self->datSet == NULL) self->datSet = MmsValue_newVisibleString(datSet); @@ -285,7 +285,7 @@ private_ClientGooseControlBlock_updateValues(ClientGooseControlBlock self, MmsVa } ClientGooseControlBlock -IedConnection_getGoCBValues(IedConnection self, IedClientError* error, char* goCBReference, ClientGooseControlBlock updateGoCB) +IedConnection_getGoCBValues(IedConnection self, IedClientError* error, const char* goCBReference, ClientGooseControlBlock updateGoCB) { MmsError mmsError = MMS_ERROR_NONE; *error = IED_ERROR_OK; @@ -297,7 +297,7 @@ IedConnection_getGoCBValues(IedConnection self, IedClientError* error, char* goC MmsMapping_getMmsDomainFromObjectReference(goCBReference, domainId); - char* itemIdStart = goCBReference + strlen(domainId) + 1; + const char* itemIdStart = goCBReference + strlen(domainId) + 1; char* separator = strchr(itemIdStart, '.'); diff --git a/src/iec61850/client/client_report.c b/src/iec61850/client/client_report.c index 45a31ca..181e09d 100644 --- a/src/iec61850/client/client_report.c +++ b/src/iec61850/client/client_report.c @@ -222,7 +222,7 @@ ClientReport_getDataSetValues(ClientReport self) } static ClientReport -lookupReportHandler(IedConnection self, char* rcbReference) +lookupReportHandler(IedConnection self, const char* rcbReference) { LinkedList element = LinkedList_getNext(self->enabledReports); @@ -239,7 +239,7 @@ lookupReportHandler(IedConnection self, char* rcbReference) } void -IedConnection_installReportHandler(IedConnection self, char* rcbReference, char* rptId, ReportCallbackFunction handler, +IedConnection_installReportHandler(IedConnection self, const char* rcbReference, const char* rptId, ReportCallbackFunction handler, void* handlerParameter) { ClientReport report = lookupReportHandler(self, rcbReference); @@ -268,7 +268,7 @@ IedConnection_installReportHandler(IedConnection self, char* rcbReference, char* } void -IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference) +IedConnection_uninstallReportHandler(IedConnection self, const char* rcbReference) { ClientReport report = lookupReportHandler(self, rcbReference); @@ -279,7 +279,7 @@ IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference) } void -IedConnection_triggerGIReport(IedConnection self, IedClientError* error, char* rcbReference) +IedConnection_triggerGIReport(IedConnection self, IedClientError* error, const char* rcbReference) { char domainId[65]; char itemId[129]; diff --git a/src/iec61850/client/client_report_control.c b/src/iec61850/client/client_report_control.c index 2e7407f..06537cf 100644 --- a/src/iec61850/client/client_report_control.c +++ b/src/iec61850/client/client_report_control.c @@ -32,7 +32,7 @@ #include "mms_mapping.h" static bool -isBufferedRcb(char* objectReference) +isBufferedRcb(const char* objectReference) { char* separator = strchr(objectReference, '.'); @@ -46,7 +46,7 @@ isBufferedRcb(char* objectReference) } ClientReportControlBlock -ClientReportControlBlock_create(char* objectReference) +ClientReportControlBlock_create(const char* objectReference) { ClientReportControlBlock self = (ClientReportControlBlock) GLOBAL_CALLOC(1, sizeof(struct sClientReportControlBlock)); @@ -103,7 +103,7 @@ ClientReportControlBlock_getRptId(ClientReportControlBlock self) } void -ClientReportControlBlock_setRptId(ClientReportControlBlock self, char* rptId) +ClientReportControlBlock_setRptId(ClientReportControlBlock self, const char* rptId) { if (self->rptId == NULL) self->rptId = MmsValue_newVisibleString(rptId); @@ -160,7 +160,7 @@ ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self) } void -ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, char* dataSetReference) +ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, const char* dataSetReference) { if (self->datSet == NULL) self->datSet = MmsValue_newVisibleString(dataSetReference); @@ -423,7 +423,7 @@ private_ClientReportControlBlock_updateValues(ClientReportControlBlock self, Mms ClientReportControlBlock -IedConnection_getRCBValues(IedConnection self, IedClientError* error, char* rcbReference, +IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char* rcbReference, ClientReportControlBlock updateRcb) { MmsError mmsError = MMS_ERROR_NONE; diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index 8ef2843..26ab5e8 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -501,7 +501,7 @@ connectionLostHandler(MmsConnection connection, void* parameter) } void -IedConnection_connect(IedConnection self, IedClientError* error, char* hostname, int tcpPort) +IedConnection_connect(IedConnection self, IedClientError* error, const char* hostname, int tcpPort) { MmsError mmsError; diff --git a/src/iec61850/common/iec61850_common.c b/src/iec61850/common/iec61850_common.c index f21644f..df654c8 100644 --- a/src/iec61850/common/iec61850_common.c +++ b/src/iec61850/common/iec61850_common.c @@ -63,13 +63,13 @@ Quality_unsetFlag(Quality* self, int flag) Quality -Quality_fromMmsValue(MmsValue* mmsValue) +Quality_fromMmsValue(const MmsValue* mmsValue) { return (Quality) MmsValue_getBitStringAsInteger(mmsValue); } Dbpos -Dbpos_fromMmsValue(MmsValue* mmsValue) +Dbpos_fromMmsValue(const MmsValue* mmsValue) { return (Dbpos) MmsValue_getBitStringAsIntegerBigEndian(mmsValue); } @@ -131,7 +131,7 @@ FunctionalConstraint_toString(FunctionalConstraint fc) { } FunctionalConstraint -FunctionalConstraint_fromString(char* fcString) +FunctionalConstraint_fromString(const char* fcString) { if (fcString[0] == 'S') { if (fcString[1] == 'T') diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index 748da87..b1b3401 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -186,7 +186,7 @@ IedConnection_setConnectTimeout(IedConnection self, uint32_t timeoutInMs); * \param tcpPort the TCP port number of the server to connect to */ void -IedConnection_connect(IedConnection self, IedClientError* error, char* hostname, int tcpPort); +IedConnection_connect(IedConnection self, IedClientError* error, const char* hostname, int tcpPort); /** * \brief Abort the connection @@ -325,7 +325,7 @@ IedConnection_getMmsConnection(IedConnection self); **************************************************/ ClientGooseControlBlock -ClientGooseControlBlock_create(char* dataAttributeReference); +ClientGooseControlBlock_create(const char* dataAttributeReference); void ClientGooseControlBlock_destroy(ClientGooseControlBlock self); @@ -340,13 +340,13 @@ char* ClientGooseControlBlock_getGoID(ClientGooseControlBlock self); void -ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, char* goID); +ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID); char* ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self); void -ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, char* datSet); +ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, const char* datSet); uint32_t ClientGooseControlBlock_getConfRev(ClientGooseControlBlock self); @@ -420,7 +420,7 @@ ClientGooseControlBlock_setDstAddress_appid(ClientGooseControlBlock self, uint16 * the updateRcb parameter. */ ClientGooseControlBlock -IedConnection_getGoCBValues(IedConnection self, IedClientError* error, char* goCBReference, ClientGooseControlBlock updateGoCB); +IedConnection_getGoCBValues(IedConnection self, IedClientError* error, const char* goCBReference, ClientGooseControlBlock updateGoCB); /** * \brief Write access to attributes of a GOOSE control block (GoCB) at the connected server @@ -493,7 +493,7 @@ IedConnection_setGoCBValues(IedConnection self, IedClientError* error, ClientGoo * the updateRcb parameter. */ ClientReportControlBlock -IedConnection_getRCBValues(IedConnection self, IedClientError* error, char* rcbReference, +IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char* rcbReference, ClientReportControlBlock updateRcb); /** Describes the reason for the inclusion of the element in the report */ @@ -624,7 +624,7 @@ typedef void (*ReportCallbackFunction) (void* parameter, ClientReport report); * \param handlerParameter user provided parameter that will be passed to the callback function */ void -IedConnection_installReportHandler(IedConnection self, char* rcbReference, char* rptId, ReportCallbackFunction handler, +IedConnection_installReportHandler(IedConnection self, const char* rcbReference, const char* rptId, ReportCallbackFunction handler, void* handlerParameter); /** @@ -634,7 +634,7 @@ IedConnection_installReportHandler(IedConnection self, char* rcbReference, char* * \param rcbReference object reference of the report control block */ void -IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference); +IedConnection_uninstallReportHandler(IedConnection self, const char* rcbReference); /** * \brief Trigger a general interrogation (GI) report for the specified report control block (RCB) @@ -646,7 +646,7 @@ IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference); * \param rcbReference object reference of the report control block */ void -IedConnection_triggerGIReport(IedConnection self, IedClientError* error, char* rcbReference); +IedConnection_triggerGIReport(IedConnection self, IedClientError* error, const char* rcbReference); /**************************************** * Access to received reports @@ -788,7 +788,7 @@ ReasonForInclusion_getValueAsString(ReasonForInclusion reasonCode); **************************************************/ ClientReportControlBlock -ClientReportControlBlock_create(char* rcbReference); +ClientReportControlBlock_create(const char* rcbReference); void ClientReportControlBlock_destroy(ClientReportControlBlock self); @@ -803,7 +803,7 @@ char* ClientReportControlBlock_getRptId(ClientReportControlBlock self); void -ClientReportControlBlock_setRptId(ClientReportControlBlock self, char* rptId); +ClientReportControlBlock_setRptId(ClientReportControlBlock self, const char* rptId); bool ClientReportControlBlock_getRptEna(ClientReportControlBlock self); @@ -837,7 +837,7 @@ ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self); * \param dataSetReference the reference of the data set */ void -ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, char* dataSetReference); +ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, const char* dataSetReference); uint32_t ClientReportControlBlock_getConfRev(ClientReportControlBlock self); @@ -1256,7 +1256,7 @@ typedef enum { * \return the newly created instance or NULL if the creation failed */ ControlObjectClient -ControlObjectClient_create(char* objectReference, IedConnection connection); +ControlObjectClient_create(const char* objectReference, IedConnection connection); void ControlObjectClient_destroy(ControlObjectClient self); diff --git a/src/iec61850/inc/iec61850_common.h b/src/iec61850/inc/iec61850_common.h index 795fce3..3341389 100644 --- a/src/iec61850/inc/iec61850_common.h +++ b/src/iec61850/inc/iec61850_common.h @@ -212,7 +212,7 @@ FunctionalConstraint_toString(FunctionalConstraint fc); * \brief parse a string treated as a functional constraint representation */ FunctionalConstraint -FunctionalConstraint_fromString(char* fcString); +FunctionalConstraint_fromString(const char* fcString); /** @} */ @@ -262,7 +262,7 @@ bool Quality_isFlagSet(Quality* self, int flag); Quality -Quality_fromMmsValue(MmsValue* mmsValue); +Quality_fromMmsValue(const MmsValue* mmsValue); /** @} */ @@ -288,7 +288,7 @@ typedef enum { * \return the corresponding Dbpos value */ Dbpos -Dbpos_fromMmsValue(MmsValue* mmsValue); +Dbpos_fromMmsValue(const MmsValue* mmsValue); /** * \brief conver Dbpos to MMS bit string diff --git a/src/mms/inc/mms_value.h b/src/mms/inc/mms_value.h index 42ac475..d700bbc 100644 --- a/src/mms/inc/mms_value.h +++ b/src/mms/inc/mms_value.h @@ -296,7 +296,7 @@ char* MmsValue_toString(MmsValue* self); void -MmsValue_setVisibleString(MmsValue* self, char* string); +MmsValue_setVisibleString(MmsValue* self, const char* string); /** @@ -319,7 +319,7 @@ MmsValue_setBitStringBit(MmsValue* self, int bitPos, bool value); * \return the value of the bit (true = 1 / false = 0) */ bool -MmsValue_getBitStringBit(MmsValue* self, int bitPos); +MmsValue_getBitStringBit(const MmsValue* self, int bitPos); /** * \brief Delete all bits (set to zero) of an MmsType object of type MMS_BITSTRING @@ -336,7 +336,7 @@ MmsValue_deleteAllBitStringBits(MmsValue* self); * \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING. */ int -MmsValue_getBitStringSize(MmsValue* self); +MmsValue_getBitStringSize(const MmsValue* self); /** * \brief Get the number of bytes required by this bitString @@ -344,7 +344,7 @@ MmsValue_getBitStringSize(MmsValue* self); * \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING. */ int -MmsValue_getBitStringByteSize(MmsValue* self); +MmsValue_getBitStringByteSize(const MmsValue* self); /** * \brief Count the number of set bits in a bit string. @@ -352,7 +352,7 @@ MmsValue_getBitStringByteSize(MmsValue* self); * \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING. */ int -MmsValue_getNumberOfSetBits(MmsValue* self); +MmsValue_getNumberOfSetBits(const MmsValue* self); /** * Set all bits (set to one) of an MmsType object of type MMS_BITSTRING @@ -371,7 +371,7 @@ MmsValue_setAllBitStringBits(MmsValue* self); * \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING. */ uint32_t -MmsValue_getBitStringAsInteger(MmsValue* self); +MmsValue_getBitStringAsInteger(const MmsValue* self); /** * \brief Convert an unsigned integer to a bit string @@ -394,7 +394,7 @@ MmsValue_setBitStringFromInteger(MmsValue* self, uint32_t intValue); * \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING. */ uint32_t -MmsValue_getBitStringAsIntegerBigEndian(MmsValue* self); +MmsValue_getBitStringAsIntegerBigEndian(const MmsValue* self); /** * \brief Convert an unsigned integer to a bit string (big endian bit order) @@ -559,7 +559,7 @@ MmsValue_getOctetStringBuffer(MmsValue* self); * \return indicates if the update has been successful (false if not) */ bool -MmsValue_update(MmsValue* self, MmsValue* source); +MmsValue_update(MmsValue* self, const MmsValue* source); /** * \brief Check if two instances of MmsValue have the same value. @@ -573,7 +573,7 @@ MmsValue_update(MmsValue* self, MmsValue* source); * \return true if both instances are of the same type and have the same value */ bool -MmsValue_equals(MmsValue* self, MmsValue* otherValue); +MmsValue_equals(const MmsValue* self, const MmsValue* otherValue); /** * \brief Check if two (complex) instances of MmsValue have the same type. @@ -588,7 +588,7 @@ MmsValue_equals(MmsValue* self, MmsValue* otherValue); * \return true if both instances and all their children are of the same type. */ bool -MmsValue_equalTypes(MmsValue* self, MmsValue* otherValue); +MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue); /************************************************************************************* * Constructors and destructors @@ -745,7 +745,7 @@ MmsValue_deleteIfNotNull(MmsValue* value); * \return new MmsValue instance of type MMS_VISIBLE_STRING */ MmsValue* -MmsValue_newVisibleString(char* string); +MmsValue_newVisibleString(const char* string); /** * \brief Create a new MmsValue instance of type MMS_VISIBLE_STRING. diff --git a/src/mms/iso_mms/common/mms_value.c b/src/mms/iso_mms/common/mms_value.c index 38400e6..1c9d16e 100644 --- a/src/mms/iso_mms/common/mms_value.c +++ b/src/mms/iso_mms/common/mms_value.c @@ -38,20 +38,20 @@ #include /* for ctime_r */ static inline int -bitStringByteSize(MmsValue* value) +bitStringByteSize(const MmsValue* value) { int bitSize = value->value.bitString.size; return (bitSize / 8) + ((bitSize % 8) > 0); } int -MmsValue_getBitStringByteSize(MmsValue* self) +MmsValue_getBitStringByteSize(const MmsValue* self) { return bitStringByteSize(self); } static void -updateStructuredComponent(MmsValue* self, MmsValue* update) +updateStructuredComponent(MmsValue* self, const MmsValue* update) { int componentCount; MmsValue** selfValues; @@ -96,7 +96,7 @@ MmsValue_newUnsignedFromBerInteger(Asn1PrimitiveValue* berInteger) } bool -MmsValue_equals(MmsValue* self, MmsValue* otherValue) +MmsValue_equals(const MmsValue* self, const MmsValue* otherValue) { if (self->type == otherValue->type) { switch (self->type) { @@ -189,7 +189,7 @@ MmsValue_equals(MmsValue* self, MmsValue* otherValue) } bool -MmsValue_equalTypes(MmsValue* self, MmsValue* otherValue) +MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue) { if (self->type == otherValue->type) { switch (self->type) { @@ -220,7 +220,7 @@ MmsValue_equalTypes(MmsValue* self, MmsValue* otherValue) } bool -MmsValue_update(MmsValue* self, MmsValue* update) +MmsValue_update(MmsValue* self, const MmsValue* update) { if (self->type == update->type) { switch (self->type) { @@ -314,7 +314,7 @@ MmsValue_newBitString(int bitSize) } static int -getBitStringByteSize(MmsValue* self) +getBitStringByteSize(const MmsValue* self) { int byteSize; @@ -361,13 +361,13 @@ MmsValue_setAllBitStringBits(MmsValue* self) } int -MmsValue_getBitStringSize(MmsValue* self) +MmsValue_getBitStringSize(const MmsValue* self) { return self->value.bitString.size; } int -MmsValue_getNumberOfSetBits(MmsValue* self) +MmsValue_getNumberOfSetBits(const MmsValue* self) { int setBitsCount = 0; @@ -404,7 +404,7 @@ MmsValue_setBitStringBit(MmsValue* self, int bitPos, bool value) } bool -MmsValue_getBitStringBit(MmsValue* self, int bitPos) +MmsValue_getBitStringBit(const MmsValue* self, int bitPos) { if (bitPos < self->value.bitString.size) { int bytePos = bitPos / 8; @@ -423,7 +423,7 @@ MmsValue_getBitStringBit(MmsValue* self, int bitPos) } uint32_t -MmsValue_getBitStringAsInteger(MmsValue* self) +MmsValue_getBitStringAsInteger(const MmsValue* self) { uint32_t value = 0; @@ -454,7 +454,7 @@ MmsValue_setBitStringFromInteger(MmsValue* self, uint32_t intValue) } uint32_t -MmsValue_getBitStringAsIntegerBigEndian(MmsValue* self) +MmsValue_getBitStringAsIntegerBigEndian(const MmsValue* self) { uint32_t value = 0; @@ -1435,7 +1435,7 @@ exit_function: } static inline void -setVisibleStringValue(MmsValue* self, char* string) +setVisibleStringValue(MmsValue* self, const char* string) { if (self->value.visibleString.buf != NULL) { if (string != NULL) { @@ -1464,7 +1464,7 @@ exit_function: } static MmsValue* -MmsValue_newString(char* string, MmsType type) +MmsValue_newString(const char* string, MmsType type) { MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); @@ -1497,7 +1497,7 @@ exit_function: } MmsValue* -MmsValue_newVisibleString(char* string) +MmsValue_newVisibleString(const char* string) { return MmsValue_newString(string, MMS_VISIBLE_STRING); } @@ -1687,7 +1687,7 @@ MmsValue_newMmsStringFromByteArray(uint8_t* byteArray, int size) } void -MmsValue_setVisibleString(MmsValue* self, char* string) +MmsValue_setVisibleString(MmsValue* self, const char* string) { if (self->type == MMS_VISIBLE_STRING) { assert(self->value.visibleString.buf != NULL); From 3932102f8615f7a2dd3f4b03cac3847335c6470d Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 22 Jan 2015 16:50:39 +0100 Subject: [PATCH 4/6] - add some more const declarations --- src/common/conversions.c | 10 +++--- src/common/inc/conversions.h | 4 +-- src/common/inc/string_utilities.h | 4 +-- src/common/string_utilities.c | 4 +-- src/iec61850/client/client_goose_control.c | 2 +- src/iec61850/client/client_report_control.c | 2 +- src/iec61850/inc/iec61850_server.h | 16 +++++----- src/iec61850/server/impl/ied_server.c | 16 +++++----- src/mms/inc/mms_value.h | 28 ++++++++--------- src/mms/iso_mms/common/mms_value.c | 34 ++++++++++----------- 10 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/common/conversions.c b/src/common/conversions.c index 51b16bf..a1e6472 100644 --- a/src/common/conversions.c +++ b/src/common/conversions.c @@ -148,7 +148,7 @@ Conversions_msTimeToGeneralizedTime(uint64_t msTime, uint8_t* buffer) } static int -getSecondsOffset(char* offsetString) +getSecondsOffset(const char* offsetString) { int hourOffset = StringUtils_digitsToInt(offsetString, 2); @@ -166,7 +166,7 @@ getSecondsOffset(char* offsetString) } uint64_t -Conversions_generalizedTimeToMsTime(char* gtString) +Conversions_generalizedTimeToMsTime(const char* gtString) { int gtStringLen = strlen(gtString); @@ -205,12 +205,12 @@ Conversions_generalizedTimeToMsTime(char* gtString) int msOffset = 0; - char* parsePos = gtString + 14; + const char* parsePos = gtString + 14; /* parse optional fraction of second field */ if (*(parsePos) == '.') { parsePos++; - char* fractionOfSecondStart = parsePos; + const char* fractionOfSecondStart = parsePos; int fractionOfSecondLen = 0; @@ -266,7 +266,7 @@ Conversions_generalizedTimeToMsTime(char* gtString) } void -memcpyReverseByteOrder(uint8_t* dst, uint8_t* src, int size) +memcpyReverseByteOrder(uint8_t* dst, const uint8_t* src, int size) { int i = 0; for (i = 0; i < size; i++) { diff --git a/src/common/inc/conversions.h b/src/common/inc/conversions.h index c847216..03b1269 100644 --- a/src/common/inc/conversions.h +++ b/src/common/inc/conversions.h @@ -35,9 +35,9 @@ void Conversions_msTimeToGeneralizedTime(uint64_t msTime, uint8_t* buffer); uint64_t -Conversions_generalizedTimeToMsTime(char* gtString); +Conversions_generalizedTimeToMsTime(const char* gtString); void -memcpyReverseByteOrder(uint8_t* dst, uint8_t* src, int size); +memcpyReverseByteOrder(uint8_t* dst, const uint8_t* src, int size); #endif /* CONVERSIONS_H_ */ diff --git a/src/common/inc/string_utilities.h b/src/common/inc/string_utilities.h index 72f44bf..3e55f92 100644 --- a/src/common/inc/string_utilities.h +++ b/src/common/inc/string_utilities.h @@ -50,7 +50,7 @@ char* createStringInBuffer(char* buffer, int count, ...); char* -createStringFromBuffer(uint8_t* buf, int size); +createStringFromBuffer(const uint8_t* buf, int size); void StringUtils_replace(char* string, char oldChar, char newChar); @@ -62,7 +62,7 @@ int StringUtils_digitToInt(char digit); int -StringUtils_digitsToInt(char* digits, int count); +StringUtils_digitsToInt(const char* digits, int count); int StringUtils_createBufferFromHexString(char* hexString, uint8_t* buffer); diff --git a/src/common/string_utilities.c b/src/common/string_utilities.c index 86d9368..82ea08e 100644 --- a/src/common/string_utilities.c +++ b/src/common/string_utilities.c @@ -61,7 +61,7 @@ copyStringToBuffer(const char* string, char* buffer) char* -createStringFromBuffer(uint8_t* buf, int size) +createStringFromBuffer(const uint8_t* buf, int size) { char* newStr = (char*) GLOBAL_MALLOC(size + 1); @@ -159,7 +159,7 @@ StringUtils_digitToInt(char digit) } int -StringUtils_digitsToInt(char* digits, int count) +StringUtils_digitsToInt(const char* digits, int count) { int i = 0; int value = 0; diff --git a/src/iec61850/client/client_goose_control.c b/src/iec61850/client/client_goose_control.c index 67b1e9b..3ee6de5 100644 --- a/src/iec61850/client/client_goose_control.c +++ b/src/iec61850/client/client_goose_control.c @@ -299,7 +299,7 @@ IedConnection_getGoCBValues(IedConnection self, IedClientError* error, const cha const char* itemIdStart = goCBReference + strlen(domainId) + 1; - char* separator = strchr(itemIdStart, '.'); + const char* separator = strchr(itemIdStart, '.'); if (separator == NULL) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; diff --git a/src/iec61850/client/client_report_control.c b/src/iec61850/client/client_report_control.c index 06537cf..71c0e38 100644 --- a/src/iec61850/client/client_report_control.c +++ b/src/iec61850/client/client_report_control.c @@ -34,7 +34,7 @@ static bool isBufferedRcb(const char* objectReference) { - char* separator = strchr(objectReference, '.'); + const char* separator = strchr(objectReference, '.'); if (separator == NULL) return false; //TODO report an error diff --git a/src/iec61850/inc/iec61850_server.h b/src/iec61850/inc/iec61850_server.h index 302c920..be78038 100644 --- a/src/iec61850/inc/iec61850_server.h +++ b/src/iec61850/inc/iec61850_server.h @@ -340,7 +340,7 @@ IedServer_getAttributeValue(IedServer self, DataAttribute* dataAttribute); * \return true or false */ bool -IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getBooleanAttributeValue(IedServer self, const DataAttribute* dataAttribute); /** * \brief Get data attribute value of an integer data attribute @@ -354,7 +354,7 @@ IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute) * \return the value as 32 bit integer */ int32_t -IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute); /** * \brief Get data attribute value of an integer data attribute @@ -368,7 +368,7 @@ IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute); * \return the value as 64 bit integer */ int64_t -IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getInt64AttributeValue(IedServer self, const DataAttribute* dataAttribute); /** * \brief Get data attribute value of an unsigned integer data attribute @@ -382,7 +382,7 @@ IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute); * \return the value as 32 bit unsigned integer */ uint32_t -IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getUInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute); /** * \brief Get data attribute value of a floating point data attribute @@ -396,7 +396,7 @@ IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute); * \return the value as 32 bit float */ float -IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getFloatAttributeValue(IedServer self, const DataAttribute* dataAttribute); /** * \brief Get data attribute value of a UTC time data attribute @@ -410,7 +410,7 @@ IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute); * \return the value as 32 bit float */ uint64_t -IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getUTCTimeAttributeValue(IedServer self, const DataAttribute* dataAttribute); /** * \brief Get data attribute value of a bit string data attribute as integer value @@ -428,7 +428,7 @@ IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute) * \return the value a 32 bit integer. */ uint32_t -IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAttribute); /** * \brief Get data attribute value of a string type data attribute @@ -442,7 +442,7 @@ IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribut * \return the value as a C string (null terminated string) */ char* -IedServer_getStringAttributeValue(IedServer self, DataAttribute* dataAttribute); +IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute); /** diff --git a/src/iec61850/server/impl/ied_server.c b/src/iec61850/server/impl/ied_server.c index f31f00d..46d472b 100644 --- a/src/iec61850/server/impl/ied_server.c +++ b/src/iec61850/server/impl/ied_server.c @@ -656,7 +656,7 @@ IedServer_getAttributeValue(IedServer self, DataAttribute* dataAttribute) } bool -IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getBooleanAttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); @@ -667,7 +667,7 @@ IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute) } int32_t -IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); @@ -679,7 +679,7 @@ IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute) } int64_t -IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getInt64AttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); @@ -691,7 +691,7 @@ IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute) } uint32_t -IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getUInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); @@ -703,7 +703,7 @@ IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute) } float -IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getFloatAttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); @@ -714,7 +714,7 @@ IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute) } uint64_t -IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getUTCTimeAttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); @@ -725,7 +725,7 @@ IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute) } uint32_t -IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); @@ -737,7 +737,7 @@ IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribut } char* -IedServer_getStringAttributeValue(IedServer self, DataAttribute* dataAttribute) +IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute) { assert(self != NULL); assert(dataAttribute != NULL); diff --git a/src/mms/inc/mms_value.h b/src/mms/inc/mms_value.h index d700bbc..bb86fa0 100644 --- a/src/mms/inc/mms_value.h +++ b/src/mms/inc/mms_value.h @@ -132,7 +132,7 @@ MmsValue_setElement(MmsValue* complexValue, int index, MmsValue* elementValue); *************************************************************************************/ MmsDataAccessError -MmsValue_getDataAccessError(MmsValue* self); +MmsValue_getDataAccessError(const MmsValue* self); /** * \brief Get the int64_t value of a MmsValue object. @@ -142,7 +142,7 @@ MmsValue_getDataAccessError(MmsValue* self); * \return signed 64 bit integer */ int64_t -MmsValue_toInt64(MmsValue* self); +MmsValue_toInt64(const MmsValue* self); /** * \brief Get the int32_t value of a MmsValue object. @@ -152,7 +152,7 @@ MmsValue_toInt64(MmsValue* self); * \return signed 32 bit integer */ int32_t -MmsValue_toInt32(MmsValue* value); +MmsValue_toInt32(const MmsValue* value); /** * \brief Get the uint32_t value of a MmsValue object. @@ -162,7 +162,7 @@ MmsValue_toInt32(MmsValue* value); * \return unsigned 32 bit integer */ uint32_t -MmsValue_toUint32(MmsValue* value); +MmsValue_toUint32(const MmsValue* value); /** * \brief Get the double value of a MmsValue object. @@ -172,7 +172,7 @@ MmsValue_toUint32(MmsValue* value); * \return 64 bit floating point value */ double -MmsValue_toDouble(MmsValue* self); +MmsValue_toDouble(const MmsValue* self); /** * \brief Get the float value of a MmsValue object. @@ -182,7 +182,7 @@ MmsValue_toDouble(MmsValue* self); * \return 32 bit floating point value */ float -MmsValue_toFloat(MmsValue* self); +MmsValue_toFloat(const MmsValue* self); /** * \brief Get the unix timestamp of a MmsValue object of type MMS_UTCTIME. @@ -192,7 +192,7 @@ MmsValue_toFloat(MmsValue* self); * \return unix timestamp of the MMS_UTCTIME variable. */ uint32_t -MmsValue_toUnixTimestamp(MmsValue* self); +MmsValue_toUnixTimestamp(const MmsValue* self); /** * \brief Set the float value of a MmsValue object. @@ -290,7 +290,7 @@ MmsValue_setBoolean(MmsValue* value, bool boolValue); * \return the MmsValue value as bool value */ bool -MmsValue_getBoolean(MmsValue* value); +MmsValue_getBoolean(const MmsValue* value); char* MmsValue_toString(MmsValue* self); @@ -435,7 +435,7 @@ MmsValue_setUtcTimeMs(MmsValue* self, uint64_t timeval); * \param buffer buffer containing the encoded UTCTime. */ void -MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer); +MmsValue_setUtcTimeByBuffer(MmsValue* self, const uint8_t* buffer); /** * \brief Get a millisecond time value from an MmsValue object of MMS_UTCTIME type. @@ -445,7 +445,7 @@ MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer); * \return the value in milliseconds since epoch (1970/01/01 00:00 UTC) */ uint64_t -MmsValue_getUtcTimeInMs(MmsValue* value); +MmsValue_getUtcTimeInMs(const MmsValue* value); /** * \brief set the TimeQuality byte of the UtcTime @@ -479,7 +479,7 @@ MmsValue_setUtcTimeQuality(MmsValue* self, uint8_t timeQuality); * \return the byte representing the time quality */ uint8_t -MmsValue_getUtcTimeQuality(MmsValue* self); +MmsValue_getUtcTimeQuality(const MmsValue* self); /** * \brief Update an MmsValue object of type MMS_BINARYTIME with a millisecond time. @@ -498,7 +498,7 @@ MmsValue_setBinaryTime(MmsValue* self, uint64_t timestamp); * \return the value in milliseconds since epoch (1970/01/01 00:00 UTC) */ uint64_t -MmsValue_getBinaryTimeAsUtcMs(MmsValue* self); +MmsValue_getBinaryTimeAsUtcMs(const MmsValue* self); /** * \brief Set the value of an MmsValue object of type MMS_OCTET_STRING. @@ -522,7 +522,7 @@ MmsValue_setOctetString(MmsValue* self, uint8_t* buf, int size); * \return size in bytes */ uint16_t -MmsValue_getOctetStringSize(MmsValue* self); +MmsValue_getOctetStringSize(const MmsValue* self); /** * \brief Returns the maximum size in bytes of an MmsValue object of type MMS_OCTET_STRING. @@ -822,7 +822,7 @@ MmsValue* MmsValue_newMmsString(char* string); void -MmsValue_setMmsString(MmsValue* value, char* string); +MmsValue_setMmsString(MmsValue* value, const char* string); /** * \brief Create a new MmsValue instance of type MMS_UTCTIME. diff --git a/src/mms/iso_mms/common/mms_value.c b/src/mms/iso_mms/common/mms_value.c index 1c9d16e..ee2e302 100644 --- a/src/mms/iso_mms/common/mms_value.c +++ b/src/mms/iso_mms/common/mms_value.c @@ -654,7 +654,7 @@ MmsValue_setBoolean(MmsValue* self, bool boolValue) } bool -MmsValue_getBoolean(MmsValue* self) +MmsValue_getBoolean(const MmsValue* self) { return self->value.boolean; } @@ -711,13 +711,13 @@ MmsValue_setUtcTimeQuality(MmsValue* self, uint8_t timeQuality) } uint8_t -MmsValue_getUtcTimeQuality(MmsValue* self) +MmsValue_getUtcTimeQuality(const MmsValue* self) { return self->value.utcTime[7]; } void -MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer) +MmsValue_setUtcTimeByBuffer(MmsValue* self, const uint8_t* buffer) { uint8_t* valueArray = self->value.utcTime; @@ -728,10 +728,10 @@ MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer) } uint64_t -MmsValue_getUtcTimeInMs(MmsValue* self) +MmsValue_getUtcTimeInMs(const MmsValue* self) { uint32_t timeval32; - uint8_t* valueArray = self->value.utcTime; + const uint8_t* valueArray = self->value.utcTime; #if (ORDER_LITTLE_ENDIAN == 1) memcpyReverseByteOrder((uint8_t*) &timeval32, valueArray, 4); @@ -800,7 +800,7 @@ MmsValue_newIntegerFromInt64(int64_t integer) * Convert signed integer to int32_t */ int32_t -MmsValue_toInt32(MmsValue* self) +MmsValue_toInt32(const MmsValue* self) { int32_t integerValue = 0; @@ -811,7 +811,7 @@ MmsValue_toInt32(MmsValue* self) } uint32_t -MmsValue_toUint32(MmsValue* self) +MmsValue_toUint32(const MmsValue* self) { uint32_t integerValue = 0; @@ -825,7 +825,7 @@ MmsValue_toUint32(MmsValue* self) * Convert signed integer to int64_t and do sign extension if required */ int64_t -MmsValue_toInt64(MmsValue* self) +MmsValue_toInt64(const MmsValue* self) { int64_t integerValue = 0; @@ -836,7 +836,7 @@ MmsValue_toInt64(MmsValue* self) } float -MmsValue_toFloat(MmsValue* self) +MmsValue_toFloat(const MmsValue* self) { if (self->type == MMS_FLOAT) { if (self->value.floatingPoint.formatWidth == 32) { @@ -858,7 +858,7 @@ MmsValue_toFloat(MmsValue* self) } double -MmsValue_toDouble(MmsValue* self) +MmsValue_toDouble(const MmsValue* self) { if (self->type == MMS_FLOAT) { double val; @@ -878,7 +878,7 @@ MmsValue_toDouble(MmsValue* self) uint32_t -MmsValue_toUnixTimestamp(MmsValue* self) +MmsValue_toUnixTimestamp(const MmsValue* self) { uint32_t timestamp; uint8_t* timeArray = (uint8_t*) ×tamp; @@ -1289,7 +1289,7 @@ MmsValue_setOctetString(MmsValue* self, uint8_t* buf, int size) } uint16_t -MmsValue_getOctetStringSize(MmsValue* self) +MmsValue_getOctetStringSize(const MmsValue* self) { return self->value.octetString.size; } @@ -1602,11 +1602,11 @@ MmsValue_setBinaryTime(MmsValue* self, uint64_t timestamp) } uint64_t -MmsValue_getBinaryTimeAsUtcMs(MmsValue* self) +MmsValue_getBinaryTimeAsUtcMs(const MmsValue* self) { uint64_t timestamp = 0; - uint8_t* binaryTimeBuf = self->value.binaryTime.buf; + const uint8_t* binaryTimeBuf = self->value.binaryTime.buf; if (self->value.binaryTime.size == 6) { @@ -1636,13 +1636,13 @@ MmsValue_getBinaryTimeAsUtcMs(MmsValue* self) } MmsDataAccessError -MmsValue_getDataAccessError(MmsValue* self) +MmsValue_getDataAccessError(const MmsValue* self) { return self->value.dataAccessError; } void -MmsValue_setMmsString(MmsValue* self, char* string) +MmsValue_setMmsString(MmsValue* self, const char* string) { if (self->type == MMS_STRING) { assert(self->value.visibleString.buf != NULL); @@ -1652,7 +1652,7 @@ MmsValue_setMmsString(MmsValue* self, char* string) } static MmsValue* -MmsValue_newStringFromByteArray(uint8_t* byteArray, int size, MmsType type) +MmsValue_newStringFromByteArray(const uint8_t* byteArray, int size, MmsType type) { MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); From 0e8980ae0f21edc40c84f672e6f2dd0db444d95b Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 26 Jan 2015 15:52:14 +0100 Subject: [PATCH 5/6] - added function MmsValue_getUtcTimeBuffer - fixed problem with entry time in buffered reporting - fixed bug in file directory service when clients sends an empty string as filename - fixed problem in file read service. Server now respects the negotiated maximum PDU size --- src/iec61850/inc/iec61850_server.h | 17 ++++++++++++++++- src/iec61850/server/impl/ied_server.c | 18 ++++++++++++++++++ src/iec61850/server/mms_mapping/reporting.c | 1 + src/mms/inc/mms_value.h | 12 ++++++++++++ src/mms/iso_mms/common/mms_value.c | 6 ++++++ src/mms/iso_mms/server/mms_file_service.c | 12 +++++++++--- src/vs/libiec61850-wo-goose.def | 4 +++- src/vs/libiec61850.def | 3 ++- 8 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/iec61850/inc/iec61850_server.h b/src/iec61850/inc/iec61850_server.h index be78038..8ebc15b 100644 --- a/src/iec61850/inc/iec61850_server.h +++ b/src/iec61850/inc/iec61850_server.h @@ -597,11 +597,26 @@ IedServer_updateVisibleStringAttributeValue(IedServer self, DataAttribute* dataA * * \param self the instance of IedServer to operate on. * \param dataAttribute the data attribute handle - * \param value the new UTC time value of the data attribute. + * \param value the new UTC time value of the data attribute as a ms timestamp */ void IedServer_updateUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute, uint64_t value); +/** + * \brief Update the value of an IEC 61850 UTC time (timestamp) data attribute. + * + * Update the value of a UTC time data attribute without handling MmsValue instances. + * + * This function will also check if a trigger condition is satisfied in the case when a report or GOOSE + * control block is enabled. + * + * \param self the instance of IedServer to operate on. + * \param dataAttribute the data attribute handle + * \param value the new UTC time value of the data attribute as a Timestamp + */ +void +IedServer_updateTimestampAttributeValue(IedServer self, DataAttribute* dataAttribute, Timestamp* timestamp); + /** * \brief Update a quality ("q") IEC 61850 data attribute. * diff --git a/src/iec61850/server/impl/ied_server.c b/src/iec61850/server/impl/ied_server.c index 46d472b..1e3a5d6 100644 --- a/src/iec61850/server/impl/ied_server.c +++ b/src/iec61850/server/impl/ied_server.c @@ -24,6 +24,7 @@ #include "iec61850_server.h" #include "mms_mapping.h" #include "mms_mapping_internal.h" +#include "mms_value_internal.h" #include "control.h" #include "stack_config.h" #include "ied_server_private.h" @@ -957,6 +958,23 @@ IedServer_updateUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribu } } +void +IedServer_updateTimestampAttributeValue(IedServer self, DataAttribute* dataAttribute, Timestamp* timestamp) +{ + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UTC_TIME); + assert(dataAttribute != NULL); + assert(self != NULL); + + if (memcmp(dataAttribute->mmsValue->value.utcTime, timestamp->val, 8) == 0) { + checkForUpdateTrigger(self, dataAttribute); + } + else { + MmsValue_setUtcTimeByBuffer(dataAttribute->mmsValue, timestamp->val); + + checkForChangedTriggers(self, dataAttribute); + } +} + void IedServer_updateQuality(IedServer self, DataAttribute* dataAttribute, Quality quality) { diff --git a/src/iec61850/server/mms_mapping/reporting.c b/src/iec61850/server/mms_mapping/reporting.c index d49a606..f5cd070 100644 --- a/src/iec61850/server/mms_mapping/reporting.c +++ b/src/iec61850/server/mms_mapping/reporting.c @@ -933,6 +933,7 @@ createBufferedReportControlBlock(ReportControlBlock* reportControlBlock, namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification)); namedVariable->name = copyString("TimeOfEntry"); namedVariable->type = MMS_BINARY_TIME; + namedVariable->typeSpec.binaryTime = 6; rcb->typeSpec.structure.elements[12] = namedVariable; mmsValue->value.structure.components[12] = MmsValue_newBinaryTime(false); diff --git a/src/mms/inc/mms_value.h b/src/mms/inc/mms_value.h index bb86fa0..6a44a0b 100644 --- a/src/mms/inc/mms_value.h +++ b/src/mms/inc/mms_value.h @@ -437,6 +437,18 @@ MmsValue_setUtcTimeMs(MmsValue* self, uint64_t timeval); void MmsValue_setUtcTimeByBuffer(MmsValue* self, const uint8_t* buffer); +/** + * \brief return the raw buffer containing the UTC time data + * + * Note: This will return the address of the raw byte buffer. The array length is 8 byte. + * + * \param self MmsValue instance to operate on. Has to be of a type MMS_UTCTIME. + * + * \return the buffer containing the raw data + */ +uint8_t* +MmsValue_getUtcTimeBuffer(MmsValue* self); + /** * \brief Get a millisecond time value from an MmsValue object of MMS_UTCTIME type. * diff --git a/src/mms/iso_mms/common/mms_value.c b/src/mms/iso_mms/common/mms_value.c index ee2e302..cf56ea3 100644 --- a/src/mms/iso_mms/common/mms_value.c +++ b/src/mms/iso_mms/common/mms_value.c @@ -727,6 +727,12 @@ MmsValue_setUtcTimeByBuffer(MmsValue* self, const uint8_t* buffer) } } +uint8_t* +MmsValue_getUtcTimeBuffer(MmsValue* self) +{ + return self->value.utcTime; +} + uint64_t MmsValue_getUtcTimeInMs(const MmsValue* self) { diff --git a/src/mms/iso_mms/server/mms_file_service.c b/src/mms/iso_mms/server/mms_file_service.c index ce1833d..ffaaae6 100644 --- a/src/mms/iso_mms/server/mms_file_service.c +++ b/src/mms/iso_mms/server/mms_file_service.c @@ -315,14 +315,15 @@ exit_reject_invalid_pdu: static void -createFileReadResponse(uint32_t invokeId, ByteBuffer* response, MmsFileReadStateMachine* frsm) +createFileReadResponse(MmsServerConnection* connection, uint32_t invokeId, + ByteBuffer* response, MmsFileReadStateMachine* frsm) { /* determine remaining bytes in file */ uint32_t bytesLeft = frsm->fileSize - frsm->readPosition; uint32_t fileChunkSize = 0; - uint32_t maxFileChunkSize = CONFIG_MMS_MAXIMUM_PDU_SIZE - 15; + uint32_t maxFileChunkSize = connection->maxPduSize - 20; uint32_t fileReadResponseSize = 1; /* for tag */ @@ -384,7 +385,7 @@ mmsServer_handleFileReadRequest( MmsFileReadStateMachine* frsm = getFrsm(connection, frsmId); if (frsm != NULL) - createFileReadResponse(invokeId, response, frsm); + createFileReadResponse(connection, invokeId, response, frsm); else mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_FILE_OTHER); } @@ -452,6 +453,11 @@ createFileDirectoryResponse(uint32_t invokeId, ByteBuffer* response, char* direc DirectoryHandle directory = FileSystem_openDirectory(directoryName); + if (continueAfterFileName != NULL) { + if (strlen(continueAfterFileName) == 0) + continueAfterFileName = NULL; + } + if (directory != NULL) { bool isDirectory; char* fileName = FileSystem_readDirectory(directory, &isDirectory); diff --git a/src/vs/libiec61850-wo-goose.def b/src/vs/libiec61850-wo-goose.def index dbbebc3..1624ef2 100644 --- a/src/vs/libiec61850-wo-goose.def +++ b/src/vs/libiec61850-wo-goose.def @@ -482,4 +482,6 @@ EXPORTS IedServer_getBitStringAttributeValue IedServer_getStringAttributeValue ModelNode_getChildWithFc - + IedServer_updateTimestampAttributeValue + MmsValue_getUtcTimeBuffer + diff --git a/src/vs/libiec61850.def b/src/vs/libiec61850.def index 0878e2f..852e2a1 100644 --- a/src/vs/libiec61850.def +++ b/src/vs/libiec61850.def @@ -506,4 +506,5 @@ EXPORTS IedServer_getBitStringAttributeValue IedServer_getStringAttributeValue ModelNode_getChildWithFc - + IedServer_updateTimestampAttributeValue + MmsValue_getUtcTimeBuffer From ffbd1f3f6a4d93a1416ecca4ceb53b579100e454 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Wed, 28 Jan 2015 15:20:55 +0100 Subject: [PATCH 6/6] - fixed bug in StaticModelGenerator.java --- src/iec61850/server/mms_mapping/control.c | 12 ++++++------ tools/model_generator/genmodel.jar | Bin 73829 -> 73830 bytes .../tools/StaticModelGenerator.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/iec61850/server/mms_mapping/control.c b/src/iec61850/server/mms_mapping/control.c index 227b2fc..3b6e663 100644 --- a/src/iec61850/server/mms_mapping/control.c +++ b/src/iec61850/server/mms_mapping/control.c @@ -44,7 +44,7 @@ #define STATE_UNSELECTED 0 #define STATE_READY 1 -#define STATE_WAIT_FOR_ACTICATION_TIME 2 +#define STATE_WAIT_FOR_ACTIVATION_TIME 2 #define STATE_PERFORM_TEST 3 #define STATE_WAIT_FOR_EXECUTION 4 #define STATE_OPERATE 5 @@ -345,13 +345,13 @@ executeStateMachine: switch (state) { - case STATE_WAIT_FOR_ACTICATION_TIME: + case STATE_WAIT_FOR_ACTIVATION_TIME: case STATE_WAIT_FOR_EXECUTION: { ControlHandlerResult dynamicCheckResult = CONTROL_RESULT_OK; bool isTimeActivatedControl = false; - if (state == STATE_WAIT_FOR_ACTICATION_TIME) + if (state == STATE_WAIT_FOR_ACTIVATION_TIME) isTimeActivatedControl = true; if (self->waitForExecutionHandler != NULL) { @@ -667,7 +667,7 @@ Control_processControlActions(MmsMapping* self, uint64_t currentTimeInMs) while (element != NULL) { ControlObject* controlObject = (ControlObject*) element->data; - if (controlObject->state == STATE_WAIT_FOR_ACTICATION_TIME) { + if (controlObject->state == STATE_WAIT_FOR_ACTIVATION_TIME) { if (controlObject->operateTime <= currentTimeInMs) { @@ -1395,7 +1395,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari int state = getState(controlObject); - if (state == STATE_WAIT_FOR_ACTICATION_TIME) { + if (state == STATE_WAIT_FOR_ACTIVATION_TIME) { indication = DATA_ACCESS_ERROR_TEMPORARILY_UNAVAILABLE; ControlObject_sendLastApplError(controlObject, connection, "Oper", @@ -1452,7 +1452,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari initiateControlTask(controlObject); - setState(controlObject, STATE_WAIT_FOR_ACTICATION_TIME); + setState(controlObject, STATE_WAIT_FOR_ACTIVATION_TIME); if (DEBUG_IED_SERVER) printf("Oper: activate time activated control\n"); diff --git a/tools/model_generator/genmodel.jar b/tools/model_generator/genmodel.jar index 182f0d55c15dbd9178b8150a01ec2fcba66cc628..4ad96abb02c4fd22b701b2df8028b60b51b52bd0 100644 GIT binary patch delta 4010 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 delta 3893 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 diff --git a/tools/model_generator/src/com/libiec61850/tools/StaticModelGenerator.java b/tools/model_generator/src/com/libiec61850/tools/StaticModelGenerator.java index 6a8c8ef..ba23d76 100644 --- a/tools/model_generator/src/com/libiec61850/tools/StaticModelGenerator.java +++ b/tools/model_generator/src/com/libiec61850/tools/StaticModelGenerator.java @@ -827,7 +827,7 @@ public class StaticModelGenerator { sgcbString += sgcb.getActSG() + ", " + sgcb.getNumOfSGs() + ", 0, false, 0, 0, "; if (currentSGCBVariableNumber < (sgcbVariableNames.size() - 1)) - sgcbString += "&" + sgcbVariableNames.get(currentGseVariableNumber + 1); + sgcbString += "&" + sgcbVariableNames.get(currentSGCBVariableNumber + 1); else sgcbString += "NULL";