use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method serializeDescBody.
private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) {
MultipartReplyDescCase descCase = (MultipartReplyDescCase) body;
MultipartReplyDesc desc = descCase.getMultipartReplyDesc();
write256String(desc.getMfrDesc(), outBuffer);
write256String(desc.getHwDesc(), outBuffer);
write256String(desc.getSwDesc(), outBuffer);
write32String(desc.getSerialNum(), outBuffer);
write256String(desc.getDpDesc(), outBuffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyFlowAggregateStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(packetCount);
final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(byteCount);
final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder().setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount))).setFlowCount(new Counter32(message.readUnsignedInt()));
message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageDeserializer method deserialize.
@Override
public MultipartReply deserialize(ByteBuf message) {
final long xid = message.readUnsignedInt();
final int type = message.readUnsignedShort();
final boolean reqMore = (message.readUnsignedShort() & 0x01) != 0;
message.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
final OFDeserializer<MultipartReplyBody> deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, type, MultipartReplyBody.class));
return new MultipartReplyBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(xid).setRequestMore(reqMore).setMultipartReplyBody(deserializer.deserialize(message)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyPortDescDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
final List<Ports> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final PortsBuilder itemBuilder = new PortsBuilder();
itemBuilder.setPortNumber(new PortNumberUni(message.readUnsignedInt()));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
itemBuilder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
items.add(itemBuilder.setName(ByteBufUtils.decodeNullTerminatedString(message, EncodeConstants.MAX_PORT_NAME_LENGTH)).setConfiguration(readPortConfig(message)).setState(readPortState(message)).setCurrentFeature(readPortFeatures(message)).setAdvertisedFeatures(readPortFeatures(message)).setSupported(readPortFeatures(message)).setPeerFeatures(readPortFeatures(message)).setCurrentSpeed(message.readUnsignedInt()).setMaximumSpeed(message.readUnsignedInt()).build());
}
return builder.setPorts(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testFlowBody.
private static void testFlowBody(MultipartReplyBody body, ByteBuf output) {
MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
FlowStats flowStats = flow.getFlowStats().get(0);
Assert.assertEquals("Wrong length", 176, output.readShort());
Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), output.readUnsignedByte());
output.skipBytes(1);
Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), output.readInt());
Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), output.readInt());
Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), output.readShort());
Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), output.readShort());
Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), output.readShort());
output.skipBytes(6);
Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), output.readLong());
Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), output.readLong());
Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), output.readLong());
Assert.assertEquals("Wrong match type", 1, output.readUnsignedShort());
output.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
short fieldAndMask = output.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
Assert.assertEquals("Wrong oxm value", 42, output.readUnsignedInt());
Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
fieldAndMask = output.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
Assert.assertEquals("Wrong oxm value", 4, output.readUnsignedByte());
output.skipBytes(7);
Assert.assertEquals("Wrong instruction type", 1, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction table-id", 5, output.readUnsignedByte());
output.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 2, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
output.skipBytes(4);
byte[] actual = new byte[8];
output.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", ByteBufUtils.bytesToHexString(actual));
actual = new byte[8];
output.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", ByteBufUtils.bytesToHexString(actual));
Assert.assertEquals("Wrong instruction type", 5, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertEquals("Wrong instruction type", 6, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction meter-id", 42, output.readUnsignedInt());
Assert.assertEquals("Wrong instruction type", 3, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 32, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertEquals("Wrong action type", 0, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, output.readUnsignedShort());
Assert.assertEquals("Wrong action type", 45, output.readUnsignedInt());
Assert.assertEquals("Wrong action type", 55, output.readUnsignedShort());
output.skipBytes(6);
Assert.assertEquals("Wrong action type", 23, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong action type", 64, output.readUnsignedByte());
output.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 4, output.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertEquals("Wrong action type", 17, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 14, output.readUnsignedShort());
output.skipBytes(2);
Assert.assertEquals("Wrong action type", 27, output.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
output.skipBytes(4);
Assert.assertTrue("Not all data were read", output.readableBytes() == 0);
}
Aggregations