Esempio n. 1
0
 private void calculate()
 {
     if (Adress != null)
     {
         this.subnetMask = this.Adress.BuildNewSubnetMask(this.net);
         this.networkAdress = this.Adress.BuildNetworkAdress();
         // ------------------------------------------------------------
         this.hostAdresses = this.Adress.BuildSubnetAdresses(this.net);
         this.firstHostAdresses = this.Adress.BuildFirstAdresses(this.net);
         this.lastHostAdresses = this.Adress.BuildLastNetAdress(this.net);
         this.broadcastAdresses = this.Adress.BuildBroadcastAdress(this.net);
         // ------------------------------------------------------------
     }
 }      
Esempio n. 2
0
 public Subnet(IPAdress Adress, int net)
 {
     this.Adress = Adress;
     this.Net = net;
 }
Esempio n. 3
0
 private void fOct_ValueChanged(object sender, EventArgs e)
 {
     this.currentIPAdress = new Classes.IPAdress((int)fOct.Value, (int)sOct.Value, (int)tOct.Value, (int)foOct.Value, (int)this.subMask.Value);
     this.lblIPAdress.Text = "IP-Adresse: " + this.currentIPAdress.ToString() + "/" + this.subMask.Value + " @ " + (int)this.nets.Value + " Netze";
 }
Esempio n. 4
0
 public frmMain()
 {
     InitializeComponent();
     this.currentIPAdress = new Classes.IPAdress(192, 168, 2, 100, 8);
     this.mySubnet = new Classes.Subnet(this.currentIPAdress, 16);
 }
Esempio n. 5
0
        public IPAdress BuildNewSubnetMask(int net)
        {
            // Get bits for this network
            int bits = GetBitsFromNet(net);
            IPAdress currentAdress = new IPAdress(this.FOct, this.SOct, this.TOct, this.FoOct, this.mask); // this.mask + bits
            Bit[] ip = new Bit[32];
            for (int i = 0; i <= 32 - 1; i++)
                ip[i] = new Bit(1);

            Bit[] subNet = new Bit[32];
            for (int i = 0; i <= 32 - 1; i++)
                subNet[i] = (i <= currentAdress.mask - 1 ? new Bit(1) : new Bit(0));

            Bit[] finalIP = linkAnd(ip, subNet);

            return this.BuildIPAdressFromBit(finalIP, currentAdress.mask);
        }
Esempio n. 6
0
        private IPAdress BuildIPAdressFromBit(Bit[] value, int mask)
        {
            IPAdress currentAdress = new IPAdress(10, 10, 10, 10, mask);
            int currentOct = 0;
            int otherCounter = 0;
            var lst = currentAdress.getBitArraysAsList();

            for (int i = 1; i <= value.Length; i++)
            {
                if (i % 8 == 0)
                {
                    lst[currentOct][otherCounter] = value[i - 1];
                    currentOct++;
                    otherCounter = 0;
                }
                else
                {
                    lst[currentOct][otherCounter] = value[i - 1];
                    otherCounter++;
                }
            }

            for (int f = 0; f <= lst.Count - 1; f++)
            {
                string currentStr = string.Empty;
                for (int b = 0; b <= lst[f].Length - 1; b++)
                { currentStr += lst[f][b].Value; }

                if (f == 0)
                    currentAdress.FOct = Convert.ToInt32(currentStr, 2);
                else if (f == 1)
                    currentAdress.SOct = Convert.ToInt32(currentStr, 2);
                else if (f == 2)
                    currentAdress.TOct = Convert.ToInt32(currentStr, 2);
                else if (f == 3)
                    currentAdress.FoOct = Convert.ToInt32(currentStr, 2);
            }

            return currentAdress;
        }