added some param structs

This commit is contained in:
Robin Müller 2022-08-09 21:03:56 +02:00
parent 0cb15e901e
commit 507c6ddff1
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
12 changed files with 98 additions and 51 deletions

View File

@ -109,9 +109,9 @@ enum AckTransactionStatus {
UNRECOGNIZED = 0b11 UNRECOGNIZED = 0b11
}; };
enum FinishedDeliveryCode { DATA_COMPLETE = 0, DATA_INCOMPLETE = 1 }; enum FileDeliveryCode { DATA_COMPLETE = 0, DATA_INCOMPLETE = 1 };
enum FinishedFileStatus { enum FileDeliveryStatus {
DISCARDED_DELIBERATELY = 0, DISCARDED_DELIBERATELY = 0,
DISCARDED_FILESTORE_REJECTION = 1, DISCARDED_FILESTORE_REJECTION = 1,
RETAINED_IN_FILESTORE = 2, RETAINED_IN_FILESTORE = 2,

View File

@ -0,0 +1,12 @@
#ifndef FSFW_CFDP_HANDLER_STATUSREPORTIF_H
#define FSFW_CFDP_HANDLER_STATUSREPORTIF_H
namespace cfdp {
class StatusReportIF {
virtual ~StatusReportIF() = default;
};
} // namespace cfdp
#endif // FSFW_CFDP_HANDLER_STATUSREPORTIF_H

View File

@ -1,11 +1,47 @@
#ifndef FSFW_CFDP_USERBASE_H #ifndef FSFW_CFDP_USERBASE_H
#define FSFW_CFDP_USERBASE_H #define FSFW_CFDP_USERBASE_H
#include <optional>
#include <utility>
#include "StatusReportIF.h"
#include "fsfw/cfdp/VarLenFields.h" #include "fsfw/cfdp/VarLenFields.h"
#include "fsfw/cfdp/tlv/FilestoreResponseTlv.h"
#include "fsfw/cfdp/tlv/MessageToUserTlv.h"
#include "fsfw/filesystem/HasFileSystemIF.h" #include "fsfw/filesystem/HasFileSystemIF.h"
namespace cfdp { namespace cfdp {
struct TransactionFinishedParams {
TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status,
FileDeliveryCode delivCode)
: id(std::move(id)), condCode(code), status(status), deliveryCode(delivCode) {}
TransactionId id;
ConditionCode condCode;
FileDeliveryStatus status;
FileDeliveryCode deliveryCode;
std::pair<uint8_t, FilestoreResponseTlv**> fsResponses;
StatusReportIF* statusReport = nullptr;
};
struct MetadataRecvParams {
TransactionId id;
EntityId sourceId;
size_t fileSize;
const char* sourceFileName;
const char* destFileName;
std::pair<uint8_t, MessageToUserTlv**> msgsToUser;
};
struct FileSegmentRecvdParams {
TransactionId id;
size_t offset;
size_t length;
std::optional<RecordContinuationState> recContState = std::nullopt;
std::pair<const uint8_t*, size_t> segmentMetadata;
};
class UserBase { class UserBase {
public: public:
/** /**
@ -30,9 +66,9 @@ class UserBase {
virtual void eofRecvIndication(TransactionId id) = 0; virtual void eofRecvIndication(TransactionId id) = 0;
// TODO: Parameters // TODO: Parameters
virtual void transactionFinishedIndication() = 0; virtual void transactionFinishedIndication(TransactionFinishedParams params) = 0;
virtual void metadataRecvdIndication() = 0; virtual void metadataRecvdIndication(MetadataRecvParams params) = 0;
virtual void fileSegmentRecvdIndication() = 0; virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0;
virtual void reportIndication() = 0; virtual void reportIndication() = 0;
virtual void suspendedIndication() = 0; virtual void suspendedIndication() = 0;
virtual void resumedIndication() = 0; virtual void resumedIndication() = 0;

View File

@ -2,9 +2,8 @@
FinishedInfo::FinishedInfo() {} FinishedInfo::FinishedInfo() {}
FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode,
cfdp::FinishedDeliveryCode deliveryCode, cfdp::FileDeliveryStatus fileStatus)
cfdp::FinishedFileStatus fileStatus)
: conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {} : conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {}
size_t FinishedInfo::getSerializedSize() const { size_t FinishedInfo::getSerializedSize() const {
@ -83,13 +82,13 @@ void FinishedInfo::setConditionCode(cfdp::ConditionCode conditionCode) {
this->conditionCode = conditionCode; this->conditionCode = conditionCode;
} }
cfdp::FinishedDeliveryCode FinishedInfo::getDeliveryCode() const { return deliveryCode; } cfdp::FileDeliveryCode FinishedInfo::getDeliveryCode() const { return deliveryCode; }
void FinishedInfo::setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode) { void FinishedInfo::setDeliveryCode(cfdp::FileDeliveryCode deliveryCode) {
this->deliveryCode = deliveryCode; this->deliveryCode = deliveryCode;
} }
cfdp::FinishedFileStatus FinishedInfo::getFileStatus() const { return fileStatus; } cfdp::FileDeliveryStatus FinishedInfo::getFileStatus() const { return fileStatus; }
void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) { void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) {
this->fsResponsesLen = fsResponsesLen; this->fsResponsesLen = fsResponsesLen;
@ -97,6 +96,6 @@ void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) {
size_t FinishedInfo::getFsResponsesLen() const { return fsResponsesLen; } size_t FinishedInfo::getFsResponsesLen() const { return fsResponsesLen; }
void FinishedInfo::setFileStatus(cfdp::FinishedFileStatus fileStatus) { void FinishedInfo::setFileStatus(cfdp::FileDeliveryStatus fileStatus) {
this->fileStatus = fileStatus; this->fileStatus = fileStatus;
} }

View File

@ -8,8 +8,8 @@
class FinishedInfo { class FinishedInfo {
public: public:
FinishedInfo(); FinishedInfo();
FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FinishedDeliveryCode deliveryCode, FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode,
cfdp::FinishedFileStatus fileStatus); cfdp::FileDeliveryStatus fileStatus);
[[nodiscard]] size_t getSerializedSize() const; [[nodiscard]] size_t getSerializedSize() const;
@ -27,15 +27,15 @@ class FinishedInfo {
ReturnValue_t getFaultLocation(EntityIdTlv** entityId); ReturnValue_t getFaultLocation(EntityIdTlv** entityId);
[[nodiscard]] cfdp::ConditionCode getConditionCode() const; [[nodiscard]] cfdp::ConditionCode getConditionCode() const;
void setConditionCode(cfdp::ConditionCode conditionCode); void setConditionCode(cfdp::ConditionCode conditionCode);
[[nodiscard]] cfdp::FinishedDeliveryCode getDeliveryCode() const; [[nodiscard]] cfdp::FileDeliveryCode getDeliveryCode() const;
void setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode); void setDeliveryCode(cfdp::FileDeliveryCode deliveryCode);
[[nodiscard]] cfdp::FinishedFileStatus getFileStatus() const; [[nodiscard]] cfdp::FileDeliveryStatus getFileStatus() const;
void setFileStatus(cfdp::FinishedFileStatus fileStatus); void setFileStatus(cfdp::FileDeliveryStatus fileStatus);
private: private:
cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD;
cfdp::FinishedDeliveryCode deliveryCode = cfdp::FinishedDeliveryCode::DATA_COMPLETE; cfdp::FileDeliveryCode deliveryCode = cfdp::FileDeliveryCode::DATA_COMPLETE;
cfdp::FinishedFileStatus fileStatus = cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY; cfdp::FileDeliveryStatus fileStatus = cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY;
FilestoreResponseTlv** fsResponses = nullptr; FilestoreResponseTlv** fsResponses = nullptr;
size_t fsResponsesLen = 0; size_t fsResponsesLen = 0;
size_t fsResponsesMaxLen = 0; size_t fsResponsesMaxLen = 0;

View File

@ -18,8 +18,8 @@ ReturnValue_t FinishPduDeserializer::parseData() {
uint8_t firstByte = *buf; uint8_t firstByte = *buf;
auto condCode = static_cast<cfdp::ConditionCode>((firstByte >> 4) & 0x0f); auto condCode = static_cast<cfdp::ConditionCode>((firstByte >> 4) & 0x0f);
finishedInfo.setConditionCode(condCode); finishedInfo.setConditionCode(condCode);
finishedInfo.setDeliveryCode(static_cast<cfdp::FinishedDeliveryCode>(firstByte >> 2 & 0b1)); finishedInfo.setDeliveryCode(static_cast<cfdp::FileDeliveryCode>(firstByte >> 2 & 0b1));
finishedInfo.setFileStatus(static_cast<cfdp::FinishedFileStatus>(firstByte & 0b11)); finishedInfo.setFileStatus(static_cast<cfdp::FileDeliveryStatus>(firstByte & 0b11));
buf += 1; buf += 1;
remSize -= 1; remSize -= 1;
currentIdx += 1; currentIdx += 1;

View File

@ -27,10 +27,10 @@ class Tlv : public TlvIF {
* - INVALID_TLV_TYPE * - INVALID_TLV_TYPE
* - SerializeIF returncode on wrong serialization parameters * - SerializeIF returncode on wrong serialization parameters
*/ */
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override; Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override; [[nodiscard]] size_t getSerializedSize() const override;
/** /**
* @brief Deserialize a LV field from a raw buffer. Zero-copy implementation * @brief Deserialize a LV field from a raw buffer. Zero-copy implementation
@ -41,15 +41,15 @@ class Tlv : public TlvIF {
* - INVALID_TLV_TYPE * - INVALID_TLV_TYPE
* - SerializeIF returncode on wrong deserialization parameters * - SerializeIF returncode on wrong deserialization parameters
*/ */
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override; Endianness streamEndianness) override;
void setValue(uint8_t *value, size_t len); void setValue(uint8_t *value, size_t len);
const uint8_t *getValue() const; [[nodiscard]] const uint8_t *getValue() const;
void setType(TlvTypes type); void setType(TlvTypes type);
TlvTypes getType() const override; [[nodiscard]] TlvTypes getType() const override;
uint8_t getLengthField() const override; [[nodiscard]] uint8_t getLengthField() const override;
private: private:
bool checkType(uint8_t rawType); bool checkType(uint8_t rawType);

View File

@ -18,8 +18,8 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
cfdp::Lv emptyFsMsg; cfdp::Lv emptyFsMsg;
FinishedInfo info(cfdp::ConditionCode::INACTIVITY_DETECTED, FinishedInfo info(cfdp::ConditionCode::INACTIVITY_DETECTED,
cfdp::FinishedDeliveryCode::DATA_INCOMPLETE, cfdp::FileDeliveryCode::DATA_INCOMPLETE,
cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY);
SECTION("Serialize") { SECTION("Serialize") {
FinishPduSerializer serializer(pduConf, info); FinishPduSerializer serializer(pduConf, info);
@ -29,8 +29,8 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
REQUIRE(((fnBuffer[1] << 8) | fnBuffer[2]) == 2); REQUIRE(((fnBuffer[1] << 8) | fnBuffer[2]) == 2);
REQUIRE(fnBuffer[10] == cfdp::FileDirectives::FINISH); REQUIRE(fnBuffer[10] == cfdp::FileDirectives::FINISH);
REQUIRE(((fnBuffer[sz - 1] >> 4) & 0x0f) == cfdp::ConditionCode::INACTIVITY_DETECTED); REQUIRE(((fnBuffer[sz - 1] >> 4) & 0x0f) == cfdp::ConditionCode::INACTIVITY_DETECTED);
REQUIRE(((fnBuffer[sz - 1] >> 2) & 0x01) == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); REQUIRE(((fnBuffer[sz - 1] >> 2) & 0x01) == cfdp::FileDeliveryCode::DATA_INCOMPLETE);
REQUIRE((fnBuffer[sz - 1] & 0b11) == cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); REQUIRE((fnBuffer[sz - 1] & 0b11) == cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY);
REQUIRE(sz == 12); REQUIRE(sz == 12);
// Add a filestore response // Add a filestore response
@ -73,10 +73,10 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
info.setConditionCode(cfdp::ConditionCode::FILESTORE_REJECTION); info.setConditionCode(cfdp::ConditionCode::FILESTORE_REJECTION);
REQUIRE(serializer.getSerializedSize() == 12 + 14 + 15 + 4); REQUIRE(serializer.getSerializedSize() == 12 + 14 + 15 + 4);
REQUIRE(sz == 12 + 14 + 15 + 4); REQUIRE(sz == 12 + 14 + 15 + 4);
info.setFileStatus(cfdp::FinishedFileStatus::DISCARDED_FILESTORE_REJECTION); info.setFileStatus(cfdp::FileDeliveryStatus::DISCARDED_FILESTORE_REJECTION);
REQUIRE(info.getFileStatus() == cfdp::FinishedFileStatus::DISCARDED_FILESTORE_REJECTION); REQUIRE(info.getFileStatus() == cfdp::FileDeliveryStatus::DISCARDED_FILESTORE_REJECTION);
info.setDeliveryCode(cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); info.setDeliveryCode(cfdp::FileDeliveryCode::DATA_INCOMPLETE);
REQUIRE(info.getDeliveryCode() == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); REQUIRE(info.getDeliveryCode() == cfdp::FileDeliveryCode::DATA_INCOMPLETE);
for (size_t maxSz = 0; maxSz < 45; maxSz++) { for (size_t maxSz = 0; maxSz < 45; maxSz++) {
sz = 0; sz = 0;
buffer = fnBuffer.data(); buffer = fnBuffer.data();
@ -93,9 +93,9 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
FinishPduDeserializer deserializer(fnBuffer.data(), fnBuffer.size(), emptyInfo); FinishPduDeserializer deserializer(fnBuffer.data(), fnBuffer.size(), emptyInfo);
result = deserializer.parseData(); result = deserializer.parseData();
REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(emptyInfo.getFileStatus() == cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); REQUIRE(emptyInfo.getFileStatus() == cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY);
REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::INACTIVITY_DETECTED); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::INACTIVITY_DETECTED);
REQUIRE(emptyInfo.getDeliveryCode() == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); REQUIRE(emptyInfo.getDeliveryCode() == cfdp::FileDeliveryCode::DATA_INCOMPLETE);
// Add a filestore response // Add a filestore response
sz = 0; sz = 0;

View File

@ -1 +1,2 @@
target_sources(${FSFW_TEST_TGT} PRIVATE FaultHandlerMock.cpp UserMock.cpp RemoteConfigTableMock.cpp) target_sources(${FSFW_TEST_TGT} PRIVATE FaultHandlerMock.cpp UserMock.cpp
RemoteConfigTableMock.cpp)

View File

@ -5,11 +5,11 @@
namespace cfdp { namespace cfdp {
class RemoteConfigTableMock: public RemoteConfigTableIF { class RemoteConfigTableMock : public RemoteConfigTableIF {
public: public:
bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg *cfg) override; bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg *cfg) override;
}; };
} } // namespace cfdp
#endif // FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H #endif // FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H

View File

@ -7,10 +7,9 @@ void cfdp::UserMock::eofSentIndication(cfdp::TransactionId id) {}
void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::ConditionCode code, void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::ConditionCode code,
uint64_t progress) {} uint64_t progress) {}
void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {} void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {}
void cfdp::UserMock::transactionFinishedIndication() {} void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {}
void cfdp::UserMock::metadataRecvdIndication() {} void cfdp::UserMock::metadataRecvdIndication(MetadataRecvParams params) {}
void cfdp::UserMock::fileSegmentRecvdIndication() {} void cfdp::UserMock::fileSegmentRecvdIndication() {}
void cfdp::UserMock::reportIndication() {} void cfdp::UserMock::reportIndication() {}
void cfdp::UserMock::suspendedIndication() {} void cfdp::UserMock::suspendedIndication() {}
void cfdp::UserMock::resumedIndication() {} void cfdp::UserMock::resumedIndication() {}

View File

@ -2,24 +2,24 @@
#define FSFW_TESTS_CFDP_USERMOCK_H #define FSFW_TESTS_CFDP_USERMOCK_H
#include "fsfw/cfdp/handler/UserBase.h" #include "fsfw/cfdp/handler/UserBase.h"
namespace cfdp { namespace cfdp {
class UserMock: public UserBase { class UserMock : public UserBase {
explicit UserMock(HasFileSystemIF& vfs); explicit UserMock(HasFileSystemIF& vfs);
public: public:
void transactionIndication(TransactionId id) override; void transactionIndication(TransactionId id) override;
void eofSentIndication(TransactionId id) override; void eofSentIndication(TransactionId id) override;
void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) override; void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) override;
void eofRecvIndication(TransactionId id) override; void eofRecvIndication(TransactionId id) override;
void transactionFinishedIndication() override; void transactionFinishedIndication(TransactionFinishedParams params) override;
void metadataRecvdIndication() override; void metadataRecvdIndication(MetadataRecvParams params) override;
void fileSegmentRecvdIndication() override; void fileSegmentRecvdIndication() override;
void reportIndication() override; void reportIndication() override;
void suspendedIndication() override; void suspendedIndication() override;
void resumedIndication() override; void resumedIndication() override;
}; };
} } // namespace cfdp
#endif // FSFW_TESTS_CFDP_USERMOCK_H #endif // FSFW_TESTS_CFDP_USERMOCK_H