use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyTableFeaturesDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
final List<TableFeatures> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final int itemLength = message.readUnsignedShort();
final TableFeaturesBuilder itemBuilder = new TableFeaturesBuilder().setTableId(message.readUnsignedByte());
message.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
final String name = ByteBufUtils.decodeNullTerminatedString(message, MAX_TABLE_NAME_LENGTH);
final byte[] match = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(match);
final byte[] write = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(write);
items.add(itemBuilder.setKey(new TableFeaturesKey(itemBuilder.getTableId())).setName(name).setMetadataMatch(new BigInteger(1, match)).setMetadataWrite(new BigInteger(1, write)).setConfig(readTableConfig(message)).setMaxEntries(message.readUnsignedInt()).setTableProperties(readTableProperties(message, itemLength - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH)).build());
}
return builder.setTableFeatures(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translate.
public static Optional<? extends MultipartReplyBody> translate(final OfHeader message, final DeviceInfo deviceInfo, @Nullable final ConvertorExecutor convertorExecutor, @Nullable final TranslatorLibrary translatorLibrary) {
if (message instanceof MultipartReply) {
final Optional<ConvertorExecutor> convertor = Optional.ofNullable(convertorExecutor);
final Optional<TranslatorLibrary> translator = Optional.ofNullable(translatorLibrary);
final MultipartReply msg = MultipartReply.class.cast(message);
final OpenflowVersion ofVersion = OpenflowVersion.get(deviceInfo.getVersion());
final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
data.setDatapathId(deviceInfo.getDatapathId());
switch(msg.getType()) {
case OFPMPFLOW:
return convertor.flatMap(c -> Optional.of(translateFlow(msg, data, c)));
case OFPMPAGGREGATE:
return Optional.of(translateAggregate(msg));
case OFPMPPORTSTATS:
return Optional.of(translatePortStats(msg, ofVersion, deviceInfo.getDatapathId()));
case OFPMPGROUP:
return convertor.flatMap(c -> Optional.of(translateGroup(msg, data, c)));
case OFPMPGROUPDESC:
return convertor.flatMap(c -> Optional.of(translateGroupDesc(msg, data, c)));
case OFPMPGROUPFEATURES:
return Optional.of(translateGroupFeatures(msg));
case OFPMPMETER:
return convertor.flatMap(c -> Optional.of(translateMeter(msg, data, c)));
case OFPMPMETERCONFIG:
return convertor.flatMap(c -> Optional.of(translateMeterConfig(msg, data, c)));
case OFPMPMETERFEATURES:
return Optional.of(translateMeterFeatures(msg));
case OFPMPTABLE:
return Optional.of(translateTable(msg));
case OFPMPQUEUE:
return Optional.of(translateQueue(msg, ofVersion, deviceInfo.getDatapathId()));
case OFPMPDESC:
return Optional.of(translateDesc(msg));
case OFPMPTABLEFEATURES:
return convertor.flatMap(c -> Optional.of(translateTableFeatures(msg, deviceInfo.getVersion(), c)));
case OFPMPPORTDESC:
return translator.flatMap(t -> Optional.of(translatePortDesc(msg, deviceInfo, t)));
default:
}
} else if (message instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) {
return Optional.of(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply.class.cast(message).getMultipartReplyBody());
}
LOG.debug("Failed to translate {} for node {}.", message.getImplementedInterface(), deviceInfo);
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeTableFeaturesBody.
private void serializeTableFeaturesBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) body;
MultipartReplyTableFeatures tableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures();
for (TableFeatures tableFeature : tableFeatures.getTableFeatures()) {
ByteBuf tableFeatureBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
tableFeatureBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
tableFeatureBuff.writeByte(tableFeature.getTableId());
tableFeatureBuff.writeZero(TABLE_FEATURES_PADDING);
write32String(tableFeature.getName(), tableFeatureBuff);
tableFeatureBuff.writeBytes(tableFeature.getMetadataMatch());
tableFeatureBuff.writeZero(64 - tableFeature.getMetadataMatch().length);
tableFeatureBuff.writeBytes(tableFeature.getMetadataWrite());
tableFeatureBuff.writeZero(64 - tableFeature.getMetadataWrite().length);
writeTableConfig(tableFeature.getConfig(), tableFeatureBuff);
tableFeatureBuff.writeInt(tableFeature.getMaxEntries().intValue());
for (TableFeatureProperties tableFeatureProp : tableFeature.getTableFeatureProperties()) {
switch(tableFeatureProp.getType()) {
case OFPTFPTINSTRUCTIONS:
writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_CODE);
break;
case OFPTFPTINSTRUCTIONSMISS:
writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_MISS_CODE);
break;
case OFPTFPTNEXTTABLES:
writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_CODE);
break;
case OFPTFPTNEXTTABLESMISS:
writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_MISS_CODE);
break;
case OFPTFPTWRITEACTIONS:
writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_CODE);
break;
case OFPTFPTWRITEACTIONSMISS:
writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_MISS_CODE);
break;
case OFPTFPTAPPLYACTIONS:
writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_CODE);
break;
case OFPTFPTAPPLYACTIONSMISS:
writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_MISS_CODE);
break;
case OFPTFPTMATCH:
writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, MATCH_CODE);
break;
case OFPTFPTWILDCARDS:
writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WILDCARDS_CODE);
break;
case OFPTFPTWRITESETFIELD:
writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_CODE);
break;
case OFPTFPTWRITESETFIELDMISS:
writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_MISS_CODE);
break;
case OFPTFPTAPPLYSETFIELD:
writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_CODE);
break;
case OFPTFPTAPPLYSETFIELDMISS:
writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_MISS_CODE);
break;
case OFPTFPTEXPERIMENTER:
case OFPTFPTEXPERIMENTERMISS:
writeExperimenterRelatedTableProperty(tableFeatureBuff, tableFeatureProp);
break;
default:
break;
}
}
tableFeatureBuff.setShort(TABLE_FEATURES_LENGTH_INDEX, tableFeatureBuff.readableBytes());
outBuffer.writeBytes(tableFeatureBuff);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeFlowBody.
private void serializeFlowBody(final MultipartReplyBody body, final ByteBuf outBuffer, final MultipartReplyMessage message) {
MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
for (FlowStats flowStats : flow.getFlowStats()) {
ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
flowStatsBuff.writeByte((byte) flowStats.getTableId().longValue());
flowStatsBuff.writeZero(FLOW_STATS_PADDING_1);
flowStatsBuff.writeInt(flowStats.getDurationSec().intValue());
flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue());
flowStatsBuff.writeShort(flowStats.getPriority());
flowStatsBuff.writeShort(flowStats.getIdleTimeout());
flowStatsBuff.writeShort(flowStats.getHardTimeout());
flowStatsBuff.writeZero(FLOW_STATS_PADDING_2);
flowStatsBuff.writeLong(flowStats.getCookie().longValue());
flowStatsBuff.writeLong(flowStats.getPacketCount().longValue());
flowStatsBuff.writeLong(flowStats.getByteCount().longValue());
OFSerializer<Match> matchSerializer = registry.<Match, OFSerializer<Match>>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class));
matchSerializer.serialize(flowStats.getMatch(), flowStatsBuff);
ListSerializer.serializeList(flowStats.getInstruction(), TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion()), registry, flowStatsBuff);
flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes());
outBuffer.writeBytes(flowStatsBuff);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializeQueueBody.
private void serializeQueueBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body;
MultipartReplyQueue queue = queueCase.getMultipartReplyQueue();
for (QueueStats queueStats : queue.getQueueStats()) {
outBuffer.writeInt(queueStats.getPortNo().intValue());
outBuffer.writeInt(queueStats.getQueueId().intValue());
outBuffer.writeLong(queueStats.getTxBytes().longValue());
outBuffer.writeLong(queueStats.getTxPackets().longValue());
outBuffer.writeLong(queueStats.getTxErrors().longValue());
outBuffer.writeInt(queueStats.getDurationSec().intValue());
outBuffer.writeInt(queueStats.getDurationNsec().intValue());
}
}
Aggregations