From 907eb0bbae9434fa2b4fb6254675efec34fe69ce Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 26 Nov 2015 12:22:35 +0100 Subject: [PATCH] - removed ResvTms form BRCB (depending on configuration option CONFIG_IEC61850_BRCB_WITH_RESVTMS) --- config/stack_config.h | 3 ++ src/iec61850/server/mms_mapping/reporting.c | 39 +++++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/config/stack_config.h b/config/stack_config.h index b842089c..7727f459 100644 --- a/config/stack_config.h +++ b/config/stack_config.h @@ -133,6 +133,9 @@ /* include support for IEC 61850 reporting services */ #define CONFIG_IEC61850_REPORT_SERVICE 1 +/* support buffered report control blocks with ResvTms field */ +#define CONFIG_IEC61850_BRCB_WITH_RESVTMS 0 + /* The default buffer size of buffered RCBs in bytes */ #define CONFIG_REPORTING_DEFAULT_REPORT_BUFFER_SIZE 65536 diff --git a/src/iec61850/server/mms_mapping/reporting.c b/src/iec61850/server/mms_mapping/reporting.c index 37ad50b0..0a8da537 100644 --- a/src/iec61850/server/mms_mapping/reporting.c +++ b/src/iec61850/server/mms_mapping/reporting.c @@ -43,6 +43,10 @@ #if (CONFIG_IEC61850_REPORT_SERVICE == 1) +#ifndef CONFIG_IEC61850_BRCB_WITH_RESVTMS +#define CONFIG_IEC61850_BRCB_WITH_RESVTMS 0 +#endif + static ReportBuffer* ReportBuffer_create(void) { @@ -836,15 +840,23 @@ createBufferedReportControlBlock(ReportControlBlock* reportControlBlock, rcb->name = copyString(reportControlBlock->name); rcb->type = MMS_STRUCTURE; + int brcbElementCount; + +#if (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1) + brcbElementCount = 15; +#else + brcbElementCount = 14; +#endif + + MmsValue* mmsValue = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); mmsValue->deleteValue = false; mmsValue->type = MMS_STRUCTURE; - mmsValue->value.structure.size = 15; - mmsValue->value.structure.components = (MmsValue**) GLOBAL_CALLOC(15, sizeof(MmsValue*)); - - rcb->typeSpec.structure.elementCount = 15; + mmsValue->value.structure.size = brcbElementCount; + mmsValue->value.structure.components = (MmsValue**) GLOBAL_CALLOC(brcbElementCount, sizeof(MmsValue*)); - rcb->typeSpec.structure.elements = (MmsVariableSpecification**) GLOBAL_CALLOC(15, + rcb->typeSpec.structure.elementCount = brcbElementCount; + rcb->typeSpec.structure.elements = (MmsVariableSpecification**) GLOBAL_CALLOC(brcbElementCount, sizeof(MmsVariableSpecification*)); MmsVariableSpecification* namedVariable = @@ -957,19 +969,24 @@ createBufferedReportControlBlock(ReportControlBlock* reportControlBlock, reportControl->timeOfEntry = mmsValue->value.structure.components[12]; + int currentIndex = 13; + +#if (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1) namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification)); namedVariable->name = copyString("ResvTms"); - namedVariable->type = MMS_UNSIGNED; - namedVariable->typeSpec.unsignedInteger = 32; - rcb->typeSpec.structure.elements[13] = namedVariable; - mmsValue->value.structure.components[13] = MmsValue_newUnsigned(32); + namedVariable->type = MMS_INTEGER; + namedVariable->typeSpec.integer = 16; + rcb->typeSpec.structure.elements[currentIndex] = namedVariable; + mmsValue->value.structure.components[currentIndex] = MmsValue_newInteger(16); + currentIndex++; +#endif /* (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1) */ namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification)); namedVariable->name = copyString("Owner"); namedVariable->type = MMS_OCTET_STRING; namedVariable->typeSpec.octetString = -64; - rcb->typeSpec.structure.elements[14] = namedVariable; - mmsValue->value.structure.components[14] = MmsValue_newOctetString(0, 4); /* size 4 is enough to store client IPv4 address */ + rcb->typeSpec.structure.elements[currentIndex] = namedVariable; + mmsValue->value.structure.components[currentIndex] = MmsValue_newOctetString(0, 4); /* size 4 is enough to store client IPv4 address */ reportControl->rcbValues = mmsValue;