开发者

Windows Routing API: What API calls are needed to build a managed version of route.exe for Windows?

开发者 https://www.devze.com 2022-12-19 06:24 出处:网络
In order to ensure we have the correct routes for various vpn connections, we typically run a batch file that calls commands similar to the following:

In order to ensure we have the correct routes for various vpn connections, we typically run a batch file that calls commands similar to the following:

route add xxx.xxx.xxx.xxx mask 255.255.255.0 yyy.yyy.yyy.yyy

We have a C# application that uses the NetworkInterfaces clas开发者_JS百科s to listen for network events, and runs this command using the Process command.

This isn't ideal, and I was wondering if there are a certain set of Win32 API calls that would mean I can add/remove routes without shelling out to a console app. In order words, what API calls is route.exe making to do it's stuff?

I think CreateIpForwardEntry and it's colleagues might be the way to go, but I'm not too sure. I read about it here: http://msdn.microsoft.com/en-us/library/aa365860(VS.85).aspx


Without any doubt, the IP Helper Functions are the ones used to implement the ROUTE command. Check GetIpForwardTable() and the MIB_IPFORWARDROW structure documentation and, for a ROUTE clone sample, check the IPRoute subdirectory (under the IPHelp directory) in your Microsoft Platform SDK directory.

0

精彩评论

暂无评论...
验证码 换一张
取 消