-
Notifications
You must be signed in to change notification settings - Fork 47
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
Fix Frame Size Issue #690
Fix Frame Size Issue #690
Conversation
|
||
if expected_frame_mac != frame_mac do | ||
{:error, "Failed to match frame ingress mac"} | ||
if byte_size(frame_rest) < frame_size + frame_padding_bytes + 16 do |
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.
What's the 16
for here? Can we make it into a descriptive constant?
%{frame_secrets | ingress_mac: ingress_mac, decoder_stream: decoder_stream} | ||
} | ||
frame_enc::binary-size(frame_size), | ||
frame_padding::binary-size(frame_padding_bytes), |
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.
Should this just be frame_enc_with_padding::binary-size(frame_size + frame_padding_bytes)
? Looks like they're pattern matched separately only to be concatenated below and never used individually.
I've noticed that binary isn't a dependency of ex_wire, could you include it? |
| {:error, | ||
:insufficient_data | ||
| :failed_to_match_header_ingress_mac | ||
| :failed_to_match_frame_ingress_mac} | ||
def unframe( |
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 you included frame parsing in the header, as in
def unframe(<<header_enc::binary-size(16), header_mac::binary-size(16), frame_rest::binary()>>, frame_secrets = %Secrets{
ingress_mac: ingress_mac,
decoder_stream: decoder_stream,
mac_encoder: mac_encoder,
mac_secret: mac_secret
})
def unframe(<<header_enc::binary-size(16), header_mac::binary-size(16), frame_rest::binary()>>, frame_secrets = %Secrets{
ingress_mac: ingress_mac,
decoder_stream: decoder_stream,
mac_encoder: mac_encoder,
mac_secret: mac_secret
}) do
...
end
def unframe(_, _), do: {:error, :insufficient_data}
You could avoid deep nested function.
When packets come in, sometimes they are incomplete. We previously handled packets that had a valid header but insufficient body size. This patch adds support for packets that don't even have complete headers. We queue the packet into queued data and wait for more data before processing. Address PR feedback
48cc61c
to
00fdd6e
Compare
I addressed the PR feedback, ready for merge. |
When packets come in, sometimes they are incomplete. We previously handled packets that had a valid header but insufficient body size. This patch adds support for packets that don't even have complete headers. We queue the packet into queued data and wait for more data before processing.