Example #1
0
        internal bool addInputEntryToInputTable(int inI, string inL, int outI, string outL)
        {
            //Console.WriteLine("||||||||||||||||||" + inL + "!!!!!");
            LabelSwitchingTableEntry entry = null;

            try
            {
                entry = findRow(inI, inL);
            }
            catch (ArgumentOutOfRangeException)
            {
                try
                {
                    entry = new LabelSwitchingTableEntry(inI, inL, outI, outL);
                    LabelSwitchingTable.Add(entry);
                    //Console.WriteLine(entry.InInterface + entry.InLabel + entry.NPop + entry.XCIndex);
                }
                catch (Exception)
                {
                    Console.WriteLine("Adding InputTableEntry gone wrong");
                    return(false);
                }
                return(true);
            }
            catch (ArgumentNullException)
            {
                try
                {
                    entry = new LabelSwitchingTableEntry(inI, inL, outI, outL);
                    LabelSwitchingTable.Add(entry);
                }
                catch (Exception)
                {
                    Console.WriteLine("Adding InputTableEntry gone wrong");
                    return(false);
                }
                return(true);
            }

            //entry.NPop = outI;
            //entry.XCIndex = xcInd;
            return(true);
        }
Example #2
0
        //internal string GetInEntry(int inI, string inL)
        //{
        //    LabelSwitchingTableEntry entry = null;
        //    try
        //    {
        //        //Console.WriteLine(inI + "|" + inL + "|");
        //        entry = findRow(inI, inL);
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e.Message);
        //        return null;
        //    }
        //    StringBuilder sb = new StringBuilder();
        //    sb.Append(GETSETKeywords.INTAB.ToString()).Append(space).Append(entry.InInterface).Append(space);
        //    if(!inL.Equals(" "))
        //        sb.Append(entry.InLabel).Append(space);
        //    sb.Append(entry.OutInterface).Append(space).Append(entry.OutLabel);
        //    return sb.ToString();
        //}

        internal bool deleteInEntry(int inP, string inL)
        {
            LabelSwitchingTableEntry entry = null;

            try
            {
                entry = findRow(inP, inL);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("deleteInEntry propably couldnt find sauch InputTableEntry");
                return(true);
            }
            if (entry != null)
            {
                if (LabelSwitchingTable.Remove(entry))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        internal byte[] DealWithPacket(CsharpMPLS.Packet _packet)
        {
            _packet.SetNodeID(lsr.nodeID);       //ustawienie id wezla w pakiecie
            if (_packet.GetAndDecreaseTTL() < 0) //TTL sprawdzenie
            {
                throw new Exception();
            }
            LabelSwitchingTableEntry entry = null;

            try
            {
                entry = this.findRow(_packet.ReturnPortNumber(), _packet.GetLabel());
                _packet.SwapLabel(entry.OutLabel);
                _packet.SetPortNumber(entry.OutInterface);
                Console.WriteLine("DealWithPacket:" + _packet.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw new Exception();
            }

            return(_packet.CreatePacketToSend());
        }