private void DisplayData(MyIp ip, IpMask mask) { var brAdr = ip.GetBroadcastAdress(mask); var netAdr = ip.GetNetworkAdress(mask); var l = new ObservableCollection <Representation> { new Representation { Name = "Ip adress", BinaryValue = ip.BinaryView(), Value = ip.ToString() }, new Representation { Name = "Mask", BinaryValue = mask.BinaryView(), Value = mask.ToString() }, new Representation { Name = "Broadcast adress", BinaryValue = brAdr.BinaryView(), Value = brAdr.ToString() }, new Representation { Name = "Network adress", BinaryValue = netAdr.BinaryView(), Value = netAdr.ToString() }, }; IpRepresentationListView.ItemsSource = l; IpClassTextBox.Text = ip.GetIpClass(); IpClassTextBox.IsEnabled = true; CountTextBox.Text = mask.GetNetworkCapacity().ToString(); CountTextBox.IsEnabled = true; }
public IpRepresentation GetBroadcastAdress(IpMask mask) { var network = new byte[4]; var ipOctets = base.GetAddressBytes(); var maskOctets = mask.GetAddressBytes(); for (var i = 0; i < 4; i++) { network[i] = (byte)(ipOctets[i] | (255 - maskOctets[i])); } return(new IpRepresentation(network)); }
public IpRepresentation GetNetworkAdress(IpMask mask) { var network = new byte[4]; var ipOctets = GetAddressBytes(); var maskOctets = mask.GetAddressBytes(); for (var i = 0; i < 4; i++) { network[i] = (byte)(ipOctets[i] & maskOctets[i]); } return(new IpRepresentation(network)); }
public MainWindow() { InitializeComponent(); byte mask = 255; byte[] result = new byte[4]; for (var i = 3; i >= 0; i--) { result[i] = 255; } for (var j = 3; j >= 0; j--) { for (int i = 0; i < 8; i++) { mask = (byte)(mask << 1); result[j] = mask; var msk = new IpMask(result); MaskComboBox.Items.Add(msk); } mask = 255; } DisplayIpAdr(); DisplayMacAdr(); }