Ejemplo n.º 1
0
        public void AddTunnel(Tunnel _t)
        {
            if (_t == null)
            {
                return;
            }
            int count = 0;
            int i     = 0;

            if (tunnels != null)
            {
                count = tunnels.Count();
            }
            for (i = 0; i < count; i++)
            {
                if (tunnels[i].Name == _t.Name)
                {
                    return;
                }
            }

            Tunnel[] tmp = new Tunnel[count + 1];
            for (i = 0; i < count; i++)
            {
                tmp[i] = tunnels[i];
            }
            tmp[count] = new Tunnel();
            tmp[count] = _t;
            tunnels    = tmp;
        }
Ejemplo n.º 2
0
        public void Delete(Tunnel _dt)
        {
            if ((_dt == null) || (_dt.Name == ""))
            {
                return;
            }
            if ((head.Name == _dt.Name) && (head.ID == _dt.ID))
            {
                head = head.Next;
                count--;
                return;
            }
            Tunnel cursor = head;

            while (cursor.Next != null)
            {
                if (cursor.Next.Name == _dt.Name)
                {
                    if (cursor.Next == tail)
                    {
                        tail = cursor;
                    }
                    cursor.Next = cursor.Next.Next;
                    count--;
                    return;
                }
                cursor = cursor.Next;
            }
        }
Ejemplo n.º 3
0
 public Tunnel()
 {
     name         = "";
     iD           = 0;
     srcInterface = new Interface();
     snkInterface = new Interface();
     next         = null;
     pRTTunnel    = null;
     rVSTunnel    = null;
 }
Ejemplo n.º 4
0
 public Tunnel(Tunnel t)
 {
     name         = t.name;
     iD           = t.iD;
     srcInterface = t.srcInterface;
     snkInterface = t.snkInterface;
     transitNEs   = t.transitNEs;
     next         = null;
     pRTTunnel    = t.PRTTunnel;
     rVSTunnel    = t.RVSTunnel;
 }
Ejemplo n.º 5
0
        public bool Add(Tunnel t)
        {
            Tunnel cursor    = head;
            Tunnel preCursor = head;

            if ((t.Name != "") &&
                (t.ID > 0) &&
                (t.SrcInterface.NEName != "") &&
                (t.SrcInterface.SlotPort != "") &&
                (t.SnkInterface.NEName != "") &&
                (t.SnkInterface.SlotPort != ""))
            {
                while (cursor != null)
                {
                    if ((cursor.Name == t.Name) && (cursor.ID == t.ID))
                    {
                        break;
                    }
                    preCursor = cursor;
                    cursor    = cursor.Next;
                }
                Tunnel newTunnel = new Tunnel(t);
                if (cursor == null)
                {
                    if (head == null)
                    {
                        head = newTunnel;
                        tail = newTunnel;
                    }
                    else
                    {
                        tail.Next = newTunnel;
                        tail      = newTunnel;
                    }
                    count++;
                    return(true);
                }
                else
                {
                    if (cursor == tail)
                    {
                        tail = newTunnel;
                    }
                    if (cursor == head)
                    {
                        head = newTunnel;
                    }
                    newTunnel.Next = cursor.Next;
                    preCursor.Next = newTunnel;
                    return(true);
                }
            }
            return(false);
        }// Add
Ejemplo n.º 6
0
        public Tunnel SearchTunnelFromCurrent(string _TunnelName)
        {
            Tunnel cursor = current;

            while (cursor != null)
            {
                if (cursor.Name == _TunnelName)
                {
                    return(cursor);
                }
                cursor = cursor.Next;
            }
            return(null);
        }
Ejemplo n.º 7
0
        public Tunnel SearchTunnel(string _TunnelName)
        {
            Tunnel cursor = head;

            if (_TunnelName == null)
            {
                return(null);
            }
            if (_TunnelName == "")
            {
                return(null);
            }
            while (cursor != null)
            {
                if (cursor.Name == _TunnelName)
                {
                    return(cursor);
                }
                cursor = cursor.Next;
            }
            return(null);
        }
Ejemplo n.º 8
0
 public TunnelList()
 {
     head    = null;
     tail    = null;
     current = null;
 }
Ejemplo n.º 9
0
        } //AddService

        public void AddTunnel(Tunnel _t)
        {
            if (_t == null)
            {
                return;
            }
            NE       tmpNE = null;
            SlotPort tmpSP = null;

            if ((_t.SnkInterface != null) && (_t.SnkInterface.NEName != ""))
            {
                tmpNE = AddNE(_t.SnkInterface.NEName);
                if (tmpNE != null)
                {
                    if (_t.SnkInterface.SlotPort != null)
                    {
                        tmpSP = tmpNE.AddSlotPort(_t.SnkInterface.SlotPort);
                    }
                    if (tmpSP != null)
                    {
                        tmpSP.AddTunnel(_t);
                    }
                }
            }
            if ((_t.SrcInterface != null) && (_t.SrcInterface.NEName != ""))
            {
                tmpNE = AddNE(_t.SrcInterface.NEName);
                if (tmpNE != null)
                {
                    if (_t.SrcInterface.SlotPort != null)
                    {
                        tmpSP = tmpNE.AddSlotPort(_t.SrcInterface.SlotPort);
                    }
                    if (tmpSP != null)
                    {
                        tmpSP.AddTunnel(_t);
                    }
                }
            }
            if (_t.TransitNE != null)
            {
                foreach (TransitNE tmpTrNE in _t.TransitNE)
                {
                    if ((tmpTrNE.NEName != null) && (tmpTrNE.NEName != ""))
                    {
                        tmpNE = AddNE(tmpTrNE.NEName);
                        if (tmpNE != null)
                        {
                            if (tmpTrNE.InSlotPort != null)
                            {
                                tmpSP = tmpNE.AddSlotPort(tmpTrNE.InSlotPort);
                            }
                            if (tmpSP != null)
                            {
                                tmpSP.AddTunnel(_t);
                            }
                            if (tmpTrNE.OutSlotPort != null)
                            {
                                tmpSP = tmpNE.AddSlotPort(tmpTrNE.OutSlotPort);
                            }
                            if (tmpSP != null)
                            {
                                tmpSP.AddTunnel(_t);
                            }
                        }
                    }
                } //forech
            }
        }