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
Unix: copy buffer before passing off to client #502
Conversation
let b = Cstruct.create_unsafe len in | ||
Cstruct.blit buf 0 b 0 len; | ||
b | ||
in |
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.
maybe use Cstruct.copy?
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.
Cstruct.copy is Cstruct.t -> int -> int -> string, that is, Cstruct.copy t off len
is the same as Cstruct.to_string t ~off ~len
:/ I didn't see a function to copy a cstruct (even though Cstruct.copy would be an obvious name for such a function)
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.
The name is Cstruct.sub_copy
?
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.
Hi @palainp, indeed, Cstruct.sub_copy
does what I want, but it only exists in unreleased cstruct. I can put a comment in the code to use Cstruct.sub_copy
in the future.
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.
Oh sorry, didn't checked the last release date :(
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.
I will cut a release of cstruct
as soon as I can but some improvements are not merged yet.
CHANGES: * TCP: add ID for PCB for connection tracking (mirage/mirage-tcpip#495 @TheLortex) * Unix stack, UDP: copy buffer before passing it to client (mirage/mirage-tcpip#502 @reynir) * API renamings (due to ppx_cstruct removal): accessors such as Icmpv4_wire.get_icmpv4_ty are now Icmpv4_wire.get_ty ("_icmpv4" is removed) (mirage/mirage-tcpip#505) * Use Cstruct.to_string instead of deprecated Cstruct.copy (mirage/mirage-tcpip#506 @hannesm) * Remove ppx_cstruct dependency (mirage/mirage-tcpip#505 @hannesm) * Remove mirage-profile dependency (mirage/mirage-tcpip#504 @hannesm) * Remove Mirage3 cross-compilation runes (mirage/mirage-tcpip#507 @hannesm) * opam: add lower bounds for cmdliner and alcotest (mirage/mirage-tcpip#506 @hannesm)
Originally reported by @rand00.