5

Is there a windows or cygwin C/C++ API to collect information provided by the route command on Windows? I'm specifically interested in the route metrics. Here's an example of what route outputs, the IPs have been changed to protect the innocent.

$ route PRINT -4
===========================================================================
Interface List
 11...64 31 50 3b ba 96 ......Broadcom NetXtreme Gigabit Ethernet
 17...00 50 56 c0 00 01 ......VMware Virtual Ethernet Adapter for VMnet1
 18...00 50 56 c0 00 08 ......VMware Virtual Ethernet Adapter for VMnet8
  1...........................Software Loopback Interface 1
 12...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
 10...00 00 00 00 00 00 00 e0 Microsoft Teredo Tunneling Adapter
 13...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
 14...00 00 00 00 00 00 00 e0 Microsoft 6to4 Adapter
 15...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #3
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      99.10.168.1     99.10.170.11     10
      99.10.168.0    255.255.248.0         On-link      99.10.170.11    266
     99.10.170.11  255.255.255.255         On-link      99.10.170.11    266
    99.10.175.255  255.255.255.255         On-link      99.10.170.11    266
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
mfisch
  • 979
  • 9
  • 15

2 Answers2

10

You should use GetIpForwardTable as the Routing Table Manager API only works for Server editions of Windows.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Mikko Korkalo
  • 375
  • 3
  • 5
3

You want the Routing Table Manager API.

Joe
  • 41,484
  • 20
  • 104
  • 125
  • Thanks Joe! We can integrate that into a cygwin program no problem. – mfisch Aug 18 '11 at 18:44
  • 3
    "Routing Protocols is a server-based technology. All the functionality of Routing Protocols is incorporated into Windows Server 2008, Windows Server 2003 and Windows 2000 Server. Routing applications cannot run on client operating systems, such as Windows XP or Windows Vista. For more specific information about which operating systems support a particular function, refer to the Requirements sections in the documentation." So how do I enumerate the routing table on a client OS? – Joakim Apr 02 '12 at 11:33