diff --git a/src/iec61850/client/client_report_control.c b/src/iec61850/client/client_report_control.c index d9d187ef..bce37e21 100644 --- a/src/iec61850/client/client_report_control.c +++ b/src/iec61850/client/client_report_control.c @@ -32,12 +32,19 @@ #include "libiec61850_platform_includes.h" static bool -isBufferedRcb(const char* objectReference) +isBufferedRcb(const char* objectReference, bool* isValid) { const char* separator = strchr(objectReference, '.'); if (separator == NULL) + separator = strchr(objectReference, '$'); + + if (separator == NULL) { + *isValid = false; return false; + } + + *isValid = true; if (*(separator + 1) == 'B') return true; @@ -48,12 +55,24 @@ isBufferedRcb(const char* objectReference) ClientReportControlBlock ClientReportControlBlock_create(const char* objectReference) { - ClientReportControlBlock self = (ClientReportControlBlock) GLOBAL_CALLOC(1, sizeof(struct sClientReportControlBlock)); + bool isReferenceValid; + bool isBuffered; + + isBuffered = isBufferedRcb(objectReference, &isReferenceValid); + + if (isReferenceValid == false) { + if (DEBUG_IED_CLIENT) + printf("DEBUG_IED_CLIENT: RCB reference invalid\n"); + + return NULL; + } - //TODO check validity of object reference?! + ClientReportControlBlock self = (ClientReportControlBlock) GLOBAL_CALLOC(1, sizeof(struct sClientReportControlBlock)); - self->objectReference = StringUtils_copyString(objectReference); - self->isBuffered = isBufferedRcb(objectReference); + if (self) { + self->objectReference = StringUtils_copyString(objectReference); + self->isBuffered = isBuffered; + } return self; }