parsing finally works

This commit is contained in:
Robin Müller 2023-07-26 16:25:42 +02:00
parent 314cba363f
commit 8f5a8b13d3
Signed by: muellerr
GPG Key ID: 407F9B00F858F270

View File

@ -17,13 +17,16 @@ cfdp::PutRequest::PutRequest(cfdp::EntityId destId, const uint8_t *msgsToUser,
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);
if (result != OK) {
return result;
if(buffer == nullptr or size == nullptr) {
return FAILED;
}
if (*size + getSerializedSize() > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
ReturnValue_t result = destId.serialize(buffer, size, maxSize, streamEndianness);
if (result != OK) {
return result;
}
result = SerializeAdapter::serialize(&metadataOnly, buffer, size, maxSize, streamEndianness);
if (result != OK) {
return result;
@ -152,7 +155,7 @@ ReturnValue_t cfdp::PutRequest::deSerialize(const uint8_t **buffer, size_t *size
}
size_t cfdp::PutRequest::getSerializedSize() const {
size_t baseSize = destId.getSerializedSize() + 1;
size_t baseSize = 1 + destId.getSerializedSize();
if (!metadataOnly) {
baseSize += sizeof(sourceNameSize) + sourceNameSize + sizeof(destNameSize) + destNameSize + 2;
}
@ -164,5 +167,5 @@ size_t cfdp::PutRequest::getSerializedSize() const {
void cfdp::PutRequest::setSourceAndDestName(cfdp::StringLv &sourceName_,
cfdp::StringLv &destName_) {
this->sourceName = sourceName_.getString(sourceNameSize);
this->destName = destName_.getString(sourceNameSize);
this->destName = destName_.getString(destNameSize);
}