Skip to content

Allow truncated RawDevice::read_frame() #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

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

Felix-El
Copy link
Contributor

@Felix-El Felix-El commented Apr 22, 2023

  • RawDevice::read_frame() succeeds with a receive buffer smaller than the frame.
  • Introduce RxCursor and TxCursor to track/update RX/TX buffer pointers making it easier to reason about functions such as read_frame / write_frame.

Closes #45

Copy link
Collaborator

@ryan-summers ryan-summers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change! Reading partial frames is definitely something we should support :)

You mentioned that reading a frame with a too-small buffer results in Ok(0) being returned, but I don't see that behavior in the code - Ok(0) is only returned when there is no data available.

Our current implementation only works if the frame passed to read_frame is large enough to receive the whole frame, so I suspect that after reading the first partial frame, we were no longer able to determine the proper size of the ethernet frame.

@Felix-El Felix-El changed the title Allow truncated RawDevice::read_frame() Allow truncated RawDevice::read_frame() Jun 20, 2023
@Felix-El
Copy link
Contributor Author

I've pushed a new version which should be easier to digest, separating out buffer manipulation to dedicated utility objects.
Probably they would aid readability also for other types of sockets but that's for a future PR.

Copy link
Collaborator

@ryan-summers ryan-summers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cursor approach is absolutely wonderful. Nice idea! I see no issues here, thanks for the changes.

Some minor requests around ownership of the cursor and I'm happy to merge this.

- `RawDevice::read_frame()` succeeds with a receive buffer smaller than the frame.
- Introduce `RxCursor` and `TxCursor` to track/update RX/TX buffer pointers making
  it easier to reason about functions such as `read_frame` / `write_frame`.
@Felix-El
Copy link
Contributor Author

Agree & done.

@ryan-summers ryan-summers merged commit 691662b into kellerkindt:master Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reading partial raw frames using RawDevice::read_frame()
2 participants