Exemplo n.º 1
0
        private void ChangeLabel(MPLSPacket packet)
        {
            int oldPort  = packet.DestinationPort;
            int oldLabel = packet.GetLabelFromStack();

            int[] FIBOutput = fib.GetOutput(oldPort, oldLabel, packet.ipPacket.destinationAddress);
            int   port      = FIBOutput[0];
            int   label     = FIBOutput[1];

            packet.DestinationPort = port;
            LogClass.WhiteLog("MPLSPacket from inPort " + oldPort + ": old label = " + oldLabel);
            if (label != 0)
            {
                packet.PutLabelOnStack(label);
                Console.WriteLine("            | new label = " + label);
            }
            else
            {
                Console.WriteLine("            | old label removed");
            }

            if (fib.LookForLabelToBeAdded(oldPort, oldLabel) != 0)
            {
                int addingLabel = fib.LookForLabelToBeAdded(oldPort, oldLabel);
                packet.PutLabelOnStack(fib.LookForLabelToBeAdded(oldPort, oldLabel));
                LogClass.Log("Starting new tunnel with label " + addingLabel);
                ChangeLabel(packet);
            }
            else if (fib.LookForLabelToBeRemoved(oldPort, oldLabel) != 0)
            {
                LogClass.Log("Ending tunnel");
                ChangeLabel(packet);
            }
        }
Exemplo n.º 2
0
        private void ChangeLabel(MPLSPacket packet)
        {
            int[] FIBOutput = fib.GetOutput(packet.destinationPort, packet.GetLabelFromStack());
            int   port      = FIBOutput[0];
            int   label     = FIBOutput[1];

            packet.destinationPort = port;
            packet.PutLabelOnStack(label);
        }