fsfw/src/fsfw/cfdp/pdu/FinishedInfo.cpp
Robin Mueller 0ac1d1c1ca Added CFDP packet stack
This PR adds the packet stack for the CCSDS File Delivery Protocol.
It also refactors the existing TMTC infastructure to allow sending
of CFDP packets to the CCSDS handlers.

This includes the whole PDU (Protocol Data Unit) stack:

- File Data PDUs

and all file directive PDUs

- ACK PDU
- NAK PDU
- Metadata PDU
- Finished PDU
- Prompt PDU
- Keep Alive PDU
- EOF PDU

The PR includes a full set of unittests for the packet stack
with a coverage of 90+ %.

The refactoring of the existing TMTC infastructure includes non-ideal
solutions like diamond inheritance.
Avoiding this solution would require refactoring the packet stack.
This would be a good idea anyway because the existing stack is tightly
coupled to the FSFW, making reuse more difficult if only the stack is
planned to be used without the store functionalities etc.

The PDU implementation provided here is only weakly coupled to the FSFW,
only using components like returnvalues or the Serialization modules.
There are dedicated serializers and deserializers, which also helps in
creating small focused modules which are easy to test.

Some of the modules here were provied by Matthias Tompert.
2021-12-03 15:33:07 +01:00

112 lines
3.1 KiB
C++

#include "FinishedInfo.h"
FinishedInfo::FinishedInfo() {
}
FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode,
cfdp::FinishedDeliveryCode deliveryCode, cfdp::FinishedFileStatus fileStatus):
conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {
}
size_t FinishedInfo::getSerializedSize() const {
size_t size = 1;
if(hasFsResponses()) {
for(size_t idx = 0; idx < fsResponsesLen; idx++) {
size += fsResponses[idx]->getSerializedSize();
}
}
if(this->faultLocation != nullptr) {
size += faultLocation->getSerializedSize();
}
return size;
}
bool FinishedInfo::hasFsResponses() const {
if(fsResponses != nullptr and fsResponsesLen > 0) {
return true;
}
return false;
}
bool FinishedInfo::canHoldFsResponses() const {
if(fsResponses != nullptr and fsResponsesMaxLen > 0) {
return true;
}
return false;
}
ReturnValue_t FinishedInfo::setFilestoreResponsesArray(FilestoreResponseTlv** fsResponses,
size_t* fsResponsesLen, const size_t* maxFsResponsesLen) {
this->fsResponses = fsResponses;
if(fsResponsesLen != nullptr) {
this->fsResponsesLen = *fsResponsesLen;
if(this->fsResponsesMaxLen < *fsResponsesLen) {
this->fsResponsesMaxLen = this->fsResponsesLen;
}
}
if(maxFsResponsesLen != nullptr) {
this->fsResponsesMaxLen = *maxFsResponsesLen;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t FinishedInfo::getFilestoreResonses(FilestoreResponseTlv ***fsResponses,
size_t *fsResponsesLen, size_t* fsResponsesMaxLen) {
if(fsResponses == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
*fsResponses = this->fsResponses;
if(fsResponsesLen != nullptr) {
*fsResponsesLen = this->fsResponsesLen;
}
if(fsResponsesMaxLen != nullptr) {
*fsResponsesMaxLen = this->fsResponsesMaxLen;
}
return HasReturnvaluesIF::RETURN_OK;
}
void FinishedInfo::setFaultLocation(EntityIdTlv *faultLocation) {
this->faultLocation = faultLocation;
}
ReturnValue_t FinishedInfo::getFaultLocation(EntityIdTlv** faultLocation) {
if(this->faultLocation == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
*faultLocation = this->faultLocation;
return HasReturnvaluesIF::RETURN_OK;
}
cfdp::ConditionCode FinishedInfo::getConditionCode() const {
return conditionCode;
}
void FinishedInfo::setConditionCode(cfdp::ConditionCode conditionCode) {
this->conditionCode = conditionCode;
}
cfdp::FinishedDeliveryCode FinishedInfo::getDeliveryCode() const {
return deliveryCode;
}
void FinishedInfo::setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode) {
this->deliveryCode = deliveryCode;
}
cfdp::FinishedFileStatus FinishedInfo::getFileStatus() const {
return fileStatus;
}
void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) {
this->fsResponsesLen = fsResponsesLen;
}
size_t FinishedInfo::getFsResponsesLen() const {
return fsResponsesLen;
}
void FinishedInfo::setFileStatus(cfdp::FinishedFileStatus fileStatus) {
this->fileStatus = fileStatus;
}