@Override
 void processOFHello(OFHello m) throws IOException {
   /*
    * Brocade switches send a second hello after
    * the controller responds with its hello. This
    * might be to confirm the protocol version used,
    * but isn't defined in the OF specification.
    *
    * We will ignore such hello messages assuming
    * the version of the hello is correct according
    * to the algorithm in the spec.
    *
    * TODO Brocade also sets the XID of this second
    * hello as the same XID the controller used.
    * Checking for this might help to assure we're
    * really dealing with the situation we think
    * we are.
    */
   if (m.getVersion().equals(factory.getVersion())) {
     log.warn(
         "Ignoring second hello from {} in state {}. Might be a Brocade.",
         channel.remoteAddress(),
         state.toString());
   } else {
     super.processOFHello(m); /* Versions don't match as they should; abort */
   }
 }
 @Override
 void processOFMessage(OFMessage m) throws IOException {
   if (m.getType().equals(OFType.PACKET_IN)) {
     log.warn(
         "Ignoring PACKET_IN message from {} during OpenFlow channel establishment.",
         channel.remoteAddress());
   } else {
     super.processOFMessage(m);
   }
 }
 @Override
 public void channelRead0(ChannelHandlerContext ctx, Iterable<OFMessage> msgList)
     throws Exception {
   for (OFMessage ofm : msgList) {
     try {
       // Do the actual packet processing
       state.processOFMessage(ofm);
     } catch (Exception ex) {
       // We are the last handler in the stream, so run the
       // exception through the channel again by passing in
       // ctx.getChannel().
       ctx.fireExceptionCaught(ex);
     }
   }
 }
Beispiel #4
0
 @Override
 public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
   if (e.getMessage() instanceof List) {
     @SuppressWarnings("unchecked")
     List<OFMessage> msglist = (List<OFMessage>) e.getMessage();
     for (OFMessage ofm : msglist) {
       try {
         // Do the actual packet processing
         state.processOFMessage(ofm);
       } catch (Exception ex) {
         // We are the last handler in the stream, so run the
         // exception through the channel again by passing in
         // ctx.getChannel().
         Channels.fireExceptionCaught(ctx.getChannel(), ex);
       }
     }
   } else {
     Channels.fireExceptionCaught(
         ctx.getChannel(), new AssertionError("Message received from channel is not a list"));
   }
 }
 /**
  * Update the channels state. Only called from the state machine.
  *
  * @param state
  * @throws IOException
  */
 private void setState(OFChannelState state) throws IOException {
   this.state = state;
   state.logState();
   state.enterState();
 }