Exemplo n.º 1
0
        /// <summary>
        /// Decrementa di una unità l'indirizzo di rete
        /// </summary>
        public static string Decrement(string address)
        {
            address = Converters.AddressToBin(address);
            if (address == "00000000.00000000.00000000.00000000")
            {
                throw new Exception("Non decrementabile");
            }
            address = Formatters.RemovePoints(address);
            //
            int temp = address.Length;

            while (address[address.Length - 1] == 0)
            {
                address = address.Remove(address.Length - 1);
            }
            address = address.Remove(address.Length - 1);
            address = address + "0";
            while (address.Length < temp)
            {
                address = address + "1";
            }
            //
            address = Formatters.AddPoints(address);
            return(address);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Dato lo slash di una subnetmask, calcola la subnetmask in base binaria
        /// </summary>
        /// <param name="slash">Slash (numero di bit della parte network)</param>
        /// <returns>Subnetmask in base binaria</returns>
        public static string SubnetmaskSlashToBin(int slash)
        {
            string str = "";

            for (int v = 0; v < slash; v++)
            {
                str += "1";
            }
            return(Formatters.AddPoints(Formatters.CompleteAddressHead(str)));
        }