Space Packet Size Check #101

Closed
meierj wants to merge 1 commits from meier/pus-distributor-bugfix into develop
9 changed files with 39 additions and 12 deletions

View File

@ -33,7 +33,11 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
if (this->currentPacket == nullptr) { if (this->currentPacket == nullptr) {
return queueMapIt; return queueMapIt;
} }
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); ReturnValue_t result = this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
if (result != HasReturnvaluesIF::RETURN_OK) {
tcStatus = PACKET_TOO_SHORT;
return this->queueMap.end();
}
if (currentPacket->getWholeData() != nullptr) { if (currentPacket->getWholeData() != nullptr) {
tcStatus = checker.checkPacket(currentPacket); tcStatus = checker.checkPacket(currentPacket);
if (tcStatus != HasReturnvaluesIF::RETURN_OK) { if (tcStatus != HasReturnvaluesIF::RETURN_OK) {

View File

@ -27,7 +27,12 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
if (this->currentPacket == nullptr) { if (this->currentPacket == nullptr) {
return queueMapIt; return queueMapIt;
} }
ReturnValue_t result =
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket); this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket);
if (result != HasReturnvaluesIF::RETURN_OK) {
tcStatus = PACKET_TOO_SHORT;
return this->queueMap.end();
}
if (currentPacket->getWholeData() != nullptr) { if (currentPacket->getWholeData() != nullptr) {
tcStatus = checker.checkPacket(currentPacket); tcStatus = checker.checkPacket(currentPacket);
if (tcStatus != HasReturnvaluesIF::RETURN_OK) { if (tcStatus != HasReturnvaluesIF::RETURN_OK) {
@ -106,6 +111,14 @@ ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) {
MessageQueueId_t PUSDistributor::getRequestQueue() { return tcQueue->getId(); } MessageQueueId_t PUSDistributor::getRequestQueue() { return tcQueue->getId(); }
ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
if (tcStatus == PACKET_LOST or tcStatus == PACKET_TOO_SHORT) {
// The ack flags, packet id and sequence control are unknown for a packet which is too short or
// has been lost
this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, UNKNOWN_ACK_FLAGS,
UNKNOWN_PACKET_ID, UNKNOWN_SEQUENCE_CONTROL, tcStatus);
currentPacket->deletePacket();
return RETURN_FAILED;
}
if (queueStatus != RETURN_OK) { if (queueStatus != RETURN_OK) {
tcStatus = queueStatus; tcStatus = queueStatus;
} }

View File

@ -72,6 +72,11 @@ class PUSDistributor : public TcDistributor, public PUSDistributorIF, public Acc
* success/failure messages. * success/failure messages.
*/ */
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override; ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
private:
static const uint8_t UNKNOWN_ACK_FLAGS = 0;
static const uint8_t UNKNOWN_PACKET_ID = 0;
static const uint8_t UNKNOWN_SEQUENCE_CONTROL = 0;
}; };
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */ #endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */

View File

@ -36,6 +36,7 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has
static constexpr ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE(1);
static constexpr ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE(2);
static constexpr ReturnValue_t SERVICE_ID_ALREADY_EXISTS = MAKE_RETURN_CODE(3); static constexpr ReturnValue_t SERVICE_ID_ALREADY_EXISTS = MAKE_RETURN_CODE(3);
static constexpr ReturnValue_t PACKET_TOO_SHORT = MAKE_RETURN_CODE(4);
/** /**
* Within the default constructor, the SystemObject id is set and the * Within the default constructor, the SystemObject id is set and the
* message queue is initialized. * message queue is initialized.

View File

@ -37,7 +37,7 @@ ReturnValue_t CFDPPacketStored::deletePacket() {
// CFDPPacket* CFDPPacketStored::getPacketBase() { // CFDPPacket* CFDPPacketStored::getPacketBase() {
// return this; // return this;
// } // }
void CFDPPacketStored::setStoreAddress(store_address_t setAddress) { ReturnValue_t CFDPPacketStored::setStoreAddress(store_address_t setAddress) {
this->storeAddress = setAddress; this->storeAddress = setAddress;
const uint8_t* tempData = nullptr; const uint8_t* tempData = nullptr;
size_t tempSize; size_t tempSize;
@ -46,11 +46,11 @@ void CFDPPacketStored::setStoreAddress(store_address_t setAddress) {
status = this->store->getData(this->storeAddress, &tempData, &tempSize); status = this->store->getData(this->storeAddress, &tempData, &tempSize);
} }
if (status == StorageManagerIF::RETURN_OK) { if (status == StorageManagerIF::RETURN_OK) {
this->setData(const_cast<uint8_t*>(tempData), tempSize); return this->setData(const_cast<uint8_t*>(tempData), tempSize);
} else { } else {
// To circumvent size checks
this->setData(nullptr, -1);
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
// To circumvent size checks
return this->setData(nullptr, -1);
} }
} }

View File

@ -29,7 +29,7 @@ class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase {
*/ */
ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize); ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize);
void setStoreAddress(store_address_t setAddress); ReturnValue_t setStoreAddress(store_address_t setAddress);
store_address_t getStoreAddress(); store_address_t getStoreAddress();

View File

@ -42,7 +42,7 @@ bool TcPacketStoredBase::checkAndSetStore() {
return true; return true;
} }
void TcPacketStoredBase::setStoreAddress(store_address_t setAddress, ReturnValue_t TcPacketStoredBase::setStoreAddress(store_address_t setAddress,
RedirectableDataPointerIF* packet) { RedirectableDataPointerIF* packet) {
this->storeAddress = setAddress; this->storeAddress = setAddress;
const uint8_t* tempData = nullptr; const uint8_t* tempData = nullptr;
@ -53,10 +53,10 @@ void TcPacketStoredBase::setStoreAddress(store_address_t setAddress,
} }
if (status == StorageManagerIF::RETURN_OK) { if (status == StorageManagerIF::RETURN_OK) {
packet->setData(const_cast<uint8_t*>(tempData), tempSize); return packet->setData(const_cast<uint8_t*>(tempData), tempSize);
} else { } else {
packet->setData(nullptr, -1);
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
return packet->setData(nullptr, -1);
} }
} }

View File

@ -38,7 +38,8 @@ class TcPacketStoredBase : public TcPacketStoredIF {
*/ */
ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize) override; ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize) override;
void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) override; ReturnValue_t setStoreAddress(store_address_t setAddress,
RedirectableDataPointerIF* packet) override;
store_address_t getStoreAddress() override; store_address_t getStoreAddress() override;
/** /**

View File

@ -16,8 +16,11 @@ class TcPacketStoredIF {
* With this call, the stored packet can be set to another packet in a store. This is useful * With this call, the stored packet can be set to another packet in a store. This is useful
* if the packet is a class member and used for more than one packet. * if the packet is a class member and used for more than one packet.
* @param setAddress The new packet id to link to. * @param setAddress The new packet id to link to.
*
* @return RETURN_OK if successful otherwise error return code.
*/ */
virtual void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) = 0; virtual ReturnValue_t setStoreAddress(store_address_t setAddress,
RedirectableDataPointerIF* packet) = 0;
virtual store_address_t getStoreAddress() = 0; virtual store_address_t getStoreAddress() = 0;