Windows 上的路由信息是否有 C/C++ API?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7110793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a C/C++ API to the route information on Windows?
提问by mfisch
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.
是否有 Windows 或 cygwin C/C++ API 来收集 Windows 上 route 命令提供的信息?我对路线指标特别感兴趣。这是路由输出的示例,IP 已更改以保护无辜者。
$ 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
回答by Mikko Korkalo
You should use GetIpForwardTable
as the Routing Table Manager API only works for Server editions of Windows.
您应该使用GetIpForwardTable
路由表管理器 API 仅适用于 Windows 的服务器版本。
回答by Joe
You want the Routing Table Manager API.
您需要路由表管理器 API。