-
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
Changes from 1 commit
58c22c2
c227eae
25c88e7
792b9c7
f0b3899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,12 +80,22 @@ class DLL_EXPORT TransferSession | |
bool IsEof = false; | ||
}; | ||
|
||
struct MessageTypeData | ||
{ | ||
uint32_t ProtocolId = 0; // Should only be SecureChannel or BDX | ||
uint8_t MessageType = 0; | ||
}; | ||
|
||
/** | ||
* @brief | ||
* All output data processed by the TransferSession object will be passed to the caller using this struct via PollOutput(). | ||
* | ||
* NOTE: Some sub-structs may contain pointers to data in a PacketBuffer. In this case, the MsgData field MUST be populated | ||
* with a PacketBufferHandle that encapsulates the respective PacketBuffer, in order to ensure valid memory access. | ||
* NOTE: Some sub-structs may contain pointers to data in a PacketBuffer (see Blockdata). In this case, the MsgData field MUST | ||
* be populated with a PacketBufferHandle that encapsulates the respective PacketBuffer, in order to ensure valid memory | ||
* access. | ||
* | ||
* NOTE: MsgData can contain messages that have been received or messages that should be sent by the caller. The underlying | ||
* buffer will always start at the data, never at the payload header. Outgoing messages do not have a header prepended. | ||
*/ | ||
struct OutputEvent | ||
{ | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. It is - see Also this struct will be crucial to any application that uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it's actually used as an arg to |
||
}; | ||
|
||
OutputEvent() : EventType(OutputEventType::kNone) { statusData = { StatusCode::kNone }; } | ||
|
@@ -107,6 +118,7 @@ class DLL_EXPORT TransferSession | |
static OutputEvent TransferAcceptEvent(TransferAcceptData data, System::PacketBufferHandle msg); | ||
static OutputEvent BlockDataEvent(BlockData data, System::PacketBufferHandle msg); | ||
static OutputEvent StatusReportEvent(OutputEventType type, StatusReportData data); | ||
static OutputEvent MsgToSendEvent(MessageTypeData typeData, System::PacketBufferHandle msg); | ||
}; | ||
|
||
/** | ||
|
@@ -119,8 +131,8 @@ class DLL_EXPORT TransferSession | |
* It is possible that consecutive calls to this method may emit different outputs depending on the state of the | ||
* TransferSession object. | ||
* | ||
* Note that if the type outputted is kMsgToSend, it is assumed that the message will be send immediately, and the | ||
* session timeout timer will begin at curTimeMs. | ||
* Note that if the type outputted is kMsgToSend, the caller is expected to send the message immediately, and the session | ||
* timeout timer will begin at curTimeMs. | ||
* | ||
* See OutputEventType for all possible output event types. | ||
* | ||
|
@@ -308,11 +320,13 @@ class DLL_EXPORT TransferSession | |
uint64_t mTransferLength = 0; ///< 0 represents indefinite length | ||
uint16_t mTransferMaxBlockSize = 0; | ||
|
||
// Used to store event data before it is emitted via PollOutput() | ||
System::PacketBufferHandle mPendingMsgHandle; | ||
StatusReportData mStatusReportData; | ||
TransferInitData mTransferRequestData; | ||
TransferAcceptData mTransferAcceptData; | ||
BlockData mBlockEventData; | ||
MessageTypeData mMsgTypeData; | ||
|
||
uint32_t mNumBytesProcessed = 0; | ||
|
||
|
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