@Test public void testSerialize() { OF10PortStatusMessageFactory serializer = new OF10PortStatusMessageFactory(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(message, serializedBuffer); BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 64); Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(7); Assert.assertEquals("Wrong port No", message.getPortNo().intValue(), serializedBuffer.readShort()); byte[] address = new byte[6]; serializedBuffer.readBytes(address); Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase()); byte[] name = new byte[16]; serializedBuffer.readBytes(name); Assert.assertEquals("Wrong name", message.getName(), new String(name).trim()); Assert.assertEquals("Wrong config", message.getConfigV10(), createPortConfig(serializedBuffer.readInt())); Assert.assertEquals("Wrong state", message.getStateV10(), createPortState(serializedBuffer.readInt())); Assert.assertEquals("Wrong current", message.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong advertised", message.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong supported", message.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong peer", message.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); }
@Override public void serialize(PortStatusMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeShort(message.getPortNo().intValue()); writeMacAddress(message.getHwAddr().getValue(), outBuffer); writeName(message.getName(), outBuffer); writePortConfig(message.getConfigV10(), outBuffer); writePortState(message.getStateV10(), outBuffer); writePortFeature(message.getCurrentFeaturesV10(), outBuffer); writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(message.getSupportedFeaturesV10(), outBuffer); writePortFeature(message.getPeerFeaturesV10(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }
OF10PortStatusMessageFactory implements OFSerializer<PortStatusMessage> { @Override public void serialize(PortStatusMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeShort(message.getPortNo().intValue()); writeMacAddress(message.getHwAddr().getValue(), outBuffer); writeName(message.getName(), outBuffer); writePortConfig(message.getConfigV10(), outBuffer); writePortState(message.getStateV10(), outBuffer); writePortFeature(message.getCurrentFeaturesV10(), outBuffer); writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(message.getSupportedFeaturesV10(), outBuffer); writePortFeature(message.getPeerFeaturesV10(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); } }
OF10PortStatusMessageFactory implements OFSerializer<PortStatusMessage> { @Override public void serialize(PortStatusMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeShort(message.getPortNo().intValue()); writeMacAddress(message.getHwAddr().getValue(), outBuffer); writeName(message.getName(), outBuffer); writePortConfig(message.getConfigV10(), outBuffer); writePortState(message.getStateV10(), outBuffer); writePortFeature(message.getCurrentFeaturesV10(), outBuffer); writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(message.getSupportedFeaturesV10(), outBuffer); writePortFeature(message.getPeerFeaturesV10(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }  }
OF10PortStatusMessageFactory implements OFSerializer<PortStatusMessage> { @Override public void serialize(PortStatusMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeShort(message.getPortNo().intValue()); writeMacAddress(message.getHwAddr().getValue(), outBuffer); writeName(message.getName(), outBuffer); writePortConfig(message.getConfigV10(), outBuffer); writePortState(message.getStateV10(), outBuffer); writePortFeature(message.getCurrentFeaturesV10(), outBuffer); writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(message.getSupportedFeaturesV10(), outBuffer); writePortFeature(message.getPeerFeaturesV10(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(PortStatusMessage message, ByteBuf outBuffer); }
OF10PortStatusMessageFactory implements OFSerializer<PortStatusMessage> { @Override public void serialize(PortStatusMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeShort(message.getPortNo().intValue()); writeMacAddress(message.getHwAddr().getValue(), outBuffer); writeName(message.getName(), outBuffer); writePortConfig(message.getConfigV10(), outBuffer); writePortState(message.getStateV10(), outBuffer); writePortFeature(message.getCurrentFeaturesV10(), outBuffer); writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); writePortFeature(message.getSupportedFeaturesV10(), outBuffer); writePortFeature(message.getPeerFeaturesV10(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(PortStatusMessage message, ByteBuf outBuffer);  }