private string getBroadcast(int index) { int bitChangeCount = _startingLocation; char[] tmp = subnetArray[index, 0].ToCharArray(); int counter = 0; for (int i = bitChangeCount + 1; i < IPAddressSize; i++) { if (counter >= _byteSpace) { if (tmp[i] != '.') { tmp[i] = '1'; } } if (tmp[i] != '.') { counter++; } } string[] binaryAddressArray = (new string(tmp)).Split('.', ':', ' '); converter = new IPConversions(ref binaryAddressArray, IPType.Binary); converter.ConvertAddress(); BroadcastID[index] = converter.GetDecimalIp(); return(converter.GetDecimalIp()); }
private string getDecimalSubnet(int index) { string[] subnetAddressArray = subnetArray[index, 0].Split('.', ' ', ':'); converter = new IPConversions(ref subnetAddressArray, IPType.Binary); converter.ConvertAddress(); DecimalID[index] = converter.GetDecimalIp(); return(converter.GetDecimalIp()); }
public IPAddress(ref string[] address1, ref string[] address2, bool isDecimal) { if (isDecimal) { IPConversions IPC = new IPConversions(ref address1, IPType.Decimal); IPC.ConvertAddress(); _address1 = IPC.GetBinaryIp().Split('.', ':', ' '); FirstOctet = address1[0]; IPC = new IPConversions(ref address2, IPType.Decimal); IPC.ConvertAddress(); _address2 = IPC.GetBinaryIp().Split('.', ':', ' '); _subnetMaskAddress = IPC.GetBinaryIp(); } else { IPConversions IPC = new IPConversions(ref address1, IPType.Binary); IPC.ConvertAddress(); FirstOctet = IPC.GetDecimalIp().Split('.', ':', ' ')[0]; _address1 = address1; IPC = new IPConversions(ref address2, IPType.Binary); IPC.ConvertAddress(); _address2 = address2; _subnetMaskAddress = IPC.GetBinaryIp(); } }
partial void IPAddress_Changed(UITextField sender) { if (IPAddress_TextBox.Text != "") { string[] inputSplit = IPAddress_TextBox.Text.Split('.', ' ', ':'); if (inputSplit.Length == 4) { if (ConvertsToDecimal(ref inputSplit)) { IPConversions ip = new IPConversions(ref inputSplit, IPType.Decimal); ip.ConvertAddress(); Results_TextBox.Text = ip.GetBinaryIp(); IPAddress_TextBox.Text = ip.GetDecimalIp(); } else if (ConvertsToBinary(ref inputSplit)) { IPConversions ip = new IPConversions(ref inputSplit, IPType.Binary); ip.ConvertAddress(); Results_TextBox.Text = ip.GetDecimalIp(); IPAddress_TextBox.Text = ip.GetBinaryIp(); } else { Results_TextBox.Text = ""; } } } }
private string getHostRange(int index) { char[] subnet = subnetArray[index, 0].ToCharArray(); subnet[IPAddressSize - 1] = '1'; string[] decimalAddressArray = BroadcastID[index].Split('.', ':', ' '); converter = new IPConversions(ref decimalAddressArray, IPType.Decimal); converter.ConvertAddress(); char[] subnet2 = converter.GetBinaryIp().ToCharArray(); subnet2[IPAddressSize - 1] = '0'; string[] binaryAddressArray = (new string(subnet)).Split('.', ' ', ':'); converter = new IPConversions(ref binaryAddressArray, IPType.Binary); converter.ConvertAddress(); string lowRange = converter.GetDecimalIp(); string[] binaryAddressArray2 = (new string(subnet2)).Split('.', ':', ' '); converter = new IPConversions(ref binaryAddressArray2, IPType.Binary); converter.ConvertAddress(); string highRange = converter.GetDecimalIp(); HostRange[index] = lowRange + " - " + highRange; return(lowRange + " - " + highRange); }
private string GetSubnetMask(int bits) { char[] mask = "00000000.00000000.00000000.00000000".ToCharArray(); int counter = 0; for (int a = 0; a < 35 && counter < bits; a++) { counter++; if (mask[a] != '.') { mask[a] = '1'; } else { counter--; } } string[] binaryAddressArray = (new string(mask)).Split('.', ':', ' '); IPConversions IPC = new IPConversions(ref binaryAddressArray, IPType.Binary); IPC.ConvertAddress(); return(IPC.GetDecimalIp()); }