//Izpišemo masko podmrežja v obeh oblikah. public static void WriteNetmask(IPAddress subnetMask) { Write("Netmask: ".PadRight(RightPadding)); ForegroundColor = Blue; string netMask = $"{subnetMask} = {SubnetMask.GetNetBitLength(subnetMask)}"; Write(netMask.PadRight(RightPadding)); ForegroundColor = Red; SetCursorPosition(ThirdRow, CursorTop); Write(subnetMask.ToBinary()); ResetColor(); WriteLine(); }
//Oblikujemo izpis za omrežje, kjer so dodatno obrvani prvi biti glede na razred IP naslova. public static void WriteNetwork(IPAddress ipAddress, IPAddress subnetMask) { var networkAddress = ipAddress.GetNetworkAddress(subnetMask); var ipClass = networkAddress.GetClass(); Write("Network: ".PadRight(RightPadding)); ForegroundColor = Blue; string network = $"{networkAddress}/{SubnetMask.GetNetBitLength(subnetMask)}"; Write(network.PadRight(RightPadding)); ForegroundColor = DarkGray; int numOfColoredBits = (int)ipClass + 1; if (numOfColoredBits == 5) { numOfColoredBits--; } SetCursorPosition(ThirdRow, CursorTop); if (ipClass > IPClass.Undefined && ipClass < IPClass.Invalid) { WriteWithColoredStartChars(networkAddress.ToBinary(), numOfColoredBits); } else { Write(networkAddress.ToBinary()); } Write(" ("); ForegroundColor = Green; if (ipClass > IPClass.Undefined && ipClass < IPClass.Invalid) { Write($"Class {ipClass}"); } else { Write(ipClass); } ForegroundColor = DarkGray; Write(")"); ResetColor(); WriteLine(); }