use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessageBuilder in project openflowplugin by opendaylight.
the class FlowMessageDeserializer method deserialize.
@Override
@SuppressWarnings("checkstyle:LineLength")
public FlowMessage deserialize(ByteBuf message) {
final FlowMessageBuilder builder = new FlowMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCookie(new FlowCookie(BigInteger.valueOf(message.readLong()))).setCookieMask(new FlowCookie(BigInteger.valueOf(message.readLong()))).setTableId(message.readUnsignedByte()).setCommand(FlowModCommand.forValue(message.readUnsignedByte())).setIdleTimeout(message.readUnsignedShort()).setHardTimeout(message.readUnsignedShort()).setPriority(message.readUnsignedShort()).setBufferId(message.readUnsignedInt()).setOutPort(BigInteger.valueOf(message.readUnsignedInt())).setOutGroup(message.readUnsignedInt()).setFlags(createFlowModFlagsFromBitmap(message.readUnsignedShort()));
message.skipBytes(PADDING);
final OFDeserializer<Match> matchDeserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
builder.setMatch(new MatchBuilder(matchDeserializer.deserialize(message)).build());
final int length = message.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 = message.readerIndex();
int offset = 0;
while (message.readerIndex() - startIndex < length) {
final int type = message.getUnsignedShort(message.readerIndex());
OFDeserializer<Instruction> deserializer = null;
if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeActionExperimenterKey(EncodeConstants.OF13_VERSION_ID, type, Instruction.class, ActionPath.INVENTORY_FLOWNODE_TABLE_APPLY_ACTIONS, null));
} else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeActionExperimenterKey(EncodeConstants.OF13_VERSION_ID, type, Instruction.class, ActionPath.INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS, null));
} else {
Long expId = null;
if (EncodeConstants.EXPERIMENTER_VALUE == type) {
expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
}
deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeExperimenterKey(EncodeConstants.OF13_VERSION_ID, type, Instruction.class, expId));
}
instructions.add(new InstructionBuilder().setKey(new InstructionKey(offset)).setOrder(offset).setInstruction(deserializer.deserialize(message)).build());
offset++;
}
builder.setInstructions(new InstructionsBuilder().setInstruction(instructions).build());
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessageBuilder in project openflowplugin by opendaylight.
the class SingleLayerFlowService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final Flow input) throws ServiceException {
final FlowMessageBuilder flowMessageBuilder = new FlowMessageBuilder(input);
final Class<? extends DataContainer> clazz = input.getImplementedInterface();
if (clazz.equals(AddFlowInput.class) || clazz.equals(UpdatedFlow.class)) {
flowMessageBuilder.setCommand(FlowModCommand.OFPFCADD);
} else if (clazz.equals(RemoveFlowInput.class) || clazz.equals(OriginalFlow.class)) {
flowMessageBuilder.setCommand(Boolean.TRUE.equals(input.isStrict()) ? FlowModCommand.OFPFCDELETESTRICT : FlowModCommand.OFPFCDELETE);
}
return flowMessageBuilder.setVersion(getVersion()).setXid(xid.getValue()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessageBuilder in project openflowplugin by opendaylight.
the class FlowMessageSerializer method writeVlanFlow.
/**
* Instead of serializing this flow normally, we need to split it to two parts if flow contains
* #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase}.
*
* @param message flow mod message
* @param outBuffer output buffer
*/
private void writeVlanFlow(final FlowMessage message, final ByteBuf outBuffer) {
writeFlow(new FlowMessageBuilder(message).setMatch(new MatchBuilder(message.getMatch()).setVlanMatch(VLAN_MATCH_FALSE).build()).setInstructions(new InstructionsBuilder().setInstruction(updateSetVlanIdAction(message)).build()).build(), outBuffer);
writeFlow(new FlowMessageBuilder(message).setMatch(new MatchBuilder(message.getMatch()).setVlanMatch(VLAN_MATCH_TRUE).build()).build(), outBuffer);
}
Aggregations