ObjFW  Hex Artifact Content

Artifact 41535b41da23040451a5147175942a49d7410b747e93bb587918ef6d2d1896a5:

Manifest of check-in [41535b41da] - 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. by js on 2022-11-01 22:18:34.


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