I'm writing a program to find out which network interface is the best to connect to a specified target address.
Right now, I can get the route table via netlink
socket APIs, but seems there is no netmask infos in it. I read the manual of rtnetlink
, in all rtattr
items, there is no netmask infos, just RTA_DST
, RTA_SRC
, RTA_GATEWAY
... defined.
So, how to check out the netmask infos in route table? Just like we can see in route -n
outputs.
Thanks a lot.