use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match 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.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.
the class Ipv6ExtHeaderEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Ipv6ExtHeaderBuilder extHeaderBuilder = new Ipv6ExtHeaderBuilder().setIpv6Exthdr(message.readUnsignedShort());
if (hasMask) {
final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
extHeaderBuilder.setIpv6ExthdrMask(ByteUtil.bytesToUnsignedShort(mask));
}
if (Objects.isNull(builder.getLayer3Match())) {
builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6ExtHeader(extHeaderBuilder.build()).build());
} else if (Ipv6Match.class.isInstance(builder.getLayer3Match()) && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6ExtHeader())) {
final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
builder.setLayer3Match(new Ipv6MatchBuilder(match).setIpv6ExtHeader(extHeaderBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "ipv6ExtHeader");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.
the class Ipv6NdTllEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
processHeader(message);
final MacAddress address = OxmDeserializerHelper.convertMacAddress(message);
if (Objects.isNull(builder.getLayer3Match())) {
builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6NdTll(address).build());
} else if (Ipv6Match.class.isInstance(builder.getLayer3Match()) && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6NdTll())) {
final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
builder.setLayer3Match(new Ipv6MatchBuilder(match).setIpv6NdTll(address).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "ipv6NdTll");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.
the class MatchDeserializer method deserializeHeader.
@Override
public Match deserializeHeader(ByteBuf inBuffer) {
final MatchBuilder builder = new MatchBuilder();
deserializeEntry(inBuffer, builder);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.
the class MatchDeserializer method deserialize.
@Override
public Match deserialize(ByteBuf inBuffer) {
if (inBuffer.readableBytes() <= 0) {
return null;
}
final MatchBuilder builder = new MatchBuilder();
// OFP do not have any method to differentiate between OXM and standard match, so we do not care about type
inBuffer.readUnsignedShort();
final int length = inBuffer.readUnsignedShort();
final int startIndex = inBuffer.readerIndex();
final int entriesLength = length - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
while (inBuffer.readerIndex() - startIndex < entriesLength) {
deserializeEntry(inBuffer, builder);
}
int paddingRemainder = length % EncodeConstants.PADDING;
if (paddingRemainder != 0) {
inBuffer.skipBytes(EncodeConstants.PADDING - paddingRemainder);
}
return builder.build();
}
Aggregations