} // No. of hosts per subnet //Function stores the network details fro the IP passed as arguments public void GetNetWorkDetails(IP ip) { TotalHosts = 1; DefaultMaskOctet = new byte[4]; IpAddress = ip.IpAddress; SubnetMaskOctet = ip.SubnetOctet; SubnetMaskOctet.CopyTo(DefaultMaskOctet, 0); for (int i = 0; i < 4; i++)//Calculate total hosts in the network { if (DefaultMaskOctet[i] != 255) { TotalHosts *= Convert.ToInt32((byte)~DefaultMaskOctet[i]) + 1; } } }
private void Run_Click(object sender, RoutedEventArgs e) { iP = new IP(); iP.IpAddress = Ip.Text; iP.GetIP(); Boolean p = iP.IpAddress.Equals("Error"); if (p) { Ip.Text = "Error"; Ip.Foreground = Brushes.Red; } else { P1.Visibility = Visibility.Hidden; P2.Visibility = Visibility.Visible; char ipClass = iP.GetClass(); string subnet = iP.ReturnSubnet(); IPDMask.Content = subnet; if (ipClass != '0' && ipClass != 'l') { IPC.Content = ipClass.ToString().ToUpper(); } //Console.WriteLine($"IP Class: {ipClass.ToString().ToUpper()}"); if (ipClass == 'l') { IPC.Content = "LocalHost Entered";//Console.WriteLine("LocalHost Entered"); return; } if (ipClass == 'a' || ipClass == 'b' || ipClass == 'c') { String[] SubnetOctet = iP.SubnetToBinary(); IPDMaskBIN.Content = string.Join('.', SubnetOctet); } } }