I'd like to get the IP address of the standard gateway on BSD/OS X systems.
That's a simple question, however, I have enormous difficulties getting an answer.
This post: Getting gateway to use for a given ip in ANSI C already answered the question, but only for non-BSD/-OSX systems.
As it's difficult to create Raw sockets on BSD systems and there is no PF_NETLINK
family, I don't know where or how to start.
The only thing I found out is that there is a family called PF_ROUTE, which seems to be the correct family for this purpose (/* Internal Routing Protocol */
). I still don't know the corresponding protocol.
There's nothing I've really tried so far since I have no idea how to start.