use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class ActionUtil method readAction.
/**
* Deserialize OpenFlow action, using extension converter if available.
* TODO: Remove also extension converters
*
* @param version OpenFlow version
* @param message OpenFlow buffered message
* @param registry deserializer registry
* @param path Action path
*/
public static Action readAction(short version, ByteBuf message, DeserializerRegistry registry, ActionPath path) {
int type = message.getUnsignedShort(message.readerIndex());
Long expId = null;
if (type == EncodeConstants.EXPERIMENTER_VALUE) {
expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
}
try {
final MessageCodeExperimenterKey key = new MessageCodeExperimenterKey(version, type, Action.class, expId);
final OFDeserializer<Action> deserializer = registry.getDeserializer(key);
return deserializer.deserialize(message);
} catch (ClassCastException | IllegalStateException e) {
final MessageCodeKey key = Objects.nonNull(expId) ? new ExperimenterActionDeserializerKey(version, expId) : new ActionDeserializerKey(version, type, expId);
final OFDeserializer<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> deserializer = registry.getDeserializer(key);
return ActionExtensionHelper.processAlienAction(deserializer.deserialize(message), OpenflowVersion.get(version), path);
}
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class MultipartRequestInputMessageFactory method setAggregate.
private MultipartRequestAggregateCase setAggregate(ByteBuf input) {
final MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder();
aggregateBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(AGGREGATE_PADDING_1);
aggregateBuilder.setOutPort(input.readUnsignedInt());
aggregateBuilder.setOutGroup(input.readUnsignedInt());
input.skipBytes(AGGREGATE_PADDING_2);
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(cookie);
aggregateBuilder.setCookie(new BigInteger(1, cookie));
final byte[] cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(cookieMask);
aggregateBuilder.setCookieMask(new BigInteger(1, cookieMask));
OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
aggregateBuilder.setMatch(matchDeserializer.deserialize(input));
caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build());
return caseBuilder.build();
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class OF10FlowModInputMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public FlowModInput deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
FlowModInputBuilder builder = new FlowModInputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
builder.setMatchV10(matchDeserializer.deserialize(rawMessage));
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(cookie);
builder.setCookie(new BigInteger(1, cookie));
builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedShort()));
builder.setIdleTimeout(rawMessage.readUnsignedShort());
builder.setHardTimeout(rawMessage.readUnsignedShort());
builder.setPriority(rawMessage.readUnsignedShort());
builder.setBufferId(rawMessage.readUnsignedInt());
builder.setOutPort(new PortNumber((long) rawMessage.readUnsignedShort()));
builder.setFlagsV10(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort()));
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, rawMessage.readableBytes(), rawMessage, keyMaker, registry);
builder.setAction(actions);
return builder.build();
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactory method setAggregate.
private MultipartRequestAggregateCase setAggregate(ByteBuf input) {
final MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder();
OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
aggregateBuilder.setMatchV10(matchDeserializer.deserialize(input));
aggregateBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(AGGREGATE_PADDING_1);
aggregateBuilder.setOutPort((long) input.readUnsignedShort());
caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build());
return caseBuilder.build();
}
use of org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactory method setFlow.
private MultipartRequestFlowCase setFlow(ByteBuf input) {
final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
flowBuilder.setMatchV10(matchDeserializer.deserialize(input));
flowBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(FLOW_PADDING_1);
flowBuilder.setOutPort((long) input.readUnsignedShort());
caseBuilder.setMultipartRequestFlow(flowBuilder.build());
return caseBuilder.build();
}
Aggregations