/// <summary> /// Returns the string representation of this frame as the given RIP version. /// </summary> /// <param name="iVersion">The version of this frame.</param> /// <returns>A string describing this frame according to the given version.</returns> public string ToString(int iVersion) { if (iVersion == 1) { return("Address Family Identifier: " + afiAddressFamilyIdentifier.ToString() + ", Address: " + ipaAddress.ToString() + ", Metric" + iMetric + "\n"); } else if (iVersion == 2) { return("Address Family Identifier: " + afiAddressFamilyIdentifier.ToString() + ", Route Tag: " + bRouteTag[0].ToString("x02") + bRouteTag[1].ToString("x02") + ", Address: " + ipaAddress.ToString() + ", Subnet Mask: " + smSubnetMask.ToString() + ", Next Hop: " + ipaNextHop.ToString() + ", Metric: " + iMetric + "\n"); } else { return(""); } }
/// <summary> /// Returns a long description of this rules condition, without the action. /// </summary> /// <returns>A long description of this rules condition</returns> public override string GetLongDescription() { if (ipaAddress != null) { return("If any address is " + ipaAddress.ToString() + (smWildcard != null ? " (Wildcard " + smWildcard.PrefixLength + ")" : "")); } else { string strSourceString = null; string strDstString = null; if (ipaSource != null) { strSourceString = "source port is " + ipaSource.ToString() + (smSourceWildcard != null ? " (Wildcard " + smSourceWildcard.ToString() + ")" : ""); } if (ipaDestination != null) { strDstString = "destination port is " + ipaDestination.ToString() + (smDestinationWildcard != null ? " (Wildcard " + smDestinationWildcard.ToString() + ")" : ""); } if (strSourceString != null && strDstString != null) { return("If " + strSourceString + " and " + strDstString); } else if (strSourceString == null && strDstString != null) { return("If " + strDstString); } else if (strSourceString != null && strDstString == null) { return("If " + strSourceString); } else { return("true"); } } }
/// <summary> /// Converts a subnetmask to a name value item with the given name /// </summary> /// <param name="strName">The name of the name value item</param> /// <param name="smMask">The subnetmask which should be converted to the value of the name value item</param> /// <returns>An array of name value items which represents the given parameters</returns> public static NameValueItem[] ConvertToNameValueItems(string strName, Subnetmask smMask) { return(new NameValueItem[] { new NameValueItem(strName, smMask.ToString()) }); }