ObjFW  Hex Artifact Content

Artifact 0702a801d8f651516ea6e303f07d51f58398f8f8455bf1439c3c198400b8418e:

  • File src/OFDDPSocket.m — part of check-in [41535b41da] at 2022-11-01 22:18:34 on branch trunk — Implement OFDDPSocket using SOCK_RAW on macOS

    This required quite some reverse engineering, as it is all completely
    undocumented.

    Receiving worked pretty much as expected: Do a readv() and get the raw
    DDP packet including headers, then parse the headers ourselves to get
    the source and fill out an OFSocketAddress.

    But sending was tricky and required reading through kernel sources.
    writev() does not work on a raw DDP socket and always fails with
    EDESTADDRREQ, even if the destination address is provided as part of the
    raw DDP packet. Meanwhile, sendmsg() always creates a DDP packet for us,
    even in raw mode, and prepends the data with what it believes to be the
    DDP protocol type (the protocol parameter passed to socket()). After
    reading through the kernel source for some time to find a way to disable
    this behavior, I found that you can set DDP_HDRINCL in ATPROTO_NONE to
    provide your entire header to sendmsg() instead to work around this,
    making it behave like you would expect from a writev() to a raw socket.

    The only missing part now is to return a proper address a socket was
    bound to, as currently it just leaves network and node at 0 and only
    fills the port. This probably just requires some more reading of kernel
    sources. (user: js, size: 5781) [annotate] [blame] [check-ins using]


A hex dump of this file is not available. Please download the raw binary file and generate a hex dump yourself.