Ejemplo n.º 1
0
 /// <summary>
 /// Initialize instance with subnet mask object.
 /// </summary>
 /// <param name="subnetMask"></param>
 public NetworkMask(SubnetMask subnetMask)
 {
     SubnetMask = subnetMask;
 }
Ejemplo n.º 2
0
        public void UpdateSubnetMask()
        {
            try
            {
                SubnetMask subnetMask = new SubnetMask(cmbSubnetMask.Text);
                if (subnetMask.IsValid())
                {
                    ipAddress.SubnetMask = subnetMask;
                    numPrefix.Value = subnetMask.Prefix;

                    picSubnetMask.Image = Resources.icon_ok_20;
                    isValidSubnetMask = true;

                    UpdatePropertiesPanel();
                    UpdateSubnetBitmap();
                }
            }
            catch
            {
                picSubnetMask.Image = Resources.icon_warning_20;
                isValidSubnetMask = false;
            }
            finally
            {
                UpdateSubnettingButton();
            }
        }
Ejemplo n.º 3
0
        public void UpdateClass()
        {
            switch (cmbClass.SelectedIndex)
            {
                case 0:
                    ipAddress = isSelectClass ? new IPv4Address(IPv4Class.A) : new IPv4Address(txtIPv4Address.Text);
                    numPrefix.Minimum = 8;
                    break;
                case 1:
                    ipAddress = isSelectClass ? new IPv4Address(IPv4Class.B) : new IPv4Address(txtIPv4Address.Text);
                    numPrefix.Minimum = 16;
                    break;
                case 2:
                    ipAddress = isSelectClass ? new IPv4Address(IPv4Class.C) : new IPv4Address(txtIPv4Address.Text);
                    numPrefix.Minimum = 24;
                    break;
                default:
                    break;
            }
            numPrefix.Value = ipAddress.SubnetMask.Prefix;
            txtIPv4Address.Text = ipAddress.Address;

            UpdatePropertiesPanel();
            UpdateSubnetBitmap();

            //Update Subnetmask combobox items
            cmbSubnetMask.Items.Clear();
            SubnetMask temp = new SubnetMask();

            for (int i = SubnetMask.ToPrefix(ipAddress.Class); i < 31; i++)
            {
                temp.Prefix = i;
                cmbSubnetMask.Items.Add(temp.ToString());
            }
        }
Ejemplo n.º 4
0
        public void UpdatePrefix()
        {
            try
            {
                SubnetMask subnetMask = new SubnetMask((int)numPrefix.Value);
                ipAddress.SubnetMask = subnetMask;

                cmbSubnetMask.Text = subnetMask.ToString();
                UpdatePropertiesPanel();

                numSubnetBits.Maximum = 30 - numPrefix.Value;
                numNumberOfSubnets.Maximum = (decimal)Math.Pow(2, 30 - (double)numPrefix.Value);
                numHostPerSubnet.Maximum = (decimal)Math.Pow(2, 32 - (double)numPrefix.Value) - 2;
                UpdateSubnetBit();
                UpdateSubnetBitmap();

                picSubnetMask.Image = Resources.icon_ok_20;
            }
            catch { }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initialize IPv4 address
 /// </summary>
 /// <param name="addr">An array of octet of IPv4 address.</param>
 /// <param name="subnetMask">Subnet mask of IPv4 address.</param>
 /// <param name="ipClass">Class of IPv4 address.</param>
 public IPv4Address(Octet[] addr, SubnetMask subnetMask, IPv4Class ipClass)
 {
     Octet = addr;
     _mask = new NetworkMask(subnetMask);
     _class = ipClass;
 }