Update FSFW from upstream #71
@ -2,14 +2,5 @@
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
void cfdp::testFunc() {
|
||||
std::vector<void*> testVec;
|
||||
testVec.reserve(10);
|
||||
std::array<uint8_t, 4> customMsg = {1, 2, 3, 4};
|
||||
MessageToUserTlv tlv0(customMsg.data(), customMsg.size());
|
||||
std::cout << testVec.size() << std::endl;
|
||||
testVec[0] = &tlv0;
|
||||
FilestoreResponseTlv tlv1();
|
||||
}
|
||||
|
||||
cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {}
|
||||
|
@ -13,8 +13,6 @@
|
||||
|
||||
namespace cfdp {
|
||||
|
||||
void testFunc();
|
||||
|
||||
struct TransactionFinishedParams {
|
||||
TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status,
|
||||
FileDeliveryCode delivCode)
|
||||
@ -24,18 +22,17 @@ struct TransactionFinishedParams {
|
||||
ConditionCode condCode;
|
||||
FileDeliveryStatus status;
|
||||
FileDeliveryCode deliveryCode;
|
||||
std::pair<uint8_t, FilestoreResponseTlv**> fsResponses;
|
||||
std::vector<FilestoreResponseTlv*> fsResponses;
|
||||
StatusReportIF* statusReport = nullptr;
|
||||
};
|
||||
|
||||
struct MetadataRecvParams {
|
||||
struct MetadataRecvdParams {
|
||||
TransactionId id;
|
||||
EntityId sourceId;
|
||||
size_t fileSize;
|
||||
const char* sourceFileName;
|
||||
const char* destFileName;
|
||||
std::vector<MessageToUserTlv*> msgsToUser;
|
||||
// std::pair<uint8_t, MessageToUserTlv**> msgsToUser;
|
||||
};
|
||||
|
||||
struct FileSegmentRecvdParams {
|
||||
@ -65,17 +62,15 @@ class UserBase {
|
||||
|
||||
virtual void transactionIndication(TransactionId id) = 0;
|
||||
virtual void eofSentIndication(TransactionId id) = 0;
|
||||
|
||||
virtual void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) = 0;
|
||||
virtual void eofRecvIndication(TransactionId id) = 0;
|
||||
|
||||
// TODO: Parameters
|
||||
virtual void transactionFinishedIndication(TransactionFinishedParams params) = 0;
|
||||
virtual void metadataRecvdIndication(MetadataRecvParams params) = 0;
|
||||
virtual void metadataRecvdIndication(MetadataRecvdParams params) = 0;
|
||||
virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0;
|
||||
virtual void reportIndication() = 0;
|
||||
virtual void suspendedIndication() = 0;
|
||||
virtual void resumedIndication() = 0;
|
||||
virtual void reportIndication(TransactionId id, StatusReportIF& report) = 0;
|
||||
virtual void suspendedIndication(TransactionId id, ConditionCode code) = 0;
|
||||
virtual void resumedIndication(TransactionId id, size_t progress) = 0;
|
||||
virtual void faultIndication(TransactionId id, ConditionCode code, size_t progress) = 0;
|
||||
virtual void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) = 0;
|
||||
virtual void eofRecvIndication(TransactionId id) = 0;
|
||||
|
||||
private:
|
||||
HasFileSystemIF& vfs;
|
||||
|
@ -3,10 +3,10 @@
|
||||
#include "fsfw/FSFW.h"
|
||||
|
||||
FilestoreRequestTlv::FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode,
|
||||
cfdp::Lv &firstFileName)
|
||||
cfdp::StringLv &firstFileName)
|
||||
: FilestoreTlvBase(actionCode, firstFileName) {}
|
||||
|
||||
FilestoreRequestTlv::FilestoreRequestTlv(cfdp::Lv &firstFileName)
|
||||
FilestoreRequestTlv::FilestoreRequestTlv(cfdp::StringLv &firstFileName)
|
||||
: FilestoreTlvBase(cfdp::FilestoreActionCode::INVALID, firstFileName) {}
|
||||
|
||||
void FilestoreRequestTlv::setSecondFileName(cfdp::Lv *secondFileName) {
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
class FilestoreRequestTlv : public cfdp::FilestoreTlvBase {
|
||||
public:
|
||||
FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode, cfdp::Lv &firstFileName);
|
||||
FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode, cfdp::StringLv &firstFileName);
|
||||
|
||||
FilestoreRequestTlv(cfdp::Lv &firstFileName);
|
||||
explicit FilestoreRequestTlv(cfdp::StringLv &firstFileName);
|
||||
|
||||
void setSecondFileName(cfdp::Lv *secondFileName);
|
||||
|
||||
@ -29,8 +29,8 @@ class FilestoreRequestTlv : public cfdp::FilestoreTlvBase {
|
||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override;
|
||||
|
||||
uint8_t getLengthField() const override;
|
||||
cfdp::TlvTypes getType() const override;
|
||||
[[nodiscard]] uint8_t getLengthField() const override;
|
||||
[[nodiscard]] cfdp::TlvTypes getType() const override;
|
||||
|
||||
private:
|
||||
cfdp::Lv *secondFileName = nullptr;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "FilestoreResponseTlv.h"
|
||||
|
||||
FilestoreResponseTlv::FilestoreResponseTlv(cfdp::FilestoreActionCode actionCode, uint8_t statusCode,
|
||||
cfdp::Lv &firstFileName, cfdp::Lv *fsMsg)
|
||||
cfdp::StringLv &firstFileName, cfdp::Lv *fsMsg)
|
||||
: FilestoreTlvBase(actionCode, firstFileName), statusCode(statusCode), filestoreMsg(fsMsg) {}
|
||||
|
||||
FilestoreResponseTlv::FilestoreResponseTlv(cfdp::Lv &firstFileName, cfdp::Lv *fsMsg)
|
||||
FilestoreResponseTlv::FilestoreResponseTlv(cfdp::StringLv &firstFileName, cfdp::Lv *fsMsg)
|
||||
: FilestoreTlvBase(firstFileName), statusCode(0), filestoreMsg(fsMsg) {}
|
||||
|
||||
uint8_t FilestoreResponseTlv::getLengthField() const {
|
||||
@ -20,12 +20,12 @@ uint8_t FilestoreResponseTlv::getLengthField() const {
|
||||
return 1 + firstFileName.getSerializedSize() + optFieldsLen;
|
||||
}
|
||||
|
||||
void FilestoreResponseTlv::setSecondFileName(cfdp::Lv *secondFileName) {
|
||||
this->secondFileName = secondFileName;
|
||||
void FilestoreResponseTlv::setSecondFileName(cfdp::StringLv *secondFileName_) {
|
||||
this->secondFileName = secondFileName_;
|
||||
}
|
||||
|
||||
void FilestoreResponseTlv::setFilestoreMessage(cfdp::Lv *filestoreMsg) {
|
||||
this->filestoreMsg = filestoreMsg;
|
||||
void FilestoreResponseTlv::setFilestoreMessage(cfdp::Lv *filestoreMsg_) {
|
||||
this->filestoreMsg = filestoreMsg_;
|
||||
}
|
||||
|
||||
ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
|
@ -4,17 +4,18 @@
|
||||
#include "Lv.h"
|
||||
#include "TlvIF.h"
|
||||
#include "fsfw/cfdp/tlv/FilestoreTlvBase.h"
|
||||
#include "fsfw/cfdp/tlv/StringLv.h"
|
||||
#include "fsfw/cfdp/tlv/Tlv.h"
|
||||
|
||||
class FilestoreResponseTlv : public cfdp::FilestoreTlvBase {
|
||||
public:
|
||||
FilestoreResponseTlv(cfdp::Lv& firstFileName, cfdp::Lv* fsMsg);
|
||||
FilestoreResponseTlv(cfdp::StringLv& firstFileName, cfdp::Lv* fsMsg);
|
||||
|
||||
FilestoreResponseTlv(cfdp::FilestoreActionCode actionCode, uint8_t statusCode,
|
||||
cfdp::Lv& firstFileName, cfdp::Lv* fsMsg);
|
||||
cfdp::StringLv& firstFileName, cfdp::Lv* fsMsg);
|
||||
|
||||
uint8_t getStatusCode() const;
|
||||
void setSecondFileName(cfdp::Lv* secondFileName);
|
||||
[[nodiscard]] uint8_t getStatusCode() const;
|
||||
void setSecondFileName(cfdp::StringLv* secondFileName);
|
||||
void setFilestoreMessage(cfdp::Lv* filestoreMsg);
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
@ -31,12 +32,12 @@ class FilestoreResponseTlv : public cfdp::FilestoreTlvBase {
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override;
|
||||
|
||||
uint8_t getLengthField() const override;
|
||||
cfdp::TlvTypes getType() const override;
|
||||
[[nodiscard]] uint8_t getLengthField() const override;
|
||||
[[nodiscard]] cfdp::TlvTypes getType() const override;
|
||||
|
||||
private:
|
||||
uint8_t statusCode;
|
||||
cfdp::Lv* secondFileName = nullptr;
|
||||
cfdp::StringLv* secondFileName = nullptr;
|
||||
cfdp::Lv* filestoreMsg = nullptr;
|
||||
|
||||
ReturnValue_t deSerializeFromValue(const uint8_t** buffer, size_t* size,
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "StringLv.h"
|
||||
#include "fsfw/FSFW.h"
|
||||
|
||||
namespace cfdp {
|
||||
@ -65,8 +66,8 @@ static constexpr uint8_t FSR_DENY_DIR_NOT_ALLOWED = 0b0010;
|
||||
|
||||
class FilestoreTlvBase : public TlvIF {
|
||||
public:
|
||||
FilestoreTlvBase(cfdp::Lv& firstFileName) : firstFileName(firstFileName){};
|
||||
FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::Lv& firstFileName)
|
||||
explicit FilestoreTlvBase(cfdp::StringLv& firstFileName) : firstFileName(firstFileName){};
|
||||
FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::StringLv& firstFileName)
|
||||
: actionCode(actionCode), firstFileName(firstFileName){};
|
||||
|
||||
ReturnValue_t commonSerialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
@ -101,7 +102,7 @@ class FilestoreTlvBase : public TlvIF {
|
||||
if (*size < 3) {
|
||||
return SerializeIF::STREAM_TOO_SHORT;
|
||||
}
|
||||
cfdp::TlvTypes type = static_cast<cfdp::TlvTypes>(**buffer);
|
||||
auto type = static_cast<cfdp::TlvTypes>(**buffer);
|
||||
if (type != getType()) {
|
||||
return cfdp::INVALID_TLV_TYPE;
|
||||
}
|
||||
@ -117,7 +118,7 @@ class FilestoreTlvBase : public TlvIF {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
bool requiresSecondFileName() const {
|
||||
[[nodiscard]] bool requiresSecondFileName() const {
|
||||
using namespace cfdp;
|
||||
if (actionCode == FilestoreActionCode::RENAME_FILE or
|
||||
actionCode == FilestoreActionCode::APPEND_FILE or
|
||||
@ -141,9 +142,9 @@ class FilestoreTlvBase : public TlvIF {
|
||||
#endif
|
||||
}
|
||||
|
||||
FilestoreActionCode getActionCode() const { return actionCode; }
|
||||
[[nodiscard]] FilestoreActionCode getActionCode() const { return actionCode; }
|
||||
|
||||
void setActionCode(FilestoreActionCode actionCode) { this->actionCode = actionCode; }
|
||||
void setActionCode(FilestoreActionCode actionCode_) { this->actionCode = actionCode_; }
|
||||
|
||||
cfdp::Lv& getFirstFileName() { return firstFileName; }
|
||||
|
||||
@ -160,11 +161,11 @@ class FilestoreTlvBase : public TlvIF {
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t getSerializedSize() const override { return getLengthField() + 2; }
|
||||
[[nodiscard]] size_t getSerializedSize() const override { return getLengthField() + 2; }
|
||||
|
||||
protected:
|
||||
FilestoreActionCode actionCode = FilestoreActionCode::INVALID;
|
||||
cfdp::Lv& firstFileName;
|
||||
cfdp::StringLv& firstFileName;
|
||||
};
|
||||
|
||||
} // namespace cfdp
|
||||
|
@ -5,3 +5,5 @@ cfdp::StringLv::StringLv(const std::string& fileName)
|
||||
|
||||
cfdp::StringLv::StringLv(const char* filename, size_t len)
|
||||
: Lv(reinterpret_cast<const uint8_t*>(filename), len) {}
|
||||
|
||||
cfdp::StringLv::StringLv() : Lv() {}
|
||||
|
@ -9,6 +9,7 @@ namespace cfdp {
|
||||
|
||||
class StringLv : public Lv {
|
||||
public:
|
||||
StringLv();
|
||||
explicit StringLv(const std::string& fileName);
|
||||
explicit StringLv(const char* filename, size_t len);
|
||||
};
|
||||
|
@ -8,8 +8,6 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
|
||||
EntityId localId = EntityId(UnsignedByteField<uint16_t>(2));
|
||||
auto fhMock = FaultHandlerMock();
|
||||
auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock);
|
||||
// auto destHandler = DestHandler();
|
||||
cfdp::testFunc();
|
||||
|
||||
SECTION("State") {}
|
||||
}
|
@ -35,7 +35,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
|
||||
|
||||
// Add a filestore response
|
||||
std::string firstName = "hello.txt";
|
||||
cfdp::Lv firstNameLv(reinterpret_cast<const uint8_t*>(firstName.data()), firstName.size());
|
||||
cfdp::StringLv firstNameLv(firstName);
|
||||
FilestoreResponseTlv response(cfdp::FilestoreActionCode::DELETE_FILE,
|
||||
cfdp::FSR_APPEND_FILE_1_NOT_EXISTS, firstNameLv, nullptr);
|
||||
FilestoreResponseTlv* responsePtr = &response;
|
||||
@ -53,7 +53,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
|
||||
|
||||
// Add two filestore responses and a fault location parameter
|
||||
std::string secondName = "hello2.txt";
|
||||
cfdp::Lv secondNameLv(reinterpret_cast<const uint8_t*>(secondName.data()), secondName.size());
|
||||
cfdp::StringLv secondNameLv(secondName);
|
||||
FilestoreResponseTlv response2(cfdp::FilestoreActionCode::DENY_FILE, cfdp::FSR_SUCCESS,
|
||||
secondNameLv, nullptr);
|
||||
REQUIRE(response2.getSerializedSize() == 15);
|
||||
@ -101,7 +101,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
|
||||
sz = 0;
|
||||
buffer = fnBuffer.data();
|
||||
std::string firstName = "hello.txt";
|
||||
cfdp::Lv firstNameLv(reinterpret_cast<const uint8_t*>(firstName.data()), firstName.size());
|
||||
cfdp::StringLv firstNameLv(firstName);
|
||||
FilestoreResponseTlv response(cfdp::FilestoreActionCode::DELETE_FILE, cfdp::FSR_NOT_PERFORMED,
|
||||
firstNameLv, nullptr);
|
||||
FilestoreResponseTlv* responsePtr = &response;
|
||||
@ -130,7 +130,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
|
||||
|
||||
// Add two filestore responses and a fault location parameter
|
||||
std::string secondName = "hello2.txt";
|
||||
cfdp::Lv secondNameLv(reinterpret_cast<const uint8_t*>(secondName.data()), secondName.size());
|
||||
cfdp::StringLv secondNameLv(secondName);
|
||||
FilestoreResponseTlv response2(cfdp::FilestoreActionCode::DENY_FILE, cfdp::FSR_SUCCESS,
|
||||
secondNameLv, nullptr);
|
||||
REQUIRE(response2.getSerializedSize() == 15);
|
||||
|
@ -20,8 +20,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
|
||||
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
|
||||
|
||||
std::string firstFileName = "hello.txt";
|
||||
cfdp::Lv sourceFileName(reinterpret_cast<const uint8_t*>(firstFileName.data()),
|
||||
firstFileName.size());
|
||||
cfdp::StringLv sourceFileName(firstFileName);
|
||||
cfdp::Lv destFileName;
|
||||
FileSize fileSize(35);
|
||||
MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName);
|
||||
|
@ -25,9 +25,9 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
|
||||
|
||||
SECTION("Filestore Response TLV") {
|
||||
std::string name = "hello.txt";
|
||||
cfdp::Lv firstName(reinterpret_cast<const uint8_t*>(name.data()), name.size());
|
||||
cfdp::StringLv firstName(name);
|
||||
std::string name2 = "hello2.txt";
|
||||
cfdp::Lv secondName(reinterpret_cast<const uint8_t*>(name2.data()), name2.size());
|
||||
cfdp::StringLv secondName(name2);
|
||||
std::string msg = "12345";
|
||||
cfdp::Lv fsMsg(reinterpret_cast<const uint8_t*>(msg.data()), msg.size());
|
||||
FilestoreResponseTlv response(cfdp::FilestoreActionCode::APPEND_FILE, cfdp::FSR_SUCCESS,
|
||||
@ -42,8 +42,8 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
|
||||
REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
|
||||
cfdp::Lv emptyMsg;
|
||||
cfdp::Lv emptySecondName;
|
||||
cfdp::StringLv emptyMsg;
|
||||
cfdp::StringLv emptySecondName;
|
||||
FilestoreResponseTlv emptyTlv(firstName, &emptyMsg);
|
||||
emptyTlv.setSecondFileName(&emptySecondName);
|
||||
result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK);
|
||||
@ -59,9 +59,9 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") {
|
||||
|
||||
SECTION("Filestore Request TLV") {
|
||||
std::string name = "hello.txt";
|
||||
cfdp::Lv firstName(reinterpret_cast<const uint8_t*>(name.data()), name.size());
|
||||
cfdp::StringLv firstName(name);
|
||||
std::string name2 = "hello2.txt";
|
||||
cfdp::Lv secondName(reinterpret_cast<const uint8_t*>(name2.data()), name2.size());
|
||||
cfdp::StringLv secondName(name2);
|
||||
FilestoreRequestTlv request(cfdp::FilestoreActionCode::APPEND_FILE, firstName);
|
||||
|
||||
// second name not set yet
|
||||
|
@ -8,8 +8,10 @@ void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::Condition
|
||||
uint64_t progress) {}
|
||||
void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {}
|
||||
void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {}
|
||||
void cfdp::UserMock::metadataRecvdIndication(MetadataRecvParams params) {}
|
||||
void cfdp::UserMock::metadataRecvdIndication(MetadataRecvdParams params) {}
|
||||
void cfdp::UserMock::fileSegmentRecvdIndication(FileSegmentRecvdParams params) {}
|
||||
void cfdp::UserMock::reportIndication() {}
|
||||
void cfdp::UserMock::suspendedIndication() {}
|
||||
void cfdp::UserMock::resumedIndication() {}
|
||||
void cfdp::UserMock::reportIndication(TransactionId id, StatusReportIF& report) {}
|
||||
void cfdp::UserMock::suspendedIndication(TransactionId id, ConditionCode code) {}
|
||||
void cfdp::UserMock::resumedIndication(TransactionId id, size_t progress) {}
|
||||
void cfdp::UserMock::faultIndication(cfdp::TransactionId id, cfdp::ConditionCode code,
|
||||
size_t progress) {}
|
||||
|
@ -10,14 +10,15 @@ class UserMock : public UserBase {
|
||||
public:
|
||||
void transactionIndication(TransactionId id) override;
|
||||
void eofSentIndication(TransactionId id) override;
|
||||
void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) override;
|
||||
void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) override;
|
||||
void eofRecvIndication(TransactionId id) override;
|
||||
void transactionFinishedIndication(TransactionFinishedParams params) override;
|
||||
void metadataRecvdIndication(MetadataRecvParams params) override;
|
||||
void metadataRecvdIndication(MetadataRecvdParams params) override;
|
||||
void fileSegmentRecvdIndication(FileSegmentRecvdParams params) override;
|
||||
void reportIndication() override;
|
||||
void suspendedIndication() override;
|
||||
void resumedIndication() override;
|
||||
void reportIndication(TransactionId id, StatusReportIF& report) override;
|
||||
void suspendedIndication(TransactionId id, ConditionCode code) override;
|
||||
void resumedIndication(TransactionId id, size_t progress) override;
|
||||
void faultIndication(TransactionId id, ConditionCode code, size_t progress) override;
|
||||
};
|
||||
|
||||
} // namespace cfdp
|
||||
|
Loading…
Reference in New Issue
Block a user