@Override
    public OFInstructionIdBsnAutoNegotiation readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 65535
      short type = bb.readShort();
      if (type != (short) 0xffff)
        throw new OFParseError(
            "Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 12) throw new OFParseError("Wrong length: Expected=12(12), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      // fixed value property experimenter == 0x5c16c7L
      int experimenter = bb.readInt();
      if (experimenter != 0x5c16c7)
        throw new OFParseError(
            "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter);
      // fixed value property subtype == 0xbL
      int subtype = bb.readInt();
      if (subtype != 0xb)
        throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got=" + subtype);

      if (logger.isTraceEnabled())
        logger.trace("readFrom - returning shared instance={}", INSTANCE);
      return INSTANCE;
    }
Exemplo n.º 2
0
 /**
  * Deserialize an object from a given byte buffer.
  *
  * @param b The bytebuf to deserialize.
  * @return The deserialized object.
  */
 @Override
 public Object deserialize(ByteBuf b, CorfuRuntime rt) {
   int classNameLength = b.readShort();
   byte[] classNameBytes = new byte[classNameLength];
   b.readBytes(classNameBytes, 0, classNameLength);
   String className = new String(classNameBytes);
   if (className.equals("null")) {
     return null;
   } else if (className.equals("CorfuObject")) {
     int SMRClassNameLength = b.readShort();
     byte[] SMRClassNameBytes = new byte[SMRClassNameLength];
     b.readBytes(SMRClassNameBytes, 0, SMRClassNameLength);
     String SMRClassName = new String(SMRClassNameBytes);
     try {
       return rt.getObjectsView()
           .build()
           .setStreamID(new UUID(b.readLong(), b.readLong()))
           .setType(Class.forName(SMRClassName))
           .open();
     } catch (ClassNotFoundException cnfe) {
       log.error("Exception during deserialization!", cnfe);
       throw new RuntimeException(cnfe);
     }
   } else {
     try (ByteBufInputStream bbis = new ByteBufInputStream(b)) {
       try (InputStreamReader r = new InputStreamReader(bbis)) {
         return gson.fromJson(r, Class.forName(className));
       }
     } catch (IOException | ClassNotFoundException ie) {
       log.error("Exception during deserialization!", ie);
       throw new RuntimeException(ie);
     }
   }
 }
    @Override
    public OFMeterFeaturesStatsReply readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property version == 5
      byte version = bb.readByte();
      if (version != (byte) 0x5)
        throw new OFParseError("Wrong version: Expected=OFVersion.OF_14(5), got=" + version);
      // fixed value property type == 19
      byte type = bb.readByte();
      if (type != (byte) 0x13)
        throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 32) throw new OFParseError("Wrong length: Expected=32(32), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      long xid = U32.f(bb.readInt());
      // fixed value property statsType == 11
      short statsType = bb.readShort();
      if (statsType != (short) 0xb)
        throw new OFParseError(
            "Wrong statsType: Expected=OFStatsType.METER_FEATURES(11), got=" + statsType);
      Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer14.readFrom(bb);
      // pad: 4 bytes
      bb.skipBytes(4);
      OFMeterFeatures features = OFMeterFeaturesVer14.READER.readFrom(bb);

      OFMeterFeaturesStatsReplyVer14 meterFeaturesStatsReplyVer14 =
          new OFMeterFeaturesStatsReplyVer14(xid, flags, features);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", meterFeaturesStatsReplyVer14);
      return meterFeaturesStatsReplyVer14;
    }
    @Override
    public OFFlowStatsEntry readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      int length = U16.f(bb.readShort());
      if (length < MINIMUM_LENGTH)
        throw new OFParseError(
            "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      TableId tableId = TableId.readByte(bb);
      // pad: 1 bytes
      bb.skipBytes(1);
      long durationSec = U32.f(bb.readInt());
      long durationNsec = U32.f(bb.readInt());
      int priority = U16.f(bb.readShort());
      int idleTimeout = U16.f(bb.readShort());
      int hardTimeout = U16.f(bb.readShort());
      Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer14.readFrom(bb);
      int importance = U16.f(bb.readShort());
      // pad: 2 bytes
      bb.skipBytes(2);
      U64 cookie = U64.ofRaw(bb.readLong());
      U64 packetCount = U64.ofRaw(bb.readLong());
      U64 byteCount = U64.ofRaw(bb.readLong());
      Match match = ChannelUtilsVer14.readOFMatch(bb);
      List<OFInstruction> instructions =
          ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer14.READER);

      OFFlowStatsEntryVer14 flowStatsEntryVer14 =
          new OFFlowStatsEntryVer14(
              tableId,
              durationSec,
              durationNsec,
              priority,
              idleTimeout,
              hardTimeout,
              flags,
              importance,
              cookie,
              packetCount,
              byteCount,
              match,
              instructions);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", flowStatsEntryVer14);
      return flowStatsEntryVer14;
    }
  @Test
  public void testMemcachedRequestEncoder() {

    MemcachedRequest request = new MemcachedRequest(Opcode.SET, "key1", "value1");

    EmbeddedChannel channel = new EmbeddedChannel(new MemcachedRequestEncoder());

    Assert.assertTrue(channel.writeOutbound(request));

    ByteBuf encoded = (ByteBuf) channel.readOutbound();

    Assert.assertNotNull(encoded);

    Assert.assertEquals(request.magic(), encoded.readByte() & 0xFF);

    Assert.assertEquals(request.opCode(), encoded.readByte() & 0xFF);

    Assert.assertEquals(4, encoded.readShort());

    Assert.assertEquals((byte) 0x08, encoded.readByte() & 0xFF);

    Assert.assertEquals((byte) 0, encoded.readByte() & 0xFF);

    Assert.assertEquals(0, encoded.readShort());
    // 注意发送端发的什么位模式这里就收什么位模式。
    // 其实这里也要注意,如果传的刚好是0x8000,解析出来也要注意符号的问题。主要要弄清java是怎么补位和截断,然后保证传的位模式不要被误解。

    Assert.assertEquals(4 + 6 + 8, encoded.readInt());

    Assert.assertEquals(request.id(), encoded.readInt());

    Assert.assertEquals(request.cas(), encoded.readLong());

    Assert.assertEquals(request.flags(), encoded.readInt());

    Assert.assertEquals(request.expires(), encoded.readInt());

    byte[] data = new byte[encoded.readableBytes()];

    encoded.readBytes(data);

    Assert.assertEquals((request.key() + request.body()).getBytes(CharsetUtil.UTF_8), data);

    Assert.assertFalse(encoded.isReadable());

    Assert.assertFalse(channel.finish());

    Assert.assertNull(channel.readInbound());
  }
 public static OFPortModFailedCode readFrom(ByteBuf bb) throws OFParseError {
   try {
     return ofWireValue(bb.readShort());
   } catch (IllegalArgumentException e) {
     throw new OFParseError(e);
   }
 }
Exemplo n.º 7
0
 @Override
 public void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception {
   while (in.readableBytes() >= 2) {
     int value = in.readShort();
     out.writeChar(value * value);
   }
 }
Exemplo n.º 8
0
 @Override
 public void readFrom(ByteBuf fromBuffer) {
   short length = fromBuffer.readShort();
   byte[] array = new byte[length];
   fromBuffer.readBytes(array);
   this.command = new String(array, PROTOCOL_ENCODING);
 }
  protected void checkCloseFrameBody(ChannelHandlerContext ctx, ByteBuf buffer) {
    if (buffer == null || buffer.capacity() == 0) {
      return;
    }
    if (buffer.capacity() == 1) {
      protocolViolation(ctx, "Invalid close frame body");
    }

    // Save reader index
    int idx = buffer.readerIndex();
    buffer.readerIndex(0);

    // Must have 2 byte integer within the valid range
    int statusCode = buffer.readShort();
    if (statusCode >= 0 && statusCode <= 999
        || statusCode >= 1004 && statusCode <= 1006
        || statusCode >= 1012 && statusCode <= 2999) {
      protocolViolation(ctx, "Invalid close frame getStatus code: " + statusCode);
    }

    // May have UTF-8 message
    if (buffer.isReadable()) {

      try {
        new UTF8Output(buffer);
      } catch (UTF8Exception ex) {
        protocolViolation(ctx, "Invalid close frame reason text. Invalid UTF-8 bytes");
      }
    }

    // Restore reader index
    buffer.readerIndex(idx);
  }
Exemplo n.º 10
0
 public void readData(ByteBuf data) {
   id = data.readShort();
   parseData(data.readUnsignedShort(), data.readUnsignedByte());
   dX = data.readFloat();
   dY = data.readFloat();
   dZ = data.readFloat();
 }
Exemplo n.º 11
0
  @Override
  public void fromBytes(final ByteBuf stream) {
    // Read the id
    short id = stream.readShort();
    if (id == -1) {
      // Invalid packet
      ThELog.warning("Unknown packet detected");
      return;
    }

    // Get the class for that id
    Class epClass = NetworkHandler.getPacketClassFromID(id);
    if (epClass == null) {
      return;
    }

    // Construct the class
    try {
      this.embeddedPacket = (ThEBasePacket) epClass.newInstance();

      // Pass to packet
      this.embeddedPacket.fromBytes(stream);
    } catch (Exception e) {
      // Packet did not have default constructor
      ThELog.warning("Unable to construct packet %s", epClass.getCanonicalName());
    }
  }
Exemplo n.º 12
0
 @Override
 protected void readFromPacket(ByteBuf buffer) {
   super.readFromPacket(buffer);
   if (buffer.readInt() == 6) {
     this.PowerVal1 = buffer.readShort();
     this.PowerVal2 = buffer.readShort();
   }
 }
 @Override
 public void unmarshallMessage(ByteBuf cb) {
   slaveServerId = cb.readInt();
   reportHost = MysqlAPIUtils.getLengthCodedString(cb);
   reportUser = MysqlAPIUtils.getLengthCodedString(cb);
   reportPassword = MysqlAPIUtils.getLengthCodedString(cb);
   reportPort = cb.readShort();
 }
Exemplo n.º 14
0
  public static ItemStack readItemstack(ByteBuf in) {
    int id = in.readShort();

    if (id == -1) return null;

    int count = in.readByte();
    int damage = in.readShort();
    int dataLength = in.readShort();
    byte[] nbtData = null;

    if (dataLength > 0) {
      nbtData = new byte[dataLength];
      in.readBytes(nbtData);
    }

    return new ItemStack(id, count, damage);
  }
    @Override
    public OFBsnSetPktinSuppressionRequest readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property version == 3
      byte version = bb.readByte();
      if (version != (byte) 0x3)
        throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got=" + version);
      // fixed value property type == 4
      byte type = bb.readByte();
      if (type != (byte) 0x4)
        throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 32) throw new OFParseError("Wrong length: Expected=32(32), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      long xid = U32.f(bb.readInt());
      // fixed value property experimenter == 0x5c16c7L
      int experimenter = bb.readInt();
      if (experimenter != 0x5c16c7)
        throw new OFParseError(
            "Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got=" + experimenter);
      // fixed value property subtype == 0xbL
      int subtype = bb.readInt();
      if (subtype != 0xb)
        throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got=" + subtype);
      boolean enabled = (bb.readByte() != 0);
      // pad: 1 bytes
      bb.skipBytes(1);
      int idleTimeout = U16.f(bb.readShort());
      int hardTimeout = U16.f(bb.readShort());
      int priority = U16.f(bb.readShort());
      U64 cookie = U64.ofRaw(bb.readLong());

      OFBsnSetPktinSuppressionRequestVer12 bsnSetPktinSuppressionRequestVer12 =
          new OFBsnSetPktinSuppressionRequestVer12(
              xid, enabled, idleTimeout, hardTimeout, priority, cookie);
      if (logger.isTraceEnabled())
        logger.trace("readFrom - read={}", bsnSetPktinSuppressionRequestVer12);
      return bsnSetPktinSuppressionRequestVer12;
    }
Exemplo n.º 16
0
 /** decode stream to object */
 public ResponseSocketBlock decode(ByteBuf buf) throws IOException {
   // * --------------------------------------------------------bytes =13
   // * byte[1]  version                              RSF版本(0x80)
   byte version = buf.readByte();
   // * byte[8]  requestID                            包含的请求ID
   long requestID = buf.readLong();
   // * byte[1]  keepData                             保留区
   buf.skipBytes(1);
   // * byte[3]  contentLength                        内容大小
   buf.skipBytes(3); // .readUnsignedMedium()
   //
   ResponseSocketBlock res = new ResponseSocketBlock();
   res.setVersion(version);
   res.setRequestID(requestID);
   // * --------------------------------------------------------bytes =8
   // * byte[2]  status                               响应状态
   res.setStatus(buf.readShort());
   // * byte[2]  serializeType-(attr-index)           序列化策略
   res.setSerializeType(buf.readShort());
   // * byte[2]  returnType-(attr-index)              返回类型
   res.setReturnType(buf.readShort());
   // * byte[2]  returnData-(attr-index)              返回数据
   res.setReturnData(buf.readShort());
   // * --------------------------------------------------------bytes =1 ~ 1021
   // * byte[1]  optionCount                          选项参数总数
   byte optionCount = buf.readByte();
   for (int i = 0; i < optionCount; i++) {
     // * byte[4]  attr-0-(attr-index,attr-index)   选项参数
     int mergeData = buf.readInt();
     res.addOption(mergeData);
   }
   // * --------------------------------------------------------bytes =6 ~ 8192
   // * byte[2]  attrPool-size (Max = 2047)           池大小
   short attrPoolSize = buf.readShort();
   for (int i = 0; i < attrPoolSize; i++) {
     // * byte[4] att-length                        属性1大小
     int length = buf.readInt();
     res.addPoolData(length);
   }
   // * --------------------------------------------------------bytes =n
   // * dataBody                                      数据内容
   res.fillFrom(buf.readBytes(res.getPoolSize()));
   return res;
 }
    @Override
    public OFBsnTlvMissPackets readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 0xd
      short type = bb.readShort();
      if (type != (short) 0xd) throw new OFParseError("Wrong type: Expected=0xd(0xd), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 12) throw new OFParseError("Wrong length: Expected=12(12), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      U64 value = U64.ofRaw(bb.readLong());

      OFBsnTlvMissPacketsVer13 bsnTlvMissPacketsVer13 = new OFBsnTlvMissPacketsVer13(value);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnTlvMissPacketsVer13);
      return bsnTlvMissPacketsVer13;
    }
 @Override
 public OFPortStatsPropExperimenter readFrom(ByteBuf bb) throws OFParseError {
   if (bb.readableBytes() < MINIMUM_LENGTH) return null;
   int start = bb.readerIndex();
   // fixed value property type == 0xffff
   short type = bb.readShort();
   if (type != (short) 0xffff)
     throw new OFParseError("Wrong type: Expected=0xffff(0xffff), got=" + type);
   int length = U16.f(bb.readShort());
   if (length < MINIMUM_LENGTH)
     throw new OFParseError(
         "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
   int experimenter = bb.readInt();
   bb.readerIndex(start);
   switch (experimenter) {
     default:
       throw new OFParseError(
           "Unknown value for discriminator experimenter of class OFPortStatsPropExperimenterVer14: "
               + experimenter);
   }
 }
  @Override
  public void readClient(ByteBuf in) {
    worldId = in.readInt();
    xPos = in.readInt();
    zPos = in.readInt();

    pos.x = in.readInt();
    pos.y = in.readShort();
    pos.z = in.readInt();

    in.readBytes(array);
  }
Exemplo n.º 20
0
  public static byte[] a(ByteBuf bytebuf) {
    short short1 = bytebuf.readShort();

    if (short1 < 0) {
      throw new IOException("Key was smaller than nothing!  Weird key!");
    } else {
      byte[] abyte = new byte[short1];

      bytebuf.readBytes(abyte);
      return abyte;
    }
  }
    @Override
    public OFBsnTlvStatus readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 0x61
      short type = bb.readShort();
      if (type != (short) 0x61)
        throw new OFParseError("Wrong type: Expected=0x61(0x61), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 5) throw new OFParseError("Wrong length: Expected=5(5), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      OFBsnStatus value = OFBsnStatusSerializerVer13.readFrom(bb);

      OFBsnTlvStatusVer13 bsnTlvStatusVer13 = new OFBsnTlvStatusVer13(value);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", bsnTlvStatusVer13);
      return bsnTlvStatusVer13;
    }
Exemplo n.º 22
0
  public static NBTTagCompound readNBTTagCompound(ByteBuf fullBuffer) throws IOException {
    short short1 = fullBuffer.readShort(); // par0DataInput.readShort();

    if (short1 < 0) {
      return null;
    } else {
      byte[] abyte = new byte[short1];
      fullBuffer.readBytes(abyte);
      return CompressedStreamTools.func_152457_a(abyte, new NBTSizeTracker(2097152L));
      // return CompressedStreamTools.decompress(abyte);
    }
  }
Exemplo n.º 23
0
 @Override
 public void fromBytes(ByteBuf buf) {
   super.fromBytes(buf);
   byte command = buf.readByte();
   if (command == 0) {
     mat = Mats.values()[buf.readByte()];
   } else if (command == 1) {
     enchant = buf.readShort();
   } else if (command == 2) {
   } else {
     throw new InvalidParameterException();
   }
 }
    @Override
    public OFActionCopyTtlIn readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 12
      short type = bb.readShort();
      if (type != (short) 0xc)
        throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_IN(12), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 8) throw new OFParseError("Wrong length: Expected=8(8), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      // pad: 4 bytes
      bb.skipBytes(4);

      if (logger.isTraceEnabled())
        logger.trace("readFrom - returning shared instance={}", INSTANCE);
      return INSTANCE;
    }
 ClayLump read(ByteBuf in) throws IOException {
   minX = in.readByte();
   minY = in.readByte();
   minZ = in.readByte();
   maxX = in.readByte();
   maxY = in.readByte();
   maxZ = in.readByte();
   icon_id = DataUtil.getBlock(in.readShort());
   icon_md = in.readByte();
   icon_side = in.readByte();
   quat = Quaternion.read(in);
   return this;
 }
Exemplo n.º 26
0
    @Override
    public LispMapNotify readFrom(ByteBuf byteBuf) throws LispParseError, LispReaderException {

      if (byteBuf.readerIndex() != 0) {
        return null;
      }

      // skip first three bytes as they represent type and reserved fields
      byteBuf.skipBytes(RESERVED_SKIP_LENGTH);

      // record count -> 8 bits
      byte recordCount = (byte) byteBuf.readUnsignedByte();

      // nonce -> 64 bits
      long nonce = byteBuf.readLong();

      // keyId -> 16 bits
      short keyId = byteBuf.readShort();

      // authenticationDataLength -> 16 bits
      short authLength = byteBuf.readShort();

      // authenticationData -> depends on the authenticationDataLength
      byte[] authData = new byte[authLength];
      byteBuf.readBytes(authData);

      List<LispMapRecord> mapRecords = Lists.newArrayList();
      for (int i = 0; i < recordCount; i++) {
        mapRecords.add(new DefaultLispMapRecord.MapRecordReader().readFrom(byteBuf));
      }

      return new DefaultNotifyBuilder()
          .withRecordCount(recordCount)
          .withNonce(nonce)
          .withKeyId(keyId)
          .withAuthenticationData(authData)
          .withMapRecords(mapRecords)
          .build();
    }
  /** 解密 */
  @Override
  protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    if (in.readableBytes() < 4) {
      return;
    }
    int header = in.readShort();
    int packetLength = in.readShort();
    // 预解密长度信息成功,回溯位置
    in.readerIndex(in.readerIndex() - 4);
    // 如果不是标识头,发送给客户端说,断开连接
    if (header != Message.HEADER || packetLength < Message.HEAD_SIZE) {
      // 数据包长度错误,断开连接
      LogUtil.error(
          String.format(
              "error packet length: packetlength=%d Packet.HDR_SIZE=%d",
              packetLength, Message.HEAD_SIZE));
      LogUtil.error(
          String.format(
              "Disconnect the client:%s",
              ((InetSocketAddress) ctx.channel().remoteAddress()).getHostName()));
      ctx.channel().close();
      return;
    }

    if (in.readableBytes() < packetLength) {
      // 数据长度不足,等待下次接收
      return;
    }
    // 读取数据并解密数据
    byte[] data = new byte[packetLength];
    in.getBytes(in.readerIndex(), data, 0, packetLength);
    in.readerIndex(in.readerIndex() + packetLength);
    Message packet = Message.build(data);
    if (packet != null) {
      out.add(packet);
    }
    return;
  }
    @Override
    public OFActionSetDlSrc readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property type == 4
      short type = bb.readShort();
      if (type != (short) 0x4)
        throw new OFParseError("Wrong type: Expected=OFActionType.SET_DL_SRC(4), got=" + type);
      int length = U16.f(bb.readShort());
      if (length != 16) throw new OFParseError("Wrong length: Expected=16(16), got=" + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      MacAddress dlAddr = MacAddress.read6Bytes(bb);
      // pad: 6 bytes
      bb.skipBytes(6);

      OFActionSetDlSrcVer10 actionSetDlSrcVer10 = new OFActionSetDlSrcVer10(dlAddr);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", actionSetDlSrcVer10);
      return actionSetDlSrcVer10;
    }
 @Override
 public OFExperimenterStatsReply readFrom(ByteBuf bb) throws OFParseError {
   if (bb.readableBytes() < MINIMUM_LENGTH) return null;
   int start = bb.readerIndex();
   // fixed value property version == 3
   byte version = bb.readByte();
   if (version != (byte) 0x3)
     throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got=" + version);
   // fixed value property type == 19
   byte type = bb.readByte();
   if (type != (byte) 0x13)
     throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got=" + type);
   int length = U16.f(bb.readShort());
   if (length < MINIMUM_LENGTH)
     throw new OFParseError(
         "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
   U32.f(bb.readInt());
   // fixed value property statsType == 65535
   short statsType = bb.readShort();
   if (statsType != (short) 0xffff)
     throw new OFParseError(
         "Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got=" + statsType);
   OFStatsReplyFlagsSerializerVer12.readFrom(bb);
   // pad: 4 bytes
   bb.skipBytes(4);
   int experimenter = bb.readInt();
   bb.readerIndex(start);
   switch (experimenter) {
     case 0x5c16c7:
       // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsReplyVer12
       return OFBsnStatsReplyVer12.READER.readFrom(bb);
     default:
       throw new OFParseError(
           "Unknown value for discriminator experimenter of class OFExperimenterStatsReplyVer12: "
               + experimenter);
   }
 }
    @Override
    public OFMeterStatsReply readFrom(ByteBuf bb) throws OFParseError {
      int start = bb.readerIndex();
      // fixed value property version == 5
      byte version = bb.readByte();
      if (version != (byte) 0x5)
        throw new OFParseError("Wrong version: Expected=OFVersion.OF_14(5), got=" + version);
      // fixed value property type == 19
      byte type = bb.readByte();
      if (type != (byte) 0x13)
        throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got=" + type);
      int length = U16.f(bb.readShort());
      if (length < MINIMUM_LENGTH)
        throw new OFParseError(
            "Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
      if (bb.readableBytes() + (bb.readerIndex() - start) < length) {
        // Buffer does not have all data yet
        bb.readerIndex(start);
        return null;
      }
      if (logger.isTraceEnabled()) logger.trace("readFrom - length={}", length);
      long xid = U32.f(bb.readInt());
      // fixed value property statsType == 9
      short statsType = bb.readShort();
      if (statsType != (short) 0x9)
        throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER(9), got=" + statsType);
      Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer14.readFrom(bb);
      // pad: 4 bytes
      bb.skipBytes(4);
      List<OFMeterStats> entries =
          ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFMeterStatsVer14.READER);

      OFMeterStatsReplyVer14 meterStatsReplyVer14 = new OFMeterStatsReplyVer14(xid, flags, entries);
      if (logger.isTraceEnabled()) logger.trace("readFrom - read={}", meterStatsReplyVer14);
      return meterStatsReplyVer14;
    }