fsfw/src/fsfw/cfdp/handler/PutRequest.h

83 lines
2.6 KiB
C
Raw Normal View History

2023-07-21 16:09:52 +02:00
#pragma once
#include <optional>
#include <vector>
#include "fsfw/cfdp/VarLenFields.h"
#include "fsfw/cfdp/tlv/FilestoreRequestTlv.h"
#include "fsfw/cfdp/tlv/MessageToUserTlv.h"
namespace cfdp {
class PutRequest : public SerializeIF {
2023-07-21 16:09:52 +02:00
public:
2023-07-24 11:15:50 +02:00
/**
* Metadata only constructor.
* @param destId
* @param msgsToUser
* @param msgsToUserTotalSize
* @param fsRequests
* @param fsRequestsSize
*/
PutRequest(EntityId destId, const uint8_t* msgsToUser, size_t msgsToUserTotalSize,
const uint8_t* fsRequests, size_t fsRequestsSize);
2023-07-26 17:47:27 +02:00
/**
2023-07-27 17:15:01 +02:00
* Put request to initiate file transfers. By default, the transmission mode and closure requested
* parameter are not present, thereby being derived from the remote configuration for a
* particular destination ID.
2023-07-26 17:47:27 +02:00
* @param destId
* @param sourceName
* @param destName
*/
PutRequest(EntityId destId, cfdp::StringLv& sourceName, cfdp::StringLv& destName);
2023-07-24 11:33:37 +02:00
/**
* Default constructor for deserialization.
*/
PutRequest() = default;
[[nodiscard]] ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
2023-07-24 10:11:16 +02:00
[[nodiscard]] size_t getSerializedSize() const override;
2023-07-24 16:38:11 +02:00
void setSourceAndDestName(cfdp::StringLv& sourceName, cfdp::StringLv& destName);
[[nodiscard]] const cfdp::StringLv& getSourceName() const;
[[nodiscard]] const cfdp::StringLv& getDestName() const;
2023-07-26 17:47:27 +02:00
void setTransmissionMode(cfdp::TransmissionMode transmissionMode);
void clearTransmissionMode();
void setClosureRequest(bool closureRequested);
void clearClosureRequest();
2023-07-26 18:20:32 +02:00
const uint8_t* getMessagesToUser(size_t& msgSize);
2023-07-21 16:35:05 +02:00
[[nodiscard]] bool isMetadataOnly() const;
2023-07-27 17:15:01 +02:00
bool getTransmissionMode(TransmissionMode& mode) const;
bool getClosureRequested(bool& closureRequested) const;
[[nodiscard]] const EntityId& getDestId() const;
void setDestId(EntityId id);
private:
EntityId destId;
2023-07-24 11:33:37 +02:00
uint8_t metadataOnly = true;
2023-07-24 11:15:50 +02:00
// Transaction parameters. Omitted if the put request is metadata only.
cfdp::StringLv sourceName;
cfdp::StringLv destName;
2023-07-24 16:38:11 +02:00
bool hasTransmissionMode = false;
2023-07-24 11:33:37 +02:00
uint8_t transmissionMode = TransmissionMode::UNACKNOWLEDGED;
2023-07-24 16:38:11 +02:00
bool hasClosureRequested = false;
2023-07-24 11:33:37 +02:00
uint8_t closureRequested = false;
2023-07-24 11:15:50 +02:00
// Metadata
size_t msgsToUsersTotalSize = 0;
2023-07-24 11:15:50 +02:00
const uint8_t* msgsToUserStartPtr = nullptr;
size_t fsRequestsTotalSize = 0;
2023-07-24 11:15:50 +02:00
const uint8_t* fsRequestStartPtr = nullptr;
2023-07-21 16:09:52 +02:00
};
} // namespace cfdp