Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            IPv4 ip1 = new IPv4("1.1.1.50");
            IPv4 ip2 = new IPv4("2.2.2.50"
                                );
            IPv4 ip3 = new IPv4();

            ip3 = ip1 + ip2;
            ip3.print();
            ip3++;
            ip3.print();

            for (int i = 0; i < 10; i++)
            {
                ip3 = ip3 + ip2;
                ip3.print();
            }

            try
            {
            }
            catch (System.Exception e)
            {
                throw;
            }
        }
Пример #2
0
        public static IPv4 operator --(IPv4 IP1)
        {
            //        Complex temp = new Complex();
            IPv4 IPSUM = new IPv4("0.0.0.-1");

            IPSUM = IP1 + IPSUM;

            return(IPSUM);
        }
Пример #3
0
        public static IPv4 operator +(IPv4 IP1, IPv4 IP2)
        {
            IPv4 IPSUM = new IPv4();
            int  riporto, temp, somma;

            for (int i = 3; i > 0; i--)
            {
                temp        = IPSUM.ip[i] + IP1.ip[i] + IP2.ip[i];
                riporto     = temp / 255;
                somma       = temp % 255;
                IPSUM.ip[i] = somma;
                IPSUM.print();
                IPSUM.ip[i - 1] += riporto;
                IPSUM.print();
            }
            IPSUM.ip[0] += IP1.ip[0] + IP2.ip[0];
            return(IPSUM);
        }
Пример #4
0
        public static IPv4 operator -(IPv4 IP1, IPv4 IP2)
        {
            //////////////////////////////////////////////////////////////////////////////
            //   FIXME   puro segnaposto per l'operazione

            IPv4 IPDIFF = new IPv4();

            Console.WriteLine("dentro");
            IP1.print();
            IP2.print();
            IPDIFF.print();
            int riporto, temp, diff;

            for (int i = 0; i < 4; i++)
            {
                IPDIFF.ip[i] = IP1.ip[i] - IP2.ip[i];
            }

            return(IPDIFF);
        }