use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeAggregateBody.
private void serializeAggregateBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body;
MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate();
outBuffer.writeLong(aggregate.getPacketCount().longValue());
outBuffer.writeLong(aggregate.getByteCount().longValue());
outBuffer.writeInt(aggregate.getFlowCount().intValue());
outBuffer.writeZero(AGGREGATE_PADDING);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeTableBody.
private void serializeTableBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body;
MultipartReplyTable table = tableCase.getMultipartReplyTable();
for (TableStats tableStats : table.getTableStats()) {
outBuffer.writeByte(tableStats.getTableId());
outBuffer.writeZero(TABLE_PADDING);
outBuffer.writeInt(tableStats.getActiveCount().intValue());
outBuffer.writeLong(tableStats.getLookupCount().longValue());
outBuffer.writeLong(tableStats.getMatchedCount().longValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeGroupDescBody.
private void serializeGroupDescBody(final MultipartReplyBody body, final ByteBuf outBuffer, final MultipartReplyMessage message) {
MultipartReplyGroupDescCase groupDescCase = (MultipartReplyGroupDescCase) body;
MultipartReplyGroupDesc group = groupDescCase.getMultipartReplyGroupDesc();
for (GroupDesc groupDesc : group.getGroupDesc()) {
ByteBuf groupDescBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
groupDescBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
groupDescBuff.writeByte(groupDesc.getType().getIntValue());
groupDescBuff.writeZero(GROUP_DESC_PADDING);
groupDescBuff.writeInt(groupDesc.getGroupId().getValue().intValue());
for (BucketsList bucket : groupDesc.getBucketsList()) {
ByteBuf bucketBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
bucketBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
bucketBuff.writeShort(bucket.getWeight());
bucketBuff.writeInt(bucket.getWatchPort().getValue().intValue());
bucketBuff.writeInt(bucket.getWatchGroup().intValue());
bucketBuff.writeZero(BUCKET_PADDING);
ListSerializer.serializeList(bucket.getAction(), TypeKeyMakerFactory.createActionKeyMaker(message.getVersion()), registry, bucketBuff);
bucketBuff.setShort(BUCKET_LENGTH_INDEX, bucketBuff.readableBytes());
groupDescBuff.writeBytes(bucketBuff);
}
groupDescBuff.setShort(GROUP_DESC_LENGTH_INDEX, groupDescBuff.readableBytes());
outBuffer.writeBytes(groupDescBuff);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeDescBody.
private void serializeDescBody(final MultipartReplyBody body, final 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 MultipartReplyFlowStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyFlowStatsBuilder builder = new MultipartReplyFlowStatsBuilder();
final List<FlowAndStatisticsMapList> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final FlowAndStatisticsMapListBuilder itemBuilder = new FlowAndStatisticsMapListBuilder();
final int itemLength = message.readUnsignedShort();
final ByteBuf itemMessage = message.readSlice(itemLength - EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
itemBuilder.setTableId(itemMessage.readUnsignedByte());
itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
itemBuilder.setDuration(new DurationBuilder().setSecond(new Counter32(itemMessage.readUnsignedInt())).setNanosecond(new Counter32(itemMessage.readUnsignedInt())).build()).setPriority(itemMessage.readUnsignedShort()).setIdleTimeout(itemMessage.readUnsignedShort()).setHardTimeout(itemMessage.readUnsignedShort()).setFlags(createFlowModFlagsFromBitmap(itemMessage.readUnsignedShort()));
itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
final byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
itemMessage.readBytes(cookie);
final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
itemMessage.readBytes(packetCount);
final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
itemMessage.readBytes(byteCount);
itemBuilder.setCookie(new FlowCookie(new BigInteger(1, cookie))).setCookieMask(new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount)));
final OFDeserializer<Match> matchDeserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
itemBuilder.setMatch(MatchUtil.transformMatch(matchDeserializer.deserialize(itemMessage), org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match.class));
final int length = itemMessage.readableBytes();
if (length > 0) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> instructions = new ArrayList<>();
final int startIndex = itemMessage.readerIndex();
int offset = 0;
while (itemMessage.readerIndex() - startIndex < length) {
instructions.add(new InstructionBuilder().setKey(new InstructionKey(offset)).setOrder(offset).setInstruction(InstructionUtil.readInstruction(EncodeConstants.OF13_VERSION_ID, itemMessage, registry)).build());
offset++;
}
itemBuilder.setInstructions(new InstructionsBuilder().setInstruction(instructions).build());
}
items.add(itemBuilder.build());
}
return builder.setFlowAndStatisticsMapList(items).build();
}
Aggregations