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; }
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; } }
public Tunnel() { name = ""; iD = 0; srcInterface = new Interface(); snkInterface = new Interface(); next = null; pRTTunnel = null; rVSTunnel = null; }
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; }
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
public Tunnel SearchTunnelFromCurrent(string _TunnelName) { Tunnel cursor = current; while (cursor != null) { if (cursor.Name == _TunnelName) { return(cursor); } cursor = cursor.Next; } return(null); }
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); }
public TunnelList() { head = null; tail = null; current = null; }
} //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 } }