-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't prepend header in BDX messages #8234
Don't prepend header in BDX messages #8234
Conversation
- remove code in BdxTransferSession that prepended PayloadHeaders to outgoing messages - add MessageTypeData to convey message type and protocol
@@ -80,12 +80,22 @@ class DLL_EXPORT TransferSession | |||
bool IsEof = false; | |||
}; | |||
|
|||
struct MessageTypeData | |||
{ | |||
uint32_t ProtocolId = 0; // Should only be SecureChannel or BDX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not store this as an actual protocol id, as opposed to uint32_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I originally wrote this header, I ran into compilation errors when I tried using non-trivial types in the structs included in the anonymous union.
That being said, I tried doing this change today and got it to compile locally, so I'm not sure what I did wrong last time. I agree with you that it's much simpler and cleaner to use Protocols::Id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New commit has these changes
{ | ||
NL_TEST_ASSERT(inSuite, false); | ||
return; | ||
payloadHeader.SetMessageType(Protocols::BDX::Id, typeData.MessageType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the typedata stored a Protocols::Id, could just have a single SetMessageType
call here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will implement
@@ -97,6 +107,7 @@ class DLL_EXPORT TransferSession | |||
TransferAcceptData transferAcceptData; | |||
BlockData blockdata; | |||
StatusReportData statusData; | |||
MessageTypeData msgTypeData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used in practice anywhere outside the unit test? I'm not obviously seeing it....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is - see PrepareOutgoingMessageEvent()
in BdxTransferSession.cpp
Also this struct will be crucial to any application that uses TransferSession
because it will need to pass the ProtocolId and MessageType to ExchangeContext::SendMessage()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's actually used as an arg to AttachHeaderAndSend
looks like. OK, that's the part I was missing.
Size increase report for "esp32-example-build" from e55ad30
Full report output
|
- ExchangeDelegate already consumes PayloadHeader from the message, so this needs to be removed from HandleMessageReceived()
I added one more commit to fix HandleMessageReceived(). It was expecting the |
* Don't prepend header in BDX messages - remove code in BdxTransferSession that prepended PayloadHeaders to outgoing messages - add MessageTypeData to convey message type and protocol * use Protocols::Id instead of uint32_t * add PayloadHeader argument to message handler methods - ExchangeDelegate already consumes PayloadHeader from the message, so this needs to be removed from HandleMessageReceived()
Problem
What is being fixed? Examples:
TransferSession
was prepending outgoing messages with aPayloadHeader
, but this is not compatible withExchangeContext::SendMessage()
which creates its ownPayloadHeader
to prependChange overview
outgoing messages
Testing
Fixed
TestBdxTransferSession
to not expect messages to already have aPayloadHeader
. Tests pass.