almost done
This commit is contained in:
parent
b0b6c68720
commit
7bf7336d4a
@ -2,9 +2,18 @@
|
||||
|
||||
using namespace returnvalue;
|
||||
|
||||
[[nodiscard]] bool cfdp::PutRequest::isMetadataOnly() const {
|
||||
return destNameSize > 0 and sourceNameSize > 0;
|
||||
}
|
||||
cfdp::PutRequest::PutRequest(cfdp::EntityId destId, const uint8_t *msgsToUser,
|
||||
size_t msgsToUserTotalSize, const uint8_t *fsRequests,
|
||||
size_t fsRequestsSize)
|
||||
: destId(std::move(destId)),
|
||||
metadataOnly(true),
|
||||
msgsToUsersTotalSize(msgsToUserTotalSize),
|
||||
msgsToUserStartPtr(msgsToUser),
|
||||
fsRequestsTotalSize(fsRequestsSize),
|
||||
fsRequestStartPtr(fsRequests) {}
|
||||
|
||||
[[nodiscard]] bool cfdp::PutRequest::isMetadataOnly() const { return metadataOnly; }
|
||||
|
||||
ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
SerializeIF::Endianness streamEndianness) const {
|
||||
ReturnValue_t result = destId.serialize(buffer, size, maxSize, streamEndianness);
|
||||
@ -16,11 +25,6 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
|
||||
}
|
||||
**buffer = metadataOnly;
|
||||
*size += 1;
|
||||
if (transmissionMode) {
|
||||
**buffer = transmissionMode;
|
||||
*size += 1;
|
||||
*buffer += 1;
|
||||
}
|
||||
if (!metadataOnly) {
|
||||
result = SerializeAdapter::serialize(&sourceNameSize, buffer, size, maxSize, streamEndianness);
|
||||
if (result != OK) {
|
||||
@ -52,11 +56,7 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
|
||||
if (result != OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::serialize(&numOfMsgsToUser, buffer, size, maxSize, streamEndianness);
|
||||
if (result != OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(*buffer, messagesToUserStartPtr, msgsToUsersTotalSize);
|
||||
std::memcpy(*buffer, msgsToUserStartPtr, msgsToUsersTotalSize);
|
||||
*buffer += msgsToUsersTotalSize;
|
||||
*size += msgsToUsersTotalSize;
|
||||
|
||||
@ -65,11 +65,7 @@ ReturnValue_t cfdp::PutRequest::serialize(uint8_t **buffer, size_t *size, size_t
|
||||
if (result != OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::serialize(&numOfFsRequests, buffer, size, maxSize, streamEndianness);
|
||||
if (result != OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(*buffer, fsRequest, fsRequestsTotalSize);
|
||||
std::memcpy(*buffer, fsRequestStartPtr, fsRequestsTotalSize);
|
||||
*buffer += fsRequestsTotalSize;
|
||||
*size += fsRequestsTotalSize;
|
||||
return OK;
|
||||
@ -84,7 +80,7 @@ size_t cfdp::PutRequest::getSerializedSize() const {
|
||||
if (!metadataOnly) {
|
||||
baseSize += sizeof(sourceNameSize) + sourceNameSize + sizeof(destNameSize) + destNameSize + 2;
|
||||
}
|
||||
baseSize += sizeof(msgsToUsersTotalSize) + sizeof(numOfMsgsToUser) + msgsToUsersTotalSize +
|
||||
sizeof(fsRequestsTotalSize) + sizeof(numOfFsRequests) + fsRequestsTotalSize;
|
||||
baseSize += sizeof(msgsToUsersTotalSize) + msgsToUsersTotalSize + sizeof(fsRequestsTotalSize) +
|
||||
fsRequestsTotalSize;
|
||||
return baseSize;
|
||||
}
|
||||
|
@ -12,14 +12,17 @@ namespace cfdp {
|
||||
class PutRequest : public SerializeIF {
|
||||
public:
|
||||
EntityId destId;
|
||||
bool metadataOnly = true;
|
||||
char* destName = nullptr;
|
||||
uint64_t destNameSize = 0;
|
||||
char* sourceName = nullptr;
|
||||
uint64_t sourceNameSize = 0;
|
||||
TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED;
|
||||
bool closureRequested = false;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
[[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,
|
||||
@ -28,12 +31,19 @@ class PutRequest : public SerializeIF {
|
||||
[[nodiscard]] bool isMetadataOnly() const;
|
||||
|
||||
private:
|
||||
bool metadataOnly = true;
|
||||
// Transaction parameters. Omitted if the put request is metadata only.
|
||||
char* destName = nullptr;
|
||||
uint64_t destNameSize = 0;
|
||||
char* sourceName = nullptr;
|
||||
uint64_t sourceNameSize = 0;
|
||||
TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED;
|
||||
bool closureRequested = false;
|
||||
// Metadata
|
||||
size_t msgsToUsersTotalSize = 0;
|
||||
uint32_t numOfMsgsToUser = 0;
|
||||
uint8_t* messagesToUserStartPtr = nullptr;
|
||||
const uint8_t* msgsToUserStartPtr = nullptr;
|
||||
size_t fsRequestsTotalSize = 0;
|
||||
uint32_t numOfFsRequests = 0;
|
||||
uint8_t* fsRequest = nullptr;
|
||||
const uint8_t* fsRequestStartPtr = nullptr;
|
||||
};
|
||||
|
||||
} // namespace cfdp
|
||||
|
Loading…
x
Reference in New Issue
Block a user