It appears that this workaround is no longer working in 12.1 (perhaps other versions of macOS).
If i run this code, with en7 as an external Apple TB GbE adapter, I get the following output:
starting with fe80::1016:f5f0:a202:9ee3%en7…
[lo0]
So the interface being attached to is the lo0 (loopback) rather than the en7 interface.
So how do we reliably get the NWInterface on current OSes; as with the OP I need this to open a custom ethernet protocol on a local link with no Internet connectivity.
Since kexts are just about gone, we need a mechanism that works reliably in UserSpace to do raw enet packets; this was the path that was recommend (NWEthernetChannel), but there is still not a complete replacement for the KPIs (nor does there appear to be reliable workarounds) after at least 4 years of filing bugs, talking to DTS and the Network engineering team.
FB7665061 (April 2020)
Post
Replies
Boosts
Views
Activity
For replacement of the IOAudioFamily type kexts for CoreAudio drivers, you want to look at implementing an AudioServerPlugin CoreAudio driver. For a virtual device, everything you need is there. For a HW device, it will also depend on whether or not DriverKit supports the HW.
See
https://developer.apple.com/library/archive/samplecode/AudioDriverExamples/Introduction/Intro.html
https://developer.apple.com/library/archive/qa/qa1811/_index.html
https://developer.apple.com/forums/thread/122517
and Google search for "AudioServerPlugin" for other sources of details.