I'm using RTNETLINK to identify the current gateway, so as to remember the firewall settings based on the Access Point I'm connected to.
WLAN connections give an ESSID that I can use for this purpose, but LAN connections don't, so I fallback to using the MAC address of the gateway as an identifier. But when I use this process on a phone's WWAN data connection, I can't retrieve any MAC address of the gateway.
I found out that in C I can use if_indextoname()
on rtmsg->rta_dst->rta_oif
to retrieve the outgoing interface name, like in this example, but I guess that there is no guarantee that it will conform to the interface type - it won't translate 1:1 to either WWAN, WLAN or LAN.
Is there a way to find this out in RTNETLINK ? If not, are there other kernel interfaces usable for this purpose ?