Find the gateway of the TCP/IP network using ioctl functions

Instead of using the command line operations like route show, is there any way to get the gateway of the TCP/IP network?

I went through the various flags used by ioctl. In that there are options to add and delete the gateway but no option to get one.