Exemplo n.º 1
0
 public IPCalculation(InternetProtocolAddress ip, byte cidr)
 {
     this.ip   = ip;
     this.cidr = cidr;
     setnetmask();
     setHostnumber();
 }
Exemplo n.º 2
0
 public IPCalculation(InternetProtocolAddress ip, byte cidr)
 {
     this.ip = ip;
     this.cidr = cidr;
     setnetmask();
     setHostnumber();
 }
Exemplo n.º 3
0
 public IPCalculation(InternetProtocolAddress ip, byte cidr)
 {
     this.ip   = ip;
     this.cidr = cidr;
     //if (cidr > 32 || cidr < 0) throw new IndexOutOfRangeException();
     setnetmask();
     setHostnumber();
 }
Exemplo n.º 4
0
 private void calculate()
 {
     byte[] octets= text2byte();
     //InternetProtocolAddress ip = new InternetProtocolAddress(octets[0], octets[1], octets[2], octets[3]);
     InternetProtocolAddress ip = new InternetProtocolAddress(192,168,178,222);
     IPCalculation ipc = new IPCalculation(ip, byte.Parse(Hostbits.SelectedItem.ToString()));
     updateDecimalLabels(ipc);
     updateBinaryLabels(ipc);
 }
Exemplo n.º 5
0
 public InternetProtocolAddress getLastAddress()
 {
     if (firstAddress == null)
         getfirstAddress();
     if (networkaddress == null)
         getNetworkAddress();
     lastAddress = new InternetProtocolAddress((networkaddress.IPAddress ^ rnetmask.IPAddress) - 1);
     return lastAddress;
 }
Exemplo n.º 6
0
 public InternetProtocolAddress getBroadcastAddress()
 {
     if (firstAddress == null)
         getfirstAddress();
     if (networkaddress == null)
         getNetworkAddress();
     broadcastAddress = new InternetProtocolAddress((networkaddress.IPAddress ^ rnetmask.IPAddress));
     return broadcastAddress;
 }
Exemplo n.º 7
0
 public InternetProtocolAddress getLastAddress()
 {
     if (firstAddress == null)
     {
         getfirstAddress();
     }
     if (networkaddress == null)
     {
         getNetworkAddress();
     }
     lastAddress = new InternetProtocolAddress((networkaddress.IPAddress ^ rnetmask.IPAddress) - 1);
     return(lastAddress);
 }
Exemplo n.º 8
0
 public InternetProtocolAddress getBroadcastAddress()
 {
     if (firstAddress == null)
     {
         getfirstAddress();
     }
     if (networkaddress == null)
     {
         getNetworkAddress();
     }
     broadcastAddress = new InternetProtocolAddress((networkaddress.IPAddress ^ rnetmask.IPAddress));
     return(broadcastAddress);
 }
Exemplo n.º 9
0
        private void setnetmask()
        {
            byte octet = 0;
            byte value = 128;

            byte[] netmask = new byte[4];
            for (int i = 0; i <= 32; i++)
            {
                if (i % 8 == 0 && i > 0)
                {
                    netmask[(i / 8) - 1] = octet;
                    octet = 0;
                    value = 128;
                }
                if (i < cidr)
                {
                    octet += value;
                }

                value /= 2;
            }
            this.netmask = new InternetProtocolAddress(netmask[0], netmask[1], netmask[2], netmask[3]);
            rnetmask     = new InternetProtocolAddress(this.netmask.IPAddress ^ UInt32.MaxValue);
        }
Exemplo n.º 10
0
 public InternetProtocolAddress getNetworkAddress()
 {
     networkaddress = new InternetProtocolAddress(ip.IPAddress & netmask.IPAddress);
     return networkaddress;
 }
Exemplo n.º 11
0
 public InternetProtocolAddress getfirstAddress()
 {
     firstAddress = new InternetProtocolAddress((ip.IPAddress & netmask.IPAddress) + 1);
     networkaddress = new InternetProtocolAddress(ip.IPAddress & netmask.IPAddress);
     return firstAddress;
 }
Exemplo n.º 12
0
        private void setnetmask()
        {
            byte octet = 0;
            byte value = 128;
            byte[] netmask = new byte[4];
            for (int i = 0; i <= 32; i++)
            {
                if (i % 8 == 0 && i > 0)
                {
                    netmask[(i / 8) - 1] = octet;
                    octet = 0;
                    value = 128;
                }
                if (i < cidr)
                {
                    octet += value;
                }

                value /= 2;
            }
            this.netmask = new InternetProtocolAddress(netmask[0], netmask[1], netmask[2], netmask[3]);
            rnetmask = new InternetProtocolAddress(this.netmask.IPAddress ^ UInt32.MaxValue);
        }
Exemplo n.º 13
0
 public InternetProtocolAddress getNetworkAddress()
 {
     networkaddress = new InternetProtocolAddress(ip.IPAddress & netmask.IPAddress);
     return(networkaddress);
 }
Exemplo n.º 14
0
 public InternetProtocolAddress getfirstAddress()
 {
     firstAddress   = new InternetProtocolAddress((ip.IPAddress & netmask.IPAddress) + 1);
     networkaddress = new InternetProtocolAddress(ip.IPAddress & netmask.IPAddress);
     return(firstAddress);
 }