- fixed - endless loop sending reports when MMS PDU size is too small (LIB61850-365)

pull/417/head
Michael Zillgith 3 years ago
parent 98f088a1d3
commit 91b0e6ed67

@ -3325,6 +3325,8 @@ sendNextReportEntrySegment(ReportControl* self)
MmsValue* subSeqNum = self->subSeqVal; MmsValue* subSeqNum = self->subSeqVal;
int numberOfAddedElements = 0;
for (i = 0; i < self->dataSet->elementCount; i++) { for (i = 0; i < self->dataSet->elementCount; i++) {
if ((report->flags > 0) || MmsValue_getBitStringBit(inclusionField, i)) { if ((report->flags > 0) || MmsValue_getBitStringBit(inclusionField, i)) {
@ -3406,6 +3408,8 @@ sendNextReportEntrySegment(ReportControl* self)
MmsValue_setBitStringBit(self->inclusionField, i, true); MmsValue_setBitStringBit(self->inclusionField, i, true);
numberOfAddedElements++;
accessResultSize += elementSize; accessResultSize += elementSize;
estimatedSegmentSize += elementSize; estimatedSegmentSize += elementSize;
} }
@ -3446,11 +3450,16 @@ sendNextReportEntrySegment(ReportControl* self)
uint32_t informationReportSize = 1 + informationReportContentSize + BerEncoder_determineLengthSize(informationReportContentSize); uint32_t informationReportSize = 1 + informationReportContentSize + BerEncoder_determineLengthSize(informationReportContentSize);
uint32_t completeMessageSize = 1 + informationReportSize + BerEncoder_determineLengthSize(informationReportSize); uint32_t completeMessageSize = 1 + informationReportSize + BerEncoder_determineLengthSize(informationReportSize);
if ((int) completeMessageSize > maxMmsPduSize) { if (((int) completeMessageSize > maxMmsPduSize) || (numberOfAddedElements == 0)) {
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("IED_SERVER: report message too large %u (max = %i) -> skip message!\n", completeMessageSize, maxMmsPduSize); printf("IED_SERVER: MMS PDU size too small to encode report data (max PDU size = %i) -> skip message!\n", maxMmsPduSize);
goto exit_function; self->startIndexForNextSegment = 0;
segmented = false;
moreFollows = false;
sentSuccess = true;
goto exit_remove_report;
} }
/* encode the report message */ /* encode the report message */
@ -3674,6 +3683,8 @@ sendNextReportEntrySegment(ReportControl* self)
self->startIndexForNextSegment = maxIndex; self->startIndexForNextSegment = maxIndex;
} }
exit_remove_report:
if (segmented == false) { if (segmented == false) {
assert(self->reportBuffer->nextToTransmit != self->reportBuffer->nextToTransmit->next); assert(self->reportBuffer->nextToTransmit != self->reportBuffer->nextToTransmit->next);

Loading…
Cancel
Save