diff --git a/tcdistribution/CFDPDistributor.h b/tcdistribution/CFDPDistributor.h index d61357b2..3b4c31f2 100644 --- a/tcdistribution/CFDPDistributor.h +++ b/tcdistribution/CFDPDistributor.h @@ -1,10 +1,9 @@ #ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ +#include "TcPacketCheckCFDP.h" #include "CFDPDistributorIF.h" #include "TcDistributor.h" -#include "TcPacketCheck.h" - #include "../tmtcpacket/pus/tc.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../tmtcservices/AcceptsTelecommandsIF.h" @@ -43,7 +42,7 @@ protected: /** * This attribute contains the class, that performs a formal packet check. */ - TcPacketCheck checker; + TcPacketCheckCFDP checker; /** * With this class, verification messages are sent to the * TC Verification service. diff --git a/tcdistribution/CMakeLists.txt b/tcdistribution/CMakeLists.txt index 359b8a81..7118c38c 100644 --- a/tcdistribution/CMakeLists.txt +++ b/tcdistribution/CMakeLists.txt @@ -2,7 +2,8 @@ target_sources(${LIB_FSFW_NAME} PRIVATE CCSDSDistributor.cpp PUSDistributor.cpp TcDistributor.cpp - TcPacketCheck.cpp + TcPacketCheckPUS.cpp + TcPacketCheckCFDP.cpp CFDPDistributor.cpp ) diff --git a/tcdistribution/PUSDistributor.h b/tcdistribution/PUSDistributor.h index db93fbb3..1c9d4dfc 100644 --- a/tcdistribution/PUSDistributor.h +++ b/tcdistribution/PUSDistributor.h @@ -1,10 +1,9 @@ #ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ +#include "TcPacketCheckPUS.h" #include "PUSDistributorIF.h" #include "TcDistributor.h" -#include "TcPacketCheck.h" - #include "../tmtcpacket/pus/tc.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../tmtcservices/AcceptsTelecommandsIF.h" @@ -43,7 +42,7 @@ protected: /** * This attribute contains the class, that performs a formal packet check. */ - TcPacketCheck checker; + TcPacketCheckPUS checker; /** * With this class, verification messages are sent to the * TC Verification service. diff --git a/tcdistribution/TcPacketCheckCFDP.cpp b/tcdistribution/TcPacketCheckCFDP.cpp new file mode 100644 index 00000000..2b0e3d32 --- /dev/null +++ b/tcdistribution/TcPacketCheckCFDP.cpp @@ -0,0 +1,13 @@ +#include "TcPacketCheckCFDP.h" + + +TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid): apid(setApid) { +} + +ReturnValue_t TcPacketCheckCFDP::checkPacket(TcPacketStoredBase* currentPacket) { + return RETURN_OK; +} + +uint16_t TcPacketCheckCFDP::getApid() const { + return apid; +} diff --git a/tcdistribution/TcPacketCheckCFDP.h b/tcdistribution/TcPacketCheckCFDP.h new file mode 100644 index 00000000..41a65f08 --- /dev/null +++ b/tcdistribution/TcPacketCheckCFDP.h @@ -0,0 +1,35 @@ +#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ +#define FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ + +#include "TcPacketCheckIF.h" + +#include "../FSFW.h" + +class TcPacketStoredBase; + +/** + * This class performs a formal packet check for incoming CFDP Packets. + * @ingroup tc_distribution + */ +class TcPacketCheckCFDP : + public TcPacketCheckIF, + public HasReturnvaluesIF { +protected: + /** + * The packet id each correct packet should have. + * It is composed of the APID and some static fields. + */ + uint16_t apid; +public: + /** + * The constructor only sets the APID attribute. + * @param set_apid The APID to set. + */ + TcPacketCheckCFDP(uint16_t setApid); + + ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) override; + + uint16_t getApid() const; +}; + +#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ */ diff --git a/tcdistribution/TcPacketCheckIF.h b/tcdistribution/TcPacketCheckIF.h new file mode 100644 index 00000000..58c17021 --- /dev/null +++ b/tcdistribution/TcPacketCheckIF.h @@ -0,0 +1,32 @@ +#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ +#define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ + +#include "../returnvalues/HasReturnvaluesIF.h" + +// TODO TcPacketStoredBase is currently only for PUS packets. not for CFDP packets +class TcPacketStoredBase; + +/** + * This interface is used by PacketCheckers for PUS packets and CFDP packets . + * @ingroup tc_distribution + */ +class TcPacketCheckIF { +public: + /** + * The empty virtual destructor. + */ + virtual ~TcPacketCheckIF() { + } + + /** + * This is the actual method to formally check a certain Packet. + * The packet's Application Data can not be checked here. + * @param current_packet The packet to check + * @return - @c RETURN_OK on success. + * - @c INCORRECT_CHECKSUM if checksum is invalid. + * - @c ILLEGAL_APID if APID does not match. + */ + virtual ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) = 0; +}; + +#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */ diff --git a/tcdistribution/TcPacketCheck.cpp b/tcdistribution/TcPacketCheckPUS.cpp similarity index 85% rename from tcdistribution/TcPacketCheck.cpp rename to tcdistribution/TcPacketCheckPUS.cpp index b3a025a4..a338585e 100644 --- a/tcdistribution/TcPacketCheck.cpp +++ b/tcdistribution/TcPacketCheckPUS.cpp @@ -1,4 +1,4 @@ -#include "TcPacketCheck.h" +#include "TcPacketCheckPUS.h" #include "../globalfunctions/CRC.h" #include "../tmtcpacket/pus/tc/TcPacketBase.h" @@ -7,10 +7,10 @@ #include "../storagemanager/StorageManagerIF.h" #include "../tmtcservices/VerificationCodes.h" -TcPacketCheck::TcPacketCheck(uint16_t setApid): apid(setApid) { +TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid): apid(setApid) { } -ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) { +ReturnValue_t TcPacketCheckPUS::checkPacket(TcPacketStoredBase* currentPacket) { TcPacketBase* tcPacketBase = currentPacket->getPacketBase(); if(tcPacketBase == nullptr) { return RETURN_FAILED; @@ -41,6 +41,6 @@ ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) { return RETURN_OK; } -uint16_t TcPacketCheck::getApid() const { +uint16_t TcPacketCheckPUS::getApid() const { return apid; } diff --git a/tcdistribution/TcPacketCheck.h b/tcdistribution/TcPacketCheckPUS.h similarity index 75% rename from tcdistribution/TcPacketCheck.h rename to tcdistribution/TcPacketCheckPUS.h index 7106b7e4..85b30378 100644 --- a/tcdistribution/TcPacketCheck.h +++ b/tcdistribution/TcPacketCheckPUS.h @@ -1,5 +1,7 @@ -#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ -#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ +#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ +#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ + +#include "TcPacketCheckIF.h" #include "../FSFW.h" #include "../returnvalues/HasReturnvaluesIF.h" @@ -12,7 +14,9 @@ class TcPacketStoredBase; * Currently, it only checks if the APID and CRC are correct. * @ingroup tc_distribution */ -class TcPacketCheck : public HasReturnvaluesIF { +class TcPacketCheckPUS : + public TcPacketCheckIF, + public HasReturnvaluesIF { protected: /** * Describes the version number a packet must have to pass. @@ -49,18 +53,11 @@ public: * The constructor only sets the APID attribute. * @param set_apid The APID to set. */ - TcPacketCheck(uint16_t setApid); - /** - * This is the actual method to formally check a certain Telecommand Packet. - * The packet's Application Data can not be checked here. - * @param current_packet The packt to check - * @return - @c RETURN_OK on success. - * - @c INCORRECT_CHECKSUM if checksum is invalid. - * - @c ILLEGAL_APID if APID does not match. - */ - ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket); + TcPacketCheckPUS(uint16_t setApid); + + ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket) override; uint16_t getApid() const; }; -#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */ +#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */