bool thInterfaceIO_HandlerStatusCallback(TrafficHandlerPort sender, TrafficHandlerPort attacher) { CheckPorts(sender, InterfaceIOPort); DirectInterfaceIOHandler thLocalHandler = (DirectInterfaceIOHandler)TrafficHandler; return(attacher.ParentHandler is IPInterface && thLocalHandler.ContainsInterface((IPInterface)attacher.ParentHandler)); }
/// <summary> /// Creates an InterfaceIO port /// </summary> /// <param name="h">The DirectInterfaceIOHandler to create the port for</param> /// <returns>The created port</returns> protected TrafficHandlerPort CreateDirectInterfaceIOPort(DirectInterfaceIOHandler h) { if (h != TrafficHandler) { throw new InvalidOperationException("It's not allowed to create a port with a traffic handler which was not created by this definition"); } InterfaceIOPort = new TrafficHandlerPort(this, "Interface IO Port", "A port which receives and transmits data from and to an inbound network interface", PortType.InterfaceIO, "I/O"); InterfaceIOPort.HandlerAttaching += new TrafficHandlerPort.PortActionEventHandler(thInterfaceIO_HandlerAttached); InterfaceIOPort.HandlerStatusCallback += new TrafficHandlerPort.PortQueryEventHandler(thInterfaceIO_HandlerStatusCallback); InterfaceIOPort.HandlerDetaching += new TrafficHandlerPort.PortActionEventHandler(thInterfaceIO_HandlerDetached); return(InterfaceIOPort); }
private bool AttachInterface(TrafficHandlerPort h) { DirectInterfaceIOHandler thLocalHandler = (DirectInterfaceIOHandler)TrafficHandler; if (h.PortType == PortType.Interface) { if (h.ParentHandler is IPInterface) { IPInterface ipi = (IPInterface)h.ParentHandler; if (!thLocalHandler.ContainsInterface(ipi)) { thLocalHandler.AddInterface(ipi); } else { throw new InvalidOperationException("The ports " + h.Name + " and " + InterfaceIOPort.Name + " are already connected."); } return(true); } } throw new InvalidOperationException("The " + InterfaceIOPort.Name + " cannot be used with other ports then interface ports or other devices then ip interfaces."); }