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
class 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