private void AddRecord(string command, string clientName)
        {
            // Dodawanie rekordu do tablicy MPLS FIB
            // i wysyłanie komunikatu do odpowiedniego węzła sieciowego

            MplsFIBRecord record = new MplsFIBRecord(command);
            bool          added  = false;

            foreach (MplsFIBRecord row in MplsFibTable)
            {
                if (row.Equals(record))
                {
                    added = true;
                    ReturnLog("Record already exists");
                    break;
                }
            }

            if (added == false)
            {
                try
                {
                    MplsFibTable.Add(record);
                    Send(ClientNamesKeyName[clientName], "ADDRECORD " + record.send());
                    ReturnLog("Record added to MPLS FIB Table");
                }
                catch (Exception e) { ReturnLog("Unable to send message to " + clientName); }
            }
        }
        private void RemoveRecord(string command, string clientName)
        {
            // Usuwanie rekordu z tablicy MPLS FIB
            // i wysyłanie komunikatu do odpowiedniego klienta komunikatu, aby usunąć rekord

            MplsFIBRecord record  = new MplsFIBRecord(command);
            bool          removed = false;

            foreach (MplsFIBRecord row in MplsFibTable)
            {
                if (row.Equals(record))
                {
                    MplsFibTable.Remove(row);

                    try
                    {
                        Send(ClientNamesKeyName[clientName], "REMOVERECORD " + record.send());
                        ReturnLog("Record removed from MPLS FIB Table");
                        removed = true;
                        break;
                    }
                    catch (Exception e) { ReturnLog(e + "\nUnable to send message to " + clientName); }
                }
            }

            if (removed == false)
            {
                ReturnLog("Record doesn't exists");
            }
        }
Ejemplo n.º 3
0
 public override bool Equals(Object obj)
 {
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         MplsFIBRecord record = (MplsFIBRecord)obj;
         return((RouterName == record.RouterName) && (InputPort == record.InputPort) &&
                (InputLabel == record.InputLabel) && (OutputPort == record.OutputPort) &&
                (Enumerable.SequenceEqual(OutputLabel, record.OutputLabel)) && (Index == record.Index));
     }
 }