use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata in project openflowplugin by opendaylight.
the class WriteMetadataCase method process.
@Override
public Optional<Instruction> process(@Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
WriteMetadata writeMetadata = source.getWriteMetadata();
WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
writeMetadataBuilder.setMetadata(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadata(), OFConstants.SIZE_OF_LONG_IN_BYTES));
writeMetadataBuilder.setMetadataMask(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadataMask(), OFConstants.SIZE_OF_LONG_IN_BYTES));
writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
InstructionBuilder instructionBuilder = new InstructionBuilder();
instructionBuilder.setInstructionChoice(writeMetadataCaseBuilder.build());
return Optional.of(instructionBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata in project genius by opendaylight.
the class IfmUtil method mergeOpenflowMetadataWriteInstructions.
public static BigInteger[] mergeOpenflowMetadataWriteInstructions(List<Instruction> instructions) {
BigInteger metadata = new BigInteger("0", 16);
BigInteger metadataMask = new BigInteger("0", 16);
if (instructions != null && !instructions.isEmpty()) {
// check if metadata write instruction is present
for (Instruction instruction : instructions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction actualInstruction = instruction.getInstruction();
if (actualInstruction instanceof WriteMetadataCase) {
WriteMetadataCase writeMetaDataInstruction = (WriteMetadataCase) actualInstruction;
WriteMetadata availableMetaData = writeMetaDataInstruction.getWriteMetadata();
metadata = metadata.or(availableMetaData.getMetadata());
metadataMask = metadataMask.or(availableMetaData.getMetadataMask());
}
}
}
return new BigInteger[] { metadata, metadataMask };
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata in project genius by opendaylight.
the class InstructionWriteMetadataTest method verifyInstructionInfo.
private void verifyInstructionInfo(InstructionInfo instructionInfo) {
Instruction instruction = instructionInfo.buildInstruction(2);
assertEquals(2, instruction.getKey().getOrder().intValue());
assertTrue(instruction.getInstruction() instanceof WriteMetadataCase);
WriteMetadataCase writeMetadataCase = (WriteMetadataCase) instruction.getInstruction();
WriteMetadata writeMetadata = writeMetadataCase.getWriteMetadata();
assertEquals(BigInteger.ONE, writeMetadata.getMetadata());
assertEquals(BigInteger.TEN, writeMetadata.getMetadataMask());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata in project openflowplugin by opendaylight.
the class WriteMetadataInstructionSerializer method serialize.
@Override
public void serialize(WriteMetadataCase input, ByteBuf outBuffer) {
super.serialize(input, outBuffer);
final WriteMetadata writeMetadata = input.getWriteMetadata();
outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
outBuffer.writeBytes(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadata(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
outBuffer.writeBytes(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadataMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata in project openflowplugin by opendaylight.
the class WriteMetadataInstructionSerializer method serialize.
@Override
public void serialize(Instruction instruction, ByteBuf outBuffer) {
outBuffer.writeShort(getType());
outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH);
outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
WriteMetadata metadata = ((WriteMetadataCase) instruction.getInstructionChoice()).getWriteMetadata();
outBuffer.writeBytes(metadata.getMetadata());
outBuffer.writeBytes(metadata.getMetadataMask());
}
Aggregations