Skip to content

Support ancillary data over sendmsg, recvmsg #313

Closed

Description

@brunowonka

Should socket2 support sendmsg/recvmsg including control ancillary data to expose things like IP_TTL and IPV6_PKTINFO.

I took a quick stab at it to figure out how it'd look like. I only did the writing side, I think there's a lot of design work and discussion here and I'm more than half-convinced this should be an enum instead of what I wrote.

I think it'd be interesting to basically provide some safe wrappers around CMSG and the many control data types. Unclear if it's in the interest of the authors of the crate to maintain all of those, however. Also I have 0 experience with Windows here so I didn't even try satisfying it with my prototype, and I'm honestly not even sure where to begin there.

Interested to hear the maintainer's thoughts. I'm willing to iterate on design and implementation here if there is interest.

Note: This is somewhat related to #86 from what I gathered in the discussion over there.

Activity

  1. Thomasdezeeuw commented on Jun 19, 2022

    @Thomasdezeeuw
    Contributor

    @brunowonka I don't really have time to review this at the moment, but if you open a draft pr I can start reviewing the code once I have some time. In general I think that if the API surface isn't too big socket2 should be able to support this.

  2. added a commit that references this issue on Jun 23, 2022
    e7dbdbe
  3. brunowonka commented on Jun 23, 2022

    @brunowonka
    Author

    Thanks @Thomasdezeeuw, opened #316 to get the conversation started

  4. leshow commented on Jun 30, 2022

    @leshow

    I don't have an opinion on the code per-say, but I did want to link some other resources I stumbled across that may be helpful:

    As an argument for supporting sendmsg/recvmsg, if you want to modify the interface or ip used when sending or receiving a message while bound to ipaddr_any, for instance, those methods are necessary. dnsmasq does this in its DHCP impl. If socket2 is meant to support "advanced configuration options" it seems like something it should be able to do.

    edit: it looks like quinn uses sendmmsg/recvmmsg on linux but falls back to just send_to/recv_from on windows? see here

  5. added a commit that references this issue on Jul 11, 2022
    d6a3d1c
  6. leshow commented on Mar 29, 2023

    @leshow

    If this is useful for anyone, I extracted some of the code from quinn into a library that has sendmsg/recvmsg for tokio & std https://github.com/leshow/unix-udp-sock

  7. chrysn commented on Nov 29, 2023

    @chrysn

    Reading and writing PKTINFO would also be of great help for std_embedded_nal, as having the local address is mandatory for that interface, to allow QUIC and CoAP implementations. (Right now, that crate goes through nix, but this crate could offer it in a sufficiently abstract way that even Windows can be supported).

  8. Thomasdezeeuw commented on Jan 25, 2025

    @Thomasdezeeuw
    Contributor

    We now support this with MsgHdrMut and MsgHdr, recvmsg and sendmsg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions