private bool IPv4_calculateBits() { byte[] tmp; if (IsValidInput_IpV4() && isValidInput_IpV4SubnetMask()) { switch (IpCalculator.getFieldStatus(writeStruct(Textbox_FieldType.SUBNETMASK_LONG), writeStruct(Textbox_FieldType.SUBNETMASK_SHORT))) { case IpV4_FieldStatus.SHORTFILLED: tmp = IpCalculator.calcEmptySubnetMaskFields(Subnet_textBox_ShortWritten); int a = tmp[0]; int b = tmp[1]; int c = tmp[2]; int d = tmp[3]; Subnet_textBox1.Text = a.ToString(); Subnet_textBox2.Text = b.ToString(); Subnet_textBox3.Text = c.ToString(); Subnet_textBox4.Text = d.ToString(); break; case IpV4_FieldStatus.LONGFILLED: tmp = IpCalculator.calcEmptySubnetMaskFields(Subnet_textBox1, Subnet_textBox2, Subnet_textBox3, Subnet_textBox4); int x = tmp[0]; Subnet_textBox_ShortWritten.Text = x.ToString(); break; default: throw new NotImplementedException(); } return(true); } else { return(false); } }
private bool isValidInput_IpV4SubnetMask() { switch (IpCalculator.getFieldStatus(writeStruct(Textbox_FieldType.SUBNETMASK_LONG), writeStruct(Textbox_FieldType.SUBNETMASK_SHORT))) { case IpV4_FieldStatus.SHORTFILLED: if (IpCalculator.isLegitIpV4SubnetMask(Subnet_textBox_ShortWritten)) { createErrorLabel(ErrorCodeNo.NOERROR); return(true); } else { createErrorLabel(ErrorCodeNo.WRONGSUBNETCODE); return(false); } case IpV4_FieldStatus.LONGFILLED: if (IpCalculator.isIpV4Digit(Subnet_textBox1, true) && IpCalculator.isIpV4Digit(Subnet_textBox2, true) && IpCalculator.isIpV4Digit(Subnet_textBox3, true) && IpCalculator.isIpV4Digit(Subnet_textBox4, true)) { if (IpCalculator.isLegitIpV4SubnetMask(writeStruct(Textbox_FieldType.SUBNETMASK_LONG))) { createErrorLabel(ErrorCodeNo.NOERROR); return(true); } else { createErrorLabel(ErrorCodeNo.WRONGSUBNETCODE); return(false); } } else { createErrorLabel(ErrorCodeNo.WRONGSUBNETCODE); return(false); } case IpV4_FieldStatus.BOTHFILLED: createErrorLabel(ErrorCodeNo.MULTIPLEFIELDSFILLED); return(false); case IpV4_FieldStatus.NOFIELDSFILLED: createErrorLabel(ErrorCodeNo.WRONGSUBNETCODE); return(false); default: throw new NotImplementedException(); } }