Default Gateway in C on Linux

前端 未结 3 965
-上瘾入骨i
-上瘾入骨i 2020-12-09 05:21

How do you find the default gateway of a routing table using C on Linux?

I don\'t want to issue a call to the shell or read a file. There are ioctls for adding and

3条回答
  •  鱼传尺愫
    2020-12-09 06:09

    You will probably need to use a NETLINK_ROUTE socket, part of the PF_NETLINK family of sockets. Check out the source code of the 'ip' program part of 'iproute'. Specifically, its 'route' subcommand.

提交回复
热议问题