private static List <Route> GetRoutes(VyattaShell Shell) { string ShowRoutes = Shell.RunCommand("sudo route -n"); string[] RouteLines = ShowRoutes.Split(new char[] { '\n' }); List <Route> Routes = new List <Route>(); foreach (string Line in RouteLines) { Match Match = GatewayRegex.Match(Line); if (Match.Success) { Route Route = new Route(); Route.Destination = Match.Groups[1].Value; Route.Gateway = Match.Groups[2].Value; Route.Genmask = Match.Groups[3].Value; Route.Interface = Match.Groups[4].Value; Routes.Add(Route); } } return(Routes); }
public static bool DeleteRoutes(VyattaShell Shell, List <Route> Routes) { foreach (Route Route in Routes) { string Result = Shell.RunCommand(string.Format("ip route del {0} via {1} dev {2}", Route.CalculatedNetmask.Value, Route.Gateway, Route.Interface)); //TODO: Check Result } return(true); }