EIVE upstream #29

Merged
muellerr merged 693 commits from use-eive-upstream into develop 2023-06-30 15:44:39 +02:00
71 changed files with 337 additions and 339 deletions
Showing only changes of commit 7eb63d6d79 - Show all commits

View File

@ -41,7 +41,7 @@ static constexpr ReturnValue_t INVALID_PDU_FORMAT = returnvalue::makeCode(CFDP_C
//! Checksum types according to the SANA Checksum Types registry
//! https://sanaregistry.org/r/checksum_identifiers/
enum ChecksumTypes {
enum ChecksumType {
// Modular legacy checksum
MODULAR = 0,
CRC_32_PROXIMITY_1 = 1,
@ -50,9 +50,9 @@ enum ChecksumTypes {
NULL_CHECKSUM = 15
};
enum PduTypes : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 };
enum PduType : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 };
enum TransmissionModes : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 };
enum TransmissionMode : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 };
enum SegmentMetadataFlag : bool { NOT_PRESENT = false, PRESENT = true };
@ -70,7 +70,7 @@ enum WidthInBytes : uint8_t {
FOUR_BYTES = 4,
};
enum FileDirectives : uint8_t {
enum FileDirective : uint8_t {
INVALID_DIRECTIVE = 0x0f,
// The _DIRECTIVE suffix is mandatory here because of some nameclash!
EOF_DIRECTIVE = 0x04,
@ -82,7 +82,7 @@ enum FileDirectives : uint8_t {
KEEP_ALIVE = 0x0c
};
enum ConditionCodes : uint8_t {
enum ConditionCode : uint8_t {
NO_CONDITION_FIELD = 0xff,
NO_ERROR = 0b0000,
POSITIVE_ACK_LIMIT_REACHED = 0b0001,
@ -99,8 +99,7 @@ enum ConditionCodes : uint8_t {
CANCEL_REQUEST_RECEIVED = 0b1111
};
enum FaultHandlerCodes {
enum FaultHandlerCode {
RESERVED = 0b0000,
NOTICE_OF_CANCELLATION = 0b0001,
NOTICE_OF_SUSPENSION = 0b0010,
@ -126,7 +125,7 @@ enum FileDeliveryStatus {
enum PromptResponseRequired : uint8_t { PROMPT_NAK = 0, PROMPT_KEEP_ALIVE = 1 };
enum TlvTypes : uint8_t {
enum TlvType : uint8_t {
FILESTORE_REQUEST = 0x00,
FILESTORE_RESPONSE = 0x01,
MSG_TO_USER = 0x02,

View File

@ -5,8 +5,8 @@ namespace cfdp {
FaultHandlerBase::FaultHandlerBase() = default;
FaultHandlerBase::~FaultHandlerBase() = default;
bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCodes code,
cfdp::FaultHandlerCodes& handler) const {
bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCode code,
cfdp::FaultHandlerCode& handler) const {
auto iter = faultHandlerMap.find(code);
if (iter == faultHandlerMap.end()) {
return false;
@ -15,32 +15,32 @@ bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCodes code,
return true;
}
bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes handler) {
bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode handler) {
if (not faultHandlerMap.contains(code)) {
return false;
}
if (handler != FaultHandlerCodes::NOTICE_OF_SUSPENSION and
handler != FaultHandlerCodes::ABANDON_TRANSACTION and
handler != FaultHandlerCodes::NOTICE_OF_CANCELLATION and
handler != FaultHandlerCodes::IGNORE_ERROR) {
if (handler != FaultHandlerCode::NOTICE_OF_SUSPENSION and
handler != FaultHandlerCode::ABANDON_TRANSACTION and
handler != FaultHandlerCode::NOTICE_OF_CANCELLATION and
handler != FaultHandlerCode::IGNORE_ERROR) {
return false;
}
faultHandlerMap[code] = handler;
return true;
}
bool FaultHandlerBase::reportFault(cfdp::TransactionId& id, cfdp::ConditionCodes code) {
bool FaultHandlerBase::reportFault(cfdp::TransactionId& id, cfdp::ConditionCode code) {
if (not faultHandlerMap.contains(code)) {
return false;
}
cfdp::FaultHandlerCodes fh = faultHandlerMap[code];
if (fh == cfdp::FaultHandlerCodes::IGNORE_ERROR) {
cfdp::FaultHandlerCode fh = faultHandlerMap[code];
if (fh == cfdp::FaultHandlerCode::IGNORE_ERROR) {
ignoreCb(id, code);
} else if (fh == cfdp::FaultHandlerCodes::ABANDON_TRANSACTION) {
} else if (fh == cfdp::FaultHandlerCode::ABANDON_TRANSACTION) {
abandonCb(id, code);
} else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) {
} else if (fh == cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION) {
noticeOfCancellationCb(id, code);
} else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION) {
} else if (fh == cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION) {
noticeOfSuspensionCb(id, code);
} else {
// Should never happen, but use defensive programming

View File

@ -43,33 +43,33 @@ class FaultHandlerBase {
* - true if the condition code is valid
* - false otherwise
*/
bool getFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes& handler) const;
bool getFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode& handler) const;
bool setFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes handler);
bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode handler);
bool reportFault(cfdp::TransactionId& id, cfdp::ConditionCodes code);
bool reportFault(cfdp::TransactionId& id, cfdp::ConditionCode code);
virtual void noticeOfSuspensionCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0;
virtual void noticeOfCancellationCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0;
virtual void abandonCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0;
virtual void ignoreCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0;
virtual void noticeOfSuspensionCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
virtual void noticeOfCancellationCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
virtual void abandonCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
virtual void ignoreCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0;
private:
etl::flat_map<cfdp::ConditionCodes, cfdp::FaultHandlerCodes, 10> faultHandlerMap = {
etl::pair{cfdp::ConditionCodes::POSITIVE_ACK_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::KEEP_ALIVE_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::INVALID_TRANSMISSION_MODE,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::FILE_SIZE_ERROR, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::UNSUPPORTED_CHECKSUM_TYPE,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::FILESTORE_REJECTION, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCodes::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}};
etl::flat_map<cfdp::ConditionCode, cfdp::FaultHandlerCode, 10> faultHandlerMap = {
etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED,
cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::INVALID_TRANSMISSION_MODE,
cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILE_SIZE_ERROR, cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE,
cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCode::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCode::IGNORE_ERROR}};
};
} // namespace cfdp

View File

@ -14,12 +14,12 @@
namespace cfdp {
struct TransactionFinishedParams {
TransactionFinishedParams(const TransactionId& id, ConditionCodes code, FileDeliveryCode delivCode,
TransactionFinishedParams(const TransactionId& id, ConditionCode code, FileDeliveryCode delivCode,
FileDeliveryStatus status)
: id(id), condCode(code), status(status), deliveryCode(delivCode) {}
const TransactionId& id;
ConditionCodes condCode;
ConditionCode condCode;
FileDeliveryStatus status;
FileDeliveryCode deliveryCode;
std::vector<FilestoreResponseTlv*> fsResponses;
@ -85,10 +85,10 @@ class UserBase {
virtual void metadataRecvdIndication(const MetadataRecvdParams& params) = 0;
virtual void fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) = 0;
virtual void reportIndication(const TransactionId& id, StatusReportIF& report) = 0;
virtual void suspendedIndication(const TransactionId& id, ConditionCodes code) = 0;
virtual void suspendedIndication(const TransactionId& id, ConditionCode code) = 0;
virtual void resumedIndication(const TransactionId& id, size_t progress) = 0;
virtual void faultIndication(const TransactionId& id, ConditionCodes code, size_t progress) = 0;
virtual void abandonedIndication(const TransactionId& id, ConditionCodes code,
virtual void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0;
virtual void abandonedIndication(const TransactionId& id, ConditionCode code,
size_t progress) = 0;
virtual void eofRecvIndication(const TransactionId& id) = 0;

View File

@ -32,8 +32,8 @@ struct RemoteEntityCfg {
size_t maxFileSegmentLen = 2048;
bool closureRequested = false;
bool crcOnTransmission = false;
TransmissionModes defaultTransmissionMode = TransmissionModes::UNACKNOWLEDGED;
ChecksumTypes defaultChecksum = ChecksumTypes::NULL_CHECKSUM;
TransmissionMode defaultTransmissionMode = TransmissionMode::UNACKNOWLEDGED;
ChecksumType defaultChecksum = ChecksumType::NULL_CHECKSUM;
const uint8_t version = CFDP_VERSION_2;
};

View File

@ -1,23 +1,21 @@
#include "helpers.h"
const char* COND_CODE_STRINGS[14] = {
"Unknown",
"No Error",
"Positive ACK Limit Reached",
"Keep Alive Limit Reached",
"Invalid Transmission Mode",
"Filestore Rejection",
"File Checksum Failure",
"File Size Error",
"NAK limit reached",
"Inactivity Detected",
"Check Limit Reached",
"Unsupported Checksum Type",
"Suspend Request Received",
"Cancel Request Received"
};
const char* COND_CODE_STRINGS[14] = {"Unknown",
"No Error",
"Positive ACK Limit Reached",
"Keep Alive Limit Reached",
"Invalid Transmission Mode",
"Filestore Rejection",
"File Checksum Failure",
"File Size Error",
"NAK limit reached",
"Inactivity Detected",
"Check Limit Reached",
"Unsupported Checksum Type",
"Suspend Request Received",
"Cancel Request Received"};
const char* cfdp::getConditionCodeString(cfdp::ConditionCodes code) {
const char* cfdp::getConditionCodeString(cfdp::ConditionCode code) {
switch (code) {
case NO_CONDITION_FIELD:
return COND_CODE_STRINGS[0];

View File

@ -5,7 +5,7 @@
namespace cfdp {
const char* getConditionCodeString(cfdp::ConditionCodes code);
const char* getConditionCodeString(cfdp::ConditionCode code);
}
#endif // FSFW_EXAMPLE_HOSTED_HELPER_H

View File

@ -1,32 +1,32 @@
#include "AckInfo.h"
AckInfo::AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCodes ackedConditionCode,
AckInfo::AckInfo(cfdp::FileDirective ackedDirective, cfdp::ConditionCode ackedConditionCode,
cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode)
: ackedDirective(ackedDirective),
ackedConditionCode(ackedConditionCode),
transactionStatus(transactionStatus),
directiveSubtypeCode(directiveSubtypeCode) {
if (ackedDirective == cfdp::FileDirectives::FINISH) {
if (ackedDirective == cfdp::FileDirective::FINISH) {
this->directiveSubtypeCode = 0b0001;
} else {
this->directiveSubtypeCode = 0b0000;
}
}
cfdp::ConditionCodes AckInfo::getAckedConditionCode() const { return ackedConditionCode; }
cfdp::ConditionCode AckInfo::getAckedConditionCode() const { return ackedConditionCode; }
void AckInfo::setAckedConditionCode(cfdp::ConditionCodes ackedConditionCode) {
void AckInfo::setAckedConditionCode(cfdp::ConditionCode ackedConditionCode) {
this->ackedConditionCode = ackedConditionCode;
if (ackedDirective == cfdp::FileDirectives::FINISH) {
if (ackedDirective == cfdp::FileDirective::FINISH) {
this->directiveSubtypeCode = 0b0001;
} else {
this->directiveSubtypeCode = 0b0000;
}
}
cfdp::FileDirectives AckInfo::getAckedDirective() const { return ackedDirective; }
cfdp::FileDirective AckInfo::getAckedDirective() const { return ackedDirective; }
void AckInfo::setAckedDirective(cfdp::FileDirectives ackedDirective) {
void AckInfo::setAckedDirective(cfdp::FileDirective ackedDirective) {
this->ackedDirective = ackedDirective;
}

View File

@ -6,14 +6,14 @@
class AckInfo {
public:
AckInfo();
AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCodes ackedConditionCode,
AckInfo(cfdp::FileDirective ackedDirective, cfdp::ConditionCode ackedConditionCode,
cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode = 0);
cfdp::ConditionCodes getAckedConditionCode() const;
void setAckedConditionCode(cfdp::ConditionCodes ackedConditionCode);
cfdp::ConditionCode getAckedConditionCode() const;
void setAckedConditionCode(cfdp::ConditionCode ackedConditionCode);
cfdp::FileDirectives getAckedDirective() const;
void setAckedDirective(cfdp::FileDirectives ackedDirective);
cfdp::FileDirective getAckedDirective() const;
void setAckedDirective(cfdp::FileDirective ackedDirective);
uint8_t getDirectiveSubtypeCode() const;
void setDirectiveSubtypeCode(uint8_t directiveSubtypeCode);
@ -22,8 +22,8 @@ class AckInfo {
void setTransactionStatus(cfdp::AckTransactionStatus transactionStatus);
private:
cfdp::FileDirectives ackedDirective = cfdp::FileDirectives::INVALID_DIRECTIVE;
cfdp::ConditionCodes ackedConditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD;
cfdp::FileDirective ackedDirective = cfdp::FileDirective::INVALID_DIRECTIVE;
cfdp::ConditionCode ackedConditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD;
cfdp::AckTransactionStatus transactionStatus = cfdp::AckTransactionStatus::UNDEFINED;
uint8_t directiveSubtypeCode = 0;
};

View File

@ -1,7 +1,7 @@
#include "AckPduCreator.h"
AckPduCreator::AckPduCreator(AckInfo &ackInfo, PduConfig &pduConf)
: FileDirectiveCreator(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {}
: FileDirectiveCreator(pduConf, cfdp::FileDirective::ACK, 2), ackInfo(ackInfo) {}
size_t AckPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); }
@ -11,12 +11,12 @@ ReturnValue_t AckPduCreator::serialize(uint8_t **buffer, size_t *size, size_t ma
if (result != returnvalue::OK) {
return result;
}
cfdp::FileDirectives ackedDirective = ackInfo.getAckedDirective();
cfdp::FileDirective ackedDirective = ackInfo.getAckedDirective();
uint8_t directiveSubtypeCode = ackInfo.getDirectiveSubtypeCode();
cfdp::ConditionCodes ackedConditionCode = ackInfo.getAckedConditionCode();
cfdp::ConditionCode ackedConditionCode = ackInfo.getAckedConditionCode();
cfdp::AckTransactionStatus transactionStatus = ackInfo.getTransactionStatus();
if (ackedDirective != cfdp::FileDirectives::FINISH and
ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE) {
if (ackedDirective != cfdp::FileDirective::FINISH and
ackedDirective != cfdp::FileDirective::EOF_DIRECTIVE) {
// TODO: better returncode
return returnvalue::FAILED;
}

View File

@ -19,7 +19,7 @@ ReturnValue_t AckPduReader::parseData() {
}
bool AckPduReader::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) {
cfdp::FileDirectives directive;
cfdp::FileDirective directive;
if (not checkAckedDirectiveField(firstByte, directive)) {
return false;
}
@ -29,17 +29,17 @@ bool AckPduReader::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) {
return false;
}
this->info.setDirectiveSubtypeCode(directiveSubtypeCode);
this->info.setAckedConditionCode(static_cast<cfdp::ConditionCodes>(secondByte >> 4));
this->info.setAckedConditionCode(static_cast<cfdp::ConditionCode>(secondByte >> 4));
this->info.setTransactionStatus(static_cast<cfdp::AckTransactionStatus>(secondByte & 0x0f));
return true;
}
bool AckPduReader::checkAckedDirectiveField(uint8_t firstPduDataByte,
cfdp::FileDirectives& ackedDirective) {
uint8_t ackedDirectiveRaw = static_cast<cfdp::FileDirectives>(firstPduDataByte >> 4);
if (ackedDirectiveRaw != cfdp::FileDirectives::EOF_DIRECTIVE and
ackedDirectiveRaw != cfdp::FileDirectives::FINISH) {
cfdp::FileDirective& ackedDirective) {
uint8_t ackedDirectiveRaw = static_cast<cfdp::FileDirective>(firstPduDataByte >> 4);
if (ackedDirectiveRaw != cfdp::FileDirective::EOF_DIRECTIVE and
ackedDirectiveRaw != cfdp::FileDirective::FINISH) {
return false;
}
ackedDirective = (static_cast<cfdp::FileDirectives>(ackedDirectiveRaw));
ackedDirective = (static_cast<cfdp::FileDirective>(ackedDirectiveRaw));
return true;
}

View File

@ -16,7 +16,7 @@ class AckPduReader : public FileDirectiveReader {
ReturnValue_t parseData() override;
static bool checkAckedDirectiveField(uint8_t firstPduDataByte,
cfdp::FileDirectives& ackedDirective);
cfdp::FileDirective& ackedDirective);
private:
bool checkAndSetCodes(uint8_t rawAckedByte, uint8_t rawAckedConditionCode);

View File

@ -1,18 +1,18 @@
#include "EofInfo.h"
EofInfo::EofInfo(cfdp::ConditionCodes conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
EofInfo::EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
EntityIdTlv* faultLoc)
: conditionCode(conditionCode), checksum(checksum), fileSize(fileSize), faultLoc(faultLoc) {}
EofInfo::EofInfo(EntityIdTlv* faultLoc)
: conditionCode(cfdp::ConditionCodes::NO_CONDITION_FIELD),
: conditionCode(cfdp::ConditionCode::NO_CONDITION_FIELD),
checksum(0),
fileSize(0),
faultLoc(faultLoc) {}
uint32_t EofInfo::getChecksum() const { return checksum; }
cfdp::ConditionCodes EofInfo::getConditionCode() const { return conditionCode; }
cfdp::ConditionCode EofInfo::getConditionCode() const { return conditionCode; }
EntityIdTlv* EofInfo::getFaultLoc() const { return faultLoc; }
@ -20,7 +20,7 @@ cfdp::FileSize& EofInfo::getFileSize() { return fileSize; }
void EofInfo::setChecksum(uint32_t checksum) { this->checksum = checksum; }
void EofInfo::setConditionCode(cfdp::ConditionCodes conditionCode) {
void EofInfo::setConditionCode(cfdp::ConditionCode conditionCode) {
this->conditionCode = conditionCode;
}
@ -36,7 +36,7 @@ size_t EofInfo::getSerializedSize(bool fssLarge) {
}
// Do not account for fault location if the condition code is NO_ERROR. We assume that
// a serializer will not serialize the fault location here.
if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCodes::NO_ERROR) {
if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
size += faultLoc->getSerializedSize();
}
return size;

View File

@ -8,23 +8,23 @@
struct EofInfo {
public:
explicit EofInfo(EntityIdTlv* faultLoc = nullptr);
EofInfo(cfdp::ConditionCodes conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize,
EntityIdTlv* faultLoc = nullptr);
size_t getSerializedSize(bool fssLarge = false);
[[nodiscard]] uint32_t getChecksum() const;
[[nodiscard]] cfdp::ConditionCodes getConditionCode() const;
[[nodiscard]] cfdp::ConditionCode getConditionCode() const;
[[nodiscard]] EntityIdTlv* getFaultLoc() const;
cfdp::FileSize& getFileSize();
void setChecksum(uint32_t checksum);
void setConditionCode(cfdp::ConditionCodes conditionCode);
void setConditionCode(cfdp::ConditionCode conditionCode);
void setFaultLoc(EntityIdTlv* faultLoc);
ReturnValue_t setFileSize(size_t size, bool isLarge);
private:
cfdp::ConditionCodes conditionCode;
cfdp::ConditionCode conditionCode;
uint32_t checksum;
cfdp::FileSize fileSize;
EntityIdTlv* faultLoc = nullptr;

View File

@ -3,7 +3,7 @@
#include "fsfw/FSFW.h"
EofPduCreator::EofPduCreator(PduConfig &conf, EofInfo &info)
: FileDirectiveCreator(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) {
: FileDirectiveCreator(conf, cfdp::FileDirective::EOF_DIRECTIVE, 9), info(info) {
setDirectiveDataFieldLen(info.getSerializedSize(HeaderCreator::getLargeFileFlag()));
}
@ -33,7 +33,7 @@ ReturnValue_t EofPduCreator::serialize(uint8_t **buffer, size_t *size, size_t ma
uint32_t fileSizeValue = info.getFileSize().getSize();
result = SerializeAdapter::serialize(&fileSizeValue, buffer, size, maxSize, streamEndianness);
}
if (info.getFaultLoc() != nullptr and info.getConditionCode() != cfdp::ConditionCodes::NO_ERROR) {
if (info.getFaultLoc() != nullptr and info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
result = info.getFaultLoc()->serialize(buffer, size, maxSize, streamEndianness);
}
return result;

View File

@ -25,7 +25,7 @@ ReturnValue_t EofPduReader::parseData() {
bufPtr += currentIdx;
deserLen -= currentIdx;
info.setConditionCode(static_cast<cfdp::ConditionCodes>(*bufPtr >> 4));
info.setConditionCode(static_cast<cfdp::ConditionCode>(*bufPtr >> 4));
bufPtr += 1;
deserLen -= 1;
uint32_t checksum = 0;
@ -47,7 +47,7 @@ ReturnValue_t EofPduReader::parseData() {
if (result != returnvalue::OK) {
return result;
}
if (info.getConditionCode() != cfdp::ConditionCodes::NO_ERROR) {
if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
EntityIdTlv* tlvPtr = info.getFaultLoc();
if (tlvPtr == nullptr) {
#if FSFW_VERBOSE_LEVEL >= 1

View File

@ -3,7 +3,7 @@
#include <cstring>
FileDataCreator::FileDataCreator(PduConfig& conf, FileDataInfo& info)
: HeaderCreator(conf, cfdp::PduTypes::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) {
: HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) {
update();
}

View File

@ -1,8 +1,8 @@
#include "FileDirectiveCreator.h"
FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirectives directiveCode,
FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirective directiveCode,
size_t directiveParamFieldLen)
: HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, directiveParamFieldLen + 1),
: HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1),
directiveCode(directiveCode) {}
size_t FileDirectiveCreator::getSerializedSize() const {
@ -36,4 +36,4 @@ void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) {
HeaderCreator::setPduDataFieldLen(len + 1);
}
cfdp::FileDirectives FileDirectiveCreator::getDirectiveCode() const { return directiveCode; }
cfdp::FileDirective FileDirectiveCreator::getDirectiveCode() const { return directiveCode; }

View File

@ -5,10 +5,10 @@
class FileDirectiveCreator : public HeaderCreator {
public:
FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirectives directiveCode,
FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirective directiveCode,
size_t directiveParamFieldLen);
[[nodiscard]] cfdp::FileDirectives getDirectiveCode() const;
[[nodiscard]] cfdp::FileDirective getDirectiveCode() const;
/**
* This only returns the size of the PDU header + 1 for the directive code octet.
@ -28,7 +28,7 @@ class FileDirectiveCreator : public HeaderCreator {
void setDirectiveDataFieldLen(size_t len);
private:
cfdp::FileDirectives directiveCode = cfdp::FileDirectives::INVALID_DIRECTIVE;
cfdp::FileDirective directiveCode = cfdp::FileDirective::INVALID_DIRECTIVE;
};
#endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_ */

View File

@ -3,7 +3,7 @@
FileDirectiveReader::FileDirectiveReader(const uint8_t *pduBuf, size_t maxSize)
: PduHeaderReader(pduBuf, maxSize) {}
cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return fileDirective; }
cfdp::FileDirective FileDirectiveReader::getFileDirective() const { return fileDirective; }
ReturnValue_t FileDirectiveReader::parseData() {
ReturnValue_t result = PduHeaderReader::parseData();
@ -20,7 +20,7 @@ ReturnValue_t FileDirectiveReader::parseData() {
if (not checkFileDirective(pointers.rawPtr[currentIdx])) {
return cfdp::INVALID_DIRECTIVE_FIELD;
}
setFileDirective(static_cast<cfdp::FileDirectives>(pointers.rawPtr[currentIdx]));
setFileDirective(static_cast<cfdp::FileDirective>(pointers.rawPtr[currentIdx]));
return returnvalue::OK;
}
@ -30,15 +30,15 @@ size_t FileDirectiveReader::getHeaderSize() const {
}
bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) {
if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or
(rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) {
if (rawByte < cfdp::FileDirective::EOF_DIRECTIVE or
(rawByte > cfdp::FileDirective::PROMPT and rawByte != cfdp::FileDirective::KEEP_ALIVE)) {
// Invalid directive field
return false;
}
return true;
}
void FileDirectiveReader::setFileDirective(cfdp::FileDirectives fileDirective_) {
void FileDirectiveReader::setFileDirective(cfdp::FileDirective fileDirective_) {
fileDirective = fileDirective_;
}

View File

@ -22,7 +22,7 @@ class FileDirectiveReader : public PduHeaderReader {
ReturnValue_t parseData() override;
[[nodiscard]] size_t getHeaderSize() const override;
[[nodiscard]] cfdp::FileDirectives getFileDirective() const;
[[nodiscard]] cfdp::FileDirective getFileDirective() const;
void setEndianness(SerializeIF::Endianness endianness);
[[nodiscard]] SerializeIF::Endianness getEndianness() const;
@ -30,8 +30,8 @@ class FileDirectiveReader : public PduHeaderReader {
protected:
private:
void setFileDirective(cfdp::FileDirectives fileDirective);
cfdp::FileDirectives fileDirective = cfdp::FileDirectives::INVALID_DIRECTIVE;
void setFileDirective(cfdp::FileDirective fileDirective);
cfdp::FileDirective fileDirective = cfdp::FileDirective::INVALID_DIRECTIVE;
SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK;
};

View File

@ -2,7 +2,7 @@
FinishedInfo::FinishedInfo() {}
FinishedInfo::FinishedInfo(cfdp::ConditionCodes conditionCode, cfdp::FileDeliveryCode deliveryCode,
FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode,
cfdp::FileDeliveryStatus fileStatus)
: conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {}
@ -76,9 +76,9 @@ ReturnValue_t FinishedInfo::getFaultLocation(EntityIdTlv** faultLocation) {
return returnvalue::OK;
}
cfdp::ConditionCodes FinishedInfo::getConditionCode() const { return conditionCode; }
cfdp::ConditionCode FinishedInfo::getConditionCode() const { return conditionCode; }
void FinishedInfo::setConditionCode(cfdp::ConditionCodes conditionCode) {
void FinishedInfo::setConditionCode(cfdp::ConditionCode conditionCode) {
this->conditionCode = conditionCode;
}

View File

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

View File

@ -1,7 +1,7 @@
#include "FinishedPduCreator.h"
FinishPduCreator::FinishPduCreator(PduConfig &conf, FinishedInfo &finishInfo)
: FileDirectiveCreator(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) {
: FileDirectiveCreator(conf, cfdp::FileDirective::FINISH, 0), finishInfo(finishInfo) {
updateDirectiveFieldLen();
}

View File

@ -15,7 +15,7 @@ ReturnValue_t FinishPduReader::parseData() {
return SerializeIF::STREAM_TOO_SHORT;
}
uint8_t firstByte = *buf;
auto condCode = static_cast<cfdp::ConditionCodes>((firstByte >> 4) & 0x0f);
auto condCode = static_cast<cfdp::ConditionCode>((firstByte >> 4) & 0x0f);
finishedInfo.setConditionCode(condCode);
finishedInfo.setDeliveryCode(static_cast<cfdp::FileDeliveryCode>(firstByte >> 2 & 0b1));
finishedInfo.setFileStatus(static_cast<cfdp::FileDeliveryStatus>(firstByte & 0b11));
@ -31,14 +31,14 @@ ReturnValue_t FinishPduReader::parseData() {
FinishedInfo& FinishPduReader::getInfo() { return finishedInfo; }
ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf,
cfdp::ConditionCodes conditionCode) {
cfdp::ConditionCode conditionCode) {
ReturnValue_t result = returnvalue::OK;
size_t fsResponsesIdx = 0;
auto endianness = getEndianness();
FilestoreResponseTlv** fsResponseArray = nullptr;
size_t fsResponseMaxArrayLen = 0;
EntityIdTlv* faultLocation = nullptr;
cfdp::TlvTypes nextTlv = cfdp::TlvTypes::INVALID_TLV;
cfdp::TlvType nextTlv = cfdp::TlvType::INVALID_TLV;
while (remLen > 0) {
// Simply forward parse the TLV type. Every TLV type except the last one must be a Filestore
// Response TLV, and even the last one can be a Filestore Response TLV if the fault
@ -46,8 +46,8 @@ ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const
if (currentIdx + 2 > maxSize) {
return SerializeIF::STREAM_TOO_SHORT;
}
nextTlv = static_cast<cfdp::TlvTypes>(*buf);
if (nextTlv == cfdp::TlvTypes::FILESTORE_RESPONSE) {
nextTlv = static_cast<cfdp::TlvType>(*buf);
if (nextTlv == cfdp::TlvType::FILESTORE_RESPONSE) {
if (fsResponseArray == nullptr) {
if (not finishedInfo.canHoldFsResponses()) {
return cfdp::FINISHED_CANT_PARSE_FS_RESPONSES;
@ -63,11 +63,11 @@ ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const
return result;
}
fsResponsesIdx += 1;
} else if (nextTlv == cfdp::TlvTypes::ENTITY_ID) {
} else if (nextTlv == cfdp::TlvType::ENTITY_ID) {
// This needs to be the last TLV and it should not be here if the condition code
// is "No Error" or "Unsupported Checksum Type"
if (conditionCode == cfdp::ConditionCodes::NO_ERROR or
conditionCode == cfdp::ConditionCodes::UNSUPPORTED_CHECKSUM_TYPE) {
if (conditionCode == cfdp::ConditionCode::NO_ERROR or
conditionCode == cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE) {
return cfdp::INVALID_TLV_TYPE;
}
result = finishedInfo.getFaultLocation(&faultLocation);

View File

@ -16,7 +16,7 @@ class FinishPduReader : public FileDirectiveReader {
FinishedInfo& finishedInfo;
ReturnValue_t parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf,
cfdp::ConditionCodes conditionCode);
cfdp::ConditionCode conditionCode);
};
#endif /* FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ */

View File

@ -1,6 +1,6 @@
#include "HeaderCreator.h"
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen,
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
cfdp::SegmentMetadataFlag segmentMetadataFlag,
cfdp::SegmentationControl segCtrl)
: pduType(pduType),
@ -65,17 +65,17 @@ void HeaderCreator::setPduDataFieldLen(size_t pduDataFieldLen_) {
pduDataFieldLen = pduDataFieldLen_;
}
void HeaderCreator::setPduType(cfdp::PduTypes pduType_) { pduType = pduType_; }
void HeaderCreator::setPduType(cfdp::PduType pduType_) { pduType = pduType_; }
void HeaderCreator::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag_) {
segmentMetadataFlag = segmentMetadataFlag_;
}
cfdp::PduTypes HeaderCreator::getPduType() const { return pduType; }
cfdp::PduType HeaderCreator::getPduType() const { return pduType; }
cfdp::Direction HeaderCreator::getDirection() const { return pduConf.direction; }
cfdp::TransmissionModes HeaderCreator::getTransmissionMode() const { return pduConf.mode; }
cfdp::TransmissionMode HeaderCreator::getTransmissionMode() const { return pduConf.mode; }
bool HeaderCreator::getCrcFlag() const { return pduConf.crcFlag; }

View File

@ -9,7 +9,7 @@
class HeaderCreator : public SerializeIF, public PduHeaderIF {
public:
HeaderCreator(
PduConfig& pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen,
PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT,
cfdp::SegmentationControl segCtrl =
cfdp::SegmentationControl::NO_RECORD_BOUNDARIES_PRESERVATION);
@ -29,15 +29,15 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
Endianness streamEndianness) override;
void setPduDataFieldLen(size_t pduDataFieldLen);
void setPduType(cfdp::PduTypes pduType);
void setPduType(cfdp::PduType pduType);
void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag);
[[nodiscard]] size_t getPduDataFieldLen() const override;
[[nodiscard]] size_t getWholePduSize() const override;
[[nodiscard]] cfdp::PduTypes getPduType() const override;
[[nodiscard]] cfdp::PduType getPduType() const override;
[[nodiscard]] cfdp::Direction getDirection() const override;
[[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override;
[[nodiscard]] cfdp::TransmissionMode getTransmissionMode() const override;
[[nodiscard]] bool getCrcFlag() const override;
[[nodiscard]] bool getLargeFileFlag() const override;
[[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override;
@ -52,7 +52,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override;
private:
cfdp::PduTypes pduType;
cfdp::PduType pduType;
cfdp::SegmentMetadataFlag segmentMetadataFlag;
cfdp::SegmentationControl segmentationCtrl;
size_t pduDataFieldLen;

View File

@ -57,16 +57,16 @@ size_t PduHeaderReader::getWholePduSize() const {
return getPduDataFieldLen() + PduHeaderReader::getHeaderSize();
}
cfdp::PduTypes PduHeaderReader::getPduType() const {
return static_cast<cfdp::PduTypes>((pointers.fixedHeader->firstByte >> 4) & 0x01);
cfdp::PduType PduHeaderReader::getPduType() const {
return static_cast<cfdp::PduType>((pointers.fixedHeader->firstByte >> 4) & 0x01);
}
cfdp::Direction PduHeaderReader::getDirection() const {
return static_cast<cfdp::Direction>((pointers.fixedHeader->firstByte >> 3) & 0x01);
}
cfdp::TransmissionModes PduHeaderReader::getTransmissionMode() const {
return static_cast<cfdp::TransmissionModes>((pointers.fixedHeader->firstByte >> 2) & 0x01);
cfdp::TransmissionMode PduHeaderReader::getTransmissionMode() const {
return static_cast<cfdp::TransmissionMode>((pointers.fixedHeader->firstByte >> 2) & 0x01);
}
bool PduHeaderReader::getCrcFlag() const { return (pointers.fixedHeader->firstByte >> 1) & 0x01; }

View File

@ -1,7 +1,7 @@
#include "KeepAlivePduCreator.h"
KeepAlivePduCreator::KeepAlivePduCreator(PduConfig &conf, cfdp::FileSize &progress)
: FileDirectiveCreator(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) {
: FileDirectiveCreator(conf, cfdp::FileDirective::KEEP_ALIVE, 4), progress(progress) {
updateDirectiveFieldLen();
}

View File

@ -1,6 +1,6 @@
#include "MetadataInfo.h"
MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumTypes checksumType,
MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType,
cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
cfdp::StringLv& destFileName)
: MetadataInfo(fileSize, sourceFileName, destFileName) {
@ -23,9 +23,9 @@ void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, std::optional<size
}
}
cfdp::ChecksumTypes MetadataInfo::getChecksumType() const { return checksumType; }
cfdp::ChecksumType MetadataInfo::getChecksumType() const { return checksumType; }
void MetadataInfo::setChecksumType(cfdp::ChecksumTypes checksumType_) {
void MetadataInfo::setChecksumType(cfdp::ChecksumType checksumType_) {
checksumType = checksumType_;
}

View File

@ -13,15 +13,15 @@ class MetadataInfo {
public:
MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
cfdp::StringLv& destFileName);
MetadataInfo(bool closureRequested, cfdp::ChecksumTypes checksumType, cfdp::FileSize& fileSize,
MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, cfdp::FileSize& fileSize,
cfdp::StringLv& sourceFileName, cfdp::StringLv& destFileName);
size_t getSerializedSize(bool fssLarge = false);
void setOptionsArray(cfdp::Tlv** optionsArray, std::optional<size_t> optionsLen,
std::optional<size_t> maxOptionsLen);
[[nodiscard]] cfdp::ChecksumTypes getChecksumType() const;
void setChecksumType(cfdp::ChecksumTypes checksumType);
[[nodiscard]] cfdp::ChecksumType getChecksumType() const;
void setChecksumType(cfdp::ChecksumType checksumType);
[[nodiscard]] bool isClosureRequested() const;
void setClosureRequested(bool closureRequested = false);
@ -42,7 +42,7 @@ class MetadataInfo {
private:
bool closureRequested = false;
cfdp::ChecksumTypes checksumType = cfdp::ChecksumTypes::NULL_CHECKSUM;
cfdp::ChecksumType checksumType = cfdp::ChecksumType::NULL_CHECKSUM;
cfdp::FileSize& fileSize;
cfdp::StringLv& sourceFileName;
cfdp::StringLv& destFileName;

View File

@ -1,7 +1,7 @@
#include "MetadataPduCreator.h"
MetadataPduCreator::MetadataPduCreator(PduConfig &conf, MetadataInfo &info)
: FileDirectiveCreator(conf, cfdp::FileDirectives::METADATA, 5), info(info) {
: FileDirectiveCreator(conf, cfdp::FileDirective::METADATA, 5), info(info) {
updateDirectiveFieldLen();
}

View File

@ -15,7 +15,7 @@ ReturnValue_t MetadataPduReader::parseData() {
return SerializeIF::STREAM_TOO_SHORT;
}
info.setClosureRequested((*buf >> 6) & 0x01);
info.setChecksumType(static_cast<cfdp::ChecksumTypes>(*buf & 0x0f));
info.setChecksumType(static_cast<cfdp::ChecksumType>(*buf & 0x0f));
remSize -= 1;
buf += 1;
auto endianness = getEndianness();

View File

@ -1,7 +1,7 @@
#include "NakPduCreator.h"
NakPduCreator::NakPduCreator(PduConfig &pduConf, NakInfo &nakInfo)
: FileDirectiveCreator(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) {
: FileDirectiveCreator(pduConf, cfdp::FileDirective::NAK, 0), nakInfo(nakInfo) {
updateDirectiveFieldLen();
}

View File

@ -2,7 +2,7 @@
#include <utility>
PduConfig::PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode,
PduConfig::PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionMode mode,
cfdp::TransactionSeqNum seqNum, bool crcFlag, bool largeFile,
cfdp::Direction direction)
: mode(mode),

View File

@ -7,11 +7,11 @@
class PduConfig {
public:
PduConfig() = default;
PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode,
PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionMode mode,
cfdp::TransactionSeqNum seqNum, bool crcFlag = false, bool largeFile = false,
cfdp::Direction direction = cfdp::Direction::TOWARDS_RECEIVER);
cfdp::TransmissionModes mode = cfdp::TransmissionModes::ACKNOWLEDGED;
cfdp::TransmissionMode mode = cfdp::TransmissionMode::ACKNOWLEDGED;
cfdp::TransactionSeqNum seqNum;
cfdp::EntityId sourceId;
cfdp::EntityId destId;

View File

@ -17,9 +17,9 @@ class PduHeaderIF {
[[nodiscard]] virtual size_t getWholePduSize() const = 0;
[[nodiscard]] virtual size_t getPduDataFieldLen() const = 0;
[[nodiscard]] virtual cfdp::PduTypes getPduType() const = 0;
[[nodiscard]] virtual cfdp::PduType getPduType() const = 0;
[[nodiscard]] virtual cfdp::Direction getDirection() const = 0;
[[nodiscard]] virtual cfdp::TransmissionModes getTransmissionMode() const = 0;
[[nodiscard]] virtual cfdp::TransmissionMode getTransmissionMode() const = 0;
[[nodiscard]] virtual bool getCrcFlag() const = 0;
[[nodiscard]] virtual bool getLargeFileFlag() const = 0;
[[nodiscard]] virtual cfdp::SegmentationControl getSegmentationControl() const = 0;

View File

@ -56,9 +56,9 @@ class PduHeaderReader : public RedirectableDataPointerIF, public PduHeaderIF {
[[nodiscard]] size_t getPduDataFieldLen() const override;
[[nodiscard]] size_t getWholePduSize() const override;
[[nodiscard]] cfdp::PduTypes getPduType() const override;
[[nodiscard]] cfdp::PduType getPduType() const override;
[[nodiscard]] cfdp::Direction getDirection() const override;
[[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override;
[[nodiscard]] cfdp::TransmissionMode getTransmissionMode() const override;
[[nodiscard]] bool getCrcFlag() const override;
[[nodiscard]] bool getLargeFileFlag() const override;
[[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override;

View File

@ -1,7 +1,7 @@
#include "PromptPduCreator.h"
PromptPduCreator::PromptPduCreator(PduConfig &conf, cfdp::PromptResponseRequired responseRequired)
: FileDirectiveCreator(conf, cfdp::FileDirectives::PROMPT, 1),
: FileDirectiveCreator(conf, cfdp::FileDirective::PROMPT, 1),
responseRequired(responseRequired) {}
size_t PromptPduCreator::getSerializedSize() const {

View File

@ -11,7 +11,7 @@ ReturnValue_t EntityIdTlv::serialize(uint8_t **buffer, size_t *size, size_t maxS
if (maxSize < this->getSerializedSize()) {
return BUFFER_TOO_SHORT;
}
**buffer = cfdp::TlvTypes::ENTITY_ID;
**buffer = cfdp::TlvType::ENTITY_ID;
*size += 1;
*buffer += 1;
size_t serLen = entityId.getSerializedSize();
@ -28,8 +28,8 @@ ReturnValue_t EntityIdTlv::deSerialize(const uint8_t **buffer, size_t *size,
if (*size < 3) {
return STREAM_TOO_SHORT;
}
cfdp::TlvTypes type = static_cast<cfdp::TlvTypes>(**buffer);
if (type != cfdp::TlvTypes::ENTITY_ID) {
cfdp::TlvType type = static_cast<cfdp::TlvType>(**buffer);
if (type != cfdp::TlvType::ENTITY_ID) {
return cfdp::INVALID_TLV_TYPE;
}
*buffer += 1;
@ -54,6 +54,6 @@ ReturnValue_t EntityIdTlv::deSerialize(cfdp::Tlv &tlv, Endianness endianness) {
uint8_t EntityIdTlv::getLengthField() const { return 1 + entityId.getSerializedSize(); }
cfdp::TlvTypes EntityIdTlv::getType() const { return cfdp::TlvTypes::ENTITY_ID; }
cfdp::TlvType EntityIdTlv::getType() const { return cfdp::TlvType::ENTITY_ID; }
cfdp::EntityId &EntityIdTlv::getEntityId() { return entityId; }

View File

@ -27,7 +27,7 @@ class EntityIdTlv : public TlvIF {
Endianness streamEndianness) override;
uint8_t getLengthField() const override;
cfdp::TlvTypes getType() const override;
cfdp::TlvType getType() const override;
cfdp::EntityId& getEntityId();

View File

@ -1,7 +1,7 @@
#include "FaultHandlerOverrideTlv.h"
FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCodes conditionCode,
cfdp::FaultHandlerCodes handlerCode)
FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode,
cfdp::FaultHandlerCode handlerCode)
: conditionCode(conditionCode), handlerCode(handlerCode) {}
FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() = default;
@ -32,8 +32,8 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_
if (*size < 3) {
return SerializeIF::STREAM_TOO_SHORT;
}
auto detectedType = static_cast<cfdp::TlvTypes>(**buffer);
if (detectedType != cfdp::TlvTypes::FAULT_HANDLER) {
auto detectedType = static_cast<cfdp::TlvType>(**buffer);
if (detectedType != cfdp::TlvType::FAULT_HANDLER) {
return cfdp::INVALID_TLV_TYPE;
}
*buffer += 1;
@ -44,11 +44,11 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_
}
*buffer += 1;
*size += 1;
this->conditionCode = static_cast<cfdp::ConditionCodes>((**buffer >> 4) & 0x0f);
this->handlerCode = static_cast<cfdp::FaultHandlerCodes>(**buffer & 0x0f);
this->conditionCode = static_cast<cfdp::ConditionCode>((**buffer >> 4) & 0x0f);
this->handlerCode = static_cast<cfdp::FaultHandlerCode>(**buffer & 0x0f);
*buffer += 1;
*size += 1;
return returnvalue::OK;
}
cfdp::TlvTypes FaultHandlerOverrideTlv::getType() const { return cfdp::TlvTypes::FAULT_HANDLER; }
cfdp::TlvType FaultHandlerOverrideTlv::getType() const { return cfdp::TlvType::FAULT_HANDLER; }

View File

@ -6,7 +6,7 @@
class FaultHandlerOverrideTlv : public TlvIF {
public:
FaultHandlerOverrideTlv();
FaultHandlerOverrideTlv(cfdp::ConditionCodes conditionCode, cfdp::FaultHandlerCodes handlerCode);
FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, cfdp::FaultHandlerCode handlerCode);
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override;
@ -16,11 +16,11 @@ class FaultHandlerOverrideTlv : public TlvIF {
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
[[nodiscard]] uint8_t getLengthField() const override;
[[nodiscard]] cfdp::TlvTypes getType() const override;
[[nodiscard]] cfdp::TlvType getType() const override;
private:
cfdp::ConditionCodes conditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD;
cfdp::FaultHandlerCodes handlerCode = cfdp::FaultHandlerCodes::RESERVED;
cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD;
cfdp::FaultHandlerCode handlerCode = cfdp::FaultHandlerCode::RESERVED;
};
#endif /* FSFW_SRC_FSFW_CFDP_TLV_FAULTHANDLEROVERRIDETLV_H_ */

View File

@ -76,4 +76,4 @@ ReturnValue_t FilestoreRequestTlv::deSerializeFromValue(const uint8_t **buffer,
return result;
}
cfdp::TlvTypes FilestoreRequestTlv::getType() const { return cfdp::TlvTypes::FILESTORE_REQUEST; }
cfdp::TlvType FilestoreRequestTlv::getType() const { return cfdp::TlvType::FILESTORE_REQUEST; }

View File

@ -30,7 +30,7 @@ class FilestoreRequestTlv : public cfdp::FilestoreTlvBase {
Endianness streamEndianness) override;
[[nodiscard]] uint8_t getLengthField() const override;
[[nodiscard]] cfdp::TlvTypes getType() const override;
[[nodiscard]] cfdp::TlvType getType() const override;
private:
cfdp::Lv *secondFileName = nullptr;

View File

@ -112,4 +112,4 @@ ReturnValue_t FilestoreResponseTlv::deSerialize(const cfdp::Tlv &tlv, Endianness
uint8_t FilestoreResponseTlv::getStatusCode() const { return statusCode; }
cfdp::TlvTypes FilestoreResponseTlv::getType() const { return cfdp::TlvTypes::FILESTORE_RESPONSE; }
cfdp::TlvType FilestoreResponseTlv::getType() const { return cfdp::TlvType::FILESTORE_RESPONSE; }

View File

@ -33,7 +33,7 @@ class FilestoreResponseTlv : public cfdp::FilestoreTlvBase {
Endianness streamEndianness) override;
[[nodiscard]] uint8_t getLengthField() const override;
[[nodiscard]] cfdp::TlvTypes getType() const override;
[[nodiscard]] cfdp::TlvType getType() const override;
private:
uint8_t statusCode;

View File

@ -102,7 +102,7 @@ class FilestoreTlvBase : public TlvIF {
if (*size < 3) {
return SerializeIF::STREAM_TOO_SHORT;
}
auto type = static_cast<cfdp::TlvTypes>(**buffer);
auto type = static_cast<cfdp::TlvType>(**buffer);
if (type != getType()) {
return cfdp::INVALID_TLV_TYPE;
}

View File

@ -1,4 +1,4 @@
#include "FlowLabelTlv.h"
FlowLabelTlv::FlowLabelTlv(uint8_t* value, size_t size)
: Tlv(cfdp::TlvTypes::FLOW_LABEL, value, size) {}
: Tlv(cfdp::TlvType::FLOW_LABEL, value, size) {}

View File

@ -1,9 +1,9 @@
#include "MessageToUserTlv.h"
MessageToUserTlv::MessageToUserTlv(uint8_t* value, size_t size)
: Tlv(cfdp::TlvTypes::MSG_TO_USER, value, size) {}
: Tlv(cfdp::TlvType::MSG_TO_USER, value, size) {}
MessageToUserTlv::MessageToUserTlv() : Tlv() {}
MessageToUserTlv::MessageToUserTlv(const std::vector<uint8_t>& data)
: Tlv(cfdp::TlvTypes::MSG_TO_USER, data.data(), data.size()) {}
: Tlv(cfdp::TlvType::MSG_TO_USER, data.data(), data.size()) {}

View File

@ -1,6 +1,6 @@
#include "Tlv.h"
cfdp::Tlv::Tlv(TlvTypes type, const uint8_t *value, size_t size)
cfdp::Tlv::Tlv(TlvType type, const uint8_t *value, size_t size)
: type(type), value(value, size, true) {
if (size > 0) {
zeroLen = false;
@ -17,7 +17,7 @@ ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSiz
if (*size + 2 > maxSize) {
return BUFFER_TOO_SHORT;
}
if (type == TlvTypes::INVALID_TLV) {
if (type == TlvType::INVALID_TLV) {
return INVALID_TLV_TYPE;
}
**buffer = type;
@ -59,7 +59,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
return INVALID_TLV_TYPE;
}
type = static_cast<TlvTypes>(rawType);
type = static_cast<TlvType>(rawType);
*buffer += 1;
*size -= 1;
@ -83,7 +83,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
const uint8_t *cfdp::Tlv::getValue() const { return value.getConstBuffer(); }
cfdp::TlvTypes cfdp::Tlv::getType() const { return type; }
cfdp::TlvType cfdp::Tlv::getType() const { return type; }
bool cfdp::Tlv::checkType(uint8_t rawType) {
if (rawType != 0x03 and rawType <= 6) {
@ -101,4 +101,4 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) {
uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; }
void cfdp::Tlv::setType(TlvTypes type) { this->type = type; }
void cfdp::Tlv::setType(TlvType type) { this->type = type; }

View File

@ -13,7 +13,7 @@ namespace cfdp {
*/
class Tlv : public TlvIF {
public:
Tlv(TlvTypes type, const uint8_t *value, size_t size);
Tlv(TlvType type, const uint8_t *value, size_t size);
Tlv();
/**
@ -47,15 +47,15 @@ class Tlv : public TlvIF {
void setValue(uint8_t *value, size_t len);
[[nodiscard]] const uint8_t *getValue() const;
void setType(TlvTypes type);
[[nodiscard]] TlvTypes getType() const override;
void setType(TlvType type);
[[nodiscard]] TlvType getType() const override;
[[nodiscard]] uint8_t getLengthField() const override;
private:
bool checkType(uint8_t rawType);
bool zeroLen = true;
TlvTypes type = TlvTypes::INVALID_TLV;
TlvType type = TlvType::INVALID_TLV;
SerialBufferAdapter<uint8_t> value;
};

View File

@ -8,7 +8,7 @@ class TlvIF : public SerializeIF {
virtual ~TlvIF(){};
virtual uint8_t getLengthField() const = 0;
virtual cfdp::TlvTypes getType() const = 0;
virtual cfdp::TlvType getType() const = 0;
};
#endif /* FSFW_SRC_FSFW_CFDP_TLVIF_H_ */

View File

@ -25,12 +25,12 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
const cfdp::EntityId& sourceId(groundEntityId);
const cfdp::EntityId& destId(obswEntityId);
cfdp::TransactionSeqNum seqNum(UnsignedByteField<uint16_t>(12));
auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionModes::UNACKNOWLEDGED, seqNum);
auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionMode::UNACKNOWLEDGED, seqNum);
std::string sourceFileString = "hello.txt";
cfdp::StringLv sourceFileName(sourceFileString);
std::string destFileString = "hello2.txt";
cfdp::StringLv destFileName(destFileString);
MetadataInfo metadataInfo(false, cfdp::ChecksumTypes::CRC_32, fileSize, sourceFileName,
MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName,
destFileName);
MetadataPduCreator creator(pduConf, metadataInfo);
uint8_t* dataPtr = nullptr;

View File

@ -5,80 +5,81 @@
TEST_CASE("CFDP Fault Handler", "[cfdp]") {
using namespace cfdp;
auto fhMock = FaultHandlerMock();
cfdp::FaultHandlerCodes fhCode;
cfdp::FaultHandlerCode fhCode;
cfdp::TransactionId id;
SECTION("State") {
// Verify initial condition
CHECK(fhMock.getFaultHandler(ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::POSITIVE_ACK_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::INVALID_TRANSMISSION_MODE, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::FILESTORE_REJECTION, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::FILE_CHECKSUM_FAILURE, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::FILE_SIZE_ERROR, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::NAK_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::INACTIVITY_DETECTED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.getFaultHandler(ConditionCode::CHECK_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
}
SECTION("Call Handler, Ignore Fault") {
auto& info = fhMock.getFhInfo(FaultHandlerCodes::IGNORE_ERROR);
CHECK(fhMock.reportFault(ConditionCode::CHECK_LIMIT_REACHED));
auto& info = fhMock.getFhInfo(FaultHandlerCode::IGNORE_ERROR);
CHECK(fhMock.reportFault(id, ConditionCode::CHECK_LIMIT_REACHED));
CHECK(info.callCount == 1);
CHECK(info.condCodes.back() == ConditionCode::CHECK_LIMIT_REACHED);
fhMock.reportFault(ConditionCode::FILE_CHECKSUM_FAILURE);
fhMock.reportFault(id, ConditionCode::FILE_CHECKSUM_FAILURE);
CHECK(info.callCount == 2);
CHECK(info.condCodes.back() == ConditionCode::FILE_CHECKSUM_FAILURE);
}
SECTION("Invalid Reported Code") { CHECK(not fhMock.reportFault(ConditionCode::NO_ERROR)); }
SECTION("Invalid Reported Code") { CHECK(not fhMock.reportFault(id, ConditionCode::NO_ERROR)); }
SECTION("Invalid FH code") {
CHECK(not fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
FaultHandlerCodes::RESERVED));
FaultHandlerCode::RESERVED));
CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode));
CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR);
CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCodes::IGNORE_ERROR));
CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR);
CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCode::IGNORE_ERROR));
CHECK(not fhMock.getFaultHandler(ConditionCode::NO_ERROR, fhCode));
}
SECTION("Set Other Fault Handler") {
CHECK(fhMock.setFaultHandler(ConditionCode::FILE_CHECKSUM_FAILURE,
FaultHandlerCodes::NOTICE_OF_CANCELLATION));
FaultHandlerCode::NOTICE_OF_CANCELLATION));
CHECK(fhMock.setFaultHandler(ConditionCode::INACTIVITY_DETECTED,
FaultHandlerCodes::ABANDON_TRANSACTION));
FaultHandlerCode::ABANDON_TRANSACTION));
CHECK(fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
FaultHandlerCodes::NOTICE_OF_SUSPENSION));
auto& ignoreInfo = fhMock.getFhInfo(FaultHandlerCodes::IGNORE_ERROR);
auto& cancellationInfo = fhMock.getFhInfo(FaultHandlerCodes::NOTICE_OF_CANCELLATION);
auto& suspensionInfo = fhMock.getFhInfo(FaultHandlerCodes::NOTICE_OF_SUSPENSION);
auto& abandonInfo = fhMock.getFhInfo(FaultHandlerCodes::ABANDON_TRANSACTION);
FaultHandlerCode::NOTICE_OF_SUSPENSION));
auto& ignoreInfo = fhMock.getFhInfo(FaultHandlerCode::IGNORE_ERROR);
auto& cancellationInfo = fhMock.getFhInfo(FaultHandlerCode::NOTICE_OF_CANCELLATION);
auto& suspensionInfo = fhMock.getFhInfo(FaultHandlerCode::NOTICE_OF_SUSPENSION);
auto& abandonInfo = fhMock.getFhInfo(FaultHandlerCode::ABANDON_TRANSACTION);
CHECK(fhMock.reportFault(ConditionCode::FILE_CHECKSUM_FAILURE));
CHECK(fhMock.reportFault(id, ConditionCode::FILE_CHECKSUM_FAILURE));
CHECK(cancellationInfo.callCount == 1);
CHECK(cancellationInfo.condCodes.back() == ConditionCode::FILE_CHECKSUM_FAILURE);
CHECK(ignoreInfo.callCount == 0);
CHECK(suspensionInfo.callCount == 0);
CHECK(abandonInfo.callCount == 0);
CHECK(fhMock.reportFault(ConditionCode::INACTIVITY_DETECTED));
CHECK(fhMock.reportFault(id, ConditionCode::INACTIVITY_DETECTED));
CHECK(cancellationInfo.callCount == 1);
CHECK(ignoreInfo.callCount == 0);
CHECK(suspensionInfo.callCount == 0);
CHECK(abandonInfo.callCount == 1);
CHECK(abandonInfo.condCodes.back() == ConditionCode::INACTIVITY_DETECTED);
CHECK(fhMock.reportFault(ConditionCode::KEEP_ALIVE_LIMIT_REACHED));
CHECK(fhMock.reportFault(id, ConditionCode::KEEP_ALIVE_LIMIT_REACHED));
CHECK(cancellationInfo.callCount == 1);
CHECK(ignoreInfo.callCount == 0);
CHECK(suspensionInfo.callCount == 1);

View File

@ -15,19 +15,19 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") {
auto seqNum = TransactionSeqNum(WidthInBytes::TWO_BYTES, 15);
auto sourceId = EntityId(WidthInBytes::TWO_BYTES, 1);
auto destId = EntityId(WidthInBytes::TWO_BYTES, 2);
auto pduConf = PduConfig(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
AckInfo ackInfo(FileDirectives::EOF_DIRECTIVE, ConditionCode::NO_ERROR,
auto pduConf = PduConfig(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
AckInfo ackInfo(FileDirective::EOF_DIRECTIVE, ConditionCode::NO_ERROR,
AckTransactionStatus::ACTIVE);
auto ackSerializer = AckPduCreator(ackInfo, pduConf);
result = ackSerializer.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
SECTION("Serialize") {
REQUIRE(buf[sz - 3] == cfdp::FileDirectives::ACK);
REQUIRE((buf[sz - 2] >> 4) == FileDirectives::EOF_DIRECTIVE);
REQUIRE(buf[sz - 3] == cfdp::FileDirective::ACK);
REQUIRE((buf[sz - 2] >> 4) == FileDirective::EOF_DIRECTIVE);
REQUIRE((buf[sz - 2] & 0x0f) == 0);
REQUIRE(buf[sz - 1] == AckTransactionStatus::ACTIVE);
ackInfo.setAckedDirective(FileDirectives::FINISH);
ackInfo.setAckedDirective(FileDirective::FINISH);
ackInfo.setAckedConditionCode(ConditionCode::FILESTORE_REJECTION);
ackInfo.setTransactionStatus(AckTransactionStatus::TERMINATED);
auto ackSerializer2 = AckPduCreator(ackInfo, pduConf);
@ -35,21 +35,21 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") {
sz = 0;
result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(buf[sz - 3] == cfdp::FileDirectives::ACK);
REQUIRE((buf[sz - 2] >> 4) == FileDirectives::FINISH);
REQUIRE(buf[sz - 3] == cfdp::FileDirective::ACK);
REQUIRE((buf[sz - 2] >> 4) == FileDirective::FINISH);
REQUIRE((buf[sz - 2] & 0x0f) == 0b0001);
REQUIRE((buf[sz - 1] >> 4) == ConditionCode::FILESTORE_REJECTION);
REQUIRE((buf[sz - 1] & 0b11) == AckTransactionStatus::TERMINATED);
bufptr = buf.data();
sz = 0;
ackInfo.setAckedDirective(FileDirectives::KEEP_ALIVE);
ackInfo.setAckedDirective(FileDirective::KEEP_ALIVE);
auto ackSerializer3 = AckPduCreator(ackInfo, pduConf);
result = ackSerializer3.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK);
// Invalid file directive
REQUIRE(result != returnvalue::OK);
ackInfo.setAckedDirective(FileDirectives::FINISH);
ackInfo.setAckedDirective(FileDirective::FINISH);
// buffer too small
result = ackSerializer.serialize(&bufptr, &sz, 8, SerializeIF::Endianness::NETWORK);
REQUIRE(result == SerializeIF::BUFFER_TOO_SHORT);
@ -60,12 +60,12 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") {
auto reader = AckPduReader(buf.data(), sz, ackInfo2);
result = reader.parseData();
REQUIRE(result == returnvalue::OK);
REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::EOF_DIRECTIVE);
REQUIRE(ackInfo2.getAckedDirective() == FileDirective::EOF_DIRECTIVE);
REQUIRE(ackInfo2.getAckedConditionCode() == ConditionCode::NO_ERROR);
REQUIRE(ackInfo2.getDirectiveSubtypeCode() == 0);
REQUIRE(ackInfo2.getTransactionStatus() == AckTransactionStatus::ACTIVE);
AckInfo newInfo = AckInfo(FileDirectives::FINISH, ConditionCode::FILESTORE_REJECTION,
AckInfo newInfo = AckInfo(FileDirective::FINISH, ConditionCode::FILESTORE_REJECTION,
AckTransactionStatus::TERMINATED);
auto ackSerializer2 = AckPduCreator(newInfo, pduConf);
bufptr = buf.data();
@ -76,23 +76,23 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") {
auto reader2 = AckPduReader(buf.data(), sz, ackInfo2);
result = reader2.parseData();
REQUIRE(result == returnvalue::OK);
REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::FINISH);
REQUIRE(ackInfo2.getAckedDirective() == FileDirective::FINISH);
REQUIRE(ackInfo2.getAckedConditionCode() == ConditionCode::FILESTORE_REJECTION);
REQUIRE(ackInfo2.getDirectiveSubtypeCode() == 0b0001);
REQUIRE(ackInfo2.getTransactionStatus() == AckTransactionStatus::TERMINATED);
uint8_t prevVal = buf[sz - 2];
buf[sz - 2] = FileDirectives::INVALID_DIRECTIVE << 4;
buf[sz - 2] = FileDirective::INVALID_DIRECTIVE << 4;
result = reader2.parseData();
REQUIRE(result == cfdp::INVALID_ACK_DIRECTIVE_FIELDS);
buf[sz - 2] = FileDirectives::FINISH << 4 | 0b1111;
buf[sz - 2] = FileDirective::FINISH << 4 | 0b1111;
result = reader2.parseData();
REQUIRE(result == cfdp::INVALID_ACK_DIRECTIVE_FIELDS);
buf[sz - 2] = prevVal;
buf[sz - 3] = cfdp::FileDirectives::INVALID_DIRECTIVE;
buf[sz - 3] = cfdp::FileDirective::INVALID_DIRECTIVE;
result = reader2.parseData();
REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELD);
buf[sz - 3] = cfdp::FileDirectives::ACK;
buf[sz - 3] = cfdp::FileDirective::ACK;
auto maxSizeTooSmall = AckPduReader(buf.data(), sz - 2, ackInfo2);
result = maxSizeTooSmall.parseData();
REQUIRE(result == SerializeIF::STREAM_TOO_SHORT);

View File

@ -17,11 +17,11 @@ TEST_CASE("CFDP Header", "[cfdp]") {
cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0);
cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1);
PduConfig pduConf =
PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false);
PduConfig(sourceId, destId, cfdp::TransmissionMode::ACKNOWLEDGED, seqNum, false);
uint8_t* serTarget = serBuf.data();
const uint8_t* deserTarget = serTarget;
size_t serSize = 0;
auto creator = HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, 0);
auto creator = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0);
SECTION("Header State") {
REQUIRE(seqNum.getSerializedSize() == 1);
@ -33,10 +33,10 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(creator.getLargeFileFlag() == false);
REQUIRE(creator.getLenEntityIds() == 1);
REQUIRE(creator.getLenSeqNum() == 1);
REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT);
REQUIRE(creator.getSegmentationControl() == false);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionMode::ACKNOWLEDGED);
cfdp::TransactionSeqNum seqNumLocal;
creator.getTransactionSeqNum(seqNumLocal);
REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::ONE_BYTE);
@ -85,9 +85,9 @@ TEST_CASE("CFDP Header", "[cfdp]") {
pduConf.crcFlag = true;
pduConf.largeFile = true;
pduConf.direction = cfdp::Direction::TOWARDS_SENDER;
pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED;
pduConf.mode = cfdp::TransmissionMode::UNACKNOWLEDGED;
creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION);
creator.setPduType(cfdp::PduTypes::FILE_DATA);
creator.setPduType(cfdp::PduType::FILE_DATA);
creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT);
serTarget = serBuf.data();
serSize = 0;
@ -103,9 +103,9 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(creator.getLargeFileFlag() == true);
REQUIRE(creator.getLenEntityIds() == 1);
REQUIRE(creator.getLenSeqNum() == 1);
REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA);
REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA);
REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionMode::UNACKNOWLEDGED);
REQUIRE(creator.getSegmentationControl() == true);
}
@ -122,9 +122,9 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(creator.getLargeFileFlag() == true);
REQUIRE(creator.getLenEntityIds() == 4);
REQUIRE(creator.getLenSeqNum() == 2);
REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA);
REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA);
REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionMode::UNACKNOWLEDGED);
REQUIRE(creator.getSegmentationControl() == true);
// Last three bits are 2 now (length of seq number) and bit 1 to bit 3 is 4 (len entity IDs)
REQUIRE(serBuf[3] == 0b11001010);
@ -235,10 +235,10 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(reader.getLargeFileFlag() == false);
REQUIRE(reader.getLenEntityIds() == 1);
REQUIRE(reader.getLenSeqNum() == 1);
REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT);
REQUIRE(reader.getSegmentationControl() == false);
REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED);
REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionMode::ACKNOWLEDGED);
// No PDU data contained, so the PDU data field is empty
REQUIRE(reader.getPduDataField() == nullptr);
@ -253,9 +253,9 @@ TEST_CASE("CFDP Header", "[cfdp]") {
pduConf.crcFlag = true;
pduConf.largeFile = true;
pduConf.direction = cfdp::Direction::TOWARDS_SENDER;
pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED;
pduConf.mode = cfdp::TransmissionMode::UNACKNOWLEDGED;
creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION);
creator.setPduType(cfdp::PduTypes::FILE_DATA);
creator.setPduType(cfdp::PduType::FILE_DATA);
creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT);
result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff);
REQUIRE(result == returnvalue::OK);
@ -278,10 +278,10 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(reader.getLargeFileFlag() == true);
REQUIRE(reader.getLenEntityIds() == 4);
REQUIRE(reader.getLenSeqNum() == 2);
REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DATA);
REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DATA);
REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT);
REQUIRE(reader.getSegmentationControl() == true);
REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED);
REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionMode::UNACKNOWLEDGED);
// Again, no data field set because this is a header only
REQUIRE(reader.getPduDataField() == nullptr);

View File

@ -20,7 +20,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") {
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
auto eofSerializer = EofPduCreator(pduConf, eofInfo);
SECTION("Serialize") {
@ -37,7 +37,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") {
SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(fileSizeVal == 12);
REQUIRE(buf[sz - 10] == cfdp::FileDirectives::EOF_DIRECTIVE);
REQUIRE(buf[sz - 10] == cfdp::FileDirective::EOF_DIRECTIVE);
REQUIRE(buf[sz - 9] == 0x00);
REQUIRE(sz == 20);
@ -52,13 +52,13 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") {
SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(sz == 28);
REQUIRE(buf[10] == cfdp::FileDirectives::EOF_DIRECTIVE);
REQUIRE(buf[10] == cfdp::FileDirective::EOF_DIRECTIVE);
REQUIRE(buf[11] >> 4 == cfdp::ConditionCode::FILESTORE_REJECTION);
uint64_t fileSizeLarge = 0;
result = SerializeAdapter::deSerialize(&fileSizeLarge, buf.data() + 16, nullptr,
SerializeIF::Endianness::NETWORK);
REQUIRE(fileSizeLarge == 0x10ffffff10);
REQUIRE(buf[sz - 4] == cfdp::TlvTypes::ENTITY_ID);
REQUIRE(buf[sz - 4] == cfdp::TlvType::ENTITY_ID);
// width of entity ID is 2
REQUIRE(buf[sz - 3] == 2);
uint16_t entityIdRaw = 0;
@ -105,7 +105,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") {
REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::FILESTORE_REJECTION);
REQUIRE(emptyInfo.getChecksum() == 5);
REQUIRE(emptyInfo.getFileSize().getSize() == 0x10ffffff10);
REQUIRE(emptyInfo.getFaultLoc()->getType() == cfdp::TlvTypes::ENTITY_ID);
REQUIRE(emptyInfo.getFaultLoc()->getType() == cfdp::TlvType::ENTITY_ID);
REQUIRE(emptyInfo.getFaultLoc()->getSerializedSize() == 4);
uint16_t destId = emptyInfo.getFaultLoc()->getEntityId().getValue();
REQUIRE(destId == 2);

View File

@ -17,7 +17,7 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") {
EntityId destId(WidthInBytes::TWO_BYTES, 2);
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
for (uint8_t idx = 0; idx < 10; idx++) {
fileBuffer[idx] = idx;

View File

@ -12,11 +12,11 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0);
cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1);
PduConfig pduConf =
PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false);
PduConfig(sourceId, destId, cfdp::TransmissionMode::ACKNOWLEDGED, seqNum, false);
uint8_t* serTarget = serBuf.data();
const uint8_t* deserTarget = serTarget;
size_t serSize = 0;
auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4);
auto fdSer = FileDirectiveCreator(pduConf, FileDirective::ACK, 4);
SECTION("Serialization") {
REQUIRE(fdSer.getSerializedSize() == 8);
@ -37,7 +37,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
REQUIRE(serBuf[5] == 2);
// Dest ID
REQUIRE(serBuf[6] == 1);
REQUIRE(serBuf[7] == FileDirectives::ACK);
REQUIRE(serBuf[7] == FileDirective::ACK);
}
SECTION("Serialization fails") {
@ -73,10 +73,10 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
REQUIRE(fdDeser.parseData() == returnvalue::OK);
REQUIRE(not fdDeser.isNull());
REQUIRE(fdDeser);
REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK);
REQUIRE(fdDeser.getFileDirective() == FileDirective::ACK);
REQUIRE(fdDeser.getPduDataFieldLen() == 5);
REQUIRE(fdDeser.getHeaderSize() == 8);
REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
serBuf[7] = 0xff;
// Invalid file directive

View File

@ -14,7 +14,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
EntityId destId(WidthInBytes::TWO_BYTES, 2);
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
cfdp::Lv emptyFsMsg;
FinishedInfo info(cfdp::ConditionCode::INACTIVITY_DETECTED,
@ -27,7 +27,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
REQUIRE(result == returnvalue::OK);
REQUIRE(serializer.getSerializedSize() == 12);
REQUIRE(((fnBuffer[1] << 8) | fnBuffer[2]) == 2);
REQUIRE(fnBuffer[10] == cfdp::FileDirectives::FINISH);
REQUIRE(fnBuffer[10] == cfdp::FileDirective::FINISH);
REQUIRE(((fnBuffer[sz - 1] >> 4) & 0x0f) == cfdp::ConditionCode::INACTIVITY_DETECTED);
REQUIRE(((fnBuffer[sz - 1] >> 2) & 0x01) == cfdp::FileDeliveryCode::DATA_INCOMPLETE);
REQUIRE((fnBuffer[sz - 1] & 0b11) == cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY);
@ -176,7 +176,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") {
fnBuffer[11] = tmp;
// Invalid TLV type, should be entity ID
fnBuffer[sz - 4] = cfdp::TlvTypes::FILESTORE_REQUEST;
fnBuffer[sz - 4] = cfdp::TlvType::FILESTORE_REQUEST;
result = deserializer3.parseData();
REQUIRE(result == cfdp::INVALID_TLV_TYPE);

View File

@ -14,7 +14,7 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") {
EntityId destId(WidthInBytes::TWO_BYTES, 2);
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
FileSize progress(0x50);
@ -22,7 +22,7 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") {
KeepAlivePduCreator serializer(pduConf, progress);
result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(kaBuffer[10] == cfdp::FileDirectives::KEEP_ALIVE);
REQUIRE(kaBuffer[10] == cfdp::FileDirective::KEEP_ALIVE);
uint32_t fsRaw = 0;
result = SerializeAdapter::deSerialize(&fsRaw, kaBuffer.data() + 11, nullptr,
SerializeIF::Endianness::NETWORK);

View File

@ -17,13 +17,13 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
EntityId destId(WidthInBytes::TWO_BYTES, 2);
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
std::string firstFileName = "hello.txt";
cfdp::StringLv sourceFileName(firstFileName);
cfdp::StringLv destFileName;
FileSize fileSize(35);
MetadataInfo info(false, ChecksumTypes::MODULAR, fileSize, sourceFileName, destFileName);
MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName);
FilestoreResponseTlv response(FilestoreActionCode::CREATE_DIRECTORY, FSR_CREATE_NOT_ALLOWED,
sourceFileName, nullptr);
@ -46,7 +46,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
REQUIRE(info.getDestFileName().getSerializedSize() == 1);
REQUIRE(info.getSerializedSize() == 16);
REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 17);
REQUIRE(mdBuffer[10] == FileDirectives::METADATA);
REQUIRE(mdBuffer[10] == FileDirective::METADATA);
// no closure requested and checksum type is modular => 0x00
REQUIRE(mdBuffer[11] == 0x00);
uint32_t fileSizeRaw = 0;
@ -74,7 +74,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
REQUIRE(info.getMaxOptionsLen() == 2);
info.setMaxOptionsLen(3);
REQUIRE(info.getMaxOptionsLen() == 3);
info.setChecksumType(cfdp::ChecksumTypes::CRC_32C);
info.setChecksumType(cfdp::ChecksumType::CRC_32C);
info.setClosureRequested(true);
uint8_t* buffer = mdBuffer.data();
size_t sz = 0;
@ -83,8 +83,8 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 37);
auto checksumType = static_cast<cfdp::ChecksumTypes>(mdBuffer[11] & 0x0f);
REQUIRE(checksumType == cfdp::ChecksumTypes::CRC_32C);
auto checksumType = static_cast<cfdp::ChecksumType>(mdBuffer[11] & 0x0f);
REQUIRE(checksumType == cfdp::ChecksumType::CRC_32C);
bool closureRequested = mdBuffer[11] >> 6 & 0x01;
REQUIRE(closureRequested == true);
// The size of the two options is 19. Summing up:
@ -130,7 +130,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
size_t maxSize = 4;
info.setOptionsArray(options.data(), sizeOfOptions, maxSize);
REQUIRE(info.getOptionsLen() == 2);
info.setChecksumType(cfdp::ChecksumTypes::CRC_32C);
info.setChecksumType(cfdp::ChecksumType::CRC_32C);
info.setClosureRequested(true);
uint8_t* buffer = mdBuffer.data();
size_t sz = 0;
@ -143,9 +143,9 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
MetadataPduReader deserializer2(mdBuffer.data(), mdBuffer.size(), info);
result = deserializer2.parseData();
REQUIRE(result == returnvalue::OK);
REQUIRE(options[0]->getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
REQUIRE(options[0]->getType() == cfdp::TlvType::FILESTORE_RESPONSE);
REQUIRE(options[0]->getSerializedSize() == 14);
REQUIRE(options[1]->getType() == cfdp::TlvTypes::MSG_TO_USER);
REQUIRE(options[1]->getType() == cfdp::TlvType::MSG_TO_USER);
REQUIRE(options[1]->getSerializedSize() == 5);
for (size_t invalidFieldLen = 0; invalidFieldLen < 36; invalidFieldLen++) {

View File

@ -15,7 +15,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") {
EntityId destId(WidthInBytes::TWO_BYTES, 2);
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
FileSize startOfScope(50);
FileSize endOfScope(1050);
@ -29,7 +29,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") {
REQUIRE(sz == 19);
REQUIRE(serializer.getPduDataFieldLen() == 9);
REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 0x09);
REQUIRE(nakBuffer[10] == cfdp::FileDirectives::NAK);
REQUIRE(nakBuffer[10] == cfdp::FileDirective::NAK);
uint32_t scope = 0;
result = SerializeAdapter::deSerialize(&scope, nakBuffer.data() + 11, nullptr,
SerializeIF::Endianness::NETWORK);

View File

@ -14,7 +14,7 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") {
EntityId destId(WidthInBytes::TWO_BYTES, 2);
TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15);
EntityId sourceId(WidthInBytes::TWO_BYTES, 1);
PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum);
PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum);
SECTION("Serialize") {
PromptPduCreator serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE);
@ -23,7 +23,7 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") {
REQUIRE(serializer.getWholePduSize() == 12);
REQUIRE(sz == 12);
REQUIRE(serializer.getPduDataFieldLen() == 2);
REQUIRE(rawBuf[10] == FileDirectives::PROMPT);
REQUIRE(rawBuf[10] == FileDirective::PROMPT);
REQUIRE(((rawBuf[sz - 1] >> 7) & 0x01) == cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE);
for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) {

View File

@ -16,13 +16,13 @@ TEST_CASE("CFDP Base", "[cfdp]") {
cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0);
cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1);
PduConfig pduConf =
PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false);
PduConfig(sourceId, destId, cfdp::TransmissionMode::ACKNOWLEDGED, seqNum, false);
uint8_t* serTarget = serBuf.data();
const uint8_t* deserTarget = serTarget;
size_t serSize = 0;
SECTION("File Directive") {
auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4);
auto fdSer = FileDirectiveCreator(pduConf, FileDirective::ACK, 4);
REQUIRE(fdSer.getSerializedSize() == 8);
serTarget = serBuf.data();
serSize = 0;
@ -41,7 +41,7 @@ TEST_CASE("CFDP Base", "[cfdp]") {
REQUIRE(serBuf[5] == 2);
// Dest ID
REQUIRE(serBuf[6] == 1);
REQUIRE(serBuf[7] == FileDirectives::ACK);
REQUIRE(serBuf[7] == FileDirective::ACK);
serTarget = serBuf.data();
size_t deserSize = 20;
@ -65,10 +65,10 @@ TEST_CASE("CFDP Base", "[cfdp]") {
REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE);
fdDeser.setEndianness(SerializeIF::Endianness::NETWORK);
REQUIRE(fdDeser.parseData() == returnvalue::OK);
REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK);
REQUIRE(fdDeser.getFileDirective() == FileDirective::ACK);
REQUIRE(fdDeser.getPduDataFieldLen() == 5);
REQUIRE(fdDeser.getHeaderSize() == 8);
REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
serBuf[7] = 0xff;
// Invalid file directive

View File

@ -41,7 +41,7 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(),
SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
REQUIRE(rawResponse.getType() == cfdp::TlvType::FILESTORE_RESPONSE);
cfdp::StringLv emptyMsg;
cfdp::StringLv emptySecondName;
FilestoreResponseTlv emptyTlv(firstName, &emptyMsg);
@ -96,12 +96,12 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(),
SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
REQUIRE(rawRequest.getType() == cfdp::TlvType::FILESTORE_REQUEST);
emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE);
result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST);
REQUIRE(emptyRequest.getType() == cfdp::TlvType::FILESTORE_REQUEST);
REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE);
}
@ -111,7 +111,7 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
FlowLabelTlv flowLabelTlv(&flowLabel, 1);
FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION,
cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION);
cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION);
size_t sz = 0;
result =
faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK);
@ -128,7 +128,7 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") {
EntityIdTlv idTlv(emptyId);
serPtr = rawBuf.data();
result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2);
cfdp::Tlv rawTlv(cfdp::TlvType::ENTITY_ID, rawBuf.data() + 2, 2);
REQUIRE(result == returnvalue::OK);
deserPtr = rawBuf.data();
result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK);

View File

@ -22,14 +22,14 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
SECTION("TLV Serialization") {
std::array<uint8_t, 8> tlvBuf{};
REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == returnvalue::OK);
auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize);
auto tlv = Tlv(TlvType::ENTITY_ID, tlvBuf.data(), deserSize);
REQUIRE(tlv.getSerializedSize() == 4);
REQUIRE(tlv.getLengthField() == 2);
deserSize = 0;
REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) ==
returnvalue::OK);
REQUIRE(deserSize == 4);
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
REQUIRE(rawBuf[0] == TlvType::ENTITY_ID);
REQUIRE(rawBuf[1] == 2);
uint16_t entityId = 0;
REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize,
@ -38,7 +38,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
}
SECTION("TLV Other Value") {
auto tlv = Tlv(TlvTypes::ENTITY_ID, rawBuf.data(), deserSize);
auto tlv = Tlv(TlvType::ENTITY_ID, rawBuf.data(), deserSize);
// Set new value
sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12);
REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(),
@ -48,17 +48,17 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
deserSize = 0;
result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID);
REQUIRE(rawBuf[0] == TlvType::ENTITY_ID);
REQUIRE(rawBuf[1] == 4);
REQUIRE(result == returnvalue::OK);
}
SECTION("TLV Invalid") {
auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0);
auto tlvInvalid = Tlv(cfdp::TlvType::INVALID_TLV, rawBuf.data(), 0);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) != returnvalue::OK);
tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3);
tlvInvalid = Tlv(cfdp::TlvType::ENTITY_ID, nullptr, 3);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) != returnvalue::OK);
REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) !=
@ -69,13 +69,13 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
}
SECTION("TLV Zero Length Field") {
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
Tlv zeroLenField(TlvType::FAULT_HANDLER, nullptr, 0);
REQUIRE(zeroLenField.getSerializedSize() == 2);
serPtr = rawBuf.data();
deserSize = 0;
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),
SerializeIF::Endianness::NETWORK) == returnvalue::OK);
REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER);
REQUIRE(rawBuf[0] == TlvType::FAULT_HANDLER);
REQUIRE(rawBuf[1] == 0);
}
@ -85,7 +85,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
serPtr = tlvRawBuf.data();
result =
sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK);
auto tlvSerialization = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize);
auto tlvSerialization = Tlv(TlvType::ENTITY_ID, tlvRawBuf.data(), deserSize);
serPtr = rawBuf.data();
deserSize = 0;
result = tlvSerialization.serialize(&serPtr, &deserSize, rawBuf.size(),
@ -95,7 +95,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK);
REQUIRE(result == returnvalue::OK);
REQUIRE(tlv.getSerializedSize() == 4);
REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID);
REQUIRE(tlv.getType() == TlvType::ENTITY_ID);
deserPtr = tlv.getValue();
uint16_t entityId = 0;
deserSize = 0;
@ -109,12 +109,12 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") {
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) ==
SerializeIF::STREAM_TOO_SHORT);
// Set invalid TLV
rawBuf[0] = TlvTypes::INVALID_TLV;
rawBuf[0] = TlvType::INVALID_TLV;
deserSize = 4;
REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) !=
returnvalue::OK);
Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0);
Tlv zeroLenField(TlvType::FAULT_HANDLER, nullptr, 0);
serPtr = rawBuf.data();
deserSize = 0;
REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(),

View File

@ -2,31 +2,31 @@
namespace cfdp {
void FaultHandlerMock::noticeOfSuspensionCb(cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION);
void FaultHandlerMock::noticeOfSuspensionCb(TransactionId& id, cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION);
info.callCount++;
info.condCodes.push(code);
}
void FaultHandlerMock::noticeOfCancellationCb(cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION);
void FaultHandlerMock::noticeOfCancellationCb(TransactionId& id, cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION);
info.callCount++;
info.condCodes.push(code);
}
void FaultHandlerMock::abandonCb(cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::ABANDON_TRANSACTION);
void FaultHandlerMock::abandonCb(TransactionId& id, cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::ABANDON_TRANSACTION);
info.callCount++;
info.condCodes.push(code);
}
void FaultHandlerMock::ignoreCb(cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::IGNORE_ERROR);
void FaultHandlerMock::ignoreCb(TransactionId& id, cfdp::ConditionCode code) {
auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::IGNORE_ERROR);
info.callCount++;
info.condCodes.push(code);
}
FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCodes fhCode) {
FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCode fhCode) {
return fhInfoMap.at(fhCode);
}
@ -34,7 +34,7 @@ void FaultHandlerMock::reset() { fhInfoMap.clear(); }
bool FaultHandlerMock::faultCbWasCalled() const {
return std::any_of(fhInfoMap.begin(), fhInfoMap.end(),
[](const std::pair<cfdp::FaultHandlerCodes, FaultInfo>& pair) {
[](const std::pair<cfdp::FaultHandlerCode, FaultInfo>& pair) {
return pair.second.callCount > 0;
});
}

View File

@ -15,21 +15,21 @@ class FaultHandlerMock : public FaultHandlerBase {
std::queue<cfdp::ConditionCode> condCodes;
};
void noticeOfSuspensionCb(ConditionCode code) override;
void noticeOfCancellationCb(ConditionCode code) override;
void abandonCb(ConditionCode code) override;
void ignoreCb(ConditionCode code) override;
void noticeOfSuspensionCb(TransactionId& id, ConditionCode code) override;
void noticeOfCancellationCb(TransactionId& id, ConditionCode code) override;
void abandonCb(TransactionId& id,ConditionCode code) override;
void ignoreCb(TransactionId& id, ConditionCode code) override;
FaultInfo& getFhInfo(FaultHandlerCodes fhCode);
FaultInfo& getFhInfo(FaultHandlerCode fhCode);
[[nodiscard]] bool faultCbWasCalled() const;
void reset();
private:
std::map<cfdp::FaultHandlerCodes, FaultInfo> fhInfoMap = {
std::pair{cfdp::FaultHandlerCodes::IGNORE_ERROR, FaultInfo()},
std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION, FaultInfo()},
std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION, FaultInfo()},
std::pair{cfdp::FaultHandlerCodes::ABANDON_TRANSACTION, FaultInfo()}};
std::map<cfdp::FaultHandlerCode, FaultInfo> fhInfoMap = {
std::pair{cfdp::FaultHandlerCode::IGNORE_ERROR, FaultInfo()},
std::pair{cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION, FaultInfo()},
std::pair{cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION, FaultInfo()},
std::pair{cfdp::FaultHandlerCode::ABANDON_TRANSACTION, FaultInfo()}};
};
} // namespace cfdp