private string getHostRange(int index) { char[] subnet = subnetArray[index, 0].ToCharArray(); subnet[IPAddressSize - 1] = '1'; Binary b = new Binary(BroadcastID[index]); b.convertToBinary(); char[] subnet2 = b.binaryIP.ToCharArray(); subnet2[IPAddressSize - 1] = '0'; Decimals d = new Decimals(new string(subnet)); d.convertToDecimal(); string lowRange = d.decimalIP; Decimals d2 = new Decimals(new string(subnet2)); d2.convertToDecimal(); string highRange = d2.decimalIP; HostRange[index] = lowRange + " - " + highRange; return(lowRange + " - " + highRange); }
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++; } } Decimals d = new Decimals(new string(tmp)); d.convertToDecimal(); BroadcastID[index] = d.decimalIP; return(d.decimalIP); }
private string getDecimalSubnet(int index) { Decimals decimalOutput = new Decimals(subnetArray[index, 0]); decimalOutput.convertToDecimal(); DecimalID[index] = decimalOutput.decimalIP; return(decimalOutput.decimalIP); }
public static 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--; } } Decimals d = new Decimals(new string(mask)); d.convertToDecimal(); return(d.decimalIP); }