@Override public String toString() { return getSwitchInfoString(); }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { channel = e.getChannel(); log.info("New switch connection from {}", channel.getRemoteAddress()); /* hack to wait for the switch to tell us what it's max version is. This is not spec compliant and should be removed as soon as switches behave better. */ //sendHandshakeHelloMessage(); setState(ChannelState.WAIT_HELLO); }
@Override public void run(Timeout t) throws Exception { if (t.isCancelled()) { return; } if (!ctx.getChannel().isOpen()) { return; } if (!channelHandler.isHandshakeComplete()) { Channels.fireExceptionCaught(ctx, EXCEPTION); } } }
@Override public ChannelPipeline getPipeline() throws Exception { OFChannelHandler handler = new OFChannelHandler(controller);
@Override public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { log.info("Switch disconnected callback for sw:{}. Cleaning up ...", getSwitchInfoString()); if (thisdpid != 0) { if (!duplicateDpidFound) { // if the disconnected switch (on this ChannelHandler) // was not one with a duplicate-dpid, it is safe to remove all // state for it at the controller. Notice that if the disconnected // switch was a duplicate-dpid, calling the method below would clear // all state for the original switch (with the same dpid), // which we obviously don't want. log.info("{}:removal called", getSwitchInfoString()); if (sw != null) { sw.removeConnectedSwitch(); } } else { // A duplicate was disconnected on this ChannelHandler, // this is the same switch reconnecting, but the original state was // not cleaned up - XXX check liveness of original ChannelHandler log.info("{}:duplicate found", getSwitchInfoString()); duplicateDpidFound = Boolean.FALSE; } } else { log.warn("no dpid in channelHandler registered for " + "disconnected switch {}", getSwitchInfoString()); } }
getSwitchInfoString()); ctx.getChannel().close(); } else if (e.getCause() instanceof HandshakeTimeoutException) { log.error("Disconnecting switch {}: failed to complete handshake", getSwitchInfoString()); ctx.getChannel().close(); } else if (e.getCause() instanceof ClosedChannelException) { log.debug("Channel for sw {} already closed", getSwitchInfoString()); } else if (e.getCause() instanceof IOException) { if (!e.getCause().getMessage().equals(RESET_BY_PEER) && !e.getCause().getMessage().equals(BROKEN_PIPE)) { log.error("Disconnecting switch {} due to IO Error: {}", getSwitchInfoString(), e.getCause().getMessage()); if (log.isDebugEnabled()) { } else if (e.getCause() instanceof SwitchStateException) { log.error("Disconnecting switch {} due to switch state error: {}", getSwitchInfoString(), e.getCause().getMessage()); if (log.isDebugEnabled()) { } else if (e.getCause() instanceof OFParseError) { log.error("Disconnecting switch " + getSwitchInfoString() + " due to message parse failure", e.getCause()); } else { log.error("Error while processing message from switch " + getSwitchInfoString()