ObjFW  Check-in [41535b41da]

Overview
Comment: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.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 41535b41da23040451a5147175942a49d7410b747e93bb587918ef6d2d1896a5
User & Date: js on 2022-11-01 22:18:34
Other Links: manifest | tags
Context
2022-11-01
23:23
OFDDPSocket: Return correct bound address on macOS check-in: e5075e42ab user: js tags: trunk
22:18
Implement OFDDPSocket using SOCK_RAW on macOS check-in: 41535b41da user: js tags: trunk
2022-10-31
21:41
Check for and use <netat/appletalk.h> check-in: 019ff77f50 user: js tags: trunk
Changes