From 26ea6606bf271ef8dc9ce52e624f026296b07015 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 Aug 2022 20:56:09 +0200 Subject: [PATCH] metadata recvd indication --- src/fsfw/cfdp/handler/DestHandler.cpp | 9 +++++++++ src/fsfw/cfdp/handler/UserBase.h | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index aefa1aa3..a52af18e 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -169,5 +169,14 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met return FAILED; } step = TransactionStep::RECEIVING_FILE_DATA_PDUS; + MetadataRecvdParams params; + params.sourceId = tp.pduConf.sourceId; + params.fileSize = tp.fileSize.getSize(); + params.destFileName = tp.destName.data(); + params.sourceFileName = tp.sourceName.data(); + params.id = tp.transactionId; + params.msgsToUserArray = dynamic_cast(userTlvVec.data()); + params.msgsToUserLen = info.getOptionsLen(); + dp.user.metadataRecvdIndication(params); return OK; } diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 34af89a5..0003decf 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -29,10 +29,11 @@ struct TransactionFinishedParams { struct MetadataRecvdParams { TransactionId id; EntityId sourceId; - size_t fileSize; - const char* sourceFileName; - const char* destFileName; - std::vector msgsToUser; + uint64_t fileSize; + const char* sourceFileName = ""; + const char* destFileName = ""; + size_t msgsToUserLen = 0; + const MessageToUserTlv* msgsToUserArray = nullptr; }; struct FileSegmentRecvdParams { @@ -63,6 +64,16 @@ class UserBase { virtual void transactionIndication(TransactionId id) = 0; virtual void eofSentIndication(TransactionId id) = 0; virtual void transactionFinishedIndication(TransactionFinishedParams params) = 0; + /** + * Will be called if metadata was received. + * + * IMPORTANT: The passed struct contains the messages to the user in form of a raw C array. + * The TLVs in these arrays are zero-copy types, which means that they point to the raw data + * inside the metadata packet directly. The metadata packet will be deleted from the TC store + * shortly after it was processed. If some of the data is to be cached and/or used after the + * function call, it needs to be copied into another user-provided buffer. + * @param params + */ virtual void metadataRecvdIndication(MetadataRecvdParams params) = 0; virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0; virtual void reportIndication(TransactionId id, StatusReportIF& report) = 0;