Skip to content
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

Consider making ControlMessageOwned::decode_from public #2613

Open
redbaron opened this issue Mar 4, 2025 · 0 comments
Open

Consider making ControlMessageOwned::decode_from public #2613

redbaron opened this issue Mar 4, 2025 · 0 comments

Comments

@redbaron
Copy link

redbaron commented Mar 4, 2025

My IO layer is built around io_uring, where multishot results gives access to control messages buffer as raw bytes and it is up to the app to parse it.

I could get by with libc to iterate over headers:

        let hdr: RecvMsgOut = io_uring::types::RecvMsgOut::parse(buf)?;

        // Fake msghdr to iterate over control messages
        let mut mhdr = new_msghdr();
        mhdr.msg_controllen = hdr.control_data().len() as _;
        mhdr.msg_control = hdr.control_data().as_ptr() as _;

        // SAFETY: msghdr.msg_controllen and msghdr.msg_control are valid
        unsafe {
            let mut cmsghdr = libc::CMSG_FIRSTHDR(std::ptr::addr_of!(mhdr));
            while !cmsghdr.is_null() {
                let cmsg = &*cmsghdr;
                // ControlMessageOwned::decode_from();
                cmsghdr = libc::CMSG_NXTHDR(&mhdr as *const _, cmsghdr);
            }
        }

but interpreting each header remains fairly low level. This crate contains most complete ergonomic handler for each individual control message type I could find, but it doesn't expose it publically. Maybe you could change ControlMessageOwned::decode_from to pub?

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

No branches or pull requests

1 participant