public static void DeleteStaticRoute(VyattaConfigObject ConfigRoot, RouterData Data, string Network) { if (Network.Contains("-")) { Network = Netmask.IPRangeToCIDR(Network); } ConfigRoot.Delete(string.Format("protocols:static:route {0}", Network)); }
public static VyattaConfigObject AddStaticRoute(VyattaConfigObject ConfigRoot, RouterData Data, string Network, string Target, string Description) { if (Network.Contains("-")) { Network = Netmask.IPRangeToCIDR(Network); } foreach (var Int in Data.Interfaces) { if ((Int.Description == Target || Int.Interface == Target) && Int.Gateway != null) { Target = Int.Gateway; break; } } string DescriptionOut = string.Format("VCU-Auto: {0}", Description); VyattaConfigObject Route = ConfigRoot.AddObject(string.Format("protocols:static:route {0}:next-hop {1}", Network, Target)); Route.AddAttribute("description").Add(DescriptionOut); return(Route); }