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)
Topic:
App & System Services
SubTopic:
Networking
Tags: